@gelatocloud/gasless 0.0.0 → 0.0.1

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 (33) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/_dist/bundler/index.js +1 -1
  3. package/_dist/bundler/index.js.map +1 -1
  4. package/_dist/constants/index.d.ts.map +1 -0
  5. package/_dist/constants/index.js.map +1 -0
  6. package/_dist/relayer/evm/actions/getGelatoStatus.d.ts +97 -0
  7. package/_dist/relayer/evm/actions/getGelatoStatus.d.ts.map +1 -0
  8. package/_dist/relayer/evm/actions/getGelatoStatus.js +78 -0
  9. package/_dist/relayer/evm/actions/getGelatoStatus.js.map +1 -0
  10. package/_dist/relayer/evm/actions/index.d.ts +2 -0
  11. package/_dist/relayer/evm/actions/index.d.ts.map +1 -1
  12. package/_dist/relayer/evm/actions/index.js +2 -0
  13. package/_dist/relayer/evm/actions/index.js.map +1 -1
  14. package/_dist/relayer/evm/actions/waitForGelatoStatus.d.ts +4 -0
  15. package/_dist/relayer/evm/actions/waitForGelatoStatus.d.ts.map +1 -0
  16. package/_dist/relayer/evm/actions/waitForGelatoStatus.js +19 -0
  17. package/_dist/relayer/evm/actions/waitForGelatoStatus.js.map +1 -0
  18. package/_dist/relayer/evm/index.d.ts +3 -1
  19. package/_dist/relayer/evm/index.d.ts.map +1 -1
  20. package/_dist/relayer/evm/index.js +3 -1
  21. package/_dist/relayer/evm/index.js.map +1 -1
  22. package/_dist/tsconfig.build.tsbuildinfo +1 -1
  23. package/bundler/index.ts +1 -1
  24. package/package.json +12 -9
  25. package/relayer/evm/actions/getGelatoStatus.ts +99 -0
  26. package/relayer/evm/actions/index.ts +2 -0
  27. package/relayer/evm/actions/waitForGelatoStatus.ts +28 -0
  28. package/relayer/evm/index.ts +10 -1
  29. package/_dist/relayer/constants/index.d.ts.map +0 -1
  30. package/_dist/relayer/constants/index.js.map +0 -1
  31. /package/_dist/{relayer/constants → constants}/index.d.ts +0 -0
  32. /package/_dist/{relayer/constants → constants}/index.js +0 -0
  33. /package/{relayer/constants → constants}/index.ts +0 -0
package/bundler/index.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  createBundlerClient,
7
7
  type UserOperationReceipt
8
8
  } from 'viem/account-abstraction';
9
- import { GELATO_PROD_API, GELATO_STAGING_API } from '../relayer/constants/index.js';
9
+ import { GELATO_PROD_API, GELATO_STAGING_API } from '../constants/index.js';
10
10
  import { getCapabilities } from '../relayer/evm/actions/index.js';
11
11
  import { type Payment, PaymentType } from '../types/index.js';
12
12
  import {
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "@gelatocloud/gasless",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "author": "Gelato",
5
5
  "description": "Gelato Gasless SDK: All-in-one solution for gasless transactions",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/gelatodigital/gasless.git",
9
+ "directory": "src"
10
+ },
11
+ "homepage": "https://docs.gelato.cloud",
12
+ "bugs": {
13
+ "url": "https://github.com/gelatodigital/gasless/issues"
14
+ },
6
15
  "main": "./_dist/index.js",
7
16
  "types": "./_dist/index.d.ts",
8
17
  "typings": "./_dist/index.d.ts",
@@ -17,17 +26,11 @@
17
26
  "zod": "4.1.13"
18
27
  },
19
28
  "peerDependencies": {
20
- "typescript": "5.9.3",
21
- "viem": "2.39.3"
22
- },
23
- "peerDependenciesMeta": {
24
- "typescript": {
25
- "optional": true
26
- }
29
+ "viem": "^2.0.0"
27
30
  },
