@eco-foundation/api-schemas 0.1.0

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 (102) hide show
  1. package/README.md +160 -0
  2. package/dist/build-digest.d.ts +2 -0
  3. package/dist/build-digest.js +10 -0
  4. package/dist/build-digest.js.map +1 -0
  5. package/dist/fixtures/index.d.ts +14 -0
  6. package/dist/fixtures/index.js +71 -0
  7. package/dist/fixtures/index.js.map +1 -0
  8. package/dist/fixtures/v1/chains-list.response.default.json +37 -0
  9. package/dist/fixtures/v1/deposit-addresses-create.request.gateway-erc20.json +16 -0
  10. package/dist/fixtures/v1/deposit-addresses-create.response.gateway-erc20.json +20 -0
  11. package/dist/fixtures/v1/deposit-addresses-lookup.response.default.json +24 -0
  12. package/dist/fixtures/v1/deposit-addresses-submit-erc-2612.request.deposit-address-target.json +23 -0
  13. package/dist/fixtures/v1/deposit-addresses-submit-erc-3009.request.deposit-address-target.json +24 -0
  14. package/dist/fixtures/v1/intents-status.response.gasless-handoff.json +30 -0
  15. package/dist/fixtures/v1/intents-status.response.intent-filled.json +21 -0
  16. package/dist/fixtures/v1/intents-status.response.unknown.json +20 -0
  17. package/dist/fixtures/v1/intents-status.response.wallet-page.json +27 -0
  18. package/dist/fixtures/v1/intents-submit-erc-3009.response.job.json +25 -0
  19. package/dist/fixtures/v1/intents-submit-permit2.request.quote-target.json +25 -0
  20. package/dist/fixtures/v1/intents-submit-permit3.request.quote-target.json +27 -0
  21. package/dist/fixtures/v1/quotes-create.request.public-swap.json +25 -0
  22. package/dist/fixtures/v1/quotes-create.response.all-quotes.json +455 -0
  23. package/dist/fixtures/v1/quotes-create.response.private-swap.json +152 -0
  24. package/dist/fixtures/v1/quotes-create.response.public-swap.json +158 -0
  25. package/dist/fixtures/v1/routes-list.response.default.json +26 -0
  26. package/dist/fixtures/v1/tokens-list.response.default.json +24 -0
  27. package/dist/generated/build-digest.json +7 -0
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.js +47 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/openapi.d.ts +2 -0
  32. package/dist/openapi.js +81 -0
  33. package/dist/openapi.js.map +1 -0
  34. package/dist/scripts/generate-build-digest.d.ts +1 -0
  35. package/dist/scripts/generate-build-digest.js +25 -0
  36. package/dist/scripts/generate-build-digest.js.map +1 -0
  37. package/dist/scripts/generate-openapi.d.ts +1 -0
  38. package/dist/scripts/generate-openapi.js +21 -0
  39. package/dist/scripts/generate-openapi.js.map +1 -0
  40. package/dist/testing/index.d.ts +7 -0
  41. package/dist/testing/index.js +27 -0
  42. package/dist/testing/index.js.map +1 -0
  43. package/dist/v1/endpoints/chains.d.ts +52 -0
  44. package/dist/v1/endpoints/chains.js +23 -0
  45. package/dist/v1/endpoints/chains.js.map +1 -0
  46. package/dist/v1/endpoints/deposit-addresses.d.ts +100 -0
  47. package/dist/v1/endpoints/deposit-addresses.js +61 -0
  48. package/dist/v1/endpoints/deposit-addresses.js.map +1 -0
  49. package/dist/v1/endpoints/quotes.d.ts +861 -0
  50. package/dist/v1/endpoints/quotes.js +297 -0
  51. package/dist/v1/endpoints/quotes.js.map +1 -0
  52. package/dist/v1/endpoints/registry.d.ts +641 -0
  53. package/dist/v1/endpoints/registry.js +108 -0
  54. package/dist/v1/endpoints/registry.js.map +1 -0
  55. package/dist/v1/endpoints/routes.d.ts +35 -0
  56. package/dist/v1/endpoints/routes.js +21 -0
  57. package/dist/v1/endpoints/routes.js.map +1 -0
  58. package/dist/v1/endpoints/status.d.ts +149 -0
  59. package/dist/v1/endpoints/status.js +110 -0
  60. package/dist/v1/endpoints/status.js.map +1 -0
  61. package/dist/v1/endpoints/submit.d.ts +271 -0
  62. package/dist/v1/endpoints/submit.js +127 -0
  63. package/dist/v1/endpoints/submit.js.map +1 -0
  64. package/dist/v1/endpoints/tokens.d.ts +59 -0
  65. package/dist/v1/endpoints/tokens.js +22 -0
  66. package/dist/v1/endpoints/tokens.js.map +1 -0
  67. package/dist/v1/enums.d.ts +133 -0
  68. package/dist/v1/enums.js +62 -0
  69. package/dist/v1/enums.js.map +1 -0
  70. package/dist/v1/errors/catalog.d.ts +247 -0
  71. package/dist/v1/errors/catalog.js +124 -0
  72. package/dist/v1/errors/catalog.js.map +1 -0
  73. package/dist/v1/errors/lock.d.ts +10 -0
  74. package/dist/v1/errors/lock.js +45 -0
  75. package/dist/v1/errors/lock.js.map +1 -0
  76. package/dist/v1/errors/problem.d.ts +50 -0
  77. package/dist/v1/errors/problem.js +82 -0
  78. package/dist/v1/errors/problem.js.map +1 -0
  79. package/dist/v1/index.d.ts +14 -0
  80. package/dist/v1/index.js +32 -0
  81. package/dist/v1/index.js.map +1 -0
  82. package/dist/v1/primitives.d.ts +33 -0
  83. package/dist/v1/primitives.js +63 -0
  84. package/dist/v1/primitives.js.map +1 -0
  85. package/dist/v1/signature.d.ts +10 -0
  86. package/dist/v1/signature.js +72 -0
  87. package/dist/v1/signature.js.map +1 -0
  88. package/dist/v1/tolerant.d.ts +4 -0
  89. package/dist/v1/tolerant.js +11 -0
  90. package/dist/v1/tolerant.js.map +1 -0
  91. package/dist/v1/types.d.ts +277 -0
  92. package/dist/v1/types.js +3 -0
  93. package/dist/v1/types.js.map +1 -0
  94. package/errors/catalog.lock.json +232 -0
  95. package/fixtures/quote-signature/vector-1.json +9 -0
  96. package/fixtures/quote-signature/vector-2.json +13 -0
  97. package/fixtures/quote-signature/vector-3.json +9 -0
  98. package/fixtures/signature-hash/vectors.json +58 -0
  99. package/openapi/v1.json +5225 -0
  100. package/package.json +71 -0
  101. package/v1/types.d.ts +7 -0
  102. package/v1/types.js +5 -0
