@seapay-ai/erc3009 0.1.1 → 0.2.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 (98) hide show
  1. package/README.md +171 -184
  2. package/dist/build.d.ts +27 -0
  3. package/dist/build.d.ts.map +1 -0
  4. package/dist/build.js +47 -0
  5. package/dist/domain.d.ts +29 -0
  6. package/dist/domain.d.ts.map +1 -0
  7. package/dist/domain.js +57 -0
  8. package/dist/index.d.ts +8 -22
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +10 -31
  11. package/dist/registry.d.ts +44 -0
  12. package/dist/registry.d.ts.map +1 -0
  13. package/dist/registry.js +166 -0
  14. package/dist/types/index.d.ts +44 -3
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/types/index.js +1 -3
  17. package/dist/utils.d.ts +13 -0
  18. package/dist/utils.d.ts.map +1 -0
  19. package/dist/utils.js +19 -0
  20. package/dist/verify.d.ts +14 -0
  21. package/dist/verify.d.ts.map +1 -0
  22. package/dist/verify.js +36 -0
  23. package/package.json +8 -7
  24. package/dist/api/index.d.ts +0 -2
  25. package/dist/api/index.d.ts.map +0 -1
  26. package/dist/api/index.js +0 -1
  27. package/dist/api/prepare.d.ts +0 -47
  28. package/dist/api/prepare.d.ts.map +0 -1
  29. package/dist/api/prepare.js +0 -57
  30. package/dist/core.d.ts +0 -14
  31. package/dist/core.d.ts.map +0 -1
  32. package/dist/core.js +0 -13
  33. package/dist/domain/index.d.ts +0 -3
  34. package/dist/domain/index.d.ts.map +0 -1
  35. package/dist/domain/index.js +0 -2
  36. package/dist/domain/normalize.d.ts +0 -9
  37. package/dist/domain/normalize.d.ts.map +0 -1
  38. package/dist/domain/normalize.js +0 -25
  39. package/dist/domain/resolveDomain.d.ts +0 -15
  40. package/dist/domain/resolveDomain.d.ts.map +0 -1
  41. package/dist/domain/resolveDomain.js +0 -47
  42. package/dist/erc3009/buildTypes.d.ts +0 -6
  43. package/dist/erc3009/buildTypes.d.ts.map +0 -1
  44. package/dist/erc3009/buildTypes.js +0 -11
  45. package/dist/erc3009/constants.d.ts +0 -7
  46. package/dist/erc3009/constants.d.ts.map +0 -1
  47. package/dist/erc3009/constants.js +0 -6
  48. package/dist/erc3009/index.d.ts +0 -7
  49. package/dist/erc3009/index.d.ts.map +0 -1
  50. package/dist/erc3009/index.js +0 -6
  51. package/dist/erc3009/message.d.ts +0 -21
  52. package/dist/erc3009/message.d.ts.map +0 -1
  53. package/dist/erc3009/message.js +0 -29
  54. package/dist/erc3009/sign.d.ts +0 -7
  55. package/dist/erc3009/sign.d.ts.map +0 -1
  56. package/dist/erc3009/sign.js +0 -8
  57. package/dist/erc3009/typedData.d.ts +0 -15
  58. package/dist/erc3009/typedData.d.ts.map +0 -1
  59. package/dist/erc3009/typedData.js +0 -21
  60. package/dist/erc3009/verify.d.ts +0 -10
  61. package/dist/erc3009/verify.d.ts.map +0 -1
  62. package/dist/erc3009/verify.js +0 -17
  63. package/dist/registry/chains.d.ts +0 -22
  64. package/dist/registry/chains.d.ts.map +0 -1
  65. package/dist/registry/chains.js +0 -104
  66. package/dist/registry/index.d.ts +0 -4
  67. package/dist/registry/index.d.ts.map +0 -1
  68. package/dist/registry/index.js +0 -6
  69. package/dist/registry/registry.d.ts +0 -38
  70. package/dist/registry/registry.d.ts.map +0 -1
  71. package/dist/registry/registry.js +0 -73
  72. package/dist/registry/tokens/index.d.ts +0 -11
  73. package/dist/registry/tokens/index.d.ts.map +0 -1
  74. package/dist/registry/tokens/index.js +0 -14
  75. package/dist/registry/tokens/usdc.d.ts +0 -27
  76. package/dist/registry/tokens/usdc.d.ts.map +0 -1
  77. package/dist/registry/tokens/usdc.js +0 -104
  78. package/dist/types/domain.d.ts +0 -24
  79. package/dist/types/domain.d.ts.map +0 -1
  80. package/dist/types/domain.js +0 -1
  81. package/dist/types/erc3009.d.ts +0 -38
  82. package/dist/types/erc3009.d.ts.map +0 -1
  83. package/dist/types/erc3009.js +0 -15
  84. package/dist/types/registry.d.ts +0 -35
  85. package/dist/types/registry.d.ts.map +0 -1
  86. package/dist/types/registry.js +0 -1
  87. package/dist/utils/hex.d.ts +0 -13
  88. package/dist/utils/hex.d.ts.map +0 -1
  89. package/dist/utils/hex.js +0 -19
  90. package/dist/utils/index.d.ts +0 -4
  91. package/dist/utils/index.d.ts.map +0 -1
  92. package/dist/utils/index.js +0 -3
  93. package/dist/utils/nonce.d.ts +0 -5
  94. package/dist/utils/nonce.d.ts.map +0 -1
  95. package/dist/utils/nonce.js +0 -7
  96. package/dist/utils/time.d.ts +0 -13
  97. package/dist/utils/time.d.ts.map +0 -1
  98. package/dist/utils/time.js +0 -18
