agent402-client 0.8.24 → 0.8.25

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/index.js CHANGED
@@ -32,7 +32,7 @@ export { AsyncJobPendingError } from "./async-job.js";
32
32
  // `User-Agent: agent402-client/<version>` - a standard header, no extra
33
33
  // network calls - so a seller can attribute traffic (and settled payments)
34
34
  // to this SDK. Product token only; nothing about the caller rides along.
35
- const VERSION = "0.8.24";
35
+ const VERSION = "0.8.25";
36
36
  const USER_AGENT = `agent402-client/${VERSION}`;
37
37
  // A package built on this SDK (an adapter) names itself first: its own
38
38
  // product token, then this one. Anything that is not one well-formed token
@@ -1365,6 +1365,7 @@ export const NETWORK_CAIP2 = {
1365
1365
  "base-sepolia": "eip155:84532",
1366
1366
  robinhood: "eip155:4663",
1367
1367
  arc: "eip155:5042",
1368
+ ink: "eip155:57073",
1368
1369
  monad: "eip155:143",
1369
1370
  celo: "eip155:42220",
1370
1371
  avalanche: "eip155:43114",
package/known-assets.js CHANGED
@@ -12,6 +12,12 @@
12
12
  // and a buyer with a cap does not sign it. The table is keyed by CAIP-2 ids
13
13
  // only: a bare v1 network name (for example "base") is not priced.
14
14
  //
15
+ // An entry may also name its token's EIP-712 domain (`name` and `version`,
16
+ // read from the token's own name() and version()). An EVM "exact" signer
17
+ // signs under the domain the accept's `extra` carries, so for such an entry
18
+ // an accept whose `extra.name` or `extra.version` is not exactly the token's
19
+ // cannot be priced either, and a buyer with a cap does not sign it.
20
+ //
15
21
  // The same file ships in agent402-client, agent402-mcp and agent402-openclaw;
16
22
  // the parent repo's scripts/test-known-assets.js keeps the copies identical and
17
23
  // checks the table against the assets the server offers.
@@ -29,6 +35,7 @@ export const KNOWN_ASSETS = Object.freeze({
29
35
  "eip155:1329": [{ asset: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392", decimals: 6, symbol: "USDC" }], // Sei
30
36
  "eip155:10": [{ asset: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", decimals: 6, symbol: "USDC" }], // Optimism
31
37
  "eip155:5042": [{ asset: "0x3600000000000000000000000000000000000000", decimals: 6, symbol: "USDC" }], // Arc
38
+ "eip155:57073": [{ asset: "0x2D270e6886d130D724215A266106e6832161EAEd", decimals: 6, symbol: "USDC", name: "USDC", version: "2" }], // Ink
32
39
  "eip155:4663": [{ asset: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168", decimals: 6, symbol: "USDG" }], // Robinhood Chain
33
40
  // Solana: the USDC mint.
34
41
  "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": [{ asset: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", decimals: 6, symbol: "USDC" }],
@@ -56,6 +63,7 @@ export const NETWORK_NAMES = Object.freeze({
56
63
  sei: ["eip155:1329"],
57
64
  optimism: ["eip155:10"],
58
65
  arc: ["eip155:5042"],
66
+ ink: ["eip155:57073"],
59
67
  robinhood: ["eip155:4663"],
60
68
  solana: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
61
69
  "solana-devnet": ["solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"],
@@ -88,6 +96,15 @@ export function knownAsset(network, asset) {
88
96
  return list.find((e) => sameAsset(e.asset, asset)) || null;
89
97
  }
90
98
 
99
+ /** True when the accept carries the EIP-712 domain the table names for its
100
+ * asset (`extra.name` and `extra.version`, exactly), or when the entry names
101
+ * none. */
102
+ export function acceptDomainMatches(entry, accept) {
103
+ if (!entry || (entry.name == null && entry.version == null)) return true;
104
+ const extra = accept && typeof accept.extra === "object" && accept.extra ? accept.extra : {};
105
+ return extra.name === entry.name && extra.version === entry.version;
106
+ }
107
+
91
108
  /** The base-unit amount the signer of `x402Version` signs for one accept, as
92
109
  * a string of digits: `maxAmountRequired` under v1, `amount` under v2. With
93
110
  * no version, the one field present (or both, when they agree). null when
@@ -111,12 +128,13 @@ export function acceptAmount(accept, x402Version = undefined) {
111
128
 
112
129
  /** The USD value of one accept: the base-unit amount its version's signer
113
130
  * signs (acceptAmount) over the KNOWN decimals of its asset. null when the
114
- * asset is not known or the amount cannot be read. */
131
+ * asset is not known, when the accept names a different EIP-712 domain than
132
+ * the table's for that asset, or when the amount cannot be read. */
115
133
  export function acceptUsd(accept, x402Version = undefined) {
116
134
  const raw = acceptAmount(accept, x402Version);
117
135
  if (raw == null) return null;
118
136
  const entry = knownAsset(accept.network, accept.asset);
119
- if (!entry) return null;
137
+ if (!entry || !acceptDomainMatches(entry, accept)) return null;
120
138
  return Number(raw) / 10 ** entry.decimals;
121
139
  }
122
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent402-client",
3
- "version": "0.8.24",
3
+ "version": "0.8.25",
4
4
  "description": "Agent402 buyer SDK: resolve a task to a tool across 500+ pay-per-call endpoints and call it with payment handled - free via proof-of-work, or over x402 or MPP (a stock mppx fetch works) with a wallet you keep; the buy side of Agentic Finance. Caching, idempotent retries (Idempotency-Key), non-custodial, zero dependencies.",
5
5
  "type": "module",
6
6
  "main": "index.js",