@zyfai/sdk 0.1.3 → 0.1.4
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 +9 -2
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,16 +100,23 @@ const walletInfo = await sdk.getSmartWalletAddress(userAddress, 42161);
|
|
|
100
100
|
console.log("Safe Address:", walletInfo.address);
|
|
101
101
|
console.log("Is Deployed:", walletInfo.isDeployed);
|
|
102
102
|
|
|
103
|
-
// Deploy the Safe
|
|
103
|
+
// Deploy the Safe (automatically checks if already deployed)
|
|
104
104
|
const result = await sdk.deploySafe(userAddress, 42161);
|
|
105
105
|
|
|
106
106
|
if (result.success) {
|
|
107
107
|
console.log("Safe Address:", result.safeAddress);
|
|
108
108
|
console.log("Status:", result.status); // 'deployed' | 'failed'
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
if (result.alreadyDeployed) {
|
|
111
|
+
console.log("Safe was already deployed - no action needed");
|
|
112
|
+
} else {
|
|
113
|
+
console.log("Transaction Hash:", result.txHash);
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
116
|
```
|
|
112
117
|
|
|
118
|
+
**Note:** The SDK proactively checks if the Safe is already deployed before attempting deployment. If it exists, it returns `alreadyDeployed: true` without making any transactions.
|
|
119
|
+
|
|
113
120
|
### 2. Multi-Chain Support
|
|
114
121
|
|
|
115
122
|
The SDK supports the following chains:
|
package/dist/index.d.mts
CHANGED
|
@@ -21,6 +21,8 @@ interface DeploySafeResponse {
|
|
|
21
21
|
safeAddress: Address;
|
|
22
22
|
txHash: string;
|
|
23
23
|
status: "deployed" | "failed";
|
|
24
|
+
/** True if the Safe was already deployed (no new deployment needed) */
|
|
25
|
+
alreadyDeployed?: boolean;
|
|
24
26
|
}
|
|
25
27
|
/** @internal */
|
|
26
28
|
interface UpdateUserProfileRequest {
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ interface DeploySafeResponse {
|
|
|
21
21
|
safeAddress: Address;
|
|
22
22
|
txHash: string;
|
|
23
23
|
status: "deployed" | "failed";
|
|
24
|
+
/** True if the Safe was already deployed (no new deployment needed) */
|
|
25
|
+
alreadyDeployed?: boolean;
|
|
24
26
|
}
|
|
25
27
|
/** @internal */
|
|
26
28
|
interface UpdateUserProfileRequest {
|
package/dist/index.js
CHANGED
|
@@ -875,6 +875,26 @@ var ZyfaiSDK = class {
|
|
|
875
875
|
}
|
|
876
876
|
const walletClient = this.getWalletClient(chainId);
|
|
877
877
|
const chainConfig = getChainConfig(chainId);
|
|
878
|
+
const safeAddress = await getDeterministicSafeAddress({
|
|
879
|
+
owner: walletClient,
|
|
880
|
+
safeOwnerAddress: userAddress,
|
|
881
|
+
chain: chainConfig.chain,
|
|
882
|
+
publicClient: chainConfig.publicClient,
|
|
883
|
+
environment: this.environment
|
|
884
|
+
});
|
|
885
|
+
const alreadyDeployed = await isSafeDeployed(
|
|
886
|
+
safeAddress,
|
|
887
|
+
chainConfig.publicClient
|
|
888
|
+
);
|
|
889
|
+
if (alreadyDeployed) {
|
|
890
|
+
return {
|
|
891
|
+
success: true,
|
|
892
|
+
safeAddress,
|
|
893
|
+
txHash: "0x0",
|
|
894
|
+
status: "deployed",
|
|
895
|
+
alreadyDeployed: true
|
|
896
|
+
};
|
|
897
|
+
}
|
|
878
898
|
const accountType = await getAccountType(
|
|
879
899
|
userAddress,
|
|
880
900
|
chainConfig.publicClient
|
package/dist/index.mjs
CHANGED
|
@@ -854,6 +854,26 @@ var ZyfaiSDK = class {
|
|
|
854
854
|
}
|
|
855
855
|
const walletClient = this.getWalletClient(chainId);
|
|
856
856
|
const chainConfig = getChainConfig(chainId);
|
|
857
|
+
const safeAddress = await getDeterministicSafeAddress({
|
|
858
|
+
owner: walletClient,
|
|
859
|
+
safeOwnerAddress: userAddress,
|
|
860
|
+
chain: chainConfig.chain,
|
|
861
|
+
publicClient: chainConfig.publicClient,
|
|
862
|
+
environment: this.environment
|
|
863
|
+
});
|
|
864
|
+
const alreadyDeployed = await isSafeDeployed(
|
|
865
|
+
safeAddress,
|
|
866
|
+
chainConfig.publicClient
|
|
867
|
+
);
|
|
868
|
+
if (alreadyDeployed) {
|
|
869
|
+
return {
|
|
870
|
+
success: true,
|
|
871
|
+
safeAddress,
|
|
872
|
+
txHash: "0x0",
|
|
873
|
+
status: "deployed",
|
|
874
|
+
alreadyDeployed: true
|
|
875
|
+
};
|
|
876
|
+
}
|
|
857
877
|
const accountType = await getAccountType(
|
|
858
878
|
userAddress,
|
|
859
879
|
chainConfig.publicClient
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "TypeScript SDK for ZyFAI Yield Optimization Engine - Deploy Safe smart wallets, manage session keys, and interact with DeFi protocols",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|