@@ -1,15 +0,0 @@
1
- import type { EIP712Domain, ResolveDomainParams } from "../types/domain.js";
2
- /**
3
- * Resolve EIP-712 domain from chain + token with override support
4
- *
5
- * Priority:
6
- * 1. Explicit overrides (name, version, verifyingContract)
7
- * 2. Registry lookup (by symbol or address)
8
- * 3. Error if cannot resolve
9
- */
10
- export declare function resolveDomain(params: ResolveDomainParams): EIP712Domain;
11
- /**
12
- * Resolve domain from token config only (no overrides)
13
- */
14
- export declare function resolveDomainFromToken(symbol: string, chainId: number): EIP712Domain;
15
- //# sourceMappingURL=resolveDomain.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveDomain.d.ts","sourceRoot":"","sources":["../../src/domain/resolveDomain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI5E;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,YAAY,CA8BvE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,YAAY,CAcd"}
@@ -1,47 +0,0 @@
1
- import { getToken, getTokenByAddress } from "../registry/registry.js";
2
- import { normalizeAddress, normalizeChainId } from "./normalize.js";
3
- /**
4
- * Resolve EIP-712 domain from chain + token with override support
5
- *
6
- * Priority:
7
- * 1. Explicit overrides (name, version, verifyingContract)
8
- * 2. Registry lookup (by symbol or address)
9
- * 3. Error if cannot resolve
10
- */
11
- export function resolveDomain(params) {
12
- const chainId = normalizeChainId(params.chainId);
13
- // Try registry lookup
14
- let config = getToken(params.token, chainId);
15
- // If not found by symbol, try as address
16
- if (!config && params.token.startsWith("0x")) {
17
- config = getTokenByAddress(params.token, chainId);
18
- }
19
- // If still not found and no explicit verifyingContract, error
20
- if (!config && !params.verifyingContract) {
21
- throw new Error(`Token "${params.token}" not found in registry for chainId ${chainId}. ` +
22
- `Provide explicit domain parameters or use a supported token.`);
23
- }
24
- // Build domain with overrides
25
- const domain = {
26
- name: params.name ?? config?.name ?? "USD Coin",
27
- version: params.version ?? config?.version ?? "2",
28
- chainId,
29
- verifyingContract: normalizeAddress(params.verifyingContract ?? config?.verifyingContract ?? params.token),
30
- };
31
- return domain;
32
- }
33
- /**
34
- * Resolve domain from token config only (no overrides)
35
- */
36
- export function resolveDomainFromToken(symbol, chainId) {
37
- const config = getToken(symbol, chainId);
38
- if (!config) {
39
- throw new Error(`Token "${symbol}" not configured for chainId ${chainId}`);
40
- }
41
- return {
42
- name: config.name,
43
- version: config.version,
44
- chainId: config.chainId,
45
- verifyingContract: config.verifyingContract,
46
- };
47
- }
@@ -1,6 +0,0 @@
1
- import type { TypedDataField } from "ethers";
2
- /**
3
- * Build EIP-712 types object for ERC-3009
4
- */
5
- export declare function buildTypes(): Record<string, TypedDataField[]>;
6
- //# sourceMappingURL=buildTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildTypes.d.ts","sourceRoot":"","sources":["../../src/erc3009/buildTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAM7C;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAM7D"}
@@ -1,11 +0,0 @@
1
- import { TRANSFER_WITH_AUTHORIZATION_TYPE, TRANSFER_WITH_AUTHORIZATION_FIELDS, } from "./constants.js";
2
- /**
3
- * Build EIP-712 types object for ERC-3009
4
- */
5
- export function buildTypes() {
6
- return {
7
- [TRANSFER_WITH_AUTHORIZATION_TYPE]: [
8
- ...TRANSFER_WITH_AUTHORIZATION_FIELDS,
9
- ],
10
- };
11
- }
@@ -1,7 +0,0 @@
1
- import { TRANSFER_WITH_AUTHORIZATION_TYPE, TRANSFER_WITH_AUTHORIZATION_FIELDS } from "../types/erc3009.js";
2
- export { TRANSFER_WITH_AUTHORIZATION_TYPE, TRANSFER_WITH_AUTHORIZATION_FIELDS };
3
- /**
4
- * EIP-712 primary type for ERC-3009
5
- */
6
- export declare const PRIMARY_TYPE = "TransferWithAuthorization";
7
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/erc3009/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,kCAAkC,EACnC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gCAAgC,EAAE,kCAAkC,EAAE,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,YAAY,8BAAmC,CAAC"}
@@ -1,6 +0,0 @@
1
- import { TRANSFER_WITH_AUTHORIZATION_TYPE, TRANSFER_WITH_AUTHORIZATION_FIELDS, } from "../types/erc3009.js";
2
- export { TRANSFER_WITH_AUTHORIZATION_TYPE, TRANSFER_WITH_AUTHORIZATION_FIELDS };
3
- /**
4
- * EIP-712 primary type for ERC-3009
5
- */
6
- export const PRIMARY_TYPE = TRANSFER_WITH_AUTHORIZATION_TYPE;
@@ -1,7 +0,0 @@
1
- export * from "./constants.js";
2
- export * from "./buildTypes.js";
3
- export * from "./message.js";
4
- export * from "./typedData.js";
5
- export * from "./sign.js";
6
- export * from "./verify.js";
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/erc3009/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -1,6 +0,0 @@
1
- export * from "./constants.js";
2
- export * from "./buildTypes.js";
3
- export * from "./message.js";
4
- export * from "./typedData.js";
5
- export * from "./sign.js";
6
- export * from "./verify.js";
@@ -1,21 +0,0 @@
1
- import type { TransferWithAuthorization } from "../types/erc3009.js";
2
- export type BuildMessageParams = {
3
- from: string;
4
- to: string;
5
- value: bigint | number | string;
6
- validAfter?: bigint | number | string;
7
- validBefore?: bigint | number | string;
8
- nonce?: string;
9
- };
10
- /**
11
- * Build a TransferWithAuthorization message
12
- */
13
- export declare function buildMessage(params: BuildMessageParams): TransferWithAuthorization;
14
- /**
15
- * Build message with explicit time window (in seconds)
16
- * @param ttlSeconds - time-to-live in seconds (default: 300 = 5 minutes)
17
- */
18
- export declare function buildMessageWithTTL(params: Omit<BuildMessageParams, "validAfter" | "validBefore"> & {
19
- ttlSeconds?: number;
20
- }): TransferWithAuthorization;
21
- //# sourceMappingURL=message.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/erc3009/message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAIrE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,yBAAyB,CAW3B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,YAAY,GAAG,aAAa,CAAC,GAAG;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,yBAAyB,CAO3B"}
@@ -1,29 +0,0 @@
1
- import { randomNonce } from "../utils/nonce.js";
2
- import { nowPlusSeconds, toBigInt } from "../utils/time.js";
3
- /**
4
- * Build a TransferWithAuthorization message
5
- */
6
- export function buildMessage(params) {
7
- return {
8
- from: params.from,
9
- to: params.to,
10
- value: toBigInt(params.value),
11
- validAfter: params.validAfter ? toBigInt(params.validAfter) : 0n,
12
- validBefore: params.validBefore
13
- ? toBigInt(params.validBefore)
14
- : nowPlusSeconds(300), // default: 5 minutes
15
- nonce: params.nonce || randomNonce(),
16
- };
17
- }
18
- /**
19
- * Build message with explicit time window (in seconds)
20
- * @param ttlSeconds - time-to-live in seconds (default: 300 = 5 minutes)
21
- */
22
- export function buildMessageWithTTL(params) {
23
- const ttl = params.ttlSeconds ?? 300;
24
- return buildMessage({
25
- ...params,
26
- validAfter: 0,
27
- validBefore: nowPlusSeconds(ttl),
28
- });
29
- }
@@ -1,7 +0,0 @@
1
- import type { Wallet } from "ethers";
2
- import type { EIP712Domain, TransferWithAuthorization } from "../types/index.js";
3
- /**
4
- * Sign a TransferWithAuthorization message with an ethers Wallet
5
- */
6
- export declare function signTransferWithAuthorization(wallet: Wallet, domain: EIP712Domain, message: TransferWithAuthorization): Promise<string>;
7
- //# sourceMappingURL=sign.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../src/erc3009/sign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAGjF;;GAEG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CAGjB"}
@@ -1,8 +0,0 @@
1
- import { buildTypedData } from "./typedData.js";
2
- /**
3
- * Sign a TransferWithAuthorization message with an ethers Wallet
4
- */
5
- export async function signTransferWithAuthorization(wallet, domain, message) {
6
- const typed = buildTypedData({ domain, message });
7
- return await wallet.signTypedData(typed.domain, typed.types, typed.message);
8
- }
@@ -1,15 +0,0 @@
1
- import type { TypedDataDomain, TypedDataField } from "ethers";
2
- import type { TransferWithAuthorization, EIP712Domain } from "../types/index.js";
3
- export type TypedData = {
4
- domain: TypedDataDomain;
5
- types: Record<string, TypedDataField[]>;
6
- message: TransferWithAuthorization;
7
- };
8
- /**
9
- * Build complete typed data structure for EIP-712 signing
10
- */
11
- export declare function buildTypedData(params: {
12
- domain: EIP712Domain;
13
- message: TransferWithAuthorization;
14
- }): TypedData;
15
- //# sourceMappingURL=typedData.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typedData.d.ts","sourceRoot":"","sources":["../../src/erc3009/typedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,KAAK,EACV,yBAAyB,EACzB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAG3B,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IACxC,OAAO,EAAE,yBAAyB,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,yBAAyB,CAAC;CACpC,GAAG,SAAS,CAgBZ"}
@@ -1,21 +0,0 @@
1
- import { buildTypes } from "./buildTypes.js";
2
- /**
3
- * Build complete typed data structure for EIP-712 signing
4
- */
5
- export function buildTypedData(params) {
6
- return {
7
- domain: {
8
- name: params.domain.name,
9
- version: params.domain.version,
10
- chainId: params.domain.chainId,
11
- verifyingContract: params.domain.verifyingContract,
12
- },
13
- types: buildTypes(),
14
- message: {
15
- ...params.message,
16
- value: BigInt(params.message.value),
17
- validAfter: BigInt(params.message.validAfter),
18
- validBefore: BigInt(params.message.validBefore),
19
- },
20
- };
21
- }
@@ -1,10 +0,0 @@
1
- import type { EIP712Domain, TransferWithAuthorization } from "../types/index.js";
2
- /**
3
- * Recover the signer address from a signature
4
- */
5
- export declare function recoverSigner(domain: EIP712Domain, message: TransferWithAuthorization, signature: string): string;
6
- /**
7
- * Verify that a signature was signed by the expected address
8
- */
9
- export declare function verifySignature(domain: EIP712Domain, message: TransferWithAuthorization, signature: string, expectedSigner: string): boolean;
10
- //# sourceMappingURL=verify.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/erc3009/verify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAIjF;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,yBAAyB,EAClC,SAAS,EAAE,MAAM,GAChB,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,yBAAyB,EAClC,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAKT"}
@@ -1,17 +0,0 @@
1
- import { verifyTypedData } from "ethers";
2
- import { buildTypes } from "./buildTypes.js";
3
- import { normalizeAddress } from "../utils/hex.js";
4
- /**
5
- * Recover the signer address from a signature
6
- */
7
- export function recoverSigner(domain, message, signature) {
8
- const types = buildTypes();
9
- return verifyTypedData(domain, types, message, signature);
10
- }
11
- /**
12
- * Verify that a signature was signed by the expected address
13
- */
14
- export function verifySignature(domain, message, signature, expectedSigner) {
15
- const recovered = recoverSigner(domain, message, signature);
16
- return (normalizeAddress(recovered) === normalizeAddress(expectedSigner));
17
- }
@@ -1,22 +0,0 @@
1
- import type { ChainConfig } from "../types/registry.js";
2
- /**
3
- * Chain registry with metadata for supported chains
4
- */
5
- export declare const CHAINS: Record<number, ChainConfig>;
6
- /**
7
- * Get chain configuration by chainId
8
- */
9
- export declare function getChain(chainId: number): ChainConfig | undefined;
10
- /**
11
- * List all supported chain IDs
12
- */
13
- export declare function listChainIds(): number[];
14
- /**
15
- * List all supported chains
16
- */
17
- export declare function listChains(): ChainConfig[];
18
- /**
19
- * Check if chain is supported
20
- */
21
- export declare function isChainSupported(chainId: number): boolean;
22
- //# sourceMappingURL=chains.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/registry/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA4E9C,CAAC;AAEF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEjE;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,WAAW,EAAE,CAE1C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD"}
@@ -1,104 +0,0 @@
1
- /**
2
- * Chain registry with metadata for supported chains
3
- */
4
- export const CHAINS = {
5
- // Ethereum Mainnet
6
- 1: {
7
- chainId: 1,
8
- name: "Ethereum",
9
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
10
- blockExplorerUrls: ["https://etherscan.io"],
11
- },
12
- // Ethereum Sepolia Testnet
13
- 11155111: {
14
- chainId: 11155111,
15
- name: "Sepolia",
16
- nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
17
- blockExplorerUrls: ["https://sepolia.etherscan.io"],
18
- testnet: true,
19
- },
20
- // Base Mainnet
21
- 8453: {
22
- chainId: 8453,
23
- name: "Base",
24
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
25
- blockExplorerUrls: ["https://basescan.org"],
26
- },
27
- // Base Sepolia Testnet
28
- 84532: {
29
- chainId: 84532,
30
- name: "Base Sepolia",
31
- nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
32
- blockExplorerUrls: ["https://sepolia.basescan.org"],
33
- testnet: true,
34
- },
35
- // Arbitrum One
36
- 42161: {
37
- chainId: 42161,
38
- name: "Arbitrum One",
39
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
40
- blockExplorerUrls: ["https://arbiscan.io"],
41
- },
42
- // Arbitrum Sepolia Testnet
43
- 421614: {
44
- chainId: 421614,
45
- name: "Arbitrum Sepolia",
46
- nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
47
- blockExplorerUrls: ["https://sepolia.arbiscan.io"],
48
- testnet: true,
49
- },
50
- // Polygon
51
- 137: {
52
- chainId: 137,
53
- name: "Polygon",
54
- nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18 },
55
- blockExplorerUrls: ["https://polygonscan.com"],
56
- },
57
- // Polygon Amoy Testnet
58
- 80002: {
59
- chainId: 80002,
60
- name: "Polygon Amoy",
61
- nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18 },
62
- blockExplorerUrls: ["https://amoy.polygonscan.com"],
63
- testnet: true,
64
- },
65
- // Optimism
66
- 10: {
67
- chainId: 10,
68
- name: "Optimism",
69
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
70
- blockExplorerUrls: ["https://optimistic.etherscan.io"],
71
- },
72
- // Optimism Sepolia Testnet
73
- 11155420: {
74
- chainId: 11155420,
75
- name: "Optimism Sepolia",
76
- nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
77
- blockExplorerUrls: ["https://sepolia-optimism.etherscan.io"],
78
- testnet: true,
79
- },
80
- };
81
- /**
82
- * Get chain configuration by chainId
83
- */
84
- export function getChain(chainId) {
85
- return CHAINS[chainId];
86
- }
87
- /**
88
- * List all supported chain IDs
89
- */
90
- export function listChainIds() {
91
- return Object.keys(CHAINS).map(Number);
92
- }
93
- /**
94
- * List all supported chains
95
- */
96
- export function listChains() {
97
- return Object.values(CHAINS);
98
- }
99
- /**
100
- * Check if chain is supported
101
- */
102
- export function isChainSupported(chainId) {
103
- return chainId in CHAINS;
104
- }
@@ -1,4 +0,0 @@
1
- export { CHAINS, listChainIds, listChains, isChainSupported } from "./chains.js";
2
- export { TOKENS, USDC, getUSDC, isUSDCSupported, listUSDCChains, listTokenSymbols } from "./tokens/index.js";
3
- export { getToken, getTokenByAddress, getChain, listTokensOnChain, isTokenSupported, } from "./registry.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGjF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG7G,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
@@ -1,6 +0,0 @@
1
- // Export chain-related functions
2
- export { CHAINS, listChainIds, listChains, isChainSupported } from "./chains.js";
3
- // Export token-related functions
4
- export { TOKENS, USDC, getUSDC, isUSDCSupported, listUSDCChains, listTokenSymbols } from "./tokens/index.js";
5
- // Export registry functions (these override some chain functions, but that's intentional)
6
- export { getToken, getTokenByAddress, getChain, listTokensOnChain, isTokenSupported, } from "./registry.js";
@@ -1,38 +0,0 @@
1
- import type { ChainConfig, TokenConfig } from "../types/registry.js";
2
- /**
3
- * Get token configuration by symbol and chainId
4
- */
5
- export declare function getToken(symbol: string, chainId: number): TokenConfig | undefined;
6
- /**
7
- * Get token configuration by address (exact match)
8
- */
9
- export declare function getTokenByAddress(address: string, chainId: number): TokenConfig | undefined;
10
- /**
11
- * Get chain configuration
12
- */
13
- export declare function getChain(chainId: number): ChainConfig | undefined;
14
- /**
15
- * List all chains
16
- */
17
- export declare function listChains(): ChainConfig[];
18
- /**
19
- * List all chain IDs
20
- */
21
- export declare function listChainIds(): number[];
22
- /**
23
- * List all token symbols
24
- */
25
- export declare function listTokenSymbols(): string[];
26
- /**
27
- * List all tokens on a specific chain
28
- */
29
- export declare function listTokensOnChain(chainId: number): TokenConfig[];
30
- /**
31
- * Check if token is supported on chain
32
- */
33
- export declare function isTokenSupported(symbol: string, chainId: number): boolean;
34
- /**
35
- * Check if chain is supported
36
- */
37
- export declare function isChainSupported(chainId: number): boolean;
38
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKrE;;GAEG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,WAAW,GAAG,SAAS,CAGzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,WAAW,GAAG,SAAS,CAYzB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEjE;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,WAAW,EAAE,CAE1C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAShE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD"}
@@ -1,73 +0,0 @@
1
- import { CHAINS, getChain as getChainConfig } from "./chains.js";
2
- import { TOKENS } from "./tokens/index.js";
3
- import { normalizeAddress } from "../utils/hex.js";
4
- /**
5
- * Get token configuration by symbol and chainId
6
- */
7
- export function getToken(symbol, chainId) {
8
- const tokenSymbol = symbol.toUpperCase();
9
- return TOKENS[tokenSymbol]?.[chainId];
10
- }
11
- /**
12
- * Get token configuration by address (exact match)
13
- */
14
- export function getTokenByAddress(address, chainId) {
15
- const normalized = normalizeAddress(address);
16
- const tokens = Object.values(TOKENS);
17
- for (const tokenChains of tokens) {
18
- const config = tokenChains[chainId];
19
- if (config && normalizeAddress(config.verifyingContract) === normalized) {
20
- return config;
21
- }
22
- }
23
- return undefined;
24
- }
25
- /**
26
- * Get chain configuration
27
- */
28
- export function getChain(chainId) {
29
- return getChainConfig(chainId);
30
- }
31
- /**
32
- * List all chains
33
- */
34
- export function listChains() {
35
- return Object.values(CHAINS);
36
- }
37
- /**
38
- * List all chain IDs
39
- */
40
- export function listChainIds() {
41
- return Object.keys(CHAINS).map(Number);
42
- }
43
- /**
44
- * List all token symbols
45
- */
46
- export function listTokenSymbols() {
47
- return Object.keys(TOKENS);
48
- }
49
- /**
50
- * List all tokens on a specific chain
51
- */
52
- export function listTokensOnChain(chainId) {
53
- const result = [];
54
- for (const tokenChains of Object.values(TOKENS)) {
55
- const config = tokenChains[chainId];
56
- if (config) {
57
- result.push(config);
58
- }
59
- }
60
- return result;
61
- }
62
- /**
63
- * Check if token is supported on chain
64
- */
65
- export function isTokenSupported(symbol, chainId) {
66
- return getToken(symbol, chainId) !== undefined;
67
- }
68
- /**
69
- * Check if chain is supported
70
- */
71
- export function isChainSupported(chainId) {
72
- return chainId in CHAINS;
73
- }
@@ -1,11 +0,0 @@
1
- export * from "./usdc.js";
2
- import type { TokenRegistry } from "../../types/registry.js";
3
- /**
4
- * All token configurations indexed by symbol
5
- */
6
- export declare const TOKENS: TokenRegistry;
7
- /**
8
- * Get all supported token symbols
9
- */
10
- export declare function listTokenSymbols(): string[];
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/registry/tokens/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,aAEpB,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C"}
@@ -1,14 +0,0 @@
1
- export * from "./usdc.js";
2
- import { USDC } from "./usdc.js";
3
- /**
4
- * All token configurations indexed by symbol
5
- */
6
- export const TOKENS = {
7
- USDC,
8
- };
9
- /**
10
- * Get all supported token symbols
11
- */
12
- export function listTokenSymbols() {
13
- return Object.keys(TOKENS);
14
- }
@@ -1,27 +0,0 @@
1
- import type { TokenConfig } from "../../types/registry.js";
2
- /**
3
- * USDC token configurations across supported chains
4
- *
5
- * Note: These are the proxy addresses and EIP-712 domain parameters
6
- * for the USDC contract on each chain.
7
- *
8
- * **IMPORTANT**: Domain names vary by network:
9
- * - Base Mainnet (8453): name = "USD Coin"
10
- * - Base Sepolia (84532): name = "USDC"
11
- *
12
- * Always use the correct domain name for signature verification to work.
13
- */
14
- export declare const USDC: Record<number, TokenConfig>;
15
- /**
16
- * Get USDC configuration for a specific chain
17
- */
18
- export declare function getUSDC(chainId: number): TokenConfig | undefined;
19
- /**
20
- * Check if USDC is supported on a chain
21
- */
22
- export declare function isUSDCSupported(chainId: number): boolean;
23
- /**
24
- * List all chains where USDC is configured
25
- */
26
- export declare function listUSDCChains(): number[];
27
- //# sourceMappingURL=usdc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usdc.d.ts","sourceRoot":"","sources":["../../../src/registry/tokens/usdc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAyE5C,CAAC;AAEF;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEhE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC"}