@zkp2p/sdk 0.11.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -7
- package/dist/{chunk-LPKFXAKY.mjs → chunk-RYBXFY6X.mjs} +44235 -478
- package/dist/chunk-RYBXFY6X.mjs.map +1 -0
- package/dist/index.cjs +44752 -451
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +33 -5
- package/dist/index.d.ts +33 -5
- package/dist/index.mjs +536 -12
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-LCSRVC7F.mjs +5 -0
- package/dist/{protocolViewerParsers-M7C2ICV3.mjs.map → protocolViewerParsers-LCSRVC7F.mjs.map} +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{vaultUtils-CbfjrxgD.d.mts → vaultUtils-xNLHO5lY.d.mts} +330 -4
- package/dist/{vaultUtils-CbfjrxgD.d.ts → vaultUtils-xNLHO5lY.d.ts} +330 -4
- package/package.json +1 -1
- package/dist/chunk-LPKFXAKY.mjs.map +0 -1
- package/dist/protocolViewerParsers-M7C2ICV3.mjs +0 -5
package/README.md
CHANGED
|
@@ -107,6 +107,8 @@ Indexer defaults by environment:
|
|
|
107
107
|
| Indexer | `client.indexer.getDeposits`, `getDepositsWithRelations`, `getDepositById`, `getDepositsByIds`, `getDepositsByIdsWithRelations`, `getDepositsByPayeeHash`, `getIntentsForDeposits`, `getOwnerIntents`, `getIntentsByRateManager`, `getIntentByHash`, `getExpiredIntents`, `getFulfilledIntentEvents`, `getIntentFulfillmentAmounts`, `getFulfillmentAndPayment`, `getDepositFundActivities`, `getMakerFundActivities`, `getDepositDailySnapshots`, `getProfitSnapshotsByDeposits`, `getRateManagers`, `getRateManagerDetail`, `getRateManagerDelegations`, `getDelegationForDeposit`, `getManagerDailySnapshots`, `getManualRateUpdates`, `getOracleConfigUpdates`, `query` |
|
|
108
108
|
| React hooks | `@zkp2p/sdk/react` exports hooks for deposits, intents, delegation, vaults, and payment methods |
|
|
109
109
|
| Attribution | ERC-8021 helpers like `sendTransactionWithAttribution`, `encodeWithAttribution`, and `txOverrides.referrer` support |
|
|
110
|
+
| Taker staking | `ensureStakeAllowance`, `depositStake`, `withdrawStake`, `claim`, `setTakerAuthorization`, `selectStakeOwner`, `clearStakeOwner`, direct StakeVault reads, and `client.indexer.getStakingState()` |
|
|
111
|
+
| Chargeback keepers | `releaseMaturedChargebackIntent`, `releaseMaturedChargebackIntents`, with caller-pinned `chargebackPolicyAddress` support |
|
|
110
112
|
|
|
111
113
|
## Extension Metadata Bridge
|
|
112
114
|
|
|
@@ -144,10 +146,11 @@ peer.authenticate({
|
|
|
144
146
|
});
|
|
145
147
|
```
|
|
146
148
|
|
|
147
|
-
`requestConnection()`
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
`requestConnection()` opens an extension-owned approval window for third-party
|
|
150
|
+
origins. Trusted Peer hosts and `localhost` are already connected.
|
|
151
|
+
`authenticate()` identifies the provider with `platform` and
|
|
152
|
+
`actionType`; the extension fetches the matching extension-managed template
|
|
153
|
+
from `https://api.zkp2p.xyz/providers/`. Buyer TEE is API/template driven: pass `captureMode: "buyerTee"` plus
|
|
151
154
|
`attestationServiceUrl`, and the extension returns encrypted session material.
|
|
152
155
|
For SAR, pass `captureMode: "sellerCredential"` and optionally pass
|
|
153
156
|
`attestationServiceUrl` only when overriding the extension's production
|
|
@@ -187,7 +190,6 @@ environment. Production and preproduction use
|
|
|
187
190
|
`0x83671606454fA72ba1e2831E18C5090D25629414`, enabling prepaid intent-lifetime
|
|
188
191
|
extensions. Pass `intentGuardian` explicitly only when integrating a custom
|
|
189
192
|
guardian.
|
|
190
|
-
|
|
191
193
|
## Payee Registration and Quotes
|
|
192
194
|
|
|
193
195
|
```ts
|
|
@@ -212,8 +214,8 @@ const { hashedOnchainIds } = await client.registerPayeeDetails({
|
|
|
212
214
|
const quote = await client.getQuote({
|
|
213
215
|
paymentPlatforms: ['wise'],
|
|
214
216
|
fiatCurrency: 'USD',
|
|
215
|
-
user: '
|
|
216
|
-
recipient: '
|
|
217
|
+
user: '0xBuyer',
|
|
218
|
+
recipient: '0xBuyer',
|
|
217
219
|
destinationChainId: 8453,
|
|
218
220
|
destinationToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
219
221
|
amount: '250',
|
|
@@ -228,6 +230,79 @@ const payeeHash = await client.resolvePayeeHash(
|
|
|
228
230
|
|
|
229
231
|
`getQuote()` returns available liquidity plus payee details when authenticated. Use `getQuotesBestByPlatform()` to fetch the best quote per supported payment platform in a single call (handy for cross-platform comparison UIs).
|
|
230
232
|
|
|
233
|
+
## Taker Staking
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const amount = 250_000000n;
|
|
237
|
+
const approval = await client.ensureStakeAllowance({ amount });
|
|
238
|
+
// Wait for approval.hash to confirm when hadAllowance is false.
|
|
239
|
+
|
|
240
|
+
await client.depositStake({ amount }); // sender becomes the stake owner
|
|
241
|
+
await client.withdrawStake({ amount: 50_000000n }); // immediate, free stake only
|
|
242
|
+
await client.claim(); // withdraws the caller's full claimable balance
|
|
243
|
+
|
|
244
|
+
// Safe sponsorship is a two-actor flow:
|
|
245
|
+
await client.setTakerAuthorization({ taker, authorized: true }); // signed by the Safe
|
|
246
|
+
await client.selectStakeOwner({ stakeOwner: safeAddress }); // signed by the taker
|
|
247
|
+
await client.clearStakeOwner(); // taker returns to self-stake
|
|
248
|
+
|
|
249
|
+
const onchain = await client.getStakeVaultState({
|
|
250
|
+
staker: takerAddress,
|
|
251
|
+
taker: takerAddress,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
const indexed = await client.indexer.getStakingState({
|
|
255
|
+
chainId: 8453,
|
|
256
|
+
environment: 'base',
|
|
257
|
+
vaultAddress: client.getStakeVaultContract().address,
|
|
258
|
+
chargebackPolicyAddress: client.getChargebackPolicyContract().address,
|
|
259
|
+
taker: takerAddress,
|
|
260
|
+
// Always supply the effective owner from the fresh on-chain read.
|
|
261
|
+
stakeOwner: onchain.stakeOwner,
|
|
262
|
+
});
|
|
263
|
+
// indexed: effective/raw ownership, total/locked/free stake, claimable,
|
|
264
|
+
// authorizations, admissions-pause state, Vault controller, and per-row
|
|
265
|
+
// freshness.
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Stake writes expose direct and `.prepare()` variants: `depositStake`,
|
|
269
|
+
`withdrawStake`, `claim`, `setTakerAuthorization`, `selectStakeOwner`, and
|
|
270
|
+
`clearStakeOwner`. There is no withdrawal request, cooldown, or exit
|
|
271
|
+
lifecycle — `withdrawStake` is immediate up to `freeStake`, and `claim`
|
|
272
|
+
withdraws the complete claimable balance. Chargebackable capacity is exactly
|
|
273
|
+
the effective owner's free stake (1:1); never sum a taker's self-stake with a
|
|
274
|
+
sponsor's stake.
|
|
275
|
+
|
|
276
|
+
The vault's controller is the `ChargebackPolicy` contract. It owns
|
|
277
|
+
per-payment-method risk windows (`getRiskWindow(paymentMethodHash)`),
|
|
278
|
+
per-deposit chargeback enablement (`isChargebackEnabled(escrow, depositId)`),
|
|
279
|
+
and the global `admissionsPaused()` switch. `@zkp2p/contracts-v2@0.4.0`
|
|
280
|
+
resolves the deployed StakeVault, ChargebackPolicy, and OrchestratorV3 for
|
|
281
|
+
both the production and staging bundles; a bundle without them fails closed
|
|
282
|
+
(`VITE_BASE_STAGING_STAKE_VAULT_ADDRESS` /
|
|
283
|
+
`VITE_BASE_STAGING_CHARGEBACK_POLICY_ADDRESS` overrides support local
|
|
284
|
+
deployments).
|
|
285
|
+
|
|
286
|
+
Keeper writes are direct and prepareable:
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
const release = await client.releaseMaturedChargebackIntents.prepare({
|
|
290
|
+
intentHashes: [intentHash],
|
|
291
|
+
chargebackPolicyAddress: snapshottedPolicyAddress,
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
An explicit `chargebackPolicyAddress` is caller-pinned and may be outside the
|
|
296
|
+
client's configured deployment context, allowing sweepers to group intents by
|
|
297
|
+
their snapshotted policy deployment without a later SDK configuration change
|
|
298
|
+
rerouting them.
|
|
299
|
+
|
|
300
|
+
`client.indexer.getStakingState()` composes the `@zkp2p/indexer-schema@0.20.0`
|
|
301
|
+
account rows and preserves their individual freshness. Its caller-supplied
|
|
302
|
+
`stakeOwner` must come from a fresh on-chain `stakeOwnerOf(taker)` read; stale
|
|
303
|
+
indexed ownership is reported without attributing another owner's balance.
|
|
304
|
+
Refetch immediately before signaling; the contract stays authoritative.
|
|
305
|
+
|
|
231
306
|
For table-style liquidity UIs, the low-level `apiGetOrderbookTable()` adapter exposes curator's paginated public/private orderbook rows and row-level privacy metadata.
|
|
232
307
|
|
|
233
308
|
## Seller Credential Status
|
|
@@ -644,6 +719,17 @@ const fulfilledEvents = await client.indexer.getFulfilledIntentEvents(['0xIntent
|
|
|
644
719
|
const fulfillment = await client.indexer.getIntentFulfillmentAmounts('0xIntentHash');
|
|
645
720
|
const fulfillmentAndPayment = await client.indexer.getFulfillmentAndPayment('0xIntentHash');
|
|
646
721
|
|
|
722
|
+
// Indexed staking state. stakeOwner must come from a fresh
|
|
723
|
+
// stakeOwnerOf(taker) read; the adapter checks it against indexed ownership.
|
|
724
|
+
const stakingState = await client.indexer.getStakingState({
|
|
725
|
+
chainId: 8453,
|
|
726
|
+
environment: 'base',
|
|
727
|
+
vaultAddress: '0xStakeVault',
|
|
728
|
+
chargebackPolicyAddress: '0xChargebackPolicy',
|
|
729
|
+
taker: '0xTaker',
|
|
730
|
+
stakeOwner: '0xEffectiveStakeOwner',
|
|
731
|
+
});
|
|
732
|
+
|
|
647
733
|
// Received USDC:
|
|
648
734
|
// - fulfilledEvents[0].amount is the net USDC transferred to the taker.
|
|
649
735
|
// - fulfillment.takerAmountNetFees is the same net taker amount from the Intent row.
|
|
@@ -713,15 +799,23 @@ Hook groups:
|
|
|
713
799
|
|
|
714
800
|
```ts
|
|
715
801
|
import {
|
|
802
|
+
DEFERRED_SETTLEMENT_FUNDED_EVENT_ABI,
|
|
716
803
|
getContracts,
|
|
804
|
+
getOrchestratorV3Contract,
|
|
717
805
|
getPaymentMethodsCatalog,
|
|
718
806
|
getRateManagerContracts,
|
|
807
|
+
getChargebackPolicyContract,
|
|
808
|
+
getStakeVaultContract,
|
|
809
|
+
RISK_POSITION_SETTLED_EVENT_ABI,
|
|
719
810
|
resolveFiatCurrencyBytes32,
|
|
720
811
|
resolvePaymentMethodHash,
|
|
721
812
|
} from '@zkp2p/sdk';
|
|
722
813
|
|
|
723
814
|
const contracts = getContracts(8453, 'production');
|
|
724
815
|
const rateManagerContracts = getRateManagerContracts(8453, 'production');
|
|
816
|
+
const stakeVault = getStakeVaultContract(8453, 'staging');
|
|
817
|
+
const orchestratorV3 = getOrchestratorV3Contract(8453, 'staging');
|
|
818
|
+
const chargebackPolicy = getChargebackPolicyContract(8453, 'staging');
|
|
725
819
|
const paymentMethods = getPaymentMethodsCatalog(8453, 'production');
|
|
726
820
|
const usdHash = resolveFiatCurrencyBytes32('USD');
|
|
727
821
|
const wiseHash = resolvePaymentMethodHash('wise', { env: 'production' });
|