11import chai from 'chai'
22import chaiAsPromised from 'chai-as-promised'
3- import sinon from 'sinon'
4- import { BundlerClient , Safe4337InitOptions , Safe4337Pack } from '@safe-global/relay-kit'
5- import { generateTransferCallData } from '@safe-global/relay-kit/packs/safe-4337/testing-utils/helpers'
3+ import { Safe4337InitOptions , Safe4337Pack , SafeOperation } from '@safe-global/relay-kit'
64import SafeApiKit from '@safe-global/api-kit/index'
75import { getAddSafeOperationProps } from '@safe-global/api-kit/utils/safeOperation'
8- import { SafeOperation } from '@safe-global/types-kit'
9- // Needs to be imported from dist folder in order to mock the getEip4337BundlerProvider function
10- import * as safe4337Utils from '@safe-global/relay-kit/dist/src/packs/safe-4337/utils'
6+ import { generateTransferCallData } from '@safe-global/relay-kit/test-utils'
117import { getApiKit , getEip1193Provider } from '../utils/setupKits'
12- import {
13- ENTRYPOINT_ADDRESS_V06 ,
14- RPC_4337_CALLS
15- } from '@safe-global/relay-kit/packs/safe-4337/constants'
168
179chai . use ( chaiAsPromised )
1810
19- const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676'
20- const PRIVATE_KEY_2 = '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44'
11+ const PRIVATE_KEY_1 = '0x83a415ca62e11f5fa5567e98450d0f82ae19ff36ef876c10a8d448c788a53676' // 0x56e2C102c664De6DfD7315d12c0178b61D16F171
12+ const PRIVATE_KEY_2 = '0xb88ad5789871315d0dab6fc5961d6714f24f35a6393f13a6f426dfecfc00ab44' // 0x9cCBDE03eDd71074ea9c49e413FA9CDfF16D263B
2113const SAFE_ADDRESS = '0x60C4Ab82D06Fd7dFE9517e17736C2Dcc77443EF0' // 4337 enabled 1/2 Safe (v1.4.1) owned by PRIVATE_KEY_1 + PRIVATE_KEY_2
2214const TX_SERVICE_URL = 'https://safe-transaction-sepolia.staging.5afe.dev/api'
23- const BUNDLER_URL = ` https://bundler.url`
15+ const BUNDLER_URL = ' https://api.pimlico.io/v2/sepolia/rpc?apikey=pim_Vjs7ohRqWdvsjUegngf9Bg'
2416const PAYMASTER_TOKEN_ADDRESS = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'
2517
2618let safeApiKit : SafeApiKit
@@ -31,8 +23,8 @@ let safeOpHash: string
3123describe ( 'confirmSafeOperation' , ( ) => {
3224 const transferUSDC = {
3325 to : PAYMASTER_TOKEN_ADDRESS ,
34- data : generateTransferCallData ( SAFE_ADDRESS , 100_000n ) ,
35- value : Date . now ( ) . toString ( ) , // Make sure that the transaction hash is unique
26+ data : generateTransferCallData ( SAFE_ADDRESS , 100_000n ) + Date . now ( ) . toString ( ) , // Make sure that the transaction hash is unique
27+ value : '0' ,
3628 operation : 0
3729 }
3830
@@ -41,7 +33,8 @@ describe('confirmSafeOperation', () => {
4133 provider : options . provider || getEip1193Provider ( ) ,
4234 signer : options . signer || PRIVATE_KEY_1 ,
4335 options : { safeAddress : SAFE_ADDRESS } ,
44- bundlerUrl : BUNDLER_URL
36+ bundlerUrl : BUNDLER_URL ,
37+ safeModulesVersion : '0.2.0'
4538 } )
4639
4740 const createSignature = async ( safeOperation : SafeOperation , signer : string ) => {
@@ -68,21 +61,7 @@ describe('confirmSafeOperation', () => {
6861 return signedSafeOperation
6962 }
7063
71- const requestStub = sinon . stub ( )
72-
7364 before ( async ( ) => {
74- sinon . stub ( safe4337Utils , 'getEip4337BundlerProvider' ) . returns ( {
75- request : requestStub
76- } as unknown as BundlerClient )
77-
78- requestStub . withArgs ( { method : RPC_4337_CALLS . CHAIN_ID } ) . resolves ( '0xaa36a7' )
79- requestStub
80- . withArgs ( { method : RPC_4337_CALLS . SUPPORTED_ENTRY_POINTS } )
81- . resolves ( [ ENTRYPOINT_ADDRESS_V06 ] )
82- requestStub
83- . withArgs ( { method : 'pimlico_getUserOperationGasPrice' } )
84- . resolves ( { fast : { maxFeePerGas : '0x3b9aca00' , maxPriorityFeePerGas : '0x3b9aca00' } } )
85-
8665 safe4337Pack = await getSafe4337Pack ( { signer : PRIVATE_KEY_1 } )
8766 safeApiKit = getApiKit ( TX_SERVICE_URL )
8867
@@ -91,10 +70,6 @@ describe('confirmSafeOperation', () => {
9170 safeOpHash = safeOperation . getHash ( )
9271 } )
9372
94- after ( ( ) => {
95- sinon . restore ( )
96- } )
97-
9873 describe ( 'should fail' , ( ) => {
9974 it ( 'if SafeOperation hash is empty' , async ( ) => {
10075 const signature = await createSignature ( safeOperation , PRIVATE_KEY_2 )
0 commit comments