@moonbeam-foundation/sdk 0.13.0 → 0.13.1

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 (101) hide show
  1. package/README.md +61 -16
  2. package/dist/core/keyed.d.ts +17 -0
  3. package/dist/core/keyed.d.ts.map +1 -0
  4. package/dist/core/keyed.js +36 -0
  5. package/dist/core/keyed.js.map +1 -0
  6. package/dist/cover/index.d.ts.map +1 -1
  7. package/dist/cover/index.js +2 -1
  8. package/dist/cover/index.js.map +1 -1
  9. package/dist/devnet/index.d.ts.map +1 -1
  10. package/dist/devnet/index.js +3 -2
  11. package/dist/devnet/index.js.map +1 -1
  12. package/dist/devnet/profile.d.ts.map +1 -1
  13. package/dist/devnet/profile.js +3 -2
  14. package/dist/devnet/profile.js.map +1 -1
  15. package/dist/economy/index.d.ts +264 -0
  16. package/dist/economy/index.d.ts.map +1 -0
  17. package/dist/economy/index.js +376 -0
  18. package/dist/economy/index.js.map +1 -0
  19. package/dist/jobs/index.d.ts.map +1 -1
  20. package/dist/jobs/index.js +2 -1
  21. package/dist/jobs/index.js.map +1 -1
  22. package/dist/market/cohorts.d.ts +9 -3
  23. package/dist/market/cohorts.d.ts.map +1 -1
  24. package/dist/market/cohorts.js +5 -3
  25. package/dist/market/cohorts.js.map +1 -1
  26. package/dist/market/http.d.ts.map +1 -1
  27. package/dist/market/http.js +2 -1
  28. package/dist/market/http.js.map +1 -1
  29. package/dist/market/index.d.ts +3 -0
  30. package/dist/market/index.d.ts.map +1 -1
  31. package/dist/market/index.js +3 -0
  32. package/dist/market/index.js.map +1 -1
  33. package/dist/market/journey.d.ts.map +1 -1
  34. package/dist/market/journey.js +3 -2
  35. package/dist/market/journey.js.map +1 -1
  36. package/dist/market/listed.d.ts.map +1 -1
  37. package/dist/market/listed.js +2 -1
  38. package/dist/market/listed.js.map +1 -1
  39. package/dist/market/reads.d.ts +124 -0
  40. package/dist/market/reads.d.ts.map +1 -0
  41. package/dist/market/reads.js +99 -0
  42. package/dist/market/reads.js.map +1 -0
  43. package/dist/market/states-data.d.ts +491 -0
  44. package/dist/market/states-data.d.ts.map +1 -0
  45. package/dist/market/states-data.js +4 -0
  46. package/dist/market/states-data.js.map +1 -0
  47. package/dist/market/states.d.ts +40 -0
  48. package/dist/market/states.d.ts.map +1 -0
  49. package/dist/market/states.js +36 -0
  50. package/dist/market/states.js.map +1 -0
  51. package/dist/market/venues-data.d.ts.map +1 -1
  52. package/dist/market/venues-data.js +197 -159
  53. package/dist/market/venues-data.js.map +1 -1
  54. package/dist/market/venues.d.ts +6 -4
  55. package/dist/market/venues.d.ts.map +1 -1
  56. package/dist/market/venues.js +4 -3
  57. package/dist/market/venues.js.map +1 -1
  58. package/dist/onboard/index.d.ts +1 -0
  59. package/dist/onboard/index.d.ts.map +1 -1
  60. package/dist/onboard/index.js +4 -3
  61. package/dist/onboard/index.js.map +1 -1
  62. package/dist/playground/cases.d.ts +72 -0
  63. package/dist/playground/cases.d.ts.map +1 -0
  64. package/dist/playground/cases.js +115 -0
  65. package/dist/playground/cases.js.map +1 -0
  66. package/dist/playground/doc.d.ts +2 -0
  67. package/dist/playground/doc.d.ts.map +1 -0
  68. package/dist/playground/doc.js +52 -0
  69. package/dist/playground/doc.js.map +1 -0
  70. package/dist/playground/index.d.ts +172 -0
  71. package/dist/playground/index.d.ts.map +1 -0
  72. package/dist/playground/index.js +246 -0
  73. package/dist/playground/index.js.map +1 -0
  74. package/dist/playground/nets.d.ts +79 -0
  75. package/dist/playground/nets.d.ts.map +1 -0
  76. package/dist/playground/nets.js +147 -0
  77. package/dist/playground/nets.js.map +1 -0
  78. package/dist/playground/ports.d.ts +93 -0
  79. package/dist/playground/ports.d.ts.map +1 -0
  80. package/dist/playground/ports.js +72 -0
  81. package/dist/playground/ports.js.map +1 -0
  82. package/dist/playground/stream.d.ts +106 -0
  83. package/dist/playground/stream.d.ts.map +1 -0
  84. package/dist/playground/stream.js +269 -0
  85. package/dist/playground/stream.js.map +1 -0
  86. package/dist/proof/index.d.ts.map +1 -1
  87. package/dist/proof/index.js +2 -1
  88. package/dist/proof/index.js.map +1 -1
  89. package/dist/resale/index.d.ts.map +1 -1
  90. package/dist/resale/index.js +3 -2
  91. package/dist/resale/index.js.map +1 -1
  92. package/dist/x402/index.d.ts.map +1 -1
  93. package/dist/x402/index.js +3 -2
  94. package/dist/x402/index.js.map +1 -1
  95. package/docs/PATHS.md +96 -0
  96. package/docs/VENUES.md +10 -10
  97. package/docs/io-coverage.md +206 -0
  98. package/docs/playground.md +220 -0
  99. package/examples/50-x402-pay-a-wall.mjs +1 -1
  100. package/examples/data/x402-wall-402.json +6 -6
  101. package/package.json +26 -4
