@gelatocloud/gasless 0.0.5 → 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.
Files changed (115) hide show
  1. package/README.md +182 -71
  2. package/_dist/account/actions/getFeeQuote.d.ts +4 -5
  3. package/_dist/account/actions/getFeeQuote.d.ts.map +1 -1
  4. package/_dist/account/actions/getFeeQuote.js +4 -9
  5. package/_dist/account/actions/getFeeQuote.js.map +1 -1
  6. package/_dist/account/actions/sendTransaction.d.ts +5 -6
  7. package/_dist/account/actions/sendTransaction.d.ts.map +1 -1
  8. package/_dist/account/actions/sendTransaction.js +3 -14
  9. package/_dist/account/actions/sendTransaction.js.map +1 -1
  10. package/_dist/account/actions/sendTransactionSync.d.ts +2 -2
  11. package/_dist/account/actions/sendTransactionSync.d.ts.map +1 -1
  12. package/_dist/account/actions/sendTransactionSync.js +3 -14
  13. package/_dist/account/actions/sendTransactionSync.js.map +1 -1
  14. package/_dist/account/adapters/gelato/index.d.ts.map +1 -1
  15. package/_dist/account/adapters/gelato/index.js +1 -1
  16. package/_dist/account/adapters/gelato/index.js.map +1 -1
  17. package/_dist/account/index.d.ts +1 -1
  18. package/_dist/account/index.d.ts.map +1 -1
  19. package/_dist/account/index.js +4 -4
  20. package/_dist/account/index.js.map +1 -1
  21. package/_dist/bundler/actions/estimateUserOperationGas.d.ts +1 -3
  22. package/_dist/bundler/actions/estimateUserOperationGas.d.ts.map +1 -1
  23. package/_dist/bundler/actions/estimateUserOperationGas.js +2 -2
  24. package/_dist/bundler/actions/estimateUserOperationGas.js.map +1 -1
  25. package/_dist/bundler/actions/getUserOperationGasPrice.d.ts +1 -2
  26. package/_dist/bundler/actions/getUserOperationGasPrice.d.ts.map +1 -1
  27. package/_dist/bundler/actions/getUserOperationGasPrice.js +2 -2
  28. package/_dist/bundler/actions/getUserOperationGasPrice.js.map +1 -1
  29. package/_dist/bundler/actions/getUserOperationQuote.d.ts +1 -3
  30. package/_dist/bundler/actions/getUserOperationQuote.d.ts.map +1 -1
  31. package/_dist/bundler/actions/getUserOperationQuote.js +2 -2
  32. package/_dist/bundler/actions/getUserOperationQuote.js.map +1 -1
  33. package/_dist/bundler/actions/prepareUserOperation.d.ts +1 -3
  34. package/_dist/bundler/actions/prepareUserOperation.d.ts.map +1 -1
  35. package/_dist/bundler/actions/prepareUserOperation.js +8 -47
  36. package/_dist/bundler/actions/prepareUserOperation.js.map +1 -1
  37. package/_dist/bundler/actions/sendUserOperation.d.ts +1 -3
  38. package/_dist/bundler/actions/sendUserOperation.d.ts.map +1 -1
  39. package/_dist/bundler/actions/sendUserOperation.js +2 -2
  40. package/_dist/bundler/actions/sendUserOperation.js.map +1 -1
  41. package/_dist/bundler/actions/sendUserOperationSync.d.ts +4 -4
  42. package/_dist/bundler/actions/sendUserOperationSync.d.ts.map +1 -1
  43. package/_dist/bundler/actions/sendUserOperationSync.js +14 -5
  44. package/_dist/bundler/actions/sendUserOperationSync.js.map +1 -1
  45. package/_dist/bundler/index.d.ts +4 -2
  46. package/_dist/bundler/index.d.ts.map +1 -1
  47. package/_dist/bundler/index.js +10 -15
  48. package/_dist/bundler/index.js.map +1 -1
  49. package/_dist/index.d.ts +1 -0
  50. package/_dist/index.d.ts.map +1 -1
  51. package/_dist/index.js +1 -0
  52. package/_dist/index.js.map +1 -1
  53. package/_dist/relayer/evm/actions/getGelatoStatus.d.ts +2 -2
  54. package/_dist/relayer/evm/actions/getGelatoStatus.d.ts.map +1 -1
  55. package/_dist/relayer/evm/actions/getGelatoStatus.js +12 -28
  56. package/_dist/relayer/evm/actions/getGelatoStatus.js.map +1 -1
  57. package/_dist/relayer/evm/actions/getStatus.d.ts +6 -17
  58. package/_dist/relayer/evm/actions/getStatus.d.ts.map +1 -1
  59. package/_dist/relayer/evm/actions/getStatus.js +12 -28
  60. package/_dist/relayer/evm/actions/getStatus.js.map +1 -1
  61. package/_dist/relayer/evm/actions/handleTerminalStatus.js +1 -1
  62. package/_dist/relayer/evm/actions/handleTerminalStatus.js.map +1 -1
  63. package/_dist/relayer/evm/actions/index.d.ts +1 -1
  64. package/_dist/relayer/evm/actions/index.d.ts.map +1 -1
  65. package/_dist/relayer/evm/actions/index.js +1 -1
  66. package/_dist/relayer/evm/actions/index.js.map +1 -1
  67. package/_dist/relayer/evm/actions/sendTransaction.d.ts +0 -2
  68. package/_dist/relayer/evm/actions/sendTransaction.d.ts.map +1 -1
  69. package/_dist/relayer/evm/actions/sendTransaction.js +1 -2
  70. package/_dist/relayer/evm/actions/sendTransaction.js.map +1 -1
  71. package/_dist/relayer/evm/actions/sendTransactionSync.d.ts +2 -0
  72. package/_dist/relayer/evm/actions/sendTransactionSync.d.ts.map +1 -1
  73. package/_dist/relayer/evm/actions/sendTransactionSync.js +25 -14
  74. package/_dist/relayer/evm/actions/sendTransactionSync.js.map +1 -1
  75. package/_dist/relayer/evm/actions/waitForGelatoStatus.d.ts +5 -1
  76. package/_dist/relayer/evm/actions/waitForGelatoStatus.d.ts.map +1 -1
  77. package/_dist/relayer/evm/actions/waitForGelatoStatus.js +16 -10
  78. package/_dist/relayer/evm/actions/waitForGelatoStatus.js.map +1 -1
  79. package/_dist/relayer/evm/actions/waitForReceipt.d.ts +5 -0
  80. package/_dist/relayer/evm/actions/waitForReceipt.d.ts.map +1 -0
  81. package/_dist/relayer/evm/actions/{waitForInclusion.js → waitForReceipt.js} +4 -4
  82. package/_dist/relayer/evm/actions/waitForReceipt.js.map +1 -0
  83. package/_dist/relayer/evm/actions/waitForStatus.d.ts +5 -1
  84. package/_dist/relayer/evm/actions/waitForStatus.d.ts.map +1 -1
  85. package/_dist/relayer/evm/actions/waitForStatus.js +13 -8
  86. package/_dist/relayer/evm/actions/waitForStatus.js.map +1 -1
  87. package/_dist/relayer/evm/index.d.ts +6 -5
  88. package/_dist/relayer/evm/index.d.ts.map +1 -1
  89. package/_dist/relayer/evm/index.js +16 -7
  90. package/_dist/relayer/evm/index.js.map +1 -1
  91. package/_dist/tsconfig.build.tsbuildinfo +1 -1
  92. package/_dist/types/payment.d.ts +2 -14
  93. package/_dist/types/payment.d.ts.map +1 -1
  94. package/_dist/types/payment.js +2 -12
  95. package/_dist/types/payment.js.map +1 -1
  96. package/_dist/types/schema.d.ts +32 -0
  97. package/_dist/types/schema.d.ts.map +1 -1
  98. package/_dist/types/schema.js +26 -1
  99. package/_dist/types/schema.js.map +1 -1
  100. package/_dist/utils/errors.d.ts +20 -0
  101. package/_dist/utils/errors.d.ts.map +1 -0
  102. package/_dist/utils/errors.js +40 -0
  103. package/_dist/utils/errors.js.map +1 -0
  104. package/_dist/utils/index.d.ts +2 -0
  105. package/_dist/utils/index.d.ts.map +1 -1
  106. package/_dist/utils/index.js +2 -0
  107. package/_dist/utils/index.js.map +1 -1
  108. package/_dist/utils/withTimeout.d.ts +76 -0
  109. package/_dist/utils/withTimeout.d.ts.map +1 -0
  110. package/_dist/utils/withTimeout.js +89 -0
  111. package/_dist/utils/withTimeout.js.map +1 -0
  112. package/package.json +1 -1
  113. package/_dist/relayer/evm/actions/waitForInclusion.d.ts +0 -4
  114. package/_dist/relayer/evm/actions/waitForInclusion.d.ts.map +0 -1
  115. package/_dist/relayer/evm/actions/waitForInclusion.js.map +0 -1
