@zyfai/sdk 1.10.0 → 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 +40 -6
- package/dist/index.d.mts +34 -6
- package/dist/index.d.ts +34 -6
- package/dist/index.js +42 -10
- package/dist/index.mjs +42 -10
- package/package.json +1 -1
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
|
-
`
|
|
276
|
-
|
|
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
|
-
|
|
305
|
-
|
|
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
|
-
>
|
|
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
|
@@ -203,7 +203,7 @@ interface SmartWalletResponse {
|
|
|
203
203
|
isOwner: boolean;
|
|
204
204
|
}
|
|
205
205
|
/** Next nested-parent action after wallet connect (integrator-owned). */
|
|
206
|
-
type NestedSafeOnboardingStep = "deploy" | "
|
|
206
|
+
type NestedSafeOnboardingStep = "deploy" | "deposit" | "withdraw" | "ready";
|
|
207
207
|
interface NestedSafeOnboardingStatus$1 {
|
|
208
208
|
isNestedOwner: boolean;
|
|
209
209
|
childRegistered: boolean;
|
|
@@ -1627,17 +1627,45 @@ declare class ZyfaiSDK {
|
|
|
1627
1627
|
*/
|
|
1628
1628
|
getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
|
|
1629
1629
|
/**
|
|
1630
|
-
*
|
|
1630
|
+
* Return nested-parent onboarding flags and the suggested next treasury step.
|
|
1631
1631
|
*
|
|
1632
1632
|
* @group Deposits and withdrawals
|
|
1633
1633
|
*
|
|
1634
|
-
* @remarks
|
|
1635
|
-
*
|
|
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
|
/**
|
|
@@ -1655,7 +1683,7 @@ declare class ZyfaiSDK {
|
|
|
1655
1683
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
1656
1684
|
* @param chainId - Target chain ID
|
|
1657
1685
|
* @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
|
|
1658
|
-
* @param createSessionKey -
|
|
1686
|
+
* @param createSessionKey - For EOA owners, if true, creates a session key after deployment (default: false). Nested Safe owners always register the session after deploy.
|
|
1659
1687
|
* @returns Deployment response with Safe address and transaction hash
|
|
1660
1688
|
*
|
|
1661
1689
|
* @example
|
package/dist/index.d.ts
CHANGED
|
@@ -203,7 +203,7 @@ interface SmartWalletResponse {
|
|
|
203
203
|
isOwner: boolean;
|
|
204
204
|
}
|
|
205
205
|
/** Next nested-parent action after wallet connect (integrator-owned). */
|
|
206
|
-
type NestedSafeOnboardingStep = "deploy" | "
|
|
206
|
+
type NestedSafeOnboardingStep = "deploy" | "deposit" | "withdraw" | "ready";
|
|
207
207
|
interface NestedSafeOnboardingStatus$1 {
|
|
208
208
|
isNestedOwner: boolean;
|
|
209
209
|
childRegistered: boolean;
|
|
@@ -1627,17 +1627,45 @@ declare class ZyfaiSDK {
|
|
|
1627
1627
|
*/
|
|
1628
1628
|
getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
|
|
1629
1629
|
/**
|
|
1630
|
-
*
|
|
1630
|
+
* Return nested-parent onboarding flags and the suggested next treasury step.
|
|
1631
1631
|
*
|
|
1632
1632
|
* @group Deposits and withdrawals
|
|
1633
1633
|
*
|
|
1634
|
-
* @remarks
|
|
1635
|
-
*
|
|
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
|
/**
|
|
@@ -1655,7 +1683,7 @@ declare class ZyfaiSDK {
|
|
|
1655
1683
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
1656
1684
|
* @param chainId - Target chain ID
|
|
1657
1685
|
* @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
|
|
1658
|
-
* @param createSessionKey -
|
|
1686
|
+
* @param createSessionKey - For EOA owners, if true, creates a session key after deployment (default: false). Nested Safe owners always register the session after deploy.
|
|
1659
1687
|
* @returns Deployment response with Safe address and transaction hash
|
|
1660
1688
|
*
|
|
1661
1689
|
* @example
|
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) {
|
|
@@ -2081,8 +2083,9 @@ function portfolioHasWithdrawableBalance(portfolio) {
|
|
|
2081
2083
|
}
|
|
2082
2084
|
function deriveNestedSafeOnboardingStep(flags) {
|
|
2083
2085
|
if (!flags.isNestedOwner) return "deploy";
|
|
2084
|
-
if (!flags.childRegistered || !flags.childDeployed)
|
|
2085
|
-
|
|
2086
|
+
if (!flags.childRegistered || !flags.childDeployed || !flags.sessionActive) {
|
|
2087
|
+
return "deploy";
|
|
2088
|
+
}
|
|
2086
2089
|
if (!flags.hasPortfolioBalance) return "deposit";
|
|
2087
2090
|
if (flags.hasPortfolioBalance) return "withdraw";
|
|
2088
2091
|
return "ready";
|
|
@@ -3759,17 +3762,45 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3759
3762
|
};
|
|
3760
3763
|
}
|
|
3761
3764
|
/**
|
|
3762
|
-
*
|
|
3765
|
+
* Return nested-parent onboarding flags and the suggested next treasury step.
|
|
3763
3766
|
*
|
|
3764
3767
|
* @group Deposits and withdrawals
|
|
3765
3768
|
*
|
|
3766
|
-
* @remarks
|
|
3767
|
-
*
|
|
3768
|
-
* 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
|
|
3769
3772
|
* ({@link ZyfaiSDK.getPortfolio}). Wallet connect remains integrator-side.
|
|
3770
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
|
+
*
|
|
3771
3785
|
* @param userAddress - Parent Safe address from {@link ZyfaiSDK.connectAccount}
|
|
3772
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
|
+
* ```
|
|
3773
3804
|
*/
|
|
3774
3805
|
async getNestedSafeOnboardingStatus(userAddress, chainId) {
|
|
3775
3806
|
if (!userAddress) {
|
|
@@ -3851,7 +3882,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3851
3882
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
3852
3883
|
* @param chainId - Target chain ID
|
|
3853
3884
|
* @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
|
|
3854
|
-
* @param createSessionKey -
|
|
3885
|
+
* @param createSessionKey - For EOA owners, if true, creates a session key after deployment (default: false). Nested Safe owners always register the session after deploy.
|
|
3855
3886
|
* @returns Deployment response with Safe address and transaction hash
|
|
3856
3887
|
*
|
|
3857
3888
|
* @example
|
|
@@ -3909,6 +3940,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3909
3940
|
chainConfig.publicClient
|
|
3910
3941
|
);
|
|
3911
3942
|
const nestedSafeOwner = ownerAccountType === "Safe";
|
|
3943
|
+
const registerSession = nestedSafeOwner || Boolean(createSessionKey);
|
|
3912
3944
|
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
3913
3945
|
if (!safeAddress && !nestedSafeOwner) {
|
|
3914
3946
|
throw new Error(
|
|
@@ -3933,7 +3965,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3933
3965
|
}
|
|
3934
3966
|
await this.updateUserProtocols(strategy);
|
|
3935
3967
|
let sessionKeyCreated2 = false;
|
|
3936
|
-
if (
|
|
3968
|
+
if (registerSession) {
|
|
3937
3969
|
try {
|
|
3938
3970
|
await this.createSessionKey(userAddress, chainId);
|
|
3939
3971
|
sessionKeyCreated2 = true;
|
|
@@ -3993,7 +4025,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3993
4025
|
});
|
|
3994
4026
|
}
|
|
3995
4027
|
let sessionKeyCreated = false;
|
|
3996
|
-
if (
|
|
4028
|
+
if (registerSession) {
|
|
3997
4029
|
try {
|
|
3998
4030
|
await this.createSessionKey(userAddress, chainId);
|
|
3999
4031
|
sessionKeyCreated = true;
|
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) {
|
|
@@ -2036,8 +2038,9 @@ function portfolioHasWithdrawableBalance(portfolio) {
|
|
|
2036
2038
|
}
|
|
2037
2039
|
function deriveNestedSafeOnboardingStep(flags) {
|
|
2038
2040
|
if (!flags.isNestedOwner) return "deploy";
|
|
2039
|
-
if (!flags.childRegistered || !flags.childDeployed)
|
|
2040
|
-
|
|
2041
|
+
if (!flags.childRegistered || !flags.childDeployed || !flags.sessionActive) {
|
|
2042
|
+
return "deploy";
|
|
2043
|
+
}
|
|
2041
2044
|
if (!flags.hasPortfolioBalance) return "deposit";
|
|
2042
2045
|
if (flags.hasPortfolioBalance) return "withdraw";
|
|
2043
2046
|
return "ready";
|
|
@@ -3714,17 +3717,45 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3714
3717
|
};
|
|
3715
3718
|
}
|
|
3716
3719
|
/**
|
|
3717
|
-
*
|
|
3720
|
+
* Return nested-parent onboarding flags and the suggested next treasury step.
|
|
3718
3721
|
*
|
|
3719
3722
|
* @group Deposits and withdrawals
|
|
3720
3723
|
*
|
|
3721
|
-
* @remarks
|
|
3722
|
-
*
|
|
3723
|
-
* 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
|
|
3724
3727
|
* ({@link ZyfaiSDK.getPortfolio}). Wallet connect remains integrator-side.
|
|
3725
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
|
+
*
|
|
3726
3740
|
* @param userAddress - Parent Safe address from {@link ZyfaiSDK.connectAccount}
|
|
3727
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
|
+
* ```
|
|
3728
3759
|
*/
|
|
3729
3760
|
async getNestedSafeOnboardingStatus(userAddress, chainId) {
|
|
3730
3761
|
if (!userAddress) {
|
|
@@ -3806,7 +3837,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3806
3837
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
3807
3838
|
* @param chainId - Target chain ID
|
|
3808
3839
|
* @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
|
|
3809
|
-
* @param createSessionKey -
|
|
3840
|
+
* @param createSessionKey - For EOA owners, if true, creates a session key after deployment (default: false). Nested Safe owners always register the session after deploy.
|
|
3810
3841
|
* @returns Deployment response with Safe address and transaction hash
|
|
3811
3842
|
*
|
|
3812
3843
|
* @example
|
|
@@ -3864,6 +3895,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3864
3895
|
chainConfig.publicClient
|
|
3865
3896
|
);
|
|
3866
3897
|
const nestedSafeOwner = ownerAccountType === "Safe";
|
|
3898
|
+
const registerSession = nestedSafeOwner || Boolean(createSessionKey);
|
|
3867
3899
|
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
3868
3900
|
if (!safeAddress && !nestedSafeOwner) {
|
|
3869
3901
|
throw new Error(
|
|
@@ -3888,7 +3920,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3888
3920
|
}
|
|
3889
3921
|
await this.updateUserProtocols(strategy);
|
|
3890
3922
|
let sessionKeyCreated2 = false;
|
|
3891
|
-
if (
|
|
3923
|
+
if (registerSession) {
|
|
3892
3924
|
try {
|
|
3893
3925
|
await this.createSessionKey(userAddress, chainId);
|
|
3894
3926
|
sessionKeyCreated2 = true;
|
|
@@ -3948,7 +3980,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3948
3980
|
});
|
|
3949
3981
|
}
|
|
3950
3982
|
let sessionKeyCreated = false;
|
|
3951
|
-
if (
|
|
3983
|
+
if (registerSession) {
|
|
3952
3984
|
try {
|
|
3953
3985
|
await this.createSessionKey(userAddress, chainId);
|
|
3954
3986
|
sessionKeyCreated = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "1.10.
|
|
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",
|