diff --git a/CHANGELOG.md b/CHANGELOG.md index b355bd5..01a094b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [2.0.3] - 2025-08-22 + +### Added Changes + +- `chainId` is mandatory in the `transaction()` method. +- For `send` and `estimate`, the `etherspotModularSdk` is initialized using the transaction's `chainId` rather than the provider's `chainId`. ## [2.0.2] - 2025-07-24 ### Added Changes diff --git a/__tests__/EtherspotTransactionKit.test.ts b/__tests__/EtherspotTransactionKit.test.ts index 137e854..16356c0 100644 --- a/__tests__/EtherspotTransactionKit.test.ts +++ b/__tests__/EtherspotTransactionKit.test.ts @@ -193,6 +193,7 @@ describe('EtherspotTransactionKit', () => { it('should use default values for optional parameters', () => { const txParams = { + chainId: 1, to: '0x1234567890123456789012345678901234567890', }; @@ -206,7 +207,7 @@ describe('EtherspotTransactionKit', () => { it('should throw error for missing to address', () => { expect(() => { - transactionKit.transaction({ to: '' }); + transactionKit.transaction({ chainId: 1, to: '' }); }).toThrow('transaction(): to is required.'); }); @@ -214,7 +215,7 @@ describe('EtherspotTransactionKit', () => { (isAddress as unknown as jest.Mock).mockReturnValue(false); expect(() => { - transactionKit.transaction({ to: 'invalid-address' }); + transactionKit.transaction({ chainId: 1, to: 'invalid-address' }); }).toThrow(`transaction(): 'invalid-address' is not a valid address.`); }); @@ -230,6 +231,7 @@ describe('EtherspotTransactionKit', () => { it('should throw error for invalid value', () => { expect(() => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: 'invalid', }); @@ -241,6 +243,7 @@ describe('EtherspotTransactionKit', () => { it('should throw error for negative value', () => { expect(() => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: '-1', }); @@ -251,6 +254,7 @@ describe('EtherspotTransactionKit', () => { it('should accept bigint value', () => { const txParams = { + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: BigInt(1000), }; @@ -266,6 +270,7 @@ describe('EtherspotTransactionKit', () => { describe('name', () => { beforeEach(() => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', }); }); @@ -319,6 +324,7 @@ describe('EtherspotTransactionKit', () => { describe('remove', () => { it('should remove named transaction', () => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', }); transactionKit.name({ transactionName: 'test' }); @@ -341,6 +347,7 @@ describe('EtherspotTransactionKit', () => { it('should throw error if transaction not named', () => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', }); @@ -355,6 +362,7 @@ describe('EtherspotTransactionKit', () => { describe('update', () => { beforeEach(() => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', }); transactionKit.name({ transactionName: 'test' }); @@ -380,6 +388,7 @@ describe('EtherspotTransactionKit', () => { describe('estimate', () => { beforeEach(() => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: '1000000000000000000', data: '0x1234', @@ -504,6 +513,7 @@ describe('EtherspotTransactionKit', () => { it('should allow transaction with value = 0 and data = 0x', async () => { const kit = new EtherspotTransactionKit(mockConfig); kit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: '0', data: '0x', @@ -547,6 +557,7 @@ describe('EtherspotTransactionKit', () => { describe('send', () => { beforeEach(() => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: '1000000000000000000', data: '0x1234', @@ -658,6 +669,7 @@ describe('EtherspotTransactionKit', () => { it('should allow sending transaction with value = 0 and data = 0x', async () => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: '0', data: '0x', @@ -743,6 +755,7 @@ describe('EtherspotTransactionKit', () => { it('should return state with transaction', () => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: '1000000000000000000', }); @@ -779,6 +792,7 @@ describe('EtherspotTransactionKit', () => { expect(() => { debugKit.setDebugMode(true); debugKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', }); debugKit.name({ transactionName: 'debug-tx' }); @@ -828,6 +842,7 @@ describe('EtherspotTransactionKit', () => { it('should reset all state', () => { // Set up some state transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', }); transactionKit.name({ transactionName: 'test' }); @@ -870,6 +885,7 @@ describe('EtherspotTransactionKit', () => { describe('State management during operations', () => { beforeEach(() => { transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', value: '1000000000000000000', }); @@ -929,23 +945,24 @@ describe('EtherspotTransactionKit', () => { }); describe('Provider integration', () => { - it('should handle provider chain ID changes', () => { + it('should use explicit chainId from transaction call', () => { mockProvider.getChainId.mockReturnValue(5); transactionKit.transaction({ + chainId: 1, to: '0x1234567890123456789012345678901234567890', }); const state = transactionKit.getState(); expect(state.workingTransaction?.chainId).toBe(1); - // Test with no explicit chainId transactionKit.transaction({ + chainId: 137, to: '0x1234567890123456789012345678901234567890', value: '1', }); const state2 = transactionKit.getState(); - expect(state2.workingTransaction?.chainId).toBe(1); // Should use default + expect(state2.workingTransaction?.chainId).toBe(137); }); it('should handle SDK instance errors gracefully', async () => { @@ -972,12 +989,14 @@ describe('Batch operations', () => { mockSdk.send.mockReset(); mockSdk.totalGasEstimated.mockReset(); transactionKit.transaction({ + chainId: 1, to: '0x1111111111111111111111111111111111111111', value: '1000000000000000000', }); transactionKit.name({ transactionName: 'tx1' }); transactionKit.addToBatch({ batchName: 'batch1' }); transactionKit.transaction({ + chainId: 1, to: '0x2222222222222222222222222222222222222222', value: '2000000000000000000', }); diff --git a/example/package-lock.json b/example/package-lock.json index c7fdadf..ff5a37c 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -29,11 +29,11 @@ }, "..": { "name": "@etherspot/transaction-kit", - "version": "2.0.0", + "version": "2.0.2", "license": "MIT", "dependencies": { "@etherspot/eip1271-verification-util": "0.1.2", - "@etherspot/modular-sdk": "6.1.0", + "@etherspot/modular-sdk": "6.1.1", "buffer": "6.0.3", "lodash": "4.17.21", "viem": "2.21.54" diff --git a/example/src/App.tsx b/example/src/App.tsx index 4d506f6..f36b2de 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -39,6 +39,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000dead', value: '1000000000000000000', }); @@ -57,6 +58,7 @@ const App = () => { transactionName: 'tx1', }) as INamedTransaction; named.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000beef', value: '2000000000000000000', }); @@ -86,6 +88,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000cafe', value: '3000000000000000000', }); @@ -104,6 +107,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000babe', value: '4000000000000000000', }); @@ -252,6 +256,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000f00d', value: '5000000000000000000', }); @@ -272,6 +277,7 @@ const App = () => { try { // Ensure tx3 is in batch1 kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000babe', value: '4000000000000000000', }); @@ -295,6 +301,7 @@ const App = () => { try { // Add tx5 to batch2 kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000c0de', value: '6000000000000000000', }); @@ -304,6 +311,7 @@ const App = () => { named.addToBatch({ batchName: 'batch2' }); // Add tx6 to batch2 kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000c0fe', value: '7000000000000000000', }); @@ -327,6 +335,7 @@ const App = () => { try { // Ensure tx3 is in batch1 kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000babe', value: '4000000000000000000', }); @@ -336,6 +345,7 @@ const App = () => { named.addToBatch({ batchName: 'batch1' }); // Now update tx3 in batch1 named.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000feed', value: '8880000000000000000', }); @@ -353,6 +363,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000aabb', value: '1000000000000000000', }); @@ -389,6 +400,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000cafe', value: '123', }); @@ -423,7 +435,7 @@ const App = () => { label: 'Add Transaction with Invalid Address', action: async (logAndUpdateState: (msg: string) => void) => { try { - kit.transaction({ to: 'not-an-address', value: '1' }); + kit.transaction({ chainId: 137, to: 'not-an-address', value: '1' }); logAndUpdateState('Should not see this.'); } catch (e) { logAndUpdateState('Error: ' + (e as Error).message); @@ -435,6 +447,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000dead', value: '-1', }); @@ -474,6 +487,7 @@ const App = () => { try { // Create empty batchD by adding and removing a tx kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000dede', value: '1', }); @@ -512,6 +526,7 @@ const App = () => { try { // Add tx10 to batchE kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000eeee', value: '1', }); @@ -533,6 +548,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000f0f0', value: '1', }); @@ -548,6 +564,7 @@ const App = () => { action: async (logAndUpdateState: (msg: string) => void) => { try { kit.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000f1f1', value: '1', }); @@ -556,6 +573,7 @@ const App = () => { }) as INamedTransaction; named.addToBatch({ batchName: 'batchF' }); named.transaction({ + chainId: 137, to: '0x000000000000000000000000000000000000f2f2', value: '2', }); diff --git a/lib/TransactionKit.ts b/lib/TransactionKit.ts index b8ed22a..3f7aee0 100644 --- a/lib/TransactionKit.ts +++ b/lib/TransactionKit.ts @@ -125,12 +125,12 @@ export class EtherspotTransactionKit implements IInitial { try { // Get SDK instance for the chain - const etherspotModulaSdk = + const etherspotModularSdk = await this.etherspotProvider.getSdk(walletAddressChainId); let walletAddress: string | undefined; try { - walletAddress = await etherspotModulaSdk.getCounterFactualAddress(); + walletAddress = await etherspotModularSdk.getCounterFactualAddress(); log( `Got wallet address from getCounterFactualAddress for chain ${walletAddressChainId}`, walletAddress, @@ -173,11 +173,21 @@ export class EtherspotTransactionKit implements IInitial { * - The transaction context is stored in the instance until it is named or added to a batch. */ transaction({ - chainId = 1, + chainId, to, value = '0', data = '0x', }: TransactionParams): ITransaction { + if (chainId === undefined || chainId === null) { + this.throwError( + 'transaction(): chainId is required. Please specify the target network explicitly.' + ); + } + + if (typeof chainId !== 'number' || !Number.isInteger(chainId)) { + this.throwError('transaction(): chainId must be a valid number.'); + } + if (!to) { this.throwError('transaction(): to is required.'); } @@ -186,10 +196,6 @@ export class EtherspotTransactionKit implements IInitial { this.throwError(`transaction(): '${to}' is not a valid address.`); } - if (typeof chainId !== 'number' || !Number.isInteger(chainId)) { - this.throwError('transaction(): chainId must be a valid number.'); - } - let parsedValue: bigint; try { parsedValue = typeof value === 'bigint' ? value : BigInt(value); @@ -618,7 +624,7 @@ export class EtherspotTransactionKit implements IInitial { const result = { to: this.workingTransaction?.to || '', chainId: - this.workingTransaction?.chainId || + this.workingTransaction?.chainId ?? this.etherspotProvider.getChainId(), errorMessage, errorType, @@ -653,11 +659,12 @@ export class EtherspotTransactionKit implements IInitial { // Only proceed if value and data are defined // Get fresh SDK instance to avoid state pollution log('estimate(): Getting SDK...', undefined, this.debugMode); - const etherspotModulaSdk = await this.etherspotProvider.getSdk( - this.etherspotProvider.getChainId(), + const transactionChainId = this.workingTransaction!.chainId; + const etherspotModularSdk = await this.etherspotProvider.getSdk( + transactionChainId, true ); - log('estimate(): Got SDK:', etherspotModulaSdk, this.debugMode); + log('estimate(): Got SDK:', etherspotModularSdk, this.debugMode); // Clear any existing operations log( @@ -665,7 +672,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - await etherspotModulaSdk.clearUserOpsFromBatch(); + await etherspotModularSdk.clearUserOpsFromBatch(); log( 'estimate(): Cleared user ops from batch.', undefined, @@ -678,7 +685,7 @@ export class EtherspotTransactionKit implements IInitial { this.workingTransaction, this.debugMode ); - await etherspotModulaSdk.addUserOpsToBatch({ + await etherspotModularSdk.addUserOpsToBatch({ to: this.workingTransaction.to || '', value: this.workingTransaction.value.toString(), data: this.workingTransaction.data, @@ -687,7 +694,7 @@ export class EtherspotTransactionKit implements IInitial { // Estimate the transaction log('estimate(): Estimating user op...', undefined, this.debugMode); - const userOp = await etherspotModulaSdk.estimate({ + const userOp = await etherspotModularSdk.estimate({ paymasterDetails, gasDetails, callGasLimit, @@ -696,7 +703,7 @@ export class EtherspotTransactionKit implements IInitial { // Calculate total gas cost log('estimate(): Calculating total gas...', undefined, this.debugMode); - const totalGas = await etherspotModulaSdk.totalGasEstimated(userOp); + const totalGas = await etherspotModularSdk.totalGasEstimated(userOp); log('estimate(): Got totalGas:', totalGas, this.debugMode); const totalGasBigInt = BigInt(totalGas.toString()); const maxFeePerGasBigInt = BigInt(userOp.maxFeePerGas.toString()); @@ -721,9 +728,7 @@ export class EtherspotTransactionKit implements IInitial { to: this.workingTransaction?.to || '', value: this.workingTransaction?.value?.toString(), data: this.workingTransaction?.data, - chainId: - this.workingTransaction?.chainId || - this.etherspotProvider.getChainId(), + chainId: this.workingTransaction!.chainId, cost, userOp, isEstimatedSuccessfully: true, @@ -846,7 +851,7 @@ export class EtherspotTransactionKit implements IInitial { const result = { to: this.workingTransaction?.to || '', chainId: - this.workingTransaction?.chainId || + this.workingTransaction?.chainId ?? this.etherspotProvider.getChainId(), errorMessage, errorType, @@ -861,15 +866,16 @@ export class EtherspotTransactionKit implements IInitial { try { // Get fresh SDK instance to avoid state pollution log('send(): Getting SDK...', undefined, this.debugMode); - const etherspotModulaSdk = await this.etherspotProvider.getSdk( - this.etherspotProvider.getChainId(), + const transactionChainId = this.workingTransaction!.chainId; + const etherspotModularSdk = await this.etherspotProvider.getSdk( + transactionChainId, true ); - log('send(): Got SDK:', etherspotModulaSdk, this.debugMode); + log('send(): Got SDK:', etherspotModularSdk, this.debugMode); // Clear any existing operations log('send(): Clearing user ops from batch...', undefined, this.debugMode); - await etherspotModulaSdk.clearUserOpsFromBatch(); + await etherspotModularSdk.clearUserOpsFromBatch(); log('send(): Cleared user ops from batch.', undefined, this.debugMode); // Add the transaction to the userOp Batch @@ -878,7 +884,7 @@ export class EtherspotTransactionKit implements IInitial { this.workingTransaction, this.debugMode ); - await etherspotModulaSdk.addUserOpsToBatch({ + await etherspotModularSdk.addUserOpsToBatch({ to: this.workingTransaction?.to || '', value: this.workingTransaction?.value?.toString(), data: this.workingTransaction?.data || '0x', @@ -889,7 +895,7 @@ export class EtherspotTransactionKit implements IInitial { let estimatedUserOp; try { log('send(): Estimating user op...', undefined, this.debugMode); - estimatedUserOp = await etherspotModulaSdk.estimate({ + estimatedUserOp = await etherspotModularSdk.estimate({ paymasterDetails, }); log('send(): Got estimated userOp:', estimatedUserOp, this.debugMode); @@ -923,7 +929,7 @@ export class EtherspotTransactionKit implements IInitial { // Calculate total gas cost (using the final UserOp values) log('send(): Calculating total gas...', undefined, this.debugMode); - const totalGas = await etherspotModulaSdk.totalGasEstimated(finalUserOp); + const totalGas = await etherspotModularSdk.totalGasEstimated(finalUserOp); log('send(): Got totalGas:', totalGas, this.debugMode); const totalGasBigInt = BigInt(totalGas.toString()); const maxFeePerGasBigInt = BigInt(finalUserOp.maxFeePerGas.toString()); @@ -945,7 +951,7 @@ export class EtherspotTransactionKit implements IInitial { let userOpHash: string; try { log('send(): Sending userOp...', undefined, this.debugMode); - userOpHash = await etherspotModulaSdk.send(finalUserOp); + userOpHash = await etherspotModularSdk.send(finalUserOp); log('send(): Got userOpHash:', userOpHash, this.debugMode); } catch (sendError) { const sendErrorMessage = parseEtherspotErrorMessage( @@ -965,7 +971,7 @@ export class EtherspotTransactionKit implements IInitial { value: this.workingTransaction?.value?.toString(), data: this.workingTransaction?.data, chainId: - this.workingTransaction?.chainId || + this.workingTransaction?.chainId ?? this.etherspotProvider.getChainId(), cost, userOp: finalUserOp, @@ -987,6 +993,14 @@ export class EtherspotTransactionKit implements IInitial { this.isSending = false; this.containsSendingError = false; + // Save transaction data before clearing state + const successResult = { + to: this.workingTransaction?.to || '', + value: this.workingTransaction?.value?.toString(), + data: this.workingTransaction?.data, + chainId: this.workingTransaction!.chainId, + }; + // Remove transaction from state after successful send const transactionName = this.selectedTransactionName; if (transactionName && this.namedTransactions[transactionName]) { @@ -1004,12 +1018,7 @@ export class EtherspotTransactionKit implements IInitial { this.clearWorkingState(); const result = { - to: this.workingTransaction?.to || '', - value: this.workingTransaction?.value?.toString(), - data: this.workingTransaction?.data, - chainId: - this.workingTransaction?.chainId || - this.etherspotProvider.getChainId(), + ...successResult, cost, userOp: finalUserOp, userOpHash, @@ -1127,13 +1136,13 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - const etherspotModulaSdk = await this.etherspotProvider.getSdk( + const etherspotModularSdk = await this.etherspotProvider.getSdk( batchChainId, true // force new instance ); log( `estimateBatches(): Got SDK for batch ${batchName}:`, - etherspotModulaSdk, + etherspotModularSdk, this.debugMode ); @@ -1143,7 +1152,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - await etherspotModulaSdk.clearUserOpsFromBatch(); + await etherspotModularSdk.clearUserOpsFromBatch(); log( `estimateBatches(): Cleared user ops from batch ${batchName}.`, undefined, @@ -1163,7 +1172,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - await etherspotModulaSdk.addUserOpsToBatch({ + await etherspotModularSdk.addUserOpsToBatch({ to: tx.to || '', value: tx.value?.toString(), data: tx.data, @@ -1187,7 +1196,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - const userOp = await etherspotModulaSdk.estimate({ + const userOp = await etherspotModularSdk.estimate({ paymasterDetails, }); log( @@ -1202,7 +1211,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - const totalGas = await etherspotModulaSdk.totalGasEstimated(userOp); + const totalGas = await etherspotModularSdk.totalGasEstimated(userOp); log( `estimateBatches(): Got totalGas for batch ${batchName}:`, totalGas, @@ -1400,13 +1409,13 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - const etherspotModulaSdk = await this.etherspotProvider.getSdk( + const etherspotModularSdk = await this.etherspotProvider.getSdk( batchChainId, true // force new instance ); log( `sendBatches(): Got SDK for batch ${batchName}:`, - etherspotModulaSdk, + etherspotModularSdk, this.debugMode ); @@ -1416,7 +1425,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - await etherspotModulaSdk.clearUserOpsFromBatch(); + await etherspotModularSdk.clearUserOpsFromBatch(); log( `sendBatches(): Cleared user ops from batch ${batchName}.`, undefined, @@ -1436,7 +1445,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - await etherspotModulaSdk.addUserOpsToBatch({ + await etherspotModularSdk.addUserOpsToBatch({ to: tx.to || '', value: tx.value?.toString(), data: tx.data, @@ -1462,7 +1471,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - estimatedUserOp = await etherspotModulaSdk.estimate({ + estimatedUserOp = await etherspotModularSdk.estimate({ paymasterDetails, }); log( @@ -1524,7 +1533,7 @@ export class EtherspotTransactionKit implements IInitial { this.debugMode ); const totalGas = - await etherspotModulaSdk.totalGasEstimated(finalUserOp); + await etherspotModularSdk.totalGasEstimated(finalUserOp); log( `sendBatches(): Got totalGas for batch ${batchName}:`, totalGas, @@ -1559,7 +1568,7 @@ export class EtherspotTransactionKit implements IInitial { undefined, this.debugMode ); - userOpHash = await etherspotModulaSdk.send(finalUserOp); + userOpHash = await etherspotModularSdk.send(finalUserOp); log( `sendBatches(): Got userOpHash for batch ${batchName}:`, userOpHash, @@ -1810,7 +1819,7 @@ export class EtherspotTransactionKit implements IInitial { timeout: number = 60 * 1000, retryInterval: number = 2000 ): Promise { - const etherspotModulaSdk = await this.getSdk(txChainId); + const etherspotModularSdk = await this.getSdk(txChainId); let transactionHash: string | null = null; const timeoutTotal = Date.now() + timeout; @@ -1818,7 +1827,8 @@ export class EtherspotTransactionKit implements IInitial { while (!transactionHash && Date.now() < timeoutTotal) { await new Promise((resolve) => setTimeout(resolve, retryInterval)); try { - transactionHash = await etherspotModulaSdk.getUserOpReceipt(userOpHash); + transactionHash = + await etherspotModularSdk.getUserOpReceipt(userOpHash); } catch (error) { console.error( 'Error fetching transaction hash. Please check if the transaction has gone through, or try to send the transaction again:', diff --git a/lib/interfaces/index.ts b/lib/interfaces/index.ts index b7cbc76..b7e3091 100644 --- a/lib/interfaces/index.ts +++ b/lib/interfaces/index.ts @@ -236,7 +236,7 @@ export interface ToParams { } export interface TransactionParams { - chainId?: number; + chainId: number; to: string; value?: bigint | string; data?: string; diff --git a/package-lock.json b/package-lock.json index d9a3688..112b41d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@etherspot/transaction-kit", - "version": "2.0.0", + "version": "2.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@etherspot/transaction-kit", - "version": "2.0.0", + "version": "2.0.2", "license": "MIT", "dependencies": { "@etherspot/eip1271-verification-util": "0.1.2", - "@etherspot/modular-sdk": "^6.1.1", + "@etherspot/modular-sdk": "6.1.1", "buffer": "6.0.3", "lodash": "4.17.21", "viem": "2.21.54" diff --git a/package.json b/package.json index e437530..61f19ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@etherspot/transaction-kit", "description": "Framework-agnostic Etherspot Transaction Kit", - "version": "2.0.2", + "version": "2.0.3", "main": "dist/cjs/index.js", "scripts": { "rollup:build": "NODE_OPTIONS=--max-old-space-size=8192 rollup -c --bundleConfigAsCjs",