@gelatocloud/gasless 0.0.1 → 0.0.3

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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +417 -0
  3. package/_dist/account/actions/sendTransactionSync.d.ts +2 -2
  4. package/_dist/account/actions/sendTransactionSync.d.ts.map +1 -1
  5. package/_dist/account/actions/sendTransactionSync.js.map +1 -1
  6. package/_dist/account/index.d.ts +3 -3
  7. package/_dist/account/index.d.ts.map +1 -1
  8. package/_dist/account/index.js +1 -0
  9. package/_dist/account/index.js.map +1 -1
  10. package/_dist/relayer/evm/actions/getStatus.d.ts +77 -0
  11. package/_dist/relayer/evm/actions/getStatus.d.ts.map +1 -1
  12. package/_dist/relayer/evm/actions/getStatus.js +7 -1
  13. package/_dist/relayer/evm/actions/getStatus.js.map +1 -1
  14. package/_dist/relayer/evm/actions/handleTerminalStatus.d.ts +3 -0
  15. package/_dist/relayer/evm/actions/handleTerminalStatus.d.ts.map +1 -0
  16. package/_dist/relayer/evm/actions/handleTerminalStatus.js +29 -0
  17. package/_dist/relayer/evm/actions/handleTerminalStatus.js.map +1 -0
  18. package/_dist/relayer/evm/actions/index.d.ts +1 -0
  19. package/_dist/relayer/evm/actions/index.d.ts.map +1 -1
  20. package/_dist/relayer/evm/actions/index.js +1 -0
  21. package/_dist/relayer/evm/actions/index.js.map +1 -1
  22. package/_dist/relayer/evm/actions/sendTransactionSync.d.ts +2 -2
  23. package/_dist/relayer/evm/actions/sendTransactionSync.d.ts.map +1 -1
  24. package/_dist/relayer/evm/actions/sendTransactionSync.js +3 -1
  25. package/_dist/relayer/evm/actions/sendTransactionSync.js.map +1 -1
  26. package/_dist/relayer/evm/actions/waitForInclusion.d.ts +4 -0
  27. package/_dist/relayer/evm/actions/waitForInclusion.d.ts.map +1 -0
  28. package/_dist/relayer/evm/actions/waitForInclusion.js +11 -0
  29. package/_dist/relayer/evm/actions/waitForInclusion.js.map +1 -0
  30. package/_dist/relayer/evm/errors/index.d.ts +36 -0
  31. package/_dist/relayer/evm/errors/index.d.ts.map +1 -0
  32. package/_dist/relayer/evm/errors/index.js +62 -0
  33. package/_dist/relayer/evm/errors/index.js.map +1 -0
  34. package/_dist/relayer/evm/index.d.ts +3 -2
  35. package/_dist/relayer/evm/index.d.ts.map +1 -1
  36. package/_dist/relayer/evm/index.js +1 -0
  37. package/_dist/relayer/evm/index.js.map +1 -1
  38. package/_dist/tsconfig.build.tsbuildinfo +1 -1
  39. package/package.json +6 -1
  40. package/CHANGELOG.md +0 -9
  41. package/account/actions/getFeeQuote.ts +0 -34
  42. package/account/actions/index.ts +0 -3
  43. package/account/actions/sendTransaction.ts +0 -61
  44. package/account/actions/sendTransactionSync.ts +0 -51
  45. package/account/adapters/gelato/abi.ts +0 -13
  46. package/account/adapters/gelato/constants.ts +0 -13
  47. package/account/adapters/gelato/index.ts +0 -216
  48. package/account/adapters/index.ts +0 -1
  49. package/account/adapters/types/index.ts +0 -36
  50. package/account/index.ts +0 -60
  51. package/account/utils/delegation.ts +0 -9
  52. package/account/utils/estimation.ts +0 -29
  53. package/account/utils/index.ts +0 -2
  54. package/bundler/actions/estimateUserOperationGas.ts +0 -63
  55. package/bundler/actions/getUserOperationGasPrice.ts +0 -25
  56. package/bundler/actions/getUserOperationQuote.ts +0 -83
  57. package/bundler/actions/index.ts +0 -6
  58. package/bundler/actions/prepareUserOperation.ts +0 -437
  59. package/bundler/actions/sendUserOperation.ts +0 -64
  60. package/bundler/actions/sendUserOperationSync.ts +0 -71
  61. package/bundler/index.ts +0 -98
  62. package/constants/index.ts +0 -2
  63. package/index.ts +0 -4
  64. package/relayer/evm/actions/getCapabilities.ts +0 -22
  65. package/relayer/evm/actions/getFeeData.ts +0 -36
  66. package/relayer/evm/actions/getFeeQuote.ts +0 -39
  67. package/relayer/evm/actions/getGelatoStatus.ts +0 -99
  68. package/relayer/evm/actions/getStatus.ts +0 -92
  69. package/relayer/evm/actions/index.ts +0 -9
  70. package/relayer/evm/actions/sendTransaction.ts +0 -33
  71. package/relayer/evm/actions/sendTransactionSync.ts +0 -30
  72. package/relayer/evm/actions/waitForGelatoStatus.ts +0 -28
  73. package/relayer/evm/actions/waitForStatus.ts +0 -24
  74. package/relayer/evm/index.ts +0 -77
  75. package/relayer/index.ts +0 -1
  76. package/tsconfig.build.json +0 -19
  77. package/tsconfig.json +0 -8
  78. package/types/error.ts +0 -38
  79. package/types/index.ts +0 -3
  80. package/types/payment.ts +0 -23
  81. package/types/schema.ts +0 -28
  82. package/utils/index.ts +0 -2
  83. package/utils/payment.ts +0 -20
  84. package/utils/serialize.ts +0 -91