@@ -1,17 +1,5 @@
1
- import { type Address } from 'viem';
2
- export declare enum PaymentType {
3
- Token = "token",
4
- Sponsored = "sponsored"
5
- }
6
- export type TokenPayment = {
7
- type: PaymentType.Token;
8
- address: Address;
9
- };
10
1
  export type SponsoredPayment = {
11
- type: PaymentType.Sponsored;
2
+ type: 'sponsored';
12
3
  };
13
- export type Payment = TokenPayment | SponsoredPayment;
14
- export declare const sponsored: () => Payment;
15
- export declare const token: (address: Address) => Payment;
16
- export declare const native: () => Payment;
4
+ export declare const sponsored: () => SponsoredPayment;
17
5
  //# sourceMappingURL=payment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../types/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,MAAM,CAAC;AAEjD,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,SAAS,cAAc;CACxB;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEtD,eAAO,MAAM,SAAS,QAAO,OAA4C,CAAC;AAE1E,eAAO,MAAM,KAAK,GAAI,SAAS,OAAO,KAAG,OAAiD,CAAC;AAE3F,eAAO,MAAM,MAAM,QAAO,OAA8D,CAAC"}
1
+ {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../types/payment.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,gBAA2C,CAAC"}
@@ -1,16 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.native = exports.token = exports.sponsored = exports.PaymentType = void 0;
4
- const viem_1 = require("viem");
5
- var PaymentType;
6
- (function (PaymentType) {
7
- PaymentType["Token"] = "token";
8
- PaymentType["Sponsored"] = "sponsored";
9
- })(PaymentType || (exports.PaymentType = PaymentType = {}));
10
- const sponsored = () => ({ type: PaymentType.Sponsored });
3
+ exports.sponsored = void 0;
4
+ const sponsored = () => ({ type: 'sponsored' });
11
5
  exports.sponsored = sponsored;
12
- const token = (address) => ({ address, type: PaymentType.Token });
13
- exports.token = token;
14
- const native = () => ({ address: viem_1.zeroAddress, type: PaymentType.Token });
15
- exports.native = native;
16
6
  //# sourceMappingURL=payment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../types/payment.ts"],"names":[],"mappings":";;;AAAA,+BAAiD;AAEjD,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,sCAAuB,CAAA;AACzB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAaM,MAAM,SAAS,GAAG,GAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC;AAA7D,QAAA,SAAS,aAAoD;AAEnE,MAAM,KAAK,GAAG,CAAC,OAAgB,EAAW,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;AAA9E,QAAA,KAAK,SAAyE;AAEpF,MAAM,MAAM,GAAG,GAAY,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAW,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;AAA5E,QAAA,MAAM,UAAsE"}
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../types/payment.ts"],"names":[],"mappings":";;;AAIO,MAAM,SAAS,GAAG,GAAqB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AAA5D,QAAA,SAAS,aAAmD"}
@@ -7,4 +7,36 @@ export declare const evmTokenSchema: z.ZodObject<{
7
7
  decimals: z.ZodNumber;
8
8
  }, z.core.$strip>;
9
9
  export type EvmToken = z.infer<typeof evmTokenSchema>;
10
+ /**
11
+ * Schema for transaction log entries
12
+ */
13
+ export declare const logSchema: z.ZodObject<{
14
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
15
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
16
+ topics: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
17
+ }, z.core.$strip>;
18
+ /**
19
+ * Schema for transaction receipts
20
+ */
21
+ export declare const receiptSchema: z.ZodObject<{
22
+ blockHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
23
+ blockNumber: z.ZodCoercedBigInt<unknown>;
24
+ gasUsed: z.ZodCoercedBigInt<unknown>;
25
+ logs: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
27
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
28
+ topics: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
29
+ }, z.core.$strip>>>;
30
+ transactionHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
31
+ }, z.core.$strip>;
32
+ /**
33
+ * Base schema for all status responses
34
+ */
35
+ export declare const baseStatusSchema: z.ZodObject<{
36
+ chainId: z.ZodCoercedNumber<unknown>;
37
+ createdAt: z.ZodNumber;
38
+ }, z.core.$strip>;
39
+ export type Log = z.infer<typeof logSchema>;
40
+ export type TransactionReceipt = z.infer<typeof receiptSchema>;
41
+ export type BaseStatus = z.infer<typeof baseStatusSchema>;
10
42
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../types/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,aAAa,+DAGO,CAAC;AAElC,eAAO,MAAM,eAAe,+DAGK,CAAC;AAElC,eAAO,MAAM,gBAAgB,+DAGS,CAAC;AAEvC,eAAO,MAAM,cAAc;;;iBAGzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../types/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,aAAa,+DAGO,CAAC;AAElC,eAAO,MAAM,eAAe,+DAGK,CAAC;AAElC,eAAO,MAAM,gBAAgB,+DAGS,CAAC;AAEvC,eAAO,MAAM,cAAc;;;iBAGzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,SAAS;;;;iBAIpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;iBAMxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AAGH,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAC5C,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.evmTokenSchema = exports.evmAddressSchema = exports.hexData32Schema = exports.hexDataSchema = void 0;
3
+ exports.baseStatusSchema = exports.receiptSchema = exports.logSchema = exports.evmTokenSchema = exports.evmAddressSchema = exports.hexData32Schema = exports.hexDataSchema = void 0;
4
4
  const viem_1 = require("viem");
