@gelatocloud/gasless 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +182 -71
- package/_dist/account/actions/getFeeQuote.d.ts +4 -5
- package/_dist/account/actions/getFeeQuote.d.ts.map +1 -1
- package/_dist/account/actions/getFeeQuote.js +4 -9
- package/_dist/account/actions/getFeeQuote.js.map +1 -1
- package/_dist/account/actions/sendTransaction.d.ts +5 -6
- package/_dist/account/actions/sendTransaction.d.ts.map +1 -1
- package/_dist/account/actions/sendTransaction.js +3 -14
- package/_dist/account/actions/sendTransaction.js.map +1 -1
- package/_dist/account/actions/sendTransactionSync.d.ts +2 -2
- package/_dist/account/actions/sendTransactionSync.d.ts.map +1 -1
- package/_dist/account/actions/sendTransactionSync.js +3 -14
- package/_dist/account/actions/sendTransactionSync.js.map +1 -1
- package/_dist/account/adapters/gelato/index.d.ts.map +1 -1
- package/_dist/account/adapters/gelato/index.js +1 -1
- package/_dist/account/adapters/gelato/index.js.map +1 -1
- package/_dist/account/index.d.ts +2 -1
- package/_dist/account/index.d.ts.map +1 -1
- package/_dist/account/index.js +6 -5
- package/_dist/account/index.js.map +1 -1
- package/_dist/bundler/actions/estimateUserOperationGas.d.ts +1 -3
- package/_dist/bundler/actions/estimateUserOperationGas.d.ts.map +1 -1
- package/_dist/bundler/actions/estimateUserOperationGas.js +2 -2
- package/_dist/bundler/actions/estimateUserOperationGas.js.map +1 -1
- package/_dist/bundler/actions/getUserOperationGasPrice.d.ts +1 -2
- package/_dist/bundler/actions/getUserOperationGasPrice.d.ts.map +1 -1
- package/_dist/bundler/actions/getUserOperationGasPrice.js +2 -2
- package/_dist/bundler/actions/getUserOperationGasPrice.js.map +1 -1
- package/_dist/bundler/actions/getUserOperationQuote.d.ts +1 -3
- package/_dist/bundler/actions/getUserOperationQuote.d.ts.map +1 -1
- package/_dist/bundler/actions/getUserOperationQuote.js +2 -2
- package/_dist/bundler/actions/getUserOperationQuote.js.map +1 -1
- package/_dist/bundler/actions/prepareUserOperation.d.ts +1 -3
- package/_dist/bundler/actions/prepareUserOperation.d.ts.map +1 -1
- package/_dist/bundler/actions/prepareUserOperation.js +8 -47
- package/_dist/bundler/actions/prepareUserOperation.js.map +1 -1
- package/_dist/bundler/actions/sendUserOperation.d.ts +1 -3
- package/_dist/bundler/actions/sendUserOperation.d.ts.map +1 -1
- package/_dist/bundler/actions/sendUserOperation.js +2 -2
- package/_dist/bundler/actions/sendUserOperation.js.map +1 -1
- package/_dist/bundler/actions/sendUserOperationSync.d.ts +4 -4
- package/_dist/bundler/actions/sendUserOperationSync.d.ts.map +1 -1
- package/_dist/bundler/actions/sendUserOperationSync.js +14 -5
- package/_dist/bundler/actions/sendUserOperationSync.js.map +1 -1
- package/_dist/bundler/index.d.ts +5 -2
- package/_dist/bundler/index.d.ts.map +1 -1
- package/_dist/bundler/index.js +11 -16
- package/_dist/bundler/index.js.map +1 -1
- package/_dist/index.d.ts +1 -0
- package/_dist/index.d.ts.map +1 -1
- package/_dist/index.js +1 -0
- package/_dist/index.js.map +1 -1
- package/_dist/relayer/evm/actions/getGelatoStatus.d.ts +2 -2
- package/_dist/relayer/evm/actions/getGelatoStatus.d.ts.map +1 -1
- package/_dist/relayer/evm/actions/getGelatoStatus.js +12 -28
- package/_dist/relayer/evm/actions/getGelatoStatus.js.map +1 -1
- package/_dist/relayer/evm/actions/getStatus.d.ts +6 -17
- package/_dist/relayer/evm/actions/getStatus.d.ts.map +1 -1
- package/_dist/relayer/evm/actions/getStatus.js +12 -28
- package/_dist/relayer/evm/actions/getStatus.js.map +1 -1
- package/_dist/relayer/evm/actions/handleTerminalStatus.js +1 -1
- package/_dist/relayer/evm/actions/handleTerminalStatus.js.map +1 -1
- package/_dist/relayer/evm/actions/index.d.ts +1 -1
- package/_dist/relayer/evm/actions/index.d.ts.map +1 -1
- package/_dist/relayer/evm/actions/index.js +1 -1
- package/_dist/relayer/evm/actions/index.js.map +1 -1
- package/_dist/relayer/evm/actions/sendTransaction.d.ts +0 -2
- package/_dist/relayer/evm/actions/sendTransaction.d.ts.map +1 -1
- package/_dist/relayer/evm/actions/sendTransaction.js +1 -2
- package/_dist/relayer/evm/actions/sendTransaction.js.map +1 -1
- package/_dist/relayer/evm/actions/sendTransactionSync.d.ts +2 -0
- package/_dist/relayer/evm/actions/sendTransactionSync.d.ts.map +1 -1
- package/_dist/relayer/evm/actions/sendTransactionSync.js +25 -14
- package/_dist/relayer/evm/actions/sendTransactionSync.js.map +1 -1
- package/_dist/relayer/evm/actions/waitForGelatoStatus.d.ts +5 -1
- package/_dist/relayer/evm/actions/waitForGelatoStatus.d.ts.map +1 -1
- package/_dist/relayer/evm/actions/waitForGelatoStatus.js +16 -10
- package/_dist/relayer/evm/actions/waitForGelatoStatus.js.map +1 -1
- package/_dist/relayer/evm/actions/waitForReceipt.d.ts +5 -0
- package/_dist/relayer/evm/actions/waitForReceipt.d.ts.map +1 -0
- package/_dist/relayer/evm/actions/{waitForInclusion.js → waitForReceipt.js} +4 -4
- package/_dist/relayer/evm/actions/waitForReceipt.js.map +1 -0
- package/_dist/relayer/evm/actions/waitForStatus.d.ts +5 -1
- package/_dist/relayer/evm/actions/waitForStatus.d.ts.map +1 -1
- package/_dist/relayer/evm/actions/waitForStatus.js +13 -8
- package/_dist/relayer/evm/actions/waitForStatus.js.map +1 -1
- package/_dist/relayer/evm/index.d.ts +7 -5
- package/_dist/relayer/evm/index.d.ts.map +1 -1
- package/_dist/relayer/evm/index.js +17 -8
- package/_dist/relayer/evm/index.js.map +1 -1
- package/_dist/tsconfig.build.tsbuildinfo +1 -1
- package/_dist/types/payment.d.ts +2 -14
- package/_dist/types/payment.d.ts.map +1 -1
- package/_dist/types/payment.js +2 -12
- package/_dist/types/payment.js.map +1 -1
- package/_dist/types/schema.d.ts +32 -0
- package/_dist/types/schema.d.ts.map +1 -1
- package/_dist/types/schema.js +26 -1
- package/_dist/types/schema.js.map +1 -1
- package/_dist/utils/errors.d.ts +20 -0
- package/_dist/utils/errors.d.ts.map +1 -0
- package/_dist/utils/errors.js +40 -0
- package/_dist/utils/errors.js.map +1 -0
- package/_dist/utils/index.d.ts +2 -0
- package/_dist/utils/index.d.ts.map +1 -1
- package/_dist/utils/index.js +2 -0
- package/_dist/utils/index.js.map +1 -1
- package/_dist/utils/withTimeout.d.ts +76 -0
- package/_dist/utils/withTimeout.d.ts.map +1 -0
- package/_dist/utils/withTimeout.js +89 -0
- package/_dist/utils/withTimeout.js.map +1 -0
- package/package.json +1 -1
- package/_dist/relayer/evm/actions/waitForInclusion.d.ts +0 -4
- package/_dist/relayer/evm/actions/waitForInclusion.d.ts.map +0 -1
- package/_dist/relayer/evm/actions/waitForInclusion.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
- **Turbo Relayer**: The fastest, most efficient way to submit transactions on-chain with zero gas overhead, ideal for latency-sensitive workflows.
|
|
11
11
|
- **Turbo Relayer with Smart Account** - Leverage Smart Accounts for streamlined transaction encoding and signing while retaining Turbo-level performance.
|
|
12
12
|
- **ERC-4337 Bundler** - A fully compliant ERC-4337 bundler for native Account Abstraction flows.
|
|
13
|
-
- **
|
|
13
|
+
- **Sponsorship via Gas Tank** - Support for sponsored transactions using your Gas Tank.
|
|
14
14
|
- **2D nonce support** - Advanced nonce management using both `nonce` and `nonceKey` for parallelized execution.
|
|
15
15
|
- **Type-safe** - Implemented on top of [viem](https://viem.sh), offering complete TypeScript type safety and developer ergonomics.
|
|
16
16
|
- **Synchronous methods**: Send transaction and get the receipt in a single call
|
|
@@ -42,7 +42,7 @@ Direct gasless transaction relay without smart accounts. Best for simple sponsor
|
|
|
42
42
|
|
|
43
43
|
**Synchronous:**
|
|
44
44
|
```typescript
|
|
45
|
-
import { createGelatoEvmRelayerClient
|
|
45
|
+
import { createGelatoEvmRelayerClient } from '@gelatocloud/gasless';
|
|
46
46
|
import { baseSepolia } from 'viem/chains';
|
|
47
47
|
|
|
48
48
|
const relayer = createGelatoEvmRelayerClient({
|
|
@@ -54,8 +54,7 @@ const relayer = createGelatoEvmRelayerClient({
|
|
|
54
54
|
const receipt = await relayer.sendTransactionSync({
|
|
55
55
|
chainId: baseSepolia.id,
|
|
56
56
|
to: '0xTargetContract...',
|
|
57
|
-
data: '0xCalldata...'
|
|
58
|
-
payment: sponsored()
|
|
57
|
+
data: '0xCalldata...'
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
console.log(`Transaction hash: ${receipt.transactionHash}`);
|
|
@@ -63,7 +62,7 @@ console.log(`Transaction hash: ${receipt.transactionHash}`);
|
|
|
63
62
|
|
|
64
63
|
**Asynchronous:**
|
|
65
64
|
```typescript
|
|
66
|
-
import { createGelatoEvmRelayerClient, StatusCode
|
|
65
|
+
import { createGelatoEvmRelayerClient, StatusCode } from '@gelatocloud/gasless';
|
|
67
66
|
import { baseSepolia } from 'viem/chains';
|
|
68
67
|
|
|
69
68
|
const relayer = createGelatoEvmRelayerClient({
|
|
@@ -75,15 +74,14 @@ const relayer = createGelatoEvmRelayerClient({
|
|
|
75
74
|
const taskId = await relayer.sendTransaction({
|
|
76
75
|
chainId: baseSepolia.id,
|
|
77
76
|
to: '0xTargetContract...',
|
|
78
|
-
data: '0xCalldata...'
|
|
79
|
-
payment: sponsored()
|
|
77
|
+
data: '0xCalldata...'
|
|
80
78
|
});
|
|
81
79
|
|
|
82
80
|
// Poll for status separately
|
|
83
|
-
const status = await relayer.waitForStatus({ id: taskId });
|
|
81
|
+
const { status, receipt } = await relayer.waitForStatus({ id: taskId });
|
|
84
82
|
|
|
85
|
-
if (status.status === StatusCode.
|
|
86
|
-
console.log(`Transaction hash: ${
|
|
83
|
+
if (status.status === StatusCode.Success) {
|
|
84
|
+
console.log(`Transaction hash: ${receipt.transactionHash}`);
|
|
87
85
|
}
|
|
88
86
|
```
|
|
89
87
|
|
|
@@ -95,9 +93,7 @@ Gelato's smart account implementation with ERC-7821 delegation pattern.
|
|
|
95
93
|
```typescript
|
|
96
94
|
import {
|
|
97
95
|
createGelatoSmartAccountClient,
|
|
98
|
-
toGelatoSmartAccount
|
|
99
|
-
sponsored
|
|
100
|
-
} from '@gelatocloud/gasless';
|
|
96
|
+
toGelatoSmartAccount } from '@gelatocloud/gasless';
|
|
101
97
|
import { createPublicClient, http } from 'viem';
|
|
102
98
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
103
99
|
import { baseSepolia } from 'viem/chains';
|
|
@@ -123,9 +119,7 @@ const receipt = await client.sendTransactionSync({
|
|
|
123
119
|
calls: [
|
|
124
120
|
{ to: '0xContract1...', data: '0xCalldata1...' },
|
|
125
121
|
{ to: '0xContract2...', data: '0xCalldata2...' }
|
|
126
|
-
]
|
|
127
|
-
payment: sponsored()
|
|
128
|
-
// Optional: nonce or nonceKey for 2D nonce management
|
|
122
|
+
]// Optional: nonce or nonceKey for 2D nonce management
|
|
129
123
|
});
|
|
130
124
|
|
|
131
125
|
console.log(`Transaction hash: ${receipt.transactionHash}`);
|
|
@@ -136,47 +130,29 @@ console.log(`Transaction hash: ${receipt.transactionHash}`);
|
|
|
136
130
|
import {
|
|
137
131
|
createGelatoSmartAccountClient,
|
|
138
132
|
toGelatoSmartAccount,
|
|
139
|
-
StatusCode
|
|
140
|
-
sponsored
|
|
141
|
-
} from '@gelatocloud/gasless';
|
|
133
|
+
StatusCode } from '@gelatocloud/gasless';
|
|
142
134
|
|
|
143
135
|
// ... same setup as above ...
|
|
144
136
|
|
|
145
137
|
// Send transaction (returns immediately with task ID)
|
|
146
138
|
const taskId = await client.sendTransaction({
|
|
147
|
-
calls: [{ to: '0xContract...', data: '0xCalldata...' }]
|
|
148
|
-
payment: sponsored()
|
|
149
|
-
});
|
|
139
|
+
calls: [{ to: '0xContract...', data: '0xCalldata...' }] });
|
|
150
140
|
|
|
151
141
|
// Poll for status separately
|
|
152
142
|
const status = await client.waitForStatus({ id: taskId });
|
|
153
143
|
|
|
154
|
-
if (status.status === StatusCode.
|
|
144
|
+
if (status.status === StatusCode.Success) {
|
|
155
145
|
console.log(`Transaction hash: ${status.receipt.transactionHash}`);
|
|
156
146
|
}
|
|
157
147
|
```
|
|
158
148
|
|
|
159
|
-
**Fee Quote (Optional):** Pre-fetch a quote to avoid duplicate requests:
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
const quote = await client.getFeeQuote({
|
|
163
|
-
calls: [{ to: '0x...', data: '0x...' }],
|
|
164
|
-
payment: token('0xTokenAddress...')
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
const hash = await client.sendTransaction({
|
|
168
|
-
calls: [{ to: '0x...', data: '0x...' }],
|
|
169
|
-
payment: token('0xTokenAddress...'),
|
|
170
|
-
quote // Pass the pre-fetched quote
|
|
171
|
-
});
|
|
172
|
-
```
|
|
173
149
|
|
|
174
150
|
### Bundler (ERC-4337)
|
|
175
151
|
|
|
176
152
|
Compatible with any ERC-4337 smart account.
|
|
177
153
|
|
|
178
154
|
```typescript
|
|
179
|
-
import { createGelatoBundlerClient
|
|
155
|
+
import { createGelatoBundlerClient } from '@gelatocloud/gasless';
|
|
180
156
|
import { to7702SimpleSmartAccount } from 'permissionless/accounts';
|
|
181
157
|
import { createPublicClient, http } from 'viem';
|
|
182
158
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
@@ -200,7 +176,7 @@ const bundler = await createGelatoBundlerClient({
|
|
|
200
176
|
account,
|
|
201
177
|
client,
|
|
202
178
|
apiKey: process.env.GELATO_API_KEY,
|
|
203
|
-
|
|
179
|
+
sponsored: true
|
|
204
180
|
});
|
|
205
181
|
|
|
206
182
|
// Send a user operation
|
|
@@ -214,20 +190,6 @@ const { receipt } = await bundler.waitForUserOperationReceipt({ hash });
|
|
|
214
190
|
console.log(`Transaction hash: ${receipt.transactionHash}`);
|
|
215
191
|
```
|
|
216
192
|
|
|
217
|
-
## Payment Options
|
|
218
|
-
|
|
219
|
-
```typescript
|
|
220
|
-
import { sponsored, token, native } from '@gelatocloud/gasless';
|
|
221
|
-
|
|
222
|
-
// Gelato pays gas (gasless for user)
|
|
223
|
-
payment: sponsored()
|
|
224
|
-
|
|
225
|
-
// Pay with an ERC-20 token
|
|
226
|
-
payment: token('0xTokenAddress...')
|
|
227
|
-
|
|
228
|
-
// Pay with native currency (ETH, MATIC, etc.)
|
|
229
|
-
payment: native()
|
|
230
|
-
```
|
|
231
193
|
|
|
232
194
|
## API Reference
|
|
233
195
|
|
|
@@ -248,14 +210,13 @@ const client = createGelatoEvmRelayerClient({
|
|
|
248
210
|
|
|
249
211
|
| Method | Parameters | Returns | Description |
|
|
250
212
|
|--------|------------|---------|-------------|
|
|
251
|
-
| `sendTransaction` | `{ chainId, to, data,
|
|
252
|
-
| `sendTransactionSync` | `{ chainId, to, data,
|
|
213
|
+
| `sendTransaction` | `{ chainId, to, data, authorizationList?, context? }` | `Promise<Hex>` | Submit a transaction |
|
|
214
|
+
| `sendTransactionSync` | `{ chainId, to, data, timeout?, pollingInterval?, ... }` | `Promise<TransactionReceipt>` | Send and wait for receipt |
|
|
253
215
|
| `getStatus` | `{ id: string }` | `Promise<Status>` | Get transaction status |
|
|
254
|
-
| `waitForStatus` | `{ id: string }` | `Promise<TerminalStatus>` | Wait for final status |
|
|
255
|
-
| `
|
|
216
|
+
| `waitForStatus` | `{ id: string, timeout?, pollingInterval? }` | `Promise<TerminalStatus>` | Wait for final status |
|
|
217
|
+
| `waitForReceipt` | `{ id: string, timeout?, pollingInterval? }` | `Promise<TransactionReceipt>` | Wait for receipt, throws on failure |
|
|
256
218
|
| `getCapabilities` | - | `Promise<Capabilities>` | Get supported chains |
|
|
257
219
|
| `getFeeData` | `{ chainId, gas, l1Fee? }` | `Promise<FeeData>` | Get network fee data |
|
|
258
|
-
| `getFeeQuote` | `{ chainId, gas, token, l1Fee? }` | `Promise<FeeQuote>` | Get fee quote for token payment |
|
|
259
220
|
|
|
260
221
|
---
|
|
261
222
|
|
|
@@ -287,18 +248,39 @@ const client = await createGelatoSmartAccountClient({
|
|
|
287
248
|
|
|
288
249
|
| Method | Parameters | Returns | Description |
|
|
289
250
|
|--------|------------|---------|-------------|
|
|
290
|
-
| `sendTransaction` | `{ calls,
|
|
291
|
-
| `sendTransactionSync` | `{ calls,
|
|
292
|
-
| `getFeeQuote` | `{ calls, payment }` | `Promise<FeeQuote>` | Get fee quote |
|
|
251
|
+
| `sendTransaction` | `{ calls, nonce?, nonceKey?}` | `Promise<Hex>` | Send transaction(s) |
|
|
252
|
+
| `sendTransactionSync` | `{ calls, nonce?, nonceKey?, timeout?, pollingInterval?, ... }` | `Promise<TransactionReceipt>` | Send and wait for receipt |
|
|
293
253
|
| `getStatus` | `{ id: string }` | `Promise<Status>` | Get transaction status |
|
|
294
|
-
| `waitForStatus` | `{ id: string }` | `Promise<TerminalStatus>` | Wait for final status |
|
|
295
|
-
| `
|
|
254
|
+
| `waitForStatus` | `{ id: string, timeout?, pollingInterval? }` | `Promise<TerminalStatus>` | Wait for final status |
|
|
255
|
+
| `waitForReceipt` | `{ id: string, timeout?, pollingInterval? }` | `Promise<TransactionReceipt>` | Wait for receipt, throws on failure |
|
|
296
256
|
| `getCapabilities` | - | `Promise<Capabilities>` | Get supported chains |
|
|
297
257
|
|
|
298
258
|
**Nonce Options:**
|
|
299
259
|
- `nonce`: Explicit nonce value
|
|
300
260
|
- `nonceKey`: Key for 2D nonce (allows parallel transactions)
|
|
301
261
|
|
|
262
|
+
**Polling Configuration:**
|
|
263
|
+
|
|
264
|
+
All synchronous methods (`sendTransactionSync`, `sendUserOperationSync`, `waitForStatus`, `waitForReceipt`) support customizable polling behavior:
|
|
265
|
+
|
|
266
|
+
- `timeout` (optional): Maximum wait time in milliseconds
|
|
267
|
+
- Default: `120000` (2 minutes)
|
|
268
|
+
- Must not exceed `600000` (10 minutes)
|
|
269
|
+
- `pollingInterval` (optional): Frequency to check status in milliseconds
|
|
270
|
+
- Default: `1000` (1 second)
|
|
271
|
+
|
|
272
|
+
**Example:**
|
|
273
|
+
```typescript
|
|
274
|
+
// Wait up to 30 seconds, checking every 500ms
|
|
275
|
+
const receipt = await relayer.sendTransactionSync({
|
|
276
|
+
chainId: baseSepolia.id,
|
|
277
|
+
to: '0xTargetContract...',
|
|
278
|
+
data: '0xCalldata...',
|
|
279
|
+
timeout: 30000,
|
|
280
|
+
pollingInterval: 500
|
|
281
|
+
});
|
|
282
|
+
```
|
|
283
|
+
|
|
302
284
|
---
|
|
303
285
|
|
|
304
286
|
### Bundler API
|
|
@@ -312,7 +294,7 @@ const bundler = await createGelatoBundlerClient({
|
|
|
312
294
|
account: SmartAccount, // Any ERC-4337 smart account
|
|
313
295
|
client: Client, // viem public client
|
|
314
296
|
apiKey: string, // Your Gelato API key
|
|
315
|
-
|
|
297
|
+
sponsored: boolean, // Whether to use sponsored payment via Gas Tank
|
|
316
298
|
pollingInterval?: number // Polling interval in ms
|
|
317
299
|
});
|
|
318
300
|
```
|
|
@@ -322,7 +304,7 @@ const bundler = await createGelatoBundlerClient({
|
|
|
322
304
|
| Method | Parameters | Returns | Description |
|
|
323
305
|
|--------|------------|---------|-------------|
|
|
324
306
|
| `sendUserOperation` | `{ calls }` | `Promise<Hex>` | Send a user operation |
|
|
325
|
-
| `sendUserOperationSync` | `{ calls, timeout }` | `Promise<UserOperationReceipt>` | Send and wait for receipt |
|
|
307
|
+
| `sendUserOperationSync` | `{ calls, timeout?, pollingInterval? }` | `Promise<UserOperationReceipt>` | Send and wait for receipt |
|
|
326
308
|
| `waitForUserOperationReceipt` | `{ hash }` | `Promise<{ receipt }>` | Wait for receipt |
|
|
327
309
|
| `estimateUserOperationGas` | `UserOperationParams` | `Promise<GasEstimate>` | Estimate gas |
|
|
328
310
|
| `prepareUserOperation` | `UserOperationParams` | `Promise<UserOperation>` | Prepare operation |
|
|
@@ -339,18 +321,39 @@ const bundler = await createGelatoBundlerClient({
|
|
|
339
321
|
enum StatusCode {
|
|
340
322
|
Pending = 100, // Transaction pending
|
|
341
323
|
Submitted = 110, // Submitted to network
|
|
342
|
-
|
|
324
|
+
Success = 200, // Successfully included
|
|
343
325
|
Rejected = 400, // Rejected by relayer
|
|
344
326
|
Reverted = 500 // Reverted on-chain
|
|
345
327
|
}
|
|
346
328
|
```
|
|
347
329
|
|
|
348
|
-
####
|
|
330
|
+
#### ErrorCode
|
|
349
331
|
|
|
350
332
|
```typescript
|
|
351
|
-
enum
|
|
352
|
-
|
|
353
|
-
|
|
333
|
+
enum ErrorCode {
|
|
334
|
+
// JSON-RPC
|
|
335
|
+
ParseError = -32700,
|
|
336
|
+
InvalidRequest = -32600,
|
|
337
|
+
MethodNotFound = -32601,
|
|
338
|
+
InvalidParams = -32602,
|
|
339
|
+
InternalError = -32603,
|
|
340
|
+
TimeoutError = -32070,
|
|
341
|
+
|
|
342
|
+
// Relayer
|
|
343
|
+
Unauthorized = 4100,
|
|
344
|
+
UnsupportedPaymentToken = 4202,
|
|
345
|
+
InsufficientPayment = 4200,
|
|
346
|
+
InsufficientBalance = 4205,
|
|
347
|
+
UnsupportedChain = 4206,
|
|
348
|
+
UnknownTransactionId = 4208,
|
|
349
|
+
InvalidAuthorizationList = 4210,
|
|
350
|
+
SimulationFailed = 4211,
|
|
351
|
+
|
|
352
|
+
// Bundler
|
|
353
|
+
ValidationFailed = -32500,
|
|
354
|
+
PaymasterValidationFailed = -32501,
|
|
355
|
+
InvalidSignature = -32507,
|
|
356
|
+
ExecutionFailed = -32521
|
|
354
357
|
}
|
|
355
358
|
```
|
|
356
359
|
|
|
@@ -372,7 +375,7 @@ import { StatusCode } from '@gelatocloud/gasless';
|
|
|
372
375
|
const status = await client.waitForStatus({ id: hash });
|
|
373
376
|
|
|
374
377
|
switch (status.status) {
|
|
375
|
-
case StatusCode.
|
|
378
|
+
case StatusCode.Success:
|
|
376
379
|
console.log('Success:', status.receipt.transactionHash);
|
|
377
380
|
break;
|
|
378
381
|
case StatusCode.Rejected:
|
|
@@ -384,6 +387,114 @@ switch (status.status) {
|
|
|
384
387
|
}
|
|
385
388
|
```
|
|
386
389
|
|
|
390
|
+
## Error Handling
|
|
391
|
+
|
|
392
|
+
### Timeout Errors
|
|
393
|
+
|
|
394
|
+
Synchronous methods (`sendTransactionSync`, `waitForStatus`, `waitForReceipt`) throw `TimeoutError` when operations don't complete within the configured timeout:
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
import { TimeoutError } from '@gelatocloud/gasless';
|
|
398
|
+
|
|
399
|
+
try {
|
|
400
|
+
const receipt = await relayer.sendTransactionSync({
|
|
401
|
+
chainId: baseSepolia.id,
|
|
402
|
+
to: '0xTargetContract...',
|
|
403
|
+
data: '0xCalldata...',
|
|
404
|
+
timeout: 10000
|
|
405
|
+
});
|
|
406
|
+
} catch (error) {
|
|
407
|
+
if (error instanceof TimeoutError) {
|
|
408
|
+
console.error('Transaction timed out:', error.message);
|
|
409
|
+
// Transaction may still be pending - you can retry with longer timeout
|
|
410
|
+
// or use async methods to check status manually
|
|
411
|
+
} else {
|
|
412
|
+
console.error('Other error:', error);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Automatic Fallback on Timeout
|
|
418
|
+
|
|
419
|
+
When `sendTransactionSync` times out, it automatically falls back to polling for the transaction status. If you see a warning message like:
|
|
420
|
+
|
|
421
|
+
```
|
|
422
|
+
Transaction 0x... sync call timed out, falling back to polling for completion. DO NOT RETRY this transaction.
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
This means your transaction was successfully submitted but the sync method timed out. The SDK will continue polling for completion automatically. **Do not retry the operation** as this could result in duplicate transactions.
|
|
426
|
+
|
|
427
|
+
### Recovery Strategies
|
|
428
|
+
|
|
429
|
+
If a timeout occurs:
|
|
430
|
+
1. **Wait for automatic fallback**: `sendTransactionSync` automatically polls after timeout
|
|
431
|
+
2. **Check status manually**: Use `getStatus({ id })` to check if transaction is still processing
|
|
432
|
+
3. **Retry with longer timeout**: Increase `timeout` and call `waitForStatus` again
|
|
433
|
+
4. **Use async methods**: Switch to async pattern for more control
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
try {
|
|
437
|
+
// Try with default 10s timeout
|
|
438
|
+
const receipt = await relayer.sendTransactionSync({
|
|
439
|
+
chainId: baseSepolia.id,
|
|
440
|
+
to: '0xTargetContract...',
|
|
441
|
+
data: '0xCalldata...',
|
|
442
|
+
});
|
|
443
|
+
} catch (error) {
|
|
444
|
+
if (error instanceof TimeoutError) {
|
|
445
|
+
// Retry with 60s timeout
|
|
446
|
+
const taskId = await relayer.sendTransaction({
|
|
447
|
+
chainId: baseSepolia.id,
|
|
448
|
+
to: '0xTargetContract...',
|
|
449
|
+
data: '0xCalldata...',
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
const status = await relayer.waitForStatus({
|
|
453
|
+
id: taskId,
|
|
454
|
+
timeout: 60000
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
console.log('Transaction completed:', status);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### Configuration Limits
|
|
463
|
+
|
|
464
|
+
The SDK enforces the following limits to prevent denial of service:
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
import {
|
|
468
|
+
MIN_TIMEOUT,
|
|
469
|
+
MAX_TIMEOUT,
|
|
470
|
+
MIN_POLLING_INTERVAL,
|
|
471
|
+
MAX_POLLING_INTERVAL
|
|
472
|
+
} from '@gelatocloud/gasless';
|
|
473
|
+
|
|
474
|
+
console.log(MIN_TIMEOUT); // 1000ms (1 second)
|
|
475
|
+
console.log(MAX_TIMEOUT); // 600000ms (10 minutes)
|
|
476
|
+
console.log(MIN_POLLING_INTERVAL); // 100ms
|
|
477
|
+
console.log(MAX_POLLING_INTERVAL); // 300000ms (5 minutes)
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
You can set default timeout and polling interval at the client level:
|
|
481
|
+
|
|
482
|
+
```typescript
|
|
483
|
+
const relayer = createGelatoEvmRelayerClient({
|
|
484
|
+
apiKey: process.env.GELATO_API_KEY,
|
|
485
|
+
timeout: 30000, // Default 30 second timeout
|
|
486
|
+
pollingInterval: 500 // Default 500ms polling interval
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
// Methods use client defaults unless overridden
|
|
490
|
+
const receipt = await relayer.sendTransactionSync({
|
|
491
|
+
chainId: baseSepolia.id,
|
|
492
|
+
to: '0xTargetContract...',
|
|
493
|
+
data: '0xCalldata...',
|
|
494
|
+
// timeout: 60000 // Optional: override client default
|
|
495
|
+
});
|
|
496
|
+
```
|
|
497
|
+
|
|
387
498
|
## Requirements
|
|
388
499
|
|
|
389
500
|
- Node.js >= 23
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { type Call } from 'viem';
|
|
1
|
+
import { type Address, type Call } from 'viem';
|
|
2
2
|
import type { SmartAccount } from 'viem/account-abstraction';
|
|
3
|
-
import type {
|
|
4
|
-
import { type Payment } from '../../types/index.js';
|
|
3
|
+
import type { FeeQuote, GelatoEvmRelayerClient } from '../../relayer/index.js';
|
|
5
4
|
import type { GelatoSmartAccountImplementation } from '../adapters/types/index.js';
|
|
6
5
|
export type GetFeeQuoteParameters = {
|
|
7
|
-
|
|
6
|
+
token?: Address;
|
|
8
7
|
calls: Call[];
|
|
9
8
|
};
|
|
10
|
-
export declare const getFeeQuote: (client: GelatoEvmRelayerClient, account: SmartAccount<GelatoSmartAccountImplementation>,
|
|
9
|
+
export declare const getFeeQuote: (client: GelatoEvmRelayerClient, account: SmartAccount<GelatoSmartAccountImplementation>, parameters: GetFeeQuoteParameters) => Promise<FeeQuote>;
|
|
11
10
|
//# sourceMappingURL=getFeeQuote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFeeQuote.d.ts","sourceRoot":"","sources":["../../../account/actions/getFeeQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAe,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"getFeeQuote.d.ts","sourceRoot":"","sources":["../../../account/actions/getFeeQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,IAAI,EAAe,MAAM,MAAM,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAEnF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,EAC9B,SAAS,YAAY,CAAC,gCAAgC,CAAC,EACvD,YAAY,qBAAqB,KAChC,OAAO,CAAC,QAAQ,CAWlB,CAAC"}
|
|
@@ -2,19 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFeeQuote = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const { payment } = parameters;
|
|
9
|
-
const calls = payment.type === index_js_1.PaymentType.Token
|
|
10
|
-
? (0, index_js_2.appendPayment)(parameters.calls, payment.address, capabilities.feeCollector, 1n)
|
|
11
|
-
: parameters.calls;
|
|
12
|
-
const { estimatedGas, estimatedL1Fee } = await account.estimate({ calls });
|
|
5
|
+
const getFeeQuote = async (client, account, parameters) => {
|
|
6
|
+
const { token } = parameters;
|
|
7
|
+
const { estimatedGas, estimatedL1Fee } = await account.estimate({ calls: parameters.calls });
|
|
13
8
|
return await client.getFeeQuote({
|
|
14
9
|
chainId: account.chain.id,
|
|
15
10
|
gas: estimatedGas,
|
|
16
11
|
l1Fee: estimatedL1Fee,
|
|
17
|
-
token:
|
|
12
|
+
token: token ?? viem_1.zeroAddress
|
|
18
13
|
});
|
|
19
14
|
};
|
|
20
15
|
exports.getFeeQuote = getFeeQuote;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFeeQuote.js","sourceRoot":"","sources":["../../../account/actions/getFeeQuote.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"getFeeQuote.js","sourceRoot":"","sources":["../../../account/actions/getFeeQuote.ts"],"names":[],"mappings":";;;AAAA,+BAA4D;AAUrD,MAAM,WAAW,GAAG,KAAK,EAC9B,MAA8B,EAC9B,OAAuD,EACvD,UAAiC,EACd,EAAE;IACrB,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;IAE7B,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAE7F,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC;QAC9B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,GAAG,EAAE,YAAY;QACjB,KAAK,EAAE,cAAc;QACrB,KAAK,EAAE,KAAK,IAAI,kBAAW;KAC5B,CAAC,CAAC;AACL,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Hex } from 'viem';
|
|
1
|
+
import type { Call, Hex } from 'viem';
|
|
2
2
|
import type { SmartAccount } from 'viem/account-abstraction';
|
|
3
|
-
import type {
|
|
3
|
+
import type { GelatoEvmRelayerClient } from '../../relayer/index.js';
|
|
4
4
|
import type { GelatoSmartAccountImplementation } from '../adapters/types/index.js';
|
|
5
|
-
import { type GetFeeQuoteParameters } from './getFeeQuote.js';
|
|
6
5
|
export type NonceOrKey = {
|
|
7
6
|
nonce?: never;
|
|
8
7
|
nonceKey?: never;
|
|
@@ -13,8 +12,8 @@ export type NonceOrKey = {
|
|
|
13
12
|
nonce?: never;
|
|
14
13
|
nonceKey: bigint;
|
|
15
14
|
};
|
|
16
|
-
export type SendTransactionParameters =
|
|
17
|
-
|
|
15
|
+
export type SendTransactionParameters = NonceOrKey & {
|
|
16
|
+
calls: Call[];
|
|
18
17
|
};
|
|
19
|
-
export declare const sendTransaction: (client: GelatoEvmRelayerClient, account: SmartAccount<GelatoSmartAccountImplementation>,
|
|
18
|
+
export declare const sendTransaction: (client: GelatoEvmRelayerClient, account: SmartAccount<GelatoSmartAccountImplementation>, parameters: SendTransactionParameters) => Promise<Hex>;
|
|
20
19
|
//# sourceMappingURL=sendTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTransaction.d.ts","sourceRoot":"","sources":["../../../account/actions/sendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"sendTransaction.d.ts","sourceRoot":"","sources":["../../../account/actions/sendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAEnF,MAAM,MAAM,UAAU,GAClB;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,yBAAyB,GAAG,UAAU,GAAG;IACnD,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,QAAQ,sBAAsB,EAC9B,SAAS,YAAY,CAAC,gCAAgC,CAAC,EACvD,YAAY,yBAAyB,KACpC,OAAO,CAAC,GAAG,CAmBb,CAAC"}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendTransaction = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const sendTransaction = async (client, account, capabilities, parameters) => {
|
|
8
|
-
const { payment } = parameters;
|
|
9
|
-
const [quote, nonce, deployed] = await Promise.all([
|
|
10
|
-
payment.type === index_js_1.PaymentType.Token
|
|
11
|
-
? (parameters.quote ?? (await (0, getFeeQuote_js_1.getFeeQuote)(client, account, capabilities, parameters)))
|
|
12
|
-
: undefined,
|
|
4
|
+
const sendTransaction = async (client, account, parameters) => {
|
|
5
|
+
const { calls } = parameters;
|
|
6
|
+
const [nonce, deployed] = await Promise.all([
|
|
13
7
|
parameters.nonce ?? account.getNonce({ key: parameters.nonceKey }),
|
|
14
8
|
account.isDeployed()
|
|
15
9
|
]);
|
|
16
|
-
const calls = quote
|
|
17
|
-
? (0, index_js_2.appendPayment)(parameters.calls, quote.token.address, capabilities.feeCollector, quote.fee)
|
|
18
|
-
: parameters.calls;
|
|
19
10
|
const [data, authorizationList] = await Promise.all([
|
|
20
11
|
account.encodeCallData({ calls, nonce }),
|
|
21
12
|
deployed ? undefined : account.signAuthorization().then((x) => [x])
|
|
@@ -23,9 +14,7 @@ const sendTransaction = async (client, account, capabilities, parameters) => {
|
|
|
23
14
|
return await client.sendTransaction({
|
|
24
15
|
authorizationList,
|
|
25
16
|
chainId: account.chain.id,
|
|
26
|
-
context: quote?.context,
|
|
27
17
|
data,
|
|
28
|
-
payment,
|
|
29
18
|
to: account.address
|
|
30
19
|
});
|
|
31
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../account/actions/sendTransaction.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../account/actions/sendTransaction.ts"],"names":[],"mappings":";;;AAuBO,MAAM,eAAe,GAAG,KAAK,EAClC,MAA8B,EAC9B,OAAuD,EACvD,UAAqC,EACvB,EAAE;IAChB,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC;QAClE,OAAO,CAAC,UAAU,EAAE;KACrB,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAClD,OAAO,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACxC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KACpE,CAAC,CAAC;IAEH,OAAO,MAAM,MAAM,CAAC,eAAe,CAAC;QAClC,iBAAiB;QACjB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,IAAI;QACJ,EAAE,EAAE,OAAO,CAAC,OAAO;KACpB,CAAC,CAAC;AACL,CAAC,CAAC;AAvBW,QAAA,eAAe,mBAuB1B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { SmartAccount } from 'viem/account-abstraction';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GelatoEvmRelayerClient, TransactionReceipt } from '../../relayer/index.js';
|
|
3
3
|
import type { GelatoSmartAccountImplementation } from '../adapters/types/index.js';
|
|
4
4
|
import type { SendTransactionParameters } from './sendTransaction.js';
|
|
5
5
|
export type SendTransactionSyncParameters = SendTransactionParameters & {
|
|
6
6
|
timeout?: number;
|
|
7
7
|
};
|
|
8
|
-
export declare const sendTransactionSync: (client: GelatoEvmRelayerClient, account: SmartAccount<GelatoSmartAccountImplementation>,
|
|
8
|
+
export declare const sendTransactionSync: (client: GelatoEvmRelayerClient, account: SmartAccount<GelatoSmartAccountImplementation>, parameters: SendTransactionSyncParameters) => Promise<TransactionReceipt>;
|
|
9
9
|
//# sourceMappingURL=sendTransactionSync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTransactionSync.d.ts","sourceRoot":"","sources":["../../../account/actions/sendTransactionSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sendTransactionSync.d.ts","sourceRoot":"","sources":["../../../account/actions/sendTransactionSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,MAAM,6BAA6B,GAAG,yBAAyB,GAAG;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,sBAAsB,EAC9B,SAAS,YAAY,CAAC,gCAAgC,CAAC,EACvD,YAAY,6BAA6B,KACxC,OAAO,CAAC,kBAAkB,CAoB5B,CAAC"}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendTransactionSync = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const sendTransactionSync = async (client, account, capabilities, parameters) => {
|
|
8
|
-
const { payment, timeout } = parameters;
|
|
9
|
-
const [quote, nonce, deployed] = await Promise.all([
|
|
10
|
-
payment.type === index_js_1.PaymentType.Token
|
|
11
|
-
? (parameters.quote ?? (await (0, getFeeQuote_js_1.getFeeQuote)(client, account, capabilities, parameters)))
|
|
12
|
-
: undefined,
|
|
4
|
+
const sendTransactionSync = async (client, account, parameters) => {
|
|
5
|
+
const { timeout, calls } = parameters;
|
|
6
|
+
const [nonce, deployed] = await Promise.all([
|
|
13
7
|
parameters.nonce ?? account.getNonce({ key: parameters.nonceKey }),
|
|
14
8
|
account.isDeployed()
|
|
15
9
|
]);
|
|
16
|
-
const calls = quote
|
|
17
|
-
? (0, index_js_2.appendPayment)(parameters.calls, quote.token.address, capabilities.feeCollector, quote.fee)
|
|
18
|
-
: parameters.calls;
|
|
19
10
|
const [data, authorizationList] = await Promise.all([
|
|
20
11
|
account.encodeCallData({ calls, nonce }),
|
|
21
12
|
deployed ? undefined : account.signAuthorization().then((x) => [x])
|
|
@@ -23,9 +14,7 @@ const sendTransactionSync = async (client, account, capabilities, parameters) =>
|
|
|
23
14
|
return await client.sendTransactionSync({
|
|
24
15
|
authorizationList,
|
|
25
16
|
chainId: account.chain.id,
|
|
26
|
-
context: quote?.context,
|
|
27
17
|
data,
|
|
28
|
-
payment,
|
|
29
18
|
timeout,
|
|
30
19
|
to: account.address
|
|
31
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTransactionSync.js","sourceRoot":"","sources":["../../../account/actions/sendTransactionSync.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sendTransactionSync.js","sourceRoot":"","sources":["../../../account/actions/sendTransactionSync.ts"],"names":[],"mappings":";;;AASO,MAAM,mBAAmB,GAAG,KAAK,EACtC,MAA8B,EAC9B,OAAuD,EACvD,UAAyC,EACZ,EAAE;IAC/B,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;IAEtC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC;QAClE,OAAO,CAAC,UAAU,EAAE;KACrB,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAClD,OAAO,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACxC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KACpE,CAAC,CAAC;IAEH,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC;QACtC,iBAAiB;QACjB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,IAAI;QACJ,OAAO;QACP,EAAE,EAAE,OAAO,CAAC,OAAO;KACpB,CAAC,CAAC;AACL,CAAC,CAAC;AAxBW,QAAA,mBAAmB,uBAwB9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../account/adapters/gelato/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,cAAc,EACnB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../account/adapters/gelato/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,cAAc,EACnB,KAAK,YAAY,EAGjB,KAAK,SAAS,EAEf,MAAM,MAAM,CAAC;AACd,OAAO,EACL,eAAe,EAGf,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAWlC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAU1E,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC5E,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,YAAY,CACrD,gCAAgC,CAAC,OAAO,eAAe,EAAE,KAAK,CAAC,CAChE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,YAAY,4BAA4B,KACvC,4BAsKF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../account/adapters/gelato/index.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../account/adapters/gelato/index.ts"],"names":[],"mappings":";;;AAAA,+BAYc;AACd,kEAKkC;AAClC,0CAOsB;AACtB,uDAAwD;AACxD,mDAAoF;AAEpF,qCAA4E;AAC5E,iDAMwB;AAWjB,MAAM,oBAAoB,GAAG,CAClC,UAAwC,EACV,EAAE;IAChC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;IAErC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC5B,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAO,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK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