@armory-sh/base 0.2.33 → 0.2.34-alpha.25.97

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.
@@ -3,7 +3,6 @@ export declare const USDC_BASE: CustomToken;
3
3
  export declare const EURC_BASE: CustomToken;
4
4
  export declare const USDC_BASE_SEPOLIA: CustomToken;
5
5
  export declare const USDC_SKALE_BASE: CustomToken;
6
- export declare const SKL_SKALE_BASE: CustomToken;
7
6
  export declare const USDT_SKALE_BASE: CustomToken;
8
7
  export declare const WBTC_SKALE_BASE: CustomToken;
9
8
  export declare const WETH_SKALE_BASE: CustomToken;
@@ -20,7 +19,6 @@ export declare const TOKENS: {
20
19
  readonly USDT_SKALE_BASE: CustomToken;
21
20
  readonly WBTC_SKALE_BASE: CustomToken;
22
21
  readonly WETH_SKALE_BASE: CustomToken;
23
- readonly SKL_SKALE_BASE: CustomToken;
24
22
  readonly SKL_SKALE_BASE_SEPOLIA: CustomToken;
25
23
  readonly USDC_SKALE_BASE_SEPOLIA: CustomToken;
26
24
  readonly USDT_SKALE_BASE_SEPOLIA: CustomToken;
package/dist/eip712.d.ts CHANGED
@@ -48,10 +48,6 @@ export declare const EIP712_TYPES: {
48
48
  readonly type: "bytes32";
49
49
  }];
50
50
  };
51
- export declare const USDC_DOMAIN: {
52
- readonly NAME: "USD Coin";
53
- readonly VERSION: "2";
54
- };
55
51
  export declare const createEIP712Domain: (chainId: number, contractAddress: `0x${string}`) => EIP712Domain;
