@dcentralab/d402-client 0.3.12 → 0.3.13
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/dist/index.d.mts +37 -36
- package/dist/index.d.ts +37 -36
- package/dist/index.js +43 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10715,6 +10715,49 @@ async function executeWithdrawal(params) {
|
|
|
10715
10715
|
await publicClient.waitForTransactionReceipt({ hash });
|
|
10716
10716
|
return hash;
|
|
10717
10717
|
}
|
|
10718
|
+
async function withdrawAllFromSettlement(params) {
|
|
10719
|
+
const {
|
|
10720
|
+
walletClient,
|
|
10721
|
+
publicClient,
|
|
10722
|
+
tokenAddress,
|
|
10723
|
+
walletAddress,
|
|
10724
|
+
sendToOwner = true,
|
|
10725
|
+
network = "sepolia"
|
|
10726
|
+
} = params;
|
|
10727
|
+
if (!walletClient?.account) {
|
|
10728
|
+
throw new Error("Wallet account not found. Please connect your wallet.");
|
|
10729
|
+
}
|
|
10730
|
+
const account = walletClient.account;
|
|
10731
|
+
const walletAbi = getContractAbi("IATPWallet" /* IATP_WALLET */, network);
|
|
10732
|
+
if (!walletAbi) {
|
|
10733
|
+
throw new Error(`IATPWallet ABI not found for network: ${network}`);
|
|
10734
|
+
}
|
|
10735
|
+
await publicClient.simulateContract({
|
|
10736
|
+
account,
|
|
10737
|
+
address: walletAddress,
|
|
10738
|
+
abi: walletAbi,
|
|
10739
|
+
functionName: "withdrawAllFromSettlement",
|
|
10740
|
+
args: [tokenAddress, sendToOwner]
|
|
10741
|
+
});
|
|
10742
|
+
const estimatedGas = await publicClient.estimateContractGas({
|
|
10743
|
+
address: walletAddress,
|
|
10744
|
+
abi: walletAbi,
|
|
10745
|
+
functionName: "withdrawAllFromSettlement",
|
|
10746
|
+
args: [tokenAddress, sendToOwner],
|
|
10747
|
+
account
|
|
10748
|
+
});
|
|
10749
|
+
const gasLimit = estimatedGas + estimatedGas / 5n;
|
|
10750
|
+
const hash = await walletClient.writeContract({
|
|
10751
|
+
address: walletAddress,
|
|
10752
|
+
abi: walletAbi,
|
|
10753
|
+
functionName: "withdrawAllFromSettlement",
|
|
10754
|
+
args: [tokenAddress, sendToOwner],
|
|
10755
|
+
account,
|
|
10756
|
+
gas: gasLimit
|
|
10757
|
+
});
|
|
10758
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
10759
|
+
return hash;
|
|
10760
|
+
}
|
|
10718
10761
|
|
|
10719
10762
|
// src/client/D402Client.ts
|
|
10720
10763
|
var D402Client = class {
|
|
@@ -11049,42 +11092,6 @@ async function withdrawAllAvailableEpochs(params) {
|
|
|
11049
11092
|
await publicClient.waitForTransactionReceipt({ hash });
|
|
11050
11093
|
return hash;
|
|
11051
11094
|
}
|
|
11052
|
-
async function withdrawAllFromSettlement(params) {
|
|
11053
|
-
const { walletClient, publicClient, tokenAddress, sendToOwner = true, network = "sepolia" } = params;
|
|
11054
|
-
if (!walletClient?.account) {
|
|
11055
|
-
throw new Error("Wallet account not found. Please connect your wallet.");
|
|
11056
|
-
}
|
|
11057
|
-
const account = walletClient.account;
|
|
11058
|
-
const walletConfig = getContractConfig("IATPWallet" /* IATP_WALLET */, network);
|
|
11059
|
-
if (!walletConfig) {
|
|
11060
|
-
throw new Error(`IATPWallet contract not found for network: ${network}`);
|
|
11061
|
-
}
|
|
11062
|
-
await publicClient.simulateContract({
|
|
11063
|
-
account,
|
|
11064
|
-
address: walletConfig.address,
|
|
11065
|
-
abi: walletConfig.abi,
|
|
11066
|
-
functionName: "withdrawAllFromSettlement",
|
|
11067
|
-
args: [tokenAddress, sendToOwner]
|
|
11068
|
-
});
|
|
11069
|
-
const estimatedGas = await publicClient.estimateContractGas({
|
|
11070
|
-
address: walletConfig.address,
|
|
11071
|
-
abi: walletConfig.abi,
|
|
11072
|
-
functionName: "withdrawAllFromSettlement",
|
|
11073
|
-
args: [tokenAddress, sendToOwner],
|
|
11074
|
-
account
|
|
11075
|
-
});
|
|
11076
|
-
const gasLimit = estimatedGas + estimatedGas / 5n;
|
|
11077
|
-
const hash = await walletClient.writeContract({
|
|
11078
|
-
address: walletConfig.address,
|
|
11079
|
-
abi: walletConfig.abi,
|
|
11080
|
-
functionName: "withdrawAllFromSettlement",
|
|
11081
|
-
args: [tokenAddress, sendToOwner],
|
|
11082
|
-
account,
|
|
11083
|
-
gas: gasLimit
|
|
11084
|
-
});
|
|
11085
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
11086
|
-
return hash;
|
|
11087
|
-
}
|
|
11088
11095
|
|
|
11089
11096
|
// src/index.ts
|
|
11090
11097
|
init_utils();
|