@vechain/vechain-kit 2.0.0-rc.6 → 2.0.0-rc.8

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.cts CHANGED
@@ -2083,6 +2083,8 @@ declare const getAllEventLogs: ({ nodeUrl, thor, order, from, to, filterCriteria
2083
2083
  * @param onTxConfirmed callback to run when the tx is confirmed
2084
2084
  * @param onTxFailedOrCancelled callback to run when the tx fails or is cancelled
2085
2085
  * @param suggestedMaxGas the suggested max gas for the transaction
2086
+ * @param privyUIOptions options to pass to the Privy UI
2087
+ * @param gasPadding the gas padding to use for the transaction (Eg. 0.1 for 10%)
2086
2088
  */
2087
2089
  type UseSendTransactionProps = {
2088
2090
  signerAccountAddress?: string | null;
@@ -2095,6 +2097,7 @@ type UseSendTransactionProps = {
2095
2097
  description?: string;
2096
2098
  buttonText?: string;
2097
2099
  };
2100
+ gasPadding?: number;
2098
2101
  };
2099
2102
  /**
2100
2103
  * Return value of the {@link useSendTransaction} hook
@@ -2146,9 +2149,10 @@ type UseSendTransactionReturnValue = {
2146
2149
  * @param onTxFailedOrCancelled callback to run when the tx fails or is cancelled
2147
2150
  * @param suggestedMaxGas the suggested max gas for the transaction
2148
2151
  * @param privyUIOptions options to pass to the Privy UI
2152
+ * @param gasPadding the gas padding to use for the transaction (Eg. 0.1 for 10%)
2149
2153
  * @returns see {@link UseSendTransactionReturnValue}
2150
2154
  */
2151
- declare const useSendTransaction: ({ signerAccountAddress, clauses, onTxConfirmed, onTxFailedOrCancelled, suggestedMaxGas, privyUIOptions, }: UseSendTransactionProps) => UseSendTransactionReturnValue;
2155
+ declare const useSendTransaction: ({ signerAccountAddress, clauses, onTxConfirmed, onTxFailedOrCancelled, suggestedMaxGas, privyUIOptions, gasPadding, }: UseSendTransactionProps) => UseSendTransactionReturnValue;
2152
2156
 
2153
2157
  type useTransferERC20Props = {
2154
2158
  fromAddress: string;
@@ -2183,6 +2187,7 @@ type BuildTransactionProps<ClausesParams> = {
2183
2187
  onSuccess?: () => void;
2184
2188
  invalidateCache?: boolean;
2185
2189
  suggestedMaxGas?: number;
2190
+ gasPadding?: number;
2186
2191
  onFailure?: () => void;
2187
2192
  };
2188
2193
  /**
@@ -2193,9 +2198,10 @@ type BuildTransactionProps<ClausesParams> = {
2193
2198
  * @param onSuccess - An optional callback function to be called after the transaction is successfully sent.
2194
2199
  * @param onFailure - An optional callback function to be called after the transaction is failed or cancelled.
2195
2200
  * @param suggestedMaxGas - The suggested maximum gas for the transaction.
2201
+ * @param gasPadding - The padding to add to the suggested maximum gas.
2196
2202
  * @returns An object containing the result of the `useSendTransaction` hook and a `sendTransaction` function.
2197
2203
  */
2198
- declare const useBuildTransaction: <ClausesParams>({ clauseBuilder, refetchQueryKeys, invalidateCache, onSuccess, onFailure, suggestedMaxGas, }: BuildTransactionProps<ClausesParams>) => {
2204
+ declare const useBuildTransaction: <ClausesParams>({ clauseBuilder, refetchQueryKeys, invalidateCache, onSuccess, onFailure, suggestedMaxGas, gasPadding, }: BuildTransactionProps<ClausesParams>) => {
2199
2205
  sendTransaction: (props: ClausesParams) => Promise<void>;
2200
2206
  isTransactionPending: boolean;
2201
2207
  isWaitingForWalletConfirmation: boolean;
package/dist/index.d.ts CHANGED
@@ -2083,6 +2083,8 @@ declare const getAllEventLogs: ({ nodeUrl, thor, order, from, to, filterCriteria
2083
2083
  * @param onTxConfirmed callback to run when the tx is confirmed
2084
2084
  * @param onTxFailedOrCancelled callback to run when the tx fails or is cancelled
2085
2085
  * @param suggestedMaxGas the suggested max gas for the transaction
2086
+ * @param privyUIOptions options to pass to the Privy UI
2087
+ * @param gasPadding the gas padding to use for the transaction (Eg. 0.1 for 10%)
2086
2088
  */
2087
2089
  type UseSendTransactionProps = {
2088
2090
  signerAccountAddress?: string | null;
@@ -2095,6 +2097,7 @@ type UseSendTransactionProps = {
2095
2097
  description?: string;
2096
2098
  buttonText?: string;
2097
2099
  };
2100
+ gasPadding?: number;
2098
2101
  };
2099
2102
  /**
2100
2103
  * Return value of the {@link useSendTransaction} hook
@@ -2146,9 +2149,10 @@ type UseSendTransactionReturnValue = {
2146
2149
  * @param onTxFailedOrCancelled callback to run when the tx fails or is cancelled
2147
2150
  * @param suggestedMaxGas the suggested max gas for the transaction
2148
2151
  * @param privyUIOptions options to pass to the Privy UI
2152
+ * @param gasPadding the gas padding to use for the transaction (Eg. 0.1 for 10%)
2149
2153
  * @returns see {@link UseSendTransactionReturnValue}
2150
2154
  */
2151
- declare const useSendTransaction: ({ signerAccountAddress, clauses, onTxConfirmed, onTxFailedOrCancelled, suggestedMaxGas, privyUIOptions, }: UseSendTransactionProps) => UseSendTransactionReturnValue;
2155
+ declare const useSendTransaction: ({ signerAccountAddress, clauses, onTxConfirmed, onTxFailedOrCancelled, suggestedMaxGas, privyUIOptions, gasPadding, }: UseSendTransactionProps) => UseSendTransactionReturnValue;
2152
2156
 
2153
2157
  type useTransferERC20Props = {
2154
2158
  fromAddress: string;
@@ -2183,6 +2187,7 @@ type BuildTransactionProps<ClausesParams> = {
2183
2187
  onSuccess?: () => void;
2184
2188
  invalidateCache?: boolean;
2185
2189
  suggestedMaxGas?: number;
2190
+ gasPadding?: number;
2186
2191
  onFailure?: () => void;
2187
2192
  };
2188
2193
  /**
@@ -2193,9 +2198,10 @@ type BuildTransactionProps<ClausesParams> = {
2193
2198
  * @param onSuccess - An optional callback function to be called after the transaction is successfully sent.
2194
2199
  * @param onFailure - An optional callback function to be called after the transaction is failed or cancelled.
2195
2200
  * @param suggestedMaxGas - The suggested maximum gas for the transaction.
2201
+ * @param gasPadding - The padding to add to the suggested maximum gas.
2196
2202
  * @returns An object containing the result of the `useSendTransaction` hook and a `sendTransaction` function.
2197
2203
  */
2198
- declare const useBuildTransaction: <ClausesParams>({ clauseBuilder, refetchQueryKeys, invalidateCache, onSuccess, onFailure, suggestedMaxGas, }: BuildTransactionProps<ClausesParams>) => {
2204
+ declare const useBuildTransaction: <ClausesParams>({ clauseBuilder, refetchQueryKeys, invalidateCache, onSuccess, onFailure, suggestedMaxGas, gasPadding, }: BuildTransactionProps<ClausesParams>) => {
2199
2205
  sendTransaction: (props: ClausesParams) => Promise<void>;
2200
2206
  isTransactionPending: boolean;
2201
2207
  isWaitingForWalletConfirmation: boolean;
package/dist/index.js CHANGED
@@ -4818,7 +4818,7 @@ var AddressDisplay = ({
4818
4818
 
4819
4819
  // package.json
4820
4820
  var package_default = {
4821
- version: "2.0.0-rc.6"};
4821
+ version: "2.0.0-rc.8"};
4822
4822
  var VersionFooter = ({ ...props }) => {
4823
4823
  const { darkMode: isDark } = useVeChainKitConfig();
4824
4824
  return /* @__PURE__ */ jsxs(
@@ -17848,10 +17848,18 @@ var getAllEventLogs = async ({
17848
17848
  };
17849
17849
 
17850
17850
  // src/hooks/thor/transactions/transactionUtils.ts
17851
- var estimateTxGas = async (thor, clauses, caller) => {
17852
- const response = await thor.transactions.estimateGas(clauses, caller);
17851
+ var estimateTxGas = async (thor, clauses, caller, options) => {
17852
+ const response = await thor.transactions.estimateGas(
17853
+ clauses,
17854
+ caller,
17855
+ options
17856
+ );
17853
17857
  if (response.reverted) throw new Error("Failed to estimate gas");
17854
- return response.totalGas;
17858
+ let totalGas = response?.totalGas ?? 0;
17859
+ if (!totalGas || Number.isNaN(totalGas)) {
17860
+ totalGas = 0;
17861
+ }
17862
+ return Math.ceil(totalGas);
17855
17863
  };
17856
17864
  var useSendTransaction = ({
17857
17865
  signerAccountAddress,
@@ -17859,7 +17867,8 @@ var useSendTransaction = ({
17859
17867
  onTxConfirmed,
17860
17868
  onTxFailedOrCancelled,
17861
17869
  suggestedMaxGas,
17862
- privyUIOptions
17870
+ privyUIOptions,
17871
+ gasPadding
17863
17872
  }) => {
17864
17873
  const thor = useThor();
17865
17874
  const { signer } = useWallet$1();
@@ -17886,7 +17895,12 @@ var useSendTransaction = ({
17886
17895
  estimatedGas = await estimateTxGas(
17887
17896
  thor,
17888
17897
  [..._clauses],
17889
- signerAccountAddress
17898
+ signerAccountAddress,
17899
+ {
17900
+ revision: "next",
17901
+ ...gasPadding ? { gasPadding } : {}
17902
+ //If gasPadding is provided, use it, otherwise it will apply only revision
17903
+ }
17890
17904
  );
17891
17905
  } catch (e) {
17892
17906
  console.error("Gas estimation failed", e);
@@ -18149,7 +18163,8 @@ var useBuildTransaction = ({
18149
18163
  invalidateCache = true,
18150
18164
  onSuccess,
18151
18165
  onFailure,
18152
- suggestedMaxGas
18166
+ suggestedMaxGas,
18167
+ gasPadding
18153
18168
  }) => {
18154
18169
  const { account } = useWallet();
18155
18170
  const queryClient = useQueryClient();
@@ -18170,7 +18185,8 @@ var useBuildTransaction = ({
18170
18185
  signerAccountAddress: account?.address,
18171
18186
  onTxConfirmed: handleOnSuccess,
18172
18187
  suggestedMaxGas,
18173
- onTxFailedOrCancelled: onFailure
18188
+ onTxFailedOrCancelled: onFailure,
18189
+ gasPadding
18174
18190
  });
18175
18191
  const sendTransaction = useCallback(
18176
18192
  async (props) => {