5
5
  const zod_1 = require("zod");
6
6
  const hexData32Pattern = /^0x([0-9a-fA-F][0-9a-fA-F]){32}$/;
@@ -22,4 +22,29 @@ exports.evmTokenSchema = zod_1.z.object({
22
22
  address: exports.evmAddressSchema,
23
23
  decimals: zod_1.z.number()
24
24
  });
25
+ /**
26
+ * Schema for transaction log entries
27
+ */
28
+ exports.logSchema = zod_1.z.object({
29
+ address: exports.evmAddressSchema,
30
+ data: exports.hexDataSchema,
31
+ topics: zod_1.z.array(exports.hexData32Schema)
32
+ });
33
+ /**
34
+ * Schema for transaction receipts
35
+ */
36
+ exports.receiptSchema = zod_1.z.object({
37
+ blockHash: exports.hexData32Schema,
38
+ blockNumber: zod_1.z.coerce.bigint(),
39
+ gasUsed: zod_1.z.coerce.bigint(),
40
+ logs: zod_1.z.array(exports.logSchema).optional(),
41
+ transactionHash: exports.hexData32Schema
42
+ });
43
+ /**
44
+ * Base schema for all status responses
45
+ */
46
+ exports.baseStatusSchema = zod_1.z.object({
47
+ chainId: zod_1.z.coerce.number(),
48
+ createdAt: zod_1.z.number()
49
+ });
25
50
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../types/schema.ts"],"names":[],"mappings":";;;AAAA,+BAA4C;AAC5C,6BAAwB;AAExB,MAAM,gBAAgB,GAAG,kCAAkC,CAAC;AAC5D,MAAM,cAAc,GAAG,+BAA+B,CAAC;AACvD,MAAM,iBAAiB,GAAG,kCAAkC,CAAC;AAEhD,QAAA,aAAa,GAAG,OAAC;KAC3B,MAAM,EAAE;KACR,KAAK,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;KACxD,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAU,CAAC,CAAC;AAErB,QAAA,eAAe,GAAG,OAAC;KAC7B,MAAM,EAAE;KACR,KAAK,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC;KAClE,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAU,CAAC,CAAC;AAErB,QAAA,gBAAgB,GAAG,OAAC;KAC9B,MAAM,EAAE;KACR,KAAK,CAAC,iBAAiB,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC;KAChE,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,iBAAU,EAAC,GAAG,CAAC,CAAC,CAAC;AAE1B,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,OAAO,E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AAG,OAAC,CAAC,MAAM,CAAC;IACpC,SAAS,EAAE,uBAAe;IAC1B,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,MAAM,EAAE;IAC9B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,MAAM,EAAE;IAC1B,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,iBAAS,CAAC,CAAC,QAAQ,EAAE;IACnC,eAAe,EAAE,uBAAe;CACjC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Hex } from 'viem';
2
+ /**
3
+ * Extracts the transaction/operation ID from an error
4
+ *
5
+ * Expected error structure:
6
+ * ```json
7
+ * {
8
+ * "error": {
9
+ * "code": -X,
10
+ * "data": "0x... (transaction/operation hash)",
11
+ * "message": "..."
12
+ * }
13
+ * }
14
+ * ```
15
+ *
16
+ * @param error - The error to check
17
+ * @returns The ID of the transaction/operation or undefined if not found
18
+ */
19
+ export declare function retrieveIdFromError(error: unknown): Hex | undefined;
20
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGhC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS,CAoBnE"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.retrieveIdFromError = retrieveIdFromError;
4
+ const schema_js_1 = require("../types/schema.js");
5
+ /**
6
+ * Extracts the transaction/operation ID from an error
7
+ *
8
+ * Expected error structure:
9
+ * ```json
10
+ * {
11
+ * "error": {
12
+ * "code": -X,
13
+ * "data": "0x... (transaction/operation hash)",
14
+ * "message": "..."
15
+ * }
16
+ * }
17
+ * ```
18
+ *
19
+ * @param error - The error to check
20
+ * @returns The ID of the transaction/operation or undefined if not found
21
+ */
22
+ function retrieveIdFromError(error) {
23
+ // Type guard: check if error is an object
24
+ if (typeof error !== 'object' || error === null) {
25
+ return undefined;
26
+ }
27
+ const err = error;
28
+ const data = err['data'];
29
+ // Validate that id/userOperationHash exists and is a string (transaction/operation hash)
30
+ if (typeof data !== 'string' || data.length === 0) {
31
+ return undefined;
32
+ }
33
+ try {
34
+ return schema_js_1.hexData32Schema.parse(data);
35
+ }
36
+ catch {
37
+ return undefined;
38
+ }
39
+ }
40
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../utils/errors.ts"],"names":[],"mappings":";;AAoBA,kDAoBC;AAvCD,kDAAqD;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,mBAAmB,CAAC,KAAc;IAChD,0CAA0C;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,KAAgC,CAAC;IAE7C,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAW,CAAC;IAEnC,yFAAyF;IACzF,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,2BAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -1,3 +1,5 @@
1
+ export * from './errors.js';
1
2
  export * from './payment.js';