56
52
  export declare const createTransferWithAuthorization: (params: Omit<TransferWithAuthorization, "value" | "validAfter" | "validBefore" | "nonce"> & {
57
53
  value: bigint | number;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export type { BalanceOfParams, BalanceOfReturnType, ERC20Abi, NameReturnType, ReceiveWithAuthorizationParams, SymbolReturnType, TransferWithAuthorizationParams, } from "./abi/erc20";
2
2
  export { ERC20_ABI } from "./abi/erc20";
3
3
  export { runAfterPaymentResponseHooks, runBeforeSignPaymentHooks, runOnPaymentRequiredHooks, selectRequirementWithHooks, } from "./client-hooks-runtime";
4
- export { EURC_BASE, getAllTokens, getEURCTokens, getSKLTokens, getToken, getTokensByChain, getTokensBySymbol, getUSDCTokens, getUSDTTokens, getWBTCTokens, getWETHTokens, SKL_SKALE_BASE, SKL_SKALE_BASE_SEPOLIA, TOKENS, USDC_BASE, USDC_BASE_SEPOLIA, USDC_SKALE_BASE, USDC_SKALE_BASE_SEPOLIA, USDT_SKALE_BASE, USDT_SKALE_BASE_SEPOLIA, WBTC_SKALE_BASE, WBTC_SKALE_BASE_SEPOLIA, WETH_SKALE_BASE, WETH_SKALE_BASE_SEPOLIA, } from "./data/tokens";
4
+ export { EURC_BASE, getAllTokens, getEURCTokens, getSKLTokens, getToken, getTokensByChain, getTokensBySymbol, getUSDCTokens, getUSDTTokens, getWBTCTokens, getWETHTokens, SKL_SKALE_BASE_SEPOLIA, TOKENS, USDC_BASE, USDC_BASE_SEPOLIA, USDC_SKALE_BASE, USDC_SKALE_BASE_SEPOLIA, USDT_SKALE_BASE, USDT_SKALE_BASE_SEPOLIA, WBTC_SKALE_BASE, WBTC_SKALE_BASE_SEPOLIA, WETH_SKALE_BASE, WETH_SKALE_BASE_SEPOLIA, } from "./data/tokens";
5
5
  export type { EIP712Domain, EIP712Types, TransferWithAuthorization, TypedDataDomain, TypedDataField, } from "./eip712";
6
- export { createEIP712Domain, createTransferWithAuthorization, EIP712_TYPES, USDC_DOMAIN, validateTransferWithAuthorization, } from "./eip712";
6
+ export { createEIP712Domain, createTransferWithAuthorization, EIP712_TYPES, validateTransferWithAuthorization, } from "./eip712";
7
7
  export { decodePaymentV2, decodeSettlementV2, encodePaymentV2, encodeSettlementV2, isPaymentV2, isSettlementV2, } from "./encoding";
8
8
  export type { PaymentRequiredOptions } from "./encoding/x402";
9
9
  export { createPaymentRequiredHeaders, createSettlementHeaders, decodePayment, decodeSettlementResponse, decodeX402Response, detectPaymentVersion, encodePayment, encodeSettlementResponse, encodeX402Response, extractPaymentFromHeaders, safeBase64Decode, safeBase64Encode, } from "./encoding/x402";
package/dist/index.js CHANGED
@@ -190,14 +190,6 @@ var USDC_SKALE_BASE = {
190
190
  chainId: 1187947933,
191
191
  decimals: 6
192
192
  };
193
- var SKL_SKALE_BASE = {
194
- symbol: "SKL",
195
- name: "SKALE",
196
- version: "1",
197
- contractAddress: "0xE0595a049d02b7674572b0d59cd4880Db60EDC50",
198
- chainId: 1187947933,
199
- decimals: 18
200
- };
201
193
  var USDT_SKALE_BASE = {
202
194
  symbol: "USDT",
203
195
  name: "Tether USD",
@@ -270,7 +262,6 @@ var TOKENS = {
270
262
  USDT_SKALE_BASE,
271
263
  WBTC_SKALE_BASE,
272
264
  WETH_SKALE_BASE,
273
- SKL_SKALE_BASE,
274
265
  SKL_SKALE_BASE_SEPOLIA,
275
266
  USDC_SKALE_BASE_SEPOLIA,
276
267
  USDT_SKALE_BASE_SEPOLIA,
@@ -313,6 +304,209 @@ function getWETHTokens() {
313
304
  return getTokensBySymbol("WETH");
314
305
  }
315
306
 
307
+ // src/types/networks.ts
308
+ var isEvmAddress = (value) => /^0x[a-fA-F0-9]{40}$/.test(value);
309
+ var tokenKey = (chainId, contractAddress) => `${chainId}:${contractAddress.toLowerCase()}`;
310
+ var tokenRegistry = /* @__PURE__ */ new Map([
311
+ [tokenKey(8453, "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"), {
312
+ symbol: "USDC",
313
+ name: "USDC",
314
+ version: "2",
315
+ contractAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
316
+ chainId: 8453,
317
+ decimals: 6
318
+ }],
319
+ [tokenKey(84532, "0x036CbD53842c5426634e7929541eC2318f3dCF7e"), {
320
+ symbol: "USDC",
321
+ name: "USDC",
322
+ version: "2",
323
+ contractAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
324
+ chainId: 84532,
325
+ decimals: 6
326
+ }],
327
+ [tokenKey(8453, "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42"), {
328
+ symbol: "EURC",
329
+ name: "EURC",
330
+ version: "2",
331
+ contractAddress: "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",
332
+ chainId: 8453,
333
+ decimals: 6
334
+ }],
335
+ [tokenKey(1187947933, "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20"), {
336
+ symbol: "USDC",
337
+ name: "USDC",
338
+ version: "2",
339
+ contractAddress: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",
340
+ chainId: 1187947933,
341
+ decimals: 6
342
+ }],
343
+ [tokenKey(1187947933, "0x2bF5bF154b515EaA82C31a65ec11554fF5aF7fCA"), {
344
+ symbol: "USDT",
345
+ name: "USDT",
346
+ version: "1",
347
+ contractAddress: "0x2bF5bF154b515EaA82C31a65ec11554fF5aF7fCA",
348
+ chainId: 1187947933,
349
+ decimals: 6
350
+ }],
351
+ [tokenKey(1187947933, "0x1aeeCFE5454c83B42D8A316246CAc9739E7f690e"), {
352
+ symbol: "WBTC",
353
+ name: "Wrapped BTC",
354
+ version: "1",
355
+ contractAddress: "0x1aeeCFE5454c83B42D8A316246CAc9739E7f690e",
356
+ chainId: 1187947933,
357
+ decimals: 8
358
+ }],
359
+ [tokenKey(1187947933, "0x7bD39ABBd0Dd13103542cAe3276C7fA332bCA486"), {
360
+ symbol: "WETH",
361
+ name: "Wrapped Ether",
362
+ version: "1",
363
+ contractAddress: "0x7bD39ABBd0Dd13103542cAe3276C7fA332bCA486",
364
+ chainId: 1187947933,
365
+ decimals: 6
366
+ }],
367
+ [tokenKey(324705682, "0xaf2e0ff5b5f51553fdb34ce7f04a6c3201cee57b"), {
368
+ symbol: "SKL",
369
+ name: "SKALE",
370
+ version: "1",
371
+ contractAddress: "0xaf2e0ff5b5f51553fdb34ce7f04a6c3201cee57b",
372
+ chainId: 324705682,
373
+ decimals: 18
374
+ }],
375
+ [tokenKey(324705682, "0x036CbD53842c5426634e7929541eC2318f3dCF7e"), {
376
+ symbol: "USDC",
377
+ name: "USDC",
378
+ version: "2",
379
+ contractAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
380
+ chainId: 324705682,
381
+ decimals: 6
382
+ }],
383
+ [tokenKey(324705682, "0x3ca0a49f511c2c89c4dcbbf1731120d8919050bf"), {
384
+ symbol: "USDT",
385
+ name: "USDT",
386
+ version: "1",
387
+ contractAddress: "0x3ca0a49f511c2c89c4dcbbf1731120d8919050bf",
388
+ chainId: 324705682,
389
+ decimals: 6
390
+ }],
391
+ [tokenKey(324705682, "0x4512eacd4186b025186e1cf6cc0d89497c530e87"), {
392
+ symbol: "WBTC",
393
+ name: "Wrapped BTC",
394
+ version: "1",
395
+ contractAddress: "0x4512eacd4186b025186e1cf6cc0d89497c530e87",
396
+ chainId: 324705682,
397
+ decimals: 8
398
+ }],
399
+ [tokenKey(324705682, "0xf94056bd7f6965db3757e1b145f200b7346b4fc0"), {
400
+ symbol: "WETH",
401
+ name: "Wrapped Ether",
402
+ version: "1",
403
+ contractAddress: "0xf94056bd7f6965db3757e1b145f200b7346b4fc0",
404
+ chainId: 324705682,
405
+ decimals: 18
406
+ }]
407
+ ]);
408
+ var NETWORKS = {
409
+ ethereum: {
410
+ name: "Ethereum Mainnet",
411
+ chainId: 1,
412
+ usdcAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
413
+ rpcUrl: "https://eth.llamarpc.com",
414
+ caip2Id: "eip155:1",
415
+ caipAssetId: "eip155:1/erc20:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
416
+ },
417
+ base: {
418
+ name: "Base Mainnet",
419
+ chainId: 8453,
420
+ usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
421
+ rpcUrl: "https://mainnet.base.org",
422
+ caip2Id: "eip155:8453",
423
+ caipAssetId: "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
424
+ },
425
+ "base-sepolia": {
426
+ name: "Base Sepolia",
427
+ chainId: 84532,
428
+ usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
429
+ rpcUrl: "https://sepolia.base.org",
430
+ caip2Id: "eip155:84532",
431
+ caipAssetId: "eip155:84532/erc20:0x036CbD53842c5426634e7929541eC2318f3dCF7e"
432
+ },
433
+ "skale-base": {
434
+ name: "SKALE Base",
435
+ chainId: 1187947933,
436
+ usdcAddress: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",
437
+ rpcUrl: "https://skale-base.skalenodes.com/v1/base",
438
+ caip2Id: "eip155:1187947933",
439
+ caipAssetId: "eip155:1187947933/erc20:0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20"
440
+ },
441
+ "skale-base-sepolia": {
442
+ name: "SKALE Base Sepolia",
443
+ chainId: 324705682,
444
+ usdcAddress: "0x2e08028E3C4c2356572E096d8EF835cD5C6030bD",
445
+ rpcUrl: "https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha",
446
+ caip2Id: "eip155:324705682",
447
+ caipAssetId: "eip155:324705682/erc20:0x2e08028E3C4c2356572E096d8EF835cD5C6030bD"
448
+ },
449
+ "ethereum-sepolia": {
450
+ name: "Ethereum Sepolia",
451
+ chainId: 11155111,
452
+ usdcAddress: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
453
+ rpcUrl: "https://rpc.sepolia.org",
454
+ caip2Id: "eip155:11155111",
455
+ caipAssetId: "eip155:11155111/erc20:0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
456
+ }
457
+ };
458
+ var getNetworkConfig = (name) => NETWORKS[name];
459
+ var getNetworkByChainId = (chainId) => Object.values(NETWORKS).find((c) => c.chainId === chainId);
460
+ var getMainnets = () => Object.values(NETWORKS).filter(
461
+ (c) => !c.name.toLowerCase().includes("sepolia")
462
+ );
463
+ var getTestnets = () => Object.values(NETWORKS).filter(
464
+ (c) => c.name.toLowerCase().includes("sepolia")
465
+ );
466
+ var registerToken = (token) => {
467
+ if (typeof token !== "object" || token === null) {
468
+ throw new Error("Invalid token: must be an object");
469
+ }
470
+ const t = token;
471
+ if (typeof t.symbol !== "string") {
472
+ throw new Error("Invalid token: symbol must be a string");
473
+ }
474
+ if (typeof t.name !== "string") {
475
+ throw new Error("Invalid token: name must be a string");
476
+ }
477
+ if (typeof t.version !== "string") {
478
+ throw new Error("Invalid token: version must be a string");
479
+ }
480
+ if (typeof t.contractAddress !== "string" || !isEvmAddress(t.contractAddress)) {
481
+ throw new Error(
482
+ "Invalid token: contractAddress must be a valid EVM address"
483
+ );
484
+ }
485
+ if (typeof t.chainId !== "number" || !Number.isInteger(t.chainId) || t.chainId <= 0) {
486
+ throw new Error("Invalid token: chainId must be a positive integer");
487
+ }
488
+ if (t.decimals !== void 0 && (typeof t.decimals !== "number" || !Number.isInteger(t.decimals) || t.decimals < 0)) {
489
+ throw new Error("Invalid token: decimals must be a non-negative integer");
490
+ }
491
+ const validated = {
492
+ symbol: t.symbol,
493
+ name: t.name,
494
+ version: t.version,
495
+ contractAddress: t.contractAddress,
496
+ chainId: t.chainId,
497
+ decimals: t.decimals
498
+ };
499
+ tokenRegistry.set(
500
+ tokenKey(validated.chainId, validated.contractAddress),
501
+ validated
502
+ );
503
+ return validated;
504
+ };
505
+ var getCustomToken = (chainId, contractAddress) => tokenRegistry.get(tokenKey(chainId, contractAddress));
506
+ var getAllCustomTokens = () => Array.from(tokenRegistry.values());
507
+ var unregisterToken = (chainId, contractAddress) => tokenRegistry.delete(tokenKey(chainId, contractAddress));
508
+ var isCustomToken = (chainId, contractAddress) => tokenRegistry.has(tokenKey(chainId, contractAddress));
509
+
316
510
  // src/eip712.ts
317
511
  var EIP712_TYPES = {
318
512
  TransferWithAuthorization: [
@@ -324,16 +518,20 @@ var EIP712_TYPES = {
324
518
  { name: "nonce", type: "bytes32" }
325
519
  ]
326
520
  };
327
- var USDC_DOMAIN = {
328
- NAME: "USD Coin",
329
- VERSION: "2"
521
+ var createEIP712Domain = (chainId, contractAddress) => {
522
+ const token = getCustomToken(chainId, contractAddress);
523
+ if (!token) {
524
+ throw new Error(
525
+ `Token not found in registry: chainId=${chainId}, contractAddress=${contractAddress}. Please register the token using registerToken() before use.`
526
+ );
527
+ }
528
+ return {
529
+ name: token.name,
530
+ version: token.version,
531
+ chainId,
532
+ verifyingContract: contractAddress
533
+ };
330
534
  };
331
- var createEIP712Domain = (chainId, contractAddress) => ({
332
- name: USDC_DOMAIN.NAME,
333
- version: USDC_DOMAIN.VERSION,
334
- chainId,
335
- verifyingContract: contractAddress
336
- });
337
535
  var createTransferWithAuthorization = (params) => ({
338
536
  from: params.from,
339
537
  to: params.to,
@@ -622,11 +820,10 @@ function toJsonSafe(data) {
622
820
  function resolveUrl(config) {
623
821
  return config?.url ?? DEFAULT_FACILITATOR_URL;
624
822
  }
625
- async function resolveHeaders(config) {
823
+ function resolveHeaders(config) {
626
824
  const base = { "Content-Type": "application/json" };
627
- if (!config?.createHeaders) return base;
628
- const extra = await config.createHeaders();
629
- return { ...base, ...extra };
825
+ if (!config?.headers) return base;
826
+ return { ...base, ...config.headers };
630
827
  }
631
828
  async function verifyPayment(payload, requirements, config) {
632
829
  const url = resolveUrl(config);
@@ -726,112 +923,6 @@ function extractPayerAddress(payload) {
726
923
  }
727
924
  throw new Error("Unable to extract payer address from payload");
728
925
  }
729
-
730
- // src/types/networks.ts
731
- var isEvmAddress = (value) => /^0x[a-fA-F0-9]{40}$/.test(value);
732
- var tokenRegistry = /* @__PURE__ */ new Map();
733
- var tokenKey = (chainId, contractAddress) => `${chainId}:${contractAddress.toLowerCase()}`;
734
- var NETWORKS = {
735
- ethereum: {
736
- name: "Ethereum Mainnet",
737
- chainId: 1,
738
- usdcAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
739
- rpcUrl: "https://eth.llamarpc.com",
740
- caip2Id: "eip155:1",
741
- caipAssetId: "eip155:1/erc20:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
742
- },
743
- base: {
744
- name: "Base Mainnet",
745
- chainId: 8453,
746
- usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
747
- rpcUrl: "https://mainnet.base.org",
748
- caip2Id: "eip155:8453",
749
- caipAssetId: "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
750
- },
751
- "base-sepolia": {
752
- name: "Base Sepolia",
753
- chainId: 84532,
754
- usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
755
- rpcUrl: "https://sepolia.base.org",
756
- caip2Id: "eip155:84532",
757
- caipAssetId: "eip155:84532/erc20:0x036CbD53842c5426634e7929541eC2318f3dCF7e"
758
- },
759
- "skale-base": {
760
- name: "SKALE Base",
761
- chainId: 1187947933,
762
- usdcAddress: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",
763
- rpcUrl: "https://skale-base.skalenodes.com/v1/base",
764
- caip2Id: "eip155:1187947933",
765
- caipAssetId: "eip155:1187947933/erc20:0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20"
766
- },
767
- "skale-base-sepolia": {
768
- name: "SKALE Base Sepolia",
769
- chainId: 324705682,
770
- usdcAddress: "0x2e08028E3C4c2356572E096d8EF835cD5C6030bD",
771
- rpcUrl: "https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha",
772
- caip2Id: "eip155:324705682",
773
- caipAssetId: "eip155:324705682/erc20:0x2e08028E3C4c2356572E096d8EF835cD5C6030bD"
774
- },
775
- "ethereum-sepolia": {
776
- name: "Ethereum Sepolia",
777
- chainId: 11155111,
778
- usdcAddress: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
779
- rpcUrl: "https://rpc.sepolia.org",
780
- caip2Id: "eip155:11155111",
781
- caipAssetId: "eip155:11155111/erc20:0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
782
- }
783
- };
784
- var getNetworkConfig = (name) => NETWORKS[name];
785
- var getNetworkByChainId = (chainId) => Object.values(NETWORKS).find((c) => c.chainId === chainId);
786
- var getMainnets = () => Object.values(NETWORKS).filter(
787
- (c) => !c.name.toLowerCase().includes("sepolia")
788
- );
789
- var getTestnets = () => Object.values(NETWORKS).filter(
790
- (c) => c.name.toLowerCase().includes("sepolia")
791
- );
792
- var registerToken = (token) => {
793
- if (typeof token !== "object" || token === null) {
794
- throw new Error("Invalid token: must be an object");
795
- }
796
- const t = token;
797
- if (typeof t.symbol !== "string") {
798
- throw new Error("Invalid token: symbol must be a string");
799
- }
800
- if (typeof t.name !== "string") {
801
- throw new Error("Invalid token: name must be a string");
802
- }
803
- if (typeof t.version !== "string") {
804
- throw new Error("Invalid token: version must be a string");
805
- }
806
- if (typeof t.contractAddress !== "string" || !isEvmAddress(t.contractAddress)) {
807
- throw new Error(
808
- "Invalid token: contractAddress must be a valid EVM address"
809
- );
810
- }
811
- if (typeof t.chainId !== "number" || !Number.isInteger(t.chainId) || t.chainId <= 0) {
812
- throw new Error("Invalid token: chainId must be a positive integer");
813
- }
814
- if (t.decimals !== void 0 && (typeof t.decimals !== "number" || !Number.isInteger(t.decimals) || t.decimals < 0)) {
815
- throw new Error("Invalid token: decimals must be a non-negative integer");
816
- }
817
- const validated = {
818
- symbol: t.symbol,
819
- name: t.name,
820
- version: t.version,
821
- contractAddress: t.contractAddress,
822
- chainId: t.chainId,
823
- decimals: t.decimals
824
- };
825
- tokenRegistry.set(
826
- tokenKey(validated.chainId, validated.contractAddress),
827
- validated
828
- );
829
- return validated;
830
- };
831
- var getCustomToken = (chainId, contractAddress) => tokenRegistry.get(tokenKey(chainId, contractAddress));
832
- var getAllCustomTokens = () => Array.from(tokenRegistry.values());
833
- var unregisterToken = (chainId, contractAddress) => tokenRegistry.delete(tokenKey(chainId, contractAddress));
834
- var isCustomToken = (chainId, contractAddress) => tokenRegistry.has(tokenKey(chainId, contractAddress));
835
926
  function createNonce() {
836
927
  const bytes = randomBytes(32);
837
928
  return `0x${bytes.toString("hex")}`;
@@ -1933,4 +2024,4 @@ function validateRouteConfig(config) {
1933
2024
  return null;
1934
2025
  }
1935
2026
 
1936
- export { EIP712_TYPES, ERC20_ABI, EURC_BASE, NETWORKS, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PAYMENT_SIGNATURE_HEADER, PaymentException, SCHEMES, SKL_SKALE_BASE, SKL_SKALE_BASE_SEPOLIA, SigningError, TOKENS, USDC_BASE, USDC_BASE_SEPOLIA, USDC_DOMAIN, USDC_SKALE_BASE, USDC_SKALE_BASE_SEPOLIA, USDT_SKALE_BASE, USDT_SKALE_BASE_SEPOLIA, V2_HEADERS, WBTC_SKALE_BASE, WBTC_SKALE_BASE_SEPOLIA, WETH_SKALE_BASE, WETH_SKALE_BASE_SEPOLIA, X402ClientError, X402_VERSION, addressToAssetId, assetIdToAddress, caip2ToNetwork, calculateValidBefore, checkFacilitatorSupport, clearFacilitatorCapabilityCache, combineSignature as combineSignatureV2, createEIP712Domain, createError, createNonce, createPaymentRequiredHeaders, createPaymentRequirements, createSettlementHeaders, createTransferWithAuthorization, decodeBase64ToUtf8, decodePayloadHeader, decodePayment, decodePaymentV2, decodeSettlementResponse, decodeSettlementV2, decodeX402Response, detectPaymentVersion, detectX402Version, encodePayment, encodePaymentV2, encodeSettlementResponse, encodeSettlementV2, encodeUtf8ToBase64, encodeX402Response, enrichPaymentRequirement, enrichPaymentRequirements, extractPayerAddress, extractPaymentFromHeaders, filterExtensionsForFacilitator, filterExtensionsForFacilitators, filterExtensionsForRequirements, findMatchingRoute, findRequirementByAccepted, findRequirementByNetwork, fromAtomicUnits, generateNonce, getAllCustomTokens, getAllTokens, getAvailableNetworks, getAvailableTokens, getCurrentTimestamp, getCustomToken, getEURCTokens, getMainnets, getNetworkByChainId, getNetworkConfig, getPaymentHeaderName, getSKLTokens, getSupported, getTestnets, getToken, getTokensByChain, getTokensBySymbol, getTxHash, getUSDCTokens, getUSDTTokens, getWBTCTokens, getWETHTokens, isAddress2 as isAddress, isCAIP2ChainId, isCAIPAssetId, isCustomToken, isExactEvmPayload, isPaymentPayload, isPaymentPayloadV2, isPaymentRequiredV2, isPaymentV2, isResolvedNetwork, isResolvedToken, isSettlementSuccessful, isSettlementV2, isValidAddress, isValidationError, isX402V2Payload, isX402V2PaymentRequired, isX402V2Requirements, isX402V2Settlement, matchRoute, networkToCaip2, normalizeAddress, normalizeBase64Url, normalizeNetworkName, parseJsonOrBase64, parseRoutePattern, parseSignature as parseSignatureV2, registerToken, resolveFacilitator, resolveFacilitatorUrlFromRequirement, resolveNetwork, resolveToken, runAfterPaymentResponseHooks, runBeforeSignPaymentHooks, runOnPaymentRequiredHooks, safeBase64Decode2 as safeBase64Decode, safeBase64Encode2 as safeBase64Encode, selectRequirementWithHooks, settlePayment, toAtomicUnits, toBase64Url, unregisterToken, validateAcceptConfig, validatePaymentConfig, validateRouteConfig, validateTransferWithAuthorization, verifyPayment };
2027
+ export { EIP712_TYPES, ERC20_ABI, EURC_BASE, NETWORKS, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PAYMENT_SIGNATURE_HEADER, PaymentException, SCHEMES, SKL_SKALE_BASE_SEPOLIA, SigningError, TOKENS, USDC_BASE, USDC_BASE_SEPOLIA, USDC_SKALE_BASE, USDC_SKALE_BASE_SEPOLIA, USDT_SKALE_BASE, USDT_SKALE_BASE_SEPOLIA, V2_HEADERS, WBTC_SKALE_BASE, WBTC_SKALE_BASE_SEPOLIA, WETH_SKALE_BASE, WETH_SKALE_BASE_SEPOLIA, X402ClientError, X402_VERSION, addressToAssetId, assetIdToAddress, caip2ToNetwork, calculateValidBefore, checkFacilitatorSupport, clearFacilitatorCapabilityCache, combineSignature as combineSignatureV2, createEIP712Domain, createError, createNonce, createPaymentRequiredHeaders, createPaymentRequirements, createSettlementHeaders, createTransferWithAuthorization, decodeBase64ToUtf8, decodePayloadHeader, decodePayment, decodePaymentV2, decodeSettlementResponse, decodeSettlementV2, decodeX402Response, detectPaymentVersion, detectX402Version, encodePayment, encodePaymentV2, encodeSettlementResponse, encodeSettlementV2, encodeUtf8ToBase64, encodeX402Response, enrichPaymentRequirement, enrichPaymentRequirements, extractPayerAddress, extractPaymentFromHeaders, filterExtensionsForFacilitator, filterExtensionsForFacilitators, filterExtensionsForRequirements, findMatchingRoute, findRequirementByAccepted, findRequirementByNetwork, fromAtomicUnits, generateNonce, getAllCustomTokens, getAllTokens, getAvailableNetworks, getAvailableTokens, getCurrentTimestamp, getCustomToken, getEURCTokens, getMainnets, getNetworkByChainId, getNetworkConfig, getPaymentHeaderName, getSKLTokens, getSupported, getTestnets, getToken, getTokensByChain, getTokensBySymbol, getTxHash, getUSDCTokens, getUSDTTokens, getWBTCTokens, getWETHTokens, isAddress2 as isAddress, isCAIP2ChainId, isCAIPAssetId, isCustomToken, isExactEvmPayload, isPaymentPayload, isPaymentPayloadV2, isPaymentRequiredV2, isPaymentV2, isResolvedNetwork, isResolvedToken, isSettlementSuccessful, isSettlementV2, isValidAddress, isValidationError, isX402V2Payload, isX402V2PaymentRequired, isX402V2Requirements, isX402V2Settlement, matchRoute, networkToCaip2, normalizeAddress, normalizeBase64Url, normalizeNetworkName, parseJsonOrBase64, parseRoutePattern, parseSignature as parseSignatureV2, registerToken, resolveFacilitator, resolveFacilitatorUrlFromRequirement, resolveNetwork, resolveToken, runAfterPaymentResponseHooks, runBeforeSignPaymentHooks, runOnPaymentRequiredHooks, safeBase64Decode2 as safeBase64Decode, safeBase64Encode2 as safeBase64Encode, selectRequirementWithHooks, settlePayment, toAtomicUnits, toBase64Url, unregisterToken, validateAcceptConfig, validatePaymentConfig, validateRouteConfig, validateTransferWithAuthorization, verifyPayment };
@@ -1,7 +1,7 @@
1
1
  import type { PaymentPayload, PaymentRequirements, SettlementResponse, VerifyResponse } from "./types/x402";
2
2
  export interface FacilitatorClientConfig {
3
3
  url: string;
4
- createHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
4
+ headers?: Record<string, string>;
5
5
  }
6
6
  export declare function verifyPayment(payload: PaymentPayload, requirements: PaymentRequirements, config?: FacilitatorClientConfig): Promise<VerifyResponse>;
7
7
  export declare function settlePayment(payload: PaymentPayload, requirements: PaymentRequirements, config?: FacilitatorClientConfig): Promise<SettlementResponse>;
@@ -25,7 +25,7 @@ export interface FacilitatorConfig {
25
25
  /** Facilitator URL for verification/settlement */
26
26
  url: string;
27
27
  /** Optional authentication headers */
28
- headers?: () => Record<string, string>;
28
+ headers?: Record<string, string>;
29
29
  /** Networks this facilitator supports (auto-detected if not provided) */
30
30
  networks?: NetworkId[];
31
31
  /** Tokens this facilitator supports (optional) */
@@ -50,9 +50,9 @@ export interface FacilitatorSettleResult {
50
50
  error?: string;
51
51
  }
52
52
  /**
53
- * Settlement mode - verify only, settle only, or both
53
+ * Settlement mode - verify only or settle
54
54
  */
55
- export type SettlementMode = "verify" | "settle" | "async";
55
+ export type SettlementMode = "verify" | "settle";
56
56
  /**
57
57
  * CAIP-2 chain ID type (e.g., eip155:8453)
58
58
  */
@@ -13,7 +13,7 @@ export type PaymentRequired = PaymentRequiredV2;
13
13
  */
14
14
  export interface FacilitatorConfig {
15
15
  url: string;
16
- createHeaders?: () => Record<string, string>;
16
+ headers?: Record<string, string>;
17
17
  }
18
18
  /**
19
19
  * Result from facilitator verification
@@ -34,9 +34,9 @@ export interface FacilitatorSettleResult {
34
34
  error?: string;
35
35
  }
36
36
  /**
37
- * Settlement mode - verify only, settle only, or both
37
+ * Settlement mode - verify only or settle
38
38
  */
39
- export type SettlementMode = "verify" | "settle" | "async";
39
+ export type SettlementMode = "verify" | "settle";
40
40
  /**
41
41
  * Payment destination - address, CAIP-2 chain ID, or CAIP asset ID
42
42
  */
@@ -100,7 +100,8 @@ export interface X402Response {
100
100
  x402Version: X402Version;
101
101
  error?: string;
102
102
  accepts?: PaymentRequirements[];
103
- payer?: Address;
103
+ resource?: ResourceInfo;
104
+ extensions?: Record<string, unknown>;
104
105
  }
105
106
  /**
106
107
  * Type guards
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armory-sh/base",
3
- "version": "0.2.33",
3
+ "version": "0.2.34-alpha.25.97",
4
4
  "license": "MIT",
5
5
  "author": "Sawyer Cutler <sawyer@dirtroad.dev>",
6
6
  "keywords": [
@@ -40,16 +40,6 @@ export const USDC_SKALE_BASE: CustomToken = {
40
40
  decimals: 6,
41
41
  };
42
42
 
43
- export const SKL_SKALE_BASE: CustomToken = {
44
- symbol: "SKL",
45
- name: "SKALE",
46
- version: "1",
47
- contractAddress:
48
- "0xE0595a049d02b7674572b0d59cd4880Db60EDC50" as `0x${string}`,
49
- chainId: 1187947933,
50
- decimals: 18,
51
- };
52
-
53
43
  export const USDT_SKALE_BASE: CustomToken = {
54
44
  symbol: "USDT",
55
45
  name: "Tether USD",
@@ -138,7 +128,6 @@ export const TOKENS = {
138
128
  USDT_SKALE_BASE,
139
129
  WBTC_SKALE_BASE,
140
130
  WETH_SKALE_BASE,
141
- SKL_SKALE_BASE,
142
131
  SKL_SKALE_BASE_SEPOLIA,
143
132
  USDC_SKALE_BASE_SEPOLIA,
144
133
  USDT_SKALE_BASE_SEPOLIA,
package/src/eip712.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import type { CustomToken } from "./types/networks";
2
+ import { getCustomToken } from "./types/networks";
3
+
1
4
  export type TypedDataDomain = {
2
5
  name?: string;
3
6
  version?: string;
@@ -42,20 +45,26 @@ export const EIP712_TYPES = {
42
45
  ] as const,
43
46
  } as const satisfies EIP712Types;
44
47
 
45
- export const USDC_DOMAIN = {
46
- NAME: "USD Coin",
47
- VERSION: "2",
48
- } as const;
49
-
50
48
  export const createEIP712Domain = (
51
49
  chainId: number,
52
50
  contractAddress: `0x${string}`,
53
- ): EIP712Domain => ({
54
- name: USDC_DOMAIN.NAME,
55
- version: USDC_DOMAIN.VERSION,
56
- chainId,
57
- verifyingContract: contractAddress,
58
- });
51
+ ): EIP712Domain => {
52
+ const token = getCustomToken(chainId, contractAddress);
53
+
54
+ if (!token) {
55
+ throw new Error(
56
+ `Token not found in registry: chainId=${chainId}, contractAddress=${contractAddress}. ` +
57
+ `Please register the token using registerToken() before use.`
58
+ );
59
+ }
60
+
61
+ return {
62
+ name: token.name,
63
+ version: token.version,
64
+ chainId,
65
+ verifyingContract: contractAddress,
66
+ };
67
+ };
59
68
 
60
69
  export const createTransferWithAuthorization = (
61
70
  params: Omit<
package/src/index.ts CHANGED
@@ -33,7 +33,6 @@ export {
33
33
  getUSDTTokens,
34
34
  getWBTCTokens,
35
35
  getWETHTokens,
36
- SKL_SKALE_BASE,
37
36
  SKL_SKALE_BASE_SEPOLIA,
38
37
  TOKENS,
39
38
  USDC_BASE,
@@ -61,7 +60,6 @@ export {
61
60
  createEIP712Domain,
62
61
  createTransferWithAuthorization,
63
62
  EIP712_TYPES,
64
- USDC_DOMAIN,
65
63
  validateTransferWithAuthorization,
66
64
  } from "./eip712";
67
65
  // ============================================
@@ -9,9 +9,7 @@ import { decodeBase64ToUtf8 } from "./utils/base64";
9
9
 
10
10
  export interface FacilitatorClientConfig {
11
11
  url: string;
12
- createHeaders?: () =>
13
- | Record<string, string>
14
- | Promise<Record<string, string>>;
12
+ headers?: Record<string, string>;
15
13
  }
16
14
 
17
15
  const DEFAULT_FACILITATOR_URL = "https://facilitator.payai.network";
@@ -38,13 +36,12 @@ function resolveUrl(config?: FacilitatorClientConfig): string {
38
36
  return config?.url ?? DEFAULT_FACILITATOR_URL;
39
37
  }
40
38
 
41
- async function resolveHeaders(
39
+ function resolveHeaders(
42
40
  config?: FacilitatorClientConfig,
43
- ): Promise<Record<string, string>> {
41
+ ): Record<string, string> {
44
42
  const base: Record<string, string> = { "Content-Type": "application/json" };
45
- if (!config?.createHeaders) return base;
46
- const extra = await config.createHeaders();
47
- return { ...base, ...extra };
43
+ if (!config?.headers) return base;
44
+ return { ...base, ...config.headers };
48
45
  }
49
46
 
50
47
  export async function verifyPayment(
package/src/types/api.ts CHANGED
@@ -33,7 +33,7 @@ export interface FacilitatorConfig {
33
33
  /** Facilitator URL for verification/settlement */
34
34
  url: string;
35
35
  /** Optional authentication headers */
36
- headers?: () => Record<string, string>;
36
+ headers?: Record<string, string>;
37
37
  /** Networks this facilitator supports (auto-detected if not provided) */
38
38
  networks?: NetworkId[];
39
39
  /** Tokens this facilitator supports (optional) */
@@ -61,9 +61,9 @@ export interface FacilitatorSettleResult {
61
61
  }
62
62
 
63
63
  /**
64
- * Settlement mode - verify only, settle only, or both
64
+ * Settlement mode - verify only or settle
65
65
  */
66
- export type SettlementMode = "verify" | "settle" | "async";
66
+ export type SettlementMode = "verify" | "settle";
67
67
 
68
68
  /**
69
69
  * CAIP-2 chain ID type (e.g., eip155:8453)
@@ -19,10 +19,109 @@ export interface CustomToken {
19
19
  decimals?: number;
20
20
  }
21
21
 
22
- const tokenRegistry = new Map<string, CustomToken>();
23
22
  const tokenKey = (chainId: number, contractAddress: string): string =>
24
23
  `${chainId}:${contractAddress.toLowerCase()}`;
25
24
 
25
+ // Built-in tokens - hardcoded in registry
26
+ const tokenRegistry = new Map<string, CustomToken>([
27
+ [tokenKey(8453, "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"), {
28
+ symbol: "USDC",
29
+ name: "USDC",
30
+ version: "2",
31
+ contractAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" as `0x${string}`,
32
+ chainId: 8453,
33
+ decimals: 6,
34
+ }],
35
+ [tokenKey(84532, "0x036CbD53842c5426634e7929541eC2318f3dCF7e"), {
36
+ symbol: "USDC",
37
+ name: "USDC",
38
+ version: "2",
39
+ contractAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e" as `0x${string}`,
40
+ chainId: 84532,
41
+ decimals: 6,
42
+ }],
43
+ [tokenKey(8453, "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42"), {
44
+ symbol: "EURC",
45
+ name: "EURC",
46
+ version: "2",
47
+ contractAddress: "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42" as `0x${string}`,
48
+ chainId: 8453,
49
+ decimals: 6,
50
+ }],
51
+ [tokenKey(1187947933, "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20"), {
52
+ symbol: "USDC",
53
+ name: "USDC",
54
+ version: "2",
55
+ contractAddress: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20" as `0x${string}`,
56
+ chainId: 1187947933,
57
+ decimals: 6,
58
+ }],
59
+ [tokenKey(1187947933, "0x2bF5bF154b515EaA82C31a65ec11554fF5aF7fCA"), {
60
+ symbol: "USDT",
61
+ name: "USDT",
62
+ version: "1",
63
+ contractAddress: "0x2bF5bF154b515EaA82C31a65ec11554fF5aF7fCA" as `0x${string}`,
64
+ chainId: 1187947933,
65
+ decimals: 6,
66
+ }],
67
+ [tokenKey(1187947933, "0x1aeeCFE5454c83B42D8A316246CAc9739E7f690e"), {
68
+ symbol: "WBTC",
69
+ name: "Wrapped BTC",
70
+ version: "1",
71
+ contractAddress: "0x1aeeCFE5454c83B42D8A316246CAc9739E7f690e" as `0x${string}`,
72
+ chainId: 1187947933,
73
+ decimals: 8,
74
+ }],
75
+ [tokenKey(1187947933, "0x7bD39ABBd0Dd13103542cAe3276C7fA332bCA486"), {
76
+ symbol: "WETH",
77
+ name: "Wrapped Ether",
78
+ version: "1",
79
+ contractAddress: "0x7bD39ABBd0Dd13103542cAe3276C7fA332bCA486" as `0x${string}`,
80
+ chainId: 1187947933,
81
+ decimals: 6,
82
+ }],
83
+ [tokenKey(324705682, "0xaf2e0ff5b5f51553fdb34ce7f04a6c3201cee57b"), {
84
+ symbol: "SKL",
85
+ name: "SKALE",
86
+ version: "1",
87
+ contractAddress: "0xaf2e0ff5b5f51553fdb34ce7f04a6c3201cee57b" as `0x${string}`,
88
+ chainId: 324705682,
89
+ decimals: 18,
90
+ }],
91
+ [tokenKey(324705682, "0x036CbD53842c5426634e7929541eC2318f3dCF7e"), {
92
+ symbol: "USDC",
93
+ name: "USDC",
94
+ version: "2",
95
+ contractAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e" as `0x${string}`,
96
+ chainId: 324705682,
97
+ decimals: 6,
98
+ }],
99
+ [tokenKey(324705682, "0x3ca0a49f511c2c89c4dcbbf1731120d8919050bf"), {
100
+ symbol: "USDT",
101
+ name: "USDT",
102
+ version: "1",
103
+ contractAddress: "0x3ca0a49f511c2c89c4dcbbf1731120d8919050bf" as `0x${string}`,
104
+ chainId: 324705682,
105
+ decimals: 6,
106
+ }],
107
+ [tokenKey(324705682, "0x4512eacd4186b025186e1cf6cc0d89497c530e87"), {
108
+ symbol: "WBTC",
109
+ name: "Wrapped BTC",
110
+ version: "1",
111
+ contractAddress: "0x4512eacd4186b025186e1cf6cc0d89497c530e87" as `0x${string}`,
112
+ chainId: 324705682,
113
+ decimals: 8,
114
+ }],
115
+ [tokenKey(324705682, "0xf94056bd7f6965db3757e1b145f200b7346b4fc0"), {
116
+ symbol: "WETH",
117
+ name: "Wrapped Ether",
118
+ version: "1",
119
+ contractAddress: "0xf94056bd7f6965db3757e1b145f200b7346b4fc0" as `0x${string}`,
120
+ chainId: 324705682,
121
+ decimals: 18,
122
+ }],
123
+ ]);
124
+
26
125
  export const NETWORKS: Record<string, NetworkConfig> = {
27
126
  ethereum: {
28
127
  name: "Ethereum Mainnet",
@@ -30,7 +30,7 @@ export type PaymentRequired = PaymentRequiredV2;
30
30
  */
31
31
  export interface FacilitatorConfig {
32
32
  url: string;
33
- createHeaders?: () => Record<string, string>;
33
+ headers?: Record<string, string>;
34
34
  }
35
35
 
36
36
  /**
@@ -54,9 +54,9 @@ export interface FacilitatorSettleResult {
54
54
  }
55
55
 
56
56
  /**
57
- * Settlement mode - verify only, settle only, or both
57
+ * Settlement mode - verify only or settle
58
58
  */
59
- export type SettlementMode = "verify" | "settle" | "async";
59
+ export type SettlementMode = "verify" | "settle";
60
60
 
61
61
  /**
62
62
  * Payment destination - address, CAIP-2 chain ID, or CAIP asset ID
package/src/types/x402.ts CHANGED
@@ -125,7 +125,8 @@ export interface X402Response {
125
125
  x402Version: X402Version;
126
126
  error?: string;
127
127
  accepts?: PaymentRequirements[];
128
- payer?: Address;
128
+ resource?: ResourceInfo;
129
+ extensions?: Record<string, unknown>;
129
130
  }
130
131
 
131
132
  /**