Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(relay-kit): Add Entrypoint v0.7 support #1103

Open
wants to merge 62 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
22ceffc
Add a specific userOperations module
yagopv Jan 10, 2025
5ab7193
eth_estimateUserOperationGas v0.7 support
yagopv Jan 13, 2025
ee61a99
Fix initCode
yagopv Jan 13, 2025
7a1a767
Change SafeOp structure
yagopv Jan 15, 2025
36c2da9
Working version for sponsored transactions
yagopv Jan 17, 2025
feda7e8
Update playgrounds
yagopv Jan 20, 2025
77c9973
Fix SigningMethod evaluated incorrectly
yagopv Jan 20, 2025
8eff392
Fix paymaster 0x0000...
yagopv Jan 20, 2025
dbe373d
Add more RPC calls
yagopv Jan 22, 2025
9fcea54
Update to work with new Pimlico paymasters
yagopv Jan 22, 2025
5eff169
Improvements
yagopv Jan 23, 2025
19b63c7
Update playgrounds
yagopv Jan 23, 2025
71048b4
Update comments in playgrounds
yagopv Jan 23, 2025
a27f78d
Improve SafeOperation
yagopv Jan 24, 2025
d94bbe8
Remove calculateSafeUserOperationHash
yagopv Jan 24, 2025
0cd4cfa
Improve dummySignatures retrieval
yagopv Jan 24, 2025
ce90770
Improve version management for SafeOperations
yagopv Jan 24, 2025
3c75c5d
Merge branch 'development' of https://github.com/safe-global/safe-cor…
yagopv Jan 24, 2025
958316c
Fix other kits
yagopv Jan 24, 2025
503a7cc
Refactor rpc schemas
yagopv Jan 27, 2025
c60dd14
Some improvements
yagopv Jan 27, 2025
38c85fb
Improve playgrounds
yagopv Jan 27, 2025
e1fa4b4
Fix SafeOperationV06
yagopv Jan 28, 2025
0a4ba15
Update playgrounds
yagopv Jan 28, 2025
3c524f3
uncomment
yagopv Jan 28, 2025
e245d03
Merge branch 'development' of https://github.com/safe-global/safe-cor…
yagopv Jan 28, 2025
e6559c1
Improve imports
yagopv Jan 28, 2025
a204a8a
Fix tests
yagopv Jan 29, 2025
800d2a0
Downgrade viem version breaking tests
yagopv Jan 30, 2025
d0e1147
Fix tests
yagopv Jan 30, 2025
dc086be
Merge branch 'development' of https://github.com/safe-global/safe-cor…
yagopv Jan 30, 2025
069e4f5
Fix nonce
yagopv Jan 30, 2025
6b5f563
Fix starter-kit
yagopv Jan 30, 2025
f57bab9
Fix api-kit tests
yagopv Jan 30, 2025
7529635
Fix some tests
yagopv Jan 31, 2025
705be62
Fix api kit tests
yagopv Jan 31, 2025
a8d7ba0
protocol-kit shouldn't be a dep of SafeOperation
yagopv Jan 31, 2025
d0d81e9
Merge branch 'development' of https://github.com/safe-global/safe-cor…
yagopv Jan 31, 2025
4a21b2c
Fix protocol-kit tests
yagopv Jan 31, 2025
0a3842f
Update test
yagopv Jan 31, 2025
bd31756
Not neccesary sharedSigner
yagopv Jan 31, 2025
5159d69
Add SafeOperationV07 tests
yagopv Feb 3, 2025
2e9e136
Fix tests
yagopv Feb 3, 2025
1d52221
Merge branch 'development' of https://github.com/safe-global/safe-cor…
yagopv Feb 3, 2025
f7ce30b
Improve gas estimation
yagopv Feb 4, 2025
9601e11
Improve SafeOperationFactory
yagopv Feb 4, 2025
479fd13
Add SPONSORSHIP_POLICY_ID env var
yagopv Feb 4, 2025
1b1b163
Improve estimator
yagopv Feb 4, 2025
a9f2c35
Add tests
yagopv Feb 4, 2025
e0ace1d
Add test
yagopv Feb 4, 2025
bfe5591
Fix checksum shared signer
yagopv Feb 5, 2025
e145ac4
Update api-kit-interoperability
yagopv Feb 5, 2025
6dc64ad
Update playground/utils.ts
yagopv Feb 6, 2025
3182c56
Update packages/protocol-kit/src/utils/signatures/utils.ts
yagopv Feb 6, 2025
36f2f16
Update packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts
yagopv Feb 6, 2025
6130264
Fix using viem sepolia chain in tests
yagopv Feb 6, 2025
c3a3e20
Merge branch 'feat/entrypoint-v7' of https://github.com/safe-global/s…
yagopv Feb 6, 2025
e49b3e8
Remove SafeOperation Interface
yagopv Feb 6, 2025
609aa1b
Renamed SafeOperationBase -> SafeOperation
yagopv Feb 6, 2025
d775fb4
Merge branch 'development' into feat/entrypoint-v7
yagopv Feb 6, 2025
028c582
Add test
yagopv Feb 6, 2025
480f84a
restore SafeOperation interface and rename the class to BaseSafeOpera…
yagopv Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/api-kit/src/SafeApiKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
import { validateEip3770Address, validateEthereumAddress } from '@safe-global/protocol-kit'
import {
Eip3770Address,
isSafeOperation,
SafeMultisigConfirmationListResponse,
SafeMultisigTransactionResponse,
SafeOperation,
SafeOperationConfirmationListResponse,
SafeOperationResponse
SafeOperationResponse,
UserOperationV06
} from '@safe-global/types-kit'
import { TRANSACTION_SERVICE_URLS } from './utils/config'
import { isEmptyData } from './utils'
import { getAddSafeOperationProps } from './utils/safeOperation'
import { getAddSafeOperationProps, isSafeOperation } from './utils/safeOperation'

