@aifinpay/mcp 2.5.0 → 2.7.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.
- package/README.md +111 -20
- package/dist/config.d.ts +6 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +39 -4
- package/dist/config.js.map +1 -1
- package/dist/native-price.d.ts +1 -1
- package/dist/native-price.d.ts.map +1 -1
- package/dist/native-price.js +3 -3
- package/dist/native-price.js.map +1 -1
- package/dist/pay-chains.d.ts +5 -4
- package/dist/pay-chains.d.ts.map +1 -1
- package/dist/pay-chains.js +29 -28
- package/dist/pay-chains.js.map +1 -1
- package/dist/payment-identity.d.ts +17 -0
- package/dist/payment-identity.d.ts.map +1 -0
- package/dist/payment-identity.js +75 -0
- package/dist/payment-identity.js.map +1 -0
- package/dist/payment-state.d.ts +2 -1
- package/dist/payment-state.d.ts.map +1 -1
- package/dist/payment-state.js +52 -17
- package/dist/payment-state.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/agent-claim-self.d.ts +3 -3
- package/dist/tools/agent-claim-self.d.ts.map +1 -1
- package/dist/tools/agent-claim-self.js +65 -88
- package/dist/tools/agent-claim-self.js.map +1 -1
- package/dist/tools/agent-history.d.ts +0 -1
- package/dist/tools/agent-history.d.ts.map +1 -1
- package/dist/tools/agent-history.js +51 -52
- package/dist/tools/agent-history.js.map +1 -1
- package/dist/tools/agent-quota.d.ts.map +1 -1
- package/dist/tools/agent-quota.js +42 -11
- package/dist/tools/agent-quota.js.map +1 -1
- package/dist/tools/payable-fetch.d.ts.map +1 -1
- package/dist/tools/payable-fetch.js +156 -57
- package/dist/tools/payable-fetch.js.map +1 -1
- package/package.json +6 -6
- package/skills/SKILL.md +165 -43
- package/dist/directory.d.ts +0 -55
- package/dist/directory.d.ts.map +0 -1
- package/dist/directory.js +0 -56
- package/dist/directory.js.map +0 -1
- package/dist/tools/agent-call.d.ts +0 -68
- package/dist/tools/agent-call.d.ts.map +0 -1
- package/dist/tools/agent-call.js +0 -129
- package/dist/tools/agent-call.js.map +0 -1
- package/dist/tools/agent-quote.d.ts +0 -41
- package/dist/tools/agent-quote.d.ts.map +0 -1
- package/dist/tools/agent-quote.js +0 -81
- package/dist/tools/agent-quote.js.map +0 -1
- package/dist/tools/pay-with-split.d.ts +0 -93
- package/dist/tools/pay-with-split.d.ts.map +0 -1
- package/dist/tools/pay-with-split.js +0 -138
- package/dist/tools/pay-with-split.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,10 @@ AiFinPay MCP server for persistent agent identity, Agent Passport resolution,
|
|
|
4
4
|
route discovery and non-signing settlement invoices. Canonical domain:
|
|
5
5
|
**aifinpay.io**.
|
|
6
6
|
|
|
7
|
-
Version **2.
|
|
7
|
+
Version **2.7.0** is prepared in this checkout, requiring agent2.5.0 and canonical skill2.8.0.
|
|
8
|
+
The published baseline checked2026-10-04 was MCP2.5.0. Package publication and
|
|
9
|
+
real registry dependency/lock refresh remain release gates; a source-cohort
|
|
10
|
+
build does not prove those steps. Owner-enabled v1.4 purchases with `payable_fetch` are
|
|
8
11
|
released: on Polygon since 2.2.0, on Base (ETH or USDC) since 2.5.0; site-wide
|
|
9
12
|
batches with `scope: "merchant"` since 2.4.1. Without payment configuration the server keeps
|
|
10
13
|
its inspection-only tool inventory.
|
|
@@ -49,8 +52,9 @@ POL for gas: an exact-amount token approval plus the settlement, both within
|
|
|
49
52
|
|
|
50
53
|
### Paying on another chain
|
|
51
54
|
|
|
52
|
-
`AIFINPAY_PAY_CHAIN` picks the chain `payable_fetch` settles on:
|
|
53
|
-
|
|
55
|
+
`AIFINPAY_PAY_CHAIN` explicitly picks the chain `payable_fetch` settles on:
|
|
56
|
+
`polygon` by default, or an exact supported name in the capability list below.
|
|
57
|
+
Only the owner sets it, and a merchant is paid on a chain
|
|
54
58
|
only if its quote is for that chain; a quote for any other chain is refused,
|
|
55
59
|
never followed. On Base the batch is paid in ETH (or `AIFINPAY_PAY_ASSET:
|
|
56
60
|
"USDC"`) and gas is ETH, so the cap is `AIFINPAY_MAX_GAS`, in ETH:
|
|
@@ -65,8 +69,8 @@ never followed. On Base the batch is paid in ETH (or `AIFINPAY_PAY_ASSET:
|
|
|
65
69
|
`AIFINPAY_MAX_GAS` is the gas cap in the pay chain's native currency;
|
|
66
70
|
`AIFINPAY_MAX_GAS_POL` remains accepted on Polygon and is refused on Base rather
|
|
67
71
|
than read as ETH (0.3 POL is about $0.04; 0.3 ETH is several hundred dollars).
|
|
68
|
-
On Base the worst case includes
|
|
69
|
-
|
|
72
|
+
On Base the worst case includes L1 data and operator fees; the owner must set
|
|
73
|
+
the cap from the current estimate. The wallet's EVM address is the same on every chain, so
|
|
70
74
|
fund it with ETH on Base, not on Ethereum mainnet. `AIFINPAY_RPC_URL` optionally
|
|
71
75
|
replaces the chain's public RPC (`https://mainnet.base.org`,
|
|
72
76
|
`https://polygon.drpc.org`).
|
|
@@ -78,8 +82,8 @@ Call `payable_fetch({"url":"https://merchant.example/api/data"})`. The tool
|
|
|
78
82
|
uses the original signed v1.4 quote, independent fresh native/USD pricing, SDK
|
|
79
83
|
runtime/signer verification and owner limits. It persists the prepared transaction
|
|
80
84
|
before sending, verifies the receipt, and reuses the purchased batch. No special
|
|
81
|
-
merchant script, alternate contract or facilitator fallback is used. GET
|
|
82
|
-
mode only,
|
|
85
|
+
merchant script, alternate contract or facilitator fallback is used. GET on the configured chain; EVM receipt payments use live
|
|
86
|
+
mode only, in its native currency or the configured
|
|
83
87
|
stablecoin; Amoy payment receipts are not supported. The smallest batch is $0.10 plus gas, so keep `AIFINPAY_MAX_USD`
|
|
84
88
|
a little above the batch you expect to buy.
|
|
85
89
|
|
|
@@ -94,9 +98,10 @@ owner can add it.
|
|
|
94
98
|
### Network access
|
|
95
99
|
|
|
96
100
|
A sandbox that allowlists outbound hosts must allow `api.aifinpay.io` (quotes and
|
|
97
|
-
receipts) and an RPC for the pay chain. The independent
|
|
98
|
-
|
|
99
|
-
then `api.coingecko.com`;
|
|
101
|
+
receipts) and an RPC for the pay chain. The independent native/USD rate
|
|
102
|
+
uses the pinned Chainlink feed on Polygon/Base, then `api.coinbase.com`,
|
|
103
|
+
then `api.coingecko.com`; other chains use those HTTP price sources.
|
|
104
|
+
If none provides a valid fresh rate, `payable_fetch` stops before paying and
|
|
100
105
|
the error names each host it tried.
|
|
101
106
|
|
|
102
107
|
## Link the agent to its owner's dashboard
|
|
@@ -105,15 +110,18 @@ The owner sees the agent's balance, payments and receipts at
|
|
|
105
110
|
https://dash.aifinpay.io → My Agents. There, **Claim via MCP** generates a
|
|
106
111
|
one-time URL; pass it to `agent_claim_self`. The tool contacts only AiFinPay
|
|
107
112
|
origins, signs only the claim challenge for this agent's own address, and moves
|
|
108
|
-
no funds.
|
|
113
|
+
no funds. The owner-selected payment family must be confirmed successfully;
|
|
114
|
+
the second wallet is best-effort. Use the selected wallet's Fund panel for
|
|
115
|
+
available networks and assets; binding does not activate a disabled network.
|
|
116
|
+
Offer this to the owner after `init`.
|
|
109
117
|
|
|
110
|
-
Private recovery state lives at `AIFINPAY_HOME/payments/<evm-address>/state.json`
|
|
118
|
+
Private recovery state for all payment families lives at `AIFINPAY_HOME/payments/<evm-address>/state.json`
|
|
111
119
|
(default home `~/.aifinpay`). State is mode600 in mode700 directories, atomically
|
|
112
120
|
written and fsynced. One operation lock serializes the wallet across processes.
|
|
113
121
|
A retry recovers a pending receipt before allowing another purchase. A process
|
|
114
122
|
crash leaves the lock for owner reconciliation; it is never stolen automatically.
|
|
115
|
-
If a prepared transaction was never broadcast or
|
|
116
|
-
hash before clearing anything. Never put raw transactions, receipt JWTs or the
|
|
123
|
+
If a prepared transaction was never broadcast or its outcome remains unknown,
|
|
124
|
+
reconcile its exact hash before clearing anything. Never put raw transactions, receipt JWTs or the
|
|
117
125
|
state file in chat. Unconfirmed payments consume the budget conservatively.
|
|
118
126
|
|
|
119
127
|
## Tools
|
|
@@ -197,7 +205,7 @@ A client configuration can use the keystore without embedding its secret:
|
|
|
197
205
|
"mcpServers": {
|
|
198
206
|
"aifinpay": {
|
|
199
207
|
"command": "npx",
|
|
200
|
-
"args": ["-y", "@aifinpay/mcp
|
|
208
|
+
"args": ["-y", "@aifinpay/mcp"],
|
|
201
209
|
"env": {
|
|
202
210
|
"AIFINPAY_AGENTS_FILE": "/absolute/project/aifinpay/agents.json",
|
|
203
211
|
"AIFINPAY_AGENT_ID": "research-agent"
|
|
@@ -239,20 +247,23 @@ snapshot. Verify `agent_address` against the wallet you intend to use.
|
|
|
239
247
|
| `AIFINPAY_MAX_USD` | — | Per-payment USD cap for `payable_fetch`; required when payments are enabled. |
|
|
240
248
|
| `AIFINPAY_GATEWAY_ORIGINS` | — | Comma-separated exact HTTPS origins the agent may pay; required with payments. |
|
|
241
249
|
| `AIFINPAY_GATEWAY_PATH_MODE` | `gateway` | Use `gateway` for merchant-slug identity or `direct` for full request-path identity. |
|
|
242
|
-
| `AIFINPAY_PAY_CHAIN` | `polygon` |
|
|
243
|
-
| `AIFINPAY_MAX_GAS` | — | Gas cap per payment in the pay chain's native currency (POL, ETH).
|
|
250
|
+
| `AIFINPAY_PAY_CHAIN` | `polygon` | Owner-selected payment chain; see the2.7.0 source capability list. |
|
|
251
|
+
| `AIFINPAY_MAX_GAS` | — | Gas cap per payment in the pay chain's native currency (POL, ETH, AVAX, BNB, XRP). |
|
|
244
252
|
| `AIFINPAY_RPC_URL` | chain's public RPC | HTTPS RPC for the pay chain. |
|
|
245
253
|
| `AIFINPAY_CLAIM_ORIGINS` | AiFinPay dashboards | Exact origins `agent_claim_self` may link the agent to. |
|
|
246
254
|
|
|
247
|
-
`agent_history({address, source:"transactions"})` reads
|
|
248
|
-
settlements
|
|
255
|
+
`agent_history({address, source:"transactions", network:"polygon"})` reads
|
|
256
|
+
indexed settlements for that network when the backend's durable indexer serves
|
|
257
|
+
it. The dated production baseline has Polygon indexing; another client chain
|
|
258
|
+
descriptor alone does not prove history coverage. `source:"receipts"` reads retained batches, including test-mode
|
|
249
259
|
payments. Pass `passport` instead of, or alongside, `address` to resolve a
|
|
250
260
|
public passport first. A backend without the passport resolver cannot satisfy
|
|
251
261
|
passport-only queries. No secret API key is needed for public metadata.
|
|
252
262
|
|
|
253
263
|
Responses do not include bearer receipts. Limits are 1..100; follow
|
|
254
264
|
`next_offset`. History source/coverage is explicit: it is not a full wallet
|
|
255
|
-
explorer.
|
|
265
|
+
explorer. Test-mode indexing depends on backend capabilities; retained receipt
|
|
266
|
+
history is a separate source and does not establish mainnet activation.
|
|
256
267
|
|
|
257
268
|
```
|
|
258
269
|
const { server } = await createServer(loadConfigFromEnv());
|
|
@@ -285,3 +296,83 @@ executor; this MCP does not expose Amoy paid receipt purchases.
|
|
|
285
296
|
## License
|
|
286
297
|
|
|
287
298
|
MIT.
|
|
299
|
+
|
|
300
|
+
## Additional EVM networks in the 2.7.0 source candidate
|
|
301
|
+
|
|
302
|
+
Owner `AIFINPAY_PAY_CHAIN` accepts polygon, base, optimism, arbitrum, avalanche,
|
|
303
|
+
bnb, unichain, xrplevm and robinhood. `AIFINPAY_MAX_GAS` is in the selected native
|
|
304
|
+
POL/ETH/AVAX/BNB/XRP currency; the legacy POL cap applies only on Polygon. Assets
|
|
305
|
+
must be pinned for that chain, including BNB 18-decimal USDC/USDT and Robinhood
|
|
306
|
+
18-decimal USDe/6-decimal USDG. XRPL EVM has native XRP only. Metadata comes from
|
|
307
|
+
agent 2.5.0; the backend must still authorize and serve that merchant/network.
|
|
308
|
+
Source support does not activate networks in production. Pending journals retain
|
|
309
|
+
the original chain and are recovered without another settlement. A legacy
|
|
310
|
+
missing-chain journal is adopted only when the owner-configured chain and the
|
|
311
|
+
actual signed transaction's chain ID, payer, pinned target and exact call agree.
|
|
312
|
+
Insufficient evidence requires manual receipt reconciliation. A later quote
|
|
313
|
+
expiry does not invalidate receipt recovery for an existing payment.
|
|
314
|
+
|
|
315
|
+
Release order: publish reviewed canonical skill2.8.0 and agent2.5.0, refresh MCP
|
|
316
|
+
dependencies and lock from those real registry releases, pass standalone MCP
|
|
317
|
+
CI, then publish MCP2.7.0. This candidate is tested against fresh source-packed
|
|
318
|
+
agent2.5.0 and skill2.8.0. The existing registry entries remain until publication;
|
|
319
|
+
no npm integrity/resolution is fabricated. An old2.3.x agent cannot build the
|
|
320
|
+
new descriptor/helper imports, and old skill2.6.0 cannot satisfy the exact
|
|
321
|
+
release-target guard. Hosted source CI uses `scripts/check-mcp-source-cohort.mjs`: a byte-preserving fixed registry bootstrap and genuine same-commit Node plus fully pinned canonical skill packages in disposable directories. Exact package bytes, versions, bundled skill and full tests must pass; the registry publication guard must still refuse this source cohort. Standalone release CI requires the refreshed real registry lock. Never publish the candidate with the old registry dependency lock.
|
|
322
|
+
|
|
323
|
+
Use one shared local filesystem for a wallet's ledger/journal and reconcile
|
|
324
|
+
pending transactions before downgrading. Node 2.4 reservations never expire for
|
|
325
|
+
an unknown outcome; receipt failures never refund confirmed spend. Older SDK
|
|
326
|
+
versions can expire or reset this state. Custom capped v1.4 ledger adapters need
|
|
327
|
+
the new bound preparation/recovery/completion hooks; absence refuses payment.
|
|
328
|
+
|
|
329
|
+
## Solana source candidate
|
|
330
|
+
|
|
331
|
+
Version2.7 targets NodeSDK2.5 and canonical skill2.8. These are coordinated
|
|
332
|
+
release targets; source integration does not establish npm publication or
|
|
333
|
+
activate a network. The published deployments1.1.3 Solana entries remain
|
|
334
|
+
disabled. `payable_fetch` retains the SDK availability check and cannot
|
|
335
|
+
override it.
|
|
336
|
+
|
|
337
|
+
For a separately accepted and served Solana route, the owner sets
|
|
338
|
+
`AIFINPAY_PAY_CHAIN=solana`, explicit `AIFINPAY_SOLANA_NETWORK=mainnet` with
|
|
339
|
+
live mode (or devnet with dev mode), and a trusted HTTPS `AIFINPAY_RPC_URL`.
|
|
340
|
+
`AIFINPAY_MAX_FEE_LAMPORTS` is a positive integer cap on transaction fees plus
|
|
341
|
+
required account rent; EVM gas caps cannot be used on Solana. Native SOL and
|
|
342
|
+
network-pinned classic SPL assets are selected with `AIFINPAY_PAY_ASSET`.
|
|
343
|
+
Existing payments opt-in, approved origins and per-payment/daily USD caps
|
|
344
|
+
remain required.
|
|
345
|
+
|
|
346
|
+
Before a Solana quote request, SDK2.5 saves the exact signed authorization,
|
|
347
|
+
nonce and owner context in its shared private ledger. After a timeout or
|
|
348
|
+
restart it replays that admission instead of generating a new nonce. The
|
|
349
|
+
per-payment limit stays fixed for that admission across daily rollover;
|
|
350
|
+
MCP still checks the current daily allowance before submission. An exact
|
|
351
|
+
authenticated non-admission response can close only an unreserved local
|
|
352
|
+
intent. It never refunds an issued backend quote reservation. Keep pending
|
|
353
|
+
2.5 ledger state when upgrading; reconcile it before downgrade and never
|
|
354
|
+
delete state to retry a payment.
|
|
355
|
+
|
|
356
|
+
The private durable journal keeps the full signed Solana transaction and
|
|
357
|
+
base58 signature before submission, including fee/rent in the admission
|
|
358
|
+
amount. Payer identities retain case. Restart/retry recovers the original
|
|
359
|
+
receipt; timeout or blockhash expiry never triggers a replacement payment.
|
|
360
|
+
The same local wallet budget remains shared across payment families.
|
|
361
|
+
|
|
362
|
+
A proven finalized Solana transaction failure is returned as an error, without
|
|
363
|
+
a receipt or replacement payment. After the SDK verifies the exact signed
|
|
364
|
+
transaction and canonical finalized block and durably reconciles its bound
|
|
365
|
+
ledger, MCP atomically retains the actual fee debit and clears its pending
|
|
366
|
+
purchase guard. Its private journal keeps the original signature and failed
|
|
367
|
+
status. Missing or mismatched evidence retains the full reservation; expiry
|
|
368
|
+
alone cannot release it. A persistence failure can be retried without resending.
|
|
369
|
+
|
|
370
|
+
Before publication, install the actual published coordinated Node/skill
|
|
371
|
+
versions and refresh the real registry lock; a locally packed source cohort
|
|
372
|
+
is test evidence only. Do not publish with the previous dependency lock.
|
|
373
|
+
|
|
374
|
+
Solana `agent_history` and `agent_quota` use the exact case-sensitive local
|
|
375
|
+
Solana address and owner-configured cluster plus independently pinned program.
|
|
376
|
+
They request the new program's indexed settlements and retained receipts; the
|
|
377
|
+
legacy program and another cluster are separate histories. Explicit EVM
|
|
378
|
+
history selection continues to use the wallet's EVM address.
|
package/dist/config.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface McpConfig {
|
|
|
8
8
|
agentId?: string;
|
|
9
9
|
walletHome?: string;
|
|
10
10
|
walletPassphrase?: string;
|
|
11
|
-
/**
|
|
11
|
+
/** Dev environment. EVM payments stay live-only; Solana requires explicit devnet. */
|
|
12
12
|
devMode?: boolean;
|
|
13
13
|
/** Custom AiFinPay backend URL. Defaults to production. */
|
|
14
14
|
baseUrl?: string;
|
|
@@ -17,13 +17,17 @@ export interface McpConfig {
|
|
|
17
17
|
/** Owner opt-in; never accepted from tool arguments. */
|
|
18
18
|
paymentsEnabled?: boolean;
|
|
19
19
|
dailyAmountUsd?: number;
|
|
20
|
-
/** Chain payable_fetch settles on: "polygon" (default) or "
|
|
20
|
+
/** Chain payable_fetch settles on: "polygon" (default), another supported EVM chain, or "solana". Set by
|
|
21
21
|
* the owner only; never inferred from a quote or a tool argument. */
|
|
22
22
|
payChain?: string;
|
|
23
23
|
/** RPC for the pay chain; defaults to the chain's public RPC. */
|
|
24
24
|
rpcUrl?: string;
|
|
25
25
|
/** Gas cap per payment, in the pay chain's native currency (POL, ETH). */
|
|
26
26
|
maxGas?: string;
|
|
27
|
+
/** Owner-selected cluster, independently bound to live/prod or dev mode. */
|
|
28
|
+
solanaNetwork?: "mainnet" | "devnet";
|
|
29
|
+
/** Integer lamports for transaction fees and required account rent. */
|
|
30
|
+
maxFeeLamports?: string;
|
|
27
31
|
/** Same cap under its original name; accepted on Polygon only. */
|
|
28
32
|
maxGasPol?: string;
|
|
29
33
|
/** What payable_fetch pays with: the chain's native currency (default) or a
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|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ExB,qDAAqD;IACrD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,iBAAiB,IAAI,SAAS,CA+B7C;AAgED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAkF/D"}
|
package/dist/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { paymentStableAsset, solanaStableMint } from "@aifinpay/agent";
|
|
1
2
|
import { payChain } from "./pay-chains.js";
|
|
2
3
|
export function loadConfigFromEnv() {
|
|
3
4
|
if (process.env.AIFINPAY_MODE && !["live", "dev"].includes(process.env.AIFINPAY_MODE)) {
|
|
@@ -12,6 +13,8 @@ export function loadConfigFromEnv() {
|
|
|
12
13
|
payChain: process.env.AIFINPAY_PAY_CHAIN || undefined,
|
|
13
14
|
rpcUrl: process.env.AIFINPAY_RPC_URL || undefined,
|
|
14
15
|
maxGas: process.env.AIFINPAY_MAX_GAS || undefined,
|
|
16
|
+
solanaNetwork: parseSolanaNetwork(process.env.AIFINPAY_SOLANA_NETWORK),
|
|
17
|
+
maxFeeLamports: process.env.AIFINPAY_MAX_FEE_LAMPORTS || undefined,
|
|
15
18
|
maxGasPol: process.env.AIFINPAY_MAX_GAS_POL || undefined,
|
|
16
19
|
payAsset: process.env.AIFINPAY_PAY_ASSET || undefined,
|
|
17
20
|
devMode: process.env.AIFINPAY_MODE === "dev",
|
|
@@ -29,6 +32,13 @@ export function loadConfigFromEnv() {
|
|
|
29
32
|
trustedHosts: splitList(process.env.AIFINPAY_TRUSTED_HOSTS),
|
|
30
33
|
};
|
|
31
34
|
}
|
|
35
|
+
function parseSolanaNetwork(raw) {
|
|
36
|
+
if (raw === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
if (raw === "mainnet" || raw === "devnet")
|
|
39
|
+
return raw;
|
|
40
|
+
throw new Error("AIFINPAY_SOLANA_NETWORK must be mainnet or devnet");
|
|
41
|
+
}
|
|
32
42
|
function parseGatewayPathMode(raw) {
|
|
33
43
|
if (raw === undefined || raw.trim() === "")
|
|
34
44
|
return "gateway";
|
|
@@ -87,9 +97,9 @@ function splitOrigins(raw) {
|
|
|
87
97
|
export function validatePaymentConfig(config) {
|
|
88
98
|
if (!config.paymentsEnabled)
|
|
89
99
|
throw new Error("Payments disabled; owner must set AIFINPAY_PAYMENTS_ENABLED=1");
|
|
90
|
-
if (config.devMode)
|
|
91
|
-
throw new Error("MCP receipt payments support live mode only");
|
|
92
100
|
const chain = payChain(config.payChain);
|
|
101
|
+
if (config.devMode && chain.name !== "solana")
|
|
102
|
+
throw new Error("MCP receipt payments support live mode only");
|
|
93
103
|
if (config.rpcUrl !== undefined) {
|
|
94
104
|
let rpc;
|
|
95
105
|
try {
|
|
@@ -119,8 +129,33 @@ export function validatePaymentConfig(config) {
|
|
|
119
129
|
}
|
|
120
130
|
}))
|
|
121
131
|
throw new Error("Payments require explicit exact HTTPS AIFINPAY_GATEWAY_ORIGINS");
|
|
122
|
-
if (
|
|
123
|
-
|
|
132
|
+
if (chain.name === "solana") {
|
|
133
|
+
const expectedNetwork = config.devMode ? "devnet" : "mainnet";
|
|
134
|
+
if (config.solanaNetwork !== expectedNetwork)
|
|
135
|
+
throw new Error(`AIFINPAY_SOLANA_NETWORK must be ${expectedNetwork} for the configured AIFINPAY_MODE`);
|
|
136
|
+
if (!config.rpcUrl)
|
|
137
|
+
throw new Error("Solana payments require an explicit owner-trusted AIFINPAY_RPC_URL");
|
|
138
|
+
if (config.maxGas !== undefined || config.maxGasPol !== undefined)
|
|
139
|
+
throw new Error("Solana uses AIFINPAY_MAX_FEE_LAMPORTS for fees and rent; EVM gas caps do not apply");
|
|
140
|
+
if (config.payAsset !== undefined && config.payAsset !== "SOL") {
|
|
141
|
+
try {
|
|
142
|
+
solanaStableMint(config.solanaNetwork, config.payAsset);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
throw new Error("AIFINPAY_PAY_ASSET is not pinned for the selected Solana network");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const fee = config.maxFeeLamports;
|
|
149
|
+
if (typeof fee !== "string" || !/^[1-9][0-9]*$/.test(fee) || BigInt(fee) > 2n ** 64n - 1n)
|
|
150
|
+
throw new Error("AIFINPAY_MAX_FEE_LAMPORTS must be a positive uint64 integer covering transaction fees and account rent");
|
|
151
|
+
return BigInt(fee);
|
|
152
|
+
}
|
|
153
|
+
if (config.solanaNetwork !== undefined || config.maxFeeLamports !== undefined)
|
|
154
|
+
throw new Error("Solana network and lamport fee settings require AIFINPAY_PAY_CHAIN=solana");
|
|
155
|
+
if (config.payAsset !== undefined &&
|
|
156
|
+
config.payAsset !== chain.native &&
|
|
157
|
+
!paymentStableAsset(chain.name, config.payAsset))
|
|
158
|
+
throw new Error(`AIFINPAY_PAY_ASSET must be "${chain.native}" or a stablecoin symbol pinned for ${chain.name}`);
|
|
124
159
|
// The POL-named cap means POL. Read on another chain it would silently cap
|
|
125
160
|
// ETH gas at a number chosen for POL — 0.3 POL is ~$0.04, 0.3 ETH is ~$800.
|
|
126
161
|
if (config.maxGasPol !== undefined && chain.name !== "polygon")
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AA6E3C,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,CAAC,MAAM,EAAE,KA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5D,MAAM,IAAI,KAAK,CACb,2DAA2D,KAAK,CAAC,IAAI,6BAA6B,KAAK,CAAC,MAAM,EAAE,CACjH,CAAC;IACJ,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,SAAS;QACrG,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,sBAAsB,CAAC;IACvF,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC;IAC9C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,uCAAuC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/E,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,kFAAkF,KAAK,CAAC,MAAM,EAAE,CACxG,CAAC;IACJ,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1E,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iCAAiC,CAAC,CAAC;IAC9F,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/native-price.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { type PayChain } from "./pay-chains.js";
|
|
|
17
17
|
* 3. api.coingecko.com.
|
|
18
18
|
* Feed addresses and ids live in pay-chains.ts.
|
|
19
19
|
*/
|
|
20
|
-
export declare const CHAINLINK_POL_USD_POLYGON: `0x${string}
|
|
20
|
+
export declare const CHAINLINK_POL_USD_POLYGON: `0x${string}` | undefined;
|
|
21
21
|
export interface NativePrice {
|
|
22
22
|
usd: number;
|
|
23
23
|
observedAtMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-price.d.ts","sourceRoot":"","sources":["../src/native-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"native-price.d.ts","sourceRoot":"","sources":["../src/native-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,yBAAyB,2BAAwC,CAAC;AAO/E,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,MAAM,EAAE,GAAG,UAAU,GAAG,WAAW,CAAC;CAC1D;AAED,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAoE1E;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,WAAW,CAAC,CAsBvB;AAED,4DAA4D;AAC5D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAE3G"}
|
package/dist/native-price.js
CHANGED
|
@@ -56,7 +56,7 @@ async function fromChainlink(fetchImpl, rpc, chain) {
|
|
|
56
56
|
if (answer <= 0n || answer >= 2n ** 255n)
|
|
57
57
|
throw new Error("non-positive answer");
|
|
58
58
|
const ageS = Math.floor(Date.now() / 1000) - updatedAt;
|
|
59
|
-
if (ageS > MAX_FEED_AGE_S)
|
|
59
|
+
if (ageS < -30 || ageS > MAX_FEED_AGE_S)
|
|
60
60
|
throw new Error(`feed is ${ageS}s old`);
|
|
61
61
|
const usd = Number(answer) / 10 ** CHAINLINK_DECIMALS;
|
|
62
62
|
if (!sane(usd, chain))
|
|
@@ -87,7 +87,7 @@ async function fromCoinGecko(fetchImpl, chain) {
|
|
|
87
87
|
const ageS = Math.floor(Date.now() / 1000) - Number(entry?.last_updated_at ?? 0);
|
|
88
88
|
if (!sane(usd, chain))
|
|
89
89
|
throw new Error("invalid response");
|
|
90
|
-
if (!(ageS <= MAX_FEED_AGE_S))
|
|
90
|
+
if (!(ageS >= -30 && ageS <= MAX_FEED_AGE_S))
|
|
91
91
|
throw new Error(`price is ${ageS}s old`);
|
|
92
92
|
return { usd, observedAtMs: Date.now(), source: "coingecko" };
|
|
93
93
|
}
|
|
@@ -100,7 +100,7 @@ export async function independentNativeUsd(opts) {
|
|
|
100
100
|
const { chain } = opts;
|
|
101
101
|
const attempts = [];
|
|
102
102
|
const rpc = opts.rpc;
|
|
103
|
-
if (rpc)
|
|
103
|
+
if (rpc && chain.chainlinkNativeUsd)
|
|
104
104
|
attempts.push([`Chainlink on ${chain.label} via ${hostOf(rpc)}`, () => fromChainlink(opts.fetchImpl, rpc, chain)]);
|
|
105
105
|
attempts.push(["api.coinbase.com", () => fromCoinbase(opts.fetchImpl, chain)]);
|
|
106
106
|
attempts.push(["api.coingecko.com", () => fromCoinGecko(opts.fetchImpl, chain)]);
|
package/dist/native-price.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-price.js","sourceRoot":"","sources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OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;AAC9G,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,oBAAoB,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
package/dist/pay-chains.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Aifp1V14Chain } from "@aifinpay/agent";
|
|
2
2
|
/**
|
|
3
3
|
* The chains payable_fetch can settle on, and everything that differs between
|
|
4
4
|
* them. The owner picks one with AIFINPAY_PAY_CHAIN; nothing here is ever taken
|
|
@@ -9,7 +9,7 @@ import type { Aifp1V14Chain } from "@aifinpay/agent";
|
|
|
9
9
|
* compile) and the backend serves it.
|
|
10
10
|
*/
|
|
11
11
|
export interface PayChain {
|
|
12
|
-
name: Aifp1V14Chain;
|
|
12
|
+
name: Aifp1V14Chain | "solana";
|
|
13
13
|
/** How messages to the owner name it. */
|
|
14
14
|
label: string;
|
|
15
15
|
/** Native currency: the default pay asset and the gas currency. */
|
|
@@ -17,7 +17,7 @@ export interface PayChain {
|
|
|
17
17
|
/** Public RPC used when the owner sets none; also read for the Chainlink price. */
|
|
18
18
|
defaultRpc: string;
|
|
19
19
|
/** Chainlink <native>/USD aggregator proxy on this chain, 8 decimals. */
|
|
20
|
-
chainlinkNativeUsd
|
|
20
|
+
chainlinkNativeUsd?: `0x${string}`;
|
|
21
21
|
/** Coinbase spot pair, e.g. "ETH-USD". */
|
|
22
22
|
coinbasePair: string;
|
|
23
23
|
/** CoinGecko simple/price id. */
|
|
@@ -26,6 +26,7 @@ export interface PayChain {
|
|
|
26
26
|
maxSaneUsd: number;
|
|
27
27
|
}
|
|
28
28
|
export declare const PAY_CHAINS: Readonly<Record<Aifp1V14Chain, PayChain>>;
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const SOLANA_PAY_CHAIN: Readonly<PayChain>;
|
|
30
|
+
export declare const PAY_CHAIN_NAMES: string[];
|
|
30
31
|
export declare function payChain(name: string | undefined): PayChain;
|
|
31
32
|
//# sourceMappingURL=pay-chains.d.ts.map
|
package/dist/pay-chains.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay-chains.d.ts","sourceRoot":"","sources":["../src/pay-chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"pay-chains.d.ts","sourceRoot":"","sources":["../src/pay-chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,aAAa,GAAG,QAAQ,CAAC;IAC/B,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,kBAAkB,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACnC,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;CACpB;AAkBD,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAA4B,CAAC;AAE9F,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,CAQ9C,CAAC;AACH,eAAO,MAAM,eAAe,UAAyC,CAAC;AAEtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAM3D"}
|
package/dist/pay-chains.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
coinbasePair:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
1
|
+
import { PAYMENT_CHAINS } from "@aifinpay/agent";
|
|
2
|
+
// Reuse the SDK's trusted chain descriptors. Feed proxies are included only
|
|
3
|
+
// where already independently pinned; other chains use Coinbase/CoinGecko.
|
|
4
|
+
const payChains = {};
|
|
5
|
+
for (const name of Object.keys(PAYMENT_CHAINS)) {
|
|
6
|
+
const descriptor = PAYMENT_CHAINS[name];
|
|
7
|
+
payChains[name] = Object.freeze({
|
|
8
|
+
...descriptor,
|
|
9
|
+
name,
|
|
10
|
+
coinbasePair: `${descriptor.native}-USD`,
|
|
11
|
+
...(name === "polygon"
|
|
12
|
+
? { chainlinkNativeUsd: "0xAB594600376Ec9fD91F8e885dADF0CE036862dE0" }
|
|
13
|
+
: name === "base"
|
|
14
|
+
? { chainlinkNativeUsd: "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70" }
|
|
15
|
+
: {}),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export const PAY_CHAINS = Object.freeze(payChains);
|
|
19
|
+
export const SOLANA_PAY_CHAIN = Object.freeze({
|
|
20
|
+
name: "solana",
|
|
21
|
+
label: "Solana",
|
|
22
|
+
native: "SOL",
|
|
23
|
+
defaultRpc: "https://api.mainnet-beta.solana.com",
|
|
24
|
+
coinbasePair: "SOL-USD",
|
|
25
|
+
coingeckoId: "solana",
|
|
26
|
+
maxSaneUsd: 100_000,
|
|
28
27
|
});
|
|
29
|
-
export const PAY_CHAIN_NAMES = Object.keys(PAY_CHAINS);
|
|
28
|
+
export const PAY_CHAIN_NAMES = [...Object.keys(PAY_CHAINS), "solana"];
|
|
30
29
|
export function payChain(name) {
|
|
30
|
+
if (name === "solana")
|
|
31
|
+
return SOLANA_PAY_CHAIN;
|
|
31
32
|
const key = (name ?? "polygon");
|
|
32
33
|
const chain = Object.hasOwn(PAY_CHAINS, key) ? PAY_CHAINS[key] : undefined;
|
|
33
34
|
if (!chain)
|
package/dist/pay-chains.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay-chains.js","sourceRoot":"","sources":["../src/pay-chains.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pay-chains.js","sourceRoot":"","sources":["../src/pay-chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AA6BrE,4EAA4E;AAC5E,2EAA2E;AAC3E,MAAM,SAAS,GAAG,EAAqC,CAAC;AACxD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAoB,EAAE,CAAC;IAClE,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,GAAG,UAAU;QACb,IAAI;QACJ,YAAY,EAAE,GAAG,UAAU,CAAC,MAAM,MAAM;QACxC,GAAG,CAAC,IAAI,KAAK,SAAS;YACpB,CAAC,CAAC,EAAE,kBAAkB,EAAE,4CAAqD,EAAE;YAC/E,CAAC,CAAC,IAAI,KAAK,MAAM;gBACf,CAAC,CAAC,EAAE,kBAAkB,EAAE,4CAAqD,EAAE;gBAC/E,CAAC,CAAC,EAAE,CAAC;KACV,CAAC,CAAC;AACL,CAAC;AACD,MAAM,CAAC,MAAM,UAAU,GAA8C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAE9F,MAAM,CAAC,MAAM,gBAAgB,GAAuB,MAAM,CAAC,MAAM,CAAC;IAChE,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,qCAAqC;IACjD,YAAY,EAAE,SAAS;IACvB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,OAAO;CACpB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEtE,MAAM,UAAU,QAAQ,CAAC,IAAwB;IAC/C,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,gBAAgB,CAAC;IAC/C,MAAM,GAAG,GAAG,CAAC,IAAI,IAAI,SAAS,CAAkB,CAAC;IACjD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/F,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { McpConfig } from "./config.js";
|
|
2
|
+
export declare function isSolanaPublicKey(value: unknown): value is string;
|
|
3
|
+
/** Read/recovery inventory never grants settlement availability. */
|
|
4
|
+
export declare function solanaHistorySelection(config: McpConfig): {
|
|
5
|
+
network: "mainnet" | "devnet";
|
|
6
|
+
program: string;
|
|
7
|
+
};
|
|
8
|
+
/** A pinned request alone does not make a misconfigured response match it. */
|
|
9
|
+
export declare function assertSolanaReadContext(value: unknown, address: string, selected: ReturnType<typeof solanaHistorySelection>, identityField: "address" | "payer" | "agent_address"): asserts value is Record<string, unknown>;
|
|
10
|
+
export declare function assertSolanaQuota(row: Record<string, unknown>): void;
|
|
11
|
+
export declare function solanaIndexingMetadata(value: unknown): {
|
|
12
|
+
coverage_kind: string;
|
|
13
|
+
coverage_start: unknown;
|
|
14
|
+
archive_complete: boolean;
|
|
15
|
+
complete: boolean;
|
|
16
|
+
} | undefined;
|
|
17
|
+
//# sourceMappingURL=payment-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-identity.d.ts","sourceRoot":"","sources":["../src/payment-identity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAMjE;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG;IAAE,OAAO,EAAE,SAAS,GAAG,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAM5G;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,EACnD,aAAa,EAAE,SAAS,GAAG,OAAO,GAAG,eAAe,GACnD,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAW1C;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAgC7D;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO;;;;;cAsBpD"}
|