@zeroxyz/sdk 0.10.0 → 0.11.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/CHANGELOG.md +8 -0
- package/README.md +17 -3
- package/dist/{chunk-IFVGW4ZN.cjs → chunk-HKF4TRC6.cjs} +46 -3
- package/dist/chunk-HKF4TRC6.cjs.map +1 -0
- package/dist/{chunk-A7WZYQXS.js → chunk-T77VVLOM.js} +46 -3
- package/dist/chunk-T77VVLOM.js.map +1 -0
- package/dist/{client-D_ohktBl.d.cts → client-DKbrAo9Z.d.cts} +19 -1
- package/dist/{client-D_ohktBl.d.ts → client-DKbrAo9Z.d.ts} +19 -1
- package/dist/index.cjs +44 -44
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-A7WZYQXS.js.map +0 -1
- package/dist/chunk-IFVGW4ZN.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to `@zeroxyz/sdk` will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) — with the pre-1.0 caveat that minor versions may include breaking changes.
|
|
6
6
|
|
|
7
|
+
## 0.11.0
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`client.wallet.import()`** — link an existing self-custody wallet to the session user by private key (`{ privateKey, makePrimary? }` → the linked wallet). 409s when the wallet is already linked to this or another profile. New export `ImportWalletOptions`. (ZERO-478)
|
|
12
|
+
- **`client.wallet.setPrimary()` / `client.wallet.remove()`** — session-mode multi-wallet management: switch the primary payer wallet, or unlink a wallet (rejected for the primary wallet or a non-zero balance). New exports `SetPrimaryWalletOptions` / `RemoveWalletOptions`. (ZERO-478)
|
|
13
|
+
- **`UserWalletDto.importedAt`** — set on wallets linked via `wallet.import()`, absent/null otherwise. (ZERO-478)
|
|
14
|
+
|
|
7
15
|
## 0.10.0
|
|
8
16
|
|
|
9
17
|
### Changed
|
package/README.md
CHANGED
|
@@ -223,14 +223,26 @@ const url = await client.wallet.fundingUrl({ amount: "10" });
|
|
|
223
223
|
|
|
224
224
|
Poll `balance()` to decide when to top up. Then either open `fundingUrl()` yourself to refill the shared wallet — from an ops dashboard, a low-balance alert, or alongside a direct USDC transfer to the `wallet.address()` result — or hand the link to the end user. Either way the link is **single-use** and burns when opened, so generate it at the moment of funding and don't pre-open one you intend to give to someone else.
|
|
225
225
|
|
|
226
|
-
In **session mode** (acting for a Zero user)
|
|
226
|
+
In **session mode** (acting for a Zero user) wallets are managed server-side, and a few more methods apply:
|
|
227
227
|
|
|
228
228
|
```ts
|
|
229
229
|
await client.wallet.list(); // every wallet linked to the session user
|
|
230
230
|
await client.wallet.provision(); // create the user's managed wallet (idempotent)
|
|
231
|
+
|
|
232
|
+
// Link an existing self-custody wallet by private key (0x prefix optional).
|
|
233
|
+
// Pass makePrimary to have it pay for the user's calls from now on.
|
|
234
|
+
const imported = await client.wallet.import({
|
|
235
|
+
privateKey: "0x…",
|
|
236
|
+
makePrimary: true,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Switch which linked wallet is primary, or unlink one. remove() rejects the
|
|
240
|
+
// primary wallet and any wallet holding a balance — reassign / drain first.
|
|
241
|
+
await client.wallet.setPrimary({ walletAddress: imported.walletAddress });
|
|
242
|
+
await client.wallet.remove({ walletAddress: "0x…" });
|
|
231
243
|
```
|
|
232
244
|
|
|
233
|
-
`wallet.address()` covers the common case (resolve — or provision — the primary managed wallet); reach for
|
|
245
|
+
`wallet.address()` covers the common case (resolve — or provision — the primary managed wallet); reach for the methods above when you need the full wallet objects, explicit provisioning, or multi-wallet management. Imported wallets carry an `importedAt` timestamp on the returned wallet objects.
|
|
234
246
|
|
|
235
247
|
## Namespaces
|
|
236
248
|
|
|
@@ -249,7 +261,9 @@ const { capabilities } = await client.search("translate text to french", {
|
|
|
249
261
|
const cap = await client.capabilities.get("cap_abc"); // by uid
|
|
250
262
|
const cap2 = await client.capabilities.get("z_Ab12cd.1"); // by search token
|
|
251
263
|
|
|
252
|
-
// Wallet — balance
|
|
264
|
+
// Wallet — balance, one-time funding URL, and (session mode) multi-wallet
|
|
265
|
+
// management: list / provision / import / setPrimary / remove. See
|
|
266
|
+
// "Wallet & funding" above.
|
|
253
267
|
const { amount } = await client.wallet.balance();
|
|
254
268
|
const fundUrl = await client.wallet.fundingUrl({ amount: "10" });
|
|
255
269
|
|
|
@@ -1952,7 +1952,7 @@ var clientFetch = async (client, url, opts = {}) => {
|
|
|
1952
1952
|
|
|
1953
1953
|
// package.json
|
|
1954
1954
|
var package_default = {
|
|
1955
|
-
version: "0.
|
|
1955
|
+
version: "0.11.0"};
|
|
1956
1956
|
|
|
1957
1957
|
// src/version.ts
|
|
1958
1958
|
var SDK_VERSION = package_default.version;
|
|
@@ -2443,6 +2443,7 @@ var userWalletDtoSchema = zod.z.object({
|
|
|
2443
2443
|
source: zod.z.enum(["self_custody", "privy_embedded"]),
|
|
2444
2444
|
isPrimary: zod.z.boolean(),
|
|
2445
2445
|
linkedAt: zod.z.union([zod.z.string(), zod.z.date()]).nullable().optional(),
|
|
2446
|
+
importedAt: zod.z.union([zod.z.string(), zod.z.date()]).nullable().optional(),
|
|
2446
2447
|
delegationGranted: zod.z.boolean(),
|
|
2447
2448
|
signerQuorumId: zod.z.string().nullable(),
|
|
2448
2449
|
// Per-transaction USDC cap in base units (6 dp). null = unlimited, 0 = free-only.
|
|
@@ -3228,6 +3229,48 @@ var Wallet = class {
|
|
|
3228
3229
|
},
|
|
3229
3230
|
userWalletDtoSchema
|
|
3230
3231
|
);
|
|
3232
|
+
// Link an existing self-custody wallet to the session user by private key.
|
|
3233
|
+
// Session-only. 409s when the wallet is already linked (to this or another
|
|
3234
|
+
// profile — the error message says which).
|
|
3235
|
+
import = (opts) => request(
|
|
3236
|
+
this.client,
|
|
3237
|
+
{
|
|
3238
|
+
method: "POST",
|
|
3239
|
+
path: "/v1/users/me/wallets/import",
|
|
3240
|
+
body: {
|
|
3241
|
+
privateKey: opts.privateKey,
|
|
3242
|
+
...opts.makePrimary !== void 0 ? { makePrimary: opts.makePrimary } : {}
|
|
3243
|
+
},
|
|
3244
|
+
signal: opts.signal
|
|
3245
|
+
},
|
|
3246
|
+
userWalletDtoSchema
|
|
3247
|
+
);
|
|
3248
|
+
// Make one of the session user's linked wallets the primary payer.
|
|
3249
|
+
// Session-only. 404s when the address isn't linked to the user.
|
|
3250
|
+
setPrimary = (opts) => request(
|
|
3251
|
+
this.client,
|
|
3252
|
+
{
|
|
3253
|
+
method: "PATCH",
|
|
3254
|
+
path: "/v1/users/me/wallets/primary",
|
|
3255
|
+
body: { walletAddress: opts.walletAddress },
|
|
3256
|
+
signal: opts.signal
|
|
3257
|
+
},
|
|
3258
|
+
userWalletDtoSchema
|
|
3259
|
+
);
|
|
3260
|
+
// Unlink a wallet from the session user. Session-only. 409s on the primary
|
|
3261
|
+
// wallet or a non-zero balance (the error message says which); 404s when
|
|
3262
|
+
// the address isn't linked. Responds 204 — resolves to void.
|
|
3263
|
+
remove = async (opts) => {
|
|
3264
|
+
await request(
|
|
3265
|
+
this.client,
|
|
3266
|
+
{
|
|
3267
|
+
method: "DELETE",
|
|
3268
|
+
path: `/v1/users/me/wallets/${opts.walletAddress}`,
|
|
3269
|
+
signal: opts.signal
|
|
3270
|
+
},
|
|
3271
|
+
zod.z.undefined()
|
|
3272
|
+
);
|
|
3273
|
+
};
|
|
3231
3274
|
// Routes by identity: account mode signs EIP-191 against /v1/wallet/fund-url,
|
|
3232
3275
|
// session mode hits /v1/users/me/fund-url (Bearer-authed, wallet resolved
|
|
3233
3276
|
// server-side). Both honor `provider` (coinbase | stripe).
|
|
@@ -3785,5 +3828,5 @@ exports.normalizeTransportEnvelopeRequest = normalizeTransportEnvelopeRequest;
|
|
|
3785
3828
|
exports.paymentHasAnchor = paymentHasAnchor;
|
|
3786
3829
|
exports.tempoChainLabelFromId = tempoChainLabelFromId;
|
|
3787
3830
|
exports.unwrapTransportEnvelope = unwrapTransportEnvelope;
|
|
3788
|
-
//# sourceMappingURL=chunk-
|
|
3789
|
-
//# sourceMappingURL=chunk-
|
|
3831
|
+
//# sourceMappingURL=chunk-HKF4TRC6.cjs.map
|
|
3832
|
+
//# sourceMappingURL=chunk-HKF4TRC6.cjs.map
|