btc-wallet 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,11 +9,12 @@ export declare function getAccountInfo(csna: string, accountContractId: string):
9
9
  gas_token: Record<string, string>;
10
10
  debt_info: DebtInfo;
11
11
  }>;
12
- export declare function checkGasTokenArrears(debtInfo: DebtInfo, isDev: boolean, autoDeposit?: boolean): Promise<{
12
+ type CheckGasTokenArrearsReturnType<T extends boolean> = T extends true ? void : {
13
13
  receiver_id: string;
14
14
  amount: string;
15
15
  msg: string;
16
- } | undefined>;
16
+ } | undefined;
17
+ export declare function checkGasTokenArrears<T extends boolean>(debtInfo: DebtInfo | undefined, isDev: boolean, autoDeposit?: T): Promise<CheckGasTokenArrearsReturnType<T>>;
17
18
  export declare function getBtcGasPrice(): Promise<number>;
18
19
  export declare function getBtcBalance(): Promise<{
19
20
  rawBalance: number;
package/dist/index.js CHANGED
@@ -3217,13 +3217,13 @@ function getAccountInfo(csna, accountContractId) {
3217
3217
  }
3218
3218
  function checkGasTokenArrears(debtInfo, isDev, autoDeposit) {
3219
3219
  return __async(this, null, function* () {
3220
+ if (!debtInfo)
3221
+ return;
3220
3222
  const config = yield getConfig(isDev);
3221
- const transferAmount = debtInfo.transfer_amount || "0";
3223
+ const transferAmount = debtInfo.transfer_amount;
3222
3224
  console.log("get_account debtInfo:", debtInfo);
3223
- if (transferAmount === "0")
3224
- return;
3225
3225
  const action = {
3226
- receiver_id: config.token,
3226
+ receiver_id: config.accountContractId,
3227
3227
  amount: transferAmount,
3228
3228
  msg: JSON.stringify("Deposit")
3229
3229
  };
@@ -3349,13 +3349,13 @@ function executeBTCDepositAndAction(_0) {
3349
3349
  if (new import_big.default(rawDepositAmount).lt(0)) {
3350
3350
  throw new Error("amount must be greater than 0");
3351
3351
  }
3352
- const { depositAmount } = yield getDepositAmount(rawDepositAmount, {
3352
+ const { depositAmount, receiveAmount } = yield getDepositAmount(rawDepositAmount, {
3353
3353
  isDev
3354
3354
  });
3355
3355
  const accountInfo = yield getAccountInfo(csna, config.accountContractId);
3356
3356
  const newActions = [];
3357
3357
  const gasLimit = new import_big.default(50).mul(__pow(10, 12)).toFixed(0);
3358
- const repayAction = yield checkGasTokenArrears(accountInfo.debt_info, isDev);
3358
+ const repayAction = yield checkGasTokenArrears(accountInfo.debt_info, isDev, false);
3359
3359
  if (repayAction) {
3360
3360
  newActions.push(__spreadProps(__spreadValues({}, repayAction), {
3361
3361
  gas: gasLimit
@@ -3363,7 +3363,7 @@ function executeBTCDepositAndAction(_0) {
3363
3363
  }
3364
3364
  if (action) {
3365
3365
  newActions.push(__spreadProps(__spreadValues({}, action), {
3366
- amount: (repayAction == null ? void 0 : repayAction.amount) && !fixedAmount ? new import_big.default(depositAmount).minus(repayAction.amount).toString() : depositAmount.toString(),
3366
+ amount: (repayAction == null ? void 0 : repayAction.amount) && !fixedAmount ? new import_big.default(receiveAmount).minus(repayAction.amount).toString() : receiveAmount.toString(),
3367
3367
  gas: gasLimit
3368
3368
  }));
3369
3369
  }
@@ -3883,7 +3883,7 @@ function setupBTCWallet({
3883
3883
 
3884
3884
  // src/index.ts
3885
3885
  var getVersion = () => {
3886
- return "0.3.13";
3886
+ return "0.3.14";
3887
3887
  };
3888
3888
  if (typeof window !== "undefined") {
3889
3889
  window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();