@@ -1,71 +0,0 @@
1
- import type { BaseError, Chain, Client, Transport } from 'viem';
2
- import {
3
- formatUserOperationReceipt,
4
- formatUserOperationRequest,
5
- getUserOperationError,
6
- type PrepareUserOperationParameters,
7
- type SendUserOperationParameters,
8
- type SmartAccount,
9
- type UserOperation,
10
- type UserOperationReceipt
11
- } from 'viem/account-abstraction';
12
- import { parseAccount } from 'viem/accounts';
13
- import type { CapabilitiesByChain } from '../../relayer/evm/actions/index.js';
14
- import { AccountNotFoundError, type Payment } from '../../types/index.js';
15
- import { prepareUserOperation } from './prepareUserOperation.js';
16
-
17
- export type SendUserOperationSyncParameters = SendUserOperationParameters & {
18
- timeout: number;
19
- };
20
-
21
- export const sendUserOperationSync = async <account extends SmartAccount | undefined>(
22
- client: Client<Transport, Chain | undefined, account>,
23
- parameters: SendUserOperationSyncParameters,
24
- capabilities: CapabilitiesByChain,
25
- payment?: Payment
26
- ): Promise<UserOperationReceipt> => {
27
- const { account: account_ = client.account, entryPointAddress, timeout } = parameters;
28
-
29
- if (!account_ && !parameters.sender) throw new AccountNotFoundError();
30
- const account = account_ ? parseAccount(account_) : undefined;
31
-
32
- const request = account
33
- ? await prepareUserOperation(
34
- client,
35
- parameters as unknown as PrepareUserOperationParameters,
36
- capabilities,
37
- payment,
38
- true
39
- )
40
- : parameters;
41
-
42
- // biome-ignore lint/style/noNonNullAssertion: copied from viem
43
- const signature = (parameters.signature ||
44
- (await account?.signUserOperation?.(request as UserOperation)))!;
45
-
46
- const rpcParameters = formatUserOperationRequest({
47
- ...request,
48
- signature
49
- } as UserOperation);
50
-
51
- try {
52
- const receipt = await client.request(
53
- {
54
- method: 'eth_sendUserOperationSync',
55
- // biome-ignore lint/style/noNonNullAssertion: copied from viem
56
- params: [rpcParameters, (entryPointAddress ?? account?.entryPoint?.address)!, { timeout }]
57
- } as never,
58
- { retryCount: 0 }
59
- );
60
-
61
- return formatUserOperationReceipt(receipt);
62
- } catch (error) {
63
- // biome-ignore lint/suspicious/noExplicitAny: copied from viem
64
- const calls = (parameters as any).calls;
65
- throw getUserOperationError(error as BaseError, {
66
- ...(request as UserOperation),
67
- ...(calls ? { calls } : {}),
68
- signature
69
- });
70
- }
71
- };
package/bundler/index.ts DELETED
@@ -1,98 +0,0 @@
1
- import { type Chain, type Client, http, type Transport } from 'viem';
2
- import {
3
- type BundlerActions,
4
- type BundlerClient,
5
- type BundlerClientConfig,
6
- createBundlerClient,
7
- type UserOperationReceipt
8
- } from 'viem/account-abstraction';
9
- import { GELATO_PROD_API, GELATO_STAGING_API } from '../constants/index.js';
10
- import { getCapabilities } from '../relayer/evm/actions/index.js';
11
- import { type Payment, PaymentType } from '../types/index.js';
12
- import {
13
- estimateUserOperationGas,
14
- type GetUserOperationGasPriceReturnType,
15
- type GetUserOperationQuoteParameters,
16
- type GetUserOperationQuoteReturnType,
17
- getUserOperationGasPrice,
18
- getUserOperationQuote,
19
- prepareUserOperation,
20
- type SendUserOperationSyncParameters,
21
- sendUserOperation,
22
- sendUserOperationSync
23
- } from './actions/index.js';
24
-
25
- export * from './actions/index.js';
26
-
27
- export type GelatoBundlerActions = Partial<BundlerActions> & {
28
- sendUserOperationSync: (
29
- parameters: SendUserOperationSyncParameters
30
- ) => Promise<UserOperationReceipt>;
31
- getUserOperationGasPrice: () => Promise<GetUserOperationGasPriceReturnType>;
32
- getUserOperationQuote: (
33
- parameters: GetUserOperationQuoteParameters
34
- ) => Promise<GetUserOperationQuoteReturnType>;
35
- };
36
-
37
- export type GelatoBundlerClient = BundlerClient & GelatoBundlerActions;
38
-
39
- export type GelatoBundlerClientConfig = Omit<BundlerClientConfig, 'transport' | 'userOperation'> & {
40
- client: Client<Transport, Chain>;
41
- payment?: Payment;
42
- apiKey: string;
43
- };
44
-
45
- export const createGelatoBundlerClient = async (
46
- parameters: GelatoBundlerClientConfig
47
- ): Promise<GelatoBundlerClient> => {
48
- const { client: client_, payment, apiKey } = parameters;
49
-
50
- // TODO: can just use prod endpoint in the future
51
- const base = client_.chain.testnet ? GELATO_STAGING_API : GELATO_PROD_API;
52
-
53
- let endpoint = `${base}/rpc/${client_.chain.id}`;
54
-
55
- if (payment) {
56
- endpoint += `?payment=${payment.type}`;
57
-
58
- if (payment.type === PaymentType.Token) {
59
- endpoint += `&address=${payment.address}`;
60
- }
61
- }
62
-
63
- const transport = http(endpoint, {
64
- fetchOptions: {
65
- headers: {
66
- 'X-API-Key': apiKey
67
- }
68
- }
69
- });
70
-
71
- const client = createBundlerClient({
72
- ...parameters,
73
- transport
74
- });
75
-
76
- const capabilities = (await getCapabilities(transport({})))[client_.chain.id];
77
-
78
- if (!capabilities) {
79
- throw new Error(`Chain not supported: ${client_.chain.id}`);
80
- }
81
-
82
- return client.extend(
83
- (client) =>
84
- ({
85
- estimateUserOperationGas: (parameters) =>
86
- estimateUserOperationGas(client, parameters, capabilities, payment),
87
- getUserOperationGasPrice: () => getUserOperationGasPrice(client, payment),
88
- getUserOperationQuote: (parameters) =>
89
- getUserOperationQuote(client, parameters, capabilities, payment),
90
- prepareUserOperation: (parameters) =>
91
- prepareUserOperation(client, parameters, capabilities, payment),
92
- sendUserOperation: (parameters) =>
93
- sendUserOperation(client, parameters, capabilities, payment),
94
- sendUserOperationSync: (parameters) =>
95
- sendUserOperationSync(client, parameters, capabilities, payment)
96
- }) as GelatoBundlerActions
97
- ) as unknown as GelatoBundlerClient;
98
- };
@@ -1,2 +0,0 @@
1
- export const GELATO_PROD_API = 'https://api.gelato.cloud';
2
- export const GELATO_STAGING_API = 'https://api.t.gelato.cloud';
package/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './account/index.js';
2
- export * from './bundler/index.js';
3
- export * from './relayer/index.js';
4
- export * from './types/index.js';
@@ -1,22 +0,0 @@
1
- import type { Transport } from 'viem';
2
- import { z } from 'zod';
3
- import { evmAddressSchema, evmTokenSchema } from '../../../types/index.js';
4
-
5
- const capabilitiesByChainSchema = z.object({
6
- feeCollector: evmAddressSchema,
7
- tokens: z.array(evmTokenSchema)
8
- });
9
-
10
- const capabilitiesSchema = z.record(z.string().pipe(z.coerce.number()), capabilitiesByChainSchema);
11
-
12
- export type CapabilitiesByChain = z.infer<typeof capabilitiesByChainSchema>;
13
- export type Capabilities = z.infer<typeof capabilitiesSchema>;
14
-
15
- export const getCapabilities = async (client: ReturnType<Transport>): Promise<Capabilities> => {
16
- const result = await client.request({
17
- method: 'relayer_getCapabilities',
18
- params: []
19
- });
20
-
21
- return capabilitiesSchema.parse(result);
22
- };
@@ -1,36 +0,0 @@
1
- import type { Address, Transport } from 'viem';
2
- import { z } from 'zod';
3
- import { evmTokenSchema } from '../../../types/index.js';
4
-
5
- const feeDataSchema = z.object({
6
- chainId: z.coerce.number(),
7
- context: z.unknown().optional(),
8
- expiry: z.number(),
9
- gasPrice: z.coerce.bigint(),
10
- rate: z.number(),
11
- token: evmTokenSchema
12
- });
13
-
14
- export type FeeData = z.infer<typeof feeDataSchema>;
15
-
16
- export type GetFeeDataParameters = {
17
- chainId: number;
18
- token: Address;
19
- };
20
-
21
- export const getFeeData = async (
22
- client: ReturnType<Transport>,
23
- parameters: GetFeeDataParameters
24
- ): Promise<FeeData> => {
25
- const { chainId, token } = parameters;
26
-
27
- const result = await client.request({
28
- method: 'relayer_getFeeData',
29
- params: {
30
- chainId: chainId.toString(),
31
- token
32
- }
33
- });
34
-
35
- return feeDataSchema.parse(result);
36
- };
@@ -1,39 +0,0 @@
1
- import type { Address, Transport } from 'viem';
2
- import { z } from 'zod';
3
- import { evmTokenSchema } from '../../../types/index.js';
4
-
5
- const feeQuote = z.object({
6
- chainId: z.coerce.number(),
7
- context: z.unknown().optional(),
8
- expiry: z.number(),
9
- fee: z.coerce.bigint(),
10
- token: evmTokenSchema
11
- });
12
-
13
- export type FeeQuote = z.infer<typeof feeQuote>;
14
-
15
- export type GetFeeQuoteParameters = {
16
- chainId: number;
17
- gas: bigint;
18
- l1Fee?: bigint;
19
- token: Address;
20
- };
21
-
22
- export const getFeeQuote = async (
23
- client: ReturnType<Transport>,
24
- parameters: GetFeeQuoteParameters
25
- ): Promise<FeeQuote> => {
26
- const { chainId, gas, l1Fee, token } = parameters;
27
-
28
- const result = await client.request({
29
- method: 'relayer_getFeeQuote',
30
- params: {
31
- chainId: chainId.toString(),
32
- gas: gas.toString(),
33
- l1Fee: l1Fee ? l1Fee.toString() : undefined,
34
- token
35
- }
36
- });
37
-
38
- return feeQuote.parse(result);
39
- };
@@ -1,99 +0,0 @@
1
- import type { Transport } from 'viem';
2
- import { z } from 'zod';
3
- import { evmAddressSchema, hexData32Schema, hexDataSchema } from '../../../types/index.js';
4
-
5
- export enum GelatoStatusCode {
6
- Pending = 100,
7
- Submitted = 110,
8
- Included = 200,
9
- Finalized = 210,
10
- Rejected = 400,
11
- Reverted = 500
12
- }
13
-
14
- const logSchema = z.object({
15
- address: evmAddressSchema,
16
- data: hexDataSchema,
17
- topics: z.array(hexData32Schema)
18
- });
19
-
20
- const receiptSchema = z.object({
21
- blockHash: hexData32Schema,
22
- blockNumber: z.coerce.bigint(),
23
- gasUsed: z.coerce.bigint(),
24
- logs: z.array(logSchema).optional(),
25
- transactionHash: hexData32Schema
26
- });
27
-
28
- const baseStatusSchema = z.object({
29
- chainId: z.coerce.number(),
30
- createdAt: z.number()
31
- });
32
-
33
- const pendingStatusSchema = baseStatusSchema.extend({
34
- status: z.literal(GelatoStatusCode.Pending)
35
- });
36
-
37
- const submittedStatusSchema = baseStatusSchema.extend({
38
- hash: hexData32Schema,
39
- status: z.literal(GelatoStatusCode.Submitted)
40
- });
41
-
42
- const includedStatusSchema = baseStatusSchema.extend({
43
- receipt: receiptSchema,
44
- status: z.literal(GelatoStatusCode.Included)
45
- });
46
-
47
- const finalizedStatusSchema = baseStatusSchema.extend({
48
- receipt: receiptSchema,
49
- status: z.literal(GelatoStatusCode.Finalized)
50
- });
51
-
52
- const rejectedStatusSchema = baseStatusSchema.extend({
53
- data: z.unknown().optional(),
54
- message: z.string(),
55
- status: z.literal(GelatoStatusCode.Rejected)
56
- });
57
-
58
- const revertedStatusSchema = baseStatusSchema.extend({
59
- data: z.string(),
60
- message: z.string().optional(),
61
- status: z.literal(GelatoStatusCode.Reverted)
62
- });
63
-
64
- export const gelatoTerminalStatusSchema = z.discriminatedUnion('status', [
65
- finalizedStatusSchema,
66
- rejectedStatusSchema,
67
- revertedStatusSchema
68
- ]);
69
-
70
- export const gelatoStatusSchema = z.discriminatedUnion('status', [
71
- pendingStatusSchema,
72
- submittedStatusSchema,
73
- includedStatusSchema,
74
- finalizedStatusSchema,
75
- rejectedStatusSchema,
76
- revertedStatusSchema
77
- ]);
78
-
79
- export type GelatoTerminalStatus = z.infer<typeof gelatoTerminalStatusSchema>;
80
-
81
- export type GelatoStatus = z.infer<typeof gelatoStatusSchema>;
82
-
83
- export type GetGelatoStatusParameters = {
84
- id: string;
85
- };
86
-
87
- export const getGelatoStatus = async (
88
- client: ReturnType<Transport>,
89
- parameters: GetGelatoStatusParameters
90
- ): Promise<GelatoStatus> => {
91
- const { id } = parameters;
92
-
93
- const result = await client.request({
94
- method: 'gelato_getStatus',
95
- params: { id }
96
- });
97
-
98
- return gelatoStatusSchema.parse(result);
99
- };
@@ -1,92 +0,0 @@
1
- import type { Transport } from 'viem';
2
- import { z } from 'zod';
3
- import { evmAddressSchema, hexData32Schema, hexDataSchema } from '../../../types/index.js';
4
-
5
- export enum StatusCode {
6
- Pending = 100,
7
- Submitted = 110,
8
- Included = 200,
9
- Rejected = 400,
10
- Reverted = 500
11
- }
12
-
13
- const logSchema = z.object({
14
- address: evmAddressSchema,
15
- data: hexDataSchema,
16
- topics: z.array(hexData32Schema)
17
- });
18
-
19
- const receiptSchema = z.object({
20
- blockHash: hexData32Schema,
21
- blockNumber: z.coerce.bigint(),
22
- gasUsed: z.coerce.bigint(),
23
- logs: z.array(logSchema).optional(),
24
- transactionHash: hexData32Schema
25
- });
26
-
27
- const baseStatusSchema = z.object({
28
- chainId: z.coerce.number(),
29
- createdAt: z.number()
30
- });
31
-
32
- const pendingStatusSchema = baseStatusSchema.extend({
33
- status: z.literal(StatusCode.Pending)
34
- });
35
-
36
- const submittedStatusSchema = baseStatusSchema.extend({
37
- hash: hexData32Schema,
38
- status: z.literal(StatusCode.Submitted)
39
- });
40
-
41
- const includedStatusSchema = baseStatusSchema.extend({
42
- receipt: receiptSchema,
43
- status: z.literal(StatusCode.Included)
44
- });
45
-
46
- const rejectedStatusSchema = baseStatusSchema.extend({
47
- data: z.unknown().optional(),
48
- message: z.string(),
49
- status: z.literal(StatusCode.Rejected)
50
- });
51
-
52
- const revertedStatusSchema = baseStatusSchema.extend({
53
- data: z.string(),
54
- message: z.string().optional(),
55
- status: z.literal(StatusCode.Reverted)
56
- });
57
-
58
- export const terminalStatusSchema = z.discriminatedUnion('status', [
59
- includedStatusSchema,
60
- rejectedStatusSchema,
61
- revertedStatusSchema
62
- ]);
63
-
64
- export const statusSchema = z.discriminatedUnion('status', [
65
- pendingStatusSchema,
66
- submittedStatusSchema,
67
- includedStatusSchema,
68
- rejectedStatusSchema,
69
- revertedStatusSchema
70
- ]);
71
-
72
- export type TerminalStatus = z.infer<typeof terminalStatusSchema>;
73
-
74
- export type Status = z.infer<typeof statusSchema>;
75
-
76
- export type GetStatusParameters = {
77
- id: string;
78
- };
79
-
80
- export const getStatus = async (
81
- client: ReturnType<Transport>,
82
- parameters: GetStatusParameters
83
- ): Promise<Status> => {
84
- const { id } = parameters;
85
-
86
- const result = await client.request({
87
- method: 'relayer_getStatus',
88
- params: { id }
89
- });
90
-
91
- return statusSchema.parse(result);
92
- };
@@ -1,9 +0,0 @@
1
- export * from './getCapabilities.js';
2
- export * from './getFeeData.js';
3
- export * from './getFeeQuote.js';
4
- export * from './getGelatoStatus.js';
5
- export * from './getStatus.js';
6
- export * from './sendTransaction.js';
7
- export * from './sendTransactionSync.js';
8
- export * from './waitForGelatoStatus.js';
9
- export * from './waitForStatus.js';
@@ -1,33 +0,0 @@
1
- import type { Address, Hex, SignedAuthorizationList, Transport } from 'viem';
2
- import { hexData32Schema, type Payment } from '../../../types/index.js';
3
- import { formatAuthorization } from '../../../utils/index.js';
4
-
5
- export type SendTransactionParameters = {
6
- authorizationList?: SignedAuthorizationList;
7
- chainId: number;
8
- context?: unknown;
9
- data: Hex;
10
- payment: Payment;
11
- to: Address;
12
- };
13
-
14
- export const sendTransaction = async (
15
- client: ReturnType<Transport>,
16
- parameters: SendTransactionParameters
17
- ): Promise<Hex> => {
18
- const { chainId, data, to, payment, context, authorizationList } = parameters;
19
-
20
- const result = await client.request({
21
- method: 'relayer_sendTransaction',
22
- params: {
23
- authorizationList: authorizationList ? authorizationList.map(formatAuthorization) : undefined,
24
- chainId: chainId.toString(),
25
- context,
26
- data,
27
- payment,
28
- to
29
- }
30
- });
31
-
32
- return hexData32Schema.parse(result);
33
- };
@@ -1,30 +0,0 @@
1
- import type { Transport } from 'viem';
2
- import { formatAuthorization } from '../../../utils/index.js';
3
- import { type TerminalStatus, terminalStatusSchema } from './getStatus.js';
4
- import type { SendTransactionParameters } from './sendTransaction.js';
5
-
6
- export type SendTransactionSyncParameters = SendTransactionParameters & {
7
- timeout?: number;
8
- };
9
-
10
- export const sendTransactionSync = async (
11
- client: ReturnType<Transport>,
12
- parameters: SendTransactionSyncParameters
13
- ): Promise<TerminalStatus> => {
14
- const { chainId, data, to, payment, context, authorizationList, timeout } = parameters;
15
-
16
- const result = await client.request({
17
- method: 'relayer_sendTransactionSync',
18
- params: {
19
- authorizationList: authorizationList ? authorizationList.map(formatAuthorization) : undefined,
20
- chainId: chainId.toString(),
21
- context,
22
- data,
23
- payment,
24
- timeout,
25
- to
26
- }
27
- });
28
-
29
- return terminalStatusSchema.parse(result);
30
- };
@@ -1,28 +0,0 @@
1
- import type { Transport } from 'viem';
2
- import {
3
- GelatoStatusCode,
4
- type GelatoTerminalStatus,
5
- type GetGelatoStatusParameters,
6
- getGelatoStatus
7
- } from './getGelatoStatus.js';
8
-
9
- // TODO: use websockets
10
- // TODO: make polling interval configurable
11
- export const waitForGelatoStatus = async (
12
- client: ReturnType<Transport>,
13
- parameters: GetGelatoStatusParameters
14
- ): Promise<GelatoTerminalStatus> => {
15
- while (true) {
16
- const status = await getGelatoStatus(client, parameters);
17
-
18
- if (
19
- status.status !== GelatoStatusCode.Pending &&
20
- status.status !== GelatoStatusCode.Submitted &&
21
- status.status !== GelatoStatusCode.Included
22
- ) {
23
- return status;
24
- }
25
-
26
- await new Promise((r) => setTimeout(r, 100));
27
- }
28
- };
@@ -1,24 +0,0 @@
1
- import type { Transport } from 'viem';
2
- import {
3
- type GetStatusParameters,
4
- getStatus,
5
- StatusCode,
6
- type TerminalStatus
7
- } from './getStatus.js';
8
-
9
- // TODO: use websockets
10
- // TODO: make polling interval configurable
11
- export const waitForStatus = async (
12
- client: ReturnType<Transport>,
13
- parameters: GetStatusParameters
14
- ): Promise<TerminalStatus> => {
15
- while (true) {
16
- const status = await getStatus(client, parameters);
17
-
18
- if (status.status !== StatusCode.Pending && status.status !== StatusCode.Submitted) {
19
- return status;
20
- }
21
-
22
- await new Promise((r) => setTimeout(r, 100));
23
- }
24
- };
@@ -1,77 +0,0 @@
1
- import { type Hex, type HttpTransportConfig, http } from 'viem';
2
- import { GELATO_PROD_API, GELATO_STAGING_API } from '../../constants/index.js';
3
- import {
4
- type Capabilities,
5
- type FeeData,
6
- type FeeQuote,
7
- type GelatoStatus,
8
- type GelatoTerminalStatus,
9
- type GetFeeDataParameters,
10
- type GetFeeQuoteParameters,
11
- type GetGelatoStatusParameters,
12
- type GetStatusParameters,
13
- getCapabilities,
14
- getFeeData,
15
- getFeeQuote,
16
- getGelatoStatus,
17
- getStatus,
18
- type SendTransactionParameters,
19
- type SendTransactionSyncParameters,
20
- type Status,
21
- sendTransaction,
22
- sendTransactionSync,
23
- type TerminalStatus,
24
- waitForGelatoStatus,
25
- waitForStatus
26
- } from './actions/index.js';
27
-
28
- export * from './actions/index.js';
29
-
30
- export type GelatoEvmRelayerClient = {
31
- getCapabilities: () => Promise<Capabilities>;
32
- getFeeData: (parameters: GetFeeDataParameters) => Promise<FeeData>;
33
- getFeeQuote: (parameters: GetFeeQuoteParameters) => Promise<FeeQuote>;
34
- getGelatoStatus: (parameters: GetGelatoStatusParameters) => Promise<GelatoStatus>;
35
- getStatus: (parameters: GetStatusParameters) => Promise<Status>;
36
- waitForGelatoStatus: (parameters: GetGelatoStatusParameters) => Promise<GelatoTerminalStatus>;
37
- waitForStatus: (parameters: GetStatusParameters) => Promise<TerminalStatus>;
38
- sendTransaction: (parameters: SendTransactionParameters) => Promise<Hex>;
39
- sendTransactionSync: (parameters: SendTransactionSyncParameters) => Promise<TerminalStatus>;
40
- };
41
-
42
- export type GelatoEvmRelayerClientConfig = {
43
- apiKey: string;
44
- testnet: boolean;
45
- };
46
-
47
- // TODO: the testnet/mainnet separation won't be necessary in the future
48
- export const createGelatoEvmRelayerClient = (
49
- parameters: GelatoEvmRelayerClientConfig
50
- ): GelatoEvmRelayerClient => {
51
- const { apiKey, testnet } = parameters;
52
-
53
- const config: HttpTransportConfig = {
54
- fetchOptions: {
55
- headers: {
56
- 'X-API-Key': apiKey
57
- }
58
- }
59
- };
60
-
61
- // TODO: can just use prod endpoint in the future
62
- const base = testnet ? GELATO_STAGING_API : GELATO_PROD_API;
63
-
64
- const client = http(`${base}/rpc`, config)({});
65
-
66
- return {
67
- getCapabilities: () => getCapabilities(client),
68
- getFeeData: (parameters) => getFeeData(client, parameters),
69
- getFeeQuote: (parameters) => getFeeQuote(client, parameters),
70
- getGelatoStatus: (parameters) => getGelatoStatus(client, parameters),
71
- getStatus: (parameters) => getStatus(client, parameters),
72
- sendTransaction: (parameters) => sendTransaction(client, parameters),
73
- sendTransactionSync: (parameters) => sendTransactionSync(client, parameters),
74
- waitForGelatoStatus: (parameters) => waitForGelatoStatus(client, parameters),
75
- waitForStatus: (parameters) => waitForStatus(client, parameters)
76
- };
77
- };
package/relayer/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './evm/index.js';