@@ -0,0 +1,220 @@
1
+ # The playground: devnet and Base
2
+
3
+ <!-- GENERATED by scripts/gen-playground.mjs from src/playground (NETS and CASES). Do not edit. -->
4
+
5
+ `@moonbeam-foundation/sdk/playground` is one switch between the Moonbeam devnet and Base. Every cover case of a covered job is one
6
+ plan with the same steps on both networks; only the signers, the chain id and the addresses differ. Base refuses until its
7
+ gates are met: `allowMainnet: true`, a per-run budget above 0, and two green devnet runs of the market.
8
+
9
+ A `wallet:` signer is a user wallet (on the devnet, a test wallet made for one run). A `coord:` signer is a sign request on the
10
+ coord pipe for that purpose: Moonbeam signs it there, and the SDK never holds a key. A role with no signer is a gap: every case
11
+ that needs it is refused on that network. The addresses are never in the table: they come in the placement the caller passes.
12
+
13
+ ## The networks
14
+
15
+ | | devnet | base |
16
+ |---|---|---|
17
+ | chain id | 36927 | 8453 |
18
+ | token | dUSDC (6 decimals) | USDC (6 decimals) |
19
+ | review window | 60 s | read from the hook |
20
+ | dispute window | 60 s | read from the hook |
21
+ | arbitration window | 120 s | read from the hook |
22
+
23
+ ## Who signs each role
24
+
25
+ | role | devnet | base |
26
+ |---|---|---|
27
+ | buyer | `wallet:test` | `wallet:user` |
28
+ | seller | `wallet:test` | `wallet:user` |
29
+ | evaluator | `coord:devnet.evaluate` | **none yet** (gap) |
30
+ | arbitrator | `coord:devnet.arbitrate` | **none yet** (gap) |
31
+ | keeper | `coord:devnet.keeper` | `coord:keeper.end` |
32
+ | backer | `wallet:test` | `wallet:user` |
33
+ | payout | `coord:devnet.payout` | `coord:payout.seller` |
34
+
35
+ ## The cases
36
+
37
+ | case | ending | devnet | base |
38
+ |---|---|---|---|
39
+ | `delivered-accepted` | completed | planned | refused |
40
+ | `auto-complete` | auto_completed | planned | planned |
41
+ | `no-show` | no_show | planned | planned |
42
+ | `rejected` | rejected | planned | refused |
43
+ | `rejection-overturned` | dispute_seller_won | planned | refused |
44
+ | `cheated` | cheated | planned | refused |
45
+ | `offer-cancelled` | cancelled | planned | planned |
46
+ | `offer-lapsed` | lapsed | planned | planned |
47
+ | `layer-sweep` | — | planned | planned |
48
+ | `pool-deposit-withdraw` | — | planned | planned |
49
+ | `seller-payout` | — | not_built | not_built |
50
+ | `grade-top-up` | — | not_built | not_built |
51
+
52
+ ### `delivered-accepted`
53
+
54
+ Delivered and accepted: the evaluator completes it through the judge adapter.
55
+
56
+ 1. buy · `approve` · buyer
57
+ 2. buy · `openJobWithEconomy` · buyer
58
+ 3. accept · `approve` · seller
59
+ 4. accept · `accept` · seller
60
+ 5. deliver · `submit` · seller
61
+ 6. decide · `postVerdict` · evaluator
62
+
63
+ Lights: listed · bought · delivered · settled · paid.
64
+
65
+ ### `auto-complete`
66
+
67
+ Delivered, no decision: anyone completes it after the review window.
68
+
69
+ 1. buy · `approve` · buyer
70
+ 2. buy · `openJobWithEconomy` · buyer
71
+ 3. accept · `approve` · seller
72
+ 4. accept · `accept` · seller
73
+ 5. deliver · `submit` · seller
74
+ 6. end · `claimAutoComplete` · keeper (after the review window)
75
+
76
+ Lights: listed · bought · delivered · settled · paid.
77
+
78
+ ### `no-show`
79
+
80
+ Accepted, never delivered: it expires after the deadline.
81
+
82
+ 1. buy · `approve` · buyer
83
+ 2. buy · `openJobWithEconomy` · buyer
84
+ 3. accept · `approve` · seller
85
+ 4. accept · `accept` · seller
86
+ 5. end · `expire` · keeper (after the deadline)
87
+
88
+ Lights: listed · bought · settled.
89
+
90
+ ### `rejected`
91
+
92
+ Delivered and rejected: the rejection stands.
93
+
94
+ With `via: 'finalize'` (devnet: planned, base: refused):
95
+
96
+ 1. buy · `approve` · buyer
97
+ 2. buy · `openJobWithEconomy` · buyer
98
+ 3. accept · `approve` · seller
99
+ 4. accept · `accept` · seller
100
+ 5. deliver · `submit` · seller
101
+ 6. decide · `postVerdict` · evaluator
102
+ 7. end · `finalizeReject` · keeper (after the dispute window)
103
+
104
+ With `via: 'arbitrated'` (devnet: planned, base: refused):
105
+
106
+ 1. buy · `approve` · buyer
107
+ 2. buy · `openJobWithEconomy` · buyer
108
+ 3. accept · `approve` · seller
109
+ 4. accept · `accept` · seller
110
+ 5. deliver · `submit` · seller
111
+ 6. decide · `postVerdict` · evaluator
112
+ 7. dispute · `dispute` · seller
113
+ 8. rule · `resolveDispute` · arbitrator
114
+
115
+ With `via: 'stale'` (devnet: planned, base: refused):
116
+
117
+ 1. buy · `approve` · buyer
118
+ 2. buy · `openJobWithEconomy` · buyer
119
+ 3. accept · `approve` · seller
120
+ 4. accept · `accept` · seller
121
+ 5. deliver · `submit` · seller
122
+ 6. decide · `postVerdict` · evaluator
123
+ 7. dispute · `dispute` · seller
124
+ 8. end · `settleStaleDispute` · keeper (after the arbitration window)
125
+
126
+ Lights: listed · bought · delivered · settled.
127
+
128
+ ### `rejection-overturned`
129
+
130
+ Rejected, disputed, and the arbitrator rules for the seller.
131
+
132
+ 1. buy · `approve` · buyer
133
+ 2. buy · `openJobWithEconomy` · buyer
134
+ 3. accept · `approve` · seller
135
+ 4. accept · `accept` · seller
136
+ 5. deliver · `submit` · seller
137
+ 6. decide · `postVerdict` · evaluator
138
+ 7. dispute · `dispute` · seller
139
+ 8. rule · `resolveDispute` · arbitrator
140
+
141
+ Lights: listed · bought · delivered · settled · paid.
142
+
143
+ ### `cheated`
144
+
145
+ Delivered, and the arbitrator finds the seller cheated on a loss.
146
+
147
+ 1. buy · `approve` · buyer
148
+ 2. buy · `openJobWithEconomy` · buyer
149
+ 3. accept · `approve` · seller
150
+ 4. accept · `accept` · seller
151
+ 5. deliver · `submit` · seller
152
+ 6. rule · `findCheated` · arbitrator
153
+
154
+ Lights: listed · bought · delivered · settled.
155
+
156
+ ### `offer-cancelled`
157
+
158
+ An offer the buyer withdraws before anyone accepts it.
159
+
160
+ 1. buy · `approve` · buyer
161
+ 2. buy · `openJobWithEconomy` · buyer
162
+ 3. end · `cancelOpen` · buyer
163
+
164
+ Lights: listed · bought · settled.
165
+
166
+ ### `offer-lapsed`
167
+
168
+ An offer nobody accepted: it expires after the deadline.
169
+
170
+ 1. buy · `approve` · buyer
171
+ 2. buy · `openJobWithEconomy` · buyer
172
+ 3. end · `expire` · keeper (after the deadline)
173
+
174
+ Lights: listed · bought · settled.
175
+
176
+ ### `layer-sweep`
177
+
178
+ The accrued protocol fees go to the fee payee the hook names.
179
+
180
+ 1. sweep · `sweepLayerFees` · keeper
181
+
182
+ Lights: none (no sale).
183
+
184
+ ### `pool-deposit-withdraw`
185
+
186
+ A backer deposits into the coverage pool, then redeems.
187
+
188
+ 1. back · `approve` · backer
189
+ 2. back · `deposit` · backer
190
+ 3. withdraw · `redeem` · backer
191
+
192
+ Lights: none (no sale).
193
+
194
+ ### `seller-payout`
195
+
196
+ The seller signs a claim intent and the payout releases from the vault.
197
+
198
+ Not built: the payout purpose has no devnet vault yet. No plan is made for it on either network.
199
+
200
+ ### `grade-top-up`
201
+
202
+ A grade top-up.
203
+
204
+ Not built: no devnet grades vault. No plan is made for it on either network.
205
+
206
+ ## The gaps
207
+
208
+ - **devnet**: none.
209
+ - **base**, evaluator: no coord sign purpose yet. Refused: `delivered-accepted`, `rejected` (finalize), `rejected` (arbitrated), `rejected` (stale), `rejection-overturned`.
210
+ - **base**, arbitrator: no coord sign purpose yet. Refused: `rejected` (arbitrated), `rejection-overturned`, `cheated`.
211
+
212
+ ## The lights
213
+
214
+ Each light of a sale turns on only from an ack on the coord pipe plus an event on chain:
215
+
216
+ - listed: `GET /v1/listed` (the sale run’s listed ack) and the hook’s `JobOpened` naming the seller;
217
+ - bought: the fund call’s ack and `EconomyCommitted`;
218
+ - delivered: the delivery’s ack and `Submitted`;
219
+ - settled: the sale run’s settled stage and the hook’s `Settled`;
220
+ - paid: the payout ack and the chain transfer of the seller’s leg to the seller.
@@ -16,7 +16,7 @@ const accept = live ? live.accept : pickAccept(recorded, { network });
16
16
  console.log(`the wall offers ${(live ? live.body : recorded.x402).accepts.map((a) => a.network).join(', ')}; on ${accept.network} it asks ${accept.amount} units of ${accept.asset}, paid to ${accept.payTo}`);
