@cryptorubic/web3 1.1.0-alpha-stellar.37 → 1.1.0-alpha-stellar.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "1.1.0-alpha-stellar.37",
3
+ "version": "1.1.0-alpha-stellar.38",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -4,6 +4,8 @@ exports.StellarAdapterSigner = void 0;
4
4
  const core_1 = require("@cryptorubic/core");
5
5
  const abstract_adapter_signer_1 = require("../../common/signer/abstract-adapter-signer");
6
6
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
7
+ const bignumber_js_1 = require("bignumber.js");
8
+ const insufficient_funds_gas_price_value_error_1 = require("packages/web3/src/lib/errors/cross-chain/insufficient-funds-gas-price-value.error");
7
9
  class StellarAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
8
10
  get publicClient() {
9
11
  if (!this.publicRef.public) {
@@ -28,7 +30,14 @@ class StellarAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSign
28
30
  const transaction = typeof params.txOptions.transaction === 'string'
29
31
  ? stellar_sdk_1.TransactionBuilder.fromXDR(params.txOptions.transaction, stellar_sdk_1.Networks.PUBLIC)
30
32
  : params.txOptions.transaction;
31
- const preparedTransaction = await this.publicClient.prepareTransaction(transaction);
33
+ const [preparedTransaction, accountInfo] = await Promise.all([
34
+ this.publicClient.prepareTransaction(transaction),
35
+ this.publicClient.getAccountEntry(this.walletAddress)
36
+ ]);
37
+ const necessaryBalance = new bignumber_js_1.default(2 + accountInfo.numSubEntries()).multipliedBy(5000000).plus(preparedTransaction.fee);
38
+ if (necessaryBalance.gt(accountInfo.balance().toString())) {
39
+ throw new insufficient_funds_gas_price_value_error_1.InsufficientFundsGasPriceValueError();
40
+ }
32
41
  const { signedTxXdr } = await this.wallet.signTransaction(preparedTransaction.toXDR(), {
33
42
  networkPassphrase: stellar_sdk_1.Networks.PUBLIC,
34
43
  address: this.walletAddress