@zyfai/sdk 1.10.1 → 1.10.2

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 CHANGED
@@ -271,9 +271,12 @@ const userAddress = await sdk.connectAccount(provider, chainId);
271
271
  ```
272
272
 
273
273
  **Nested Safe owners:** use the parent Safe's WalletConnect or Safe App provider.
274
- Pass the authenticated parent address and its deployed chain to the SDK.
275
- `sendDeposit` handles child account setup and authorisation; owners confirm in Safe{Wallet}.
276
- Use the object form for direct deposits to capture an exact proposal reference:
274
+ Pass the authenticated parent address and its deployed chain to the SDK. After
275
+ `connectAccount`, call `getNestedSafeOnboardingStatus(parent, chainId)` to see
276
+ which step is next (`deploy`, `deposit`, or `withdraw`). When `suggestedStep` is
277
+ `deploy`, call `deploySafe` (nested owners get session registration in that path).
278
+ Then fund with `sendDeposit`; owners confirm transfers in Safe{Wallet}. Use the
279
+ object form for direct deposits to capture an exact proposal reference:
277
280
 
278
281
  ```typescript
279
282
  const sent = await sdk.sendDeposit({
@@ -301,8 +304,9 @@ lifecycle ID. Use `getWithdrawStatus`, `waitForWithdrawSettlement` and
301
304
  returns to the authenticated parent Safe.
302
305
 
303
306
  See the [nested Safe integration guide](https://docs.zyf.ai/docs/sdk/nested-safe-deposit)
304
- for the recommended frontend flow. Do not manage child deployment, session signing,
305
- or individual owner keys in your application.
307
+ and [getNestedSafeOnboardingStatus](https://docs.zyf.ai/docs/sdk/api/get-nested-safe-onboarding-status)
308
+ for the recommended frontend flow. Use the SDK for deploy, deposit, and withdraw;
309
+ do not derive child addresses locally or ask customers to connect the child Safe.
306
310
 
307
311
  ##### `disconnectAccount(): Promise<void>`
308
312
 
@@ -344,9 +348,39 @@ Get the Smart Wallet (Safe) address for a user.
344
348
  }
345
349
  ```
346
350
 
351
+ ##### `getNestedSafeOnboardingStatus(userAddress: string, chainId: SupportedChainId): Promise<NestedSafeOnboardingStatusResponse>`
352
+
353
+ Nested-parent onboarding snapshot after SIWE. Requires `connectAccount()` with the parent Safe.
354
+
355
+ **Parameters:**
356
+
357
+ - `userAddress`: Parent Safe address from `connectAccount`
358
+ - `chainId`: Target chain ID (session readiness is per chain)
359
+
360
+ **Returns:**
361
+
362
+ ```typescript
363
+ {
364
+ success: boolean;
365
+ userAddress: string;
366
+ chainId: number;
367
+ status: {
368
+ isNestedOwner: boolean;
369
+ childRegistered: boolean;
370
+ childDeployed: boolean;
371
+ sessionActive: boolean;
372
+ hasPortfolioBalance: boolean;
373
+ suggestedStep: "deploy" | "deposit" | "withdraw" | "ready";
374
+ child: SmartWalletResponse | null;
375
+ };
376
+ }
377
+ ```
378
+
379
+ Gate treasury UI on `status.suggestedStep`. Docs: [nested Safe guide](https://docs.zyf.ai/docs/sdk/nested-safe-deposit), [API reference](https://docs.zyf.ai/docs/sdk/api/get-nested-safe-onboarding-status).
380
+
347
381
  ##### `deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy): Promise<DeploySafeResponse>`
348
382
 
349
- > Advanced/legacy method. New partner integrations should call `sendDeposit()`, which orchestrates account setup. Do not call this method as a separate step for a parent Safe.
383
+ > For EOA onboarding, prefer `sendDeposit()`, which orchestrates account setup. **Parent Safe treasuries** call `deploySafe` when `getNestedSafeOnboardingStatus` returns `suggestedStep: "deploy"`.
350
384
 
351
385
  Deploy a Safe smart wallet for a user. **Deployment is handled by the backend API**, which manages all RPC calls and bundler interactions. This avoids rate limiting issues.
352
386
 
package/dist/index.d.mts CHANGED
@@ -1627,17 +1627,45 @@ declare class ZyfaiSDK {
1627
1627
  */
1628
1628
  getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
1629
1629
  /**
1630
- * Nested-parent onboarding snapshot for a connected parent Safe address.
1630
+ * Return nested-parent onboarding flags and the suggested next treasury step.
1631
1631
  *
1632
1632
  * @group Deposits and withdrawals
1633
1633
  *
1634
- * @remarks Combines child resolution ({@link ZyfaiSDK.getSmartWalletAddress}),
1635
- * session state (account registration plus per-chain safe-deploy readiness),
1636
- * and portfolio balances
1634
+ * @remarks Requires SIWE via {@link ZyfaiSDK.connectAccount}. Combines child
1635
+ * resolution ({@link ZyfaiSDK.getSmartWalletAddress}), account session
1636
+ * registration, per-chain safe-deploy readiness, and portfolio balances
1637
1637
  * ({@link ZyfaiSDK.getPortfolio}). Wallet connect remains integrator-side.
1638
1638
  *
1639
+ * `status.sessionActive` is scoped to `chainId`: the account may have
1640
+ * `hasActiveSessionKey` while another chain still needs {@link ZyfaiSDK.deploySafe}.
1641
+ * When the child is deployed but the session is inactive on the requested chain,
1642
+ * `status.suggestedStep` is `"deploy"` (call `deploySafe` again).
1643
+ *
1644
+ * `status.suggestedStep` is `"deploy"` when the owner is not a nested Safe, the
1645
+ * child is missing or not deployed, or the session is inactive; `"deposit"` when
1646
+ * the session is ready and there is no withdrawable balance; `"withdraw"` when
1647
+ * the child holds withdrawable funds. The `"ready"` type variant is reserved;
1648
+ * current logic does not return it.
1649
+ *
1639
1650
  * @param userAddress - Parent Safe address from {@link ZyfaiSDK.connectAccount}
1640
1651
  * @param chainId - Target chain (deployment and session are per chain)
1652
+ *
1653
+ * @returns Success wrapper with {@link NestedSafeOnboardingStatus} on `status`
1654
+ *
1655
+ * @throws When `userAddress` is empty, `chainId` is unsupported, or
1656
+ * `userAddress` does not match the authenticated wallet
1657
+ *
1658
+ * @see https://docs.zyf.ai/docs/sdk/nested-safe-deposit Nested Safe integration
1659
+ * @see https://docs.zyf.ai/docs/sdk/api/get-nested-safe-onboarding-status API reference
1660
+ *
1661
+ * @example
1662
+ * ```typescript
1663
+ * const parent = await sdk.connectAccount(provider, chainId);
1664
+ * const { status } = await sdk.getNestedSafeOnboardingStatus(parent, chainId);
1665
+ * if (status.suggestedStep === "deploy") {
1666
+ * await sdk.deploySafe(parent, chainId);
1667
+ * }
1668
+ * ```
1641
1669
  */
1642
1670
  getNestedSafeOnboardingStatus(userAddress: string, chainId: SupportedChainId): Promise<NestedSafeOnboardingStatusResponse>;
1643
1671
  /**
package/dist/index.d.ts CHANGED
@@ -1627,17 +1627,45 @@ declare class ZyfaiSDK {
1627
1627
  */
1628
1628
  getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
1629
1629
  /**
1630
- * Nested-parent onboarding snapshot for a connected parent Safe address.
1630
+ * Return nested-parent onboarding flags and the suggested next treasury step.
1631
1631
  *
1632
1632
  * @group Deposits and withdrawals
1633
1633
  *
1634
- * @remarks Combines child resolution ({@link ZyfaiSDK.getSmartWalletAddress}),
1635
- * session state (account registration plus per-chain safe-deploy readiness),
1636
- * and portfolio balances
1634
+ * @remarks Requires SIWE via {@link ZyfaiSDK.connectAccount}. Combines child
1635
+ * resolution ({@link ZyfaiSDK.getSmartWalletAddress}), account session
1636
+ * registration, per-chain safe-deploy readiness, and portfolio balances
1637
1637
  * ({@link ZyfaiSDK.getPortfolio}). Wallet connect remains integrator-side.
1638
1638
  *
1639
+ * `status.sessionActive` is scoped to `chainId`: the account may have
1640
+ * `hasActiveSessionKey` while another chain still needs {@link ZyfaiSDK.deploySafe}.
1641
+ * When the child is deployed but the session is inactive on the requested chain,
1642
+ * `status.suggestedStep` is `"deploy"` (call `deploySafe` again).
1643
+ *
1644
+ * `status.suggestedStep` is `"deploy"` when the owner is not a nested Safe, the
1645
+ * child is missing or not deployed, or the session is inactive; `"deposit"` when
1646
+ * the session is ready and there is no withdrawable balance; `"withdraw"` when
1647
+ * the child holds withdrawable funds. The `"ready"` type variant is reserved;
1648
+ * current logic does not return it.
1649
+ *
1639
1650
  * @param userAddress - Parent Safe address from {@link ZyfaiSDK.connectAccount}
1640
1651
  * @param chainId - Target chain (deployment and session are per chain)
1652
+ *
1653
+ * @returns Success wrapper with {@link NestedSafeOnboardingStatus} on `status`
1654
+ *
1655
+ * @throws When `userAddress` is empty, `chainId` is unsupported, or
1656
+ * `userAddress` does not match the authenticated wallet
1657
+ *
1658
+ * @see https://docs.zyf.ai/docs/sdk/nested-safe-deposit Nested Safe integration
1659
+ * @see https://docs.zyf.ai/docs/sdk/api/get-nested-safe-onboarding-status API reference
1660
+ *
1661
+ * @example
1662
+ * ```typescript
1663
+ * const parent = await sdk.connectAccount(provider, chainId);
1664
+ * const { status } = await sdk.getNestedSafeOnboardingStatus(parent, chainId);
1665
+ * if (status.suggestedStep === "deploy") {
1666
+ * await sdk.deploySafe(parent, chainId);
1667
+ * }
1668
+ * ```
1641
1669
  */
1642
1670
  getNestedSafeOnboardingStatus(userAddress: string, chainId: SupportedChainId): Promise<NestedSafeOnboardingStatusResponse>;
1643
1671
  /**
package/dist/index.js CHANGED
@@ -905,7 +905,9 @@ function shouldBypassMinPortfolioCheck(executionApiUrl) {
905
905
  // src/config/min-portfolio-exempt.ts
906
906
  var MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES = /* @__PURE__ */ new Set([
907
907
  "0x2db791f63c8b12bde9a3fe31afa8ad491f47d60f",
908
- "0xae72cb0f7d604a8ff742d96031104506186638e3"
908
+ "0xae72cb0f7d604a8ff742d96031104506186638e3",
909
+ "0x7ee3f9fec0308f83f0f4319ea1515e80abc3f05c",
910
+ "0x29ed9c1d69406ddb0f6d65084a9167fedc471839"
909
911
  ]);
910
912
  function isMainnetMinPortfolioExempt(chainId, ...addresses) {
911
913
  if (chainId !== 1) {
@@ -3760,17 +3762,45 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3760
3762
  };
3761
3763
  }
3762
3764
  /**
3763
- * Nested-parent onboarding snapshot for a connected parent Safe address.
3765
+ * Return nested-parent onboarding flags and the suggested next treasury step.
3764
3766
  *
3765
3767
  * @group Deposits and withdrawals
3766
3768
  *
3767
- * @remarks Combines child resolution ({@link ZyfaiSDK.getSmartWalletAddress}),
3768
- * session state (account registration plus per-chain safe-deploy readiness),
3769
- * and portfolio balances
3769
+ * @remarks Requires SIWE via {@link ZyfaiSDK.connectAccount}. Combines child
3770
+ * resolution ({@link ZyfaiSDK.getSmartWalletAddress}), account session
3771
+ * registration, per-chain safe-deploy readiness, and portfolio balances
3770
3772
  * ({@link ZyfaiSDK.getPortfolio}). Wallet connect remains integrator-side.
3771
3773
  *
3774
+ * `status.sessionActive` is scoped to `chainId`: the account may have
3775
+ * `hasActiveSessionKey` while another chain still needs {@link ZyfaiSDK.deploySafe}.
3776
+ * When the child is deployed but the session is inactive on the requested chain,
3777
+ * `status.suggestedStep` is `"deploy"` (call `deploySafe` again).
3778
+ *
3779
+ * `status.suggestedStep` is `"deploy"` when the owner is not a nested Safe, the
3780
+ * child is missing or not deployed, or the session is inactive; `"deposit"` when
3781
+ * the session is ready and there is no withdrawable balance; `"withdraw"` when
3782
+ * the child holds withdrawable funds. The `"ready"` type variant is reserved;
3783
+ * current logic does not return it.
3784
+ *
3772
3785
  * @param userAddress - Parent Safe address from {@link ZyfaiSDK.connectAccount}
3773
3786
  * @param chainId - Target chain (deployment and session are per chain)
3787
+ *
3788
+ * @returns Success wrapper with {@link NestedSafeOnboardingStatus} on `status`
3789
+ *
3790
+ * @throws When `userAddress` is empty, `chainId` is unsupported, or
3791
+ * `userAddress` does not match the authenticated wallet
3792
+ *
3793
+ * @see https://docs.zyf.ai/docs/sdk/nested-safe-deposit Nested Safe integration
3794
+ * @see https://docs.zyf.ai/docs/sdk/api/get-nested-safe-onboarding-status API reference
3795
+ *
3796
+ * @example
3797
+ * ```typescript
3798
+ * const parent = await sdk.connectAccount(provider, chainId);
3799
+ * const { status } = await sdk.getNestedSafeOnboardingStatus(parent, chainId);
3800
+ * if (status.suggestedStep === "deploy") {
3801
+ * await sdk.deploySafe(parent, chainId);
3802
+ * }
3803
+ * ```
3774
3804
  */
3775
3805
  async getNestedSafeOnboardingStatus(userAddress, chainId) {
3776
3806
  if (!userAddress) {
package/dist/index.mjs CHANGED
@@ -825,7 +825,9 @@ function shouldBypassMinPortfolioCheck(executionApiUrl) {
825
825
  // src/config/min-portfolio-exempt.ts
826
826
  var MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES = /* @__PURE__ */ new Set([
827
827
  "0x2db791f63c8b12bde9a3fe31afa8ad491f47d60f",
828
- "0xae72cb0f7d604a8ff742d96031104506186638e3"
828
+ "0xae72cb0f7d604a8ff742d96031104506186638e3",
829
+ "0x7ee3f9fec0308f83f0f4319ea1515e80abc3f05c",
830
+ "0x29ed9c1d69406ddb0f6d65084a9167fedc471839"
829
831
  ]);
830
832
  function isMainnetMinPortfolioExempt(chainId, ...addresses) {
831
833
  if (chainId !== 1) {
@@ -3715,17 +3717,45 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3715
3717
  };
3716
3718
  }
3717
3719
  /**
3718
- * Nested-parent onboarding snapshot for a connected parent Safe address.
3720
+ * Return nested-parent onboarding flags and the suggested next treasury step.
3719
3721
  *
3720
3722
  * @group Deposits and withdrawals
3721
3723
  *
3722
- * @remarks Combines child resolution ({@link ZyfaiSDK.getSmartWalletAddress}),
3723
- * session state (account registration plus per-chain safe-deploy readiness),
3724
- * and portfolio balances
3724
+ * @remarks Requires SIWE via {@link ZyfaiSDK.connectAccount}. Combines child
3725
+ * resolution ({@link ZyfaiSDK.getSmartWalletAddress}), account session
3726
+ * registration, per-chain safe-deploy readiness, and portfolio balances
3725
3727
  * ({@link ZyfaiSDK.getPortfolio}). Wallet connect remains integrator-side.
3726
3728
  *
3729
+ * `status.sessionActive` is scoped to `chainId`: the account may have
3730
+ * `hasActiveSessionKey` while another chain still needs {@link ZyfaiSDK.deploySafe}.
3731
+ * When the child is deployed but the session is inactive on the requested chain,
3732
+ * `status.suggestedStep` is `"deploy"` (call `deploySafe` again).
3733
+ *
3734
+ * `status.suggestedStep` is `"deploy"` when the owner is not a nested Safe, the
3735
+ * child is missing or not deployed, or the session is inactive; `"deposit"` when
3736
+ * the session is ready and there is no withdrawable balance; `"withdraw"` when
3737
+ * the child holds withdrawable funds. The `"ready"` type variant is reserved;
3738
+ * current logic does not return it.
3739
+ *
3727
3740
  * @param userAddress - Parent Safe address from {@link ZyfaiSDK.connectAccount}
3728
3741
  * @param chainId - Target chain (deployment and session are per chain)
3742
+ *
3743
+ * @returns Success wrapper with {@link NestedSafeOnboardingStatus} on `status`
3744
+ *
3745
+ * @throws When `userAddress` is empty, `chainId` is unsupported, or
3746
+ * `userAddress` does not match the authenticated wallet
3747
+ *
3748
+ * @see https://docs.zyf.ai/docs/sdk/nested-safe-deposit Nested Safe integration
3749
+ * @see https://docs.zyf.ai/docs/sdk/api/get-nested-safe-onboarding-status API reference
3750
+ *
3751
+ * @example
3752
+ * ```typescript
3753
+ * const parent = await sdk.connectAccount(provider, chainId);
3754
+ * const { status } = await sdk.getNestedSafeOnboardingStatus(parent, chainId);
3755
+ * if (status.suggestedStep === "deploy") {
3756
+ * await sdk.deploySafe(parent, chainId);
3757
+ * }
3758
+ * ```
3729
3759
  */
3730
3760
  async getNestedSafeOnboardingStatus(userAddress, chainId) {
3731
3761
  if (!userAddress) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "description": "TypeScript SDK for self-custodial Zyfai yield agents: discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum, Base, and Arbitrum",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",