@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 CHANGED
@@ -927,6 +927,43 @@ declare function executeWithdrawal(params: {
927
927
  account: Account;
928
928
  network?: SupportedNetwork;
929
929
  }): Promise<Hash>;
930
+ /**
931
+ * Withdraw all funds from settlement layer for a wallet.
932
+ *
933
+ * This function calls the wallet's withdrawAllFromSettlement function,
934
+ * which withdraws all available funds from the settlement layer for the given token.
935
+ * Can optionally send funds directly to the owner address.
936
+ *
937
+ * @param params - Transaction parameters
938
+ * @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
939
+ * @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
940
+ * @param params.tokenAddress - Token contract address to withdraw
941
+ * @param params.sendToOwner - If true, sends funds to owner; if false, keeps in wallet (default: true)
942
+ * @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
943
+ * @returns Transaction hash
944
+ *
945
+ * @example
946
+ * ```ts
947
+ * import { withdrawAllFromSettlement } from '@dcentralab/d402-client'
948
+ *
949
+ * const hash = await withdrawAllFromSettlement({
950
+ * walletClient,
951
+ * publicClient,
952
+ * tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // USDC
953
+ * network: 'sepolia'
954
+ * })
955
+ *
956
+ * console.log('Withdrawal transaction:', hash)
957
+ * ```
958
+ */
959
+ declare function withdrawAllFromSettlement(params: {
960
+ walletClient: WalletClient;
961
+ publicClient: PublicClient;
962
+ tokenAddress: Address;
963
+ walletAddress: Address;
964
+ sendToOwner?: boolean;
965
+ network?: SupportedNetwork;
966
+ }): Promise<Hash>;
930
967
 
931
968
  /**
932
969
  * MCP Session Management
@@ -1142,42 +1179,6 @@ declare function withdrawAllAvailableEpochs(params: {
1142
1179
  tokenAddress: Address;
1143
1180
  network?: SupportedNetwork;
1144
1181
  }): Promise<Hash>;
1145
- /**
1146
- * Withdraw all funds from settlement layer for a wallet.
1147
- *
1148
- * This function calls the wallet's withdrawAllFromSettlement function,
1149
- * which withdraws all available funds from the settlement layer for the given token.
1150
- * Can optionally send funds directly to the owner address.
1151
- *
1152
- * @param params - Transaction parameters
1153
- * @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
1154
- * @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
1155
- * @param params.tokenAddress - Token contract address to withdraw
1156
- * @param params.sendToOwner - If true, sends funds to owner; if false, keeps in wallet (default: true)
1157
- * @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
1158
- * @returns Transaction hash
1159
- *
1160
- * @example
1161
- * ```ts
1162
- * import { withdrawAllFromSettlement } from '@dcentralab/d402-client'
1163
- *
1164
- * const hash = await withdrawAllFromSettlement({
1165
- * walletClient,
1166
- * publicClient,
1167
- * tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // USDC
1168
- * network: 'sepolia'
1169
- * })
1170
- *
1171
- * console.log('Withdrawal transaction:', hash)
1172
- * ```
1173
- */
1174
- declare function withdrawAllFromSettlement(params: {
1175
- walletClient: WalletClient;
1176
- publicClient: PublicClient;
1177
- tokenAddress: Address;
1178
- sendToOwner?: boolean;
1179
- network?: SupportedNetwork;
1180
- }): Promise<Hash>;
1181
1182
 
1182
1183
  /**
1183
1184
  * Contract configuration and utilities.
package/dist/index.d.ts CHANGED
@@ -927,6 +927,43 @@ declare function executeWithdrawal(params: {
927
927
  account: Account;
928
928
  network?: SupportedNetwork;
929
929
  }): Promise<Hash>;
930
+ /**
931
+ * Withdraw all funds from settlement layer for a wallet.
932
+ *
933
+ * This function calls the wallet's withdrawAllFromSettlement function,
934
+ * which withdraws all available funds from the settlement layer for the given token.
935
+ * Can optionally send funds directly to the owner address.
936
+ *
937
+ * @param params - Transaction parameters
938
+ * @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
939
+ * @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
940
+ * @param params.tokenAddress - Token contract address to withdraw
941
+ * @param params.sendToOwner - If true, sends funds to owner; if false, keeps in wallet (default: true)
942
+ * @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
943
+ * @returns Transaction hash
944
+ *
945
+ * @example
946
+ * ```ts
947
+ * import { withdrawAllFromSettlement } from '@dcentralab/d402-client'
948
+ *
949
+ * const hash = await withdrawAllFromSettlement({
950
+ * walletClient,
951
+ * publicClient,
952
+ * tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // USDC
953
+ * network: 'sepolia'
954
+ * })
955
+ *
956
+ * console.log('Withdrawal transaction:', hash)
957
+ * ```
958
+ */
959
+ declare function withdrawAllFromSettlement(params: {
960
+ walletClient: WalletClient;
961
+ publicClient: PublicClient;
962
+ tokenAddress: Address;
963
+ walletAddress: Address;
964
+ sendToOwner?: boolean;
965
+ network?: SupportedNetwork;
966
+ }): Promise<Hash>;
930
967
 
