Skip to content

Commit 7d07f28

Browse files
pedrocrvzclaude
andauthored
feat: add gas and skipSimulation params to sendTransaction (#46)
* feat: add gas and skipSimulation parameters to sendTransaction methods Add optional `gas` (bigint) and `skipSimulation` (boolean) parameters to both sendTransaction and sendTransactionSync across the relayer and account layers, passing them through to the RPC request params. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix. example --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4c8bb4c commit 7d07f28

9 files changed

Lines changed: 117 additions & 4 deletions

.changeset/sparkly-rules-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@gelatocloud/gasless": patch
3+
---
4+
5+
feat: skip simulation

src/account/actions/sendTransaction.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ describe('sendTransaction', () => {
9292
expect(account.getNonce).toHaveBeenCalledWith({ key: 5n });
9393
});
9494

95+
it('passes gas and skipSimulation through to client.sendTransaction', async () => {
96+
const account = createMockSmartAccount();
97+
98+
await sendTransaction(mockClient as never, account as never, {
99+
calls: [{ to: MOCK_ADDRESS, value: 0n }],
100+
gas: 100000n,
101+
skipSimulation: true
102+
});
103+
104+
expect(mockClient.sendTransaction).toHaveBeenCalledWith(
105+
{
106+
authorizationList: undefined,
107+
chainId: 1,
108+
data: MOCK_CALL_DATA,
109+
gas: 100000n,
110+
skipSimulation: true,
111+
to: MOCK_ADDRESS
112+
},
113+
undefined
114+
);
115+
});
116+
95117
it('passes retries option through to client.sendTransaction', async () => {
96118
const account = createMockSmartAccount();
97119

src/account/actions/sendTransaction.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export type NonceOrKey =
1919

2020
export type SendTransactionParameters = NonceOrKey & {
2121
calls: Call[];
22+
gas?: bigint;
23+
skipSimulation?: boolean;
2224
};
2325

2426
export const sendTransaction = async (
@@ -27,7 +29,7 @@ export const sendTransaction = async (
2729
parameters: SendTransactionParameters,
2830
options?: SendTransactionOptions
2931
): Promise<Hex> => {
30-
const { calls } = parameters;
32+
const { calls, gas, skipSimulation } = parameters;
3133

3234
const [nonce, deployed] = await Promise.all([
3335
parameters.nonce ?? account.getNonce({ key: parameters.nonceKey }),
@@ -44,6 +46,8 @@ export const sendTransaction = async (
4446
authorizationList,
4547
chainId: account.chain.id,
4648
data,
49+
gas,
50+
skipSimulation,
4751
to: account.address
4852
},
4953
options

src/account/actions/sendTransactionSync.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@ describe('sendTransactionSync', () => {
7777
);
7878
});
7979

80+
it('passes gas and skipSimulation through to client.sendTransactionSync', async () => {
81+
const account = createMockSmartAccount();
82+
83+
await sendTransactionSync(mockClient as never, account as never, {
84+
calls: [{ to: MOCK_ADDRESS, value: 0n }],
85+
gas: 100000n,
86+
skipSimulation: true
87+
});
88+
89+
expect(mockClient.sendTransactionSync).toHaveBeenCalledWith(
90+
{
91+
authorizationList: undefined,
92+
chainId: 1,
93+
data: MOCK_CALL_DATA,
94+
gas: 100000n,
95+
skipSimulation: true,
96+
to: MOCK_ADDRESS
97+
},
98+
undefined
99+
);
100+
});
101+
80102
it('passes retries option through to client.sendTransactionSync', async () => {
81103
const account = createMockSmartAccount();
82104

src/account/actions/sendTransactionSync.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const sendTransactionSync = async (
1212
parameters: SendTransactionSyncParameters,
1313
options?: SendTransactionSyncOptions
1414
): Promise<TransactionReceipt> => {
15-
const { calls } = parameters;
15+
const { calls, gas, skipSimulation } = parameters;
1616

1717
const [nonce, deployed] = await Promise.all([
1818
parameters.nonce ?? account.getNonce({ key: parameters.nonceKey }),
@@ -29,6 +29,8 @@ export const sendTransactionSync = async (
2929
authorizationList,
3030
chainId: account.chain.id,
3131
data,
32+
gas,
33+
skipSimulation,
3234
to: account.address
3335
},
3436
options

src/relayer/evm/actions/sendTransaction.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ describe('sendTransaction', () => {
6969
).rejects.toThrow();
7070
});
7171

72+
it('includes gas and skipSimulation in RPC params when provided', async () => {
73+
const { client, request } = createMockTransportClient();
74+
request.mockResolvedValue(MOCK_TX_HASH);
75+
76+
await sendTransaction(client, {
77+
chainId: 1,
78+
data: MOCK_CALL_DATA,
79+
gas: 100000n,
80+
skipSimulation: true,
81+
to: MOCK_ADDRESS
82+
});
83+
84+
expect(request).toHaveBeenCalledWith({
85+
method: 'relayer_sendTransaction',
86+
params: {
87+
authorizationList: undefined,
88+
chainId: '1',
89+
data: MOCK_CALL_DATA,
90+
gas: '100000',
91+
skipSimulation: true,
92+
to: MOCK_ADDRESS
93+
}
94+
});
95+
});
96+
7297
it('retries on matching error code and succeeds on retry', async () => {
7398
const { client, request } = createMockTransportClient();
7499
request

src/relayer/evm/actions/sendTransaction.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export type SendTransactionParameters = {
1111
authorizationList?: SignedAuthorizationList;
1212
chainId: number;
1313
data: Hex;
14+
gas?: bigint;
15+
skipSimulation?: boolean;
1416
to: Address;
1517
};
1618

@@ -23,7 +25,7 @@ export const sendTransaction = async (
2325
parameters: SendTransactionParameters,
2426
options?: SendTransactionOptions
2527
): Promise<Hex> => {
26-
const { chainId, data, to, authorizationList } = parameters;
28+
const { chainId, data, to, authorizationList, gas, skipSimulation } = parameters;
2729
const { retries } = options || {};
2830

2931
return withRetries(async () => {
@@ -36,6 +38,8 @@ export const sendTransaction = async (
3638
: undefined,
3739
chainId: chainId.toString(),
3840
data,
41+
gas: gas?.toString(),
42+
skipSimulation,
3943
to
4044
}
4145
});

src/relayer/evm/actions/sendTransactionSync.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,33 @@ describe('sendTransactionSync', () => {
9999
await expect(sendTransactionSync(client, baseParams)).rejects.toThrow();
100100
});
101101

102+
it('includes gas and skipSimulation in RPC params when provided', async () => {
103+
const { client, request } = createMockTransportClient();
104+
request.mockResolvedValue({
105+
chainId: 1,
106+
createdAt: 1700000000,
107+
id: MOCK_ID,
108+
receipt: mockRpcTransactionReceipt(),
109+
status: StatusCode.Success
110+
});
111+
112+
await sendTransactionSync(client, {
113+
...baseParams,
114+
gas: 100000n,
115+
skipSimulation: true
116+
});
117+
118+
expect(request).toHaveBeenCalledWith(
119+
expect.objectContaining({
120+
params: expect.objectContaining({
121+
gas: '100000',
122+
skipSimulation: true
123+
})
124+
}),
125+
expect.anything()
126+
);
127+
});
128+
102129
it('retries on matching error code and succeeds on retry', async () => {
103130
const { client, request } = createMockTransportClient();
104131
request

src/relayer/evm/actions/sendTransactionSync.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const sendTransactionSync = async (
3939
parameters: SendTransactionParameters,
4040
options?: SendTransactionSyncOptions
4141
): Promise<TransactionReceipt> => {
42-
const { chainId, data, to, authorizationList } = parameters;
42+
const { chainId, data, to, authorizationList, gas, skipSimulation } = parameters;
4343

4444
const {
4545
timeout = 120000,
@@ -61,6 +61,8 @@ export const sendTransactionSync = async (
6161
: undefined,
6262
chainId: chainId.toString(),
6363
data,
64+
gas: gas?.toString(),
65+
skipSimulation,
6466
// Always select the minimum timeout, either the http client timeout or the request timeout
6567
// The request timeout must always be greater so we can then parse the transaction id from the error
6668
// Otherwise the the http client will timeout locally

0 commit comments

Comments
 (0)