@@ -0,0 +1,14 @@
1
+ export * from './endpoints/chains';
2
+ export * from './endpoints/deposit-addresses';
3
+ export * from './endpoints/quotes';
4
+ export * from './endpoints/registry';
5
+ export * from './endpoints/routes';
6
+ export * from './endpoints/status';
7
+ export * from './endpoints/submit';
8
+ export * from './endpoints/tokens';
9
+ export * from './enums';
10
+ export * from './errors/catalog';
11
+ export * from './errors/problem';
12
+ export * from './primitives';
13
+ export * from './signature';
14
+ export declare const V1_API_VERSION: "v1";
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.V1_API_VERSION = void 0;
18
+ __exportStar(require("./endpoints/chains"), exports);
19
+ __exportStar(require("./endpoints/deposit-addresses"), exports);
20
+ __exportStar(require("./endpoints/quotes"), exports);
21
+ __exportStar(require("./endpoints/registry"), exports);
22
+ __exportStar(require("./endpoints/routes"), exports);
23
+ __exportStar(require("./endpoints/status"), exports);
24
+ __exportStar(require("./endpoints/submit"), exports);
25
+ __exportStar(require("./endpoints/tokens"), exports);
26
+ __exportStar(require("./enums"), exports);
27
+ __exportStar(require("./errors/catalog"), exports);
28
+ __exportStar(require("./errors/problem"), exports);
29
+ __exportStar(require("./primitives"), exports);
30
+ __exportStar(require("./signature"), exports);
31
+ exports.V1_API_VERSION = 'v1';
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,gEAA8C;AAC9C,qDAAmC;AACnC,uDAAqC;AACrC,qDAAmC;AACnC,qDAAmC;AACnC,qDAAmC;AACnC,qDAAmC;AACnC,0CAAwB;AACxB,mDAAiC;AACjC,mDAAiC;AACjC,+CAA6B;AAC7B,8CAA4B;AAEf,QAAA,cAAc,GAAG,IAAa,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ export declare const UintString: z.ZodString;
3
+ export type UintString = z.infer<typeof UintString>;
4
+ export declare const HexBytes: z.ZodString;
5
+ export type HexBytes = z.infer<typeof HexBytes>;
6
+ export declare const Bytes32: z.ZodString;
7
+ export type Bytes32 = z.infer<typeof Bytes32>;
8
+ export declare const EvmAddress: z.ZodString;
9
+ export declare const SvmAddress: z.ZodString;
10
+ export declare const TvmAddress: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
11
+ export declare const AnyAddress: z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodString]>]>;
12
+ export type AnyAddress = z.infer<typeof AnyAddress>;
13
+ export declare const ADDRESS_BY_CHAIN_TYPE: Record<'evm' | 'svm' | 'tvm', z.ZodType<string>>;
14
+ export declare function isSameEvmAddress(a: string, b: string): boolean;
15
+ export declare const ChainId: z.ZodNumber;
16
+ export type ChainId = z.infer<typeof ChainId>;
17
+ export declare const MAX_UNIX_SECONDS = 4102444800;
18
+ export declare const UnixSeconds: z.ZodNumber;
19
+ export type UnixSeconds = z.infer<typeof UnixSeconds>;
20
+ export declare const DappId: z.ZodString;
21
+ export declare const QuoteId: z.ZodString;
22
+ export declare const IntentId: z.ZodString;
23
+ export declare const GaslessId: z.ZodString;
24
+ export declare const GaslessJobRef: z.ZodString;
25
+ export declare const DepositAddressId: z.ZodString;
26
+ export declare const V1Id: z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodString, z.ZodString]>;
27
+ export type V1Id = z.infer<typeof V1Id>;
28
+ export interface ParsedV1Id {
29
+ type: 'quote' | 'intent' | 'gasless' | 'deposit-address';
30
+ value: string;
31
+ }
32
+ export declare function parseV1Id(id: string): ParsedV1Id;
33
+ export { tolerantEnum } from './tolerant';
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tolerantEnum = exports.V1Id = exports.DepositAddressId = exports.GaslessJobRef = exports.GaslessId = exports.IntentId = exports.QuoteId = exports.DappId = exports.UnixSeconds = exports.MAX_UNIX_SECONDS = exports.ChainId = exports.ADDRESS_BY_CHAIN_TYPE = exports.AnyAddress = exports.TvmAddress = exports.SvmAddress = exports.EvmAddress = exports.Bytes32 = exports.HexBytes = exports.UintString = void 0;
4
+ exports.isSameEvmAddress = isSameEvmAddress;
5
+ exports.parseV1Id = parseV1Id;
6
+ const zod_1 = require("zod");
7
+ exports.UintString = zod_1.z.string().regex(/^(0|[1-9]\d*)$/, 'base-10 unsigned integer string');
8
+ exports.HexBytes = zod_1.z.string().regex(/^0x(?:[0-9a-fA-F]{2})*$/, '0x-prefixed hex bytes');
9
+ exports.Bytes32 = zod_1.z.string().regex(/^0x[0-9a-fA-F]{64}$/, '0x-prefixed 32-byte hex');
10
+ exports.EvmAddress = zod_1.z
11
+ .string()
12
+ .regex(/^0x[0-9a-fA-F]{40}$/, 'EVM address (0x + 20 bytes hex)');
13
+ exports.SvmAddress = zod_1.z
14
+ .string()
15
+ .regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, 'SVM address (base58, 32-44 chars)');
16
+ exports.TvmAddress = zod_1.z.union([
17
+ zod_1.z.string().regex(/^T[1-9A-HJ-NP-Za-km-z]{33}$/, 'TVM address (base58check)'),
18
+ zod_1.z.string().regex(/^0x41[0-9a-fA-F]{40}$/, 'TVM address (0x41-prefixed hex)'),
19
+ ]);
20
+ exports.AnyAddress = zod_1.z.union([exports.EvmAddress, exports.SvmAddress, exports.TvmAddress]);
21
+ exports.ADDRESS_BY_CHAIN_TYPE = {
22
+ evm: exports.EvmAddress,
23
+ svm: exports.SvmAddress,
24
+ tvm: exports.TvmAddress,
25
+ };
26
+ function isSameEvmAddress(a, b) {
27
+ return a.toLowerCase() === b.toLowerCase();
28
+ }
29
+ exports.ChainId = zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
30
+ exports.MAX_UNIX_SECONDS = 4102444800;
31
+ exports.UnixSeconds = zod_1.z.number().int().nonnegative().max(exports.MAX_UNIX_SECONDS);
32
+ exports.DappId = zod_1.z.string().min(1).max(128);
33
+ const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
34
+ const OBJECT_ID = '[0-9a-f]{24}';
35
+ exports.QuoteId = zod_1.z.string().regex(new RegExp(`^quote:${UUID}$`), 'quote:<uuid>');
36
+ exports.IntentId = zod_1.z.string().regex(/^intent:0x[0-9a-fA-F]{64}$/, 'intent:<hash>');
37
+ exports.GaslessId = zod_1.z
38
+ .string()
39
+ .regex(new RegExp(`^gasless:(${UUID}|${OBJECT_ID})$`), 'gasless:<uuid|24-hex objectid>');
40
+ exports.GaslessJobRef = zod_1.z
41
+ .string()
42
+ .regex(new RegExp(`^(${UUID}|${OBJECT_ID})$`), '<uuid|24-hex objectid>');
43
+ exports.DepositAddressId = zod_1.z
44
+ .string()
45
+ .regex(/^deposit-address:0x[0-9a-fA-F]{40}$/, 'deposit-address:<evm address>');
46
+ exports.V1Id = zod_1.z.union([exports.QuoteId, exports.IntentId, exports.GaslessId, exports.DepositAddressId]);
47
+ const ID_PARSERS = [
48
+ { type: 'quote', schema: exports.QuoteId },
49
+ { type: 'intent', schema: exports.IntentId },
50
+ { type: 'gasless', schema: exports.GaslessId },
51
+ { type: 'deposit-address', schema: exports.DepositAddressId },
52
+ ];
53
+ function parseV1Id(id) {
54
+ for (const { type, schema } of ID_PARSERS) {
55
+ if (schema.safeParse(id).success) {
56
+ return { type, value: id.slice(type.length + 1) };
57
+ }
58
+ }
59
+ throw new Error(`unrecognized v1 id: ${id}`);
60
+ }
61
+ var tolerant_1 = require("./tolerant");
62
+ Object.defineProperty(exports, "tolerantEnum", { enumerable: true, get: function () { return tolerant_1.tolerantEnum; } });
63
+ //# sourceMappingURL=primitives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/v1/primitives.ts"],"names":[],"mappings":";;;AA8CA,4CAEC;AAoED,8BAOC;AA3HD,6BAAwB;AASX,QAAA,UAAU,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,iCAAiC,CAAC,CAAC;AAInF,QAAA,QAAQ,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;AAIhF,QAAA,OAAO,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,CAAC;AAG7E,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,EAAE;KACR,KAAK,CAAC,qBAAqB,EAAE,iCAAiC,CAAC,CAAC;AACtD,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,EAAE;KACR,KAAK,CAAC,+BAA+B,EAAE,mCAAmC,CAAC,CAAC;AAElE,QAAA,UAAU,GAAG,OAAC,CAAC,KAAK,CAAC;IAChC,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,6BAA6B,EAAE,2BAA2B,CAAC;IAC5E,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,uBAAuB,EAAE,iCAAiC,CAAC;CAC7E,CAAC,CAAC;AAOU,QAAA,UAAU,GAAG,OAAC,CAAC,KAAK,CAAC,CAAC,kBAAU,EAAE,kBAAU,EAAE,kBAAU,CAAC,CAAC,CAAC;AAG3D,QAAA,qBAAqB,GAAqD;IACrF,GAAG,EAAE,kBAAU;IACf,GAAG,EAAE,kBAAU;IACf,GAAG,EAAE,kBAAU;CAChB,CAAC;AAEF,SAAgB,gBAAgB,CAAC,CAAS,EAAE,CAAS;IACnD,OAAO,CAAC,CAAC,WAAW,EAAE,KAA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E,gBAAQ,EAAE,iBAAS,EAAE,wBAAgB,CAAC,CAAC,CAAC;AAQ9E,MAAM,UAAU,GAAuE;IACrF,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,eAAO,EAAE;IAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAQ,EAAE;IACpC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAS,EAAE;IACtC,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,wBAAgB,EAAE;CACtD,CAAC;AAQF,SAAgB,SAAS,CAAC,EAAU;IAClC,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC1C,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;YACjC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QACpD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC;AAQD,uCAA0C;AAAjC,wGAAA,YAAY,OAAA"}
@@ -0,0 +1,10 @@
1
+ export declare const ZERO_BYTES32: string;
2
+ export interface CanonicalSignature {
3
+ r: string;
4
+ s: string;
5
+ v: 27 | 28;
6
+ serialized: string;
7
+ }
8
+ export declare function canonicalizeSignature(signature: string): CanonicalSignature;
9
+ export declare function signatureHash(signature: string): string;
10
+ export declare function keccak256Hex(hexData: string): string;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZERO_BYTES32 = void 0;
4
+ exports.canonicalizeSignature = canonicalizeSignature;
5
+ exports.signatureHash = signatureHash;
6
+ exports.keccak256Hex = keccak256Hex;
7
+ const sha3_1 = require("@noble/hashes/sha3");
8
+ const utils_1 = require("@noble/hashes/utils");
9
+ const SECP256K1_N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141');
10
+ const SECP256K1_HALF_N = SECP256K1_N >> 1n;
11
+ exports.ZERO_BYTES32 = `0x${'00'.repeat(32)}`;
12
+ function wordToBigInt(bytes) {
13
+ return BigInt(`0x${(0, utils_1.bytesToHex)(bytes)}`);
14
+ }
15
+ function to32ByteHex(value) {
16
+ return value.toString(16).padStart(64, '0');
17
+ }
18
+ function canonicalizeSignature(signature) {
19
+ if (!/^0x[0-9a-fA-F]*$/.test(signature) || signature.length % 2 !== 0) {
20
+ throw new Error('signature must be 0x-prefixed hex');
21
+ }
22
+ const bytes = (0, utils_1.hexToBytes)(signature.slice(2));
23
+ let r;
24
+ let s;
25
+ let yParity;
26
+ if (bytes.length === 65) {
27
+ r = wordToBigInt(bytes.subarray(0, 32));
28
+ s = wordToBigInt(bytes.subarray(32, 64));
29
+ const v = bytes[64];
30
+ if (v === 0 || v === 1)
31
+ yParity = v;
32
+ else if (v === 27 || v === 28)
33
+ yParity = v - 27;
34
+ else
35
+ throw new Error(`invalid recovery byte: ${v}`);
36
+ }
37
+ else if (bytes.length === 64) {
38
+ r = wordToBigInt(bytes.subarray(0, 32));
39
+ const yParityAndS = wordToBigInt(bytes.subarray(32, 64));
40
+ yParity = Number(yParityAndS >> 255n);
41
+ s = yParityAndS & ((1n << 255n) - 1n);
42
+ }
43
+ else {
44
+ throw new Error(`signature must be 64 or 65 bytes, got ${bytes.length}`);
45
+ }
46
+ if (r === 0n || r >= SECP256K1_N)
47
+ throw new Error('signature r out of range');
48
+ if (s === 0n || s >= SECP256K1_N)
49
+ throw new Error('signature s out of range');
50
+ if (s > SECP256K1_HALF_N) {
51
+ s = SECP256K1_N - s;
52
+ yParity ^= 1;
53
+ }
54
+ const v = (27 + yParity);
55
+ return {
56
+ r: `0x${to32ByteHex(r)}`,
57
+ s: `0x${to32ByteHex(s)}`,
58
+ v,
59
+ serialized: `0x${to32ByteHex(r)}${to32ByteHex(s)}${v.toString(16)}`,
60
+ };
61
+ }
62
+ function signatureHash(signature) {
63
+ const { serialized } = canonicalizeSignature(signature);
64
+ return `0x${(0, utils_1.bytesToHex)((0, sha3_1.keccak_256)((0, utils_1.hexToBytes)(serialized.slice(2))))}`;
65
+ }
66
+ function keccak256Hex(hexData) {
67
+ if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(hexData)) {
68
+ throw new Error('keccak256Hex expects 0x-prefixed hex bytes');
69
+ }
70
+ return `0x${(0, utils_1.bytesToHex)((0, sha3_1.keccak_256)((0, utils_1.hexToBytes)(hexData.slice(2))))}`;
71
+ }
72
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/v1/signature.ts"],"names":[],"mappings":";;;AA+BA,sDAqCC;AAQD,sCAGC;AAGD,oCAKC;AAvFD,6CAAgD;AAChD,+CAA6D;AAE7D,MAAM,WAAW,GAAG,MAAM,CAAC,oEAAoE,CAAC,CAAC;AACjG,MAAM,gBAAgB,GAAG,WAAW,IAAI,EAAE,CAAC;AAE9B,QAAA,YAAY,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;AAUnD,SAAS,YAAY,CAAC,KAAiB;IACrC,OAAO,MAAM,CAAC,KAAK,IAAA,kBAAU,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AASD,SAAgB,qBAAqB,CAAC,SAAiB;IACrD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,mCAAmC,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AAC,EAAE,CAAC;AACrE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod';
2
+ export declare function tolerantEnum<const T extends readonly [string, ...string[]]>(values: T): z.ZodUnion<readonly [z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>, z.ZodPipe<z.ZodString, z.ZodTransform<{
3
+ unknown: string;
4
+ }, string>>]>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tolerantEnum = tolerantEnum;
4
+ const zod_1 = require("zod");
5
+ function tolerantEnum(values) {
6
+ return zod_1.z.union([
7
+ zod_1.z.enum(values),
8
+ zod_1.z.string().transform((raw) => ({ unknown: raw })),
9
+ ]);
10
+ }
11
+ //# sourceMappingURL=tolerant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tolerant.js","sourceRoot":"","sources":["../../src/v1/tolerant.ts"],"names":[],"mappings":";;AAoBA,oCAKC;AAzBD,6BAAwB;AAoBxB,SAAgB,YAAY,CAAiD,MAAS;IACpF,OAAO,OAAC,CAAC,KAAK,CAAC;QACb,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACd,OAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAwB,CAAC;KACzE,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,277 @@
1
+ export type { LegacyCodeRef, V1ErrorCode, V1ErrorDefinition } from './errors/catalog';
2
+ export type V1SwapType = 'exact-in' | 'exact-out' | 'custom';
3
+ export type V1Guarantee = 'atomic-or-refund' | 'calls-execute-or-refund';
4
+ export type V1FeeKind = 'gas' | 'proving' | 'protocol' | 'gateway';
5
+ export type V1Visibility = 'public' | 'private';
6
+ export type V1ChainType = 'evm' | 'svm' | 'tvm';
7
+ export type V1RelatedIntentRole = 'local' | 'bucket-candidate' | 'stitched-destination';
8
+ export type V1StepKind = 'swap' | 'bridge' | 'deposit' | 'transfer';
9
+ export type V1StatusType = 'intent' | 'quote' | 'gasless' | 'deposit-address';
10
+ export type V1GaslessSubState = 'pending' | 'submitted' | 'published' | 'failed';
11
+ export type V1GaslessJobStatus = 'pending' | 'processing' | 'published' | 'partial' | 'failed' | 'unknown';
12
+ export type V1DestinationCall = {
13
+ target: string;
14
+ data: string;
15
+ value: string;
16
+ tokenOut?: string;
17
+ gasLimit?: string;
18
+ };
19
+ export type V1QuoteRequest = {
20
+ swapType: V1SwapType;
21
+ source: {
22
+ chainId: number;
23
+ token: string;
24
+ amount?: string;
25
+ };
26
+ destination: {
27
+ chainId: number;
28
+ token: string;
29
+ amount?: string;
30
+ recipient?: string;
31
+ calls?: V1DestinationCall[];
32
+ };
33
+ funder: string;
34
+ refundRecipient?: string;
35
+ slippage?: number;
36
+ dappId?: string;
37
+ options?: {
38
+ deadlineSec?: number;
39
+ visibility?: V1Visibility;
40
+ maxCallDataSize?: number;
41
+ allQuotes?: boolean;
42
+ };
43
+ };
44
+ export type V1FeeToken = {
45
+ chainId: number;
46
+ address: string;
47
+ symbol: string | null;
48
+ decimals: number | null;
49
+ [extension: string]: unknown;
50
+ };
51
+ export type V1Fee = {
52
+ kind: V1FeeKind;
53
+ amount: string;
54
+ token: V1FeeToken;
55
+ estimate: boolean;
56
+ [extension: string]: unknown;
57
+ };
58
+ export type V1StepLeg = {
59
+ chainId: number;
60
+ token: string;
61
+ amount: string;
62
+ [extension: string]: unknown;
63
+ };
64
+ export type V1Step = {
65
+ kind: V1StepKind;
66
+ tool: string;
67
+ aggregator?: string;
68
+ from: V1StepLeg;
69
+ to: V1StepLeg;
70
+ fees: V1Fee[];
71
+ estimatedDurationSec: number;
72
+ [extension: string]: unknown;
73
+ };
74
+ export type V1RelatedIntent = {
75
+ role: V1RelatedIntentRole;
76
+ intentHash: string;
77
+ routeHash?: string;
78
+ bucketIndex?: number;
79
+ [extension: string]: unknown;
80
+ };
81
+ export type V1SolverIdentity = {
82
+ id: string;
83
+ name?: string;
84
+ [extension: string]: unknown;
85
+ };
86
+ export type V1FundingTransaction = {
87
+ kind: 'evm';
88
+ chainId: number;
89
+ to: string;
90
+ data: string;
91
+ value: string;
92
+ [k: string]: unknown;
93
+ } | {
94
+ kind: 'svm';
95
+ chainId: number;
96
+ serializedTransaction: string;
97
+ [k: string]: unknown;
98
+ };
99
+ export type V1IntentTokenAmount = {
100
+ token: string;
101
+ amount: string;
102
+ [extension: string]: unknown;
103
+ };
104
+ export type V1IntentCall = {
105
+ target: string;
106
+ data: string;
107
+ value: string;
108
+ [extension: string]: unknown;
109
+ };
110
+ export type V1IntentRoute = {
111
+ salt: string;
112
+ deadline: number;
113
+ source: number;
114
+ destination: number;
115
+ portal: string;
116
+ nativeAmount: string;
117
+ tokens: V1IntentTokenAmount[];
118
+ calls: V1IntentCall[] | null;
119
+ [extension: string]: unknown;
120
+ };
121
+ export type V1IntentReward = {
122
+ deadline: number;
123
+ creator: string;
124
+ prover: string;
125
+ nativeAmount: string;
126
+ tokens: V1IntentTokenAmount[];
127
+ [extension: string]: unknown;
128
+ };
129
+ export type V1Execution = {
130
+ transaction: V1FundingTransaction;
131
+ intent: {
132
+ route: V1IntentRoute;
133
+ reward: V1IntentReward;
134
+ [extension: string]: unknown;
135
+ };
136
+ encodedRoute: string | null;
137
+ encodedReward: string | null;
138
+ [extension: string]: unknown;
139
+ };
140
+ export type V1QuoteCore = {
141
+ id: string;
142
+ swapType: V1SwapType;
143
+ visibility: V1Visibility;
144
+ guarantee: V1Guarantee;
145
+ source: {
146
+ chainId: number;
147
+ token: string;
148
+ amount: string;
149
+ symbol: string | null;
150
+ decimals: number | null;
151
+ [extension: string]: unknown;
152
+ };
153
+ destination: {
154
+ chainId: number;
155
+ token: string;
156
+ amount: string;
157
+ minAmountOut: string;
158
+ recipient: string | null;
159
+ symbol: string | null;
160
+ decimals: number | null;
161
+ [extension: string]: unknown;
162
+ };
163
+ slippage: number;
164
+ fees: V1Fee[];
165
+ steps: V1Step[];
166
+ relatedIntents: V1RelatedIntent[];
167
+ solver: V1SolverIdentity;
168
+ intentHash: string | null;
169
+ execution: V1Execution | null;
170
+ expiresAt: number;
171
+ signature: string;
172
+ [extension: string]: unknown;
173
+ };
174
+ export type V1RankedQuoteEntry = V1QuoteCore;
175
+ export type V1QuoteResponse = V1QuoteCore & {
176
+ quotes: V1RankedQuoteEntry[] | null;
177
+ };
178
+ export type V1GaslessSubStatus = {
179
+ chainId: number;
180
+ quoteIds: string[];
181
+ txHash: string | null;
182
+ intentHashes: string[];
183
+ state: V1GaslessSubState;
184
+ [extension: string]: unknown;
185
+ };
186
+ export type V1GaslessJob = {
187
+ id: string;
188
+ status: V1GaslessJobStatus;
189
+ signatureHash: string;
190
+ subStatuses: V1GaslessSubStatus[];
191
+ createdAt: number;
192
+ updatedAt: number;
193
+ [extension: string]: unknown;
194
+ };
195
+ export type V1StatusEntry = {
196
+ id: string;
197
+ type: V1StatusType;
198
+ status: string;
199
+ updatedAt: number | null;
200
+ intentHashes?: string[];
201
+ txHash?: string | null;
202
+ subStatuses?: V1GaslessSubStatus[];
203
+ [extension: string]: unknown;
204
+ };
205
+ export type V1Chain = {
206
+ chainId: number;
207
+ name: string;
208
+ type: V1ChainType;
209
+ encoding: 'abi' | 'borsh';
210
+ status: 'live' | 'paused';
211
+ quoteSigner: string;
212
+ contracts: {
213
+ portal: string;
214
+ executor: string | null;
215
+ [extension: string]: unknown;
216
+ };
217
+ [extension: string]: unknown;
218
+ };
219
+ export type V1TokenEntry = {
220
+ chainId: number;
221
+ address: string;
222
+ symbol: string | null;
223
+ decimals: number | null;
224
+ supports: {
225
+ quote: ('permit3' | 'permit2' | 'erc-3009' | 'erc-2612')[];
226
+ depositAddress: ('permit3' | 'permit2' | 'erc-3009' | 'erc-2612')[];
227
+ [extension: string]: unknown;
228
+ };
229
+ [extension: string]: unknown;
230
+ };
231
+ export type V1DepositAddressKind = 'solana' | 'gateway' | 'gateway-erc20';
232
+ export type V1DepositAddressCreateRequest = {
233
+ chainId: number;
234
+ depositor: string;
235
+ kind: 'solana';
236
+ destinationAddress: string;
237
+ } | {
238
+ chainId: number;
239
+ depositor: string;
240
+ kind: 'gateway';
241
+ destinationAddress: string;
242
+ } | {
243
+ chainId: number;
244
+ depositor: string;
245
+ kind: 'gateway-erc20';
246
+ destinationAddress: string;
247
+ destinationChainId: number;
248
+ };
249
+ export type V1DepositAddress = {
250
+ id: string;
251
+ depositAddress: string;
252
+ chainId: number;
253
+ depositor: string;
254
+ kind: V1DepositAddressKind;
255
+ destinationAddress: string;
256
+ destinationChainId?: number;
257
+ expiresAt: number | null;
258
+ createdAt: number;
259
+ [extension: string]: unknown;
260
+ };
261
+ export type V1ProblemBody = {
262
+ type: string;
263
+ title: string;
264
+ status: number;
265
+ code: string;
266
+ detail?: string;
267
+ instance?: string;
268
+ legacyCode?: string;
269
+ solverErrors?: {
270
+ solver: string;
271
+ solverName?: string;
272
+ code?: string;
273
+ message: string;
274
+ [extension: string]: unknown;
275
+ }[];
276
+ [extension: string]: unknown;
277
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/v1/types.ts"],"names":[],"mappings":""}