17
17
  const q = quoteSale({ venue_in: 'x402-base', venue_out: 'x402-base', seller_price: 9207n });
18
18
  console.log(`quoteSale: the seller's 9207 → the buyer pays ${q.price_to_buyer} (the same scheme the wall prices with)`);
19
- const rail = sellerRailOf({ accepts: { network: 'solana', asset: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', payTo: 'GQcEn5pLcweo7qaiy3rDdsiUPiygygmFBaixNtNqhQVD' } });
19
+ const rail = sellerRailOf({ accepts: { network: 'solana', asset: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', payTo: 'PayTo1111111111111111111111111111111111111' } });
20
20
  console.log(`a seller who published a Solana offer is paid there: ${rail.network} ${rail.token?.symbol} to ${rail.pay_to} (${rail.state})`);
21
21
  if (chainIdOf(accept.network) === null) {
22
22
  console.log(`${accept.network} is not an EIP-3009 network: your Solana wallet sends ${accept.amount} units of ${accept.asset} to ${accept.payTo} (fee payer ${accept.extra?.feePayer ?? 'yours'})`);
@@ -9,7 +9,7 @@
9
9
  "amount": "5455",
10
10
  "maxAmountRequired": "5455",
11
11
  "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
12
- "payTo": "0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b",
12
+ "payTo": "0x1111111111111111111111111111111111111111",
13
13
  "maxTimeoutSeconds": 300,
14
14
  "extra": {
15
15
  "name": "USD Coin",
@@ -22,7 +22,7 @@
22
22
  "amount": "5455",
23
23
  "maxAmountRequired": "5455",
24
24
  "asset": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
25
- "payTo": "0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b",
25
+ "payTo": "0x1111111111111111111111111111111111111111",
26
26
  "maxTimeoutSeconds": 300,
27
27
  "extra": {
28
28
  "name": "USD Coin",
@@ -35,7 +35,7 @@
35
35
  "amount": "5455",
36
36
  "maxAmountRequired": "5455",
37
37
  "asset": "0x3600000000000000000000000000000000000000",
38
- "payTo": "0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b",
38
+ "payTo": "0x1111111111111111111111111111111111111111",
39
39
  "maxTimeoutSeconds": 300,
40
40
  "extra": {
41
41
  "name": "USDC",
@@ -48,7 +48,7 @@
48
48
  "amount": "5455",
49
49
  "maxAmountRequired": "5455",
50
50
  "asset": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
51
- "payTo": "0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b",
51
+ "payTo": "0x1111111111111111111111111111111111111111",
52
52
  "maxTimeoutSeconds": 300,
53
53
  "extra": {
54
54
  "name": "Global Dollar",
@@ -61,7 +61,7 @@
61
61
  "amount": "5455",
62
62
  "maxAmountRequired": "5455",
63
63
  "asset": "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
64
- "payTo": "0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b",
64
+ "payTo": "0x1111111111111111111111111111111111111111",
65
65
  "maxTimeoutSeconds": 300,
66
66
  "extra": {
67
67
  "name": "USDC",
@@ -74,7 +74,7 @@
74
74
  "amount": "5455",
75
75
  "maxAmountRequired": "5455",
76
76
  "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
77
- "payTo": "GQcEn5pLcweo7qaiy3rDdsiUPiygygmFBaixNtNqhQVD",
77
+ "payTo": "PayTo1111111111111111111111111111111111111",
78
78
  "maxTimeoutSeconds": 300,
79
79
  "extra": {
80
80
  "feePayer": "F742C4VfFLQ9zRQyithoj5229ZgtX2WqKCSFKgH2EThq"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonbeam-foundation/sdk",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Agentic commerce SDK for AI agents: buy and sell agent work on every market (x402, MCP, A2A, Virtuals ACP / ERC-8183, Olas, BitAgent, ERC-8004, NEAR), with graded jobs and assurance on Base. The Moonbeam Studio's workflows as code.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -100,6 +100,14 @@
100
100
  "types": "./dist/devnet/index.d.ts",
101
101
  "import": "./dist/devnet/index.js"
102
102
  },
103
+ "./economy": {
104
+ "types": "./dist/economy/index.d.ts",
105
+ "import": "./dist/economy/index.js"
106
+ },
107
+ "./playground": {
108
+ "types": "./dist/playground/index.d.ts",
109
+ "import": "./dist/playground/index.js"
110
+ },
103
111
  "./market": {
104
112
  "types": "./dist/market/index.d.ts",
105
113
  "import": "./dist/market/index.js"
@@ -130,13 +138,13 @@
130
138
  "test:watch": "vitest",
131
139
  "test:coverage": "vitest run --coverage",
132
140
  "lint": "tsc --noEmit && vitest run --reporter=dot",
133
- "prepublishOnly": "npm run check",
141
+ "prepublishOnly": "node scripts/prepublish.mjs && npm run check",
134
142
  "postbuild": "node scripts/postbuild.mjs",
135
143
  "gen:registry": "node scripts/gen-moonbeam-acp.mjs",
136
144
  "check:registry": "node scripts/gen-moonbeam-acp.mjs --check",
137
145
  "check:pins": "node scripts/check-pins.mjs",
138
146
  "check:diagrams": "node scripts/gen-diagrams.mjs >/dev/null && git diff --exit-code -- 'docs/workflows/*.svg' docs/WORKFLOWS.md",
139
- "check": "npm run typecheck && npm run build && npm test && npm run check:pins && npm run check:workflows && npm run check:venues && npm run check:diagrams",
147
+ "check": "npm run typecheck && npm run build && npm test && npm run check:pins && npm run check:workflows && npm run check:paths && npm run check:venues && npm run check:acceptance && npm run check:states && npm run check:readme && npm run check:diagrams && npm run check:playground",
140
148
  "sync": "node scripts/sync.mjs",
141
149
  "check:sync": "node scripts/sync.mjs --check",
142
150
  "test:fork": "node test/fork/run-fork.mjs",
@@ -146,7 +154,21 @@
146
154
  "gen:workflows": "node scripts/gen-workflows.mjs",
147
155
  "check:workflows": "node scripts/gen-workflows.mjs --check",
148
156
  "gen:venues": "node scripts/gen-venues.mjs",
149
- "check:venues": "node scripts/gen-venues.mjs --check"
157
+ "check:venues": "node scripts/gen-venues.mjs --check",
158
+ "gen:readme": "npm run build && node scripts/gen-readme-venues.mjs",
159
+ "check:readme": "node scripts/gen-readme-venues.mjs --check",
160
+ "gen:playground": "node scripts/gen-playground.mjs",
161
+ "check:playground": "node scripts/gen-playground.mjs --check",
162
+ "io:gen": "node scripts/io-coverage.mjs",
163
+ "io:check": "node scripts/io-coverage.mjs --check",
164
+ "io:record": "npm run build && node scripts/io-record.mjs",
165
+ "gen:paths": "npm run build && node scripts/gen-paths.mjs",
166
+ "check:paths": "node scripts/gen-paths.mjs --check",
167
+ "gen:acceptance": "node scripts/gen-acceptance-tests.mjs",
168
+ "check:acceptance": "node scripts/gen-acceptance-tests.mjs --check",
169
+ "gen:states": "node scripts/gen-states.mjs",
170
+ "check:states": "node scripts/gen-states.mjs --check",
171
+ "io:record-api": "node scripts/record-api-rung.mjs"
150
172
  },
151
173
  "keywords": [
152
174
  "moonbeam",