931
968
  /**
932
969
  * MCP Session Management
@@ -1142,42 +1179,6 @@ declare function withdrawAllAvailableEpochs(params: {
1142
1179
  tokenAddress: Address;
1143
1180
  network?: SupportedNetwork;
1144
1181
  }): Promise<Hash>;
1145
- /**
1146
- * Withdraw all funds from settlement layer for a wallet.
1147
- *
1148
- * This function calls the wallet's withdrawAllFromSettlement function,
1149
- * which withdraws all available funds from the settlement layer for the given token.
1150
- * Can optionally send funds directly to the owner address.
1151
- *
1152
- * @param params - Transaction parameters
1153
- * @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
1154
- * @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
1155
- * @param params.tokenAddress - Token contract address to withdraw
1156
- * @param params.sendToOwner - If true, sends funds to owner; if false, keeps in wallet (default: true)
1157
- * @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
1158
- * @returns Transaction hash
1159
- *
1160
- * @example
1161
- * ```ts
1162
- * import { withdrawAllFromSettlement } from '@dcentralab/d402-client'
1163
- *
1164
- * const hash = await withdrawAllFromSettlement({
1165
- * walletClient,
1166
- * publicClient,
1167
- * tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // USDC
1168
- * network: 'sepolia'
1169
- * })
1170
- *
1171
- * console.log('Withdrawal transaction:', hash)
1172
- * ```
1173
- */
1174
- declare function withdrawAllFromSettlement(params: {
1175
- walletClient: WalletClient;
1176
- publicClient: PublicClient;
1177
- tokenAddress: Address;
1178
- sendToOwner?: boolean;
1179
- network?: SupportedNetwork;
1180
- }): Promise<Hash>;
1181
1182
 
1182
1183
  /**
1183
1184
  * Contract configuration and utilities.
package/dist/index.js CHANGED
@@ -10717,6 +10717,49 @@ async function executeWithdrawal(params) {
10717
10717
  await publicClient.waitForTransactionReceipt({ hash });
10718
10718
  return hash;
10719
10719
  }
10720
+ async function withdrawAllFromSettlement(params) {
10721
+ const {
10722
+ walletClient,
10723
+ publicClient,
10724
+ tokenAddress,
10725
+ walletAddress,
10726
+ sendToOwner = true,
10727
+ network = "sepolia"
10728
+ } = params;
10729
+ if (!walletClient?.account) {
10730
+ throw new Error("Wallet account not found. Please connect your wallet.");
10731
+ }
10732
+ const account = walletClient.account;
10733
+ const walletAbi = getContractAbi("IATPWallet" /* IATP_WALLET */, network);
10734
+ if (!walletAbi) {
10735
+ throw new Error(`IATPWallet ABI not found for network: ${network}`);
10736
+ }
10737
+ await publicClient.simulateContract({
10738
+ account,
10739
+ address: walletAddress,
10740
+ abi: walletAbi,
10741
+ functionName: "withdrawAllFromSettlement",
10742
+ args: [tokenAddress, sendToOwner]
10743
+ });
10744
+ const estimatedGas = await publicClient.estimateContractGas({
10745
+ address: walletAddress,
10746
+ abi: walletAbi,
10747
+ functionName: "withdrawAllFromSettlement",
10748
+ args: [tokenAddress, sendToOwner],
10749
+ account
10750
+ });
10751
+ const gasLimit = estimatedGas + estimatedGas / 5n;
10752
+ const hash = await walletClient.writeContract({
10753
+ address: walletAddress,
10754
+ abi: walletAbi,
10755
+ functionName: "withdrawAllFromSettlement",
10756
+ args: [tokenAddress, sendToOwner],
10757
+ account,
10758
+ gas: gasLimit
10759
+ });
10760
+ await publicClient.waitForTransactionReceipt({ hash });
10761
+ return hash;
10762
+ }
10720
10763
 
10721
10764
  // src/client/D402Client.ts
10722
10765
  var D402Client = class {
@@ -11051,42 +11094,6 @@ async function withdrawAllAvailableEpochs(params) {
11051
11094
  await publicClient.waitForTransactionReceipt({ hash });
11052
11095
  return hash;
11053
11096
  }
11054
- async function withdrawAllFromSettlement(params) {
11055
- const { walletClient, publicClient, tokenAddress, sendToOwner = true, network = "sepolia" } = params;
11056
- if (!walletClient?.account) {
11057
- throw new Error("Wallet account not found. Please connect your wallet.");
11058
- }
11059
- const account = walletClient.account;
11060
- const walletConfig = getContractConfig("IATPWallet" /* IATP_WALLET */, network);
11061
- if (!walletConfig) {
11062
- throw new Error(`IATPWallet contract not found for network: ${network}`);
11063
- }
11064
- await publicClient.simulateContract({
11065
- account,
11066
- address: walletConfig.address,
11067
- abi: walletConfig.abi,
11068
- functionName: "withdrawAllFromSettlement",
11069
- args: [tokenAddress, sendToOwner]
11070
- });
11071
- const estimatedGas = await publicClient.estimateContractGas({
11072
- address: walletConfig.address,
11073
- abi: walletConfig.abi,
11074
- functionName: "withdrawAllFromSettlement",
11075
- args: [tokenAddress, sendToOwner],
11076
- account
11077
- });
11078
- const gasLimit = estimatedGas + estimatedGas / 5n;
11079
- const hash = await walletClient.writeContract({
11080
- address: walletConfig.address,
11081
- abi: walletConfig.abi,
11082
- functionName: "withdrawAllFromSettlement",
11083
- args: [tokenAddress, sendToOwner],
11084
- account,
11085
- gas: gasLimit
11086
- });
11087
- await publicClient.waitForTransactionReceipt({ hash });
11088
- return hash;
11089
- }
11090
11097
 
11091
11098
  // src/index.ts
11092
11099
  init_utils();