export interface SafeApiKitConfig {
/** chainId - The chainId */
Expand Down Expand Up @@ -122,7 +122,7 @@
* @throws "Not Found"
* @throws "Ensure this field has at least 1 hexadecimal chars (not counting 0x)."
*/
async decodeData(data: string, to?: string): Promise<any> {

Check warning on line 125 in packages/api-kit/src/SafeApiKit.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
if (data === '') {
throw new Error('Invalid data')
}
Expand Down Expand Up @@ -258,7 +258,7 @@
return sendRequest({
url: `${this.#txServiceBaseUrl}/v1/safes/${address}/`,
method: HttpMethod.Get
}).then((response: any) => {

Check warning on line 261 in packages/api-kit/src/SafeApiKit.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
// FIXME remove when the transaction service returns the singleton property instead of masterCopy
if (!response?.singleton) {
const { masterCopy, ...rest } = response
Expand Down Expand Up @@ -347,7 +347,7 @@
const { address: delegator } = this.#getEip3770Address(delegatorAddress)
const signature = await signDelegate(signer, delegate, this.#chainId)

const body: any = {

Check warning on line 350 in packages/api-kit/src/SafeApiKit.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
safe: safeAddress ? this.#getEip3770Address(safeAddress).address : null,
delegate,
delegator,
Expand Down Expand Up @@ -415,7 +415,7 @@
return sendRequest({
url: `${this.#txServiceBaseUrl}/v1/safes/${address}/creation/`,
method: HttpMethod.Get
}).then((response: any) => {

Check warning on line 418 in packages/api-kit/src/SafeApiKit.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
// FIXME remove when the transaction service returns the singleton property instead of masterCopy
if (!response?.singleton) {
const { masterCopy, ...rest } = response
Expand Down Expand Up @@ -944,21 +944,23 @@
const getISOString = (date: number | undefined) =>
!date ? null : new Date(date * 1000).toISOString()

const userOperationV06 = userOperation as UserOperationV06

return sendRequest({
url: `${this.#txServiceBaseUrl}/v1/safes/${safeAddress}/safe-operations/`,
method: HttpMethod.Post,
body: {
initCode: isEmptyData(userOperationV06.initCode) ? null : userOperationV06.initCode,
nonce: userOperation.nonce,
initCode: isEmptyData(userOperation.initCode) ? null : userOperation.initCode,
callData: userOperation.callData,
callGasLimit: userOperation.callGasLimit.toString(),
verificationGasLimit: userOperation.verificationGasLimit.toString(),
preVerificationGas: userOperation.preVerificationGas.toString(),
maxFeePerGas: userOperation.maxFeePerGas.toString(),
maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas.toString(),
paymasterAndData: isEmptyData(userOperation.paymasterAndData)
paymasterAndData: isEmptyData(userOperationV06.paymasterAndData)
? null
: userOperation.paymasterAndData,
: userOperationV06.paymasterAndData,
entryPoint,
validAfter: getISOString(options?.validAfter),
validUntil: getISOString(options?.validUntil),
Expand Down
19 changes: 13 additions & 6 deletions packages/api-kit/src/utils/safeOperation.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { SafeOperation } from '@safe-global/types-kit'
import { AddSafeOperationProps } from '../types/safeTransactionServiceTypes'

export const getAddSafeOperationProps = async (safeOperation: SafeOperation) => {
const userOperation = safeOperation.toUserOperation()
const userOperation = safeOperation.getUserOperation()
userOperation.signature = safeOperation.encodedSignatures() // Without validity dates

return {
entryPoint: safeOperation.data.entryPoint,
moduleAddress: safeOperation.moduleAddress,
safeAddress: safeOperation.data.safe,
entryPoint: safeOperation.options.entryPoint,
moduleAddress: safeOperation.options.moduleAddress,
safeAddress: userOperation.sender,
userOperation,
options: {
validAfter: safeOperation.data.validAfter,
validUntil: safeOperation.data.validUntil
validAfter: safeOperation.options.validAfter,
validUntil: safeOperation.options.validUntil
}
}
}

export const isSafeOperation = (
obj: AddSafeOperationProps | SafeOperation
): obj is SafeOperation => {
return 'signatures' in obj && 'getUserOperation' in obj && 'getHash' in obj
}
3 changes: 1 addition & 2 deletions packages/api-kit/tests/e2e/addMessageSignature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import Safe, {
EthSafeSignature,
buildSignatureBytes,
hashSafeMessage,
SigningMethod,
buildContractSignature
} from '@safe-global/protocol-kit'
import { SafeMessage } from '@safe-global/types-kit'
import { SafeMessage, SigningMethod } from '@safe-global/types-kit'
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
Expand Down
7 changes: 1 addition & 6 deletions packages/api-kit/tests/e2e/addSafeOperation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ chai.use(chaiAsPromised)
const SIGNER_PK = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
const SAFE_ADDRESS = '0x60C4Ab82D06Fd7dFE9517e17736C2Dcc77443EF0' // 1/2 Safe (v1.4.1) with signer above being an owner + 4337 module enabled
const PAYMASTER_TOKEN_ADDRESS = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'
const PAYMASTER_ADDRESS = '0x0000000000325602a77416A16136FDafd04b299f'
const BUNDLER_URL = 'https://api.pimlico.io/v2/sepolia/rpc?apikey=pim_Vjs7ohRqWdvsjUegngf9Bg'
const TX_SERVICE_URL = 'https://safe-transaction-sepolia.staging.5afe.dev/api'

Expand Down Expand Up @@ -40,10 +39,7 @@ describe('addSafeOperation', () => {
signer: protocolKit.getSafeProvider().signer,
options: { safeAddress: SAFE_ADDRESS },
bundlerUrl: BUNDLER_URL,
paymasterOptions: {
paymasterTokenAddress: PAYMASTER_TOKEN_ADDRESS,
paymasterAddress: PAYMASTER_ADDRESS
}
safeModulesVersion: '0.2.0'
})
})

Expand Down Expand Up @@ -142,7 +138,6 @@ describe('addSafeOperation', () => {
transactions: [transferUSDC, transferUSDC]
})
const signedSafeOperation = await safe4337Pack.signSafeOperation(safeOperation)

// Get the number of SafeOperations before adding a new one
const safeOperationsBefore = await safeApiKit.getSafeOperationsByAddress({
safeAddress: SAFE_ADDRESS
Expand Down
12 changes: 6 additions & 6 deletions packages/api-kit/tests/e2e/confirmSafeOperation.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { Safe4337InitOptions, Safe4337Pack } from '@safe-global/relay-kit'
import { generateTransferCallData } from '@safe-global/relay-kit/test-utils'
import { Safe4337InitOptions, Safe4337Pack, SafeOperation } from '@safe-global/relay-kit'
import SafeApiKit from '@safe-global/api-kit/index'
import { getAddSafeOperationProps } from '@safe-global/api-kit/utils/safeOperation'
import { SafeOperation } from '@safe-global/types-kit'
import { generateTransferCallData } from '@safe-global/relay-kit/test-utils'
import { getApiKit, getEip1193Provider } from '../utils/setupKits'

chai.use(chaiAsPromised)

const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
const PRIVATE_KEY_2 = '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676' // 0x56e2C102c664De6DfD7315d12c0178b61D16F171
const PRIVATE_KEY_2 = '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44' // 0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B
const SAFE_ADDRESS = '0x60C4Ab82D06Fd7dFE9517e17736C2Dcc77443EF0' // 4337 enabled 1/2 Safe (v1.4.1) owned by PRIVATE_KEY_1 + PRIVATE_KEY_2
const TX_SERVICE_URL = 'https://safe-transaction-sepolia.staging.5afe.dev/api'
const BUNDLER_URL = 'https://api.pimlico.io/v2/sepolia/rpc?apikey=pim_Vjs7ohRqWdvsjUegngf9Bg'
Expand All @@ -34,7 +33,8 @@ describe('confirmSafeOperation', () => {
provider: options.provider || getEip1193Provider(),
signer: options.signer || PRIVATE_KEY_1,
options: { safeAddress: SAFE_ADDRESS },
bundlerUrl: BUNDLER_URL
bundlerUrl: BUNDLER_URL,
safeModulesVersion: '0.2.0'
})

const createSignature = async (safeOperation: SafeOperation, signer: string) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/api-kit/tests/e2e/confirmTransaction.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Safe, {
EthSafeSignature,
buildSignatureBytes,
SigningMethod,
buildContractSignature
} from '@safe-global/protocol-kit'
import {
SafeMultisigConfirmationResponse,
SafeTransactionDataPartial
SafeTransactionDataPartial,
SigningMethod
} from '@safe-global/types-kit'
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol-kit/src/Safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
Transaction,
EIP712TypedData,
SafeTransactionData,
CompatibilityFallbackHandlerContractType
CompatibilityFallbackHandlerContractType,
SigningMethod,
SigningMethodType
} from '@safe-global/types-kit'
import {
encodeSetupCallData,
Expand All @@ -39,8 +41,6 @@ import {
RemoveOwnerTxParams,
SafeConfig,
SafeConfigProps,
SigningMethod,
SigningMethodType,
SwapOwnerTxParams,
SafeModulesPaginated,
RemovePasskeyOwnerTxParams,
Expand Down
1 change: 0 additions & 1 deletion packages/protocol-kit/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './contracts'
export * from './safeConfig'
export * from './safeProvider'
export * from './signing'
export * from './transactions'
export * from './passkeys'
9 changes: 0 additions & 9 deletions packages/protocol-kit/src/types/signing.ts

This file was deleted.

8 changes: 6 additions & 2 deletions packages/protocol-kit/src/utils/signatures/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { recoverAddress } from 'viem'
import SafeProvider from '@safe-global/protocol-kit/SafeProvider'
import { SafeSignature, SafeEIP712Args, SafeTransactionData } from '@safe-global/types-kit'
import {
SafeSignature,
SafeEIP712Args,
SafeTransactionData,
SigningMethod
} from '@safe-global/types-kit'
import semverSatisfies from 'semver/functions/satisfies.js'
import { sameString } from '../address'
import { EthSafeSignature } from './SafeSignature'
import { getEip712MessageTypes, getEip712TxTypes } from '../eip-712'
import { SigningMethod } from '@safe-global/protocol-kit/types'
import { hashTypedData } from '../eip-712'
import { encodeTypedData } from '../eip-712/encode'
import { asHash, asHex } from '../types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
getSafeWithOwners,
itif
} from '@safe-global/testing-kit'
import { SafeTransactionDataPartial } from '@safe-global/types-kit'
import { SigningMethod } from '@safe-global/protocol-kit/types'
import { SafeTransactionDataPartial, SigningMethod } from '@safe-global/types-kit'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { getEip1193Provider } from './utils/setupProvider'
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol-kit/tests/e2e/eip1271.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
itif
} from '@safe-global/testing-kit'
import SafeMessage from '@safe-global/protocol-kit/utils/messages/SafeMessage'
import { OperationType, SafeTransactionDataPartial } from '@safe-global/types-kit'
import { SigningMethod } from '@safe-global/protocol-kit/types'
import { OperationType, SafeTransactionDataPartial, SigningMethod } from '@safe-global/types-kit'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { getEip1193Provider } from './utils/setupProvider'
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol-kit/tests/e2e/execution.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getERC20Mintable, safeVersionDeployed, setupTests, itif } from '@safe-global/testing-kit'
import Safe, { SigningMethod } from '@safe-global/protocol-kit/index'
import { TransactionOptions, MetaTransactionData } from '@safe-global/types-kit'
import Safe from '@safe-global/protocol-kit/index'
import { TransactionOptions, MetaTransactionData, SigningMethod } from '@safe-global/types-kit'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { waitSafeTxReceipt } from './utils/transactions'
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol-kit/tests/e2e/offChainSignatures.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { safeVersionDeployed, setupTests, itif } from '@safe-global/testing-kit'
import Safe, { SigningMethod } from '@safe-global/protocol-kit/index'
import { SafeMultisigTransactionResponse } from '@safe-global/types-kit'
import Safe from '@safe-global/protocol-kit/index'
import { SafeMultisigTransactionResponse, SigningMethod } from '@safe-global/types-kit'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { getEip1193Provider } from './utils/setupProvider'
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-kit/tests/e2e/utilsSignatures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
adjustVInSignature,
isTxHashSignedWithPrefix
} from '@safe-global/protocol-kit/utils/signatures'
import { SigningMethod } from '@safe-global/protocol-kit/index'
import { SigningMethod } from '@safe-global/types-kit'

const safeTxHash = '0x4de27e660bd23052b71c854b0188ef1c5b325b10075c70f27afe2343e5c287f5'
const signerAddress = '0xbc2BB26a6d821e69A38016f3858561a1D80d4182'
Expand Down
5 changes: 4 additions & 1 deletion packages/relay-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export * from './packs/gelato/GelatoRelayPack'
export * from './packs/gelato/types'

export * from './packs/safe-4337/Safe4337Pack'
export { default as EthSafeOperation } from './packs/safe-4337/SafeOperation'
export { default as BaseSafeOperation } from './packs/safe-4337/BaseSafeOperation'
export { default as SafeOperationV07 } from './packs/safe-4337/SafeOperationV07'
export { default as SafeOperationV06 } from './packs/safe-4337/SafeOperationV06'
export { default as SafeOperationFactory } from './packs/safe-4337/SafeOperationFactory'

export * from './packs/safe-4337/estimators'
export * from './packs/safe-4337/types'
Expand Down
65 changes: 65 additions & 0 deletions packages/relay-kit/src/packs/safe-4337/BaseSafeOperation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { EthSafeSignature } from '@safe-global/protocol-kit'
import SafeOperationV07 from './SafeOperationV07'
import { fixtures } from '@safe-global/relay-kit/test-utils'

describe('BaseSafeOperation', () => {
it('should add and get signatures', () => {
const safeOperation = new SafeOperationV07(fixtures.USER_OPERATION_V07, {
chainId: BigInt(fixtures.CHAIN_ID),
moduleAddress: fixtures.SAFE_4337_MODULE_ADDRESS_V0_3_0,
entryPoint: fixtures.ENTRYPOINT_ADDRESS_V07
})

safeOperation.addSignature(new EthSafeSignature('0xSigner', '0xSignature'))

expect(safeOperation.signatures.size).toBe(1)
expect(safeOperation.getSignature('0xSigner')).toMatchObject({
signer: '0xSigner',
data: '0xSignature',
isContractSignature: false
})
})

it('should encode the signatures', () => {
const safeOperation = new SafeOperationV07(fixtures.USER_OPERATION_V07, {
chainId: BigInt(fixtures.CHAIN_ID),
moduleAddress: fixtures.SAFE_4337_MODULE_ADDRESS_V0_3_0,
entryPoint: fixtures.ENTRYPOINT_ADDRESS_V07
})

safeOperation.addSignature(new EthSafeSignature('0xSigner1', '0xSignature1'))
safeOperation.addSignature(new EthSafeSignature('0xSigner2', '0xSignature2'))

expect(safeOperation.encodedSignatures()).toBe('0xSignature1Signature2')
})

it('should allow to retrieve the SafeOperation hash', () => {
const safeOperation = new SafeOperationV07(fixtures.USER_OPERATION_V07, {
chainId: BigInt(fixtures.CHAIN_ID),
moduleAddress: fixtures.SAFE_4337_MODULE_ADDRESS_V0_3_0,
entryPoint: fixtures.ENTRYPOINT_ADDRESS_V07
})

expect(safeOperation.getHash()).toBe(fixtures.USER_OPERATION_V07_HASH)
})

it('should allow to retrieve the UserOperation', () => {
const safeOperation = new SafeOperationV07(fixtures.USER_OPERATION_V07, {
chainId: BigInt(fixtures.CHAIN_ID),
moduleAddress: fixtures.SAFE_4337_MODULE_ADDRESS_V0_3_0,
entryPoint: fixtures.ENTRYPOINT_ADDRESS_V07,
validAfter: 60_000,
validUntil: 60_000
})

safeOperation.addSignature(new EthSafeSignature('0xSigner1', '0xSignature1'))
safeOperation.addSignature(new EthSafeSignature('0xSigner2', '0xSignature2'))

const userOperation = safeOperation.getUserOperation()

expect(userOperation).toMatchObject({
...fixtures.USER_OPERATION_V07,
signature: '0x00000000ea6000000000ea60Signature1Signature2'
})
})
})
Loading
Loading