@dcentralab/d402-client 0.3.3 → 0.3.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/LICENSE +22 -0
- package/dist/index.d.mts +31 -15
- package/dist/index.d.ts +31 -15
- package/dist/index.js +27 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -5107,13 +5107,13 @@ async function createIATPWallet(params) {
|
|
|
5107
5107
|
}
|
|
5108
5108
|
async function getAvailableBalance(params) {
|
|
5109
5109
|
const { publicClient, walletAddress, tokenAddress, network = "sepolia" } = params;
|
|
5110
|
-
const
|
|
5111
|
-
if (!
|
|
5112
|
-
throw new Error(`IATPWallet
|
|
5110
|
+
const walletAbi = getContractAbi("IATPWallet" /* IATP_WALLET */, network);
|
|
5111
|
+
if (!walletAbi) {
|
|
5112
|
+
throw new Error(`IATPWallet ABI not found for network: ${network}`);
|
|
5113
5113
|
}
|
|
5114
5114
|
const balance = await publicClient.readContract({
|
|
5115
5115
|
address: walletAddress,
|
|
5116
|
-
abi:
|
|
5116
|
+
abi: walletAbi,
|
|
5117
5117
|
functionName: "getAvailableBalance",
|
|
5118
5118
|
args: [tokenAddress]
|
|
5119
5119
|
});
|
|
@@ -5143,37 +5143,41 @@ async function getWalletsByOwner(params) {
|
|
|
5143
5143
|
// src/wallet/withdrawals.ts
|
|
5144
5144
|
async function getWithdrawalRequest(params) {
|
|
5145
5145
|
const { publicClient, walletAddress, tokenAddress, network = "sepolia" } = params;
|
|
5146
|
-
const
|
|
5147
|
-
if (!
|
|
5148
|
-
throw new Error(`IATPWallet
|
|
5146
|
+
const walletAbi = getContractAbi("IATPWallet" /* IATP_WALLET */, network);
|
|
5147
|
+
if (!walletAbi) {
|
|
5148
|
+
throw new Error(`IATPWallet ABI not found for network: ${network}`);
|
|
5149
5149
|
}
|
|
5150
5150
|
const result = await publicClient.readContract({
|
|
5151
5151
|
address: walletAddress,
|
|
5152
|
-
abi:
|
|
5152
|
+
abi: walletAbi,
|
|
5153
5153
|
functionName: "getWithdrawalRequest",
|
|
5154
5154
|
args: [tokenAddress]
|
|
5155
5155
|
});
|
|
5156
|
-
|
|
5156
|
+
const [request, unlockTime] = result;
|
|
5157
|
+
if (request.amount === 0n) {
|
|
5157
5158
|
return null;
|
|
5158
5159
|
}
|
|
5159
|
-
return
|
|
5160
|
+
return {
|
|
5161
|
+
request,
|
|
5162
|
+
unlockTime
|
|
5163
|
+
};
|
|
5160
5164
|
}
|
|
5161
5165
|
async function requestWithdrawal(params) {
|
|
5162
5166
|
const { walletClient, publicClient, walletAddress, tokenAddress, amount, account, network = "sepolia" } = params;
|
|
5163
|
-
const
|
|
5164
|
-
if (!
|
|
5165
|
-
throw new Error(`IATPWallet
|
|
5167
|
+
const walletAbi = getContractAbi("IATPWallet" /* IATP_WALLET */, network);
|
|
5168
|
+
if (!walletAbi) {
|
|
5169
|
+
throw new Error(`IATPWallet ABI not found for network: ${network}`);
|
|
5166
5170
|
}
|
|
5167
5171
|
await publicClient.simulateContract({
|
|
5168
5172
|
account,
|
|
5169
5173
|
address: walletAddress,
|
|
5170
|
-
abi:
|
|
5174
|
+
abi: walletAbi,
|
|
5171
5175
|
functionName: "requestWithdrawal",
|
|
5172
5176
|
args: [tokenAddress, amount]
|
|
5173
5177
|
});
|
|
5174
5178
|
const estimatedGas = await publicClient.estimateContractGas({
|
|
5175
5179
|
address: walletAddress,
|
|
5176
|
-
abi:
|
|
5180
|
+
abi: walletAbi,
|
|
5177
5181
|
functionName: "requestWithdrawal",
|
|
5178
5182
|
args: [tokenAddress, amount],
|
|
5179
5183
|
account
|
|
@@ -5181,7 +5185,7 @@ async function requestWithdrawal(params) {
|
|
|
5181
5185
|
const gasLimit = estimatedGas + estimatedGas / 5n;
|
|
5182
5186
|
const hash = await walletClient.writeContract({
|
|
5183
5187
|
address: walletAddress,
|
|
5184
|
-
abi:
|
|
5188
|
+
abi: walletAbi,
|
|
5185
5189
|
functionName: "requestWithdrawal",
|
|
5186
5190
|
args: [tokenAddress, amount],
|
|
5187
5191
|
account,
|
|
@@ -5192,20 +5196,20 @@ async function requestWithdrawal(params) {
|
|
|
5192
5196
|
}
|
|
5193
5197
|
async function executeWithdrawal(params) {
|
|
5194
5198
|
const { walletClient, publicClient, walletAddress, tokenAddress, account, network = "sepolia" } = params;
|
|
5195
|
-
const
|
|
5196
|
-
if (!
|
|
5197
|
-
throw new Error(`IATPWallet
|
|
5199
|
+
const walletAbi = getContractAbi("IATPWallet" /* IATP_WALLET */, network);
|
|
5200
|
+
if (!walletAbi) {
|
|
5201
|
+
throw new Error(`IATPWallet ABI not found for network: ${network}`);
|
|
5198
5202
|
}
|
|
5199
5203
|
await publicClient.simulateContract({
|
|
5200
5204
|
account,
|
|
5201
5205
|
address: walletAddress,
|
|
5202
|
-
abi:
|
|
5206
|
+
abi: walletAbi,
|
|
5203
5207
|
functionName: "executeWithdrawal",
|
|
5204
5208
|
args: [tokenAddress]
|
|
5205
5209
|
});
|
|
5206
5210
|
const estimatedGas = await publicClient.estimateContractGas({
|
|
5207
5211
|
address: walletAddress,
|
|
5208
|
-
abi:
|
|
5212
|
+
abi: walletAbi,
|
|
5209
5213
|
functionName: "executeWithdrawal",
|
|
5210
5214
|
args: [tokenAddress],
|
|
5211
5215
|
account
|
|
@@ -5213,7 +5217,7 @@ async function executeWithdrawal(params) {
|
|
|
5213
5217
|
const gasLimit = estimatedGas + estimatedGas / 5n;
|
|
5214
5218
|
const hash = await walletClient.writeContract({
|
|
5215
5219
|
address: walletAddress,
|
|
5216
|
-
abi:
|
|
5220
|
+
abi: walletAbi,
|
|
5217
5221
|
functionName: "executeWithdrawal",
|
|
5218
5222
|
args: [tokenAddress],
|
|
5219
5223
|
account,
|
|
@@ -5306,7 +5310,7 @@ var D402Client = class {
|
|
|
5306
5310
|
*
|
|
5307
5311
|
* @param publicClient - Viem PublicClient
|
|
5308
5312
|
* @param tokenAddress - Token contract address
|
|
5309
|
-
* @returns Withdrawal request
|
|
5313
|
+
* @returns Withdrawal request details (request + unlockTime) or null if no request exists
|
|
5310
5314
|
*/
|
|
5311
5315
|
async getWithdrawalRequest(publicClient, tokenAddress) {
|
|
5312
5316
|
return getWithdrawalRequest({
|