2
3
  export * from './serialize.js';
4
+ export * from './withTimeout.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./errors.js"), exports);
17
18
  __exportStar(require("./payment.js"), exports);
18
19
  __exportStar(require("./serialize.js"), exports);
20
+ __exportStar(require("./withTimeout.js"), exports);
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,+CAA6B;AAC7B,iDAA+B;AAC/B,mDAAiC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Error thrown when a polling operation times out
3
+ */
4
+ export declare class TimeoutError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ export declare const MIN_POLLING_INTERVAL = 100;
8
+ export declare const MAX_POLLING_INTERVAL = 300000;
9
+ export declare const MIN_TIMEOUT = 1000;
10
+ export declare const MAX_TIMEOUT = 600000;
11
+ /**
12
+ * Options for configuring the withTimeout polling behavior
13
+ */
14
+ export interface WithTimeoutOptions<T> {
15
+ /**
16
+ * Function to check if polling should continue
17
+ * Return true to continue polling, false to return the result
18
+ *
19
+ * @example
20
+ * // Continue polling while status is pending
21
+ * shouldContinue: (status) => status.status === StatusCode.Pending
22
+ *
23
+ * @example
24
+ * // Continue polling while result is null
25
+ * shouldContinue: (result) => result === null
26
+ */
27
+ shouldContinue: (result: T) => boolean;
28
+ /**
29
+ * Polling interval in milliseconds
30
+ * Must be between 100ms and 300000ms (5 minutes)
31
+ */
32
+ pollingInterval: number;
33
+ /**
34
+ * Maximum time to wait before timing out in milliseconds
35
+ * Must not exceed 600000ms (10 minutes)
36
+ */
37
+ timeout: number;
38
+ /**
39
+ * Error message for timeout
40
+ * @default "Timeout waiting for result"
41
+ */
42
+ timeoutErrorMessage?: string;
43
+ }
44
+ /**
45
+ * Wraps a polling operation with configurable timeout logic
46
+ *
47
+ * This utility provides a consistent pattern for polling operations across the codebase.
48
+ * It repeatedly calls the provided function until either:
49
+ * - The shouldContinue callback returns false (success)
50
+ * - The timeout is exceeded (throws TimeoutError)
51
+ *
52
+ * If the poll function throws an error, it will propagate immediately and stop polling.
53
+ * This means the poll function should handle "not ready yet" cases by returning a value
54
+ * that shouldContinue can check, rather than throwing an error.
55
+ *
56
+ * @template T - The type of result returned by the polling function
57
+ * @param pollFn - Async function to call repeatedly
58
+ * @param options - Configuration options for polling behavior
59
+ * @returns The result from pollFn when shouldContinue returns false
60
+ * @throws {TimeoutError} When timeout is exceeded
61
+ * @throws Any error thrown by pollFn is propagated immediately
62
+ *
63
+ * @example
64
+ * // Poll for a status to complete
65
+ * const status = await withTimeout(
66
+ * () => getStatus(client, params),
67
+ * {
68
+ * shouldContinue: (s) => s.status === StatusCode.Pending,
69
+ * pollingInterval: 100,
70
+ * timeout: 10000,
71
+ * timeoutErrorMessage: 'Timeout waiting for status'
72
+ * }
73
+ * );
74
+ */
75
+ export declare function withTimeout<T>(pollFn: () => Promise<T>, options: WithTimeoutOptions<T>): Promise<T>;
76
+ //# sourceMappingURL=withTimeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withTimeout.d.ts","sourceRoot":"","sources":["../../utils/withTimeout.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAGD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,oBAAoB,SAAS,CAAC;AAC3C,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;IAEvC;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACxB,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CAiDZ"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.MAX_POLLING_INTERVAL = exports.MIN_POLLING_INTERVAL = exports.TimeoutError = void 0;
4
+ exports.withTimeout = withTimeout;
5
+ /**
6
+ * Error thrown when a polling operation times out
7
+ */
8
+ class TimeoutError extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = 'TimeoutError';
12
+ }
13
+ }
14
+ exports.TimeoutError = TimeoutError;
15
+ // Validation constants for polling parameters
16
+ exports.MIN_POLLING_INTERVAL = 100; // 100ms minimum
17
+ exports.MAX_POLLING_INTERVAL = 300000; // 5 minutes maximum
18
+ exports.MIN_TIMEOUT = 1000; // 1 second minimum
19
+ exports.MAX_TIMEOUT = 600000; // 10 minutes maximum
20
+ /**
21
+ * Wraps a polling operation with configurable timeout logic
22
+ *
23
+ * This utility provides a consistent pattern for polling operations across the codebase.
24
+ * It repeatedly calls the provided function until either:
25
+ * - The shouldContinue callback returns false (success)
26
+ * - The timeout is exceeded (throws TimeoutError)
27
+ *
28
+ * If the poll function throws an error, it will propagate immediately and stop polling.
29
+ * This means the poll function should handle "not ready yet" cases by returning a value
30
+ * that shouldContinue can check, rather than throwing an error.
31
+ *
32
+ * @template T - The type of result returned by the polling function
33
+ * @param pollFn - Async function to call repeatedly
34
+ * @param options - Configuration options for polling behavior
35
+ * @returns The result from pollFn when shouldContinue returns false
36
+ * @throws {TimeoutError} When timeout is exceeded
37
+ * @throws Any error thrown by pollFn is propagated immediately
38
+ *
39
+ * @example
40
+ * // Poll for a status to complete
41
+ * const status = await withTimeout(
42
+ * () => getStatus(client, params),
43
+ * {
44
+ * shouldContinue: (s) => s.status === StatusCode.Pending,
45
+ * pollingInterval: 100,
46
+ * timeout: 10000,
47
+ * timeoutErrorMessage: 'Timeout waiting for status'
48
+ * }
49
+ * );
50
+ */
51
+ async function withTimeout(pollFn, options) {
52
+ const { shouldContinue, pollingInterval, timeout, timeoutErrorMessage = 'Timeout waiting for result' } = options;
53
+ // Input validation to prevent DoS attacks and type confusion
54
+ if (!Number.isFinite(pollingInterval) || !Number.isInteger(pollingInterval)) {
55
+ throw new Error('pollingInterval must be a finite integer');
56
+ }
57
+ if (pollingInterval < exports.MIN_POLLING_INTERVAL) {
58
+ throw new Error(`pollingInterval must be at least ${exports.MIN_POLLING_INTERVAL}ms`);
59
+ }
60
+ if (pollingInterval > exports.MAX_POLLING_INTERVAL) {
61
+ throw new Error(`pollingInterval cannot exceed ${exports.MAX_POLLING_INTERVAL}ms`);
62
+ }
63
+ if (!Number.isFinite(timeout) || !Number.isInteger(timeout)) {
64
+ throw new Error('timeout must be a finite integer');
65
+ }
66
+ if (timeout < exports.MIN_TIMEOUT) {
67
+ throw new Error(`timeout must be at least ${exports.MIN_TIMEOUT}ms`);
68
+ }
69
+ if (timeout > exports.MAX_TIMEOUT) {
70
+ throw new Error(`timeout cannot exceed ${exports.MAX_TIMEOUT}ms`);
71
+ }
72
+ const startTime = Date.now();
73
+ while (true) {
74
+ // Poll first to ensure at least one attempt
75
+ const result = await pollFn();
76
+ // Check if we should continue polling or return
77
+ if (!shouldContinue(result)) {
78
+ return result;
79
+ }
80
+ // Check timeout AFTER getting result (more accurate)
81
+ const elapsed = Date.now() - startTime;
82
+ if (elapsed > timeout) {
83
+ throw new TimeoutError(`${timeoutErrorMessage} (exceeded timeout of ${timeout}ms)`);
84
+ }
85
+ // Wait before next poll
86
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
87
+ }
88
+ }
89
+ //# sourceMappingURL=withTimeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withTimeout.js","sourceRoot":"","sources":["../../utils/withTimeout.ts"],"names":[],"mappings":";;;AAoFA,kCAoDC;AAxID;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,8CAA8C;AACjC,QAAA,oBAAoB,GAAG,GAAG,CAAC,CAAC,gBAAgB;AAC5C,QAAA,oBAAoB,GAAG,MAAM,CAAC,CAAC,oBAAoB;AACnD,QAAA,WAAW,GAAG,IAAI,CAAC,CAAC,mBAAmB;AACvC,QAAA,WAAW,GAAG,MAAM,CAAC,CAAC,qBAAqB;AAuCxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACI,KAAK,UAAU,WAAW,C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B,CAAC;QAED,qDAAqD;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QACvC,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,YAAY,CAAC,GAAG,mBAAmB,yBAAyB,OAAO,KAAK,CAAC,CAAC;QACtF,CAAC;QAED,wBAAwB;QACxB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gelatocloud/gasless",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "author": "Gelato",
5
5
  "license": "MIT",
