@zyfai/sdk 1.8.0 → 1.8.3

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.
Files changed (3) hide show
  1. package/dist/index.js +120 -33
  2. package/dist/index.mjs +124 -36
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1413,6 +1413,10 @@ var INTENT_EXECUTOR = "0x00000000005aD9ce1f5035FD62CA96CEf16AdAAF";
1413
1413
  var PROXY_EXECUTOR = "0xF659d30D4EB88B06A909F20839D8959Bd77d8790";
1414
1414
  var INTENT_SMART_SESSIONS = "0xad568b3f825a8d5ffc06dd3253526b64d810ae89";
1415
1415
  var OWNABLE_VALIDATOR = "0x000000000013fdB5234E4E3162a810F54d9f7E98";
1416
+ var OWNABLE_VALIDATOR_DEPLOYMENTS = [
1417
+ "0x2483DA3A338895199E5e538530213157e931Bf06",
1418
+ OWNABLE_VALIDATOR
1419
+ ];
1416
1420
  var SAFE_7579_ADDRESS = "0x7579EE8307284F293B1927136486880611F20002";
1417
1421
  var ERC7579_LAUNCHPAD_ADDRESS = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
1418
1422
  var POOL_MODULE_ADDRESSES = [
@@ -1551,12 +1555,9 @@ async function signMultiChainSessionTypedData(walletClient, typedData) {
1551
1555
  if (!walletClient.account) {
1552
1556
  throw new Error("Wallet not connected. Please connect your wallet first.");
1553
1557
  }
1554
- return walletClient.signTypedData({
1558
+ return walletClient.signMessage({
1555
1559
  account: walletClient.account,
1556
- domain: typedData.domain,
1557
- types: typedData.types,
1558
- primaryType: typedData.primaryType,
1559
- message: typedData.message
1560
+ message: { raw: (0, import_viem5.hashTypedData)(typedData) }
1560
1561
  });
1561
1562
  }
1562
1563
 
@@ -1645,13 +1646,12 @@ var isOwnableValidatorOwner = async (safeAddress, userAddress, publicClient) =>
1645
1646
  }
1646
1647
  return false;
1647
1648
  };
1649
+ var isEip7702Delegation = (code) => !!code && code.toLowerCase().startsWith("0xef0100");
1650
+ var hasPersistentContractCode = (code) => !!code && code !== "0x" && !isEip7702Delegation(code);
1648
1651
  var getAccountType = async (address, publicClient) => {
1649
1652
  try {
1650
1653
  const code = await publicClient.getCode({ address });
1651
- if (!code || code === "0x" || code.length === 2) {
1652
- return "EOA";
1653
- }
1654
- if (code.startsWith("0xef01")) {
1654
+ if (!code || code === "0x" || code.length === 2 || isEip7702Delegation(code)) {
1655
1655
  return "EOA";
1656
1656
  }
1657
1657
  try {
@@ -1681,18 +1681,33 @@ var getAccountType = async (address, publicClient) => {
1681
1681
  };
1682
1682
  var deploySafeAccount = async (config) => {
1683
1683
  try {
1684
- const { owner, httpClient, chainId, strategy = "safe_strategy" } = config;
1684
+ const {
1685
+ owner,
1686
+ httpClient,
1687
+ chainId,
1688
+ publicClient,
1689
+ safeOwnerAddress,
1690
+ strategy
1691
+ } = config;
1685
1692
  if (!owner || !owner.account) {
1686
1693
  throw new Error(
1687
1694
  "Wallet not connected. Please connect your wallet first."
1688
1695
  );
1689
1696
  }
1690
1697
  console.log("strategy", strategy);
1698
+ const strategyBody = strategy ? { strategy } : {};
1691
1699
  const prepareResponse = await httpClient.post(
1692
1700
  `${ENDPOINTS.SAFE_DEPLOY}?chainId=${chainId}`,
1693
- { strategy }
1701
+ strategyBody
1694
1702
  );
1695
1703
  console.log("prepareResponse", prepareResponse);
1704
+ if (prepareResponse.success && !prepareResponse.userOpHashToSign) {
1705
+ return {
1706
+ safeAddress: prepareResponse.safeAddress || "0x",
1707
+ txHash: "0x0",
1708
+ isDeployed: true
1709
+ };
1710
+ }
1696
1711
  if (!prepareResponse.userOpHashToSign) {
1697
1712
  throw new Error(
1698
1713
  "Backend did not return userOpHashToSign. Response: " + JSON.stringify(prepareResponse)
@@ -1703,9 +1718,29 @@ var deploySafeAccount = async (config) => {
1703
1718
  account: owner.account,
1704
1719
  message: { raw: userOpHashToSign }
1705
1720
  });
1721
+ const ownerAddress = (0, import_viem6.getAddress)(safeOwnerAddress);
1722
+ const ownerCode = await publicClient.getCode({ address: ownerAddress }).catch((error) => {
1723
+ console.warn(
1724
+ `[ZyfaiSDK] Could not read code at owner ${ownerAddress}: ${error.message}. Submitting the owner signature unwrapped; a contract owner will be rejected with AA24.`
1725
+ );
1726
+ return void 0;
1727
+ });
1728
+ const delegatedEoa = isEip7702Delegation(ownerCode);
1729
+ const wrapContractSignature = hasPersistentContractCode(ownerCode);
1730
+ const ownerKind = delegatedEoa ? "eip7702" : wrapContractSignature ? "contract" : "eoa";
1731
+ console.info(
1732
+ `[ZyfaiSDK] safe-deploy signature chainId=${chainId} owner=${ownerAddress} ownerKind=${ownerKind} wrapped=${wrapContractSignature}`
1733
+ );
1734
+ const signatureToSubmit = wrapContractSignature ? buildSafeSignatureBytes([
1735
+ {
1736
+ signer: ownerAddress,
1737
+ data: userOpSignature,
1738
+ isContractSignature: true
1739
+ }
1740
+ ]) : userOpSignature;
1706
1741
  const deployResponse = await httpClient.post(
1707
1742
  `${ENDPOINTS.SAFE_DEPLOY}?chainId=${chainId}`,
1708
- { userOpSignature, strategy }
1743
+ { userOpSignature: signatureToSubmit, ...strategyBody }
1709
1744
  );
1710
1745
  if (!deployResponse.success) {
1711
1746
  throw new Error(
@@ -1778,6 +1813,33 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
1778
1813
  sessionNonces
1779
1814
  };
1780
1815
  };
1816
+ var IS_MODULE_INSTALLED_ABI = [
1817
+ {
1818
+ type: "function",
1819
+ name: "isModuleInstalled",
1820
+ stateMutability: "view",
1821
+ inputs: [
1822
+ { name: "moduleTypeId", type: "uint256" },
1823
+ { name: "module", type: "address" },
1824
+ { name: "additionalContext", type: "bytes" }
1825
+ ],
1826
+ outputs: [{ type: "bool" }]
1827
+ }
1828
+ ];
1829
+ async function resolveOwnerValidator(publicClient, childSafeAddress) {
1830
+ for (const candidate of OWNABLE_VALIDATOR_DEPLOYMENTS) {
1831
+ const installed = await publicClient.readContract({
1832
+ address: childSafeAddress,
1833
+ abi: IS_MODULE_INSTALLED_ABI,
1834
+ functionName: "isModuleInstalled",
1835
+ args: [1n, candidate, "0x"]
1836
+ }).catch(() => false);
1837
+ if (installed) return candidate;
1838
+ }
1839
+ throw new Error(
1840
+ `No known OwnableValidator is installed on Safe ${childSafeAddress}. A nested Safe owner signature cannot be routed to a validator.`
1841
+ );
1842
+ }
1781
1843
  async function signNestedOwnerSessionKey(config, sessions, allPublicClients, signingParams) {
1782
1844
  const { owner, publicClient, safeOwnerAddress } = config;
1783
1845
  const derivedChild = (await getSafeAccount(config)).address;
@@ -1809,17 +1871,15 @@ async function signNestedOwnerSessionKey(config, sessions, allPublicClients, sig
1809
1871
  sessionNonces,
1810
1872
  permitGenericPolicy
1811
1873
  });
1812
- const sessionValidator = sessions[0]?.sessionValidator;
1813
- if (!sessionValidator) {
1814
- throw new Error(
1815
- "Session configuration has no sessionValidator. The nested Safe signature cannot be routed to a validator."
1816
- );
1817
- }
1874
+ const ownerValidator = await resolveOwnerValidator(
1875
+ publicClient,
1876
+ childSafeAddress
1877
+ );
1818
1878
  const rawSignature = await signMultiChainSessionTypedData(owner, typedData);
1819
1879
  const signature = wrapNestedSafeOwnerSignature(
1820
1880
  safeOwnerAddress,
1821
1881
  rawSignature,
1822
- sessionValidator
1882
+ ownerValidator
1823
1883
  );
1824
1884
  return {
1825
1885
  signature,
@@ -3312,15 +3372,19 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3312
3372
  await this.deploySafe(userAddress, chainId, strategy, true);
3313
3373
  return;
3314
3374
  }
3375
+ console.info(
3376
+ `[ZyfaiSDK] nested deposit signing pending enable only chainId=${chainId} owner=${userAddress} sessionActive=${this.hasActiveSessionKey}`
3377
+ );
3378
+ await deploySafeAccount({
3379
+ owner: this.getWalletClient(chainId),
3380
+ safeOwnerAddress: userAddress,
3381
+ chain: chainConfig.chain,
3382
+ publicClient: chainConfig.publicClient,
3383
+ chainId,
3384
+ httpClient: this.httpClient
3385
+ });
3315
3386
  if (!this.hasActiveSessionKey) {
3316
- try {
3317
- await this.createSessionKey(userAddress, chainId);
3318
- } catch (sessionError) {
3319
- console.warn(
3320
- "Failed to create session key for nested owner:",
3321
- sessionError.message
3322
- );
3323
- }
3387
+ await this.createSessionKey(userAddress, chainId);
3324
3388
  }
3325
3389
  }
3326
3390
  async hydrateSessionWallet() {
@@ -3471,16 +3535,28 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3471
3535
  }
3472
3536
  const walletClient = this.getWalletClient(chainId);
3473
3537
  const chainConfig = getChainConfig(chainId, this.rpcUrls);
3474
- const safeAddress = await getDeterministicSafeAddress({
3475
- safeOwnerAddress: userAddress,
3476
- chain: chainConfig.chain,
3477
- publicClient: chainConfig.publicClient
3478
- });
3538
+ const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
3539
+ if (!safeAddress) {
3540
+ throw new Error("Smart wallet address is not available");
3541
+ }
3479
3542
  const alreadyDeployed = await isSafeDeployed(
3480
3543
  safeAddress,
3481
3544
  chainConfig.publicClient
3482
3545
  );
3483
3546
  if (alreadyDeployed) {
3547
+ let enableTxHash = "0x0";
3548
+ if (!this.isPredeployed) {
3549
+ const enabled = await deploySafeAccount({
3550
+ owner: walletClient,
3551
+ safeOwnerAddress: userAddress,
3552
+ chain: chainConfig.chain,
3553
+ publicClient: chainConfig.publicClient,
3554
+ chainId,
3555
+ httpClient: this.httpClient,
3556
+ strategy: strategy ? toInternalStrategy(strategy) : "safe_strategy"
3557
+ });
3558
+ enableTxHash = enabled.txHash || "0x0";
3559
+ }
3484
3560
  await this.updateUserProtocols(strategy);
3485
3561
  let sessionKeyCreated2 = false;
3486
3562
  if (createSessionKey) {
@@ -3497,7 +3573,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3497
3573
  return {
3498
3574
  success: true,
3499
3575
  safeAddress,
3500
- txHash: "0x0",
3576
+ txHash: enableTxHash,
3501
3577
  status: "deployed",
3502
3578
  sessionKeyCreated: sessionKeyCreated2
3503
3579
  };
@@ -3522,6 +3598,17 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3522
3598
  );
3523
3599
  }
3524
3600
  await this.updateUserProtocols(strategy);
3601
+ if (!this.isPredeployed) {
3602
+ await deploySafeAccount({
3603
+ owner: walletClient,
3604
+ safeOwnerAddress: userAddress,
3605
+ chain: chainConfig.chain,
3606
+ publicClient: chainConfig.publicClient,
3607
+ chainId,
3608
+ httpClient: this.httpClient,
3609
+ strategy: internalStrategy
3610
+ });
3611
+ }
3525
3612
  let sessionKeyCreated = false;
3526
3613
  if (createSessionKey) {
3527
3614
  try {
package/dist/index.mjs CHANGED
@@ -1362,6 +1362,10 @@ var INTENT_EXECUTOR = "0x00000000005aD9ce1f5035FD62CA96CEf16AdAAF";
1362
1362
  var PROXY_EXECUTOR = "0xF659d30D4EB88B06A909F20839D8959Bd77d8790";
1363
1363
  var INTENT_SMART_SESSIONS = "0xad568b3f825a8d5ffc06dd3253526b64d810ae89";
1364
1364
  var OWNABLE_VALIDATOR = "0x000000000013fdB5234E4E3162a810F54d9f7E98";
1365
+ var OWNABLE_VALIDATOR_DEPLOYMENTS = [
1366
+ "0x2483DA3A338895199E5e538530213157e931Bf06",
1367
+ OWNABLE_VALIDATOR
1368
+ ];
1365
1369
  var SAFE_7579_ADDRESS = "0x7579EE8307284F293B1927136486880611F20002";
1366
1370
  var ERC7579_LAUNCHPAD_ADDRESS = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
1367
1371
  var POOL_MODULE_ADDRESSES = [
@@ -1377,7 +1381,8 @@ var POOL_MODULE_ADDRESSES = [
1377
1381
  import { SMART_SESSIONS_ADDRESS } from "@rhinestone/module-sdk";
1378
1382
  import {
1379
1383
  concat,
1380
- getAddress
1384
+ getAddress,
1385
+ hashTypedData
1381
1386
  } from "viem";
1382
1387
  var EMPTY_DATA = "0x";
1383
1388
  var SIGNATURE_LENGTH_BYTES = 65;
@@ -1503,12 +1508,9 @@ async function signMultiChainSessionTypedData(walletClient, typedData) {
1503
1508
  if (!walletClient.account) {
1504
1509
  throw new Error("Wallet not connected. Please connect your wallet first.");
1505
1510
  }
1506
- return walletClient.signTypedData({
1511
+ return walletClient.signMessage({
1507
1512
  account: walletClient.account,
1508
- domain: typedData.domain,
1509
- types: typedData.types,
1510
- primaryType: typedData.primaryType,
1511
- message: typedData.message
1513
+ message: { raw: hashTypedData(typedData) }
1512
1514
  });
1513
1515
  }
1514
1516
 
@@ -1597,13 +1599,12 @@ var isOwnableValidatorOwner = async (safeAddress, userAddress, publicClient) =>
1597
1599
  }
1598
1600
  return false;
1599
1601
  };
1602
+ var isEip7702Delegation = (code) => !!code && code.toLowerCase().startsWith("0xef0100");
1603
+ var hasPersistentContractCode = (code) => !!code && code !== "0x" && !isEip7702Delegation(code);
1600
1604
  var getAccountType = async (address, publicClient) => {
1601
1605
  try {
1602
1606
  const code = await publicClient.getCode({ address });
1603
- if (!code || code === "0x" || code.length === 2) {
1604
- return "EOA";
1605
- }
1606
- if (code.startsWith("0xef01")) {
1607
+ if (!code || code === "0x" || code.length === 2 || isEip7702Delegation(code)) {
1607
1608
  return "EOA";
1608
1609
  }
1609
1610
  try {
@@ -1633,18 +1634,33 @@ var getAccountType = async (address, publicClient) => {
1633
1634
  };
1634
1635
  var deploySafeAccount = async (config) => {
1635
1636
  try {
1636
- const { owner, httpClient, chainId, strategy = "safe_strategy" } = config;
1637
+ const {
1638
+ owner,
1639
+ httpClient,
1640
+ chainId,
1641
+ publicClient,
1642
+ safeOwnerAddress,
1643
+ strategy
1644
+ } = config;
1637
1645
  if (!owner || !owner.account) {
1638
1646
  throw new Error(
1639
1647
  "Wallet not connected. Please connect your wallet first."
1640
1648
  );
1641
1649
  }
1642
1650
  console.log("strategy", strategy);
1651
+ const strategyBody = strategy ? { strategy } : {};
1643
1652
  const prepareResponse = await httpClient.post(
1644
1653
  `${ENDPOINTS.SAFE_DEPLOY}?chainId=${chainId}`,
1645
- { strategy }
1654
+ strategyBody
1646
1655
  );
1647
1656
  console.log("prepareResponse", prepareResponse);
1657
+ if (prepareResponse.success && !prepareResponse.userOpHashToSign) {
1658
+ return {
1659
+ safeAddress: prepareResponse.safeAddress || "0x",
1660
+ txHash: "0x0",
1661
+ isDeployed: true
1662
+ };
1663
+ }
1648
1664
  if (!prepareResponse.userOpHashToSign) {
1649
1665
  throw new Error(
1650
1666
  "Backend did not return userOpHashToSign. Response: " + JSON.stringify(prepareResponse)
@@ -1655,9 +1671,29 @@ var deploySafeAccount = async (config) => {
1655
1671
  account: owner.account,
1656
1672
  message: { raw: userOpHashToSign }
1657
1673
  });
1674
+ const ownerAddress = getAddress2(safeOwnerAddress);
1675
+ const ownerCode = await publicClient.getCode({ address: ownerAddress }).catch((error) => {
1676
+ console.warn(
1677
+ `[ZyfaiSDK] Could not read code at owner ${ownerAddress}: ${error.message}. Submitting the owner signature unwrapped; a contract owner will be rejected with AA24.`
1678
+ );
1679
+ return void 0;
1680
+ });
1681
+ const delegatedEoa = isEip7702Delegation(ownerCode);
1682
+ const wrapContractSignature = hasPersistentContractCode(ownerCode);
1683
+ const ownerKind = delegatedEoa ? "eip7702" : wrapContractSignature ? "contract" : "eoa";
1684
+ console.info(
1685
+ `[ZyfaiSDK] safe-deploy signature chainId=${chainId} owner=${ownerAddress} ownerKind=${ownerKind} wrapped=${wrapContractSignature}`
1686
+ );
1687
+ const signatureToSubmit = wrapContractSignature ? buildSafeSignatureBytes([
1688
+ {
1689
+ signer: ownerAddress,
1690
+ data: userOpSignature,
1691
+ isContractSignature: true
1692
+ }
1693
+ ]) : userOpSignature;
1658
1694
  const deployResponse = await httpClient.post(
1659
1695
  `${ENDPOINTS.SAFE_DEPLOY}?chainId=${chainId}`,
1660
- { userOpSignature, strategy }
1696
+ { userOpSignature: signatureToSubmit, ...strategyBody }
1661
1697
  );
1662
1698
  if (!deployResponse.success) {
1663
1699
  throw new Error(
@@ -1730,6 +1766,33 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
1730
1766
  sessionNonces
1731
1767
  };
1732
1768
  };
1769
+ var IS_MODULE_INSTALLED_ABI = [
1770
+ {
1771
+ type: "function",
1772
+ name: "isModuleInstalled",
1773
+ stateMutability: "view",
1774
+ inputs: [
1775
+ { name: "moduleTypeId", type: "uint256" },
1776
+ { name: "module", type: "address" },
1777
+ { name: "additionalContext", type: "bytes" }
1778
+ ],
1779
+ outputs: [{ type: "bool" }]
1780
+ }
1781
+ ];
1782
+ async function resolveOwnerValidator(publicClient, childSafeAddress) {
1783
+ for (const candidate of OWNABLE_VALIDATOR_DEPLOYMENTS) {
1784
+ const installed = await publicClient.readContract({
1785
+ address: childSafeAddress,
1786
+ abi: IS_MODULE_INSTALLED_ABI,
1787
+ functionName: "isModuleInstalled",
1788
+ args: [1n, candidate, "0x"]
1789
+ }).catch(() => false);
1790
+ if (installed) return candidate;
1791
+ }
1792
+ throw new Error(
1793
+ `No known OwnableValidator is installed on Safe ${childSafeAddress}. A nested Safe owner signature cannot be routed to a validator.`
1794
+ );
1795
+ }
1733
1796
  async function signNestedOwnerSessionKey(config, sessions, allPublicClients, signingParams) {
1734
1797
  const { owner, publicClient, safeOwnerAddress } = config;
1735
1798
  const derivedChild = (await getSafeAccount(config)).address;
@@ -1761,17 +1824,15 @@ async function signNestedOwnerSessionKey(config, sessions, allPublicClients, sig
1761
1824
  sessionNonces,
1762
1825
  permitGenericPolicy
1763
1826
  });
1764
- const sessionValidator = sessions[0]?.sessionValidator;
1765
- if (!sessionValidator) {
1766
- throw new Error(
1767
- "Session configuration has no sessionValidator. The nested Safe signature cannot be routed to a validator."
1768
- );
1769
- }
1827
+ const ownerValidator = await resolveOwnerValidator(
1828
+ publicClient,
1829
+ childSafeAddress
1830
+ );
1770
1831
  const rawSignature = await signMultiChainSessionTypedData(owner, typedData);
1771
1832
  const signature = wrapNestedSafeOwnerSignature(
1772
1833
  safeOwnerAddress,
1773
1834
  rawSignature,
1774
- sessionValidator
1835
+ ownerValidator
1775
1836
  );
1776
1837
  return {
1777
1838
  signature,
@@ -3266,15 +3327,19 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3266
3327
  await this.deploySafe(userAddress, chainId, strategy, true);
3267
3328
  return;
3268
3329
  }
3330
+ console.info(
3331
+ `[ZyfaiSDK] nested deposit signing pending enable only chainId=${chainId} owner=${userAddress} sessionActive=${this.hasActiveSessionKey}`
3332
+ );
3333
+ await deploySafeAccount({
3334
+ owner: this.getWalletClient(chainId),
3335
+ safeOwnerAddress: userAddress,
3336
+ chain: chainConfig.chain,
3337
+ publicClient: chainConfig.publicClient,
3338
+ chainId,
3339
+ httpClient: this.httpClient
3340
+ });
3269
3341
  if (!this.hasActiveSessionKey) {
3270
- try {
3271
- await this.createSessionKey(userAddress, chainId);
3272
- } catch (sessionError) {
3273
- console.warn(
3274
- "Failed to create session key for nested owner:",
3275
- sessionError.message
3276
- );
3277
- }
3342
+ await this.createSessionKey(userAddress, chainId);
3278
3343
  }
3279
3344
  }
3280
3345
  async hydrateSessionWallet() {
@@ -3425,16 +3490,28 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3425
3490
  }
3426
3491
  const walletClient = this.getWalletClient(chainId);
3427
3492
  const chainConfig = getChainConfig(chainId, this.rpcUrls);
3428
- const safeAddress = await getDeterministicSafeAddress({
3429
- safeOwnerAddress: userAddress,
3430
- chain: chainConfig.chain,
3431
- publicClient: chainConfig.publicClient
3432
- });
3493
+ const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
3494
+ if (!safeAddress) {
3495
+ throw new Error("Smart wallet address is not available");
3496
+ }
3433
3497
  const alreadyDeployed = await isSafeDeployed(
3434
3498
  safeAddress,
3435
3499
  chainConfig.publicClient
3436
3500
  );
3437
3501
  if (alreadyDeployed) {
3502
+ let enableTxHash = "0x0";
3503
+ if (!this.isPredeployed) {
3504
+ const enabled = await deploySafeAccount({
3505
+ owner: walletClient,
3506
+ safeOwnerAddress: userAddress,
3507
+ chain: chainConfig.chain,
3508
+ publicClient: chainConfig.publicClient,
3509
+ chainId,
3510
+ httpClient: this.httpClient,
3511
+ strategy: strategy ? toInternalStrategy(strategy) : "safe_strategy"
3512
+ });
3513
+ enableTxHash = enabled.txHash || "0x0";
3514
+ }
3438
3515
  await this.updateUserProtocols(strategy);
3439
3516
  let sessionKeyCreated2 = false;
3440
3517
  if (createSessionKey) {
@@ -3451,7 +3528,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3451
3528
  return {
3452
3529
  success: true,
3453
3530
  safeAddress,
3454
- txHash: "0x0",
3531
+ txHash: enableTxHash,
3455
3532
  status: "deployed",
3456
3533
  sessionKeyCreated: sessionKeyCreated2
3457
3534
  };
@@ -3476,6 +3553,17 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3476
3553
  );
3477
3554
  }
3478
3555
  await this.updateUserProtocols(strategy);
3556
+ if (!this.isPredeployed) {
3557
+ await deploySafeAccount({
3558
+ owner: walletClient,
3559
+ safeOwnerAddress: userAddress,
3560
+ chain: chainConfig.chain,
3561
+ publicClient: chainConfig.publicClient,
3562
+ chainId,
3563
+ httpClient: this.httpClient,
3564
+ strategy: internalStrategy
3565
+ });
3566
+ }
3479
3567
  let sessionKeyCreated = false;
3480
3568
  if (createSessionKey) {
3481
3569
  try {
@@ -8195,7 +8283,7 @@ import {
8195
8283
  encodeFunctionData as encodeFunctionData3,
8196
8284
  getAddress as getAddress5,
8197
8285
  hashMessage as hashMessage2,
8198
- hashTypedData,
8286
+ hashTypedData as hashTypedData2,
8199
8287
  hexToSignature,
8200
8288
  http as http3,
8201
8289
  isAddress as isAddress3,
@@ -8509,7 +8597,7 @@ function parseTypedDataPayload(params) {
8509
8597
  }
8510
8598
  function typedDataDigest(params) {
8511
8599
  const { domain, types, primaryType, message } = parseTypedDataPayload(params);
8512
- return hashTypedData({ domain, types, primaryType, message });
8600
+ return hashTypedData2({ domain, types, primaryType, message });
8513
8601
  }
8514
8602
  async function signAccountTypedData(account, params) {
8515
8603
  const { domain, types, primaryType, message } = parseTypedDataPayload(params);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "1.8.0",
3
+ "version": "1.8.3",
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",