@moonbeam-foundation/sdk 0.5.3 → 0.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.
Files changed (106) hide show
  1. package/README.md +122 -22
  2. package/dist/abi/index.d.ts +55 -0
  3. package/dist/abi/index.d.ts.map +1 -0
  4. package/dist/abi/index.js +227 -0
  5. package/dist/abi/index.js.map +1 -0
  6. package/dist/acp/events.d.ts +38 -38
  7. package/dist/acp/events.d.ts.map +1 -1
  8. package/dist/acp/events.js.map +1 -1
  9. package/dist/acp/moonbeam-acp.generated.d.ts +50 -0
  10. package/dist/acp/moonbeam-acp.generated.d.ts.map +1 -0
  11. package/dist/acp/moonbeam-acp.generated.js +56 -0
  12. package/dist/acp/moonbeam-acp.generated.js.map +1 -0
  13. package/dist/acp/pipeline.js.map +1 -1
  14. package/dist/acp/registry.d.ts.map +1 -1
  15. package/dist/acp/registry.js +5 -3
  16. package/dist/acp/registry.js.map +1 -1
  17. package/dist/actors/track-record.js.map +1 -1
  18. package/dist/adapters/acp.js.map +1 -1
  19. package/dist/adapters/stamp.d.ts +1 -1
  20. package/dist/adapters/stamp.d.ts.map +1 -1
  21. package/dist/arbitration/index.d.ts +120 -0
  22. package/dist/arbitration/index.d.ts.map +1 -0
  23. package/dist/arbitration/index.js +116 -0
  24. package/dist/arbitration/index.js.map +1 -0
  25. package/dist/assurance/assurance-shared.d.ts +1924 -0
  26. package/dist/assurance/assurance-shared.d.ts.map +1 -0
  27. package/dist/assurance/assurance-shared.js +2225 -0
  28. package/dist/assurance/assurance-shared.js.map +1 -0
  29. package/dist/assurance/index.d.ts +57 -0
  30. package/dist/assurance/index.d.ts.map +1 -0
  31. package/dist/assurance/index.js +49 -0
  32. package/dist/assurance/index.js.map +1 -0
  33. package/dist/attest/index.d.ts +19 -0
  34. package/dist/attest/index.d.ts.map +1 -0
  35. package/dist/attest/index.js +17 -0
  36. package/dist/attest/index.js.map +1 -0
  37. package/dist/client/index.d.ts +16 -6
  38. package/dist/client/index.d.ts.map +1 -1
  39. package/dist/client/index.js +21 -1
  40. package/dist/client/index.js.map +1 -1
  41. package/dist/connect/logs.js.map +1 -1
  42. package/dist/core/money.js.map +1 -1
  43. package/dist/core/settle.js.map +1 -1
  44. package/dist/core/types.d.ts +1 -1
  45. package/dist/erc8004/index.d.ts +9 -9
  46. package/dist/erc8004/index.d.ts.map +1 -1
  47. package/dist/erc8004/index.js.map +1 -1
  48. package/dist/erc8183/index.d.ts +12 -12
  49. package/dist/erc8183/index.d.ts.map +1 -1
  50. package/dist/erc8183/index.js.map +1 -1
  51. package/dist/index.d.ts +7 -0
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +8 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/judge/index.d.ts +35 -3
  56. package/dist/judge/index.d.ts.map +1 -1
  57. package/dist/judge/index.js +41 -2
  58. package/dist/judge/index.js.map +1 -1
  59. package/dist/launcher/index.d.ts +3 -3
  60. package/dist/launcher/index.d.ts.map +1 -1
  61. package/dist/onboard/index.d.ts +64 -24
  62. package/dist/onboard/index.d.ts.map +1 -1
  63. package/dist/onboard/index.js +90 -15
  64. package/dist/onboard/index.js.map +1 -1
  65. package/dist/pools/index.d.ts +49 -7
  66. package/dist/pools/index.d.ts.map +1 -1
  67. package/dist/pools/index.js +30 -6
  68. package/dist/pools/index.js.map +1 -1
  69. package/dist/proof/index.d.ts +117 -0
  70. package/dist/proof/index.d.ts.map +1 -0
  71. package/dist/proof/index.js +81 -0
  72. package/dist/proof/index.js.map +1 -0
  73. package/dist/resale/index.d.ts +120 -0
  74. package/dist/resale/index.d.ts.map +1 -0
  75. package/dist/resale/index.js +117 -0
  76. package/dist/resale/index.js.map +1 -0
  77. package/dist/resale/payment-scheme.d.mts +46 -0
  78. package/dist/resale/payment-scheme.mjs +351 -0
  79. package/dist/resale/payment-scheme.pin.json +6 -0
  80. package/dist/rpc/index.d.ts +24 -0
  81. package/dist/rpc/index.d.ts.map +1 -0
  82. package/dist/rpc/index.js +66 -0
  83. package/dist/rpc/index.js.map +1 -0
  84. package/dist/x402/index.d.ts +90 -0
  85. package/dist/x402/index.d.ts.map +1 -0
  86. package/dist/x402/index.js +75 -0
  87. package/dist/x402/index.js.map +1 -0
  88. package/examples/03-end-to-end-offline.mjs +2 -2
  89. package/examples/14-grade-record.mjs +6 -4
  90. package/examples/17-grade-live.mjs +1 -1
  91. package/examples/20-onboard-client.mjs +2 -2
  92. package/examples/24-resell-on-base.mjs +17 -0
  93. package/examples/{30-read-a-real-job.mjs → 30-read-a-job.mjs} +2 -2
  94. package/examples/32-read-live-from-base.mjs +8 -11
  95. package/examples/40-the-article.mjs +1 -1
  96. package/examples/50-x402-pay-a-wall.mjs +17 -0
  97. package/examples/51-read-a-proof.mjs +21 -0
  98. package/examples/52-arbitration-calls.mjs +13 -0
  99. package/examples/53-attested-by-default.mjs +19 -0
  100. package/examples/README.md +13 -6
  101. package/examples/data/proof-base-tx-52587000.json +116 -0
  102. package/package.json +51 -10
  103. package/skills/moonbeam-actor-backer/SKILL.md +1 -1
  104. package/skills/moonbeam-actor-challenger/SKILL.md +1 -1
  105. package/skills/moonbeam-actor-doubter/SKILL.md +1 -1
  106. package/skills/moonbeam-assurance/SKILL.md +1 -1