6
6
  "description": "Gelato Gasless SDK: All-in-one solution for gasless transactions",
@@ -1,4 +0,0 @@
1
- import type { Transport } from 'viem';
2
- import type { GetStatusParameters, TransactionReceipt } from './getStatus.js';
3
- export declare const waitForInclusion: (client: ReturnType<Transport>, parameters: GetStatusParameters) => Promise<TransactionReceipt>;
4
- //# sourceMappingURL=waitForInclusion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"waitForInclusion.d.ts","sourceRoot":"","sources":["../../../../relayer/evm/actions/waitForInclusion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAI9E,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,UAAU,CAAC,SAAS,CAAC,EAC7B,YAAY,mBAAmB,KAC9B,OAAO,CAAC,kBAAkB,CAI5B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"waitForInclusion.js","sourceRoot":"","sources":["../../../../relayer/evm/actions/waitForInclusion.ts"],"names":[],"mappings":";;;AAGA,uEAAiE;AACjE,yDAAmD;AAE5C,MAAM,gBAAgB,GAAG,KAAK,EACnC,MAA6B,EAC7B,UAA+B,EACF,EAAE;IAC/B,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAa,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAEvD,OAAO,IAAA,8CAAoB,EAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC,CAAC;AAPW,QAAA,gBAAgB,oBAO3B"}