Skip to content

Commit

Permalink
fix safe transaction proposal nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoVS09 committed Jul 21, 2024
1 parent d7d10f2 commit 2feb468
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/contracts/hardhat/deployment/addresses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { EonianHealthCheck } from './EonianHealthCheck'
import { EonianTreasury } from './EonianTreasury'
import { Chainlink } from './Chainlink'

/** Allow to execute attach transactions without deployments */
export const forceAttachTransactions = () => process.env.FORCE_ATTACH_TRANSACTIONS === 'true'

export enum Addresses {
APESWAP = 'APESWAP',
CHAINLINK = 'CHAINLINK',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { HardhatRuntimeEnvironment } from 'hardhat/types'
import { TokenSymbol, needUseSafe, sendTxWithRetry } from '@eonian/upgradeable'
import { type ApeLendingStrategy } from '../../typechain-types'
import { type DeployResult, DeployStatus } from '@eonian/upgradeable'
import { Addresses } from './addresses'
import { BaseContract, Contract } from 'ethers'
import { Addresses, forceAttachTransactions } from './addresses'
import { BaseContract } from 'ethers'

const contractName = 'ApeLendingStrategy'

Expand All @@ -24,7 +24,7 @@ export default async function deployApeLendingStrategy(token: TokenSymbol, hre:

const deployResult = await hre.deploy(contractName, token, initializeArguments)

if (deployResult.status === DeployStatus.DEPLOYED) {
if (deployResult.status === DeployStatus.DEPLOYED || forceAttachTransactions()) {
await attachToVault(deployResult.proxyAddress, token, addresses.vault, hre)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/hardhat/deployment/deployVFT.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types'
import { type DeployResult, type TokenSymbol, DeployStatus, sendTxWithRetry, needUseSafe } from '@eonian/upgradeable'
import type { VaultFounderToken } from '../../typechain-types'
import { Addresses } from './addresses'
import { Addresses, forceAttachTransactions } from './addresses'
import { BaseContract } from 'ethers'

const contractName = 'VaultFounderToken'
Expand All @@ -18,7 +18,7 @@ export default async function deployVFT(token: TokenSymbol, hre: HardhatRuntimeE
]
const deployResult = await hre.deploy(contractName, token, initializeArguments)

if (deployResult.status === DeployStatus.DEPLOYED) {
if (deployResult.status === DeployStatus.DEPLOYED || forceAttachTransactions()) {
await attachToVault(deployResult.proxyAddress, token, addresses.vault, hre)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/upgradeable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eonian/upgradeable",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"engines": {
"node": ">=20.0.0"
Expand Down
10 changes: 9 additions & 1 deletion packages/upgradeable/src/plugins/SafeAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ export class SafeAdapter extends WithLogger {
const {signerAddress, wallet} = await this.getSafeWallet(signer)
this.log(`Retrived Safe wallet with address ${await wallet.getAddress()} and signer: "${signerAddress}"`)

const nextNonce = await this.api.getNextNonce(this.walletAddress)
this.log(`Will propose new transaction with nonce ${nextNonce}`)

const tx = await wallet.createTransaction({
transactions: [{
to: address,
value: '0',
data: txData
}]
}],
options: {
// by default api proposes transactions without checking for transaction in the queue
// as a result all transactions will have same nonce and only one can be executed
nonce: nextNonce
}
})

// Deterministic hash based on transaction parameters
Expand Down

0 comments on commit 2feb468

Please sign in to comment.