@playmos/sdk 0.2.0 → 0.3.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.
- package/README.md +61 -2
- package/dist/{chunk-B7SHFZYY.js → chunk-TMBBEGIF.js} +12 -3
- package/dist/chunk-TMBBEGIF.js.map +1 -0
- package/dist/{errors-CjL85YKR.d.cts → errors-DMtMpbR6.d.cts} +99 -5
- package/dist/{errors-CjL85YKR.d.ts → errors-DMtMpbR6.d.ts} +99 -5
- package/dist/index.cjs +288 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -16
- package/dist/index.d.ts +53 -16
- package/dist/index.js +279 -22
- package/dist/index.js.map +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-B7SHFZYY.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, A as AgentWallet,
|
|
2
|
-
export {
|
|
1
|
+
import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, c as PrizeBalance, d as WithdrawResult, A as AgentWallet, e as AgentFundResult, T as TransferResult, E as EscrowHoldInput, f as EscrowHoldResult, g as EscrowResolveResult, M as MarketplaceListInput, L as Listing, h as MarketplaceSaleResult, i as MarketplaceGetResult, j as PayInput, k as Payment, l as EnterRoundInput, m as TransferReconcile, n as WaitOptions, o as TransferInput, p as TransferConfirmOptions, V as VerifyResult } from './errors-DMtMpbR6.cjs';
|
|
2
|
+
export { q as AgentEconomyConfig, r as ApiError, s as AuthError, C as ConfigError, t as ContractConfig, u as Eip1193Provider, G as GasConfig, v as GasMode, I as InsufficientGasError, w as InvalidAmountError, x as ListingStatus, y as MarketplaceItem, z as MarketplaceSale, B as MissingFieldError, D as NothingToWithdrawError, F as PaymentFailedError, H as PaymentStatus, J as PayoutRule, K as PlaymosError, O as PlaymosErrorCode, Q as RetryOptions, U as RoundStatus, X as WalletConfig, Y as WalletConnectionError, Z as WalletConnector, _ as WebhookEventType } from './errors-DMtMpbR6.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Environment resolution + the canonical address book.
|
|
@@ -80,6 +80,30 @@ declare class Playmos {
|
|
|
80
80
|
get: (input: {
|
|
81
81
|
roundId: string;
|
|
82
82
|
}) => Promise<RoundState>;
|
|
83
|
+
/**
|
|
84
|
+
* Read a wallet's **claimable** prize balance for a round (issue #41).
|
|
85
|
+
* Prefers the service chain read (`GET /v1/rounds/:id/prize?wallet=`); falls
|
|
86
|
+
* back to a direct eth_call when `prizePoolAddress` is supplied and no wallet
|
|
87
|
+
* connector is needed for the read path… actually uses service first, then
|
|
88
|
+
* on-chain via the player's provider if the service is unavailable.
|
|
89
|
+
*/
|
|
90
|
+
prize: (input: {
|
|
91
|
+
roundId: string;
|
|
92
|
+
wallet: `0x${string}`;
|
|
93
|
+
/** Optional override if you already hold the pool address from enterRound. */
|
|
94
|
+
prizePoolAddress?: `0x${string}`;
|
|
95
|
+
}) => Promise<PrizeBalance>;
|
|
96
|
+
/**
|
|
97
|
+
* Winner **claim** — call PrizePool.withdraw() from the player's wallet (issue #41).
|
|
98
|
+
* Pull-payment: credits from settle live in `withdrawable[msg.sender]`. No approve needed.
|
|
99
|
+
* Pass either `prizePoolAddress` (from enterRound / rounds.get) or `roundId` (service resolves).
|
|
100
|
+
*/
|
|
101
|
+
withdraw: (input: {
|
|
102
|
+
prizePoolAddress?: `0x${string}`;
|
|
103
|
+
roundId?: string;
|
|
104
|
+
/** Pre-check claimable; default true. Set false only if you already called `prize()`. */
|
|
105
|
+
checkBalance?: boolean;
|
|
106
|
+
}) => Promise<WithdrawResult>;
|
|
83
107
|
};
|
|
84
108
|
/**
|
|
85
109
|
* `agents` — assign wallets to the NPCs YOUR game already owns, so they can transact USDC in your economy.
|
|
@@ -99,6 +123,7 @@ declare class Playmos {
|
|
|
99
123
|
fund: (input: {
|
|
100
124
|
agentId: string;
|
|
101
125
|
amount: string;
|
|
126
|
+
idempotencyKey?: string;
|
|
102
127
|
}) => Promise<AgentFundResult>;
|
|
103
128
|
/** NPC→NPC (or →player) USDC transfer, by id. A thin alias of `playmos.transfer` (which is canonical). */
|
|
104
129
|
pay: (input: {
|
|
@@ -194,18 +219,24 @@ declare class Playmos {
|
|
|
194
219
|
/** Playmos-owned skill-game entry (10%, 60/30/10 prize pool). Closes #343. */
|
|
195
220
|
enterRound(input: EnterRoundInput): Promise<Payment>;
|
|
196
221
|
/**
|
|
197
|
-
* `transfers` — read-back / confirmation for a prior `transfer()` (
|
|
198
|
-
*
|
|
222
|
+
* `transfers` — read-back / confirmation for a prior `transfer()` (issues #27, #47).
|
|
223
|
+
* `get` reconciles once against chain truth; `wait` polls it to a terminal state
|
|
224
|
+
* for you (no hand-rolled loop). Both cover the gasless agent path.
|
|
199
225
|
*/
|
|
200
226
|
readonly transfers: {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
/** One-shot reconcile of a transfer against chain truth. */
|
|
228
|
+
get: (transferId: string) => Promise<TransferReconcile>;
|
|
229
|
+
/**
|
|
230
|
+
* Block until a transfer reaches a terminal state — `settled` or `failed` —
|
|
231
|
+
* instead of hand-rolling a poll loop (#47). Polls `transfers.get(id)` every
|
|
232
|
+
* `intervalMs` (default 1000) until terminal, then RESOLVES with the final
|
|
233
|
+
* reconcile. Throws a typed `ApiError` (`detail.timeout`) if neither
|
|
234
|
+
* `timeoutMs` (default 30000) nor `maxAttempts` (default 40) is reached first.
|
|
235
|
+
*
|
|
236
|
+
* A `failed` transfer is a legitimate outcome, so it RESOLVES (status
|
|
237
|
+
* "failed") — inspect `result.status`; it does not throw.
|
|
238
|
+
*/
|
|
239
|
+
wait: (transferId: string, opts?: WaitOptions) => Promise<TransferReconcile>;
|
|
209
240
|
};
|
|
210
241
|
/**
|
|
211
242
|
* `transfer` — the value-movement base primitive (Phase 1a): move USDC from one wallet to another,
|
|
@@ -218,12 +249,13 @@ declare class Playmos {
|
|
|
218
249
|
* Retries are safe: pass the same `idempotencyKey` and a re-call NEVER broadcasts a second tx —
|
|
219
250
|
* it returns the cached result (`idempotentReplay: true`).
|
|
220
251
|
*
|
|
221
|
-
* Confirmation: treat `status === "settled" && txHash` as final. If `settling`, call
|
|
222
|
-
* `playmos.transfers.
|
|
252
|
+
* Confirmation: treat `status === "settled" && txHash` as final. If `settling`, either call
|
|
253
|
+
* `playmos.transfers.wait(id)`, or pass `{ confirm: true }` here to block until terminal in one
|
|
254
|
+
* call (#47). BaseScan: `https://sepolia.basescan.org/tx/<txHash>`.
|
|
223
255
|
*
|
|
224
256
|
* NPC `from` requires `sk_test_` and settles gaslessly (NPC signs; service relays).
|
|
225
257
|
*/
|
|
226
|
-
transfer(input: TransferInput): Promise<TransferResult>;
|
|
258
|
+
transfer(input: TransferInput, opts?: TransferConfirmOptions): Promise<TransferResult>;
|
|
227
259
|
/** Verify a payment by the service's on-chain read (spec §6.1). Idempotent. */
|
|
228
260
|
verify(paymentId: string): Promise<VerifyResult>;
|
|
229
261
|
/**
|
|
@@ -237,6 +269,11 @@ declare class Playmos {
|
|
|
237
269
|
/** Prefer the service's authoritative micro-USDC amount; fall back to the
|
|
238
270
|
* locally-parsed value if the service didn't echo one. */
|
|
239
271
|
private resolveUnits;
|
|
272
|
+
/**
|
|
273
|
+
* Read PrizePool.withdrawable[wallet] via eth_call (issue #41).
|
|
274
|
+
* Uses the wallet provider when present; otherwise a public Base Sepolia RPC in test.
|
|
275
|
+
*/
|
|
276
|
+
private readWithdrawable;
|
|
240
277
|
private sponsorUrl;
|
|
241
278
|
/**
|
|
242
279
|
* After the batch lands, resolve the authoritative status via the service's
|
|
@@ -506,4 +543,4 @@ declare function isWalletSignatureAuthorization(auth: Authorization): auth is Wa
|
|
|
506
543
|
/** Narrow to the declared-but-unimplemented x402 variant. */
|
|
507
544
|
declare function isX402PayloadAuthorization(auth: Authorization): auth is X402PayloadAuthorization;
|
|
508
545
|
|
|
509
|
-
export { AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, type PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferInput, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, type WalletSignatureAuthorization, WebhookEvent, type X402PayloadAuthorization, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, formatMicroToUsd, isWalletSignatureAuthorization, isX402PayloadAuthorization, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, serializePaymentRequirement, ulid };
|
|
546
|
+
export { AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, type PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, PrizeBalance, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferConfirmOptions, TransferInput, TransferReconcile, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, WaitOptions, type WalletSignatureAuthorization, WebhookEvent, WithdrawResult, type X402PayloadAuthorization, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, formatMicroToUsd, isWalletSignatureAuthorization, isX402PayloadAuthorization, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, serializePaymentRequirement, ulid };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, A as AgentWallet,
|
|
2
|
-
export {
|
|
1
|
+
import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, c as PrizeBalance, d as WithdrawResult, A as AgentWallet, e as AgentFundResult, T as TransferResult, E as EscrowHoldInput, f as EscrowHoldResult, g as EscrowResolveResult, M as MarketplaceListInput, L as Listing, h as MarketplaceSaleResult, i as MarketplaceGetResult, j as PayInput, k as Payment, l as EnterRoundInput, m as TransferReconcile, n as WaitOptions, o as TransferInput, p as TransferConfirmOptions, V as VerifyResult } from './errors-DMtMpbR6.js';
|
|
2
|
+
export { q as AgentEconomyConfig, r as ApiError, s as AuthError, C as ConfigError, t as ContractConfig, u as Eip1193Provider, G as GasConfig, v as GasMode, I as InsufficientGasError, w as InvalidAmountError, x as ListingStatus, y as MarketplaceItem, z as MarketplaceSale, B as MissingFieldError, D as NothingToWithdrawError, F as PaymentFailedError, H as PaymentStatus, J as PayoutRule, K as PlaymosError, O as PlaymosErrorCode, Q as RetryOptions, U as RoundStatus, X as WalletConfig, Y as WalletConnectionError, Z as WalletConnector, _ as WebhookEventType } from './errors-DMtMpbR6.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Environment resolution + the canonical address book.
|
|
@@ -80,6 +80,30 @@ declare class Playmos {
|
|
|
80
80
|
get: (input: {
|
|
81
81
|
roundId: string;
|
|
82
82
|
}) => Promise<RoundState>;
|
|
83
|
+
/**
|
|
84
|
+
* Read a wallet's **claimable** prize balance for a round (issue #41).
|
|
85
|
+
* Prefers the service chain read (`GET /v1/rounds/:id/prize?wallet=`); falls
|
|
86
|
+
* back to a direct eth_call when `prizePoolAddress` is supplied and no wallet
|
|
87
|
+
* connector is needed for the read path… actually uses service first, then
|
|
88
|
+
* on-chain via the player's provider if the service is unavailable.
|
|
89
|
+
*/
|
|
90
|
+
prize: (input: {
|
|
91
|
+
roundId: string;
|
|
92
|
+
wallet: `0x${string}`;
|
|
93
|
+
/** Optional override if you already hold the pool address from enterRound. */
|
|
94
|
+
prizePoolAddress?: `0x${string}`;
|
|
95
|
+
}) => Promise<PrizeBalance>;
|
|
96
|
+
/**
|
|
97
|
+
* Winner **claim** — call PrizePool.withdraw() from the player's wallet (issue #41).
|
|
98
|
+
* Pull-payment: credits from settle live in `withdrawable[msg.sender]`. No approve needed.
|
|
99
|
+
* Pass either `prizePoolAddress` (from enterRound / rounds.get) or `roundId` (service resolves).
|
|
100
|
+
*/
|
|
101
|
+
withdraw: (input: {
|
|
102
|
+
prizePoolAddress?: `0x${string}`;
|
|
103
|
+
roundId?: string;
|
|
104
|
+
/** Pre-check claimable; default true. Set false only if you already called `prize()`. */
|
|
105
|
+
checkBalance?: boolean;
|
|
106
|
+
}) => Promise<WithdrawResult>;
|
|
83
107
|
};
|
|
84
108
|
/**
|
|
85
109
|
* `agents` — assign wallets to the NPCs YOUR game already owns, so they can transact USDC in your economy.
|
|
@@ -99,6 +123,7 @@ declare class Playmos {
|
|
|
99
123
|
fund: (input: {
|
|
100
124
|
agentId: string;
|
|
101
125
|
amount: string;
|
|
126
|
+
idempotencyKey?: string;
|
|
102
127
|
}) => Promise<AgentFundResult>;
|
|
103
128
|
/** NPC→NPC (or →player) USDC transfer, by id. A thin alias of `playmos.transfer` (which is canonical). */
|
|
104
129
|
pay: (input: {
|
|
@@ -194,18 +219,24 @@ declare class Playmos {
|
|
|
194
219
|
/** Playmos-owned skill-game entry (10%, 60/30/10 prize pool). Closes #343. */
|
|
195
220
|
enterRound(input: EnterRoundInput): Promise<Payment>;
|
|
196
221
|
/**
|
|
197
|
-
* `transfers` — read-back / confirmation for a prior `transfer()` (
|
|
198
|
-
*
|
|
222
|
+
* `transfers` — read-back / confirmation for a prior `transfer()` (issues #27, #47).
|
|
223
|
+
* `get` reconciles once against chain truth; `wait` polls it to a terminal state
|
|
224
|
+
* for you (no hand-rolled loop). Both cover the gasless agent path.
|
|
199
225
|
*/
|
|
200
226
|
readonly transfers: {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
/** One-shot reconcile of a transfer against chain truth. */
|
|
228
|
+
get: (transferId: string) => Promise<TransferReconcile>;
|
|
229
|
+
/**
|
|
230
|
+
* Block until a transfer reaches a terminal state — `settled` or `failed` —
|
|
231
|
+
* instead of hand-rolling a poll loop (#47). Polls `transfers.get(id)` every
|
|
232
|
+
* `intervalMs` (default 1000) until terminal, then RESOLVES with the final
|
|
233
|
+
* reconcile. Throws a typed `ApiError` (`detail.timeout`) if neither
|
|
234
|
+
* `timeoutMs` (default 30000) nor `maxAttempts` (default 40) is reached first.
|
|
235
|
+
*
|
|
236
|
+
* A `failed` transfer is a legitimate outcome, so it RESOLVES (status
|
|
237
|
+
* "failed") — inspect `result.status`; it does not throw.
|
|
238
|
+
*/
|
|
239
|
+
wait: (transferId: string, opts?: WaitOptions) => Promise<TransferReconcile>;
|
|
209
240
|
};
|
|
210
241
|
/**
|
|
211
242
|
* `transfer` — the value-movement base primitive (Phase 1a): move USDC from one wallet to another,
|
|
@@ -218,12 +249,13 @@ declare class Playmos {
|
|
|
218
249
|
* Retries are safe: pass the same `idempotencyKey` and a re-call NEVER broadcasts a second tx —
|
|
219
250
|
* it returns the cached result (`idempotentReplay: true`).
|
|
220
251
|
*
|
|
221
|
-
* Confirmation: treat `status === "settled" && txHash` as final. If `settling`, call
|
|
222
|
-
* `playmos.transfers.
|
|
252
|
+
* Confirmation: treat `status === "settled" && txHash` as final. If `settling`, either call
|
|
253
|
+
* `playmos.transfers.wait(id)`, or pass `{ confirm: true }` here to block until terminal in one
|
|
254
|
+
* call (#47). BaseScan: `https://sepolia.basescan.org/tx/<txHash>`.
|
|
223
255
|
*
|
|
224
256
|
* NPC `from` requires `sk_test_` and settles gaslessly (NPC signs; service relays).
|
|
225
257
|
*/
|
|
226
|
-
transfer(input: TransferInput): Promise<TransferResult>;
|
|
258
|
+
transfer(input: TransferInput, opts?: TransferConfirmOptions): Promise<TransferResult>;
|
|
227
259
|
/** Verify a payment by the service's on-chain read (spec §6.1). Idempotent. */
|
|
228
260
|
verify(paymentId: string): Promise<VerifyResult>;
|
|
229
261
|
/**
|
|
@@ -237,6 +269,11 @@ declare class Playmos {
|
|
|
237
269
|
/** Prefer the service's authoritative micro-USDC amount; fall back to the
|
|
238
270
|
* locally-parsed value if the service didn't echo one. */
|
|
239
271
|
private resolveUnits;
|
|
272
|
+
/**
|
|
273
|
+
* Read PrizePool.withdrawable[wallet] via eth_call (issue #41).
|
|
274
|
+
* Uses the wallet provider when present; otherwise a public Base Sepolia RPC in test.
|
|
275
|
+
*/
|
|
276
|
+
private readWithdrawable;
|
|
240
277
|
private sponsorUrl;
|
|
241
278
|
/**
|
|
242
279
|
* After the batch lands, resolve the authoritative status via the service's
|
|
@@ -506,4 +543,4 @@ declare function isWalletSignatureAuthorization(auth: Authorization): auth is Wa
|
|
|
506
543
|
/** Narrow to the declared-but-unimplemented x402 variant. */
|
|
507
544
|
declare function isX402PayloadAuthorization(auth: Authorization): auth is X402PayloadAuthorization;
|
|
508
545
|
|
|
509
|
-
export { AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, type PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferInput, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, type WalletSignatureAuthorization, WebhookEvent, type X402PayloadAuthorization, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, formatMicroToUsd, isWalletSignatureAuthorization, isX402PayloadAuthorization, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, serializePaymentRequirement, ulid };
|
|
546
|
+
export { AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, type PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, PrizeBalance, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferConfirmOptions, TransferInput, TransferReconcile, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, WaitOptions, type WalletSignatureAuthorization, WebhookEvent, WithdrawResult, type X402PayloadAuthorization, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, formatMicroToUsd, isWalletSignatureAuthorization, isX402PayloadAuthorization, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, serializePaymentRequirement, ulid };
|