@zkp2p/sdk 0.16.0-rc.1 → 0.16.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 +25 -4
- package/dist/build-metadata.json +2 -2
- package/dist/{chunk-MQPNWX5B.mjs → chunk-4UV5XMBU.mjs} +3 -3
- package/dist/{chunk-MQPNWX5B.mjs.map → chunk-4UV5XMBU.mjs.map} +1 -1
- package/dist/chunk-LBUSUTNI.mjs +12 -0
- package/dist/chunk-LBUSUTNI.mjs.map +1 -0
- package/dist/{currency-6XW25YEF.mjs → currency-6EFHONXS.mjs} +3 -3
- package/dist/{currency-6XW25YEF.mjs.map → currency-6EFHONXS.mjs.map} +1 -1
- package/dist/index.cjs +339 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +127 -4
- package/dist/index.d.ts +127 -4
- package/dist/index.mjs +347 -10
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-LD72M77T.mjs +5 -0
- package/dist/{protocolViewerParsers-UMFCZESM.mjs.map → protocolViewerParsers-LD72M77T.mjs.map} +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.mjs +1 -1
- package/dist/{vaultUtils-DZMTnUHJ.d.mts → vaultUtils-Dc5ez76H.d.mts} +1 -1
- package/dist/{vaultUtils-DZMTnUHJ.d.ts → vaultUtils-Dc5ez76H.d.ts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-6ZIKILBZ.mjs +0 -12
- package/dist/chunk-6ZIKILBZ.mjs.map +0 -1
- package/dist/protocolViewerParsers-UMFCZESM.mjs +0 -5
package/README.md
CHANGED
|
@@ -14,12 +14,10 @@ New intents use EscrowV2 and OrchestratorV4. The SDK retains reads for historica
|
|
|
14
14
|
npm install @zkp2p/sdk viem
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
`viem` `^2.37.3` is a peer dependency. React (`>=16.8.0`) is optional and only needed for `@zkp2p/sdk/react`. Node.js runtimes need version 22 or later.
|
|
17
|
+
Version `0.16.0` on npm’s `latest` tag includes `createPeer()`. `viem` `^2.37.3` is a peer dependency. React (`>=16.8.0`) is optional and only needed for `@zkp2p/sdk/react`. Node.js runtimes need version 22 or later.
|
|
18
18
|
|
|
19
19
|
## Peer quickstart
|
|
20
20
|
|
|
21
|
-
Install the release candidate with `npm install @zkp2p/sdk@rc viem`.
|
|
22
|
-
|
|
23
21
|
### Sell Base USDC
|
|
24
22
|
|
|
25
23
|
```ts
|
|
@@ -52,6 +50,27 @@ try {
|
|
|
52
50
|
|
|
53
51
|
`peer.sell()` registers the payee, approves and deposits the USDC at the zero-spread oracle market rate, and returns once the deposit confirms. `watch()` yields `awaiting-buyer`, `matched` and `delivering` until the sale ends `delivered` or `returned`. `peer.sell.capabilities()` lists each platform's currencies and payee format. Curator checks that the handle exists on its platform, PayPal.Me usernames and Wisetags included (`PAYEE_NOT_FOUND` otherwise); a new Alipay payee needs a signed identity attestation (`PAYEE_VERIFICATION_REQUIRED`). Use `peer.sell.prepare()` for unsigned transactions, and `peer.sell.withdraw(depositId, { signer })` to take back unsold USDC.
|
|
54
52
|
|
|
53
|
+
### Sell another asset (Relay)
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const peer = createPeer({
|
|
57
|
+
environment: 'production',
|
|
58
|
+
relay: { apiKey: process.env.RELAY_API_KEY },
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const { chains } = await peer.sell.sourceCapabilities(); // source chains and tokens Relay can route
|
|
62
|
+
const quote = await peer.sell.quoteSource({
|
|
63
|
+
user: signer.account.address,
|
|
64
|
+
amount: 5_000_000n, // source-token base units
|
|
65
|
+
source: { chainId: 10, currency: '0x0b2c639c533813f4aa9d7837caf62653d097ff85' }, // USDC on Optimism
|
|
66
|
+
});
|
|
67
|
+
// Send quote.txs from the source-chain wallet, then follow the route:
|
|
68
|
+
const status = await peer.sell.relayStatus(quote.requestId!);
|
|
69
|
+
// Once it succeeds, sell the Base USDC: peer.sell({ amount: quote.outputAmount, receive }, { signer })
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`quoteSource()` only returns routes that deliver canonical Base USDC to the requested recipient from the requested wallet and asset; `outputAmount` is Relay's guaranteed minimum. Relay's quote endpoint requires an API key.
|
|
73
|
+
|
|
55
74
|
### Buy Base USDC
|
|
56
75
|
|
|
57
76
|
```ts
|
|
@@ -166,7 +185,7 @@ try {
|
|
|
166
185
|
|
|
167
186
|
A closed or timed-out window doesn't mean linking failed, and a return doesn't prove it worked. Read `client.getSellerCredentialStatus({ processorName: 'venmo', payeeDetails })`: the inbox is linked only when `status` is `active` and `isMailboxSellerCredentialType(credentialType)` is `true`.
|
|
168
187
|
|
|
169
|
-
`openXMoneyConnect({ payeeDetails, payeeUsername })` and `getXMoneyConnectUrl()` do the same for X Money.
|
|
188
|
+
`openXMoneyConnect({ payeeDetails, payeeUsername })` and `getXMoneyConnectUrl()` do the same for X Money. For a `peer.sell()` app, see [optional receipt linking](https://docs.peer.xyz/developer/sell/guide#optional-receipt-linking). See the [client reference](https://docs.peer.xyz/developer/sdk/client-reference#hosted-venmo-receipt-linking) for error codes and options.
|
|
170
189
|
|
|
171
190
|
### Native app return
|
|
172
191
|
|
|
@@ -244,6 +263,8 @@ SDK errors extend `ZKP2PError` (`ValidationError`, `NetworkError`, `APIError`, a
|
|
|
244
263
|
|
|
245
264
|
## Documentation
|
|
246
265
|
|
|
266
|
+
- [Sell USDC with the Peer SDK](https://docs.peer.xyz/developer/sell)
|
|
267
|
+
- [Migrate from @zkp2p/cash](https://docs.peer.xyz/developer/sell/migrate-from-cash)
|
|
247
268
|
- [SDK overview](https://docs.peer.xyz/developer/sdk)
|
|
248
269
|
- [Client reference](https://docs.peer.xyz/developer/sdk/client-reference)
|
|
249
270
|
- [React hooks](https://docs.peer.xyz/developer/sdk/react-hooks)
|
package/dist/build-metadata.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"source": {
|
|
4
4
|
"repository": "zkp2p/zkp2p-clients",
|
|
5
|
-
"commitSha": "
|
|
5
|
+
"commitSha": "6318324893695eb4d5904438fb4c85cde4397a09",
|
|
6
6
|
"kind": "github",
|
|
7
7
|
"distributable": true
|
|
8
8
|
},
|
|
9
|
-
"sdkPackageVersion": "0.16.0
|
|
9
|
+
"sdkPackageVersion": "0.16.0",
|
|
10
10
|
"contractsPackageVersion": "0.4.4-rc.13",
|
|
11
11
|
"indexerSchemaPackageVersion": "0.23.0-rc.0",
|
|
12
12
|
"activeDisputeStack": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { currencyKeccak256, getCurrencyInfoFromHash } from './chunk-PMFXZGDQ.mjs';
|
|
2
|
-
import { __export } from './chunk-
|
|
2
|
+
import { __export } from './chunk-LBUSUTNI.mjs';
|
|
3
3
|
import { hexToBytes, keccak256, toBytes, bytesToHex } from 'viem';
|
|
4
4
|
|
|
5
5
|
// src/utils/bigint.ts
|
|
@@ -158562,5 +158562,5 @@ function enrichPvIntentView(view, chainId, env = "production") {
|
|
|
158562
158562
|
}
|
|
158563
158563
|
|
|
158564
158564
|
export { DISPUTE_PROTECTION_POLICY_ABI2 as DISPUTE_PROTECTION_POLICY_ABI, DISPUTE_PROTECTION_POLICY_V2_ABI2 as DISPUTE_PROTECTION_POLICY_V2_ABI, METHOD_NAME_TO_HASH, ORCHESTRATOR_V3_ABI2 as ORCHESTRATOR_V3_ABI, ORCHESTRATOR_V4_ABI2 as ORCHESTRATOR_V4_ABI, PAYMENT_PLATFORMS, STAKE_VAULT_ABI2 as STAKE_VAULT_ABI, STAKE_VAULT_V2_ABI2 as STAKE_VAULT_V2_ABI, SUPPORTED_PAYMENT_METHOD_HASHES, asciiToBytes32, baseStaging_default4 as baseStaging_default, base_default4 as base_default, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getDisputeProtectionPolicyContract, getDisputeProtectionPolicyV2Contract, getDisputeStackAbis, getGatingServiceAddress, getIntentGuardianContract, getKnownStakeVaultContracts, getOrchestratorV3Contract, getOrchestratorV4Contract, getPaymentMethodsCatalog, getRateManagerContracts, getStakeVaultContract, getStakeVaultV2Contract, hasIntentGuardian, matchesPaymentMethodNameAndHash, matchesQuotePaymentMethod, parseBigIntLike, parseDepositView, parseIntentView, pickAddress, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash };
|
|
158565
|
-
//# sourceMappingURL=chunk-
|
|
158566
|
-
//# sourceMappingURL=chunk-
|
|
158565
|
+
//# sourceMappingURL=chunk-4UV5XMBU.mjs.map
|
|
158566
|
+
//# sourceMappingURL=chunk-4UV5XMBU.mjs.map
|