@@ -0,0 +1,351 @@
1
+ /**
2
+ * automatch/payment-scheme.mjs — _ONE_PAYMENT_SCHEME_v1_ (2026-10-12; the owner, on learning that the memo router charges 20 %,
3
+ * ERC-8183 5 % + 5 %, BitAgent nothing, and that those fees were recorded differently per venue: "this must be always the same
4
+ * payment scheme to any-to-any agents and reseller"). ONE scheme for every sale the layer makes as seller of record, whatever the
5
+ * venue the buyer buys on (venue_in) and the venue the seller is hired on (venue_out):
6
+ *
7
+ * price_to_buyer = seller_price + our_fee + venue_fee(in) + venue_fee(out) [+ reseller_markup]
8
+ *
9
+ * The buyer pays coord once. What it paid leaves again as named legs, in whole units, and the legs sum to the payment exactly:
10
+ * our_fee coord's fee, by the rule of the door the buyer bought through (OUR_FEE.rules); on the wire and in the ledger: `fee`
11
+ * venue_fee what a VENUE itself takes, on the buying side (in) and on the selling side (out): the venue's own basis points on
12
+ * its own base, rounded as its contract rounds. Its own leg and its own ledger account; never part of our fee or
13
+ * of a reseller's markup
14
+ * seller_share what the doer receives: exactly its price on a paid ending
15
+ * reseller_markup a reseller tenant's leg, when its child bought
16
+ * provider · graders · ecosystem a metered call: the split of the wholesale (the site’s lib/usage-settle), unchanged
17
+ * A venue that takes its fee out of the money on its own side (`taken: at_source`) is grossed up for: the amount that enters it is
18
+ * the smallest one whose net is the price wanted, so the doer still receives its price and our fee does not move with the venue.
19
+ *
20
+ * The per-venue facts (VENUE_FEES) are typed HERE, once, each with the contract read it rests on; schemas/transitions.json
21
+ * `seller_coord_buyer.payment_scheme` is generated from this module (schemas/scripts/seller-coord-buyer.src.mjs), and every caller
22
+ * (redirect.mjs, escrow-job.mjs, olas-out.mjs, doer-pay.mjs, pipeline/reseller/fold.mjs; the site’s lib/acp-sales, venue-targets)
23
+ * computes through the functions below. Pure and self-contained: no import, no I/O. The site keeps a byte-identical copy at
24
+ * src/lib/payment-scheme.mjs (sha256 pinned on both sides).
25
+ */
26
+
27
+ export const RULE = 'ONE_PAYMENT_SCHEME_v1';
28
+ export const SCHEME_ID = 'taifoon.payment.scheme.v1';
29
+ export const FORMULA = 'price_to_buyer = seller_price + our_fee + venue_fee(in) + venue_fee(out) [+ reseller_markup]';
30
+ export const BPS = 10_000n;
31
+ /** label values that are not a venue of the standard: the layer's own resources, the contributors' pool, a reseller tenant's key, the
32
+ * test network, a sale nobody opened. Nothing is taken there. */
33
+ export const OWN_VENUES = Object.freeze(['coord', 'grid', 'reseller', 'devnet', 'unknown']);
34
+
35
+ /** The legs of the scheme, in the order they are written. `ledger_leg` is the leg's name in the ledger, the events and the metric
36
+ * coord_sale_units_total{leg}; `account` is where the ledger credits it. */
37
+ export const LEGS = Object.freeze([
38
+ Object.freeze({ id: 'our_fee', ledger_leg: 'fee', account: 'fee:coord', to: 'coord', what: 'coord’s fee on the sale, by the rule of the door the buyer bought through; it does not depend on the venue' }),
39
+ Object.freeze({ id: 'venue_fee', ledger_leg: 'venue_fee', account: 'fee:venue:<venue> (its platform part) · fee:venue:<venue>-evaluator (its evaluator part)', to: 'the venue', sides: Object.freeze(['in', 'out']), what: 'what the venue itself takes: on the buying side (in) and on the selling side (out); its own basis points on its own base, never part of our fee or of a reseller’s markup' }),
40
+ Object.freeze({ id: 'seller_share', ledger_leg: 'seller_share', account: 'payable:doer:<payee> · held:doer:<ref> (fee:coord when our own product served)', to: 'the doer', what: 'what the doer receives: paid − our_fee − venue_fee − reseller_markup; exactly its price on a paid ending' }),
41
+ Object.freeze({ id: 'reseller_markup', ledger_leg: 'reseller_markup', account: 'markup:reseller:<tenant>', to: 'the reseller tenant', what: 'a reseller tenant’s own leg on top of the list price, when its child bought' }),
42
+ Object.freeze({ id: 'provider', ledger_leg: 'provider', account: 'payable:contributor:<wallet> · fee:coord (our own resource)', to: 'the resource that answered', what: 'a metered call: the provider’s part of the wholesale' }),
43
+ Object.freeze({ id: 'graders', ledger_leg: 'graders', account: 'pool:graders', to: 'the graders’ pool', what: 'a metered call: the graders’ part of the wholesale' }),
44
+ Object.freeze({ id: 'ecosystem', ledger_leg: 'ecosystem', account: 'pool:ecosystem', to: 'coord', what: 'a metered call: the ecosystem’s part of the wholesale' }),
45
+ ]);
46
+ /** the legs a refund or a loss writes instead (the redirect record's own: seller_coord_buyer.redirect.refund_policy) */
47
+ export const ENDING_LEGS = Object.freeze(['refund', 'loss']);
48
+
49
+ /**
50
+ * Our fee, by the door the buyer bought through. These are the rules that already ran; none is new.
51
+ * wall a class wall (an x402 payment, a venue job that names a wall, an MCP wall tool): max(20 %, 0.002 USDC) of the wall's list
52
+ * price, rounded up, never above the price. The list price is seller_price + our_fee: what the buyer pays where no venue
53
+ * takes anything
54
+ * job_quote a job settled on the assurance hook: the answer of GET /v1/fees/quote (the site’s lib/job-fee: max(bps of the price,
55
+ * our gas + margin), at most the hook's 10 %), escrowed on top of the price. It needs live gas, so it comes in as units
56
+ * metered a metered call (RPC, GPU, TEE, forecast): no fee leg; the wholesale is split provider · graders · ecosystem
57
+ */
58
+ export const OUR_FEE = Object.freeze({
59
+ rules: Object.freeze({
60
+ wall: Object.freeze({ id: 'wall', door: 'a class wall: an x402 payment, a venue job that names a wall, an MCP wall tool', bps: 2000, min_units: 2000, min_units_of: 'a token of 6 decimals (USDC): 0.002', rounding: 'ceil', base: 'the list price (seller_price + our_fee): what the buyer pays where no venue takes anything', never_above: 'the list price',
61
+ code: 'automatch/payment-scheme.mjs ourFeeOf (pipeline/reseller/fold.mjs resaleTerms and the site’s lib/venue-targets call it)' }),
62
+ job_quote: Object.freeze({ id: 'job_quote', door: 'a job settled on the assurance hook (POST /v1/settle, a demand)', base: 'the job’s price', on_top: true,
63
+ code: 'site src/lib/job-fee.ts jobFee · GET /v1/fees/quote (it reads live gas: its answer comes in as units)' }),
64
+ metered: Object.freeze({ id: 'metered', door: 'a metered call paid from a key’s balance or an own wall', base: 'the wholesale', legs: Object.freeze(['provider', 'graders', 'ecosystem']),
65
+ code: 'site src/lib/usage-settle.ts usageLegs (TSUL_SPLIT_BPS)' }),
66
+ }),
67
+ });
68
+
69
+ // ── the per-venue facts ─────────────────────────────────────────────────────────────────────────────────────────────────────────
70
+ const ON_REFUND_ESCROW = Object.freeze({ venue_ending: 'returned', venue_ending_why: 'the venue takes its fee only on the paid ending: on a reject or an expiry the whole budget goes back to the client, no fee was taken', after_paid_ending: 'lost', after_paid_ending_why: 'a paid ending is final on the venue: a refund coord makes afterwards comes from coord’s own money, the venue keeps its fee' });
71
+ const ON_REFUND_NONE = Object.freeze({ venue_ending: 'none', venue_ending_why: 'the venue takes no fee and has no refund of its own', after_paid_ending: 'none', after_paid_ending_why: 'no venue fee was taken: nothing of it is lost or returned' });
72
+ // A venue's contract is named by its entry of the address registry (packages/addresses: system, chain, name), never by a
73
+ // literal here: the registry is the one place a contract address lives, and whoever needs the address resolves the reference
74
+ // (schemeBlock(facts, { addressOf })). A venue's own treasury is no registry contract: it is the third party's account, as its contract
75
+ // reads it (platformTreasury()), and the fork proof holds it to the chain on every run.
76
+ const E = 'standards-erc8183';
77
+ const ref = (chain, name) => Object.freeze({ system: E, chain, name });
78
+ const V3 = (chain) => ref(chain, 'Virtuals ACP v3 (ERC-8183)');
79
+ const V3_TREASURY = '0x3F833Be7447F82E8654Bc634981899db0ee8042E';
80
+ const part = (id, bps, to, { to_address = null, to_ref = null, when = 'always' } = {}) => Object.freeze({ part: id, bps, to, to_address, to_ref, when });
81
+ const escrow = ({ contract, chain, block, platform, evaluator, treasury, name, how = null }) => Object.freeze({
82
+ status: 'read', taken: 'at_source', rounding: 'floor', base: 'the job’s budget, as escrowed',
83
+ parts: Object.freeze([part('platform', platform, 'the venue’s platform treasury', { to_address: treasury }), part('evaluator', evaluator, 'the job’s evaluator (the address that completed the job; ours when our own evaluator seat completed it)', { when: 'evaluator_set' })]),
84
+ on_refund: platform + evaluator > 0 ? ON_REFUND_ESCROW : Object.freeze({ ...ON_REFUND_NONE, venue_ending_why: 'the venue reads 0 + 0: it takes nothing; on a reject or an expiry the whole budget goes back to the client' }),
85
+ evidence: Object.freeze({ contract, chain, name, reads: Object.freeze([`platformFeeBP() = ${platform}`, `evaluatorFeeBP() = ${evaluator}`, `platformTreasury() = ${treasury}`]), block, read_at: '2026-10-12',
86
+ how: how ?? `eth_call on chain ${chain} at block ${block}; automatch/escrow-job.fork.mjs asserts the reads and the amounts the contract moves on every run` }),
87
+ });
88
+ const olas = ({ chain, block }) => Object.freeze({
89
+ status: 'read', taken: 'at_source', rounding: 'ceil', base: 'the mech’s balance in the marketplace’s balance tracker when the mech withdraws it; for one request alone, its delivery rate',
90
+ parts: Object.freeze([part('platform', 1500, 'the marketplace’s balance tracker (collectedFees, drained by the Olas DAO’s drainer)', { to_ref: ref(chain, 'Olas balance tracker (native)') })]),
91
+ on_refund: Object.freeze({ venue_ending: 'returned', venue_ending_why: 'the fee is charged on what a mech earned, when it withdraws: a request no mech delivered earns nothing, so no fee is taken', after_paid_ending: 'lost', after_paid_ending_why: 'a delivered request is final on the marketplace: a refund coord makes afterwards comes from coord’s own money' }),
92
+ evidence: Object.freeze({ contract: ref(chain, 'Olas Mech Marketplace'), chain, name: 'Olas Mech Marketplace', reads: Object.freeze(['fee() = 1500', 'MAX_FEE_FACTOR() = 10000']), block, read_at: '2026-10-12',
93
+ how: chain === 8453 ? `eth_call on chain ${chain} at block ${block}; the rounding and the base were measured on a fork of Base at block 52515643 (processPaymentByMultisig on the native balance tracker: a balance of 100 pays the mech 85 and adds 15 to collectedFees; 133 → fee 20; 7 → fee 2; 10001 → fee 1501); automatch/olas-out.fork.mjs asserts it on every run`
94
+ : `eth_call on chain ${chain} at block ${block}; the rounding is the Base deployment’s (the same marketplace contract), not measured on this chain` }),
95
+ });
96
+ const X402_NONE = (network) => Object.freeze({ status: 'none', taken: null, rounding: 'floor', base: 'the payment', parts: Object.freeze([]), on_refund: ON_REFUND_NONE,
97
+ evidence: Object.freeze({ contract: null, chain: network, name: 'x402 exact scheme', reads: Object.freeze([]), block: null, read_at: '2026-10-12',
98
+ how: `the exact scheme has no fee step: the settle transaction moves accepts[].amount whole to payTo (EIP-3009 transferWithAuthorization; an SPL transfer on Solana). ${network === 'eip155:8453' ? 'On the chain itself: the wall sale settled in 0x0c7b6a48271047776138afc83a605e095b908e2e79f445423419d74b291644dd (Base block 52501615) is ONE USDC Transfer of 11667 from the payer to the wall’s payTo, the amount the sale row names' : 'Measured on Base (one settle transaction read); on this network it is the scheme’s own rule, no settle transaction of a wall was read here'}. A facilitator bills its own customer apart from the payment; that bill is not read` }) });
99
+ const WIRE_NONE = Object.freeze({ status: 'none', taken: null, rounding: 'floor', base: 'none', parts: Object.freeze([]), on_refund: ON_REFUND_NONE,
100
+ evidence: Object.freeze({ contract: null, chain: null, name: 'no payment step', reads: Object.freeze([]), block: null, read_at: '2026-10-12', how: 'the protocol has no payment step: a purchase through it is paid on one of the layer’s own doors (a class wall’s x402 payment, the assurance hook), named in the adapter’s settle.doors' }) });
101
+
102
+ /**
103
+ * What each venue of the standard takes, as read on its chain on 2026-10-12. `status`: read (a contract states it) · none (the venue has
104
+ * no fee step). `taken`: at_source (out of the money on the venue's own side, before the payee is paid) · from_payment (coord pays it
105
+ * out of what it received) · null (nothing is taken). `parts[].when`: evaluator_set = only for a job that names an evaluator.
106
+ */
107
+ export const VENUE_FEES = Object.freeze({
108
+ 'x402-base': X402_NONE('eip155:8453'), 'x402-solana': X402_NONE('solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'), 'x402-arbitrum': X402_NONE('eip155:42161'), 'x402-robinhood': X402_NONE('eip155:4663'), 'x402-monad': X402_NONE('eip155:143'),
109
+ 'erc8183-base': escrow({ contract: V3(8453), chain: 8453, block: 52515498, platform: 500, evaluator: 500, treasury: V3_TREASURY, name: 'Virtuals ACP v3 (ERC-8183)',
110
+ how: 'eth_call on chain 8453 at block 52515498; automatch/escrow-job.fork.mjs asserts the reads and the amounts the contract moves on every run; on the chain itself: job erc8183:8453:81734, budget 2222, completed in 0x4764bd2af1bce296eb29328fa519bae5a30ad7908b592f780b655b5c515b46b9 (111 to the treasury, 111 to the evaluator, 2000 to the provider)' }),
111
+ 'memoacp-base': escrow({ contract: ref(8453, 'memo-ACP payment manager'), chain: 8453, block: 52515498, platform: 2000, evaluator: 0, treasury: '0xE9683559A1177A83825A42357a94F61b26cd64C1', name: 'Virtuals memo-ACP PaymentManager' }),
112
+ 'acpv3-arc': escrow({ contract: V3(5042), chain: 5042, block: 25606479, platform: 500, evaluator: 500, treasury: V3_TREASURY, name: 'Virtuals ACP v3 (ERC-8183)', how: 'eth_call on chain 5042 at block 25606479; no job of ours has run on this chain, so the amounts are the Base deployment’s rule (the same contract address), not measured here' }),
113
+ 'acpv3-robinhood': escrow({ contract: V3(4663), chain: 4663, block: 86795902, platform: 500, evaluator: 500, treasury: V3_TREASURY, name: 'Virtuals ACP v3 (ERC-8183)', how: 'eth_call on chain 4663 at block 86795902; no job of ours has run on this chain, so the amounts are the Base deployment’s rule (the same contract address), not measured here' }),
114
+ 'bitagent-base': escrow({ contract: ref(8453, 'BitAgent ERC-8183 escrow'), chain: 8453, block: 52515498, platform: 0, evaluator: 0, treasury: '0xF0A45416394ce78F18aC4CE8AE6c6fF8Cfb4455f', name: 'BitAgent ERC-8183 escrow' }),
115
+ 'olas-gnosis': olas({ chain: 100, block: 48720836 }),
116
+ 'olas-polygon': olas({ chain: 137, block: 95410212 }),
117
+ 'olas-base': olas({ chain: 8453, block: 52515630 }),
118
+ mcp: WIRE_NONE, a2a: WIRE_NONE, erc8004: WIRE_NONE, n8n: WIRE_NONE,
119
+ // ── venues the one resolver walks that are NO adapter of the standard (`adapter: false`): a sibling of a family, declared here so its
120
+ // jobs are booked by the same scheme; it becomes an adapter's entry when the standard gains the adapter ──────────────────────────────
121
+ 'aqueous-monad': Object.freeze({ status: 'none', adapter: false, taken: null, rounding: 'floor', base: 'the amount the buyer settles', parts: Object.freeze([]),
122
+ on_refund: Object.freeze({ ...ON_REFUND_NONE, venue_ending_why: 'the escrow takes nothing: the buyer settles what it accepts and the rest is returned in the same transaction; an undelivered job is refunded whole after its deadline' }),
123
+ evidence: Object.freeze({ contract: null, chain: 143, name: 'Aqueous escrow on Monad (an outside developer’s contract; its address is automatch/escrow-sig.venues.json aqueous-monad.escrow, not in the address registry yet)', reads: Object.freeze([]), block: 112798206, read_at: '2026-10-12',
124
+ how: 'settleMetered pays the agent units × pricePerUnit and returns the rest, with no fee: on a fork of Monad at block 112798206 a job of 10000 paid the agent 10000 and returned 0 (automatch/fixtures/escrow-sig-fork-proof-2026-10-12.json, scenario metered.pass); automatch/escrow-sig.fork.mjs asserts it on every run. FORK-ONLY: nothing of ours was sent on Monad. Not an adapter of the standard: the signed-escrow sibling of the escrow-job family (automatch/escrow-sig.mjs), job.out only' }) }),
125
+ });
126
+
127
+ // ── the arithmetic ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
128
+ const whole = (v) => { try { if (typeof v === 'bigint') return v >= 0n ? v : null; if (typeof v === 'number') return Number.isSafeInteger(v) && v >= 0 ? BigInt(v) : null; if (typeof v === 'string' && /^\d{1,78}$/.test(v)) return BigInt(v); } catch { /* not a whole amount */ } return null; };
129
+ const factsOf = (venue, facts = VENUE_FEES) => {
130
+ if (OWN_VENUES.includes(venue)) return null;
131
+ const f = facts[venue];
132
+ if (!f) throw new Error(`venue ${venue} has no payment_scheme entry: a venue is quoted and booked only when its fee is declared (automatch/payment-scheme.mjs VENUE_FEES)`);
133
+ return f;
134
+ };
135
+ const feeOfBps = (base, bps, rounding) => (rounding === 'ceil' ? (base * BigInt(bps) + (BPS - 1n)) / BPS : (base * BigInt(bps)) / BPS);
136
+
137
+ /**
138
+ * What a venue takes of `base` (the amount that enters it): { venue, base, total, net, parts: [{ part, bps, units, to, to_address }],
139
+ * taken, rounding }. `o.evaluator_set` false: the job names no evaluator, so no evaluator part. `o.as_read`: { platform_bps,
140
+ * evaluator_bps } as they were read for this one job (a venue may change its fees; the declared ones are the default). Throws on a
141
+ * venue with no entry and on fees that are not a share of the base. Pure.
142
+ */
143
+ export function venueFeeOf(venue, base, o = {}) {
144
+ const B = whole(base); if (B === null) throw new Error(`the base of a venue fee is a whole amount, not ${String(base)}`);
145
+ const f = factsOf(venue, o.facts);
146
+ if (!f) return { venue, base: B, total: 0n, net: B, parts: [], taken: null, rounding: 'floor' };
147
+ const parts = [];
148
+ for (const p of f.parts) {
149
+ if (p.when === 'evaluator_set' && o.evaluator_set === false) continue;
150
+ const read = o.as_read ? o.as_read[`${p.part}_bps`] : undefined;
151
+ const bps = read === undefined || read === null ? p.bps : typeof read === 'number' ? read : typeof read === 'bigint' || (typeof read === 'string' && /^\d{1,5}$/.test(read)) ? Number(read) : NaN; // as read: a number or a string of digits, never a guess
152
+ if (!Number.isInteger(bps) || bps < 0 || bps > 10_000) throw new Error(`venue ${venue}: ${p.part} fee of ${String(read ?? p.bps)} bps is not a share of the base`);
153
+ if (bps === 0) continue; // a part the venue reads as zero takes nothing: it is no leg
154
+ parts.push({ part: p.part, bps, units: feeOfBps(B, bps, f.rounding).toString(), to: p.to, to_address: p.to_address, to_ref: p.to_ref });
155
+ }
156
+ const total = parts.reduce((a, p) => a + BigInt(p.units), 0n);
157
+ if (parts.reduce((a, p) => a + p.bps, 0) > 10_000 || total > B) throw new Error(`venue ${venue}: fees of ${parts.map((p) => p.bps).join(' + ')} bps are not a share of the base`);
158
+ return { venue, base: B, total, net: B - total, parts, taken: parts.length ? f.taken : null, rounding: f.rounding };
159
+ }
160
+
161
+ /**
162
+ * The gross-up: the smallest amount that must enter `venue` so that `net` is left after the venue's fee (the doer still receives its
163
+ * price; a wall's list price still reaches us). { venue, net, gross, fee } with fee = venueFeeOf(venue, gross). Pure.
164
+ */
165
+ export function grossUp(venue, net, o = {}) {
166
+ const N = whole(net); if (N === null) throw new Error(`a price is a whole amount, not ${String(net)}`);
167
+ const f = factsOf(venue, o.facts);
168
+ if (!f) return { venue, net: N, gross: N, fee: venueFeeOf(venue, N, o) };
169
+ const cut = BigInt(venueFeeOf(venue, BPS, o).parts.reduce((a, p) => a + p.bps, 0));
170
+ if (cut >= BPS) throw new Error(`venue ${venue}: its fees leave the payee nothing`);
171
+ // each part is rounded on its own, so the net is not gross·(1 − cut) exactly: start just under the estimate and walk up
172
+ let G = N > 2n ? ((N - 2n) * BPS) / (BPS - cut) : 0n;
173
+ if (G < N) G = N;
174
+ let fee = venueFeeOf(venue, G, o);
175
+ while (fee.net < N) { G += 1n; fee = venueFeeOf(venue, G, o); }
176
+ return { venue, net: N, gross: G, fee };
177
+ }
178
+
179
+ /** Our fee by a rule of OUR_FEE on `base` (wall: the list price; job_quote: the quote's own units). Throws on a rule that is not one. Pure. */
180
+ export function ourFeeOf(fee, base) {
181
+ const B = whole(base); if (B === null) throw new Error(`the base of our fee is a whole amount, not ${String(base)}`);
182
+ const id = fee?.rule;
183
+ if (id === 'wall') { const r = OUR_FEE.rules.wall; const pct = feeOfBps(B, r.bps, r.rounding); const f = pct > BigInt(r.min_units) ? pct : BigInt(r.min_units); return f > B ? B : f; }
184
+ if (id === 'job_quote') { const u = whole(fee.units); if (u === null) throw new Error('the hook’s fee is the answer of the fee quote (GET /v1/fees/quote), in whole units: there is no default here'); return u; }
185
+ if (id === 'metered' || id === 'none') return 0n;
186
+ throw new Error(`${String(id)} is not a fee rule of the scheme (${Object.keys(OUR_FEE.rules).join(' · ')})`);
187
+ }
188
+ /** The list price of a seller price under a fee rule: the smallest price whose fee leaves the seller its price (what the buyer pays where no venue takes anything). Pure. */
189
+ export function listPriceOf(fee, sellerPrice) {
190
+ const S = whole(sellerPrice); if (S === null) throw new Error(`a seller price is a whole amount, not ${String(sellerPrice)}`);
191
+ if (fee?.rule !== 'wall') return S + ourFeeOf(fee, S);
192
+ const r = OUR_FEE.rules.wall; const min = BigInt(r.min_units);
193
+ // a price of zero (our own product, nothing owed outside) lists at the fee's floor
194
+ let L = S + min; if (ourFeeOf(fee, L) <= min) return L;
195
+ L = (S * BPS) / (BPS - BigInt(r.bps)); if (L < S + min) L = S + min;
196
+ while (L - ourFeeOf(fee, L) < S) L += 1n;
197
+ while (L > S + min && L - 1n - ourFeeOf(fee, L - 1n) >= S) L -= 1n;
198
+ return L;
199
+ }
200
+
201
+ const mk = (leg, units, o = {}) => ({ leg, ledger_leg: leg === 'our_fee' ? 'fee' : leg, units: units.toString(), side: o.side ?? null, venue: o.venue ?? null, part: o.part ?? null, bps: o.bps ?? null, to: o.to ?? null, to_address: o.to_address ?? null, to_ref: o.to_ref ?? null, taken: o.taken ?? null });
202
+ const feeLegs = (side, f) => f.parts.map((p) => mk('venue_fee', BigInt(p.units), { side, venue: f.venue, part: p.part, bps: p.bps, to: p.to, to_address: p.to_address, to_ref: p.to_ref ?? null, taken: f.taken }));
203
+ /** Σ of a leg list, in units. Pure. */
204
+ export const sumOf = (legs) => (legs ?? []).reduce((a, l) => a + BigInt(l.units), 0n);
205
+ const markupOf = (reseller, list) => { if (!reseller) return 0n; if (reseller.markup_units !== undefined && reseller.markup_units !== null) { const u = whole(reseller.markup_units); if (u === null) throw new Error('a reseller’s markup is a whole amount'); return u; } const b = Number(reseller.markup_bps ?? 0); if (!Number.isInteger(b) || b < 0 || b > 10_000) throw new Error('a reseller’s markup is 0 to 10000 bps of the list price'); return (list * BigInt(b)) / BPS; };
206
+
207
+ /**
208
+ * THE QUOTE. What a buyer on `venue_in` pays for a seller on `venue_out` whose price is `seller_price` (whole units of the payment's
209
+ * token), and the legs that payment leaves as. One formula for every pair:
210
+ *
211
+ * list = seller_price + our_fee our fee by the door's rule, on the list price: it does not depend on a venue
212
+ * out = grossUp(venue_out, seller_price) what must enter the selling venue so the doer receives its price
213
+ * net_in = list + venue_fee(out) + reseller_markup what must reach coord
214
+ * price_to_buyer = grossUp(venue_in, net_in) what the buyer pays, the buying venue's fee on top
215
+ *
216
+ * `o`: { venue_in, venue_out, class, seller_price, reseller?: { tenant, markup_bps | markup_units }, our_fee?: { rule: 'wall' } |
217
+ * { rule: 'job_quote', units }, evaluator_set_in?, evaluator_set_out?, facts? }. Returns { ok, price_to_buyer, list_units, legs[] }
218
+ * or { ok: false, why }. Pure.
219
+ */
220
+ export function quoteSale(o = {}) {
221
+ try {
222
+ const S = whole(o.seller_price); if (S === null) return { ok: false, why: 'the seller’s price is a whole, non-negative amount in the payment’s smallest unit' };
223
+ const fee = o.our_fee ?? { rule: 'wall' };
224
+ const list = listPriceOf(fee, S); const ourFee = list - S;
225
+ const out = grossUp(o.venue_out, S, { facts: o.facts, evaluator_set: o.evaluator_set_out });
226
+ const markup = markupOf(o.reseller ?? null, list);
227
+ const netIn = list + out.fee.total + markup;
228
+ const inn = grossUp(o.venue_in, netIn, { facts: o.facts, evaluator_set: o.evaluator_set_in });
229
+ const legs = [mk('our_fee', ourFee, { to: 'coord' }), ...feeLegs('in', inn.fee), ...feeLegs('out', out.fee), mk('seller_share', S, { venue: o.venue_out, to: 'the doer' }), mk('reseller_markup', markup, { to: o.reseller?.tenant ?? null })];
230
+ const price = inn.gross;
231
+ if (sumOf(legs) !== price) return { ok: false, why: `the legs sum to ${sumOf(legs)}, the price is ${price}: nothing is quoted` };
232
+ return { ok: true, schema: 'taifoon.payment.quote.v1', rule: RULE, formula: FORMULA, venue_in: o.venue_in, venue_out: o.venue_out, class: o.class ?? null, seller_price: S.toString(), fee_rule: fee.rule,
233
+ list_units: list.toString(), out_units: out.gross.toString(), net_in_units: netIn.toString(), price_to_buyer: price.toString(), legs,
234
+ venue_fee: { in: { venue: o.venue_in, units: inn.fee.total.toString(), taken: inn.fee.taken }, out: { venue: o.venue_out, units: out.fee.total.toString(), taken: out.fee.taken } } };
235
+ } catch (e) { return { ok: false, why: String(e?.message ?? e) }; }
236
+ }
237
+
238
+ /**
239
+ * THE LEGS OF ONE PAYMENT. `p`:
240
+ * venue_in, venue_out where the buyer paid, where the seller was hired (a venue of the standard, or coord · grid · reseller · devnet)
241
+ * paid_units what the buyer put in: the wall's payment, the budget escrowed on the buying venue
242
+ * out_units what coord owes on the selling side, the selling venue's fee included (the wall's share, the budget coord
243
+ * funds, the doer's price a stand-in forwards); 0 when our own product served
244
+ * reseller { tenant, markup_units } when a reseller's child bought
245
+ * lost_units paid ahead to a seller whose answer then failed (ours to bear, inside the payment)
246
+ * ending paid (default) · venue_refund (the buying venue's own refund: everything goes back, no fee was taken) ·
247
+ * share_refund (a rejection before the share was sent: our fee stays, the share goes back)
248
+ * out_direct true when coord pays the doer itself (a transfer from the vault, a stand-in's forward): the money never
249
+ * enters the selling venue, so that venue takes nothing of it
250
+ * our_fee { rule } to check the fee against the rule (fee_rule_ok: reported, never enforced here); the fee itself is what is left
251
+ * observed { in | out: { provider, evaluator } } what the venue itself paid (the job's own events): it stands over the bps
252
+ * as_read_in/out { platform_bps, evaluator_bps } as read for this one job; evaluator_set_in/out
253
+ * Returns { ok, legs[], sum_ok, fee_rule_ok, net_in_units, fees_as } or { ok: false, why }. Σ legs = paid_units, to the unit. Pure.
254
+ */
255
+ export function legsOfPayment(p = {}) {
256
+ try {
257
+ const P = whole(p.paid_units); const G = whole(p.out_units ?? 0); const lost = whole(p.lost_units ?? 0);
258
+ if (P === null || G === null || lost === null) return { ok: false, why: 'the payment, what is owed on the selling side and what was lost are whole amounts' };
259
+ const ending = p.ending ?? 'paid';
260
+ const policy = (v) => (OWN_VENUES.includes(v) ? null : factsOf(v, p.facts).on_refund);
261
+ if (ending === 'venue_refund') {
262
+ const legs = [mk('refund', P, { to: 'the buyer' })];
263
+ return { ok: true, rule: RULE, ending, legs, sum_ok: sumOf(legs) === P, fee_rule_ok: null, net_in_units: '0', fees_as: 'no fee was taken', venue_fee_on_refund: (policy(p.venue_in) ?? policy(p.venue_out))?.venue_ending ?? 'none' };
264
+ }
265
+ if (!['paid', 'share_refund'].includes(ending)) return { ok: false, why: `${String(ending)} is not an ending of the scheme (paid · venue_refund · share_refund)` };
266
+ let fees_as = 'the venue’s fees as declared';
267
+ const side = (venue, base, obs, as_read, evaluator_set) => {
268
+ const f = venueFeeOf(venue, base, { facts: p.facts, as_read, evaluator_set });
269
+ if (as_read) fees_as = 'the venue’s fees as read on chain';
270
+ const pv = whole(obs?.provider ?? null); const ev = whole(obs?.evaluator ?? 0) ?? 0n;
271
+ // a venue that declares no fee part has nothing an observed amount could be booked as: the declared answer (nothing taken) stands
272
+ if (pv === null || OWN_VENUES.includes(venue) || pv + ev > base || !factsOf(venue, p.facts).parts.some((x) => x.part === 'platform')) return f;
273
+ // what the venue itself paid stands over the fees as they were read: the platform part is what neither the payee nor the evaluator received
274
+ // (a venue with no evaluator part keeps everything the payee did not receive as its one part)
275
+ const names = Object.fromEntries(factsOf(venue, p.facts).parts.map((x) => [x.part, x])); const evPart = names.evaluator ? ev : 0n;
276
+ const parts = [{ part: 'platform', units: (base - pv - evPart).toString() }, { part: 'evaluator', units: evPart.toString() }].filter((x) => names[x.part]).map((x) => ({ ...x, bps: null, to: names[x.part].to, to_address: names[x.part].to_address, to_ref: names[x.part].to_ref }));
277
+ fees_as = 'the amounts the venue paid (the job’s own events)';
278
+ return { ...f, total: base - pv, net: pv, parts, taken: f.taken ?? factsOf(venue, p.facts).taken };
279
+ };
280
+ const fin = side(p.venue_in, P, p.observed?.in, p.as_read_in, p.evaluator_set_in);
281
+ const netIn = fin.net;
282
+ if (p.reseller && (p.reseller.markup_units === undefined || p.reseller.markup_units === null) && p.reseller.markup_bps) return { ok: false, why: 'the legs of a payment take a reseller’s markup in units (markup_units): a share of the list price is a quote’s input (quoteSale)' };
283
+ const markup = markupOf(p.reseller ?? null, 0n);
284
+ if (G + markup + lost > netIn) return { ok: false, why: `what is owed on the selling side (${G}), the markup (${markup}) and what was lost (${lost}) are above what reached coord (${netIn}): a sale is never made at a loss` };
285
+ const ourFee = netIn - markup - G - lost;
286
+ const fout = ending === 'share_refund' || p.out_direct === true ? venueFeeOf('coord', G) : side(p.venue_out, G, p.observed?.out, p.as_read_out, p.evaluator_set_out);
287
+ const legs = [mk('our_fee', ourFee, { to: 'coord' }), ...feeLegs('in', fin), ...feeLegs('out', fout),
288
+ ending === 'share_refund' ? mk('refund', G, { to: 'the buyer' }) : mk('seller_share', fout.net, { venue: p.venue_out, to: 'the doer' }),
289
+ mk('reseller_markup', markup, { to: p.reseller?.tenant ?? null }), mk('loss', lost, { to: 'sellers whose paid answer failed' })];
290
+ // the rule's answer, on the list price this payment stands for (our fee + what the doer receives)
291
+ const fee_rule_ok = p.our_fee?.rule ? ourFee === ourFeeOf(p.our_fee, p.our_fee.rule === 'wall' ? ourFee + fout.net : fout.net) : null;
292
+ return { ok: true, rule: RULE, ending, venue_in: p.venue_in, venue_out: p.venue_out, paid_units: P.toString(), net_in_units: netIn.toString(), out_units: G.toString(), legs, sum_ok: sumOf(legs) === P, fee_rule_ok, fees_as,
293
+ venue_fee: { in: { venue: p.venue_in, units: fin.total.toString(), taken: fin.taken }, out: { venue: p.venue_out, units: fout.total.toString(), taken: fout.taken } } };
294
+ } catch (e) { return { ok: false, why: String(e?.message ?? e) }; }
295
+ }
296
+
297
+ /** The pairs the adapters of the standard declare possible: a venue whose job.in is LIVE (a buyer can buy there) × a venue whose
298
+ * job.out is LIVE (a seller is hired there), plus our own product as the selling side. `adapters` = seller_coord_buyer.adapters. Pure. */
299
+ export function pairsOf(adapters) {
300
+ const ins = (adapters ?? []).filter((a) => a.transforms?.['job.in']?.state === 'LIVE').map((a) => a.venue);
301
+ const outs = [...(adapters ?? []).filter((a) => a.transforms?.['job.out']?.state === 'LIVE').map((a) => a.venue), 'coord'];
302
+ return ins.flatMap((venue_in) => outs.map((venue_out) => ({ venue_in, venue_out })));
303
+ }
304
+
305
+ /** What the scheme lacks for a list of adapters: the venues with no entry, and the entries that are no adapter. An adapter of the
306
+ * standard without an entry fails the build of the standard and the conformance suite. Pure. */
307
+ export function schemeGaps(adapters, facts = VENUE_FEES) {
308
+ const venues = (adapters ?? []).map((a) => a.venue); const entries = Object.keys(facts);
309
+ // (an entry marked `adapter: false` is a venue the resolver walks that the standard has no adapter for yet: declared, and not a gap)
310
+ return { missing: venues.filter((v) => !entries.includes(v)), extra: entries.filter((v) => !venues.includes(v) && facts[v].adapter !== false) };
311
+ }
312
+
313
+ /** The table of what each venue takes: one row per venue, derived from the facts (the master's and the stream's fee table). Pure. */
314
+ export function venueFeeTable(facts = VENUE_FEES, { addressOf = null } = {}) {
315
+ return Object.entries(facts).map(([venue, f]) => ({ venue, status: f.status, ...(f.adapter === false ? { adapter: false } : {}), platform_bps: f.parts.find((p) => p.part === 'platform')?.bps ?? 0, evaluator_bps: f.parts.find((p) => p.part === 'evaluator')?.bps ?? 0,
316
+ total_bps: f.parts.reduce((a, p) => a + p.bps, 0), taken: f.parts.some((p) => p.bps > 0) ? f.taken : null, rounding: f.rounding, to: f.parts.filter((p) => p.bps > 0).map((p) => `${p.part}: ${p.to}`).join('; ') || null,
317
+ on_refund: f.on_refund.venue_ending, after_paid_ending: f.on_refund.after_paid_ending, contract: f.evidence.contract && addressOf ? addressOf(f.evidence.contract) : null, contract_ref: f.evidence.contract, chain: f.evidence.chain, block: f.evidence.block,
318
+ // 10000 units through the venue, both ways: what a payee nets of 10000, and what must enter for the payee to net 10000
319
+ net_of_10000: venueFeeOf(venue, 10_000n, { facts }).net.toString(), gross_for_10000: grossUp(venue, 10_000n, { facts }).gross.toString() }));
320
+ }
321
+
322
+ /** The ONE declared block (schemas/transitions.json seller_coord_buyer.payment_scheme): the legs, the formula, the fee rules, the
323
+ * per-venue facts with their evidence, the gross-up, what a refund does to a venue's fee, and the invariant. `addressOf(ref)` resolves
324
+ * a registry reference { system, chain, name } to its address (the generator passes the address registry's reader; without one the
325
+ * block carries the references alone). Deterministic. Pure. */
326
+ export function schemeBlock(facts = VENUE_FEES, { addressOf = null } = {}) {
327
+ const at = (r) => (r && addressOf ? addressOf(r) : null);
328
+ return {
329
+ id: SCHEME_ID, rule_id: RULE,
330
+ what: 'ONE payment scheme for every sale the layer makes as seller of record, whatever the venue the buyer buys on (venue_in) and the venue the seller is hired on (venue_out): the buyer pays coord once, under one derived sale key; what it paid leaves again as named legs in whole units, and the legs sum to the payment exactly. Each venue adapter maps its own rail INTO this scheme; no venue has a scheme of its own',
331
+ formula: FORMULA,
332
+ terms: { price_to_buyer: 'what the buyer pays on the buying venue', seller_price: 'what the doer receives on a paid ending: the class price, or the seller’s own price', our_fee: 'coord’s fee by the door’s rule; it does not depend on a venue', 'venue_fee(in)': 'what the buying venue takes of the buyer’s payment', 'venue_fee(out)': 'what the selling venue takes of what coord pays into it', reseller_markup: 'a reseller tenant’s leg, when its child bought' },
333
+ legs: LEGS.map((l) => ({ ...l, ...(l.sides ? { sides: [...l.sides] } : {}) })),
334
+ ending_legs: [...ENDING_LEGS],
335
+ our_fee: { rules: Object.values(OUR_FEE.rules).map((r) => ({ ...r, ...(r.legs ? { legs: [...r.legs] } : {}) })), note: 'these are the rules that already ran, by the door the buyer bought through; the scheme adds none. Our fee never contains a venue’s fee' },
336
+ venue_fee: {
337
+ rule: 'the venue’s own basis points on its own base, each part rounded as its contract rounds; its own leg (`venue_fee`), its own ledger account (fee:venue:<venue>) and its own metric series (coord_sale_units_total{leg="venue_fee"}); never part of our fee or of a reseller’s markup',
338
+ taken: { at_source: 'the venue takes it out of the money on its own side before the payee is paid (an escrow’s budget, a mech’s balance): the amount that enters the venue is grossed up for it', from_payment: 'coord pays it out of what it received (no venue of the standard does today)' },
339
+ by_venue: Object.fromEntries(Object.entries(facts).map(([venue, f]) => [venue, { status: f.status, ...(f.adapter === false ? { adapter: false } : {}), total_bps: f.parts.reduce((a, p) => a + p.bps, 0), parts: f.parts.map((p) => ({ ...p, to_address: p.to_address ?? at(p.to_ref) })), base: f.base, rounding: f.rounding, taken: f.parts.some((p) => p.bps > 0) ? f.taken : null,
340
+ on_refund: { ...f.on_refund }, evidence: { ...f.evidence, contract: at(f.evidence.contract), contract_ref: f.evidence.contract, reads: [...f.evidence.reads] } }])),
341
+ table: venueFeeTable(facts, { addressOf }),
342
+ },
343
+ gross_up: { rule: 'where a venue takes its fee at the source, the amount that enters it is the smallest one whose net is the price wanted: on the selling side the doer still receives its price, on the buying side the list price still reaches coord, and our fee is the same as on a venue that takes nothing',
344
+ steps: ['list = seller_price + our_fee', 'out = grossUp(venue_out, seller_price)', 'net_in = list + venue_fee(out) + reseller_markup', 'price_to_buyer = grossUp(venue_in, net_in)'] },
345
+ refund: { rule: 'refunds follow the redirect’s refund policy per mode (seller_coord_buyer.redirect.refund_policy), unchanged; each venue states what happens to its fee', venue_ending: 'the venue’s own refund ending (a reject, an expiry): by_venue[].on_refund.venue_ending', after_paid_ending: 'a refund coord makes after a paid ending: by_venue[].on_refund.after_paid_ending' },
346
+ invariant: 'Σ legs = the payment, to the smallest unit, for every pair of venues and every ending; our_fee is the rule’s answer; venue_fee is the venue’s declared basis points on the declared base; on a paid ending the seller receives exactly seller_price',
347
+ modes: 'the scheme does not depend on the redirect mode (forward · share · period · markup) or on a release condition: those say WHEN and HOW a leg is sent, the scheme says WHICH legs a payment has',
348
+ code: { repo: 'layer', path: 'automatch/payment-scheme.mjs', what: 'quoteSale({ venue_in, venue_out, class, seller_price, reseller? }) → { price_to_buyer, legs[] } · legsOfPayment(payment) → legs[] · venueFeeOf · grossUp · ourFeeOf', vendored: 'site src/lib/payment-scheme.mjs (byte-identical, sha256 pinned)' },
349
+ tests: { unit: 'automatch/payment-scheme.test.mjs', conformance: 'harvesters/conformance/payment-scheme.test.mjs (every adapter of the standard; an adapter without an entry fails it)', fork: 'automatch/escrow-job.fork.mjs (ERC-8183, the memo router, BitAgent) · automatch/olas-out.fork.mjs (the Olas marketplace): the amounts the contracts move equal the scheme’s legs' },
350
+ };
351
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "about": "a byte-identical copy of the coordination layer’s ONE payment scheme (packages/resale/core/payment-scheme.mjs, ONE_PAYMENT_SCHEME_v1); do not edit, re-sync it with npm run sync",
3
+ "source": "the coordination layer: packages/resale/core/payment-scheme.mjs",
4
+ "commit": "51d42de7",
5
+ "sha256": "f34a6eb7830089d11c0b22850e4cbb299000b08e44e4eb0f4ad8df4456a08020"
6
+ }
@@ -0,0 +1,24 @@
1
+ export declare const BASE_CHAIN_ID: 8453;
2
+ export type RpcNeed = 'call' | 'logs';
3
+ export interface BaseReader {
4
+ readonly chainId: typeof BASE_CHAIN_ID;
5
+ /** the endpoints this reader would try, best first */
6
+ urls(need?: RpcNeed): Promise<string[]>;
7
+ /** one JSON-RPC call; `need: 'logs'` picks endpoints proven to serve eth_getLogs windows */
8
+ call<T = unknown>(method: string, params: readonly unknown[], need?: RpcNeed): Promise<T>;
9
+ }
10
+ export declare class RpcReverted extends Error {
11
+ readonly data: string | null;
12
+ name: string;
13
+ constructor(message: string, data: string | null);
14
+ }
15
+ /** A Base reader over warmbed's rotation (default), or over the endpoints you name. */
16
+ export declare function baseReader(o?: {
17
+ urls?: readonly string[];
18
+ fetch?: typeof fetch;
19
+ timeoutMs?: number;
20
+ warmbed?: boolean;
21
+ }): BaseReader;
22
+ /** eth_call on Base: the return data, or RpcReverted with the revert data */
23
+ export declare const ethCall: (r: BaseReader, to: string, data: string, block?: string) => Promise<string>;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,aAAa,EAAG,IAAa,CAAC;AAC3C,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACtC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,aAAa,CAAC;IACvC,sDAAsD;IACtD,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,4FAA4F;IAC5F,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC3F;AACD,qBAAa,WAAY,SAAQ,KAAK;IAA+D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAA/E,IAAI,SAAiB;IAAC,YAAY,OAAO,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM,GAAG,IAAI,EAAqB;CAAE;AAKxJ,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,CAAC,GAAE;IAAE,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,UAAU,CA8BxI;AAED,6EAA6E;AAC7E,eAAO,MAAM,OAAO,MAAO,UAAU,MAAM,MAAM,QAAQ,MAAM,UAAS,MAAM,KAAc,OAAO,CAAC,MAAM,CAAsD,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @moonbeam-foundation/sdk/rpc: one injectable Base reader. By default it walks warmbed's measured rotation of Base
3
+ * endpoints (the same reader @taifoon/jev uses: warmbed first, then a static fallback list), so a rate-limited or
4
+ * range-capped public endpoint moves the call to the next one instead of failing it. A revert is an answer and is
5
+ * thrown at once. BASE_RPC (a comma list) or `urls` goes first. Reads only: nothing here signs or sends.
6
+ */
7
+ import { rpcRotation } from '@taifoon/jev';
8
+ export const BASE_CHAIN_ID = 8453;
9
+ export class RpcReverted extends Error {
10
+ data;
11
+ name = 'RpcReverted';
12
+ constructor(message, data) {
13
+ super(message);
14
+ this.data = data;
15
+ }
16
+ }
17
+ const REVERT = /revert|invalid opcode|out of gas/i;
18
+ const env = (k) => (typeof process !== 'undefined' ? process.env[k] : undefined);
19
+ /** A Base reader over warmbed's rotation (default), or over the endpoints you name. */
20
+ export function baseReader(o = {}) {
21
+ const f = o.fetch ?? fetch;
22
+ const pinned = [...(o.urls ?? []), ...String(env('BASE_RPC') ?? '').split(',').map((s) => s.trim()).filter(Boolean)];
23
+ const urls = async (need = 'call') => [...new Set([...pinned, ...(o.warmbed === false ? [] : await rpcRotation(BASE_CHAIN_ID, f, need))])];
24
+ return {
25
+ chainId: BASE_CHAIN_ID,
26
+ urls,
27
+ async call(method, params, need = 'call') {
28
+ const list = await urls(need);
29
+ if (!list.length)
30
+ throw new Error(`${method}: no Base endpoint (warmbed silent and none named)`);
31
+ let last = '';
32
+ for (const u of list) {
33
+ try {
34
+ const r = await f(u, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }), signal: AbortSignal.timeout(o.timeoutMs ?? 20_000) });
35
+ if (r.status >= 400) {
36
+ last = `${new URL(u).host}: http ${r.status}`;
37
+ continue;
38
+ }
39
+ const j = (await r.json());
40
+ if (j.error) {
41
+ const msg = String(j.error.message ?? j.error.code);
42
+ if (j.error.code === 3 || REVERT.test(msg))
43
+ throw new RpcReverted(`${method}: ${msg}`, typeof j.error.data === 'string' ? j.error.data : null);
44
+ last = `${new URL(u).host}: ${msg.slice(0, 160)}`;
45
+ continue;
46
+ }
47
+ return j.result;
48
+ }
49
+ catch (e) {
50
+ if (e instanceof RpcReverted)
51
+ throw e;
52
+ last = `${(() => { try {
53
+ return new URL(u).host;
54
+ }
55
+ catch {
56
+ return u;
57
+ } })()}: ${e.message.slice(0, 160)}`;
58
+ }
59
+ }
60
+ throw new Error(`${method}: every Base endpoint failed (last: ${last})`);
61
+ },
62
+ };
63
+ }
64
+ /** eth_call on Base: the return data, or RpcReverted with the revert data */
65
+ export const ethCall = (r, to, data, block = 'latest') => r.call('eth_call', [{ to, data }, block]);
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,IAAa,CAAC;AAS3C,MAAM,OAAO,WAAY,SAAQ,KAAK;IAAwE,IAAI;IAAhE,IAAI,GAAG,aAAa,CAAC;IAAC,YAAY,OAAe,EAAW,IAAmB;QAAI,KAAK,CAAC,OAAO,CAAC,CAAC;oBAAtC,IAAI;IAAmC,CAAC;CAAE;AAExJ,MAAM,MAAM,GAAG,mCAAmC,CAAC;AACnD,MAAM,GAAG,GAAG,CAAC,CAAS,EAAsB,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAE7G,uFAAuF;AACvF,MAAM,UAAU,UAAU,CAAC,CAAC,GAA8F,EAAE;IAC1H,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC;IAC3B,MAAM,MAAM,GAAG,CAAC,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CAAC;wBAAC,OAAO,CAAC,CAAC;oBAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAM,CAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;gBACvH,CAAC;YACH,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,uCAAuC,IAAI,GAAG,CAAC,CAAC;QAC3E,CAAC;KACF,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAa,EAAE,EAAU,EAAE,IAAY,EAAE,KAAK,GAAW,QAAQ,EAAmB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAS,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @moonbeam-foundation/sdk/x402: pay an x402 wall on Base with USDC, unsigned.
3
+ *
4
+ * baseAccept(body) the `exact` entry on Base (eip155:8453) of a 402 answer's accepts[]; others refused
5
+ * transferAuthorization(a, o) the EIP-3009 TransferWithAuthorization typed data for that entry: your wallet signs
6
+ * it (eth_signTypedData_v4); nothing here holds a key
7
+ * paymentHeader(a, auth, sig) the X-PAYMENT header value (base64 JSON) the wall takes with the signature
8
+ * quoteWall(t, path) GET a wall and read its 402 (no payment is made)
9
+ * subscribe(t, plan) POST /v1/access/subscribe (subscribePlan from ./resale): its 402 is the top-up quote
10
+ *
11
+ * Base only (the Moonbeam profile): an entry on another network is refused, not converted.
12
+ */
13
+ import type { OnboardTransport } from '../onboard/index.js';
14
+ import { subscribePlan } from '../resale/index.js';
15
+ export declare const X402_BASE_NETWORK: 'eip155:8453';
16
+ export type X402Accept = {
17
+ scheme: string;
18
+ network: string;
19
+ amount?: string;
20
+ maxAmountRequired?: string;
21
+ asset: string;
22
+ payTo: string;
23
+ maxTimeoutSeconds: number;
24
+ resource?: string;
25
+ description?: string;
26
+ extra?: {
27
+ name?: string;
28
+ version?: string;
29
+ } & Record<string, unknown>;
30
+ };
31
+ export type X402Body = {
32
+ x402Version: number;
33
+ accepts: X402Accept[];
34
+ resource?: unknown;
35
+ error?: string;
36
+ };
37
+ export type Authorization = {
38
+ from: string;
39
+ to: string;
40
+ value: string;
41
+ validAfter: string;
42
+ validBefore: string;
43
+ nonce: string;
44
+ };
45
+ export type TransferWithAuthorizationTypedData = {
46
+ domain: {
47
+ name: string;
48
+ version: string;
49
+ chainId: 8453;
50
+ verifyingContract: string;
51
+ };
52
+ types: {
53
+ TransferWithAuthorization: {
54
+ name: string;
55
+ type: string;
56
+ }[];
57
+ };
58
+ primaryType: 'TransferWithAuthorization';
59
+ message: Authorization;
60
+ };
61
+ /** the x402 body inside a wall's 402 answer (`{ x402: {…} }` or the bare body) */
62
+ export declare function x402Of(answer: unknown): X402Body;
63
+ /** the `exact` USDC entry on Base; anything else is refused (Base only) */
64
+ export declare function baseAccept(answer: unknown): X402Accept;
65
+ /** a fresh 32-byte nonce (crypto.getRandomValues) */
66
+ export declare const randomNonce: () => string;
67
+ /** The EIP-3009 typed data for one Base entry. validAfter defaults to 0, validBefore to now + maxTimeoutSeconds. */
68
+ export declare function transferAuthorization(a: X402Accept, o: {
69
+ from: string;
70
+ nonce?: string;
71
+ now?: number;
72
+ validAfter?: number;
73
+ validBefore?: number;
74
+ }): TransferWithAuthorizationTypedData;
75
+ /** The X-PAYMENT header value: base64 of { x402Version, scheme, network, payload: { signature, authorization } } */
76
+ export declare function paymentHeader(a: X402Accept, authorization: Authorization, signature: string, x402Version?: number): string;
77
+ /** GET a wall and return its 402 quote (Base entry + the whole body). Nothing is paid. */
78
+ export declare function quoteWall(t: OnboardTransport, path: string): Promise<{
79
+ status: number;
80
+ accept: X402Accept;
81
+ body: X402Body;
82
+ }>;
83
+ /** POST /v1/access/subscribe with a subscribePlan(): the layer answers with the top-up's x402 quote (a 402) */
84
+ export declare function subscribe(t: OnboardTransport, plan?: ReturnType<typeof subscribePlan>): Promise<{
85
+ status: number;
86
+ accept: X402Accept | null;
87
+ body: unknown;
88
+ }>;
89
+ export { subscribePlan };
90
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/x402/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAG,aAAsB,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IACtI,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChH,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1G,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,C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