@dcentralab/d402-client 0.3.11 → 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 +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -1
- 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 {
|
|
@@ -11054,6 +11097,6 @@ async function withdrawAllAvailableEpochs(params) {
|
|
|
11054
11097
|
init_utils();
|
|
11055
11098
|
init_errors();
|
|
11056
11099
|
|
|
11057
|
-
export { ContractName, D402Client, Invalid402ResponseError, MissingRequestConfigError, PaymentAlreadyAttemptedError, PaymentAmountExceededError, PaymentError, PaymentVerificationError, UnsupportedNetworkError, UnsupportedSchemeError, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChain, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletEIP712Domain, getWalletInfo, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs };
|
|
11100
|
+
export { ContractName, D402Client, Invalid402ResponseError, MissingRequestConfigError, PaymentAlreadyAttemptedError, PaymentAmountExceededError, PaymentError, PaymentVerificationError, UnsupportedNetworkError, UnsupportedSchemeError, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChain, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletEIP712Domain, getWalletInfo, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs, withdrawAllFromSettlement };
|
|
11058
11101
|
//# sourceMappingURL=index.mjs.map
|
|
11059
11102
|
//# sourceMappingURL=index.mjs.map
|