From 018cbf20d6f02b508597bd2edc087bbad7b732f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Sat, 16 Jul 2022 18:40:18 +0200 Subject: [PATCH 01/16] Update TranscationOptions type --- .../src/ethereumLibs/EthAdapter.ts | 2 ++ packages/safe-core-sdk-types/src/types.ts | 2 ++ packages/safe-core-sdk/README.md | 24 ++++++++++++++----- packages/safe-core-sdk/src/Safe.ts | 2 +- packages/safe-ethers-lib/src/types.ts | 2 ++ packages/safe-web3-lib/src/types.ts | 2 ++ 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/safe-core-sdk-types/src/ethereumLibs/EthAdapter.ts b/packages/safe-core-sdk-types/src/ethereumLibs/EthAdapter.ts index 099da7497..0aadeffe4 100644 --- a/packages/safe-core-sdk-types/src/ethereumLibs/EthAdapter.ts +++ b/packages/safe-core-sdk-types/src/ethereumLibs/EthAdapter.ts @@ -13,6 +13,8 @@ export interface EthAdapterTransaction { value?: string gasPrice?: number gasLimit?: number + maxFeePerGas?: number | string + maxPriorityFeePerGas?: number | string } export interface GetContractProps { diff --git a/packages/safe-core-sdk-types/src/types.ts b/packages/safe-core-sdk-types/src/types.ts index ad7fb06d3..c331f382f 100644 --- a/packages/safe-core-sdk-types/src/types.ts +++ b/packages/safe-core-sdk-types/src/types.ts @@ -54,6 +54,8 @@ export interface TransactionOptions { gas?: number | string gasLimit?: number | string gasPrice?: number | string + maxFeePerGas?: number | string + maxPriorityFeePerGas?: number | string } export interface BaseTransactionResult { diff --git a/packages/safe-core-sdk/README.md b/packages/safe-core-sdk/README.md index aca189fe1..1c423566a 100644 --- a/packages/safe-core-sdk/README.md +++ b/packages/safe-core-sdk/README.md @@ -231,14 +231,18 @@ Optionally, some properties can be passed as execution options: const options: Web3TransactionOptions = { from, // Optional gas, // Optional - gasPrice // Optional + gasPrice, // Optional + maxFeePerGas, // Optional + maxPriorityFeePerGas // Optional } ``` ```js const options: EthersTransactionOptions = { from, // Optional gasLimit, // Optional - gasPrice // Optional + gasPrice, // Optional + maxFeePerGas, // Optional + maxPriorityFeePerGas // Optional } ``` ```js @@ -590,14 +594,18 @@ Optionally, some properties can be passed as execution options: const options: Web3TransactionOptions = { from, // Optional gas, // Optional - gasPrice // Optional + gasPrice, // Optional + maxFeePerGas, // Optional + maxPriorityFeePerGas // Optional } ``` ```js const options: EthersTransactionOptions = { from, // Optional gasLimit, // Optional - gasPrice // Optional + gasPrice, // Optional + maxFeePerGas, // Optional + maxPriorityFeePerGas // Optional } ``` ```js @@ -757,14 +765,18 @@ Optionally, some properties can be passed as execution options: const options: Web3TransactionOptions = { from, // Optional gas, // Optional - gasPrice // Optional + gasPrice, // Optional + maxFeePerGas, // Optional + maxPriorityFeePerGas // Optional } ``` ```js const options: EthersTransactionOptions = { from, // Optional gasLimit, // Optional - gasPrice // Optional + gasPrice, // Optional + maxFeePerGas, // Optional + maxPriorityFeePerGas // Optional } ``` ```js diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index a09b6cb8e..2a78ca673 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -580,7 +580,7 @@ class Safe { * Executes a Safe transaction. * * @param safeTransaction - The Safe transaction to execute - * @param options - The Safe transaction execution options (gasLimit, gasPrice) + * @param options - The Safe transaction execution options (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) * @returns The Safe transaction response * @throws "No signer provided" * @throws "There are X signatures missing" diff --git a/packages/safe-ethers-lib/src/types.ts b/packages/safe-ethers-lib/src/types.ts index e00725828..b1b9838e3 100644 --- a/packages/safe-ethers-lib/src/types.ts +++ b/packages/safe-ethers-lib/src/types.ts @@ -5,6 +5,8 @@ export interface EthersTransactionOptions { from?: string gasLimit?: number | string gasPrice?: number | string + maxFeePerGas?: number | string + maxPriorityFeePerGas?: number | string } export interface EthersTransactionResult extends BaseTransactionResult { diff --git a/packages/safe-web3-lib/src/types.ts b/packages/safe-web3-lib/src/types.ts index 148337b31..6e7b77ec1 100644 --- a/packages/safe-web3-lib/src/types.ts +++ b/packages/safe-web3-lib/src/types.ts @@ -5,6 +5,8 @@ export interface Web3TransactionOptions { from?: string gas?: number | string gasPrice?: number | string + maxFeePerGas?: number | string + maxPriorityFeePerGas?: number | string } export interface Web3TransactionResult extends BaseTransactionResult { From 5035db1a0f3fd5a9618d04c40b18a3b86607a621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 07:30:35 +0200 Subject: [PATCH 02/16] Replace Rinkeby config with Goerli --- packages/safe-core-sdk/hardhat.config.ts | 6 +++--- packages/safe-ethers-adapters/.env.sample | 2 +- packages/safe-service-client/hardhat.config.ts | 8 ++++---- .../safe-service-client/scripts/generateTxServiceTypes.sh | 2 +- .../tests/e2e/getSafesByModule.test.ts | 6 +++--- packages/safe-service-client/tests/endpoint/index.test.ts | 2 +- packages/safe-service-client/tests/utils/config.ts | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/safe-core-sdk/hardhat.config.ts b/packages/safe-core-sdk/hardhat.config.ts index f3071bcb2..be719b2d6 100644 --- a/packages/safe-core-sdk/hardhat.config.ts +++ b/packages/safe-core-sdk/hardhat.config.ts @@ -27,7 +27,7 @@ if (PK) { } } -if (['rinkeby'].includes(argv.network) && INFURA_KEY === undefined) { +if (['goerli'].includes(argv.network) && INFURA_KEY === undefined) { throw new Error( `Could not find Infura key in env, unable to connect to network ${argv.network}`, ) @@ -70,9 +70,9 @@ const config: HardhatUserConfig = { { balance: '100000000000000000000', privateKey: '0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773' }, ] }, - rinkeby: { + goerli: { ...sharedNetworkConfig, - url: `https://rinkeby.infura.io/v3/${INFURA_KEY}`, + url: `https://goerli.infura.io/v3/${INFURA_KEY}`, } }, namedAccounts: { diff --git a/packages/safe-ethers-adapters/.env.sample b/packages/safe-ethers-adapters/.env.sample index 04f2e3747..9d0d9094e 100644 --- a/packages/safe-ethers-adapters/.env.sample +++ b/packages/safe-ethers-adapters/.env.sample @@ -1,4 +1,4 @@ JSON_RPC= SIGNER_KEY= DEPLOYER_SAFE= -SERVICE_URL=https://safe-transaction.rinkeby.gnosis.io \ No newline at end of file +SERVICE_URL=https://safe-transaction.goerli.gnosis.io \ No newline at end of file diff --git a/packages/safe-service-client/hardhat.config.ts b/packages/safe-service-client/hardhat.config.ts index 6a4425ff5..892fe5557 100644 --- a/packages/safe-service-client/hardhat.config.ts +++ b/packages/safe-service-client/hardhat.config.ts @@ -26,14 +26,14 @@ if (PK) { } } -if (['rinkeby'].includes(argv.network) && INFURA_KEY === undefined) { +if (['goerli'].includes(argv.network) && INFURA_KEY === undefined) { throw new Error( `Could not find Infura key in env, unable to connect to network ${argv.network}`, ) } const config: HardhatUserConfig = { - defaultNetwork: "rinkeby", + defaultNetwork: "goerli", paths: { tests: TESTS_PATH }, @@ -43,9 +43,9 @@ const config: HardhatUserConfig = { blockGasLimit: 100000000, gas: 100000000 }, - rinkeby: { + goerli: { ...sharedNetworkConfig, - url: `https://rinkeby.infura.io/v3/${INFURA_KEY}`, + url: `https://goerli.infura.io/v3/${INFURA_KEY}`, } } } diff --git a/packages/safe-service-client/scripts/generateTxServiceTypes.sh b/packages/safe-service-client/scripts/generateTxServiceTypes.sh index 70a437cdf..10ae35b96 100644 --- a/packages/safe-service-client/scripts/generateTxServiceTypes.sh +++ b/packages/safe-service-client/scripts/generateTxServiceTypes.sh @@ -1,5 +1,5 @@ #!/bin/bash mkdir -p openapi -curl 'https://safe-transaction.rinkeby.gnosis.io/?format=openapi' > openapi/tx-service.json +curl 'https://safe-transaction.goerli.gnosis.io/?format=openapi' > openapi/tx-service.json npx openapi-typescript openapi/tx-service.json --output openapi/tx-service.ts diff --git a/packages/safe-service-client/tests/e2e/getSafesByModule.test.ts b/packages/safe-service-client/tests/e2e/getSafesByModule.test.ts index cb93c5584..6c26edd13 100644 --- a/packages/safe-service-client/tests/e2e/getSafesByModule.test.ts +++ b/packages/safe-service-client/tests/e2e/getSafesByModule.test.ts @@ -7,7 +7,7 @@ import { getServiceClient } from '../utils/setupServiceClient' chai.use(chaiAsPromised) let serviceSdk: SafeServiceClient -const rinkebySpendingLimitModule = '0xCFbFaC74C26F8647cBDb8c5caf80BB5b32E43134' +const goerliSpendingLimitModule = '0xCFbFaC74C26F8647cBDb8c5caf80BB5b32E43134' describe('getSafesByModule', () => { before(async () => { @@ -38,14 +38,14 @@ describe('getSafesByModule', () => { }) it('should return the array Safes with the module enabled', async () => { - const moduleAddress = rinkebySpendingLimitModule + const moduleAddress = goerliSpendingLimitModule const moduleResponse = await serviceSdk.getSafesByModule(moduleAddress) const { safes } = moduleResponse chai.expect(safes.length).to.be.greaterThan(10) }) it('should return the array of Safes EIP-3770', async () => { - const moduleAddress = rinkebySpendingLimitModule + const moduleAddress = goerliSpendingLimitModule const eip3770ModuleAddress = `${config.EIP_3770_PREFIX}:${moduleAddress}` const moduleResponse = await serviceSdk.getSafesByModule(eip3770ModuleAddress) const { safes } = moduleResponse diff --git a/packages/safe-service-client/tests/endpoint/index.test.ts b/packages/safe-service-client/tests/endpoint/index.test.ts index f87ca7745..3b025eadc 100644 --- a/packages/safe-service-client/tests/endpoint/index.test.ts +++ b/packages/safe-service-client/tests/endpoint/index.test.ts @@ -30,7 +30,7 @@ const eip3770DelegateAddress = `${config.EIP_3770_PREFIX}:${delegateAddress}` const tokenAddress = '0xcb0591ba2d74edd4211d5200d5d3b19cf598c548' const eip3770TokenAddress = `${config.EIP_3770_PREFIX}:${tokenAddress}` const safeTxHash = '0xede78ed72e9a8afd2b7a21f35c86f56cba5fffb2fff0838e253b7a41d19ceb48' -const txServiceBaseUrl = 'https://safe-transaction.rinkeby.gnosis.io' +const txServiceBaseUrl = 'https://safe-transaction.goerli.gnosis.io' const provider = getDefaultProvider(config.JSON_RPC) const signer = new Wallet( '0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d', diff --git a/packages/safe-service-client/tests/utils/config.ts b/packages/safe-service-client/tests/utils/config.ts index 4e6919114..138c3d848 100644 --- a/packages/safe-service-client/tests/utils/config.ts +++ b/packages/safe-service-client/tests/utils/config.ts @@ -1,7 +1,7 @@ const config = { - BASE_URL: 'https://safe-transaction.rinkeby.gnosis.io', - JSON_RPC: `https://rinkeby.infura.io/v3/${process.env.INFURA_KEY}`, - EIP_3770_PREFIX: 'rin' + BASE_URL: 'https://safe-transaction.goerli.gnosis.io', + JSON_RPC: `https://goerli.infura.io/v3/${process.env.INFURA_KEY}`, + EIP_3770_PREFIX: 'gor' } export default config From 19091215d560f044df98aae9050d22159ee92274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 07:32:41 +0200 Subject: [PATCH 03/16] Fix Safe Service Client tests in Goerli --- .../tests/e2e/addSafeDelegate.test.ts | 12 +++--- .../tests/e2e/getBalances.test.ts | 26 ++++++------- .../tests/e2e/getCollectibles.test.ts | 20 +++++----- .../tests/e2e/getIncomingTransactions.test.ts | 14 +++---- .../tests/e2e/getMultisigTransactions.test.ts | 14 +++---- .../tests/e2e/getNextNonce.test.ts | 22 +++++------ .../tests/e2e/getPendingTransactions.test.ts | 8 ++-- .../tests/e2e/getSafeDelegates.test.ts | 6 +-- .../tests/e2e/getSafeInfo.test.ts | 6 +-- .../tests/e2e/getToken.test.ts | 10 ++--- .../tests/e2e/getTransaction.test.ts | 2 +- .../e2e/getTransactionConfirmations.test.ts | 2 +- .../tests/e2e/getUsdBalances.test.ts | 38 +++++++++---------- .../tests/e2e/removeAllSafeDelegates.test.ts | 8 ++-- .../tests/e2e/removeSafeDelegate.test.ts | 14 +++---- .../tests/endpoint/index.test.ts | 4 +- 16 files changed, 102 insertions(+), 104 deletions(-) diff --git a/packages/safe-service-client/tests/e2e/addSafeDelegate.test.ts b/packages/safe-service-client/tests/e2e/addSafeDelegate.test.ts index 32b78c830..ec32d7043 100644 --- a/packages/safe-service-client/tests/e2e/addSafeDelegate.test.ts +++ b/packages/safe-service-client/tests/e2e/addSafeDelegate.test.ts @@ -32,7 +32,7 @@ describe('addSafeDelegate', () => { }) it('should fail if Safe delegate address is empty', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '' const delegateConfig: SafeDelegateConfig = { safe: safeAddress, @@ -46,7 +46,7 @@ describe('addSafeDelegate', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const delegateConfig: SafeDelegateConfig = { safe: safeAddress, @@ -60,7 +60,7 @@ describe('addSafeDelegate', () => { }) it('should fail if Safe delegate address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'.toLowerCase() const delegateConfig: SafeDelegateConfig = { safe: safeAddress, @@ -88,7 +88,7 @@ describe('addSafeDelegate', () => { }) it('should fail if the signer is not an owner of the Safe', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const { serviceSdk, signer } = await getServiceClient( '0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773' @@ -105,7 +105,7 @@ describe('addSafeDelegate', () => { }) it('should add a new delegate', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const delegateConfig: SafeDelegateConfig = { safe: safeAddress, @@ -126,7 +126,7 @@ describe('addSafeDelegate', () => { }) it('should add a new delegate EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const eip3770DelegateAddress = `${config.EIP_3770_PREFIX}:${delegateAddress}` diff --git a/packages/safe-service-client/tests/e2e/getBalances.test.ts b/packages/safe-service-client/tests/e2e/getBalances.test.ts index cd10ec23a..728daa409 100644 --- a/packages/safe-service-client/tests/e2e/getBalances.test.ts +++ b/packages/safe-service-client/tests/e2e/getBalances.test.ts @@ -23,38 +23,38 @@ describe('getBalances', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.getBalances(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') }) it('should return the list of balances', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const balances = await serviceSdk.getBalances(safeAddress) chai.expect(balances.length).to.be.equal(2) const ethBalance = balances.filter((safeBalance) => !safeBalance.tokenAddress)[0] chai.expect(ethBalance.token).to.be.equal(null) - chai.expect(ethBalance.balance).to.be.equal('4000000000000000000') - const wethBalance = balances.filter( - (safeBalance) => safeBalance.tokenAddress === '0xc778417E063141139Fce010982780140Aa0cD5Ab' + chai.expect(ethBalance.balance).to.be.equal('100000000000000000') + const usdcBalance = balances.filter( + (safeBalance) => safeBalance.tokenAddress === '0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C' )[0] - chai.expect(wethBalance.token.symbol).to.be.equal('WETH') - chai.expect(wethBalance.balance).to.be.equal('10000000000000000') + chai.expect(usdcBalance.token.symbol).to.be.equal('USDC') + chai.expect(usdcBalance.balance).to.be.equal('1000000000') }) it('should return the list of balances EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const balances = await serviceSdk.getBalances(eip3770SafeAddress) chai.expect(balances.length).to.be.equal(2) const ethBalance = balances.filter((safeBalance) => !safeBalance.tokenAddress)[0] chai.expect(ethBalance.token).to.be.equal(null) - chai.expect(ethBalance.balance).to.be.equal('4000000000000000000') - const wethBalance = balances.filter( - (safeBalance) => safeBalance.tokenAddress === '0xc778417E063141139Fce010982780140Aa0cD5Ab' + chai.expect(ethBalance.balance).to.be.equal('100000000000000000') + const usdcBalance = balances.filter( + (safeBalance) => safeBalance.tokenAddress === '0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C' )[0] - chai.expect(wethBalance.token.symbol).to.be.equal('WETH') - chai.expect(wethBalance.balance).to.be.equal('10000000000000000') + chai.expect(usdcBalance.token.symbol).to.be.equal('USDC') + chai.expect(usdcBalance.balance).to.be.equal('1000000000') }) }) diff --git a/packages/safe-service-client/tests/e2e/getCollectibles.test.ts b/packages/safe-service-client/tests/e2e/getCollectibles.test.ts index 0ebb62d2b..71d18349f 100644 --- a/packages/safe-service-client/tests/e2e/getCollectibles.test.ts +++ b/packages/safe-service-client/tests/e2e/getCollectibles.test.ts @@ -23,32 +23,30 @@ describe('getCollectibles', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x72c346260a4887F0231af41178C1c818Ce34543f'.toLowerCase() await chai .expect(serviceSdk.getCollectibles(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') }) it('should return the list of collectibles', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x72c346260a4887F0231af41178C1c818Ce34543f' const safeCollectibleResponse = await serviceSdk.getCollectibles(safeAddress) - chai.expect(safeCollectibleResponse.length).to.be.equal(2) + chai.expect(safeCollectibleResponse.length).to.be.equal(1) safeCollectibleResponse.map((safeCollectible) => { - chai.expect(safeCollectible.address).to.be.equal('0x9cf1A34D70261f0594823EFCCeed53C8c639c464') - chai.expect(safeCollectible.tokenName).to.be.equal('Safe NFTs') - chai.expect(safeCollectible.metadata.type).to.be.equal('ERC721') + chai.expect(safeCollectible.address).to.be.equal('0x39Ec448b891c476e166b3C3242A90830DB556661') + chai.expect(safeCollectible.tokenName).to.be.equal('Frank\'s Art Sale') }) }) it('should return the list of collectibles EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x72c346260a4887F0231af41178C1c818Ce34543f' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const safeCollectibleResponse = await serviceSdk.getCollectibles(eip3770SafeAddress) - chai.expect(safeCollectibleResponse.length).to.be.equal(2) + chai.expect(safeCollectibleResponse.length).to.be.equal(1) safeCollectibleResponse.map((safeCollectible) => { - chai.expect(safeCollectible.address).to.be.equal('0x9cf1A34D70261f0594823EFCCeed53C8c639c464') - chai.expect(safeCollectible.tokenName).to.be.equal('Safe NFTs') - chai.expect(safeCollectible.metadata.type).to.be.equal('ERC721') + chai.expect(safeCollectible.address).to.be.equal('0x39Ec448b891c476e166b3C3242A90830DB556661') + chai.expect(safeCollectible.tokenName).to.be.equal('Frank\'s Art Sale') }) }) }) diff --git a/packages/safe-service-client/tests/e2e/getIncomingTransactions.test.ts b/packages/safe-service-client/tests/e2e/getIncomingTransactions.test.ts index eb4120fa3..fd2dd6f7f 100644 --- a/packages/safe-service-client/tests/e2e/getIncomingTransactions.test.ts +++ b/packages/safe-service-client/tests/e2e/getIncomingTransactions.test.ts @@ -23,7 +23,7 @@ describe('getIncomingTransactions', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.getIncomingTransactions(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') @@ -37,21 +37,21 @@ describe('getIncomingTransactions', () => { }) it('should return the list of incoming transactions', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' // Safe with incoming transactions + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with incoming transactions const transferListResponse = await serviceSdk.getIncomingTransactions(safeAddress) - chai.expect(transferListResponse.count).to.be.equal(10) - chai.expect(transferListResponse.results.length).to.be.equal(10) + chai.expect(transferListResponse.count).to.be.equal(3) + chai.expect(transferListResponse.results.length).to.be.equal(3) transferListResponse.results.map((transaction) => { chai.expect(transaction.to).to.be.equal(safeAddress) }) }) it('should return the list of incoming transactions EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' // Safe with incoming transactions + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with incoming transactions const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const transferListResponse = await serviceSdk.getIncomingTransactions(eip3770SafeAddress) - chai.expect(transferListResponse.count).to.be.equal(10) - chai.expect(transferListResponse.results.length).to.be.equal(10) + chai.expect(transferListResponse.count).to.be.equal(3) + chai.expect(transferListResponse.results.length).to.be.equal(3) transferListResponse.results.map((transaction) => { chai.expect(transaction.to).to.be.equal(safeAddress) }) diff --git a/packages/safe-service-client/tests/e2e/getMultisigTransactions.test.ts b/packages/safe-service-client/tests/e2e/getMultisigTransactions.test.ts index 99f01e547..521bc2235 100644 --- a/packages/safe-service-client/tests/e2e/getMultisigTransactions.test.ts +++ b/packages/safe-service-client/tests/e2e/getMultisigTransactions.test.ts @@ -23,7 +23,7 @@ describe('getMultisigTransactions', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.getMultisigTransactions(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') @@ -39,25 +39,25 @@ describe('getMultisigTransactions', () => { }) it('should return the list of multisig transactions', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' // Safe with multisig transactions + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with multisig transactions const safeMultisigTransactionListResponse = await serviceSdk.getMultisigTransactions( safeAddress ) - chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(11) - chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(11) + chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(9) + chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(9) safeMultisigTransactionListResponse.results.map((transaction) => { chai.expect(transaction.safe).to.be.equal(safeAddress) }) }) it('should return the list of multisig transactions EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' // Safe with multisig transactions + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with multisig transactions const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const safeMultisigTransactionListResponse = await serviceSdk.getMultisigTransactions( eip3770SafeAddress ) - chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(11) - chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(11) + chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(9) + chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(9) safeMultisigTransactionListResponse.results.map((transaction) => { chai.expect(transaction.safe).to.be.equal(safeAddress) }) diff --git a/packages/safe-service-client/tests/e2e/getNextNonce.test.ts b/packages/safe-service-client/tests/e2e/getNextNonce.test.ts index 033cd8a9a..ff598b5e3 100644 --- a/packages/safe-service-client/tests/e2e/getNextNonce.test.ts +++ b/packages/safe-service-client/tests/e2e/getNextNonce.test.ts @@ -22,21 +22,21 @@ describe('getNextNonce', () => { }) it('should return the next Safe nonce when there are pending transactions', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const nextNonce = await serviceSdk.getNextNonce(safeAddress) - chai.expect(nextNonce).to.be.equal(10) + chai.expect(nextNonce).to.be.equal(8) }) - it('should return the next Safe nonce when there are no pending transactions', async () => { - const safeAddress = '0x3e1ee196231490c8483df2D57403c7B814f91803' - const nextNonce = await serviceSdk.getNextNonce(safeAddress) - chai.expect(nextNonce).to.be.equal(0) - }) - - it('should return the next Safe nonce when there are no pending transactions EIP-3770', async () => { - const safeAddress = '0x3e1ee196231490c8483df2D57403c7B814f91803' + it('should return the next Safe nonce when there are pending transactions EIP-3770', async () => { + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const nextNonce = await serviceSdk.getNextNonce(eip3770SafeAddress) - chai.expect(nextNonce).to.be.equal(0) + chai.expect(nextNonce).to.be.equal(8) + }) + + it('should return the next Safe nonce when there are no pending transactions', async () => { + const safeAddress = '0x72c346260a4887F0231af41178C1c818Ce34543f' + const nextNonce = await serviceSdk.getNextNonce(safeAddress) + chai.expect(nextNonce).to.be.equal(3) }) }) diff --git a/packages/safe-service-client/tests/e2e/getPendingTransactions.test.ts b/packages/safe-service-client/tests/e2e/getPendingTransactions.test.ts index ecca53704..637c55f2e 100644 --- a/packages/safe-service-client/tests/e2e/getPendingTransactions.test.ts +++ b/packages/safe-service-client/tests/e2e/getPendingTransactions.test.ts @@ -23,28 +23,28 @@ describe('getPendingTransactions', () => { }) it('should fail if safeAddress is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.getPendingTransactions(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') }) it('should return an empty list if there are no pending transactions', async () => { - const safeAddress = '0x3e04a375aC5847C690A7f2fF54b45c59f7eeD6f0' // Safe without pending transaction + const safeAddress = '0x72c346260a4887F0231af41178C1c818Ce34543f' // Safe without pending transaction const transactionList = await serviceSdk.getPendingTransactions(safeAddress) chai.expect(transactionList.count).to.be.equal(0) chai.expect(transactionList.results.length).to.be.equal(0) }) it('should return the the transaction list', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' // Safe with pending transaction + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with pending transaction const transactionList = await serviceSdk.getPendingTransactions(safeAddress) chai.expect(transactionList.count).to.be.equal(2) chai.expect(transactionList.results.length).to.be.equal(2) }) it('should return the the transaction list EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' // Safe with pending transaction + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with pending transaction const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const transactionList = await serviceSdk.getPendingTransactions(eip3770SafeAddress) chai.expect(transactionList.count).to.be.equal(2) diff --git a/packages/safe-service-client/tests/e2e/getSafeDelegates.test.ts b/packages/safe-service-client/tests/e2e/getSafeDelegates.test.ts index 9bf2da508..197e8410c 100644 --- a/packages/safe-service-client/tests/e2e/getSafeDelegates.test.ts +++ b/packages/safe-service-client/tests/e2e/getSafeDelegates.test.ts @@ -25,7 +25,7 @@ describe('getSafeDelegates', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.getSafeDelegates(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') @@ -39,7 +39,7 @@ describe('getSafeDelegates', () => { }) it('should return an array of delegates', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateConfig1: SafeDelegateConfig = { safe: safeAddress, @@ -69,7 +69,7 @@ describe('getSafeDelegates', () => { }) it('should return an array of delegates EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const delegateConfig1: SafeDelegateConfig = { safe: eip3770SafeAddress, diff --git a/packages/safe-service-client/tests/e2e/getSafeInfo.test.ts b/packages/safe-service-client/tests/e2e/getSafeInfo.test.ts index a6eee0b6e..36c03b711 100644 --- a/packages/safe-service-client/tests/e2e/getSafeInfo.test.ts +++ b/packages/safe-service-client/tests/e2e/getSafeInfo.test.ts @@ -23,20 +23,20 @@ describe('getSafeInfo', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.getSafeInfo(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') }) it('should return an empty array if the safeTxHash is not found', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const safeInfoResponse = await serviceSdk.getSafeInfo(safeAddress) chai.expect(safeInfoResponse.address).to.be.equal(safeAddress) }) it('should return an empty array if the safeTxHash is not found EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const safeInfoResponse = await serviceSdk.getSafeInfo(eip3770SafeAddress) chai.expect(safeInfoResponse.address).to.be.equal(safeAddress) diff --git a/packages/safe-service-client/tests/e2e/getToken.test.ts b/packages/safe-service-client/tests/e2e/getToken.test.ts index ae185615d..477af71b4 100644 --- a/packages/safe-service-client/tests/e2e/getToken.test.ts +++ b/packages/safe-service-client/tests/e2e/getToken.test.ts @@ -21,22 +21,22 @@ describe('getToken', () => { }) it('should fail if token address is not checksummed', async () => { - const tokenAddress = '0xc778417E063141139Fce010982780140Aa0cD5Ab'.toLowerCase() + const tokenAddress = '0x210EC22dD6b1c174E5cA1A261DD9791e0755cc6D'.toLowerCase() await chai .expect(serviceSdk.getToken(tokenAddress)) .to.be.rejectedWith('Invalid ethereum address') }) it('should return the token info', async () => { - const tokenAddress = '0xc778417E063141139Fce010982780140Aa0cD5Ab' + const tokenAddress = '0x210EC22dD6b1c174E5cA1A261DD9791e0755cc6D' const tokenInfoResponse = await serviceSdk.getToken(tokenAddress) - chai.expect(tokenInfoResponse.address).to.be.equal('0xc778417E063141139Fce010982780140Aa0cD5Ab') + chai.expect(tokenInfoResponse.address).to.be.equal('0x210EC22dD6b1c174E5cA1A261DD9791e0755cc6D') }) it('should return the token info EIP-3770', async () => { - const tokenAddress = '0xc778417E063141139Fce010982780140Aa0cD5Ab' + const tokenAddress = '0x210EC22dD6b1c174E5cA1A261DD9791e0755cc6D' const eip3770TokenAddress = `${config.EIP_3770_PREFIX}:${tokenAddress}` const tokenInfoResponse = await serviceSdk.getToken(eip3770TokenAddress) - chai.expect(tokenInfoResponse.address).to.be.equal('0xc778417E063141139Fce010982780140Aa0cD5Ab') + chai.expect(tokenInfoResponse.address).to.be.equal('0x210EC22dD6b1c174E5cA1A261DD9791e0755cc6D') }) }) diff --git a/packages/safe-service-client/tests/e2e/getTransaction.test.ts b/packages/safe-service-client/tests/e2e/getTransaction.test.ts index f8e4ce80c..82f76a0c2 100644 --- a/packages/safe-service-client/tests/e2e/getTransaction.test.ts +++ b/packages/safe-service-client/tests/e2e/getTransaction.test.ts @@ -27,7 +27,7 @@ describe('getTransaction', () => { }) it('should return the transaction with the given safeTxHash', async () => { - const safeTxHash = '0xb22be4e57718560c89de96acd1acefe55c2673b31a7019a374ebb1d8a2842f5d' + const safeTxHash = '0xc58b604550610302477087256063d1ba195fbec20b2fd27648fec55242074592' const transaction = await serviceSdk.getTransaction(safeTxHash) chai.expect(transaction.safeTxHash).to.be.equal(safeTxHash) }) diff --git a/packages/safe-service-client/tests/e2e/getTransactionConfirmations.test.ts b/packages/safe-service-client/tests/e2e/getTransactionConfirmations.test.ts index 26bd60c1d..8657cbddd 100644 --- a/packages/safe-service-client/tests/e2e/getTransactionConfirmations.test.ts +++ b/packages/safe-service-client/tests/e2e/getTransactionConfirmations.test.ts @@ -29,7 +29,7 @@ describe('getTransactionConfirmations', () => { }) it('should return the transaction with the given safeTxHash', async () => { - const safeTxHash = '0xb22be4e57718560c89de96acd1acefe55c2673b31a7019a374ebb1d8a2842f5d' + const safeTxHash = '0xc58b604550610302477087256063d1ba195fbec20b2fd27648fec55242074592' const transactionConfirmations = await serviceSdk.getTransactionConfirmations(safeTxHash) chai.expect(transactionConfirmations.count).to.be.equal(2) chai.expect(transactionConfirmations.results.length).to.be.equal(2) diff --git a/packages/safe-service-client/tests/e2e/getUsdBalances.test.ts b/packages/safe-service-client/tests/e2e/getUsdBalances.test.ts index 134274cb6..14d4ed900 100644 --- a/packages/safe-service-client/tests/e2e/getUsdBalances.test.ts +++ b/packages/safe-service-client/tests/e2e/getUsdBalances.test.ts @@ -23,50 +23,50 @@ describe('getUsdBalances', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.getUsdBalances(safeAddress)) .to.be.rejectedWith('Checksum address validation failed') }) it('should return the list of USD balances', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const balances = await serviceSdk.getUsdBalances(safeAddress) chai.expect(balances.length).to.be.equal(2) const ethBalance = balances.filter((safeBalance) => !safeBalance.tokenAddress)[0] chai.expect(ethBalance.token).to.be.equal(null) - chai.expect(ethBalance.balance).to.be.equal('4000000000000000000') + chai.expect(ethBalance.balance).to.be.equal('100000000000000000') chai.expect(ethBalance.fiatCode).to.be.equal('USD') chai.expect(ethBalance.fiatBalance).not.to.be.equal('') chai.expect(ethBalance.fiatConversion).not.to.be.equal('') - const wethBalance = balances.filter( - (safeBalance) => safeBalance.tokenAddress === '0xc778417E063141139Fce010982780140Aa0cD5Ab' + const usdcBalance = balances.filter( + (safeBalance) => safeBalance.tokenAddress === '0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C' )[0] - chai.expect(wethBalance.token.symbol).to.be.equal('WETH') - chai.expect(wethBalance.balance).to.be.equal('10000000000000000') - chai.expect(wethBalance.fiatCode).to.be.equal('USD') - chai.expect(wethBalance.fiatBalance).not.to.be.equal('') - chai.expect(wethBalance.fiatConversion).not.to.be.equal('') + chai.expect(usdcBalance.token.symbol).to.be.equal('USDC') + chai.expect(usdcBalance.balance).to.be.equal('1000000000') + chai.expect(usdcBalance.fiatCode).to.be.equal('USD') + chai.expect(usdcBalance.fiatBalance).not.to.be.equal('') + chai.expect(usdcBalance.fiatConversion).not.to.be.equal('') }) it('should return the list of USD balances EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const balances = await serviceSdk.getUsdBalances(eip3770SafeAddress) chai.expect(balances.length).to.be.equal(2) const ethBalance = balances.filter((safeBalance) => !safeBalance.tokenAddress)[0] chai.expect(ethBalance.token).to.be.equal(null) - chai.expect(ethBalance.balance).to.be.equal('4000000000000000000') + chai.expect(ethBalance.balance).to.be.equal('100000000000000000') chai.expect(ethBalance.fiatCode).to.be.equal('USD') chai.expect(ethBalance.fiatBalance).not.to.be.equal('') chai.expect(ethBalance.fiatConversion).not.to.be.equal('') - const wethBalance = balances.filter( - (safeBalance) => safeBalance.tokenAddress === '0xc778417E063141139Fce010982780140Aa0cD5Ab' + const usdcBalance = balances.filter( + (safeBalance) => safeBalance.tokenAddress === '0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C' )[0] - chai.expect(wethBalance.token.symbol).to.be.equal('WETH') - chai.expect(wethBalance.balance).to.be.equal('10000000000000000') - chai.expect(wethBalance.fiatCode).to.be.equal('USD') - chai.expect(wethBalance.fiatBalance).not.to.be.equal('') - chai.expect(wethBalance.fiatConversion).not.to.be.equal('') + chai.expect(usdcBalance.token.symbol).to.be.equal('USDC') + chai.expect(usdcBalance.balance).to.be.equal('1000000000') + chai.expect(usdcBalance.fiatCode).to.be.equal('USD') + chai.expect(usdcBalance.fiatBalance).not.to.be.equal('') + chai.expect(usdcBalance.fiatConversion).not.to.be.equal('') }) }) diff --git a/packages/safe-service-client/tests/e2e/removeAllSafeDelegates.test.ts b/packages/safe-service-client/tests/e2e/removeAllSafeDelegates.test.ts index f28bd3c70..23deb843f 100644 --- a/packages/safe-service-client/tests/e2e/removeAllSafeDelegates.test.ts +++ b/packages/safe-service-client/tests/e2e/removeAllSafeDelegates.test.ts @@ -25,7 +25,7 @@ describe('removeAllSafeDelegates', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() await chai .expect(serviceSdk.removeAllSafeDelegates(safeAddress, signer)) .to.be.rejectedWith('Checksum address validation failed') @@ -39,7 +39,7 @@ describe('removeAllSafeDelegates', () => { }) it('should fail if the signer is not an owner of the Safe', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const { serviceSdk, signer } = await getServiceClient( '0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773' ) @@ -49,7 +49,7 @@ describe('removeAllSafeDelegates', () => { }) it('should remove all delegates', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateConfig1: SafeDelegateConfig = { safe: safeAddress, delegate: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0', @@ -72,7 +72,7 @@ describe('removeAllSafeDelegates', () => { }) it('should remove all delegates EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const delegateConfig1: SafeDelegateConfig = { safe: eip3770SafeAddress, diff --git a/packages/safe-service-client/tests/e2e/removeSafeDelegate.test.ts b/packages/safe-service-client/tests/e2e/removeSafeDelegate.test.ts index 17f30d7b1..b2c897da9 100644 --- a/packages/safe-service-client/tests/e2e/removeSafeDelegate.test.ts +++ b/packages/safe-service-client/tests/e2e/removeSafeDelegate.test.ts @@ -31,7 +31,7 @@ describe('removeSafeDelegate', () => { }) it('should fail if Safe delegate address is empty', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '' const delegateConfig: SafeDelegateDeleteConfig = { safe: safeAddress, @@ -44,7 +44,7 @@ describe('removeSafeDelegate', () => { }) it('should fail if Safe address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD'.toLowerCase() + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase() const delegateConfig: SafeDelegateDeleteConfig = { safe: safeAddress, delegate: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0', @@ -56,7 +56,7 @@ describe('removeSafeDelegate', () => { }) it('should fail if Safe delegate address is not checksummed', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'.toLowerCase() const delegateConfig: SafeDelegateDeleteConfig = { safe: safeAddress, @@ -82,7 +82,7 @@ describe('removeSafeDelegate', () => { }) it('should fail if the signer is not an owner of the Safe', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const { serviceSdk, signer } = await getServiceClient( '0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773' @@ -98,7 +98,7 @@ describe('removeSafeDelegate', () => { }) it('should fail if the delegate to remove is not a delegate', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e' const delegateConfig: SafeDelegateDeleteConfig = { safe: safeAddress, @@ -109,7 +109,7 @@ describe('removeSafeDelegate', () => { }) it('should remove a delegate', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const delegateConfig: SafeDelegateDeleteConfig = { safe: safeAddress, @@ -125,7 +125,7 @@ describe('removeSafeDelegate', () => { }) it('should remove a delegate EIP-3770', async () => { - const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' + const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const eip3770DelegateAddress = `${config.EIP_3770_PREFIX}:${delegateAddress}` diff --git a/packages/safe-service-client/tests/endpoint/index.test.ts b/packages/safe-service-client/tests/endpoint/index.test.ts index 3b025eadc..c9314625f 100644 --- a/packages/safe-service-client/tests/endpoint/index.test.ts +++ b/packages/safe-service-client/tests/endpoint/index.test.ts @@ -21,13 +21,13 @@ import { getServiceClient } from '../utils/setupServiceClient' chai.use(chaiAsPromised) chai.use(sinonChai) -const safeAddress = '0xf9A2FAa4E3b140ad42AAE8Cac4958cFf38Ab08fD' +const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}` const randomAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0' const eip3770RandomAddress = `${config.EIP_3770_PREFIX}:${randomAddress}` const delegateAddress = '0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b' const eip3770DelegateAddress = `${config.EIP_3770_PREFIX}:${delegateAddress}` -const tokenAddress = '0xcb0591ba2d74edd4211d5200d5d3b19cf598c548' +const tokenAddress = '0x210EC22dD6b1c174E5cA1A261DD9791e0755cc6D' const eip3770TokenAddress = `${config.EIP_3770_PREFIX}:${tokenAddress}` const safeTxHash = '0xede78ed72e9a8afd2b7a21f35c86f56cba5fffb2fff0838e253b7a41d19ceb48' const txServiceBaseUrl = 'https://safe-transaction.goerli.gnosis.io' From 6132d1d5eb49833ec6dbd6c98d3acdcefb8d6aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 07:33:02 +0200 Subject: [PATCH 04/16] Fix Safe Core SDK Utils tests in Goerli --- packages/safe-core-sdk-utils/tests/eip-3770.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/safe-core-sdk-utils/tests/eip-3770.test.ts b/packages/safe-core-sdk-utils/tests/eip-3770.test.ts index 5b5270c7a..b6e806921 100644 --- a/packages/safe-core-sdk-utils/tests/eip-3770.test.ts +++ b/packages/safe-core-sdk-utils/tests/eip-3770.test.ts @@ -59,12 +59,12 @@ describe('EIP-3770 chain-specific addresses', () => { }) it('should return false if prefix is invalid', async () => { - const prefix = 'RIN' + const prefix = 'GOR' chai.expect(isValidEip3770NetworkPrefix(prefix)).to.be.false }) it('should return true if prefix is valid', async () => { - const prefix = 'rin' + const prefix = 'gor' chai.expect(isValidEip3770NetworkPrefix(prefix)).to.be.true }) }) @@ -183,7 +183,7 @@ describe('EIP-3770 chain-specific addresses', () => { it('should fail validating a full address with address and prefix of different chainId', async () => { const testChainId = 100 - const testPrefix = 'rin' + const testPrefix = 'gor' const testAddress = '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1' chai .expect(() => validateEip3770Address(`${testPrefix}:${testAddress}`, testChainId)) From 68e21889a711758413b75d2ef92c2d7b30ca6da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 09:02:02 +0200 Subject: [PATCH 05/16] Make signTransaction immutable --- packages/safe-core-sdk/src/Safe.ts | 11 ++++++++--- packages/safe-core-sdk/src/safeFactory/index.ts | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index a09b6cb8e..5785ed37b 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -4,13 +4,13 @@ import { MetaTransactionData, OperationType, SafeSignature, - SafeTransaction, SafeTransactionDataPartial, SafeTransactionEIP712Args, SafeVersion, TransactionOptions, TransactionResult } from '@gnosis.pm/safe-core-sdk-types' +import { SafeTransaction } from './../../safe-core-sdk-types/src/types' import ContractManager from './managers/contractManager' import ModuleManager from './managers/moduleManager' import OwnerManager from './managers/ownerManager' @@ -372,7 +372,7 @@ class Safe { async signTransaction( safeTransaction: SafeTransaction, signingMethod: 'eth_sign' | 'eth_signTypedData' = 'eth_sign' - ): Promise { + ): Promise { const owners = await this.getOwners() const signerAddress = await this.#ethAdapter.getSignerAddress() const addressIsOwner = owners.find( @@ -388,7 +388,12 @@ class Safe { const txHash = await this.getTransactionHash(safeTransaction) signature = await this.signTransactionHash(txHash) } - safeTransaction.addSignature(signature) + const signedSafeTransaction = await this.createTransaction(safeTransaction.data) + safeTransaction.signatures.forEach((signature) => { + signedSafeTransaction.addSignature(signature) + }) + signedSafeTransaction.addSignature(signature) + return signedSafeTransaction } /** diff --git a/packages/safe-core-sdk/src/safeFactory/index.ts b/packages/safe-core-sdk/src/safeFactory/index.ts index 7a2e1e3c8..817711c9a 100644 --- a/packages/safe-core-sdk/src/safeFactory/index.ts +++ b/packages/safe-core-sdk/src/safeFactory/index.ts @@ -157,9 +157,9 @@ class SafeFactory { const initializer = await this.encodeSetupCallData(safeAccountConfig) const saltNonce = safeDeploymentConfig.saltNonce - const encodedNonce = toBuffer(this.#ethAdapter.encodeParameters(['uint256'], [saltNonce])).toString( - 'hex' - ) + const encodedNonce = toBuffer( + this.#ethAdapter.encodeParameters(['uint256'], [saltNonce]) + ).toString('hex') const salt = keccak256( toBuffer('0x' + keccak256(toBuffer(initializer)).toString('hex') + encodedNonce) From f0d14590fc9e97a9b459ba523b944f5a504f786d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 09:02:20 +0200 Subject: [PATCH 06/16] Fix signTransaction tests --- .../safe-core-sdk/tests/execution.test.ts | 28 +++++++++---------- .../tests/offChainSignatures.test.ts | 14 ++++++---- .../safe-core-sdk/tests/ownerManager.test.ts | 24 ++++++++-------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/packages/safe-core-sdk/tests/execution.test.ts b/packages/safe-core-sdk/tests/execution.test.ts index 2a66420be..449c79bbc 100644 --- a/packages/safe-core-sdk/tests/execution.test.ts +++ b/packages/safe-core-sdk/tests/execution.test.ts @@ -76,12 +76,12 @@ describe('Transactions execution', () => { data: '0x' } const tx = await safeSdk1.createTransaction(txDataPartial) - await safeSdk1.signTransaction(tx) + const signedTx = await safeSdk1.signTransaction(tx) const txHash = await safeSdk2.getTransactionHash(tx) const txResponse = await safeSdk2.approveTransactionHash(txHash) await waitSafeTxReceipt(txResponse) await chai - .expect(safeSdk2.executeTransaction(tx)) + .expect(safeSdk2.executeTransaction(signedTx)) .to.be.rejectedWith('There is 1 signature missing') }) @@ -132,12 +132,12 @@ describe('Transactions execution', () => { } const tx = await safeSdk1.createTransaction(txDataPartial) const rejectTx = await safeSdk1.createRejectionTransaction(tx.data.nonce) - await safeSdk1.signTransaction(rejectTx) - const txRejectResponse = await safeSdk2.executeTransaction(rejectTx) + const signedRejectTx = await safeSdk1.signTransaction(rejectTx) + const txRejectResponse = await safeSdk2.executeTransaction(signedRejectTx) await waitSafeTxReceipt(txRejectResponse) - await safeSdk1.signTransaction(tx) + const signedTx = await safeSdk1.signTransaction(tx) await chai - .expect(safeSdk2.executeTransaction(tx)) + .expect(safeSdk2.executeTransaction(signedTx)) .to.be.rejectedWith(safeVersionDeployed === '1.3.0' ? 'GS026' : 'Invalid owner provided') }) @@ -221,11 +221,11 @@ describe('Transactions execution', () => { data: '0x' } const tx = await safeSdk1.createTransaction(txDataPartial) - await safeSdk1.signTransaction(tx) + const signedTx = await safeSdk1.signTransaction(tx) const txHash = await safeSdk2.getTransactionHash(tx) const txResponse1 = await safeSdk2.approveTransactionHash(txHash) await waitSafeTxReceipt(txResponse1) - const txResponse2 = await safeSdk3.executeTransaction(tx) + const txResponse2 = await safeSdk3.executeTransaction(signedTx) await waitSafeTxReceipt(txResponse2) const safeFinalBalance = await safeSdk1.getBalance() chai @@ -257,11 +257,11 @@ describe('Transactions execution', () => { data: '0x' } const tx = await safeSdk1.createTransaction(txDataPartial) - await safeSdk1.signTransaction(tx) + const signedTx = await safeSdk1.signTransaction(tx) const txHash = await safeSdk2.getTransactionHash(tx) const txResponse1 = await safeSdk2.approveTransactionHash(txHash) await waitSafeTxReceipt(txResponse1) - const txResponse2 = await safeSdk3.executeTransaction(tx) + const txResponse2 = await safeSdk3.executeTransaction(signedTx) await waitSafeTxReceipt(txResponse2) const safeFinalBalance = await safeSdk1.getBalance() chai @@ -431,11 +431,11 @@ describe('Transactions execution', () => { } ] const multiSendTx = await safeSdk1.createTransaction(txs) - await safeSdk1.signTransaction(multiSendTx) + const signedMultiSendTx = await safeSdk1.signTransaction(multiSendTx) const txHash = await safeSdk2.getTransactionHash(multiSendTx) const txResponse1 = await safeSdk2.approveTransactionHash(txHash) await waitSafeTxReceipt(txResponse1) - const txResponse2 = await safeSdk3.executeTransaction(multiSendTx) + const txResponse2 = await safeSdk3.executeTransaction(signedMultiSendTx) await waitSafeTxReceipt(txResponse2) const safeFinalBalance = await safeSdk1.getBalance() chai @@ -488,11 +488,11 @@ describe('Transactions execution', () => { } ] const multiSendTx = await safeSdk1.createTransaction(txs) - await safeSdk1.signTransaction(multiSendTx) + const signedMultiSendTx = await safeSdk1.signTransaction(multiSendTx) const txHash = await safeSdk2.getTransactionHash(multiSendTx) const txResponse1 = await safeSdk2.approveTransactionHash(txHash) await waitSafeTxReceipt(txResponse1) - const txResponse2 = await safeSdk3.executeTransaction(multiSendTx) + const txResponse2 = await safeSdk3.executeTransaction(signedMultiSendTx) await waitSafeTxReceipt(txResponse2) const safeFinalERC20Balance = await erc20Mintable.balanceOf(safe.address) diff --git a/packages/safe-core-sdk/tests/offChainSignatures.test.ts b/packages/safe-core-sdk/tests/offChainSignatures.test.ts index c49789ebd..f251e9c30 100644 --- a/packages/safe-core-sdk/tests/offChainSignatures.test.ts +++ b/packages/safe-core-sdk/tests/offChainSignatures.test.ts @@ -78,8 +78,9 @@ describe('Off-chain signatures', () => { data: '0x' }) chai.expect(tx.signatures.size).to.be.eq(0) - await safeSdk.signTransaction(tx) - chai.expect(tx.signatures.size).to.be.eq(1) + const signedTx = await safeSdk.signTransaction(tx) + chai.expect(tx.signatures.size).to.be.eq(0) + chai.expect(signedTx.signatures.size).to.be.eq(1) }) it('should ignore duplicated signatures', async () => { @@ -97,10 +98,11 @@ describe('Off-chain signatures', () => { data: '0x' }) chai.expect(tx.signatures.size).to.be.eq(0) - await safeSdk.signTransaction(tx) - chai.expect(tx.signatures.size).to.be.eq(1) - await safeSdk.signTransaction(tx) - chai.expect(tx.signatures.size).to.be.eq(1) + const signedTx1 = await safeSdk.signTransaction(tx) + chai.expect(signedTx1.signatures.size).to.be.eq(1) + const signedTx2 = await safeSdk.signTransaction(signedTx1) + chai.expect(signedTx2.signatures.size).to.be.eq(1) + chai.expect(tx.signatures.size).to.be.eq(0) }) }) }) diff --git a/packages/safe-core-sdk/tests/ownerManager.test.ts b/packages/safe-core-sdk/tests/ownerManager.test.ts index 4ed4fd4d2..b2ab15f3c 100644 --- a/packages/safe-core-sdk/tests/ownerManager.test.ts +++ b/packages/safe-core-sdk/tests/ownerManager.test.ts @@ -375,9 +375,9 @@ describe('Safe owners manager', () => { chai.expect(initialOwners[1]).to.be.eq(account2.address) chai.expect(initialOwners[2]).to.be.eq(account3.address) const tx = await safeSdk1.getRemoveOwnerTx({ ownerAddress: account1.address }) - await safeSdk2.signTransaction(tx) - await safeSdk3.signTransaction(tx) - const txResponse = await safeSdk1.executeTransaction(tx) + const signedTx1 = await safeSdk2.signTransaction(tx) + const signedTx2 = await safeSdk3.signTransaction(signedTx1) + const txResponse = await safeSdk1.executeTransaction(signedTx2) await waitSafeTxReceipt(txResponse) const finalThreshold = await safeSdk1.getThreshold() chai.expect(initialThreshold - 1).to.be.eq(finalThreshold) @@ -410,9 +410,9 @@ describe('Safe owners manager', () => { chai.expect(initialOwners[1]).to.be.eq(account2.address) chai.expect(initialOwners[2]).to.be.eq(account3.address) const tx = await safeSdk1.getRemoveOwnerTx({ ownerAddress: account2.address }) - await safeSdk2.signTransaction(tx) - await safeSdk3.signTransaction(tx) - const txResponse = await safeSdk1.executeTransaction(tx) + const signedTx1 = await safeSdk2.signTransaction(tx) + const signedTx2 = await safeSdk3.signTransaction(signedTx1) + const txResponse = await safeSdk1.executeTransaction(signedTx2) await waitSafeTxReceipt(txResponse) const finalThreshold = await safeSdk1.getThreshold() chai.expect(initialThreshold - 1).to.be.eq(finalThreshold) @@ -445,9 +445,9 @@ describe('Safe owners manager', () => { ownerAddress: account1.address, threshold: newThreshold }) - await safeSdk2.signTransaction(tx) - await safeSdk3.signTransaction(tx) - const txResponse = await safeSdk1.executeTransaction(tx) + const signedTx1 = await safeSdk2.signTransaction(tx) + const signedTx2 = await safeSdk3.signTransaction(signedTx1) + const txResponse = await safeSdk1.executeTransaction(signedTx2) await waitSafeTxReceipt(txResponse) chai.expect(await safeSdk1.getThreshold()).to.be.eq(newThreshold) const finalOwners = await safeSdk1.getOwners() @@ -670,9 +670,9 @@ describe('Safe owners manager', () => { oldOwnerAddress: account2.address, newOwnerAddress: account4.address }) - await safeSdk2.signTransaction(tx) - await safeSdk3.signTransaction(tx) - const txResponse = await safeSdk1.executeTransaction(tx) + const signedTx1 = await safeSdk2.signTransaction(tx) + const signedTx2 = await safeSdk3.signTransaction(signedTx1) + const txResponse = await safeSdk1.executeTransaction(signedTx2) await waitSafeTxReceipt(txResponse) const finalOwners = await safeSdk1.getOwners() chai.expect(finalOwners.length).to.be.eq(3) From 360f7fdaa0cfedfb7518534708253b676e965477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 09:02:53 +0200 Subject: [PATCH 07/16] Update signTransaction immutability in README --- packages/safe-core-sdk/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/safe-core-sdk/README.md b/packages/safe-core-sdk/README.md index aca189fe1..a534c8e4d 100644 --- a/packages/safe-core-sdk/README.md +++ b/packages/safe-core-sdk/README.md @@ -108,7 +108,7 @@ Before executing this transaction, it must be signed by the owners and this can The `owner1` account signs the transaction off-chain. ```js -const owner1Signature = await safeSdk.signTransaction(safeTransaction) +const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction) ``` Because the signature is off-chain, there is no interaction with the contract and the signature becomes available at `safeTransaction.signatures`. @@ -556,18 +556,18 @@ Adds the signature of the current owner to the Safe transaction object. `eth_sig const transaction: SafeTransactionDataPartial = { // ... } -const safeTransaction = await safeSdk.createTransaction(transaction) -await safeSdk.signTransaction(safeTransaction) +const safeTransaction = await safeSdk.createTransaction(transaction) +const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction) ``` Optionally, an additional parameter can be passed to specify a different way of signing: ```js -await safeSdk.signTransaction(safeTransaction, 'eth_signTypedData') +const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction, 'eth_signTypedData') ``` ```js -await safeSdk.signTransaction(safeTransaction, 'eth_sign') // default option. +const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction, 'eth_sign') // default option. ``` ### approveTransactionHash From a0835e51a5fcd3d44051528fbead20643a6d7c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 09:09:13 +0200 Subject: [PATCH 08/16] Fix import --- packages/safe-core-sdk/src/Safe.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index 5785ed37b..f8d28f048 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -3,14 +3,12 @@ import { EthAdapter, MetaTransactionData, OperationType, - SafeSignature, - SafeTransactionDataPartial, + SafeSignature, SafeTransaction, SafeTransactionDataPartial, SafeTransactionEIP712Args, SafeVersion, TransactionOptions, TransactionResult } from '@gnosis.pm/safe-core-sdk-types' -import { SafeTransaction } from './../../safe-core-sdk-types/src/types' import ContractManager from './managers/contractManager' import ModuleManager from './managers/moduleManager' import OwnerManager from './managers/ownerManager' From 9b0d05e407c9932d06b208c93c2f9fe181b1f010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 10:37:06 +0200 Subject: [PATCH 09/16] Add EIP-1559 tests --- .../safe-core-sdk/tests/execution.test.ts | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/packages/safe-core-sdk/tests/execution.test.ts b/packages/safe-core-sdk/tests/execution.test.ts index 2a66420be..1fdeee2f3 100644 --- a/packages/safe-core-sdk/tests/execution.test.ts +++ b/packages/safe-core-sdk/tests/execution.test.ts @@ -333,6 +333,44 @@ describe('Transactions execution', () => { } ) + itif(process.env.ETH_LIB === 'ethers')( + 'should execute a transaction with options: { maxFeePerGas, maxPriorityFeePerGas }', + async () => { + const { accounts, contractNetworks } = await setupTests() + const [account1, account2] = accounts + const safe = await getSafeWithOwners([account1.address]) + const ethAdapter = await getEthAdapter(account1.signer) + const safeSdk1 = await Safe.create({ + ethAdapter, + safeAddress: safe.address, + contractNetworks + }) + await account1.signer.sendTransaction({ + to: safe.address, + value: BigNumber.from('1000000000000000000') // 1 ETH + }) + const txDataPartial: SafeTransactionDataPartial = { + to: account2.address, + value: '500000000000000000', // 0.5 ETH + data: '0x' + } + const tx = await safeSdk1.createTransaction(txDataPartial) + const execOptions: EthersTransactionOptions = { + maxFeePerGas: 200000000, //higher than hardhat's block baseFeePerGas + maxPriorityFeePerGas: 1 + } + const txResponse = await safeSdk1.executeTransaction(tx, execOptions) + await waitSafeTxReceipt(txResponse) + const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + chai + .expect(BigNumber.from(execOptions.maxFeePerGas)) + .to.be.eq(BigNumber.from(txConfirmed.maxFeePerGas)) + chai + .expect(BigNumber.from(execOptions.maxPriorityFeePerGas)) + .to.be.eq(BigNumber.from(txConfirmed.maxPriorityFeePerGas)) + } + ) + itif(process.env.ETH_LIB === 'web3')( 'should execute a transaction with options: { gas }', async () => { @@ -396,6 +434,44 @@ describe('Transactions execution', () => { chai.expect(execOptions.gas).to.be.eq(txConfirmed.gas) } ) + + itif(process.env.ETH_LIB === 'web3')( + 'should execute a transaction with options: { maxFeePerGas, maxPriorityFeePerGas }', + async () => { + const { accounts, contractNetworks } = await setupTests() + const [account1, account2] = accounts + const safe = await getSafeWithOwners([account1.address]) + const ethAdapter = await getEthAdapter(account1.signer) + const safeSdk1 = await Safe.create({ + ethAdapter, + safeAddress: safe.address, + contractNetworks + }) + await account1.signer.sendTransaction({ + to: safe.address, + value: BigNumber.from('1000000000000000000') // 1 ETH + }) + const txDataPartial: SafeTransactionDataPartial = { + to: account2.address, + value: '500000000000000000', // 0.5 ETH + data: '0x' + } + const tx = await safeSdk1.createTransaction(txDataPartial) + const execOptions: Web3TransactionOptions = { + maxFeePerGas: 200000000, //higher than hardhat's block baseFeePerGas + maxPriorityFeePerGas: 1 + } + const txResponse = await safeSdk1.executeTransaction(tx, execOptions) + await waitSafeTxReceipt(txResponse) + const txConfirmed = await ethAdapter.getTransaction(txResponse.hash) + chai + .expect(BigNumber.from(execOptions.maxFeePerGas)) + .to.be.eq(BigNumber.from(txConfirmed.maxFeePerGas)) + chai + .expect(BigNumber.from(execOptions.maxPriorityFeePerGas)) + .to.be.eq(BigNumber.from(txConfirmed.maxPriorityFeePerGas)) + } + ) }) describe('executeTransaction (MultiSend)', async () => { From de5c0b3ec807b62b00d9669f17db2a8abc40af2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 10:37:45 +0200 Subject: [PATCH 10/16] Add options to method comment --- packages/safe-core-sdk/src/Safe.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index 2a78ca673..a34a4d1d2 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -395,6 +395,7 @@ class Safe { * Approves on-chain a hash using the current signer account. * * @param hash - The hash to approve + * @param options - The Safe transaction execution options. Optional * @returns The Safe transaction response * @throws "Transaction hashes can only be approved by Safe owners" * @throws "Cannot specify gas and gasLimit together in transaction options" @@ -580,7 +581,7 @@ class Safe { * Executes a Safe transaction. * * @param safeTransaction - The Safe transaction to execute - * @param options - The Safe transaction execution options (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) + * @param options - The Safe transaction execution options. Optional * @returns The Safe transaction response * @throws "No signer provided" * @throws "There are X signatures missing" From 207542d6026fd667998d2446339935a9dff23f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 1 Aug 2022 17:44:43 +0200 Subject: [PATCH 11/16] Fix docs --- packages/safe-core-sdk/README.md | 2 +- packages/safe-core-sdk/src/Safe.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/safe-core-sdk/README.md b/packages/safe-core-sdk/README.md index a534c8e4d..237343ccb 100644 --- a/packages/safe-core-sdk/README.md +++ b/packages/safe-core-sdk/README.md @@ -111,7 +111,7 @@ The `owner1` account signs the transaction off-chain. const signedSafeTransaction = await safeSdk.signTransaction(safeTransaction) ``` -Because the signature is off-chain, there is no interaction with the contract and the signature becomes available at `safeTransaction.signatures`. +Because the signature is off-chain, there is no interaction with the contract and the signature becomes available at `signedSafeTransaction.signatures`. ### 3.b. On-chain signatures diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index f8d28f048..a82b3aafa 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -364,7 +364,8 @@ class Safe { * Adds the signature of the current signer to the Safe transaction object. * * @param safeTransaction - The Safe transaction to be signed - * @param signingMethod - Method followed to sign a transaction. Optional. Default value is eth_sign + * @param signingMethod - Method followed to sign a transaction. Optional. Default value is "eth_sign" + * @returns The signed Safe transaction * @throws "Transactions can only be signed by Safe owners" */ async signTransaction( From ebb41296b185d9e4393108e585d4f9ac96f7815a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Tue, 2 Aug 2022 12:40:11 +0200 Subject: [PATCH 12/16] Add temporary waring in safeTransaction method --- packages/safe-core-sdk/README.md | 2 +- packages/safe-core-sdk/src/Safe.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/safe-core-sdk/README.md b/packages/safe-core-sdk/README.md index 237343ccb..a9c84623c 100644 --- a/packages/safe-core-sdk/README.md +++ b/packages/safe-core-sdk/README.md @@ -550,7 +550,7 @@ const signature = await safeSdk.signTypedData(safeTransaction) ### signTransaction -Adds the signature of the current owner to the Safe transaction object. `eth_sign` will be used by default to generate the signature. +Returns a new `SafeTransaction` object that includes the signature of the current owner. `eth_sign` will be used by default to generate the signature. ```js const transaction: SafeTransactionDataPartial = { diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index a82b3aafa..724536f7a 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -3,7 +3,9 @@ import { EthAdapter, MetaTransactionData, OperationType, - SafeSignature, SafeTransaction, SafeTransactionDataPartial, + SafeSignature, + SafeTransaction, + SafeTransactionDataPartial, SafeTransactionEIP712Args, SafeVersion, TransactionOptions, @@ -392,6 +394,14 @@ class Safe { signedSafeTransaction.addSignature(signature) }) signedSafeTransaction.addSignature(signature) + + // TO-DO: Remove in v3.0.0 { + console.warn( + 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction' + ) + safeTransaction.addSignature(signature) + // } + return signedSafeTransaction } From 97fbc917973eb3b7aa14ffbeaff895fca2896755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Tue, 2 Aug 2022 12:50:23 +0200 Subject: [PATCH 13/16] Add Safe Core SDK postinstall script --- packages/safe-core-sdk/package.json | 1 + packages/safe-core-sdk/scripts/postinstall.ts | 7 +++++++ packages/safe-core-sdk/src/Safe.ts | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 packages/safe-core-sdk/scripts/postinstall.ts diff --git a/packages/safe-core-sdk/package.json b/packages/safe-core-sdk/package.json index eeabe7993..048f851e9 100644 --- a/packages/safe-core-sdk/package.json +++ b/packages/safe-core-sdk/package.json @@ -13,6 +13,7 @@ "scripts": { "unbuild": "rimraf dist artifacts deployments cache .nyc_output", "build": "hardhat compile && tsc", + "postinstall": "ts-node scripts/postinstall.ts", "test:ganache:web3:v1.2.0": "export TEST_NETWORK=ganache && export ETH_LIB=web3 && export SAFE_VERSION=1.2.0 && hardhat --network localhost deploy && nyc hardhat --network localhost test", "test:ganache:web3:v1.3.0": "export TEST_NETWORK=ganache && export ETH_LIB=web3 && export SAFE_VERSION=1.3.0 && hardhat --network localhost deploy && nyc hardhat --network localhost test", "test:ganache:ethers:v1.2.0": "export TEST_NETWORK=ganache && export ETH_LIB=ethers && export SAFE_VERSION=1.2.0 && hardhat --network localhost deploy && nyc hardhat --network localhost test", diff --git a/packages/safe-core-sdk/scripts/postinstall.ts b/packages/safe-core-sdk/scripts/postinstall.ts new file mode 100644 index 000000000..011273e8d --- /dev/null +++ b/packages/safe-core-sdk/scripts/postinstall.ts @@ -0,0 +1,7 @@ +function postInstall() { + console.warn( + 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction' + ) +} + +postInstall() diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index 724536f7a..3958b408f 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -401,7 +401,7 @@ class Safe { ) safeTransaction.addSignature(signature) // } - + return signedSafeTransaction } From 164ac53a475d77c78c18b0f649b7fe9bdc1bf129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Tue, 2 Aug 2022 13:02:25 +0200 Subject: [PATCH 14/16] Fix signTransaction tests --- packages/safe-core-sdk/tests/offChainSignatures.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/safe-core-sdk/tests/offChainSignatures.test.ts b/packages/safe-core-sdk/tests/offChainSignatures.test.ts index f251e9c30..4ae50d0db 100644 --- a/packages/safe-core-sdk/tests/offChainSignatures.test.ts +++ b/packages/safe-core-sdk/tests/offChainSignatures.test.ts @@ -79,7 +79,9 @@ describe('Off-chain signatures', () => { }) chai.expect(tx.signatures.size).to.be.eq(0) const signedTx = await safeSdk.signTransaction(tx) - chai.expect(tx.signatures.size).to.be.eq(0) + // TO-DO: Uncomment in v3.0.0 { + // chai.expect(tx.signatures.size).to.be.eq(0) + // } chai.expect(signedTx.signatures.size).to.be.eq(1) }) @@ -102,7 +104,9 @@ describe('Off-chain signatures', () => { chai.expect(signedTx1.signatures.size).to.be.eq(1) const signedTx2 = await safeSdk.signTransaction(signedTx1) chai.expect(signedTx2.signatures.size).to.be.eq(1) - chai.expect(tx.signatures.size).to.be.eq(0) + // TO-DO: Remove in v3.0.0 { + // chai.expect(tx.signatures.size).to.be.eq(0) + // } }) }) }) From 68a25a85ae72e554e81d74d22959eec4350c5669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Tue, 2 Aug 2022 13:04:31 +0200 Subject: [PATCH 15/16] Update signTransaction warning message --- packages/safe-core-sdk/scripts/postinstall.ts | 2 +- packages/safe-core-sdk/src/Safe.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/safe-core-sdk/scripts/postinstall.ts b/packages/safe-core-sdk/scripts/postinstall.ts index 011273e8d..622baa2da 100644 --- a/packages/safe-core-sdk/scripts/postinstall.ts +++ b/packages/safe-core-sdk/scripts/postinstall.ts @@ -1,6 +1,6 @@ function postInstall() { console.warn( - 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction' + 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction. In >=v3.0.0 the signature will only be added to the returned object, not the one that is passed as params.' ) } diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index 3958b408f..65f10e18f 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -397,7 +397,7 @@ class Safe { // TO-DO: Remove in v3.0.0 { console.warn( - 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction' + 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction. In >=v3.0.0 the signature will only be added to the returned object, not the one that is passed as params.' ) safeTransaction.addSignature(signature) // } From 46fb375b1bb634ddef5c5fd8b7dc9d6bcddbd1c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Tue, 2 Aug 2022 13:24:27 +0200 Subject: [PATCH 16/16] Update warning message --- packages/safe-core-sdk/scripts/postinstall.ts | 2 +- packages/safe-core-sdk/src/Safe.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/safe-core-sdk/scripts/postinstall.ts b/packages/safe-core-sdk/scripts/postinstall.ts index 622baa2da..73fa05e04 100644 --- a/packages/safe-core-sdk/scripts/postinstall.ts +++ b/packages/safe-core-sdk/scripts/postinstall.ts @@ -1,6 +1,6 @@ function postInstall() { console.warn( - 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction. In >=v3.0.0 the signature will only be added to the returned object, not the one that is passed as params.' + `⚠️ the "signTransaction" method now returns a signed Safe transaction. Please update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction. In >=v3.0.0, the signature will be added only to the return transaction object, and not to the one passed as an argument.` ) } diff --git a/packages/safe-core-sdk/src/Safe.ts b/packages/safe-core-sdk/src/Safe.ts index ae7e9f920..b95b1236a 100644 --- a/packages/safe-core-sdk/src/Safe.ts +++ b/packages/safe-core-sdk/src/Safe.ts @@ -397,7 +397,7 @@ class Safe { // TO-DO: Remove in v3.0.0 { console.warn( - 'WARNING! "signTransaction" method now *returns* the signed Safe transaction. Update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction. In >=v3.0.0 the signature will only be added to the returned object, not the one that is passed as params.' + `⚠️ the "signTransaction" method now returns a signed Safe transaction. Please update your code according to the new documentation: https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#signtransaction. In >=v3.0.0, the signature will be added only to the return transaction object, and not to the one passed as an argument.` ) safeTransaction.addSignature(signature) // }