@cryptorubic/web3 1.1.0-alpha-stellar.30 → 1.1.0-alpha-stellar.32

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.30",
3
+ "version": "1.1.0-alpha-stellar.32",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -1,7 +1,7 @@
1
1
  import { BlockchainName, HttpClient, ICustomLogger } from '@cryptorubic/core';
2
+ import { Abi, PublicActions, PublicClient, TransactionReceipt, WalletActions, WalletClient } from 'viem';
2
3
  import { ClientAdaptersFactoryParams } from '../../../models/create-factory-params';
3
4
  import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-signer';
4
- import { Abi, PublicActions, PublicClient, TransactionReceipt, WalletActions, WalletClient } from 'viem';
5
5
  import { EvmSendTxParams, EvmTransactionOptions } from '../models/evm-send-tx-params';
6
6
  import { Web3Error } from '../utils/parse-evm-error';
7
7
  export declare class EvmAdapterSigner extends AbstractAdapterSigner<WalletClient & WalletActions, EvmSendTxParams, TransactionReceipt> {
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EvmAdapterSigner = void 0;
4
4
  const core_1 = require("@cryptorubic/core");
5
- const abstract_adapter_signer_1 = require("../../common/signer/abstract-adapter-signer");
5
+ const bignumber_js_1 = require("bignumber.js");
6
6
  const viem_1 = require("viem");
7
7
  const actions_1 = require("viem/actions");
8
- const options_1 = require("../../utils/options");
8
+ const tx_reverted_in_chain_error_1 = require("../../../../errors/common/tx-reverted-in-chain.error");
9
+ const rubic_sdk_error_1 = require("../../../../errors/rubic-sdk.error");
9
10
  const viem_blockchain_mapping_1 = require("../../../constants/viem-blockchain-mapping");
11
+ const abstract_adapter_signer_1 = require("../../common/signer/abstract-adapter-signer");
12
+ const options_1 = require("../../utils/options");
10
13
  const parse_evm_error_1 = require("../utils/parse-evm-error");
11
- const rubic_sdk_error_1 = require("../../../../errors/rubic-sdk.error");
12
- const tx_reverted_in_chain_error_1 = require("../../../../errors/common/tx-reverted-in-chain.error");
13
- const bignumber_js_1 = require("bignumber.js");
14
14
  class EvmAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
15
15
  get publicClient() {
16
16
  if (!this.publicRef.public) {
@@ -73,8 +73,8 @@ class EvmAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
73
73
  value,
74
74
  ...(params.txOptions.data && { data: params.txOptions.data })
75
75
  };
76
- const gas = await this.publicClient.estimateGas(gaslessParams);
77
- const calculatedGas = params.txOptions.gasLimitRatio
76
+ const gas = params.txOptions.gas ? BigInt(params.txOptions.gas) : await this.publicClient.estimateGas(gaslessParams);
77
+ const calculatedGas = !params.txOptions.gas && params.txOptions.gasLimitRatio
78
78
  ? BigInt(new bignumber_js_1.default(gas.toString()).multipliedBy(params.txOptions.gasLimitRatio).toFixed(0))
79
79
  : gas;
80
80
  const gasfulParams = {
@@ -0,0 +1,4 @@
1
+ export interface StellarRpcProvider {
2
+ horizon: string;
3
+ soroban: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,10 +11,12 @@ import { Abi } from 'viem';
11
11
  import { MethodData } from '../models/web3-public-models/method-data';
12
12
  import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
13
13
  import { StellarTransactionConfig } from '../../../utils/models/stellar-transaction-config';
14
+ import { StellarRpcProvider } from './models/stellar-rpc-provider';
14
15
  export declare class StellarAdapter extends AbstractAdapter<StellarClient, StellarWallet, StellarBlockchainName> {
15
- private readonly rpcList;
16
+ private readonly rpc;
16
17
  readonly signer: StellarAdapterSigner;
17
- constructor(rpcList: string[], httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
18
+ private readonly horizonClient;
19
+ constructor(rpc: StellarRpcProvider[], httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
18
20
  initWeb3Client(): void;
19
21
  getBlockNumber(): Promise<number | {
20
22
  blockNumber: number;
@@ -11,13 +11,14 @@ const bignumber_js_1 = require("bignumber.js");
11
11
  const web3_pure_1 = require("../../../utils/web3-pure");
12
12
  const fake_stellar_wallet_1 = require("./constants/fake-stellar-wallet");
13
13
  class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
14
- constructor(rpcList, httpClient, logger, clientParams) {
14
+ constructor(rpc, httpClient, logger, clientParams) {
15
15
  super(core_1.BLOCKCHAIN_NAME.STELLAR, logger);
16
- this.rpcList = rpcList;
16
+ this.rpc = rpc;
17
17
  this.signer = new stellar_adapter_signer_1.StellarAdapterSigner(this.publicRef, httpClient, logger, clientParams);
18
+ this.horizonClient = new stellar_sdk_1.Horizon.Server(rpc[0].horizon);
18
19
  }
19
20
  initWeb3Client() {
20
- this.public = new stellar_sdk_2.rpc.Server(this.rpcList[0], {
21
+ this.public = new stellar_sdk_2.rpc.Server(this.rpc[0].soroban, {
21
22
  allowHttp: true,
22
23
  timeout: 5000
23
24
  });
@@ -27,6 +28,13 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
27
28
  return sequence;
28
29
  }
29
30
  async getTokensBalances(userAddress, tokensAddresses) {
31
+ try {
32
+ const resp = await this.horizonClient.loadAccount(userAddress);
33
+ console.log(resp.balances);
34
+ }
35
+ catch (err) {
36
+ console.error(err);
37
+ }
30
38
  return Promise.all(tokensAddresses.map((address) => this.getBalance(userAddress, address)));
31
39
  }
32
40
  async getBalance(userAddress, tokenAddress) {
@@ -84,7 +92,6 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
84
92
  return new bignumber_js_1.default(trustline.limit().toString()).lt(token.weiAmount);
85
93
  }
86
94
  catch (err) {
87
- console.error(err);
88
95
  return true;
89
96
  }
90
97
  }
@@ -3,7 +3,8 @@ import { EnvType } from '../constants/models/env-type';
3
3
  import { TronWebProvider } from '../adapters/adapter-tron/models/tron-web-provider';
4
4
  import { TonAdapterConfig } from '../adapters/models/ton-adapter-config';
5
5
  import { FallbackTransportConfig, HttpTransportConfig } from 'viem';
6
- export type RpcListType = Record<EvmBlockchainName, string[]> & Record<TronBlockchainName, TronWebProvider[]> & Record<SolanaBlockchainName, string[]> & Record<SuiBlockchainName, string[]> & Record<StellarBlockchainName, string[]>;
6
+ import { StellarRpcProvider } from '../adapters/adapter-stellar/models/stellar-rpc-provider';
7
+ export type RpcListType = Record<EvmBlockchainName, string[]> & Record<TronBlockchainName, TronWebProvider[]> & Record<SolanaBlockchainName, string[]> & Record<SuiBlockchainName, string[]> & Record<StellarBlockchainName, StellarRpcProvider[]>;
7
8
  export interface AdapterFactoryParams {
8
9
  rpcList: RpcListType;
9
10
  httpClient?: HttpClient;
@@ -3,5 +3,5 @@ import { RubicSdkError } from '../rubic-sdk.error';
3
3
  * Thrown, when user cancels transaction.
4
4
  */
5
5
  export declare class UserRejectError extends RubicSdkError {
6
- constructor();
6
+ constructor(message?: string);
7
7
  }
@@ -6,8 +6,8 @@ const rubic_sdk_error_1 = require("../rubic-sdk.error");
6
6
  * Thrown, when user cancels transaction.
7
7
  */
8
8
  class UserRejectError extends rubic_sdk_error_1.RubicSdkError {
9
- constructor() {
10
- super();
9
+ constructor(message) {
10
+ super(message);
11
11
  Object.setPrototypeOf(this, UserRejectError.prototype);
12
12
  }
13
13
  }