@armory-sh/base 0.2.30 → 0.2.32
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +67 -3
- package/dist/payment-requirements.d.ts +3 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/payment-requirements.ts +107 -2
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type { FacilitatorClientConfig, SupportedKind, SupportedResponse, } from
|
|
|
12
12
|
export { decodePayloadHeader, extractPayerAddress, getSupported, settlePayment, verifyPayment, } from "./payment-client";
|
|
13
13
|
export { clearFacilitatorCapabilityCache, filterExtensionsForFacilitator, filterExtensionsForFacilitators, filterExtensionsForRequirements, } from "./facilitator-capabilities";
|
|
14
14
|
export type { PaymentConfig, ResolvedRequirementsConfig, } from "./payment-requirements";
|
|
15
|
-
export { createPaymentRequirements, findRequirementByAccepted, findRequirementByNetwork, resolveFacilitatorUrlFromRequirement, } from "./payment-requirements";
|
|
15
|
+
export { createPaymentRequirements, enrichPaymentRequirement, enrichPaymentRequirements, findRequirementByAccepted, findRequirementByNetwork, resolveFacilitatorUrlFromRequirement, } from "./payment-requirements";
|
|
16
16
|
export { calculateValidBefore, detectX402Version, generateNonce, getPaymentHeaderName, parseJsonOrBase64, } from "./protocol";
|
|
17
17
|
export type { AcceptPaymentOptions, ArmoryPaymentResult, FacilitatorConfig, FacilitatorSettleResult, FacilitatorVerifyResult, NetworkId, PaymentError, PaymentErrorCode, PaymentResult, PayToAddress, PricingConfig, ResolvedFacilitator, ResolvedNetwork, ResolvedPaymentConfig, ResolvedToken, SettlementMode, TokenId, ValidationError, } from "./types/api";
|
|
18
18
|
export type { BeforePaymentHook, ClientHook, ClientHookErrorContext, ExtensionHook, HookConfig, HookRegistry, HookResult, OnPaymentRequiredHook, PaymentPayloadContext, PaymentRequiredContext, } from "./types/hooks";
|
package/dist/index.js
CHANGED
|
@@ -1368,6 +1368,24 @@ var isResolvedToken = (value) => {
|
|
|
1368
1368
|
};
|
|
1369
1369
|
|
|
1370
1370
|
// src/payment-requirements.ts
|
|
1371
|
+
function resolveAmountForNetwork(config, network) {
|
|
1372
|
+
const defaultAmount = config.amount ?? "1.0";
|
|
1373
|
+
if (!config.amounts) {
|
|
1374
|
+
return defaultAmount;
|
|
1375
|
+
}
|
|
1376
|
+
const explicitDefault = config.amounts.default;
|
|
1377
|
+
const fallbackAmount = explicitDefault ?? defaultAmount;
|
|
1378
|
+
for (const [networkKey, amount] of Object.entries(config.amounts)) {
|
|
1379
|
+
if (networkKey === "default") {
|
|
1380
|
+
continue;
|
|
1381
|
+
}
|
|
1382
|
+
const resolvedNetwork = resolveNetwork(networkKey);
|
|
1383
|
+
if (!isValidationError2(resolvedNetwork) && resolvedNetwork.config.chainId === network.config.chainId) {
|
|
1384
|
+
return amount;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
return fallbackAmount;
|
|
1388
|
+
}
|
|
1371
1389
|
var DEFAULT_NETWORKS = [
|
|
1372
1390
|
"ethereum",
|
|
1373
1391
|
"base",
|
|
@@ -1380,6 +1398,50 @@ var DEFAULT_TOKENS = ["usdc"];
|
|
|
1380
1398
|
var isValidationError2 = (value) => {
|
|
1381
1399
|
return typeof value === "object" && value !== null && "code" in value;
|
|
1382
1400
|
};
|
|
1401
|
+
var coerceMetadata = (requirement) => {
|
|
1402
|
+
if (typeof requirement.name === "string" && typeof requirement.version === "string") {
|
|
1403
|
+
return { name: requirement.name, version: requirement.version };
|
|
1404
|
+
}
|
|
1405
|
+
const extraName = requirement.extra && typeof requirement.extra === "object" && typeof requirement.extra.name === "string" ? requirement.extra.name : void 0;
|
|
1406
|
+
const extraVersion = requirement.extra && typeof requirement.extra === "object" && typeof requirement.extra.version === "string" ? requirement.extra.version : void 0;
|
|
1407
|
+
return { name: extraName, version: extraVersion };
|
|
1408
|
+
};
|
|
1409
|
+
var resolveTokenMetadata = (requirement) => {
|
|
1410
|
+
const chainId = parseInt(requirement.network.split(":")[1] || "0", 10);
|
|
1411
|
+
if (!Number.isFinite(chainId) || chainId <= 0) {
|
|
1412
|
+
return {};
|
|
1413
|
+
}
|
|
1414
|
+
const token = getToken(chainId, requirement.asset);
|
|
1415
|
+
if (!token) {
|
|
1416
|
+
return {};
|
|
1417
|
+
}
|
|
1418
|
+
return {
|
|
1419
|
+
name: token.name,
|
|
1420
|
+
version: token.version
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
function enrichPaymentRequirement(requirement) {
|
|
1424
|
+
const metadata = coerceMetadata(requirement);
|
|
1425
|
+
const fallback = resolveTokenMetadata(requirement);
|
|
1426
|
+
const name = metadata.name ?? fallback.name;
|
|
1427
|
+
const version = metadata.version ?? fallback.version;
|
|
1428
|
+
if (!name || !version) {
|
|
1429
|
+
return requirement;
|
|
1430
|
+
}
|
|
1431
|
+
return {
|
|
1432
|
+
...requirement,
|
|
1433
|
+
name,
|
|
1434
|
+
version,
|
|
1435
|
+
extra: {
|
|
1436
|
+
...requirement.extra ?? {},
|
|
1437
|
+
name,
|
|
1438
|
+
version
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
function enrichPaymentRequirements(requirements) {
|
|
1443
|
+
return requirements.map(enrichPaymentRequirement);
|
|
1444
|
+
}
|
|
1383
1445
|
function resolvePayTo(config, network, token) {
|
|
1384
1446
|
const chainId = network.config.chainId;
|
|
1385
1447
|
if (config.payToByToken) {
|
|
@@ -1495,7 +1557,6 @@ function createPaymentRequirements(config) {
|
|
|
1495
1557
|
chain,
|
|
1496
1558
|
tokens,
|
|
1497
1559
|
token,
|
|
1498
|
-
amount = "1.0",
|
|
1499
1560
|
maxTimeoutSeconds = 300
|
|
1500
1561
|
} = config;
|
|
1501
1562
|
const chainInputs = chain ? [chain] : chains;
|
|
@@ -1507,12 +1568,13 @@ function createPaymentRequirements(config) {
|
|
|
1507
1568
|
const requirements = [];
|
|
1508
1569
|
for (const network of networks) {
|
|
1509
1570
|
const tokensToResolve = tokenInputs?.length ? tokenInputs : DEFAULT_TOKENS;
|
|
1571
|
+
const resolvedAmount = resolveAmountForNetwork(config, network);
|
|
1572
|
+
const atomicAmount = toAtomicUnits(resolvedAmount);
|
|
1510
1573
|
for (const tokenId of tokensToResolve) {
|
|
1511
1574
|
const resolvedToken = resolveToken(tokenId, network);
|
|
1512
1575
|
if (isValidationError2(resolvedToken)) {
|
|
1513
1576
|
continue;
|
|
1514
1577
|
}
|
|
1515
|
-
const atomicAmount = toAtomicUnits(amount);
|
|
1516
1578
|
const tokenConfig = resolvedToken.config;
|
|
1517
1579
|
const resolvedPayTo = resolvePayTo(config, network, resolvedToken);
|
|
1518
1580
|
resolveFacilitatorUrl(
|
|
@@ -1527,6 +1589,8 @@ function createPaymentRequirements(config) {
|
|
|
1527
1589
|
asset: tokenConfig.contractAddress,
|
|
1528
1590
|
payTo: resolvedPayTo,
|
|
1529
1591
|
maxTimeoutSeconds,
|
|
1592
|
+
name: tokenConfig.name,
|
|
1593
|
+
version: tokenConfig.version,
|
|
1530
1594
|
extra: {
|
|
1531
1595
|
name: tokenConfig.name,
|
|
1532
1596
|
version: tokenConfig.version
|
|
@@ -1869,4 +1933,4 @@ function validateRouteConfig(config) {
|
|
|
1869
1933
|
return null;
|
|
1870
1934
|
}
|
|
1871
1935
|
|
|
1872
|
-
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, 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 };
|
|
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 };
|
|
@@ -7,6 +7,7 @@ export interface PaymentConfig {
|
|
|
7
7
|
tokens?: TokenId[];
|
|
8
8
|
token?: TokenId;
|
|
9
9
|
amount?: string;
|
|
10
|
+
amounts?: Record<string, string>;
|
|
10
11
|
maxTimeoutSeconds?: number;
|
|
11
12
|
payToByChain?: Record<string, Address | string>;
|
|
12
13
|
payToByToken?: Record<string, Record<string, Address | string>>;
|
|
@@ -23,6 +24,8 @@ export interface FacilitatorRoutingConfig {
|
|
|
23
24
|
facilitatorUrlByChain?: Record<string, string>;
|
|
24
25
|
facilitatorUrlByToken?: Record<string, Record<string, string>>;
|
|
25
26
|
}
|
|
27
|
+
export declare function enrichPaymentRequirement(requirement: PaymentRequirementsV2): PaymentRequirementsV2;
|
|
28
|
+
export declare function enrichPaymentRequirements(requirements: PaymentRequirementsV2[]): PaymentRequirementsV2[];
|
|
26
29
|
export declare function resolveFacilitatorUrlFromRequirement(config: FacilitatorRoutingConfig, requirement: Pick<PaymentRequirementsV2, "network" | "asset">): string | undefined;
|
|
27
30
|
export declare function createPaymentRequirements(config: PaymentConfig): ResolvedRequirementsConfig;
|
|
28
31
|
export declare function findRequirementByNetwork(requirements: PaymentRequirementsV2[], network: string): PaymentRequirementsV2 | undefined;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -128,6 +128,8 @@ export type {
|
|
|
128
128
|
} from "./payment-requirements";
|
|
129
129
|
export {
|
|
130
130
|
createPaymentRequirements,
|
|
131
|
+
enrichPaymentRequirement,
|
|
132
|
+
enrichPaymentRequirements,
|
|
131
133
|
findRequirementByAccepted,
|
|
132
134
|
findRequirementByNetwork,
|
|
133
135
|
resolveFacilitatorUrlFromRequirement,
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ValidationError,
|
|
7
7
|
} from "./types/api";
|
|
8
8
|
import { getNetworkConfig } from "./types/networks";
|
|
9
|
+
import { getToken } from "./data/tokens";
|
|
9
10
|
import type { Address, PaymentRequirementsV2 } from "./types/v2";
|
|
10
11
|
import { toAtomicUnits } from "./utils/x402";
|
|
11
12
|
import {
|
|
@@ -21,6 +22,7 @@ export interface PaymentConfig {
|
|
|
21
22
|
tokens?: TokenId[];
|
|
22
23
|
token?: TokenId;
|
|
23
24
|
amount?: string;
|
|
25
|
+
amounts?: Record<string, string>;
|
|
24
26
|
maxTimeoutSeconds?: number;
|
|
25
27
|
|
|
26
28
|
payToByChain?: Record<string, Address | string>;
|
|
@@ -31,6 +33,35 @@ export interface PaymentConfig {
|
|
|
31
33
|
facilitatorUrlByToken?: Record<string, Record<string, string>>;
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
function resolveAmountForNetwork(
|
|
37
|
+
config: PaymentConfig,
|
|
38
|
+
network: ResolvedNetwork,
|
|
39
|
+
): string {
|
|
40
|
+
const defaultAmount = config.amount ?? "1.0";
|
|
41
|
+
if (!config.amounts) {
|
|
42
|
+
return defaultAmount;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const explicitDefault = config.amounts.default;
|
|
46
|
+
const fallbackAmount = explicitDefault ?? defaultAmount;
|
|
47
|
+
|
|
48
|
+
for (const [networkKey, amount] of Object.entries(config.amounts)) {
|
|
49
|
+
if (networkKey === "default") {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const resolvedNetwork = resolveNetwork(networkKey);
|
|
54
|
+
if (
|
|
55
|
+
!isValidationError(resolvedNetwork) &&
|
|
56
|
+
resolvedNetwork.config.chainId === network.config.chainId
|
|
57
|
+
) {
|
|
58
|
+
return amount;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return fallbackAmount;
|
|
63
|
+
}
|
|
64
|
+
|
|
34
65
|
export interface ResolvedRequirementsConfig {
|
|
35
66
|
requirements: PaymentRequirementsV2[];
|
|
36
67
|
error?: ValidationError;
|
|
@@ -57,6 +88,78 @@ const isValidationError = (value: unknown): value is ValidationError => {
|
|
|
57
88
|
return typeof value === "object" && value !== null && "code" in value;
|
|
58
89
|
};
|
|
59
90
|
|
|
91
|
+
const coerceMetadata = (
|
|
92
|
+
requirement: PaymentRequirementsV2,
|
|
93
|
+
): { name?: string; version?: string } => {
|
|
94
|
+
if (typeof requirement.name === "string" && typeof requirement.version === "string") {
|
|
95
|
+
return { name: requirement.name, version: requirement.version };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const extraName =
|
|
99
|
+
requirement.extra &&
|
|
100
|
+
typeof requirement.extra === "object" &&
|
|
101
|
+
typeof requirement.extra.name === "string"
|
|
102
|
+
? requirement.extra.name
|
|
103
|
+
: undefined;
|
|
104
|
+
const extraVersion =
|
|
105
|
+
requirement.extra &&
|
|
106
|
+
typeof requirement.extra === "object" &&
|
|
107
|
+
typeof requirement.extra.version === "string"
|
|
108
|
+
? requirement.extra.version
|
|
109
|
+
: undefined;
|
|
110
|
+
|
|
111
|
+
return { name: extraName, version: extraVersion };
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const resolveTokenMetadata = (
|
|
115
|
+
requirement: PaymentRequirementsV2,
|
|
116
|
+
): { name?: string; version?: string } => {
|
|
117
|
+
const chainId = parseInt(requirement.network.split(":")[1] || "0", 10);
|
|
118
|
+
if (!Number.isFinite(chainId) || chainId <= 0) {
|
|
119
|
+
return {};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const token = getToken(chainId, requirement.asset);
|
|
123
|
+
if (!token) {
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
name: token.name,
|
|
129
|
+
version: token.version,
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export function enrichPaymentRequirement(
|
|
134
|
+
requirement: PaymentRequirementsV2,
|
|
135
|
+
): PaymentRequirementsV2 {
|
|
136
|
+
const metadata = coerceMetadata(requirement);
|
|
137
|
+
const fallback = resolveTokenMetadata(requirement);
|
|
138
|
+
const name = metadata.name ?? fallback.name;
|
|
139
|
+
const version = metadata.version ?? fallback.version;
|
|
140
|
+
|
|
141
|
+
if (!name || !version) {
|
|
142
|
+
return requirement;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
...requirement,
|
|
147
|
+
name,
|
|
148
|
+
version,
|
|
149
|
+
extra: {
|
|
150
|
+
...(requirement.extra ?? {}),
|
|
151
|
+
name,
|
|
152
|
+
version,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function enrichPaymentRequirements(
|
|
158
|
+
requirements: PaymentRequirementsV2[],
|
|
159
|
+
): PaymentRequirementsV2[] {
|
|
160
|
+
return requirements.map(enrichPaymentRequirement);
|
|
161
|
+
}
|
|
162
|
+
|
|
60
163
|
function resolvePayTo(
|
|
61
164
|
config: PaymentConfig,
|
|
62
165
|
network: ResolvedNetwork,
|
|
@@ -235,7 +338,6 @@ export function createPaymentRequirements(
|
|
|
235
338
|
chain,
|
|
236
339
|
tokens,
|
|
237
340
|
token,
|
|
238
|
-
amount = "1.0",
|
|
239
341
|
maxTimeoutSeconds = 300,
|
|
240
342
|
} = config;
|
|
241
343
|
|
|
@@ -251,6 +353,8 @@ export function createPaymentRequirements(
|
|
|
251
353
|
|
|
252
354
|
for (const network of networks) {
|
|
253
355
|
const tokensToResolve = tokenInputs?.length ? tokenInputs : DEFAULT_TOKENS;
|
|
356
|
+
const resolvedAmount = resolveAmountForNetwork(config, network);
|
|
357
|
+
const atomicAmount = toAtomicUnits(resolvedAmount);
|
|
254
358
|
|
|
255
359
|
for (const tokenId of tokensToResolve) {
|
|
256
360
|
const resolvedToken = resolveToken(tokenId, network);
|
|
@@ -258,7 +362,6 @@ export function createPaymentRequirements(
|
|
|
258
362
|
continue;
|
|
259
363
|
}
|
|
260
364
|
|
|
261
|
-
const atomicAmount = toAtomicUnits(amount);
|
|
262
365
|
const tokenConfig = resolvedToken.config;
|
|
263
366
|
|
|
264
367
|
const resolvedPayTo = resolvePayTo(config, network, resolvedToken);
|
|
@@ -275,6 +378,8 @@ export function createPaymentRequirements(
|
|
|
275
378
|
asset: tokenConfig.contractAddress,
|
|
276
379
|
payTo: resolvedPayTo as `0x${string}`,
|
|
277
380
|
maxTimeoutSeconds,
|
|
381
|
+
name: tokenConfig.name,
|
|
382
|
+
version: tokenConfig.version,
|
|
278
383
|
extra: {
|
|
279
384
|
name: tokenConfig.name,
|
|
280
385
|
version: tokenConfig.version,
|