Skip to content

Commit

Permalink
Merge branch 'development' into feat/4337-pack
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanra committed Apr 15, 2024
2 parents 75f678e + 46aa376 commit 9f4e594
Show file tree
Hide file tree
Showing 26 changed files with 209 additions and 119 deletions.
4 changes: 2 additions & 2 deletions packages/api-kit/tests/e2e/addMessage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const generateRandomUUID = (): string => {
}

const generateMessage = () => `${generateRandomUUID()}: I am the owner of the safe`
const safeAddress = '0x3296b3DD454B7c3912F7F477787B503918C50082'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'

describe('addMessage', () => {
before(async () => {
;({ safeApiKit, ethAdapter } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))

protocolKit = await Safe.create({
Expand Down
9 changes: 4 additions & 5 deletions packages/api-kit/tests/e2e/addMessageSignature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ const generateRandomUUID = (): string => {
}

const generateMessage = () => `${generateRandomUUID()}: I am the owner of the safe`
const safeAddress = '0x3296b3DD454B7c3912F7F477787B503918C50082'
const signerSafeAddress = '0x83aB93f078A8fbbe6a677b1C488819e0ae981128'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const signerSafeAddress = '0xDa8dd250065F19f7A29564396D7F13230b9fC5A3'

describe('addMessageSignature', () => {
before(async () => {
;({ safeApiKit: safeApiKit1, ethAdapter: ethAdapter1 } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d',
'https://safe-transaction-goerli.staging.5afe.dev/api'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
;({ ethAdapter: ethAdapter2 } = await getServiceClient(
'0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1'
'0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
))
})

Expand Down
34 changes: 17 additions & 17 deletions packages/api-kit/tests/e2e/addSafeDelegate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ let signer: Signer
describe('addSafeDelegate', () => {
before(async () => {
;({ safeApiKit, signer } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

it('should fail if Label is empty', async () => {
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('addSafeDelegate', () => {
})

it('should fail if Safe delegator address is empty', async () => {
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = ''
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
Expand All @@ -60,8 +60,8 @@ describe('addSafeDelegate', () => {
})

it('should fail if Safe address is not checksummed', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase()
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'.toLowerCase()
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
Expand All @@ -76,8 +76,8 @@ describe('addSafeDelegate', () => {
})

it('should fail if Safe delegate address is not checksummed', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'.toLowerCase()
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'.toLowerCase()
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
Expand All @@ -92,8 +92,8 @@ describe('addSafeDelegate', () => {
})

it('should fail if Safe delegator address is not checksummed', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = (await signer.getAddress()).toLowerCase()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
Expand All @@ -109,7 +109,7 @@ describe('addSafeDelegate', () => {

it('should fail if Safe does not exist', async () => {
const safeAddress = '0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e'
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
Expand All @@ -127,8 +127,8 @@ describe('addSafeDelegate', () => {
const { safeApiKit, signer } = await getServiceClient(
'0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773'
)
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
Expand All @@ -145,8 +145,8 @@ describe('addSafeDelegate', () => {
})

it('should add a new delegate', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
safeAddress,
Expand All @@ -169,7 +169,7 @@ describe('addSafeDelegate', () => {
})

it('should add a new delegate without specifying a Safe', async () => {
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const delegatorAddress = await signer.getAddress()
const delegateConfig: AddSafeDelegateProps = {
delegateAddress,
Expand All @@ -196,9 +196,9 @@ describe('addSafeDelegate', () => {
})

it('should add a new delegate EIP-3770', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const delegateAddress = '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
const delegateAddress = '0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B'
const eip3770DelegateAddress = `${config.EIP_3770_PREFIX}:${delegateAddress}`
const delegatorAddress = await signer.getAddress()
const eip3770DelegatorAddress = `${config.EIP_3770_PREFIX}:${delegatorAddress}`
Expand Down
10 changes: 4 additions & 6 deletions packages/api-kit/tests/e2e/confirmTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ let protocolKit: Safe
let ethAdapter1: EthAdapter
let ethAdapter2: EthAdapter

const safeAddress = '0x3296b3DD454B7c3912F7F477787B503918C50082'
const signerSafeAddress = '0x83aB93f078A8fbbe6a677b1C488819e0ae981128'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const signerSafeAddress = '0xDa8dd250065F19f7A29564396D7F13230b9fC5A3'

describe('proposeTransaction', () => {
before(async () => {
;({ safeApiKit: safeApiKit1, ethAdapter: ethAdapter1 } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d',
'https://safe-transaction-goerli.staging.5afe.dev/api'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
;({ ethAdapter: ethAdapter2 } = await getServiceClient(
'0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1',
'https://safe-transaction-goerli.staging.5afe.dev/api'
'0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
))
})

Expand Down
2 changes: 1 addition & 1 deletion packages/api-kit/tests/e2e/decodeData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let safeApiKit: SafeApiKit
describe('decodeData', () => {
before(async () => {
;({ safeApiKit } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

Expand Down
16 changes: 8 additions & 8 deletions packages/api-kit/tests/e2e/getIncomingTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let safeApiKit: SafeApiKit
describe('getIncomingTransactions', () => {
before(async () => {
;({ safeApiKit } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

Expand All @@ -23,7 +23,7 @@ describe('getIncomingTransactions', () => {
})

it('should fail if Safe address is not checksummed', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase()
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'.toLowerCase()
await chai
.expect(safeApiKit.getIncomingTransactions(safeAddress))
.to.be.rejectedWith('Checksum address validation failed')
Expand All @@ -37,21 +37,21 @@ describe('getIncomingTransactions', () => {
})

it('should return the list of incoming transactions', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with incoming transactions
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78' // Safe with incoming transactions
const transferListResponse = await safeApiKit.getIncomingTransactions(safeAddress)
chai.expect(transferListResponse.count).to.be.equal(5)
chai.expect(transferListResponse.results.length).to.be.equal(5)
chai.expect(transferListResponse.count).to.be.equal(6)
chai.expect(transferListResponse.results.length).to.be.equal(6)
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 = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with incoming transactions
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78' // Safe with incoming transactions
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const transferListResponse = await safeApiKit.getIncomingTransactions(eip3770SafeAddress)
chai.expect(transferListResponse.count).to.be.equal(5)
chai.expect(transferListResponse.results.length).to.be.equal(5)
chai.expect(transferListResponse.count).to.be.equal(6)
chai.expect(transferListResponse.results.length).to.be.equal(6)
transferListResponse.results.map((transaction) => {
chai.expect(transaction.to).to.be.equal(safeAddress)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/api-kit/tests/e2e/getMessage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { getServiceClient } from '../utils/setupServiceClient'
chai.use(chaiAsPromised)

let safeApiKit: SafeApiKit
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'

describe('getMessages', () => {
before(async () => {
;({ safeApiKit } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

Expand Down
4 changes: 2 additions & 2 deletions packages/api-kit/tests/e2e/getMessages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { getServiceClient } from '../utils/setupServiceClient'
chai.use(chaiAsPromised)

let safeApiKit: SafeApiKit
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'

describe('getMessages', () => {
before(async () => {
;({ safeApiKit } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

Expand Down
16 changes: 8 additions & 8 deletions packages/api-kit/tests/e2e/getMultisigTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let safeApiKit: SafeApiKit
describe('getMultisigTransactions', () => {
before(async () => {
;({ safeApiKit } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

Expand All @@ -23,7 +23,7 @@ describe('getMultisigTransactions', () => {
})

it('should fail if Safe address is not checksummed', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase()
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'.toLowerCase()
await chai
.expect(safeApiKit.getMultisigTransactions(safeAddress))
.to.be.rejectedWith('Checksum address validation failed')
Expand All @@ -38,23 +38,23 @@ describe('getMultisigTransactions', () => {
})

it('should return the list of multisig transactions', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with multisig transactions
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78' // Safe with multisig transactions
const safeMultisigTransactionListResponse =
await safeApiKit.getMultisigTransactions(safeAddress)
chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(12)
chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(12)
chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(18)
chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(18)
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 = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with multisig transactions
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78' // Safe with multisig transactions
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const safeMultisigTransactionListResponse =
await safeApiKit.getMultisigTransactions(eip3770SafeAddress)
chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(12)
chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(12)
chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(18)
chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(18)
safeMultisigTransactionListResponse.results.map((transaction) => {
chai.expect(transaction.safe).to.be.equal(safeAddress)
})
Expand Down
12 changes: 6 additions & 6 deletions packages/api-kit/tests/e2e/getNextNonce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let safeApiKit: SafeApiKit
describe('getNextNonce', () => {
before(async () => {
;({ safeApiKit } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

Expand All @@ -22,20 +22,20 @@ describe('getNextNonce', () => {
})

it('should return the next Safe nonce when there are pending transactions', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const nextNonce = await safeApiKit.getNextNonce(safeAddress)
chai.expect(nextNonce).to.be.equal(9)
chai.expect(nextNonce).to.be.equal(11)
})

it('should return the next Safe nonce when there are pending transactions EIP-3770', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const nextNonce = await safeApiKit.getNextNonce(eip3770SafeAddress)
chai.expect(nextNonce).to.be.equal(9)
chai.expect(nextNonce).to.be.equal(11)
})

it('should return the next Safe nonce when there are no pending transactions', async () => {
const safeAddress = '0x72c346260a4887F0231af41178C1c818Ce34543f'
const safeAddress = '0xDa8dd250065F19f7A29564396D7F13230b9fC5A3'
const nextNonce = await safeApiKit.getNextNonce(safeAddress)
chai.expect(nextNonce).to.be.equal(5)
})
Expand Down
18 changes: 9 additions & 9 deletions packages/api-kit/tests/e2e/getPendingTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let safeApiKit: SafeApiKit
describe('getPendingTransactions', () => {
before(async () => {
;({ safeApiKit } = await getServiceClient(
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
'0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
))
})

Expand All @@ -23,31 +23,31 @@ describe('getPendingTransactions', () => {
})

it('should fail if safeAddress is not checksummed', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205'.toLowerCase()
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78'.toLowerCase()
await chai
.expect(safeApiKit.getPendingTransactions(safeAddress))
.to.be.rejectedWith('Checksum address validation failed')
})

it('should return an empty list if there are no pending transactions', async () => {
const safeAddress = '0x72c346260a4887F0231af41178C1c818Ce34543f' // Safe without pending transaction
const safeAddress = '0xDa8dd250065F19f7A29564396D7F13230b9fC5A3' // Safe without pending transaction
const transactionList = await safeApiKit.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 = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with pending transaction
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78' // Safe with pending transaction
const transactionList = await safeApiKit.getPendingTransactions(safeAddress)
chai.expect(transactionList.count).to.be.equal(1)
chai.expect(transactionList.results.length).to.be.equal(1)
chai.expect(transactionList.count).to.be.equal(3)
chai.expect(transactionList.results.length).to.be.equal(3)
})

it('should return the the transaction list EIP-3770', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with pending transaction
const safeAddress = '0xF8ef84392f7542576F6b9d1b140334144930Ac78' // Safe with pending transaction
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const transactionList = await safeApiKit.getPendingTransactions(eip3770SafeAddress)
chai.expect(transactionList.count).to.be.equal(1)
chai.expect(transactionList.results.length).to.be.equal(1)
chai.expect(transactionList.count).to.be.equal(3)
chai.expect(transactionList.results.length).to.be.equal(3)
})
})
Loading

0 comments on commit 9f4e594

Please sign in to comment.