28
31
  "devDependencies": {
29
32
  "typescript": "5.9.3",
30
- "viem": "2.39.3",
33
+ "viem": "^2.0.0",
31
34
  "zod": "4.1.13"
32
35
  },
33
36
  "scripts": {
@@ -0,0 +1,99 @@
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,7 +1,9 @@
1
1
  export * from './getCapabilities.js';
2
2
  export * from './getFeeData.js';
3
3
  export * from './getFeeQuote.js';
4
+ export * from './getGelatoStatus.js';
4
5
  export * from './getStatus.js';
5
6
  export * from './sendTransaction.js';
6
7
  export * from './sendTransactionSync.js';
8
+ export * from './waitForGelatoStatus.js';
7
9
  export * from './waitForStatus.js';
@@ -0,0 +1,28 @@
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,15 +1,19 @@
1
1
  import { type Hex, type HttpTransportConfig, http } from 'viem';
2
- import { GELATO_PROD_API, GELATO_STAGING_API } from '../constants/index.js';
2
+ import { GELATO_PROD_API, GELATO_STAGING_API } from '../../constants/index.js';
3
3
  import {
4
4
  type Capabilities,
5
5
  type FeeData,
6
6
  type FeeQuote,
7
+ type GelatoStatus,
8
+ type GelatoTerminalStatus,
7
9
  type GetFeeDataParameters,
8
10
  type GetFeeQuoteParameters,
11
+ type GetGelatoStatusParameters,
9
12
  type GetStatusParameters,
10
13
  getCapabilities,
11
14
  getFeeData,
12
15
  getFeeQuote,
16
+ getGelatoStatus,
13
17
  getStatus,
14
18
  type SendTransactionParameters,
15
19
  type SendTransactionSyncParameters,
@@ -17,6 +21,7 @@ import {
17
21
  sendTransaction,
18
22
  sendTransactionSync,
19
23
  type TerminalStatus,
24
+ waitForGelatoStatus,
20
25
  waitForStatus
21
26
  } from './actions/index.js';
22
27
 
@@ -26,7 +31,9 @@ export type GelatoEvmRelayerClient = {
26
31
  getCapabilities: () => Promise<Capabilities>;
27
32
  getFeeData: (parameters: GetFeeDataParameters) => Promise<FeeData>;
28
33
  getFeeQuote: (parameters: GetFeeQuoteParameters) => Promise<FeeQuote>;
34
+ getGelatoStatus: (parameters: GetGelatoStatusParameters) => Promise<GelatoStatus>;
29
35
  getStatus: (parameters: GetStatusParameters) => Promise<Status>;
36
+ waitForGelatoStatus: (parameters: GetGelatoStatusParameters) => Promise<GelatoTerminalStatus>;
30
37
  waitForStatus: (parameters: GetStatusParameters) => Promise<TerminalStatus>;
31
38
  sendTransaction: (parameters: SendTransactionParameters) => Promise<Hex>;
32
39
  sendTransactionSync: (parameters: SendTransactionSyncParameters) => Promise<TerminalStatus>;
@@ -60,9 +67,11 @@ export const createGelatoEvmRelayerClient = (
60
67
  getCapabilities: () => getCapabilities(client),
61
68
  getFeeData: (parameters) => getFeeData(client, parameters),
62
69
  getFeeQuote: (parameters) => getFeeQuote(client, parameters),
70
+ getGelatoStatus: (parameters) => getGelatoStatus(client, parameters),
63
71
  getStatus: (parameters) => getStatus(client, parameters),
64
72
  sendTransaction: (parameters) => sendTransaction(client, parameters),
65
73
  sendTransactionSync: (parameters) => sendTransactionSync(client, parameters),
74
+ waitForGelatoStatus: (parameters) => waitForGelatoStatus(client, parameters),
66
75
  waitForStatus: (parameters) => waitForStatus(client, parameters)
67
76
  };
68
77
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../relayer/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,kBAAkB,+BAA+B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../relayer/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAC7C,QAAA,kBAAkB,GAAG,4BAA4B,CAAC"}
File without changes
File without changes