@zkp2p/cash 0.4.4 → 0.4.5
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/AGENTS.md +10 -2
- package/README.md +21 -40
- package/dist/{chunk-ORCJKOT6.js → chunk-YD5VHZXR.js} +6 -0
- package/dist/{createCashClient-C5YKh7cv.d.cts → createCashClient-CL1SCbqF.d.cts} +8 -3
- package/dist/{createCashClient-C5YKh7cv.d.ts → createCashClient-CL1SCbqF.d.ts} +8 -3
- package/dist/index.cjs +22 -56
- package/dist/index.d.cts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +18 -58
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/tools.cjs +2 -2
- package/dist/tools.d.cts +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +2 -2
- package/docs/lifecycle-and-recovery.md +12 -5
- package/examples/agent-tool-use.ts +9 -3
- package/examples/node-cashout.ts +6 -4
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -32,7 +32,13 @@ Every transaction (including approves) carries ERC-8021 attribution:
|
|
|
32
32
|
code. The namespaced referral marker gives its Peer Privy wallet the direct
|
|
33
33
|
deposit-level integration share instead of applying maker L1/L2.
|
|
34
34
|
|
|
35
|
-
**
|
|
35
|
+
**Platform caveats, all surfaced in `capabilities()`:**
|
|
36
|
+
|
|
37
|
+
- **Venmo, Cash App, and PayPal** carry
|
|
38
|
+
`requiresAtomicAccessPolicy: true`. Generic `cashout()` and `prepare()` reject
|
|
39
|
+
them with `ATOMIC_ACCESS_POLICY_REQUIRED` before any side effect. Use Peer
|
|
40
|
+
web's Curator-backed atomic flow or a host with the same atomic guarantee;
|
|
41
|
+
never create the deposit and attach the group policy sequentially.
|
|
36
42
|
|
|
37
43
|
- **Wise and PayPal** carry `requiresIdentityAttestation: true`. A new curator
|
|
38
44
|
registration needs a signed maker identity attestation this SDK cannot mint
|
|
@@ -93,7 +99,7 @@ const multiPlatform = await cash.cashout(
|
|
|
93
99
|
{
|
|
94
100
|
amount: usdc(500),
|
|
95
101
|
receive: [
|
|
96
|
-
{ platform: '
|
|
102
|
+
{ platform: 'chime', currency: 'USD', payee: '$handle' },
|
|
97
103
|
{ platform: 'revolut', currencies: ['EUR', 'GBP'], payee: { offchainId: 'revtag' } },
|
|
98
104
|
],
|
|
99
105
|
},
|
|
@@ -208,6 +214,8 @@ Every `CashError` carries `code`, `retryable`, `remediation`. Behavior:
|
|
|
208
214
|
| `INVALID_PAYOUT_PLATFORMS` | no | Pass one leg or an array of legs, using each platform at most once |
|
|
209
215
|
| `PAYEE_VERIFICATION_REQUIRED` | no | Register a new Wise/PayPal payee through Peer; an existing registered handle can be reused |
|
|
210
216
|
| `PAYEE_REGISTRATION_FAILED` | yes | Validate against `payeeHint`, then retry |
|
|
217
|
+
| `ATOMIC_ACCESS_POLICY_REQUIRED` | no | Use Peer web or an equivalent atomic host for Venmo, Cash App, or PayPal; nothing moved |
|
|
218
|
+
| `ACCESS_POLICY_CONFIGURATION_FAILED` | no | Recover an existing `0.4.4` deposit from its policy recovery data; do not create it again |
|
|
211
219
|
| `SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE` | no | Execute Relay with a signer first, then prepare a Base-USDC cashout |
|
|
212
220
|
| `SOURCE_RECIPIENT_MISMATCH` | no | Route Base USDC to the cashout depositor |
|
|
213
221
|
| `SOURCE_CAPABILITIES_FAILED` | yes | Retry discovery or fall back to Base USDC |
|
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ const multiCurrencyStats = fillStats['revolut:EUR+GBP+USD'];
|
|
|
46
46
|
const { depositId } = await cash.cashout(
|
|
47
47
|
{
|
|
48
48
|
amount: usdc(1000),
|
|
49
|
-
receive: { platform: '
|
|
49
|
+
receive: { platform: 'chime', currency: 'USD', payee: '$you' },
|
|
50
50
|
},
|
|
51
51
|
{ signer }, // any viem WalletClient on Base
|
|
52
52
|
);
|
|
@@ -71,7 +71,7 @@ const widestReach = await cash.cashout(
|
|
|
71
71
|
{
|
|
72
72
|
amount: usdc(1000),
|
|
73
73
|
receive: [
|
|
74
|
-
{ platform: '
|
|
74
|
+
{ platform: 'chime', currency: 'USD', payee: '$you' },
|
|
75
75
|
{ platform: 'revolut', currencies: ['EUR', 'GBP'], payee: { offchainId: 'revtag' } },
|
|
76
76
|
],
|
|
77
77
|
},
|
|
@@ -120,7 +120,7 @@ const { depositId, source } = await cash.cashout(
|
|
|
120
120
|
currency: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
121
121
|
tradeType: 'EXACT_INPUT',
|
|
122
122
|
},
|
|
123
|
-
receive: { platform: '
|
|
123
|
+
receive: { platform: 'chime', currency: 'USD', payee: { offchainId: '$you' } },
|
|
124
124
|
},
|
|
125
125
|
{ signer, sourceSigner },
|
|
126
126
|
);
|
|
@@ -141,9 +141,9 @@ console.log(source?.transactions?.origin, source?.transactions?.destination);
|
|
|
141
141
|
| `quoteSource(input)` / `executeSourceQuote(quote, { signer })` | Relay SDK EVM source routing into Base USDC before cashout |
|
|
142
142
|
| `relayStatus(requestId)` | Relay request status from the Relay SDK request path |
|
|
143
143
|
| `estimate({ amount, currency }, { includeEta? })` | Base USDC oracle estimate; optionally skip the historical ETA for progressive rendering |
|
|
144
|
-
| `cashout(input, { signer })` | Registers the payee and creates
|
|
145
|
-
| `prepare(input)` / `finalizePreparedCashout(receipt)` | Prepare external signing, then resolve the confirmed createDeposit receipt into
|
|
146
|
-
| `prepareAccessPolicy(depositId)` |
|
|
144
|
+
| `cashout(input, { signer })` | Registers the payee and creates an unrestricted-rail order; protected rails fail before any side effect |
|
|
145
|
+
| `prepare(input)` / `finalizePreparedCashout(receipt)` | Prepare unrestricted-rail external signing, then resolve the confirmed createDeposit receipt into resumable state |
|
|
146
|
+
| `prepareAccessPolicy(depositId)` | Recover a restricted-rail deposit created by the unsafe `0.4.4` sequential flow; never use it to create a new order |
|
|
147
147
|
| `order(depositId)` / `orders(owner)` | Resume any order from its id alone; list all orders for a wallet |
|
|
148
148
|
| `watch(depositId)` | Async iterator: yields on every state change until terminal, abort, or timeout |
|
|
149
149
|
| `withdraw(depositId, { signer, amount? })` | The ONE unwind verb - partial with an `amount` (live intents don't block it), full close without (prunes expired intents first) |
|
|
@@ -165,40 +165,21 @@ Peer Cash transaction, including approves, carries ERC-8021 attribution:
|
|
|
165
165
|
`peer-cash` first, optional `peer-ref-XXXXXX` from `referralCode` next, and your
|
|
166
166
|
analytics-only `referrer` code(s) after it.
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
let createDepositReceipt;
|
|
187
|
-
for (const [index, transaction] of prepared.txs.entries()) {
|
|
188
|
-
const receipt = await externalRuntime.sendAndWait(transaction);
|
|
189
|
-
if (prepared.steps[index]?.kind === 'createDeposit') {
|
|
190
|
-
createDepositReceipt = receipt;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (!createDepositReceipt) throw new Error('createDeposit receipt missing');
|
|
194
|
-
|
|
195
|
-
const result = cash.finalizePreparedCashout(createDepositReceipt);
|
|
196
|
-
if (prepared.accessPolicyRequired) {
|
|
197
|
-
await externalRuntime.sendAndWait(cash.prepareAccessPolicy(result.depositId));
|
|
198
|
-
}
|
|
199
|
-
await persistDepositId(result.depositId);
|
|
200
|
-
const liveOrder = await cash.order(result.depositId);
|
|
201
|
-
```
|
|
168
|
+
Venmo, Cash App, and PayPal must attach Plus, Pro, Peer Makers, and Peer Pay in
|
|
169
|
+
the same atomic operation that creates the deposit. A create-then-configure
|
|
170
|
+
sequence leaves a public interval in which an unapproved taker can signal an
|
|
171
|
+
intent. The generic `cashout()` and `prepare()` paths therefore throw
|
|
172
|
+
`ATOMIC_ACCESS_POLICY_REQUIRED` before wallet access, Relay quoting, payee
|
|
173
|
+
registration, allowance, or deposit submission. Peer web supports these rails
|
|
174
|
+
through its atomic Curator-backed flow. Other hosts must provide an equivalent
|
|
175
|
+
atomic batch rather than composing the two public SDK calls sequentially.
|
|
176
|
+
`capabilities()` marks these platforms with
|
|
177
|
+
`requiresAtomicAccessPolicy: true`.
|
|
178
|
+
|
|
179
|
+
`prepareAccessPolicy(depositId)` remains available only to recover a restricted
|
|
180
|
+
deposit already created by `0.4.4`. Configure that existing deposit immediately;
|
|
181
|
+
do not call `cashout()` again and do not use this recovery helper as a new-order
|
|
182
|
+
flow.
|
|
202
183
|
|
|
203
184
|
`capabilities()` presents Zelle as one platform. A cashout with
|
|
204
185
|
`receive.platform: 'zelle'` attaches only the generic Zelle payment method to
|
|
@@ -199,6 +199,12 @@ var errors = {
|
|
|
199
199
|
},
|
|
200
200
|
{ cause }
|
|
201
201
|
),
|
|
202
|
+
atomicAccessPolicyRequired: (platforms) => new CashError({
|
|
203
|
+
code: "ATOMIC_ACCESS_POLICY_REQUIRED",
|
|
204
|
+
message: `${platforms.join(", ")} cash-outs require atomic deposit creation and access-policy configuration.`,
|
|
205
|
+
retryable: false,
|
|
206
|
+
remediation: `Use Peer web or a host that atomically batches guard-before, createDeposit, guard-after, and configureDeposit. Nothing was submitted by this call.`
|
|
207
|
+
}),
|
|
202
208
|
sourceRouteUnsupportedInPrepare: () => new CashError({
|
|
203
209
|
code: "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE",
|
|
204
210
|
message: `prepare() cannot execute a Relay source route before creating the Base USDC cash-out.`,
|
|
@@ -311,6 +311,11 @@ interface CashPlatformCapability {
|
|
|
311
311
|
* `PAYEE_VERIFICATION_REQUIRED`.
|
|
312
312
|
*/
|
|
313
313
|
requiresIdentityAttestation: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* When true, the platform needs deposit creation and access-policy setup in
|
|
316
|
+
* one atomic host operation. Generic `cashout()` and `prepare()` fail closed.
|
|
317
|
+
*/
|
|
318
|
+
requiresAtomicAccessPolicy: boolean;
|
|
314
319
|
}
|
|
315
320
|
interface CashCapabilities {
|
|
316
321
|
chainId: number;
|
|
@@ -582,7 +587,7 @@ interface CashoutResult {
|
|
|
582
587
|
onchainDepositId: bigint;
|
|
583
588
|
/** Optimistic snapshot (`awaiting-buyer`); poll `order(depositId)` for live state. */
|
|
584
589
|
order: CashOrder;
|
|
585
|
-
/**
|
|
590
|
+
/** @deprecated Only present in recovery data produced by the unsafe 0.4.4 sequential flow. */
|
|
586
591
|
accessPolicyTxHash?: Hash;
|
|
587
592
|
/** Present when `cashout()` first routed a source asset through Relay. */
|
|
588
593
|
source?: {
|
|
@@ -610,7 +615,7 @@ interface PrepareResult {
|
|
|
610
615
|
register: {
|
|
611
616
|
hashedOnchainIds: string[];
|
|
612
617
|
};
|
|
613
|
-
/**
|
|
618
|
+
/** @deprecated Always false for new plans; restricted rails require an atomic host flow. */
|
|
614
619
|
accessPolicyRequired: boolean;
|
|
615
620
|
}
|
|
616
621
|
/** Confirmed createDeposit receipt from an externally executed prepare() plan. */
|
|
@@ -674,7 +679,7 @@ interface CashClient {
|
|
|
674
679
|
prepare(input: CashoutInput): Promise<PrepareResult>;
|
|
675
680
|
/** Resolve an externally executed createDeposit receipt into resumable cash-out state. */
|
|
676
681
|
finalizePreparedCashout(receipt: PreparedCashoutReceipt): CashoutResult;
|
|
677
|
-
/**
|
|
682
|
+
/** Recover an existing 0.4.4 restricted-rail deposit by preparing its four-group policy. */
|
|
678
683
|
prepareAccessPolicy(depositId: string): PreparedTransaction;
|
|
679
684
|
/** 3 - Observe: resumable from `depositId` alone; no session state anywhere. */
|
|
680
685
|
order(depositId: string): Promise<CashOrder>;
|
|
@@ -311,6 +311,11 @@ interface CashPlatformCapability {
|
|
|
311
311
|
* `PAYEE_VERIFICATION_REQUIRED`.
|
|
312
312
|
*/
|
|
313
313
|
requiresIdentityAttestation: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* When true, the platform needs deposit creation and access-policy setup in
|
|
316
|
+
* one atomic host operation. Generic `cashout()` and `prepare()` fail closed.
|
|
317
|
+
*/
|
|
318
|
+
requiresAtomicAccessPolicy: boolean;
|
|
314
319
|
}
|
|
315
320
|
interface CashCapabilities {
|
|
316
321
|
chainId: number;
|
|
@@ -582,7 +587,7 @@ interface CashoutResult {
|
|
|
582
587
|
onchainDepositId: bigint;
|
|
583
588
|
/** Optimistic snapshot (`awaiting-buyer`); poll `order(depositId)` for live state. */
|
|
584
589
|
order: CashOrder;
|
|
585
|
-
/**
|
|
590
|
+
/** @deprecated Only present in recovery data produced by the unsafe 0.4.4 sequential flow. */
|
|
586
591
|
accessPolicyTxHash?: Hash;
|
|
587
592
|
/** Present when `cashout()` first routed a source asset through Relay. */
|
|
588
593
|
source?: {
|
|
@@ -610,7 +615,7 @@ interface PrepareResult {
|
|
|
610
615
|
register: {
|
|
611
616
|
hashedOnchainIds: string[];
|
|
612
617
|
};
|
|
613
|
-
/**
|
|
618
|
+
/** @deprecated Always false for new plans; restricted rails require an atomic host flow. */
|
|
614
619
|
accessPolicyRequired: boolean;
|
|
615
620
|
}
|
|
616
621
|
/** Confirmed createDeposit receipt from an externally executed prepare() plan. */
|
|
@@ -674,7 +679,7 @@ interface CashClient {
|
|
|
674
679
|
prepare(input: CashoutInput): Promise<PrepareResult>;
|
|
675
680
|
/** Resolve an externally executed createDeposit receipt into resumable cash-out state. */
|
|
676
681
|
finalizePreparedCashout(receipt: PreparedCashoutReceipt): CashoutResult;
|
|
677
|
-
/**
|
|
682
|
+
/** Recover an existing 0.4.4 restricted-rail deposit by preparing its four-group policy. */
|
|
678
683
|
prepareAccessPolicy(depositId: string): PreparedTransaction;
|
|
679
684
|
/** 3 - Observe: resumable from `depositId` alone; no session state anywhere. */
|
|
680
685
|
order(depositId: string): Promise<CashOrder>;
|
package/dist/index.cjs
CHANGED
|
@@ -499,7 +499,8 @@ function buildCapabilities(environment) {
|
|
|
499
499
|
platform,
|
|
500
500
|
currencies: [...new Set(currencies2)].sort(),
|
|
501
501
|
payeeHint: PAYEE_HINTS[platform] ?? "Your payment handle for this platform",
|
|
502
|
-
requiresIdentityAttestation: IDENTITY_ATTESTATION_PLATFORMS.has(platform)
|
|
502
|
+
requiresIdentityAttestation: IDENTITY_ATTESTATION_PLATFORMS.has(platform),
|
|
503
|
+
requiresAtomicAccessPolicy: CASH_RESTRICTED_PLATFORMS.has(platform)
|
|
503
504
|
};
|
|
504
505
|
}).filter((p) => p.currencies.length > 0).sort((a, b) => a.platform.localeCompare(b.platform));
|
|
505
506
|
const currencies = [...new Set(platforms.flatMap((p) => p.currencies))].sort();
|
|
@@ -681,6 +682,12 @@ var errors = {
|
|
|
681
682
|
},
|
|
682
683
|
{ cause }
|
|
683
684
|
),
|
|
685
|
+
atomicAccessPolicyRequired: (platforms) => new CashError({
|
|
686
|
+
code: "ATOMIC_ACCESS_POLICY_REQUIRED",
|
|
687
|
+
message: `${platforms.join(", ")} cash-outs require atomic deposit creation and access-policy configuration.`,
|
|
688
|
+
retryable: false,
|
|
689
|
+
remediation: `Use Peer web or a host that atomically batches guard-before, createDeposit, guard-after, and configureDeposit. Nothing was submitted by this call.`
|
|
690
|
+
}),
|
|
684
691
|
sourceRouteUnsupportedInPrepare: () => new CashError({
|
|
685
692
|
code: "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE",
|
|
686
693
|
message: `prepare() cannot execute a Relay source route before creating the Base USDC cash-out.`,
|
|
@@ -1912,6 +1919,12 @@ function createCashClient(options) {
|
|
|
1912
1919
|
...range ? { intentAmountRange: range } : {}
|
|
1913
1920
|
};
|
|
1914
1921
|
}
|
|
1922
|
+
function assertGenericCashoutSupported(payoutInput) {
|
|
1923
|
+
const restrictedPlatforms = payoutInput.payouts.map((payout) => payout.processorName.toLowerCase()).filter((platform) => CASH_RESTRICTED_PLATFORMS.has(platform));
|
|
1924
|
+
if (restrictedPlatforms.length > 0) {
|
|
1925
|
+
throw errors.atomicAccessPolicyRequired(restrictedPlatforms);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1915
1928
|
function isCashPayoutSet(payouts) {
|
|
1916
1929
|
return payouts.length > 0 && payouts.every((payout) => payout.pricing.marketRate && payout.pricing.spreadBps === 0);
|
|
1917
1930
|
}
|
|
@@ -2151,42 +2164,6 @@ function createCashClient(options) {
|
|
|
2151
2164
|
if (lastNonceError) throw lastNonceError;
|
|
2152
2165
|
throw new Error(`Signer provider did not observe Relay nonce ${afterRelay - 1}`);
|
|
2153
2166
|
}
|
|
2154
|
-
async function configureCashoutAccess(client, signer, depositInput, depositId) {
|
|
2155
|
-
if (!depositInput.payouts.some(
|
|
2156
|
-
(payout) => CASH_RESTRICTED_PLATFORMS.has(payout.processorName.toLowerCase())
|
|
2157
|
-
)) {
|
|
2158
|
-
return void 0;
|
|
2159
|
-
}
|
|
2160
|
-
const groupIds = CASH_ACCESS_GROUP_IDS[environment];
|
|
2161
|
-
const prepared = prepareCashoutAccess(depositId, client);
|
|
2162
|
-
let hash;
|
|
2163
|
-
try {
|
|
2164
|
-
hash = await signer.sendTransaction({
|
|
2165
|
-
account: signer.account,
|
|
2166
|
-
chain: signer.chain,
|
|
2167
|
-
to: prepared.to,
|
|
2168
|
-
data: prepared.data,
|
|
2169
|
-
value: prepared.value
|
|
2170
|
-
});
|
|
2171
|
-
} catch (err) {
|
|
2172
|
-
throw errors.accessPolicyConfigurationFailed(depositId, groupIds, err);
|
|
2173
|
-
}
|
|
2174
|
-
let receipt;
|
|
2175
|
-
try {
|
|
2176
|
-
receipt = await client.publicClient.waitForTransactionReceipt({ hash });
|
|
2177
|
-
} catch (err) {
|
|
2178
|
-
throw errors.accessPolicyConfigurationFailed(depositId, groupIds, err, hash);
|
|
2179
|
-
}
|
|
2180
|
-
if (receipt.status === "reverted") {
|
|
2181
|
-
throw errors.accessPolicyConfigurationFailed(
|
|
2182
|
-
depositId,
|
|
2183
|
-
groupIds,
|
|
2184
|
-
errors.transactionFailed(hash),
|
|
2185
|
-
hash
|
|
2186
|
-
);
|
|
2187
|
-
}
|
|
2188
|
-
return hash;
|
|
2189
|
-
}
|
|
2190
2167
|
function prepareCashoutAccess(depositId, client = readClient) {
|
|
2191
2168
|
const { compositeId, escrowAddress, onchainDepositId } = parseDepositId(depositId);
|
|
2192
2169
|
const groupIds = CASH_ACCESS_GROUP_IDS[environment];
|
|
@@ -2246,6 +2223,7 @@ function createCashClient(options) {
|
|
|
2246
2223
|
},
|
|
2247
2224
|
async cashout(input, opts) {
|
|
2248
2225
|
const payoutInput = validatePayout(input);
|
|
2226
|
+
assertGenericCashoutSupported(payoutInput);
|
|
2249
2227
|
const client = await signingClient("cashout", opts);
|
|
2250
2228
|
const owner = opts.signer.account.address;
|
|
2251
2229
|
let sourceResult;
|
|
@@ -2343,12 +2321,6 @@ function createCashClient(options) {
|
|
|
2343
2321
|
const abi2 = client.escrowV2Abi ?? client.escrowAbi;
|
|
2344
2322
|
const resolved2 = resolveCashDepositId({ logs: receipt2.logs, abi: abi2 });
|
|
2345
2323
|
if (!resolved2) throw errors.depositResolutionFailed(hash2);
|
|
2346
|
-
const accessPolicyTxHash2 = await configureCashoutAccess(
|
|
2347
|
-
client,
|
|
2348
|
-
opts.signer,
|
|
2349
|
-
depositInput2,
|
|
2350
|
-
resolved2.compositeId
|
|
2351
|
-
);
|
|
2352
2324
|
const order2 = deriveCashOrder(resolved2.compositeId, [], {
|
|
2353
2325
|
remainingAmount: depositInput2.amount,
|
|
2354
2326
|
status: "ACTIVE"
|
|
@@ -2359,7 +2331,6 @@ function createCashClient(options) {
|
|
|
2359
2331
|
escrowAddress: resolved2.escrowAddress,
|
|
2360
2332
|
onchainDepositId: resolved2.onchainDepositId,
|
|
2361
2333
|
order: order2,
|
|
2362
|
-
...accessPolicyTxHash2 ? { accessPolicyTxHash: accessPolicyTxHash2 } : {},
|
|
2363
2334
|
source: routedSource
|
|
2364
2335
|
};
|
|
2365
2336
|
}
|
|
@@ -2404,12 +2375,6 @@ function createCashClient(options) {
|
|
|
2404
2375
|
const abi = client.escrowV2Abi ?? client.escrowAbi;
|
|
2405
2376
|
const resolved = resolveCashDepositId({ logs: receipt.logs, abi });
|
|
2406
2377
|
if (!resolved) throw errors.depositResolutionFailed(hash);
|
|
2407
|
-
const accessPolicyTxHash = await configureCashoutAccess(
|
|
2408
|
-
client,
|
|
2409
|
-
opts.signer,
|
|
2410
|
-
depositInput,
|
|
2411
|
-
resolved.compositeId
|
|
2412
|
-
);
|
|
2413
2378
|
const order = deriveCashOrder(resolved.compositeId, [], {
|
|
2414
2379
|
remainingAmount: depositInput.amount,
|
|
2415
2380
|
status: "ACTIVE"
|
|
@@ -2420,13 +2385,13 @@ function createCashClient(options) {
|
|
|
2420
2385
|
escrowAddress: resolved.escrowAddress,
|
|
2421
2386
|
onchainDepositId: resolved.onchainDepositId,
|
|
2422
2387
|
order,
|
|
2423
|
-
...accessPolicyTxHash ? { accessPolicyTxHash } : {},
|
|
2424
2388
|
...sourceResult ? { source: sourceResult } : {}
|
|
2425
2389
|
};
|
|
2426
2390
|
},
|
|
2427
2391
|
async prepare(input) {
|
|
2428
2392
|
if (input.source) throw errors.sourceRouteUnsupportedInPrepare();
|
|
2429
2393
|
const depositInput = validateDepositInput(input.amount, input);
|
|
2394
|
+
assertGenericCashoutSupported(depositInput);
|
|
2430
2395
|
const params = await buildDepositParams(readClient, depositInput);
|
|
2431
2396
|
const { prepared } = await readClient.prepareCreateDeposit({
|
|
2432
2397
|
...params,
|
|
@@ -2459,9 +2424,7 @@ function createCashClient(options) {
|
|
|
2459
2424
|
}
|
|
2460
2425
|
],
|
|
2461
2426
|
register: { hashedOnchainIds },
|
|
2462
|
-
accessPolicyRequired:
|
|
2463
|
-
(payout) => CASH_RESTRICTED_PLATFORMS.has(payout.processorName.toLowerCase())
|
|
2464
|
-
)
|
|
2427
|
+
accessPolicyRequired: false
|
|
2465
2428
|
};
|
|
2466
2429
|
},
|
|
2467
2430
|
finalizePreparedCashout(receipt) {
|
|
@@ -2988,7 +2951,8 @@ var cashCapabilitiesJsonSchema = zod.z.object({
|
|
|
2988
2951
|
platform: zod.z.string(),
|
|
2989
2952
|
currencies: zod.z.array(zod.z.string()),
|
|
2990
2953
|
payeeHint: zod.z.string(),
|
|
2991
|
-
requiresIdentityAttestation: zod.z.boolean()
|
|
2954
|
+
requiresIdentityAttestation: zod.z.boolean(),
|
|
2955
|
+
requiresAtomicAccessPolicy: zod.z.boolean().optional()
|
|
2992
2956
|
})
|
|
2993
2957
|
),
|
|
2994
2958
|
currencies: zod.z.array(zod.z.string()),
|
|
@@ -3024,6 +2988,7 @@ var CASH_ERROR_CODES = defineCashErrorCodes([
|
|
|
3024
2988
|
"ORDER_NOT_FOUND",
|
|
3025
2989
|
"PAYEE_REGISTRATION_FAILED",
|
|
3026
2990
|
"PAYEE_VERIFICATION_REQUIRED",
|
|
2991
|
+
"ATOMIC_ACCESS_POLICY_REQUIRED",
|
|
3027
2992
|
"SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE",
|
|
3028
2993
|
"SOURCE_RECIPIENT_MISMATCH",
|
|
3029
2994
|
"SOURCE_CAPABILITIES_FAILED",
|
|
@@ -3431,7 +3396,8 @@ function capabilitiesFromJson(json) {
|
|
|
3431
3396
|
},
|
|
3432
3397
|
platforms: parsed.platforms.map((p) => ({
|
|
3433
3398
|
...p,
|
|
3434
|
-
currencies: p.currencies
|
|
3399
|
+
currencies: p.currencies,
|
|
3400
|
+
requiresAtomicAccessPolicy: p.requiresAtomicAccessPolicy ?? CASH_RESTRICTED_PLATFORMS.has(p.platform)
|
|
3435
3401
|
})),
|
|
3436
3402
|
currencies: parsed.currencies,
|
|
3437
3403
|
amount: {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IntentStatus, C as CashPayoutInfo, a as IntentEntity, b as CashBuyerProfile, c as CashDepositInput, d as CreateDepositParamsArg, e as CashOrder, f as CashFill, g as CashCapabilities, h as CashoutResult, i as CashEstimate, j as CashFillStats, P as PrepareResult, k as CashPreparedStep, R as RelayExecutionResult, l as RelayQuote, m as RelayStatus, n as CashSourceCapabilities, T as TopUpResult, W as WithdrawResult } from './createCashClient-
|
|
2
|
-
export { o as CASH_ATTRIBUTION_CODE, p as CASH_REFERRAL_ATTRIBUTION_PREFIX, q as CashAsset, r as CashChain, s as CashClient, t as CashClientOptions, u as CashFillEta, v as CashLeg, w as CashMultiCurrencyLeg, x as CashNextAction, y as CashOrderState, z as CashPairFillStats, A as CashPayeeInput, B as CashPayout, D as CashPayoutPricing, E as CashPlatformCapability, F as CashPreparedStepKind, G as CashReceiveLeg, H as CashoutInput, J as CashoutOptions, K as CuratorPayeeDataInput, L as EstimateInput, M as EstimateOptions, N as MIN_CASHOUT_AMOUNT, O as OrdersOptions, Q as PreparedCashoutReceipt, S as RECOMMENDED_MIN_CASHOUT_AMOUNT, U as RelayOptions, V as RelayQuoteInput, X as RelaySourceInput, Y as RelayTransaction, Z as SignerOptions, _ as WatchOptions, $ as WithdrawOptions, a0 as buildCapabilities, a1 as createCashClient, a2 as normalizeCashPayee, a3 as toCashReferralAttributionCode } from './createCashClient-
|
|
1
|
+
import { I as IntentStatus, C as CashPayoutInfo, a as IntentEntity, b as CashBuyerProfile, c as CashDepositInput, d as CreateDepositParamsArg, e as CashOrder, f as CashFill, g as CashCapabilities, h as CashoutResult, i as CashEstimate, j as CashFillStats, P as PrepareResult, k as CashPreparedStep, R as RelayExecutionResult, l as RelayQuote, m as RelayStatus, n as CashSourceCapabilities, T as TopUpResult, W as WithdrawResult } from './createCashClient-CL1SCbqF.cjs';
|
|
2
|
+
export { o as CASH_ATTRIBUTION_CODE, p as CASH_REFERRAL_ATTRIBUTION_PREFIX, q as CashAsset, r as CashChain, s as CashClient, t as CashClientOptions, u as CashFillEta, v as CashLeg, w as CashMultiCurrencyLeg, x as CashNextAction, y as CashOrderState, z as CashPairFillStats, A as CashPayeeInput, B as CashPayout, D as CashPayoutPricing, E as CashPlatformCapability, F as CashPreparedStepKind, G as CashReceiveLeg, H as CashoutInput, J as CashoutOptions, K as CuratorPayeeDataInput, L as EstimateInput, M as EstimateOptions, N as MIN_CASHOUT_AMOUNT, O as OrdersOptions, Q as PreparedCashoutReceipt, S as RECOMMENDED_MIN_CASHOUT_AMOUNT, U as RelayOptions, V as RelayQuoteInput, X as RelaySourceInput, Y as RelayTransaction, Z as SignerOptions, _ as WatchOptions, $ as WithdrawOptions, a0 as buildCapabilities, a1 as createCashClient, a2 as normalizeCashPayee, a3 as toCashReferralAttributionCode } from './createCashClient-CL1SCbqF.cjs';
|
|
3
3
|
import { PaymentMethodCatalog, CurrencyType, OracleAdapterOverrides, OnchainCurrency, Zkp2pClient, PreparedTransaction } from '@zkp2p/sdk';
|
|
4
4
|
export { CurrencyType, PreparedTransaction, RuntimeEnv } from '@zkp2p/sdk';
|
|
5
5
|
import { Log, Abi } from 'viem';
|
|
@@ -10,7 +10,7 @@ import '@relayprotocol/relay-sdk';
|
|
|
10
10
|
* Typed errors - every failure carries a `code`, whether it is `retryable`,
|
|
11
11
|
* and a `remediation` sentence so agents can self-drive recovery.
|
|
12
12
|
*/
|
|
13
|
-
type CashErrorCode = 'ORACLE_UNSUPPORTED_CURRENCY' | 'ORACLE_READ_FAILED' | 'UNSUPPORTED_PLATFORM' | 'UNSUPPORTED_PLATFORM_CURRENCY' | 'AMOUNT_BELOW_MINIMUM' | 'INVALID_INTENT_AMOUNT_RANGE' | 'INVALID_PAYOUT_CURRENCIES' | 'INVALID_PAYOUT_PLATFORMS' | 'INVALID_REFERRAL_CODE' | 'ACTIVE_INTENT_BLOCKS_WITHDRAWAL' | 'NOTHING_TO_WITHDRAW' | 'INSUFFICIENT_AVAILABLE_FUNDS' | 'INSUFFICIENT_TOKEN_BALANCE' | 'ORDER_NOT_ACTIVE' | 'INVALID_DEPOSIT_ID' | 'ESCROW_PAUSED' | 'INDEXER_LAG' | 'INDEXER_UNAVAILABLE' | 'ORDER_NOT_FOUND' | 'PAYEE_REGISTRATION_FAILED' | 'PAYEE_VERIFICATION_REQUIRED' | 'SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE' | 'SOURCE_RECIPIENT_MISMATCH' | 'SOURCE_CAPABILITIES_FAILED' | 'SOURCE_QUOTE_FAILED' | 'SOURCE_NONCE_MANAGER_REQUIRED' | 'SOURCE_EXECUTION_FAILED' | 'SOURCE_STATUS_FAILED' | 'SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED' | 'SOURCE_CASHOUT_SUBMISSION_UNKNOWN' | 'SOURCE_CASHOUT_STATUS_UNKNOWN' | 'DEPOSIT_RESOLUTION_FAILED' | 'ACCESS_POLICY_CONFIGURATION_FAILED' | 'ALLOWANCE_NOT_VISIBLE' | 'SIGNER_REQUIRED' | 'SIGNER_CHAIN_MISMATCH' | 'SIGNER_CHAIN_UNAVAILABLE' | 'WATCH_TIMEOUT' | 'TRANSACTION_REJECTED' | 'TRANSACTION_FAILED' | 'TRANSACTION_SUBMISSION_UNKNOWN' | 'TRANSACTION_STATUS_UNKNOWN';
|
|
13
|
+
type CashErrorCode = 'ORACLE_UNSUPPORTED_CURRENCY' | 'ORACLE_READ_FAILED' | 'UNSUPPORTED_PLATFORM' | 'UNSUPPORTED_PLATFORM_CURRENCY' | 'AMOUNT_BELOW_MINIMUM' | 'INVALID_INTENT_AMOUNT_RANGE' | 'INVALID_PAYOUT_CURRENCIES' | 'INVALID_PAYOUT_PLATFORMS' | 'INVALID_REFERRAL_CODE' | 'ACTIVE_INTENT_BLOCKS_WITHDRAWAL' | 'NOTHING_TO_WITHDRAW' | 'INSUFFICIENT_AVAILABLE_FUNDS' | 'INSUFFICIENT_TOKEN_BALANCE' | 'ORDER_NOT_ACTIVE' | 'INVALID_DEPOSIT_ID' | 'ESCROW_PAUSED' | 'INDEXER_LAG' | 'INDEXER_UNAVAILABLE' | 'ORDER_NOT_FOUND' | 'PAYEE_REGISTRATION_FAILED' | 'PAYEE_VERIFICATION_REQUIRED' | 'ATOMIC_ACCESS_POLICY_REQUIRED' | 'SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE' | 'SOURCE_RECIPIENT_MISMATCH' | 'SOURCE_CAPABILITIES_FAILED' | 'SOURCE_QUOTE_FAILED' | 'SOURCE_NONCE_MANAGER_REQUIRED' | 'SOURCE_EXECUTION_FAILED' | 'SOURCE_STATUS_FAILED' | 'SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED' | 'SOURCE_CASHOUT_SUBMISSION_UNKNOWN' | 'SOURCE_CASHOUT_STATUS_UNKNOWN' | 'DEPOSIT_RESOLUTION_FAILED' | 'ACCESS_POLICY_CONFIGURATION_FAILED' | 'ALLOWANCE_NOT_VISIBLE' | 'SIGNER_REQUIRED' | 'SIGNER_CHAIN_MISMATCH' | 'SIGNER_CHAIN_UNAVAILABLE' | 'WATCH_TIMEOUT' | 'TRANSACTION_REJECTED' | 'TRANSACTION_FAILED' | 'TRANSACTION_SUBMISSION_UNKNOWN' | 'TRANSACTION_STATUS_UNKNOWN';
|
|
14
14
|
interface CashErrorShape {
|
|
15
15
|
code: CashErrorCode;
|
|
16
16
|
message: string;
|
|
@@ -96,6 +96,7 @@ declare const errors: {
|
|
|
96
96
|
indexerUnavailable: (operation: string, cause?: unknown) => CashError;
|
|
97
97
|
payeeRegistrationFailed: (cause: unknown) => CashError;
|
|
98
98
|
payeeVerificationRequired: (platform: string, cause?: unknown) => CashError;
|
|
99
|
+
atomicAccessPolicyRequired: (platforms: readonly string[]) => CashError;
|
|
99
100
|
sourceRouteUnsupportedInPrepare: () => CashError;
|
|
100
101
|
sourceRecipientMismatch: (recipient: string, owner: string) => CashError;
|
|
101
102
|
sourceCapabilitiesFailed: (cause?: unknown) => CashError;
|
|
@@ -2291,10 +2292,10 @@ declare const prepareResultJsonSchema: z.ZodObject<{
|
|
|
2291
2292
|
to: string;
|
|
2292
2293
|
value: string;
|
|
2293
2294
|
}[];
|
|
2295
|
+
accessPolicyRequired: boolean;
|
|
2294
2296
|
register: {
|
|
2295
2297
|
hashedOnchainIds: string[];
|
|
2296
2298
|
};
|
|
2297
|
-
accessPolicyRequired: boolean;
|
|
2298
2299
|
}, {
|
|
2299
2300
|
steps: {
|
|
2300
2301
|
kind: "createDeposit" | "approve" | "pruneExpiredIntents" | "withdrawDeposit" | "removeFunds" | "addFunds";
|
|
@@ -2306,10 +2307,10 @@ declare const prepareResultJsonSchema: z.ZodObject<{
|
|
|
2306
2307
|
to: string;
|
|
2307
2308
|
value: string;
|
|
2308
2309
|
}[];
|
|
2310
|
+
accessPolicyRequired: boolean;
|
|
2309
2311
|
register: {
|
|
2310
2312
|
hashedOnchainIds: string[];
|
|
2311
2313
|
};
|
|
2312
|
-
accessPolicyRequired: boolean;
|
|
2313
2314
|
}>;
|
|
2314
2315
|
declare const withdrawResultJsonSchema: z.ZodObject<{
|
|
2315
2316
|
depositId: z.ZodString;
|
|
@@ -2638,16 +2639,19 @@ declare const cashCapabilitiesJsonSchema: z.ZodObject<{
|
|
|
2638
2639
|
currencies: z.ZodArray<z.ZodString, "many">;
|
|
2639
2640
|
payeeHint: z.ZodString;
|
|
2640
2641
|
requiresIdentityAttestation: z.ZodBoolean;
|
|
2642
|
+
requiresAtomicAccessPolicy: z.ZodOptional<z.ZodBoolean>;
|
|
2641
2643
|
}, "strip", z.ZodTypeAny, {
|
|
2642
2644
|
platform: string;
|
|
2643
2645
|
currencies: string[];
|
|
2644
2646
|
payeeHint: string;
|
|
2645
2647
|
requiresIdentityAttestation: boolean;
|
|
2648
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2646
2649
|
}, {
|
|
2647
2650
|
platform: string;
|
|
2648
2651
|
currencies: string[];
|
|
2649
2652
|
payeeHint: string;
|
|
2650
2653
|
requiresIdentityAttestation: boolean;
|
|
2654
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2651
2655
|
}>, "many">;
|
|
2652
2656
|
currencies: z.ZodArray<z.ZodString, "many">;
|
|
2653
2657
|
amount: z.ZodObject<{
|
|
@@ -2739,6 +2743,7 @@ declare const cashCapabilitiesJsonSchema: z.ZodObject<{
|
|
|
2739
2743
|
currencies: string[];
|
|
2740
2744
|
payeeHint: string;
|
|
2741
2745
|
requiresIdentityAttestation: boolean;
|
|
2746
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2742
2747
|
}[];
|
|
2743
2748
|
pricing: {
|
|
2744
2749
|
spreadBps: 0;
|
|
@@ -2810,6 +2815,7 @@ declare const cashCapabilitiesJsonSchema: z.ZodObject<{
|
|
|
2810
2815
|
currencies: string[];
|
|
2811
2816
|
payeeHint: string;
|
|
2812
2817
|
requiresIdentityAttestation: boolean;
|
|
2818
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2813
2819
|
}[];
|
|
2814
2820
|
pricing: {
|
|
2815
2821
|
spreadBps: 0;
|
|
@@ -3213,7 +3219,7 @@ declare const cashErrorRecoveryJsonSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
|
|
|
3213
3219
|
transactionHash?: string | undefined;
|
|
3214
3220
|
}>]>;
|
|
3215
3221
|
declare const cashErrorJsonSchema: z.ZodObject<{
|
|
3216
|
-
code: z.ZodEnum<["ORACLE_UNSUPPORTED_CURRENCY", "ORACLE_READ_FAILED", "UNSUPPORTED_PLATFORM", "UNSUPPORTED_PLATFORM_CURRENCY", "AMOUNT_BELOW_MINIMUM", "INVALID_INTENT_AMOUNT_RANGE", "INVALID_PAYOUT_CURRENCIES", "INVALID_PAYOUT_PLATFORMS", "INVALID_REFERRAL_CODE", "ACTIVE_INTENT_BLOCKS_WITHDRAWAL", "NOTHING_TO_WITHDRAW", "INSUFFICIENT_AVAILABLE_FUNDS", "INSUFFICIENT_TOKEN_BALANCE", "ORDER_NOT_ACTIVE", "INVALID_DEPOSIT_ID", "ESCROW_PAUSED", "INDEXER_LAG", "INDEXER_UNAVAILABLE", "ORDER_NOT_FOUND", "PAYEE_REGISTRATION_FAILED", "PAYEE_VERIFICATION_REQUIRED", "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE", "SOURCE_RECIPIENT_MISMATCH", "SOURCE_CAPABILITIES_FAILED", "SOURCE_QUOTE_FAILED", "SOURCE_NONCE_MANAGER_REQUIRED", "SOURCE_EXECUTION_FAILED", "SOURCE_STATUS_FAILED", "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED", "SOURCE_CASHOUT_SUBMISSION_UNKNOWN", "SOURCE_CASHOUT_STATUS_UNKNOWN", "DEPOSIT_RESOLUTION_FAILED", "ACCESS_POLICY_CONFIGURATION_FAILED", "ALLOWANCE_NOT_VISIBLE", "SIGNER_REQUIRED", "SIGNER_CHAIN_MISMATCH", "SIGNER_CHAIN_UNAVAILABLE", "WATCH_TIMEOUT", "TRANSACTION_REJECTED", "TRANSACTION_FAILED", "TRANSACTION_SUBMISSION_UNKNOWN", "TRANSACTION_STATUS_UNKNOWN"]>;
|
|
3222
|
+
code: z.ZodEnum<["ORACLE_UNSUPPORTED_CURRENCY", "ORACLE_READ_FAILED", "UNSUPPORTED_PLATFORM", "UNSUPPORTED_PLATFORM_CURRENCY", "AMOUNT_BELOW_MINIMUM", "INVALID_INTENT_AMOUNT_RANGE", "INVALID_PAYOUT_CURRENCIES", "INVALID_PAYOUT_PLATFORMS", "INVALID_REFERRAL_CODE", "ACTIVE_INTENT_BLOCKS_WITHDRAWAL", "NOTHING_TO_WITHDRAW", "INSUFFICIENT_AVAILABLE_FUNDS", "INSUFFICIENT_TOKEN_BALANCE", "ORDER_NOT_ACTIVE", "INVALID_DEPOSIT_ID", "ESCROW_PAUSED", "INDEXER_LAG", "INDEXER_UNAVAILABLE", "ORDER_NOT_FOUND", "PAYEE_REGISTRATION_FAILED", "PAYEE_VERIFICATION_REQUIRED", "ATOMIC_ACCESS_POLICY_REQUIRED", "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE", "SOURCE_RECIPIENT_MISMATCH", "SOURCE_CAPABILITIES_FAILED", "SOURCE_QUOTE_FAILED", "SOURCE_NONCE_MANAGER_REQUIRED", "SOURCE_EXECUTION_FAILED", "SOURCE_STATUS_FAILED", "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED", "SOURCE_CASHOUT_SUBMISSION_UNKNOWN", "SOURCE_CASHOUT_STATUS_UNKNOWN", "DEPOSIT_RESOLUTION_FAILED", "ACCESS_POLICY_CONFIGURATION_FAILED", "ALLOWANCE_NOT_VISIBLE", "SIGNER_REQUIRED", "SIGNER_CHAIN_MISMATCH", "SIGNER_CHAIN_UNAVAILABLE", "WATCH_TIMEOUT", "TRANSACTION_REJECTED", "TRANSACTION_FAILED", "TRANSACTION_SUBMISSION_UNKNOWN", "TRANSACTION_STATUS_UNKNOWN"]>;
|
|
3217
3223
|
message: z.ZodString;
|
|
3218
3224
|
retryable: z.ZodBoolean;
|
|
3219
3225
|
remediation: z.ZodString;
|
|
@@ -3615,7 +3621,7 @@ declare const cashErrorJsonSchema: z.ZodObject<{
|
|
|
3615
3621
|
}>]>>;
|
|
3616
3622
|
}, "strict", z.ZodTypeAny, {
|
|
3617
3623
|
message: string;
|
|
3618
|
-
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3624
|
+
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "ATOMIC_ACCESS_POLICY_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3619
3625
|
retryable: boolean;
|
|
3620
3626
|
remediation: string;
|
|
3621
3627
|
recovery?: {
|
|
@@ -3702,7 +3708,7 @@ declare const cashErrorJsonSchema: z.ZodObject<{
|
|
|
3702
3708
|
} | undefined;
|
|
3703
3709
|
}, {
|
|
3704
3710
|
message: string;
|
|
3705
|
-
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3711
|
+
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "ATOMIC_ACCESS_POLICY_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3706
3712
|
retryable: boolean;
|
|
3707
3713
|
remediation: string;
|
|
3708
3714
|
recovery?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IntentStatus, C as CashPayoutInfo, a as IntentEntity, b as CashBuyerProfile, c as CashDepositInput, d as CreateDepositParamsArg, e as CashOrder, f as CashFill, g as CashCapabilities, h as CashoutResult, i as CashEstimate, j as CashFillStats, P as PrepareResult, k as CashPreparedStep, R as RelayExecutionResult, l as RelayQuote, m as RelayStatus, n as CashSourceCapabilities, T as TopUpResult, W as WithdrawResult } from './createCashClient-
|
|
2
|
-
export { o as CASH_ATTRIBUTION_CODE, p as CASH_REFERRAL_ATTRIBUTION_PREFIX, q as CashAsset, r as CashChain, s as CashClient, t as CashClientOptions, u as CashFillEta, v as CashLeg, w as CashMultiCurrencyLeg, x as CashNextAction, y as CashOrderState, z as CashPairFillStats, A as CashPayeeInput, B as CashPayout, D as CashPayoutPricing, E as CashPlatformCapability, F as CashPreparedStepKind, G as CashReceiveLeg, H as CashoutInput, J as CashoutOptions, K as CuratorPayeeDataInput, L as EstimateInput, M as EstimateOptions, N as MIN_CASHOUT_AMOUNT, O as OrdersOptions, Q as PreparedCashoutReceipt, S as RECOMMENDED_MIN_CASHOUT_AMOUNT, U as RelayOptions, V as RelayQuoteInput, X as RelaySourceInput, Y as RelayTransaction, Z as SignerOptions, _ as WatchOptions, $ as WithdrawOptions, a0 as buildCapabilities, a1 as createCashClient, a2 as normalizeCashPayee, a3 as toCashReferralAttributionCode } from './createCashClient-
|
|
1
|
+
import { I as IntentStatus, C as CashPayoutInfo, a as IntentEntity, b as CashBuyerProfile, c as CashDepositInput, d as CreateDepositParamsArg, e as CashOrder, f as CashFill, g as CashCapabilities, h as CashoutResult, i as CashEstimate, j as CashFillStats, P as PrepareResult, k as CashPreparedStep, R as RelayExecutionResult, l as RelayQuote, m as RelayStatus, n as CashSourceCapabilities, T as TopUpResult, W as WithdrawResult } from './createCashClient-CL1SCbqF.js';
|
|
2
|
+
export { o as CASH_ATTRIBUTION_CODE, p as CASH_REFERRAL_ATTRIBUTION_PREFIX, q as CashAsset, r as CashChain, s as CashClient, t as CashClientOptions, u as CashFillEta, v as CashLeg, w as CashMultiCurrencyLeg, x as CashNextAction, y as CashOrderState, z as CashPairFillStats, A as CashPayeeInput, B as CashPayout, D as CashPayoutPricing, E as CashPlatformCapability, F as CashPreparedStepKind, G as CashReceiveLeg, H as CashoutInput, J as CashoutOptions, K as CuratorPayeeDataInput, L as EstimateInput, M as EstimateOptions, N as MIN_CASHOUT_AMOUNT, O as OrdersOptions, Q as PreparedCashoutReceipt, S as RECOMMENDED_MIN_CASHOUT_AMOUNT, U as RelayOptions, V as RelayQuoteInput, X as RelaySourceInput, Y as RelayTransaction, Z as SignerOptions, _ as WatchOptions, $ as WithdrawOptions, a0 as buildCapabilities, a1 as createCashClient, a2 as normalizeCashPayee, a3 as toCashReferralAttributionCode } from './createCashClient-CL1SCbqF.js';
|
|
3
3
|
import { PaymentMethodCatalog, CurrencyType, OracleAdapterOverrides, OnchainCurrency, Zkp2pClient, PreparedTransaction } from '@zkp2p/sdk';
|
|
4
4
|
export { CurrencyType, PreparedTransaction, RuntimeEnv } from '@zkp2p/sdk';
|
|
5
5
|
import { Log, Abi } from 'viem';
|
|
@@ -10,7 +10,7 @@ import '@relayprotocol/relay-sdk';
|
|
|
10
10
|
* Typed errors - every failure carries a `code`, whether it is `retryable`,
|
|
11
11
|
* and a `remediation` sentence so agents can self-drive recovery.
|
|
12
12
|
*/
|
|
13
|
-
type CashErrorCode = 'ORACLE_UNSUPPORTED_CURRENCY' | 'ORACLE_READ_FAILED' | 'UNSUPPORTED_PLATFORM' | 'UNSUPPORTED_PLATFORM_CURRENCY' | 'AMOUNT_BELOW_MINIMUM' | 'INVALID_INTENT_AMOUNT_RANGE' | 'INVALID_PAYOUT_CURRENCIES' | 'INVALID_PAYOUT_PLATFORMS' | 'INVALID_REFERRAL_CODE' | 'ACTIVE_INTENT_BLOCKS_WITHDRAWAL' | 'NOTHING_TO_WITHDRAW' | 'INSUFFICIENT_AVAILABLE_FUNDS' | 'INSUFFICIENT_TOKEN_BALANCE' | 'ORDER_NOT_ACTIVE' | 'INVALID_DEPOSIT_ID' | 'ESCROW_PAUSED' | 'INDEXER_LAG' | 'INDEXER_UNAVAILABLE' | 'ORDER_NOT_FOUND' | 'PAYEE_REGISTRATION_FAILED' | 'PAYEE_VERIFICATION_REQUIRED' | 'SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE' | 'SOURCE_RECIPIENT_MISMATCH' | 'SOURCE_CAPABILITIES_FAILED' | 'SOURCE_QUOTE_FAILED' | 'SOURCE_NONCE_MANAGER_REQUIRED' | 'SOURCE_EXECUTION_FAILED' | 'SOURCE_STATUS_FAILED' | 'SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED' | 'SOURCE_CASHOUT_SUBMISSION_UNKNOWN' | 'SOURCE_CASHOUT_STATUS_UNKNOWN' | 'DEPOSIT_RESOLUTION_FAILED' | 'ACCESS_POLICY_CONFIGURATION_FAILED' | 'ALLOWANCE_NOT_VISIBLE' | 'SIGNER_REQUIRED' | 'SIGNER_CHAIN_MISMATCH' | 'SIGNER_CHAIN_UNAVAILABLE' | 'WATCH_TIMEOUT' | 'TRANSACTION_REJECTED' | 'TRANSACTION_FAILED' | 'TRANSACTION_SUBMISSION_UNKNOWN' | 'TRANSACTION_STATUS_UNKNOWN';
|
|
13
|
+
type CashErrorCode = 'ORACLE_UNSUPPORTED_CURRENCY' | 'ORACLE_READ_FAILED' | 'UNSUPPORTED_PLATFORM' | 'UNSUPPORTED_PLATFORM_CURRENCY' | 'AMOUNT_BELOW_MINIMUM' | 'INVALID_INTENT_AMOUNT_RANGE' | 'INVALID_PAYOUT_CURRENCIES' | 'INVALID_PAYOUT_PLATFORMS' | 'INVALID_REFERRAL_CODE' | 'ACTIVE_INTENT_BLOCKS_WITHDRAWAL' | 'NOTHING_TO_WITHDRAW' | 'INSUFFICIENT_AVAILABLE_FUNDS' | 'INSUFFICIENT_TOKEN_BALANCE' | 'ORDER_NOT_ACTIVE' | 'INVALID_DEPOSIT_ID' | 'ESCROW_PAUSED' | 'INDEXER_LAG' | 'INDEXER_UNAVAILABLE' | 'ORDER_NOT_FOUND' | 'PAYEE_REGISTRATION_FAILED' | 'PAYEE_VERIFICATION_REQUIRED' | 'ATOMIC_ACCESS_POLICY_REQUIRED' | 'SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE' | 'SOURCE_RECIPIENT_MISMATCH' | 'SOURCE_CAPABILITIES_FAILED' | 'SOURCE_QUOTE_FAILED' | 'SOURCE_NONCE_MANAGER_REQUIRED' | 'SOURCE_EXECUTION_FAILED' | 'SOURCE_STATUS_FAILED' | 'SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED' | 'SOURCE_CASHOUT_SUBMISSION_UNKNOWN' | 'SOURCE_CASHOUT_STATUS_UNKNOWN' | 'DEPOSIT_RESOLUTION_FAILED' | 'ACCESS_POLICY_CONFIGURATION_FAILED' | 'ALLOWANCE_NOT_VISIBLE' | 'SIGNER_REQUIRED' | 'SIGNER_CHAIN_MISMATCH' | 'SIGNER_CHAIN_UNAVAILABLE' | 'WATCH_TIMEOUT' | 'TRANSACTION_REJECTED' | 'TRANSACTION_FAILED' | 'TRANSACTION_SUBMISSION_UNKNOWN' | 'TRANSACTION_STATUS_UNKNOWN';
|
|
14
14
|
interface CashErrorShape {
|
|
15
15
|
code: CashErrorCode;
|
|
16
16
|
message: string;
|
|
@@ -96,6 +96,7 @@ declare const errors: {
|
|
|
96
96
|
indexerUnavailable: (operation: string, cause?: unknown) => CashError;
|
|
97
97
|
payeeRegistrationFailed: (cause: unknown) => CashError;
|
|
98
98
|
payeeVerificationRequired: (platform: string, cause?: unknown) => CashError;
|
|
99
|
+
atomicAccessPolicyRequired: (platforms: readonly string[]) => CashError;
|
|
99
100
|
sourceRouteUnsupportedInPrepare: () => CashError;
|
|
100
101
|
sourceRecipientMismatch: (recipient: string, owner: string) => CashError;
|
|
101
102
|
sourceCapabilitiesFailed: (cause?: unknown) => CashError;
|
|
@@ -2291,10 +2292,10 @@ declare const prepareResultJsonSchema: z.ZodObject<{
|
|
|
2291
2292
|
to: string;
|
|
2292
2293
|
value: string;
|
|
2293
2294
|
}[];
|
|
2295
|
+
accessPolicyRequired: boolean;
|
|
2294
2296
|
register: {
|
|
2295
2297
|
hashedOnchainIds: string[];
|
|
2296
2298
|
};
|
|
2297
|
-
accessPolicyRequired: boolean;
|
|
2298
2299
|
}, {
|
|
2299
2300
|
steps: {
|
|
2300
2301
|
kind: "createDeposit" | "approve" | "pruneExpiredIntents" | "withdrawDeposit" | "removeFunds" | "addFunds";
|
|
@@ -2306,10 +2307,10 @@ declare const prepareResultJsonSchema: z.ZodObject<{
|
|
|
2306
2307
|
to: string;
|
|
2307
2308
|
value: string;
|
|
2308
2309
|
}[];
|
|
2310
|
+
accessPolicyRequired: boolean;
|
|
2309
2311
|
register: {
|
|
2310
2312
|
hashedOnchainIds: string[];
|
|
2311
2313
|
};
|
|
2312
|
-
accessPolicyRequired: boolean;
|
|
2313
2314
|
}>;
|
|
2314
2315
|
declare const withdrawResultJsonSchema: z.ZodObject<{
|
|
2315
2316
|
depositId: z.ZodString;
|
|
@@ -2638,16 +2639,19 @@ declare const cashCapabilitiesJsonSchema: z.ZodObject<{
|
|
|
2638
2639
|
currencies: z.ZodArray<z.ZodString, "many">;
|
|
2639
2640
|
payeeHint: z.ZodString;
|
|
2640
2641
|
requiresIdentityAttestation: z.ZodBoolean;
|
|
2642
|
+
requiresAtomicAccessPolicy: z.ZodOptional<z.ZodBoolean>;
|
|
2641
2643
|
}, "strip", z.ZodTypeAny, {
|
|
2642
2644
|
platform: string;
|
|
2643
2645
|
currencies: string[];
|
|
2644
2646
|
payeeHint: string;
|
|
2645
2647
|
requiresIdentityAttestation: boolean;
|
|
2648
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2646
2649
|
}, {
|
|
2647
2650
|
platform: string;
|
|
2648
2651
|
currencies: string[];
|
|
2649
2652
|
payeeHint: string;
|
|
2650
2653
|
requiresIdentityAttestation: boolean;
|
|
2654
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2651
2655
|
}>, "many">;
|
|
2652
2656
|
currencies: z.ZodArray<z.ZodString, "many">;
|
|
2653
2657
|
amount: z.ZodObject<{
|
|
@@ -2739,6 +2743,7 @@ declare const cashCapabilitiesJsonSchema: z.ZodObject<{
|
|
|
2739
2743
|
currencies: string[];
|
|
2740
2744
|
payeeHint: string;
|
|
2741
2745
|
requiresIdentityAttestation: boolean;
|
|
2746
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2742
2747
|
}[];
|
|
2743
2748
|
pricing: {
|
|
2744
2749
|
spreadBps: 0;
|
|
@@ -2810,6 +2815,7 @@ declare const cashCapabilitiesJsonSchema: z.ZodObject<{
|
|
|
2810
2815
|
currencies: string[];
|
|
2811
2816
|
payeeHint: string;
|
|
2812
2817
|
requiresIdentityAttestation: boolean;
|
|
2818
|
+
requiresAtomicAccessPolicy?: boolean | undefined;
|
|
2813
2819
|
}[];
|
|
2814
2820
|
pricing: {
|
|
2815
2821
|
spreadBps: 0;
|
|
@@ -3213,7 +3219,7 @@ declare const cashErrorRecoveryJsonSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
|
|
|
3213
3219
|
transactionHash?: string | undefined;
|
|
3214
3220
|
}>]>;
|
|
3215
3221
|
declare const cashErrorJsonSchema: z.ZodObject<{
|
|
3216
|
-
code: z.ZodEnum<["ORACLE_UNSUPPORTED_CURRENCY", "ORACLE_READ_FAILED", "UNSUPPORTED_PLATFORM", "UNSUPPORTED_PLATFORM_CURRENCY", "AMOUNT_BELOW_MINIMUM", "INVALID_INTENT_AMOUNT_RANGE", "INVALID_PAYOUT_CURRENCIES", "INVALID_PAYOUT_PLATFORMS", "INVALID_REFERRAL_CODE", "ACTIVE_INTENT_BLOCKS_WITHDRAWAL", "NOTHING_TO_WITHDRAW", "INSUFFICIENT_AVAILABLE_FUNDS", "INSUFFICIENT_TOKEN_BALANCE", "ORDER_NOT_ACTIVE", "INVALID_DEPOSIT_ID", "ESCROW_PAUSED", "INDEXER_LAG", "INDEXER_UNAVAILABLE", "ORDER_NOT_FOUND", "PAYEE_REGISTRATION_FAILED", "PAYEE_VERIFICATION_REQUIRED", "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE", "SOURCE_RECIPIENT_MISMATCH", "SOURCE_CAPABILITIES_FAILED", "SOURCE_QUOTE_FAILED", "SOURCE_NONCE_MANAGER_REQUIRED", "SOURCE_EXECUTION_FAILED", "SOURCE_STATUS_FAILED", "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED", "SOURCE_CASHOUT_SUBMISSION_UNKNOWN", "SOURCE_CASHOUT_STATUS_UNKNOWN", "DEPOSIT_RESOLUTION_FAILED", "ACCESS_POLICY_CONFIGURATION_FAILED", "ALLOWANCE_NOT_VISIBLE", "SIGNER_REQUIRED", "SIGNER_CHAIN_MISMATCH", "SIGNER_CHAIN_UNAVAILABLE", "WATCH_TIMEOUT", "TRANSACTION_REJECTED", "TRANSACTION_FAILED", "TRANSACTION_SUBMISSION_UNKNOWN", "TRANSACTION_STATUS_UNKNOWN"]>;
|
|
3222
|
+
code: z.ZodEnum<["ORACLE_UNSUPPORTED_CURRENCY", "ORACLE_READ_FAILED", "UNSUPPORTED_PLATFORM", "UNSUPPORTED_PLATFORM_CURRENCY", "AMOUNT_BELOW_MINIMUM", "INVALID_INTENT_AMOUNT_RANGE", "INVALID_PAYOUT_CURRENCIES", "INVALID_PAYOUT_PLATFORMS", "INVALID_REFERRAL_CODE", "ACTIVE_INTENT_BLOCKS_WITHDRAWAL", "NOTHING_TO_WITHDRAW", "INSUFFICIENT_AVAILABLE_FUNDS", "INSUFFICIENT_TOKEN_BALANCE", "ORDER_NOT_ACTIVE", "INVALID_DEPOSIT_ID", "ESCROW_PAUSED", "INDEXER_LAG", "INDEXER_UNAVAILABLE", "ORDER_NOT_FOUND", "PAYEE_REGISTRATION_FAILED", "PAYEE_VERIFICATION_REQUIRED", "ATOMIC_ACCESS_POLICY_REQUIRED", "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE", "SOURCE_RECIPIENT_MISMATCH", "SOURCE_CAPABILITIES_FAILED", "SOURCE_QUOTE_FAILED", "SOURCE_NONCE_MANAGER_REQUIRED", "SOURCE_EXECUTION_FAILED", "SOURCE_STATUS_FAILED", "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED", "SOURCE_CASHOUT_SUBMISSION_UNKNOWN", "SOURCE_CASHOUT_STATUS_UNKNOWN", "DEPOSIT_RESOLUTION_FAILED", "ACCESS_POLICY_CONFIGURATION_FAILED", "ALLOWANCE_NOT_VISIBLE", "SIGNER_REQUIRED", "SIGNER_CHAIN_MISMATCH", "SIGNER_CHAIN_UNAVAILABLE", "WATCH_TIMEOUT", "TRANSACTION_REJECTED", "TRANSACTION_FAILED", "TRANSACTION_SUBMISSION_UNKNOWN", "TRANSACTION_STATUS_UNKNOWN"]>;
|
|
3217
3223
|
message: z.ZodString;
|
|
3218
3224
|
retryable: z.ZodBoolean;
|
|
3219
3225
|
remediation: z.ZodString;
|
|
@@ -3615,7 +3621,7 @@ declare const cashErrorJsonSchema: z.ZodObject<{
|
|
|
3615
3621
|
}>]>>;
|
|
3616
3622
|
}, "strict", z.ZodTypeAny, {
|
|
3617
3623
|
message: string;
|
|
3618
|
-
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3624
|
+
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "ATOMIC_ACCESS_POLICY_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3619
3625
|
retryable: boolean;
|
|
3620
3626
|
remediation: string;
|
|
3621
3627
|
recovery?: {
|
|
@@ -3702,7 +3708,7 @@ declare const cashErrorJsonSchema: z.ZodObject<{
|
|
|
3702
3708
|
} | undefined;
|
|
3703
3709
|
}, {
|
|
3704
3710
|
message: string;
|
|
3705
|
-
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3711
|
+
code: "ORACLE_UNSUPPORTED_CURRENCY" | "ORACLE_READ_FAILED" | "UNSUPPORTED_PLATFORM" | "UNSUPPORTED_PLATFORM_CURRENCY" | "AMOUNT_BELOW_MINIMUM" | "INVALID_INTENT_AMOUNT_RANGE" | "INVALID_PAYOUT_CURRENCIES" | "INVALID_PAYOUT_PLATFORMS" | "INVALID_REFERRAL_CODE" | "ACTIVE_INTENT_BLOCKS_WITHDRAWAL" | "NOTHING_TO_WITHDRAW" | "INSUFFICIENT_AVAILABLE_FUNDS" | "INSUFFICIENT_TOKEN_BALANCE" | "ORDER_NOT_ACTIVE" | "INVALID_DEPOSIT_ID" | "ESCROW_PAUSED" | "INDEXER_LAG" | "INDEXER_UNAVAILABLE" | "ORDER_NOT_FOUND" | "PAYEE_REGISTRATION_FAILED" | "PAYEE_VERIFICATION_REQUIRED" | "ATOMIC_ACCESS_POLICY_REQUIRED" | "SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE" | "SOURCE_RECIPIENT_MISMATCH" | "SOURCE_CAPABILITIES_FAILED" | "SOURCE_QUOTE_FAILED" | "SOURCE_NONCE_MANAGER_REQUIRED" | "SOURCE_EXECUTION_FAILED" | "SOURCE_STATUS_FAILED" | "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED" | "SOURCE_CASHOUT_SUBMISSION_UNKNOWN" | "SOURCE_CASHOUT_STATUS_UNKNOWN" | "DEPOSIT_RESOLUTION_FAILED" | "ACCESS_POLICY_CONFIGURATION_FAILED" | "ALLOWANCE_NOT_VISIBLE" | "SIGNER_REQUIRED" | "SIGNER_CHAIN_MISMATCH" | "SIGNER_CHAIN_UNAVAILABLE" | "WATCH_TIMEOUT" | "TRANSACTION_REJECTED" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMISSION_UNKNOWN" | "TRANSACTION_STATUS_UNKNOWN";
|
|
3706
3712
|
retryable: boolean;
|
|
3707
3713
|
remediation: string;
|
|
3708
3714
|
recovery?: {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MARKET_SPREAD_BPS, ORACLE_MIN_CONVERSION_RATE_SENTINEL, CASH_RETAIN_ON_EMPTY, CASH_INTENT_GUARDIAN_ADDRESS, BASE_USDC_ADDRESS, USDC_DECIMALS, BASE_CHAIN_ID, errors, isCashError, CASH_ORDER_STATUSES,
|
|
2
|
-
export { BASE_CHAIN_ID, BASE_USDC_ADDRESS, CASH_ORDER_POLL_INTERVAL_MS, CASH_ORDER_STATUSES, CASH_RETAIN_ON_EMPTY, CashError, MARKET_SPREAD_BPS, ORACLE_MIN_CONVERSION_RATE_SENTINEL, USDC_DECIMALS, errors, isCashError, isUserRejectedError } from './chunk-
|
|
1
|
+
import { MARKET_SPREAD_BPS, ORACLE_MIN_CONVERSION_RATE_SENTINEL, CASH_RETAIN_ON_EMPTY, CASH_INTENT_GUARDIAN_ADDRESS, BASE_USDC_ADDRESS, USDC_DECIMALS, BASE_CHAIN_ID, CASH_RESTRICTED_PLATFORMS, errors, isCashError, CASH_ORDER_STATUSES, mapChainError, CashError, CASH_ACCESS_GROUP_IDS } from './chunk-YD5VHZXR.js';
|
|
2
|
+
export { BASE_CHAIN_ID, BASE_USDC_ADDRESS, CASH_ORDER_POLL_INTERVAL_MS, CASH_ORDER_STATUSES, CASH_RETAIN_ON_EMPTY, CashError, MARKET_SPREAD_BPS, ORACLE_MIN_CONVERSION_RATE_SENTINEL, USDC_DECIMALS, errors, isCashError, isUserRejectedError } from './chunk-YD5VHZXR.js';
|
|
3
3
|
import { parseAbi, parseEventLogs, isAddress, http, createWalletClient, encodeFunctionData } from 'viem';
|
|
4
4
|
import { base } from 'viem/chains';
|
|
5
5
|
import { getSpreadOracleConfig, currencyInfo, getPaymentMethodsCatalog, getGatingServiceAddress, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash, getCurrencyCodeFromHash, createCompositeDepositId, appendAttributionToCalldata, Zkp2pClient, CHAINLINK_ORACLE_FEEDS } from '@zkp2p/sdk';
|
|
@@ -461,7 +461,8 @@ function buildCapabilities(environment) {
|
|
|
461
461
|
platform,
|
|
462
462
|
currencies: [...new Set(currencies2)].sort(),
|
|
463
463
|
payeeHint: PAYEE_HINTS[platform] ?? "Your payment handle for this platform",
|
|
464
|
-
requiresIdentityAttestation: IDENTITY_ATTESTATION_PLATFORMS.has(platform)
|
|
464
|
+
requiresIdentityAttestation: IDENTITY_ATTESTATION_PLATFORMS.has(platform),
|
|
465
|
+
requiresAtomicAccessPolicy: CASH_RESTRICTED_PLATFORMS.has(platform)
|
|
465
466
|
};
|
|
466
467
|
}).filter((p) => p.currencies.length > 0).sort((a, b) => a.platform.localeCompare(b.platform));
|
|
467
468
|
const currencies = [...new Set(platforms.flatMap((p) => p.currencies))].sort();
|
|
@@ -1427,6 +1428,12 @@ function createCashClient(options) {
|
|
|
1427
1428
|
...range ? { intentAmountRange: range } : {}
|
|
1428
1429
|
};
|
|
1429
1430
|
}
|
|
1431
|
+
function assertGenericCashoutSupported(payoutInput) {
|
|
1432
|
+
const restrictedPlatforms = payoutInput.payouts.map((payout) => payout.processorName.toLowerCase()).filter((platform) => CASH_RESTRICTED_PLATFORMS.has(platform));
|
|
1433
|
+
if (restrictedPlatforms.length > 0) {
|
|
1434
|
+
throw errors.atomicAccessPolicyRequired(restrictedPlatforms);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1430
1437
|
function isCashPayoutSet(payouts) {
|
|
1431
1438
|
return payouts.length > 0 && payouts.every((payout) => payout.pricing.marketRate && payout.pricing.spreadBps === 0);
|
|
1432
1439
|
}
|
|
@@ -1666,42 +1673,6 @@ function createCashClient(options) {
|
|
|
1666
1673
|
if (lastNonceError) throw lastNonceError;
|
|
1667
1674
|
throw new Error(`Signer provider did not observe Relay nonce ${afterRelay - 1}`);
|
|
1668
1675
|
}
|
|
1669
|
-
async function configureCashoutAccess(client, signer, depositInput, depositId) {
|
|
1670
|
-
if (!depositInput.payouts.some(
|
|
1671
|
-
(payout) => CASH_RESTRICTED_PLATFORMS.has(payout.processorName.toLowerCase())
|
|
1672
|
-
)) {
|
|
1673
|
-
return void 0;
|
|
1674
|
-
}
|
|
1675
|
-
const groupIds = CASH_ACCESS_GROUP_IDS[environment];
|
|
1676
|
-
const prepared = prepareCashoutAccess(depositId, client);
|
|
1677
|
-
let hash;
|
|
1678
|
-
try {
|
|
1679
|
-
hash = await signer.sendTransaction({
|
|
1680
|
-
account: signer.account,
|
|
1681
|
-
chain: signer.chain,
|
|
1682
|
-
to: prepared.to,
|
|
1683
|
-
data: prepared.data,
|
|
1684
|
-
value: prepared.value
|
|
1685
|
-
});
|
|
1686
|
-
} catch (err) {
|
|
1687
|
-
throw errors.accessPolicyConfigurationFailed(depositId, groupIds, err);
|
|
1688
|
-
}
|
|
1689
|
-
let receipt;
|
|
1690
|
-
try {
|
|
1691
|
-
receipt = await client.publicClient.waitForTransactionReceipt({ hash });
|
|
1692
|
-
} catch (err) {
|
|
1693
|
-
throw errors.accessPolicyConfigurationFailed(depositId, groupIds, err, hash);
|
|
1694
|
-
}
|
|
1695
|
-
if (receipt.status === "reverted") {
|
|
1696
|
-
throw errors.accessPolicyConfigurationFailed(
|
|
1697
|
-
depositId,
|
|
1698
|
-
groupIds,
|
|
1699
|
-
errors.transactionFailed(hash),
|
|
1700
|
-
hash
|
|
1701
|
-
);
|
|
1702
|
-
}
|
|
1703
|
-
return hash;
|
|
1704
|
-
}
|
|
1705
1676
|
function prepareCashoutAccess(depositId, client = readClient) {
|
|
1706
1677
|
const { compositeId, escrowAddress, onchainDepositId } = parseDepositId(depositId);
|
|
1707
1678
|
const groupIds = CASH_ACCESS_GROUP_IDS[environment];
|
|
@@ -1761,6 +1732,7 @@ function createCashClient(options) {
|
|
|
1761
1732
|
},
|
|
1762
1733
|
async cashout(input, opts) {
|
|
1763
1734
|
const payoutInput = validatePayout(input);
|
|
1735
|
+
assertGenericCashoutSupported(payoutInput);
|
|
1764
1736
|
const client = await signingClient("cashout", opts);
|
|
1765
1737
|
const owner = opts.signer.account.address;
|
|
1766
1738
|
let sourceResult;
|
|
@@ -1858,12 +1830,6 @@ function createCashClient(options) {
|
|
|
1858
1830
|
const abi2 = client.escrowV2Abi ?? client.escrowAbi;
|
|
1859
1831
|
const resolved2 = resolveCashDepositId({ logs: receipt2.logs, abi: abi2 });
|
|
1860
1832
|
if (!resolved2) throw errors.depositResolutionFailed(hash2);
|
|
1861
|
-
const accessPolicyTxHash2 = await configureCashoutAccess(
|
|
1862
|
-
client,
|
|
1863
|
-
opts.signer,
|
|
1864
|
-
depositInput2,
|
|
1865
|
-
resolved2.compositeId
|
|
1866
|
-
);
|
|
1867
1833
|
const order2 = deriveCashOrder(resolved2.compositeId, [], {
|
|
1868
1834
|
remainingAmount: depositInput2.amount,
|
|
1869
1835
|
status: "ACTIVE"
|
|
@@ -1874,7 +1840,6 @@ function createCashClient(options) {
|
|
|
1874
1840
|
escrowAddress: resolved2.escrowAddress,
|
|
1875
1841
|
onchainDepositId: resolved2.onchainDepositId,
|
|
1876
1842
|
order: order2,
|
|
1877
|
-
...accessPolicyTxHash2 ? { accessPolicyTxHash: accessPolicyTxHash2 } : {},
|
|
1878
1843
|
source: routedSource
|
|
1879
1844
|
};
|
|
1880
1845
|
}
|
|
@@ -1919,12 +1884,6 @@ function createCashClient(options) {
|
|
|
1919
1884
|
const abi = client.escrowV2Abi ?? client.escrowAbi;
|
|
1920
1885
|
const resolved = resolveCashDepositId({ logs: receipt.logs, abi });
|
|
1921
1886
|
if (!resolved) throw errors.depositResolutionFailed(hash);
|
|
1922
|
-
const accessPolicyTxHash = await configureCashoutAccess(
|
|
1923
|
-
client,
|
|
1924
|
-
opts.signer,
|
|
1925
|
-
depositInput,
|
|
1926
|
-
resolved.compositeId
|
|
1927
|
-
);
|
|
1928
1887
|
const order = deriveCashOrder(resolved.compositeId, [], {
|
|
1929
1888
|
remainingAmount: depositInput.amount,
|
|
1930
1889
|
status: "ACTIVE"
|
|
@@ -1935,13 +1894,13 @@ function createCashClient(options) {
|
|
|
1935
1894
|
escrowAddress: resolved.escrowAddress,
|
|
1936
1895
|
onchainDepositId: resolved.onchainDepositId,
|
|
1937
1896
|
order,
|
|
1938
|
-
...accessPolicyTxHash ? { accessPolicyTxHash } : {},
|
|
1939
1897
|
...sourceResult ? { source: sourceResult } : {}
|
|
1940
1898
|
};
|
|
1941
1899
|
},
|
|
1942
1900
|
async prepare(input) {
|
|
1943
1901
|
if (input.source) throw errors.sourceRouteUnsupportedInPrepare();
|
|
1944
1902
|
const depositInput = validateDepositInput(input.amount, input);
|
|
1903
|
+
assertGenericCashoutSupported(depositInput);
|
|
1945
1904
|
const params = await buildDepositParams(readClient, depositInput);
|
|
1946
1905
|
const { prepared } = await readClient.prepareCreateDeposit({
|
|
1947
1906
|
...params,
|
|
@@ -1974,9 +1933,7 @@ function createCashClient(options) {
|
|
|
1974
1933
|
}
|
|
1975
1934
|
],
|
|
1976
1935
|
register: { hashedOnchainIds },
|
|
1977
|
-
accessPolicyRequired:
|
|
1978
|
-
(payout) => CASH_RESTRICTED_PLATFORMS.has(payout.processorName.toLowerCase())
|
|
1979
|
-
)
|
|
1936
|
+
accessPolicyRequired: false
|
|
1980
1937
|
};
|
|
1981
1938
|
},
|
|
1982
1939
|
finalizePreparedCashout(receipt) {
|
|
@@ -2503,7 +2460,8 @@ var cashCapabilitiesJsonSchema = z.object({
|
|
|
2503
2460
|
platform: z.string(),
|
|
2504
2461
|
currencies: z.array(z.string()),
|
|
2505
2462
|
payeeHint: z.string(),
|
|
2506
|
-
requiresIdentityAttestation: z.boolean()
|
|
2463
|
+
requiresIdentityAttestation: z.boolean(),
|
|
2464
|
+
requiresAtomicAccessPolicy: z.boolean().optional()
|
|
2507
2465
|
})
|
|
2508
2466
|
),
|
|
2509
2467
|
currencies: z.array(z.string()),
|
|
@@ -2539,6 +2497,7 @@ var CASH_ERROR_CODES = defineCashErrorCodes([
|
|
|
2539
2497
|
"ORDER_NOT_FOUND",
|
|
2540
2498
|
"PAYEE_REGISTRATION_FAILED",
|
|
2541
2499
|
"PAYEE_VERIFICATION_REQUIRED",
|
|
2500
|
+
"ATOMIC_ACCESS_POLICY_REQUIRED",
|
|
2542
2501
|
"SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE",
|
|
2543
2502
|
"SOURCE_RECIPIENT_MISMATCH",
|
|
2544
2503
|
"SOURCE_CAPABILITIES_FAILED",
|
|
@@ -2946,7 +2905,8 @@ function capabilitiesFromJson(json) {
|
|
|
2946
2905
|
},
|
|
2947
2906
|
platforms: parsed.platforms.map((p) => ({
|
|
2948
2907
|
...p,
|
|
2949
|
-
currencies: p.currencies
|
|
2908
|
+
currencies: p.currencies,
|
|
2909
|
+
requiresAtomicAccessPolicy: p.requiresAtomicAccessPolicy ?? CASH_RESTRICTED_PLATFORMS.has(p.platform)
|
|
2950
2910
|
})),
|
|
2951
2911
|
currencies: parsed.currencies,
|
|
2952
2912
|
amount: {
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurrencyType } from '@zkp2p/sdk';
|
|
2
|
-
import { s as CashClient, L as EstimateInput, i as CashEstimate, J as CashoutOptions, h as CashoutResult, H as CashoutInput, T as TopUpResult, W as WithdrawResult, e as CashOrder } from './createCashClient-
|
|
2
|
+
import { s as CashClient, L as EstimateInput, i as CashEstimate, J as CashoutOptions, h as CashoutResult, H as CashoutInput, T as TopUpResult, W as WithdrawResult, e as CashOrder } from './createCashClient-CL1SCbqF.cjs';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
import '@relayprotocol/relay-sdk';
|
|
5
5
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurrencyType } from '@zkp2p/sdk';
|
|
2
|
-
import { s as CashClient, L as EstimateInput, i as CashEstimate, J as CashoutOptions, h as CashoutResult, H as CashoutInput, T as TopUpResult, W as WithdrawResult, e as CashOrder } from './createCashClient-
|
|
2
|
+
import { s as CashClient, L as EstimateInput, i as CashEstimate, J as CashoutOptions, h as CashoutResult, H as CashoutInput, T as TopUpResult, W as WithdrawResult, e as CashOrder } from './createCashClient-CL1SCbqF.js';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
import '@relayprotocol/relay-sdk';
|
|
5
5
|
|
package/dist/react.js
CHANGED
package/dist/tools.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// package.json
|
|
4
4
|
var package_default = {
|
|
5
|
-
version: "0.4.
|
|
5
|
+
version: "0.4.5"};
|
|
6
6
|
|
|
7
7
|
// src/tools/index.ts
|
|
8
8
|
var bigintString = {
|
|
@@ -164,7 +164,7 @@ var builtInCashTools = [
|
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
166
|
name: "cash_cashout",
|
|
167
|
-
description: "Start
|
|
167
|
+
description: "Start an unrestricted-rail Base-USDC cash-out using the custody-separated prepare path. Returns UNSIGNED transactions plus same-index steps [approve, createDeposit]; signing and ordered submission stay host-side. Platforms marked requiresAtomicAccessPolicy fail closed because this tool cannot safely prepare them. For another source asset, complete cash_source_quote and cash_source_status first, then pass the guaranteed Base USDC output amount here.",
|
|
168
168
|
inputSchema: {
|
|
169
169
|
type: "object",
|
|
170
170
|
properties: {
|
package/dist/tools.d.cts
CHANGED
|
@@ -145,7 +145,7 @@ declare const builtInCashTools: readonly [{
|
|
|
145
145
|
};
|
|
146
146
|
}, {
|
|
147
147
|
readonly name: "cash_cashout";
|
|
148
|
-
readonly description: "Start
|
|
148
|
+
readonly description: "Start an unrestricted-rail Base-USDC cash-out using the custody-separated prepare path. Returns UNSIGNED transactions plus same-index steps [approve, createDeposit]; signing and ordered submission stay host-side. Platforms marked requiresAtomicAccessPolicy fail closed because this tool cannot safely prepare them. For another source asset, complete cash_source_quote and cash_source_status first, then pass the guaranteed Base USDC output amount here.";
|
|
149
149
|
readonly inputSchema: {
|
|
150
150
|
readonly type: "object";
|
|
151
151
|
readonly properties: {
|
package/dist/tools.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ declare const builtInCashTools: readonly [{
|
|
|
145
145
|
};
|
|
146
146
|
}, {
|
|
147
147
|
readonly name: "cash_cashout";
|
|
148
|
-
readonly description: "Start
|
|
148
|
+
readonly description: "Start an unrestricted-rail Base-USDC cash-out using the custody-separated prepare path. Returns UNSIGNED transactions plus same-index steps [approve, createDeposit]; signing and ordered submission stay host-side. Platforms marked requiresAtomicAccessPolicy fail closed because this tool cannot safely prepare them. For another source asset, complete cash_source_quote and cash_source_status first, then pass the guaranteed Base USDC output amount here.";
|
|
149
149
|
readonly inputSchema: {
|
|
150
150
|
readonly type: "object";
|
|
151
151
|
readonly properties: {
|
package/dist/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
|
-
version: "0.4.
|
|
3
|
+
version: "0.4.5"};
|
|
4
4
|
|
|
5
5
|
// src/tools/index.ts
|
|
6
6
|
var bigintString = {
|
|
@@ -162,7 +162,7 @@ var builtInCashTools = [
|
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
name: "cash_cashout",
|
|
165
|
-
description: "Start
|
|
165
|
+
description: "Start an unrestricted-rail Base-USDC cash-out using the custody-separated prepare path. Returns UNSIGNED transactions plus same-index steps [approve, createDeposit]; signing and ordered submission stay host-side. Platforms marked requiresAtomicAccessPolicy fail closed because this tool cannot safely prepare them. For another source asset, complete cash_source_quote and cash_source_status first, then pass the guaranteed Base USDC output amount here.",
|
|
166
166
|
inputSchema: {
|
|
167
167
|
type: "object",
|
|
168
168
|
properties: {
|
|
@@ -64,10 +64,16 @@ but the host or a signer-backed client must execute the route before
|
|
|
64
64
|
`cash_cashout` prepares the Base-USDC order. Once the prepared `createDeposit`
|
|
65
65
|
transaction confirms, call `finalizePreparedCashout(receipt)` to decode it with
|
|
66
66
|
the environment-correct escrow ABI and obtain the resumable `CashoutResult`.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
|
|
68
|
+
Venmo, Cash App, and PayPal require atomic deposit creation and access-policy
|
|
69
|
+
configuration. The generic `cashout()` and `prepare()` paths reject these rails
|
|
70
|
+
with `ATOMIC_ACCESS_POLICY_REQUIRED` before wallet access, Relay work, payee
|
|
71
|
+
registration, allowance, or deposit submission. Peer web performs the required
|
|
72
|
+
guard-before, create, guard-after, and policy configuration in one Curator-backed
|
|
73
|
+
batch. A host must provide the same atomic guarantee to support these rails.
|
|
74
|
+
Discovery marks them with `requiresAtomicAccessPolicy: true`.
|
|
75
|
+
`prepareAccessPolicy(depositId)` is retained only to recover a restricted
|
|
76
|
+
deposit already created by `0.4.4`; it is not a safe new-order sequence.
|
|
71
77
|
|
|
72
78
|
There is no static chain/token allowlist in Peer Cash. Relay decides source
|
|
73
79
|
support through its metadata and quote execution, filtered to the viem/EVM
|
|
@@ -295,6 +301,7 @@ explicit override.
|
|
|
295
301
|
| `INVALID_PAYOUT_PLATFORMS` | no | The payout leg set is empty or repeats a platform. Pass one leg, or an array of legs using each platform at most once. |
|
|
296
302
|
| `PAYEE_VERIFICATION_REQUIRED` | no | A new Wise/PayPal payee needs an attestation. Register it through Peer first; an existing registration can be reused. |
|
|
297
303
|
| `PAYEE_REGISTRATION_FAILED` | yes | Curator rejected the handle or was unavailable. Check `payeeHint` and retry. |
|
|
304
|
+
| `ATOMIC_ACCESS_POLICY_REQUIRED` | no | Venmo, Cash App, or PayPal needs atomic creation and group policy setup. Use Peer web or an equivalent atomic host; nothing was submitted. |
|
|
298
305
|
| `SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE` | no | `prepare()` accepts Base USDC only. Use signed source execution, or complete Relay first and then prepare the Base cashout. |
|
|
299
306
|
| `SOURCE_RECIPIENT_MISMATCH` | no | Relay output recipient differs from the cashout depositor. Use the depositor address. |
|
|
300
307
|
| `SOURCE_CAPABILITIES_FAILED` | yes | Relay source discovery failed. Retry or use Base USDC. |
|
|
@@ -312,7 +319,7 @@ explicit override.
|
|
|
312
319
|
| `TRANSACTION_SUBMISSION_UNKNOWN` | no | A Base mutation returned no hash but may have broadcast. Inspect wallet/protocol state and its recovery action before any retry. |
|
|
313
320
|
| `TRANSACTION_STATUS_UNKNOWN` | no | A transaction was submitted but its receipt is unknown. Inspect `recovery.transactionHash` before resubmitting. |
|
|
314
321
|
| `DEPOSIT_RESOLUTION_FAILED` | no | Base tx succeeded but no `DepositReceived` was decoded. Inspect its logs and recover the composite id. |
|
|
315
|
-
| `ACCESS_POLICY_CONFIGURATION_FAILED` | no |
|
|
322
|
+
| `ACCESS_POLICY_CONFIGURATION_FAILED` | no | A `0.4.4` cash-out exists without confirmed group policy. Configure that existing deposit from recovery data; never create it again. |
|
|
316
323
|
| `INVALID_DEPOSIT_ID` | no | The id is not `escrowAddress_onchainId`. A bare number cannot cold-hydrate; use the value returned by `cashout()`. |
|
|
317
324
|
| `ORDER_NOT_FOUND` | yes | Unknown id or immediate indexer lag. Verify the id and retry shortly after creation. |
|
|
318
325
|
| `INDEXER_LAG` | yes | Indexer trails the chain. Retry the read shortly. |
|
|
@@ -104,10 +104,16 @@ console.log(`manifest: ${cashToolManifest.name}@${cashToolManifest.version}`);
|
|
|
104
104
|
console.log(`tools: ${cashToolManifest.tools.map((t) => t.name).join(', ')}\n`);
|
|
105
105
|
|
|
106
106
|
const caps = (await executeTool('cash_capabilities', {})) as {
|
|
107
|
-
platforms: {
|
|
107
|
+
platforms: {
|
|
108
|
+
platform: string;
|
|
109
|
+
currencies: string[];
|
|
110
|
+
payeeHint: string;
|
|
111
|
+
requiresAtomicAccessPolicy: boolean;
|
|
112
|
+
}[];
|
|
108
113
|
};
|
|
109
|
-
|
|
110
|
-
console.log(`
|
|
114
|
+
const venmo = caps.platforms.find((p) => p.platform === 'venmo');
|
|
115
|
+
console.log(`agent sees ${caps.platforms.length} platforms; venmo capability:`);
|
|
116
|
+
console.log(` hint="${venmo?.payeeHint}" atomic=${venmo?.requiresAtomicAccessPolicy}\n`);
|
|
111
117
|
|
|
112
118
|
const est = await executeTool('cash_estimate', {
|
|
113
119
|
amount: usdc(250).toString(),
|
package/examples/node-cashout.ts
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
* The curator validates supported handles against the live platform, so the
|
|
12
12
|
* payee must be a real account. A new Wise/PayPal registration also needs the
|
|
13
13
|
* identity attestation created by Peer; an existing registered handle can be
|
|
14
|
-
* reused.
|
|
15
|
-
*
|
|
14
|
+
* reused. Venmo, Cash App, and PayPal require Peer web or another host that
|
|
15
|
+
* creates the deposit and access policy atomically, so this generic demo uses
|
|
16
|
+
* Chime by default. Override the demo corridor with:
|
|
17
|
+
* CASH_PLATFORM=revolut CASH_CURRENCY=EUR CASH_PAYEE=your-revtag
|
|
16
18
|
*/
|
|
17
19
|
import { createWalletClient, http } from 'viem';
|
|
18
20
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
@@ -26,9 +28,9 @@ const signer = createWalletClient({ account, chain: base, transport: http() });
|
|
|
26
28
|
// One leg here; `receive` also accepts an array of legs to offer several
|
|
27
29
|
// platforms on one order (each platform at most once, all at the oracle rate).
|
|
28
30
|
const receive = {
|
|
29
|
-
platform: process.env.CASH_PLATFORM ?? '
|
|
31
|
+
platform: process.env.CASH_PLATFORM ?? 'chime',
|
|
30
32
|
currency: (process.env.CASH_CURRENCY ?? 'USD') as CurrencyType,
|
|
31
|
-
payee: { offchainId: process.env.CASH_PAYEE ?? '
|
|
33
|
+
payee: { offchainId: process.env.CASH_PAYEE ?? '$your-chime-sign' },
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
const cash = createCashClient({ environment: 'staging' });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkp2p/cash",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Peer Cash - offramp-only SDK for routing crypto to Base USDC, then cashing out to fiat at the live oracle market rate.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Peer (https://peer.xyz)",
|