@cryptorubic/web3 1.0.0-alpha.no-sdk.27 → 1.0.0-alpha.no-sdk.29
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 +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/lib/adapter/adapters/adapter-bitcoin/bitcoin-adapter.d.ts +2 -0
- package/src/lib/adapter/adapters/adapter-bitcoin/bitcoin-adapter.js +6 -0
- package/src/lib/adapter/adapters/adapter-bitcoin/signer/bitcoin-adapter-signer.d.ts +2 -2
- package/src/lib/adapter/adapters/adapter-bitcoin/signer/bitcoin-adapter-signer.js +19 -5
- package/src/lib/adapter/adapters/adapter-evm/evm-adapter.d.ts +7 -0
- package/src/lib/adapter/adapters/adapter-evm/evm-adapter.js +18 -0
- package/src/lib/adapter/adapters/adapter-evm/signer/evm-adapter-signer.d.ts +0 -7
- package/src/lib/adapter/adapters/adapter-evm/signer/evm-adapter-signer.js +0 -18
- package/src/lib/adapter/adapters/adapter-solana/signer/solana-adapter-signer.d.ts +0 -2
- package/src/lib/adapter/adapters/adapter-solana/signer/solana-adapter-signer.js +0 -18
- package/src/lib/adapter/adapters/adapter-solana/solana-adapter.d.ts +2 -1
- package/src/lib/adapter/adapters/adapter-solana/solana-adapter.js +20 -3
- package/src/lib/adapter/adapters/adapter-sui/signer/sui-adapter-signer.d.ts +0 -2
- package/src/lib/adapter/adapters/adapter-sui/signer/sui-adapter-signer.js +0 -14
- package/src/lib/adapter/adapters/adapter-sui/sui-adapter.d.ts +2 -0
- package/src/lib/adapter/adapters/adapter-sui/sui-adapter.js +14 -0
- package/src/lib/adapter/adapters/adapter-ton/signer/ton-adapter-signer.d.ts +0 -2
- package/src/lib/adapter/adapters/adapter-ton/signer/ton-adapter-signer.js +0 -8
- package/src/lib/adapter/adapters/adapter-ton/ton-adapter.d.ts +2 -0
- package/src/lib/adapter/adapters/adapter-ton/ton-adapter.js +8 -0
- package/src/lib/adapter/adapters/adapter-tron/signer/tron-adapter-signer.d.ts +0 -7
- package/src/lib/adapter/adapters/adapter-tron/signer/tron-adapter-signer.js +0 -18
- package/src/lib/adapter/adapters/adapter-tron/tron-adapter.d.ts +7 -0
- package/src/lib/adapter/adapters/adapter-tron/tron-adapter.js +18 -0
- package/src/lib/adapter/adapters/common/abstract-adapter.d.ts +3 -0
- package/src/lib/adapter/adapters/common/abstract-adapter.js +16 -0
- package/src/lib/adapter/adapters/common/signer/abstract-adapter-signer.d.ts +0 -3
- package/src/lib/adapter/adapters/common/signer/abstract-adapter-signer.js +0 -17
- package/src/lib/adapter/adapters/models/approve-adapter.js +1 -44
- package/src/lib/adapter/adapters/adapter-ton/services/ton-client/ton-client.d.ts +0 -6
- package/src/lib/adapter/adapters/adapter-ton/services/ton-client/ton-client.js +0 -18
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export * from './lib/adapter/adapters/adapter-sui/sui-adapter';
|
|
|
19
19
|
export * from './lib/adapter/adapters/adapter-ton/signer/ton-adapter-signer';
|
|
20
20
|
export * from './lib/adapter/adapters/adapter-ton/models/ton-send-tx-params';
|
|
21
21
|
export * from './lib/adapter/adapters/adapter-ton/services/ton-api.service';
|
|
22
|
-
export * from './lib/adapter/adapters/adapter-ton/services/ton-client/ton-client';
|
|
23
22
|
export * from './lib/adapter/adapters/adapter-ton/ton-adapter';
|
|
24
23
|
export * from './lib/adapter/adapters/adapter-tron/signer/tron-adapter-signer';
|
|
25
24
|
export * from './lib/adapter/adapters/adapter-tron/models/tron-send-tx-params';
|
package/src/index.js
CHANGED
|
@@ -22,7 +22,6 @@ tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-sui/sui-adapter"),
|
|
|
22
22
|
tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-ton/signer/ton-adapter-signer"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-ton/models/ton-send-tx-params"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-ton/services/ton-api.service"), exports);
|
|
25
|
-
tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-ton/services/ton-client/ton-client"), exports);
|
|
26
25
|
tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-ton/ton-adapter"), exports);
|
|
27
26
|
tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-tron/signer/tron-adapter-signer"), exports);
|
|
28
27
|
tslib_1.__exportStar(require("./lib/adapter/adapters/adapter-tron/models/tron-send-tx-params"), exports);
|
|
@@ -9,6 +9,7 @@ import { Abi } from 'viem';
|
|
|
9
9
|
import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
|
|
10
10
|
import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
|
|
11
11
|
import { MethodData } from '../models/web3-public-models/method-data';
|
|
12
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
12
13
|
export declare class BitcoinAdapter extends AbstractAdapter<BtcWallet, BtcWallet, BitcoinBlockchainName> {
|
|
13
14
|
private readonly httpClient;
|
|
14
15
|
readonly signer: BitcoinAdapterSigner;
|
|
@@ -16,6 +17,7 @@ export declare class BitcoinAdapter extends AbstractAdapter<BtcWallet, BtcWallet
|
|
|
16
17
|
constructor(httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
17
18
|
callContractMethod<T extends Web3PrimitiveType = string>(): Promise<T>;
|
|
18
19
|
read<T>(args: unknown): Promise<T>;
|
|
20
|
+
getTransactionStatus(txHash: string): Promise<TxStatus>;
|
|
19
21
|
getBalance(userAddress: string, _tokenAddress?: string): Promise<BigNumber>;
|
|
20
22
|
getTokensBalances(userAddress: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
21
23
|
multicallContractsMethods<Output extends Web3PrimitiveType>(contractAbi: Abi, contractsData: {
|
|
@@ -5,6 +5,7 @@ const core_1 = require("@cryptorubic/core");
|
|
|
5
5
|
const bignumber_js_1 = require("bignumber.js");
|
|
6
6
|
const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
7
7
|
const bitcoin_adapter_signer_1 = require("./signer/bitcoin-adapter-signer");
|
|
8
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
8
9
|
class BitcoinAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
9
10
|
get public() {
|
|
10
11
|
throw new Error('public property is not set in BitcoinAdapter.');
|
|
@@ -20,6 +21,11 @@ class BitcoinAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
20
21
|
read(args) {
|
|
21
22
|
throw new Error('Not implemented');
|
|
22
23
|
}
|
|
24
|
+
async getTransactionStatus(txHash) {
|
|
25
|
+
const url = `https://api.blockcypher.com/v1/btc/main/txs/${txHash}`;
|
|
26
|
+
const { confirmations } = await this.httpClient.get(url);
|
|
27
|
+
return confirmations > 0 ? tx_status_1.TX_STATUS.SUCCESS : tx_status_1.TX_STATUS.PENDING;
|
|
28
|
+
}
|
|
23
29
|
async getBalance(userAddress, _tokenAddress) {
|
|
24
30
|
const url = `https://api.blockcypher.com/v1/btc/main/addrs/${userAddress}/balance`;
|
|
25
31
|
const response = await this.httpClient.get(url);
|
|
@@ -3,15 +3,15 @@ import { ClientAdaptersFactoryParams } from '../../../models/create-factory-para
|
|
|
3
3
|
import { BitconSendTxParams } from '../models/btc-send-tx-params';
|
|
4
4
|
import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-signer';
|
|
5
5
|
import { BtcWallet } from '../../models/btc-wallet-provider';
|
|
6
|
-
import { TxStatus } from '../../models/web3-public-models/tx-status';
|
|
7
6
|
export declare class BitcoinAdapterSigner extends AbstractAdapterSigner<BtcWallet, BitconSendTxParams, string> {
|
|
8
7
|
constructor(httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
9
8
|
write(args: unknown): Promise<string>;
|
|
10
9
|
getBlockchainName(): Promise<BlockchainName>;
|
|
11
|
-
getTransactionStatus(txHash: string): Promise<TxStatus>;
|
|
12
10
|
sendTransaction(params: BitconSendTxParams): Promise<string>;
|
|
13
11
|
private transfer;
|
|
14
12
|
private sendPsbtTransaction;
|
|
15
13
|
private getSrcStatusRecursive;
|
|
16
14
|
private isPsbtConfig;
|
|
15
|
+
private getTransactionStatus;
|
|
16
|
+
private getSrcTxStatus;
|
|
17
17
|
}
|
|
@@ -15,11 +15,6 @@ class BitcoinAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSign
|
|
|
15
15
|
getBlockchainName() {
|
|
16
16
|
return Promise.resolve(core_1.BLOCKCHAIN_NAME.BITCOIN);
|
|
17
17
|
}
|
|
18
|
-
async getTransactionStatus(txHash) {
|
|
19
|
-
const url = `https://api.blockcypher.com/v1/btc/main/txs/${txHash}`;
|
|
20
|
-
const { confirmations } = await this.httpClient.get(url);
|
|
21
|
-
return confirmations > 0 ? tx_status_1.TX_STATUS.SUCCESS : tx_status_1.TX_STATUS.PENDING;
|
|
22
|
-
}
|
|
23
18
|
async sendTransaction(params) {
|
|
24
19
|
if (this.isPsbtConfig(params.txOptions)) {
|
|
25
20
|
return this.sendPsbtTransaction(params.txOptions);
|
|
@@ -118,5 +113,24 @@ class BitcoinAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSign
|
|
|
118
113
|
isPsbtConfig(txConfig) {
|
|
119
114
|
return 'psbt' in txConfig;
|
|
120
115
|
}
|
|
116
|
+
async getTransactionStatus(txHash) {
|
|
117
|
+
const url = `https://api.blockcypher.com/v1/btc/main/txs/${txHash}`;
|
|
118
|
+
const { confirmations } = await this.httpClient.get(url);
|
|
119
|
+
return confirmations > 0 ? tx_status_1.TX_STATUS.SUCCESS : tx_status_1.TX_STATUS.PENDING;
|
|
120
|
+
}
|
|
121
|
+
async getSrcTxStatus(blockchain, srcTxHash) {
|
|
122
|
+
try {
|
|
123
|
+
const status = await this.getTransactionStatus(srcTxHash);
|
|
124
|
+
if (status === tx_status_1.TX_STATUS.FAIL && blockchain === core_1.BLOCKCHAIN_NAME.ZK_SYNC) {
|
|
125
|
+
const zkSyncAwarenessTime = 4000;
|
|
126
|
+
await (0, waitFor_1.waitFor)(zkSyncAwarenessTime);
|
|
127
|
+
return this.getTransactionStatus(srcTxHash);
|
|
128
|
+
}
|
|
129
|
+
return status;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
121
135
|
}
|
|
122
136
|
exports.BitcoinAdapterSigner = BitcoinAdapterSigner;
|
|
@@ -13,6 +13,7 @@ import { GasPrice } from '../models/evm-web3-public-models/gas-price';
|
|
|
13
13
|
import { EvmTransactionOptions } from './models/evm-send-tx-params';
|
|
14
14
|
import { ApprovableAdapter } from '../models/approve-adapter';
|
|
15
15
|
import { AllowanceInfo } from '../models/common-types';
|
|
16
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
16
17
|
export declare class EvmAdapter extends AbstractAdapter<PublicActions & PublicClient, WalletClient & WalletActions, EvmBlockchainName> implements ApprovableAdapter<EvmTransactionConfig> {
|
|
17
18
|
readonly signer: EvmAdapterSigner;
|
|
18
19
|
needPreswapAction(token: TokenAmount, contractAddress: string, walletAddress: string, amount: string): Promise<boolean>;
|
|
@@ -24,6 +25,12 @@ export declare class EvmAdapter extends AbstractAdapter<PublicActions & PublicCl
|
|
|
24
25
|
gasPrice?: string;
|
|
25
26
|
gas?: string;
|
|
26
27
|
}): Promise<T>;
|
|
28
|
+
getTransactionStatus(hash: string): Promise<TxStatus>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets mined transaction receipt.
|
|
31
|
+
* @param hash Transaction hash
|
|
32
|
+
*/
|
|
33
|
+
private getTransactionReceipt;
|
|
27
34
|
getTokensBalances(userAddress: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
28
35
|
multicallContractsMethods<Output extends Web3PrimitiveType>(contractAbi: Abi, contractsData: {
|
|
29
36
|
contractAddress: string;
|
|
@@ -14,6 +14,7 @@ const rubic_sdk_error_1 = require("../../../errors/rubic-sdk.error");
|
|
|
14
14
|
const uni_v3_permit_abi_1 = require("../constants/uni-v3-permit-abi");
|
|
15
15
|
const insufficient_funds_gas_price_value_error_1 = require("../../../errors/cross-chain/insufficient-funds-gas-price-value.error");
|
|
16
16
|
const options_1 = require("../utils/options");
|
|
17
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
17
18
|
class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
18
19
|
async needPreswapAction(token, contractAddress, walletAddress, amount) {
|
|
19
20
|
return this.needApprove(token, contractAddress, walletAddress, amount);
|
|
@@ -42,6 +43,23 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
42
43
|
...(options.from && { account: options.from })
|
|
43
44
|
});
|
|
44
45
|
}
|
|
46
|
+
async getTransactionStatus(hash) {
|
|
47
|
+
const txReceipt = await this.getTransactionReceipt(hash);
|
|
48
|
+
if (txReceipt === null) {
|
|
49
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
50
|
+
}
|
|
51
|
+
if (txReceipt.status) {
|
|
52
|
+
return tx_status_1.TX_STATUS.SUCCESS;
|
|
53
|
+
}
|
|
54
|
+
return tx_status_1.TX_STATUS.FAIL;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets mined transaction receipt.
|
|
58
|
+
* @param hash Transaction hash
|
|
59
|
+
*/
|
|
60
|
+
async getTransactionReceipt(hash) {
|
|
61
|
+
return this.public.getTransactionReceipt({ hash: hash });
|
|
62
|
+
}
|
|
45
63
|
async getTokensBalances(userAddress, tokensAddresses) {
|
|
46
64
|
const indexOfNativeCoin = tokensAddresses.findIndex((tokenAddress) => web3_pure_1.Web3Pure.isNativeAddress('ETH', tokenAddress));
|
|
47
65
|
const promises = [];
|
|
@@ -4,17 +4,10 @@ import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-sign
|
|
|
4
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
|
-
import { TxStatus } from '../../models/web3-public-models/tx-status';
|
|
8
7
|
export declare class EvmAdapterSigner extends AbstractAdapterSigner<WalletClient & WalletActions, EvmSendTxParams, TransactionReceipt> {
|
|
9
8
|
private readonly evmPublic;
|
|
10
9
|
constructor(evmPublic: PublicActions & PublicClient, httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
11
10
|
getBlockchainName(): Promise<BlockchainName | undefined>;
|
|
12
|
-
getTransactionStatus(hash: string): Promise<TxStatus>;
|
|
13
|
-
/**
|
|
14
|
-
* Gets mined transaction receipt.
|
|
15
|
-
* @param hash Transaction hash
|
|
16
|
-
*/
|
|
17
|
-
private getTransactionReceipt;
|
|
18
11
|
/**
|
|
19
12
|
* Sends Eth in transaction and resolve the promise when the transaction is included in the block.
|
|
20
13
|
* @param toAddress Eth receiver address.
|
|
@@ -9,7 +9,6 @@ const options_1 = require("../../utils/options");
|
|
|
9
9
|
const viem_blockchain_mapping_1 = require("../../../constants/viem-blockchain-mapping");
|
|
10
10
|
const parse_evm_error_1 = require("../utils/parse-evm-error");
|
|
11
11
|
const rubic_sdk_error_1 = require("../../../../errors/rubic-sdk.error");
|
|
12
|
-
const tx_status_1 = require("../../models/web3-public-models/tx-status");
|
|
13
12
|
const tx_reverted_in_chain_error_1 = require("../../../../errors/common/tx-reverted-in-chain.error");
|
|
14
13
|
class EvmAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
15
14
|
constructor(evmPublic, httpClient, logger, clientParams) {
|
|
@@ -20,23 +19,6 @@ class EvmAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
|
20
19
|
const userChainId = await this.wallet.getChainId();
|
|
21
20
|
return core_1.BlockchainsInfo.getBlockchainNameById(userChainId);
|
|
22
21
|
}
|
|
23
|
-
async getTransactionStatus(hash) {
|
|
24
|
-
const txReceipt = await this.getTransactionReceipt(hash);
|
|
25
|
-
if (txReceipt === null) {
|
|
26
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
27
|
-
}
|
|
28
|
-
if (txReceipt.status) {
|
|
29
|
-
return tx_status_1.TX_STATUS.SUCCESS;
|
|
30
|
-
}
|
|
31
|
-
return tx_status_1.TX_STATUS.FAIL;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Gets mined transaction receipt.
|
|
35
|
-
* @param hash Transaction hash
|
|
36
|
-
*/
|
|
37
|
-
async getTransactionReceipt(hash) {
|
|
38
|
-
return this.evmPublic.getTransactionReceipt({ hash: hash });
|
|
39
|
-
}
|
|
40
22
|
/**
|
|
41
23
|
* Sends Eth in transaction and resolve the promise when the transaction is included in the block.
|
|
42
24
|
* @param toAddress Eth receiver address.
|
|
@@ -4,13 +4,11 @@ import { ClientAdaptersFactoryParams } from '../../../models/create-factory-para
|
|
|
4
4
|
import { SolanaSendTxParams } from '../models/solana-send-tx-params';
|
|
5
5
|
import { Connection } from '@solana/web3.js';
|
|
6
6
|
import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-signer';
|
|
7
|
-
import { TxStatus } from '../../models/web3-public-models/tx-status';
|
|
8
7
|
export declare class SolanaAdapterSigner extends AbstractAdapterSigner<SolanaWeb3, SolanaSendTxParams, string> {
|
|
9
8
|
private readonly connection;
|
|
10
9
|
constructor(connection: Connection, httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
11
10
|
write<T>(): Promise<T>;
|
|
12
11
|
getBlockchainName(): Promise<BlockchainName>;
|
|
13
|
-
getTransactionStatus(txHash: string): Promise<TxStatus>;
|
|
14
12
|
sendTransaction(params: SolanaSendTxParams): Promise<string>;
|
|
15
13
|
private waitForTxConfirmation;
|
|
16
14
|
}
|
|
@@ -8,7 +8,6 @@ const js_base64_1 = require("js-base64");
|
|
|
8
8
|
const user_reject_error_1 = require("../../../../errors/blockchain/user-reject.error");
|
|
9
9
|
const errors_1 = require("../../utils/errors");
|
|
10
10
|
const abstract_adapter_signer_1 = require("../../common/signer/abstract-adapter-signer");
|
|
11
|
-
const tx_status_1 = require("../../models/web3-public-models/tx-status");
|
|
12
11
|
const tx_reverted_in_chain_error_1 = require("../../../../errors/common/tx-reverted-in-chain.error");
|
|
13
12
|
class SolanaAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
14
13
|
constructor(connection, httpClient, logger, clientParams) {
|
|
@@ -21,23 +20,6 @@ class SolanaAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigne
|
|
|
21
20
|
getBlockchainName() {
|
|
22
21
|
return Promise.resolve(core_1.BLOCKCHAIN_NAME.SOLANA);
|
|
23
22
|
}
|
|
24
|
-
async getTransactionStatus(txHash) {
|
|
25
|
-
try {
|
|
26
|
-
const transaction = await this.connection.getTransaction(txHash, {
|
|
27
|
-
maxSupportedTransactionVersion: 1
|
|
28
|
-
});
|
|
29
|
-
if (transaction?.meta?.err) {
|
|
30
|
-
return tx_status_1.TX_STATUS.FAIL;
|
|
31
|
-
}
|
|
32
|
-
if (transaction?.blockTime) {
|
|
33
|
-
return tx_status_1.TX_STATUS.SUCCESS;
|
|
34
|
-
}
|
|
35
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
23
|
async sendTransaction(params) {
|
|
42
24
|
try {
|
|
43
25
|
const decodedData = js_base64_1.Base64.toUint8Array(params.txOptions.data);
|
|
@@ -8,13 +8,14 @@ import { SolanaWeb3 } from '../../constants/models/solana-web3';
|
|
|
8
8
|
import { SolanaAdapterSigner } from './signer/solana-adapter-signer';
|
|
9
9
|
import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
|
|
10
10
|
import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
|
|
11
|
-
|
|
11
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
12
12
|
export declare class SolanaAdapter extends AbstractAdapter<Connection, SolanaWeb3, SolanaBlockchainName> {
|
|
13
13
|
private readonly httpClient;
|
|
14
14
|
readonly signer: SolanaAdapterSigner;
|
|
15
15
|
constructor(rpcList: string[], httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
16
16
|
callContractMethod<T extends Web3PrimitiveType = string>(): Promise<T>;
|
|
17
17
|
read<T>(): Promise<T>;
|
|
18
|
+
getTransactionStatus(txHash: string): Promise<TxStatus>;
|
|
18
19
|
/**
|
|
19
20
|
* Gets balance of multiple tokens.
|
|
20
21
|
* @param address Wallet address.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SolanaAdapter =
|
|
3
|
+
exports.SolanaAdapter = void 0;
|
|
4
4
|
const spl_token_1 = require("@solana/spl-token");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
const core_1 = require("@cryptorubic/core");
|
|
@@ -11,7 +11,7 @@ const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
|
11
11
|
const web3_pure_1 = require("../../../utils/web3-pure");
|
|
12
12
|
const solana_tokens_service_1 = require("./services/solana-tokens-service");
|
|
13
13
|
const solana_adapter_signer_1 = require("./signer/solana-adapter-signer");
|
|
14
|
-
|
|
14
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
15
15
|
class SolanaAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
16
16
|
constructor(rpcList, httpClient, logger, clientParams) {
|
|
17
17
|
super(core_1.BLOCKCHAIN_NAME.SOLANA, logger);
|
|
@@ -25,6 +25,23 @@ class SolanaAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
25
25
|
async read() {
|
|
26
26
|
throw new Error('Method read is not supported');
|
|
27
27
|
}
|
|
28
|
+
async getTransactionStatus(txHash) {
|
|
29
|
+
try {
|
|
30
|
+
const transaction = await this.public.getTransaction(txHash, {
|
|
31
|
+
maxSupportedTransactionVersion: 1
|
|
32
|
+
});
|
|
33
|
+
if (transaction?.meta?.err) {
|
|
34
|
+
return tx_status_1.TX_STATUS.FAIL;
|
|
35
|
+
}
|
|
36
|
+
if (transaction?.blockTime) {
|
|
37
|
+
return tx_status_1.TX_STATUS.SUCCESS;
|
|
38
|
+
}
|
|
39
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
28
45
|
/**
|
|
29
46
|
* Gets balance of multiple tokens.
|
|
30
47
|
* @param address Wallet address.
|
|
@@ -38,7 +55,7 @@ class SolanaAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
38
55
|
}));
|
|
39
56
|
const nativeSolBalance = await this.public.getBalanceAndContext(new web3_js_1.PublicKey(address), 'confirmed');
|
|
40
57
|
return tokensAddresses.map((tokenAddress) => {
|
|
41
|
-
if (tokenAddress ===
|
|
58
|
+
if (tokenAddress === web3_pure_1.Web3Pure.getNativeTokenAddress(core_1.BLOCKCHAIN_NAME.SOLANA)) {
|
|
42
59
|
return new bignumber_js_1.default(nativeSolBalance.value.toString());
|
|
43
60
|
}
|
|
44
61
|
const tokenWithBalance = tokenInfo.get(tokenAddress);
|
|
@@ -3,14 +3,12 @@ import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-sign
|
|
|
3
3
|
import { ClientAdaptersFactoryParams } from '../../../models/create-factory-params';
|
|
4
4
|
import { SuiSendTxParams } from '../models/sui-send-tx-params';
|
|
5
5
|
import { WalletAdapter } from '@suiet/wallet-sdk';
|
|
6
|
-
import { TxStatus } from '../../models/web3-public-models/tx-status';
|
|
7
6
|
import { ExecuteTransactionBlockParams, SuiClient, SuiTransactionBlockResponse } from '@mysten/sui/dist/cjs/client';
|
|
8
7
|
export declare class SuiAdapterSigner extends AbstractAdapterSigner<WalletAdapter, SuiSendTxParams, string> {
|
|
9
8
|
private readonly suiClient;
|
|
10
9
|
constructor(suiClient: SuiClient, httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
11
10
|
write<T>(): Promise<T>;
|
|
12
11
|
getBlockchainName(): Promise<BlockchainName>;
|
|
13
|
-
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
14
12
|
sendTransaction(params: SuiSendTxParams): Promise<string>;
|
|
15
13
|
executeTxBlock(params: ExecuteTransactionBlockParams): Promise<SuiTransactionBlockResponse>;
|
|
16
14
|
}
|
|
@@ -5,7 +5,6 @@ const core_1 = require("@cryptorubic/core");
|
|
|
5
5
|
const abstract_adapter_signer_1 = require("../../common/signer/abstract-adapter-signer");
|
|
6
6
|
const user_reject_error_1 = require("../../../../errors/blockchain/user-reject.error");
|
|
7
7
|
const parse_evm_error_1 = require("../../adapter-evm/utils/parse-evm-error");
|
|
8
|
-
const tx_status_1 = require("../../models/web3-public-models/tx-status");
|
|
9
8
|
class SuiAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
10
9
|
constructor(suiClient, httpClient, logger, clientParams) {
|
|
11
10
|
super(httpClient, logger, clientParams);
|
|
@@ -17,19 +16,6 @@ class SuiAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
|
17
16
|
getBlockchainName() {
|
|
18
17
|
return Promise.resolve(core_1.BLOCKCHAIN_NAME.SUI);
|
|
19
18
|
}
|
|
20
|
-
async getTransactionStatus(srcTxHash) {
|
|
21
|
-
try {
|
|
22
|
-
const txDetails = await this.suiClient.getTransactionBlock({ digest: srcTxHash });
|
|
23
|
-
const status = txDetails?.effects?.status.status;
|
|
24
|
-
if (!status) {
|
|
25
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
26
|
-
}
|
|
27
|
-
return status === 'success' ? tx_status_1.TX_STATUS.SUCCESS : tx_status_1.TX_STATUS.FAIL;
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
19
|
async sendTransaction(params) {
|
|
34
20
|
try {
|
|
35
21
|
const account = this.wallet.accounts[0];
|
|
@@ -8,11 +8,13 @@ import { SuiAdapterSigner } from './signer/sui-adapter-signer';
|
|
|
8
8
|
import { ClientAdaptersFactoryParams } from '../../models/create-factory-params';
|
|
9
9
|
import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
|
|
10
10
|
import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
|
|
11
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
11
12
|
export declare class SuiAdapter extends AbstractAdapter<SuiClient, WalletAdapter, SuiBlockchainName> {
|
|
12
13
|
readonly signer: SuiAdapterSigner;
|
|
13
14
|
constructor(rpcList: string[], httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
14
15
|
callContractMethod<T extends Web3PrimitiveType = string>(): Promise<T>;
|
|
15
16
|
read<T>(): Promise<T>;
|
|
17
|
+
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
16
18
|
getTokensBalances(userAddress: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
17
19
|
multicallContractsMethods<Output extends Web3PrimitiveType>(): Promise<ContractMulticallResponse<Output>[][]>;
|
|
18
20
|
getBlockNumber(): Promise<number | {
|
|
@@ -7,6 +7,7 @@ const bignumber_js_1 = require("bignumber.js");
|
|
|
7
7
|
const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
8
8
|
const web3_pure_1 = require("../../../utils/web3-pure");
|
|
9
9
|
const sui_adapter_signer_1 = require("./signer/sui-adapter-signer");
|
|
10
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
10
11
|
class SuiAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
11
12
|
constructor(rpcList, httpClient, logger, clientParams) {
|
|
12
13
|
super(core_1.BLOCKCHAIN_NAME.SUI, logger);
|
|
@@ -19,6 +20,19 @@ class SuiAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
19
20
|
async read() {
|
|
20
21
|
throw new Error('Method read is not supported');
|
|
21
22
|
}
|
|
23
|
+
async getTransactionStatus(srcTxHash) {
|
|
24
|
+
try {
|
|
25
|
+
const txDetails = await this.public.getTransactionBlock({ digest: srcTxHash });
|
|
26
|
+
const status = txDetails?.effects?.status.status;
|
|
27
|
+
if (!status) {
|
|
28
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
29
|
+
}
|
|
30
|
+
return status === 'success' ? tx_status_1.TX_STATUS.SUCCESS : tx_status_1.TX_STATUS.FAIL;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
22
36
|
async getTokensBalances(userAddress, tokensAddresses) {
|
|
23
37
|
const allUserTokens = await this.public.getAllBalances({ owner: userAddress });
|
|
24
38
|
return tokensAddresses.map((address) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BlockchainName, HttpClient, ICustomLogger } from '@cryptorubic/core';
|
|
2
2
|
import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-signer';
|
|
3
3
|
import { ClientAdaptersFactoryParams } from '../../../models/create-factory-params';
|
|
4
|
-
import { TxStatus } from '../../models/web3-public-models/tx-status';
|
|
5
4
|
import { TonSendTxParams } from '../models/ton-send-tx-params';
|
|
6
5
|
import { TonConnectUI } from '@tonconnect/ui';
|
|
7
6
|
import { BasicSendTransactionOptions } from '../../models/basic-transaction-options';
|
|
@@ -15,7 +14,6 @@ export declare class TonAdapterSigner extends AbstractAdapterSigner<TonConnectUI
|
|
|
15
14
|
constructor(tonApi: TonApiService, tonClient: TonClient, httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
16
15
|
write<T>(): Promise<T>;
|
|
17
16
|
getBlockchainName(): Promise<BlockchainName>;
|
|
18
|
-
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
19
17
|
sendTransaction(params: TonSendTxParams): Promise<string>;
|
|
20
18
|
private waitForTransactionReceipt;
|
|
21
19
|
/**
|
|
@@ -4,7 +4,6 @@ exports.TonAdapterSigner = 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 user_reject_error_1 = require("../../../../errors/blockchain/user-reject.error");
|
|
7
|
-
const tx_status_1 = require("../../models/web3-public-models/tx-status");
|
|
8
7
|
const rubic_sdk_error_1 = require("../../../../errors/rubic-sdk.error");
|
|
9
8
|
const errors_1 = require("../../utils/errors");
|
|
10
9
|
const core_2 = require("@ton/core");
|
|
@@ -21,13 +20,6 @@ class TonAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
|
21
20
|
getBlockchainName() {
|
|
22
21
|
return Promise.resolve(core_1.BLOCKCHAIN_NAME.TON);
|
|
23
22
|
}
|
|
24
|
-
async getTransactionStatus(srcTxHash) {
|
|
25
|
-
const isCompleted = await this.tonApi.checkIsTxCompleted(srcTxHash);
|
|
26
|
-
if (isCompleted) {
|
|
27
|
-
return tx_status_1.TX_STATUS.SUCCESS;
|
|
28
|
-
}
|
|
29
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
30
|
-
}
|
|
31
23
|
async sendTransaction(params) {
|
|
32
24
|
try {
|
|
33
25
|
const { boc } = await this.wallet.sendTransaction({
|
|
@@ -9,12 +9,14 @@ import { TonAdapterSigner } from './signer/ton-adapter-signer';
|
|
|
9
9
|
import { ClientAdaptersFactoryParams } from '../../models/create-factory-params';
|
|
10
10
|
import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
|
|
11
11
|
import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
|
|
12
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
12
13
|
export declare class TonAdapter extends AbstractAdapter<TonClient, TonConnectUI, TonBlockchainName> {
|
|
13
14
|
readonly signer: TonAdapterSigner;
|
|
14
15
|
private readonly tonApi;
|
|
15
16
|
constructor(httpClient: HttpClient, config: TonAdapterConfig, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
16
17
|
read<T>(): Promise<T>;
|
|
17
18
|
callContractMethod<T extends Web3PrimitiveType = string>(): Promise<T>;
|
|
19
|
+
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
18
20
|
getTokensBalances(userAddress: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
19
21
|
multicallContractsMethods<Output extends Web3PrimitiveType>(): Promise<ContractMulticallResponse<Output>[][]>;
|
|
20
22
|
getBlockNumber(): Promise<number | {
|
|
@@ -8,6 +8,7 @@ const bignumber_js_1 = require("bignumber.js");
|
|
|
8
8
|
const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
9
9
|
const web3_pure_1 = require("../../../utils/web3-pure");
|
|
10
10
|
const ton_adapter_signer_1 = require("./signer/ton-adapter-signer");
|
|
11
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
11
12
|
class TonAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
12
13
|
constructor(httpClient, config, logger, clientParams) {
|
|
13
14
|
super(core_1.BLOCKCHAIN_NAME.TON, logger);
|
|
@@ -21,6 +22,13 @@ class TonAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
21
22
|
async callContractMethod() {
|
|
22
23
|
throw new Error('Method call is not supported');
|
|
23
24
|
}
|
|
25
|
+
async getTransactionStatus(srcTxHash) {
|
|
26
|
+
const isCompleted = await this.tonApi.checkIsTxCompleted(srcTxHash);
|
|
27
|
+
if (isCompleted) {
|
|
28
|
+
return tx_status_1.TX_STATUS.SUCCESS;
|
|
29
|
+
}
|
|
30
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
31
|
+
}
|
|
24
32
|
async getTokensBalances(userAddress, tokensAddresses) {
|
|
25
33
|
const tokensWithBalance = await this.tonApi.fetchAllNonNullableTokensInfoForWallet(userAddress);
|
|
26
34
|
const nativeIndex = tokensAddresses.findIndex((tokenAddress) => web3_pure_1.Web3Pure.isNativeAddress('TON', tokenAddress));
|
|
@@ -3,19 +3,12 @@ import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-sign
|
|
|
3
3
|
import { BlockchainName, HttpClient, ICustomLogger } from '@cryptorubic/core';
|
|
4
4
|
import { ClientAdaptersFactoryParams } from '../../../models/create-factory-params';
|
|
5
5
|
import { TronSendTxParams } from '../models/tron-send-tx-params';
|
|
6
|
-
import { TxStatus } from '../../models/web3-public-models/tx-status';
|
|
7
6
|
import { TronParameters } from '../../../../utils/models/tron-parameters';
|
|
8
7
|
export declare class TronAdapterSigner extends AbstractAdapterSigner<TronWeb, TronSendTxParams, string> {
|
|
9
8
|
private readonly tronWeb;
|
|
10
9
|
constructor(tronWeb: TronWeb, httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
11
10
|
write(contractAddress: string, methodSignature: string, parameters: TronParameters): Promise<string>;
|
|
12
11
|
getBlockchainName(): Promise<BlockchainName>;
|
|
13
|
-
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
14
|
-
/**
|
|
15
|
-
* Gets mined transaction info.
|
|
16
|
-
* @param hash Transaction hash.
|
|
17
|
-
*/
|
|
18
|
-
private getTransactionInfo;
|
|
19
12
|
sendTransaction(params: TronSendTxParams): Promise<string>;
|
|
20
13
|
trySendTransaction(params: TronSendTxParams): Promise<string>;
|
|
21
14
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TronAdapterSigner = void 0;
|
|
4
4
|
const abstract_adapter_signer_1 = require("../../common/signer/abstract-adapter-signer");
|
|
5
5
|
const core_1 = require("@cryptorubic/core");
|
|
6
|
-
const tx_status_1 = require("../../models/web3-public-models/tx-status");
|
|
7
6
|
const parse_tron_error_1 = require("../utils/parse-tron-error");
|
|
8
7
|
class TronAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
9
8
|
constructor(tronWeb, httpClient, logger, clientParams) {
|
|
@@ -19,23 +18,6 @@ class TronAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner
|
|
|
19
18
|
getBlockchainName() {
|
|
20
19
|
return Promise.resolve(core_1.BLOCKCHAIN_NAME.TRON);
|
|
21
20
|
}
|
|
22
|
-
async getTransactionStatus(srcTxHash) {
|
|
23
|
-
const txReceipt = await this.getTransactionInfo(srcTxHash);
|
|
24
|
-
if (txReceipt?.receipt) {
|
|
25
|
-
if (txReceipt.result === 'FAILED') {
|
|
26
|
-
return tx_status_1.TX_STATUS.FAIL;
|
|
27
|
-
}
|
|
28
|
-
return tx_status_1.TX_STATUS.SUCCESS;
|
|
29
|
-
}
|
|
30
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Gets mined transaction info.
|
|
34
|
-
* @param hash Transaction hash.
|
|
35
|
-
*/
|
|
36
|
-
async getTransactionInfo(hash) {
|
|
37
|
-
return this.tronWeb.trx.getTransactionInfo(hash);
|
|
38
|
-
}
|
|
39
21
|
async sendTransaction(params) {
|
|
40
22
|
try {
|
|
41
23
|
const transaction = await this.tronWeb.transactionBuilder.triggerSmartContract(params.contractAddress, params.methodSignature, params.txOptions, params.parameters, this.walletAddress);
|
|
@@ -13,6 +13,7 @@ import { TronAdapterSigner } from './signer/tron-adapter-signer';
|
|
|
13
13
|
import { TronTransactionOptions } from './models/tron-send-tx-params';
|
|
14
14
|
import { AllowanceInfo } from '../models/common-types';
|
|
15
15
|
import { ApprovableAdapter } from '../models/approve-adapter';
|
|
16
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
16
17
|
export declare class TronAdapter extends AbstractAdapter<TronWeb, TronWeb, TronBlockchainName> implements ApprovableAdapter<TronTransactionConfig> {
|
|
17
18
|
readonly signer: TronAdapterSigner;
|
|
18
19
|
private readonly multicallAddress;
|
|
@@ -21,6 +22,12 @@ export declare class TronAdapter extends AbstractAdapter<TronWeb, TronWeb, TronB
|
|
|
21
22
|
fullHost: string;
|
|
22
23
|
})[], httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
23
24
|
callContractMethod<T extends Web3PrimitiveType = string>(contractAddress: string, contractAbi: Abi, methodName: string, methodArguments?: unknown[]): Promise<T>;
|
|
25
|
+
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets mined transaction info.
|
|
28
|
+
* @param hash Transaction hash.
|
|
29
|
+
*/
|
|
30
|
+
private getTransactionInfo;
|
|
24
31
|
getTokensBalances(userAddress: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
25
32
|
multicallContractsMethods<Output extends TronWeb3PrimitiveType>(contractAbi: any, contractsData: {
|
|
26
33
|
contractAddress: string;
|
|
@@ -12,6 +12,7 @@ const tron_web3_pure_1 = require("../../../utils/web3-types/tron-web3-pure");
|
|
|
12
12
|
const tron_adapter_signer_1 = require("./signer/tron-adapter-signer");
|
|
13
13
|
const options_1 = require("../utils/options");
|
|
14
14
|
const parse_tron_error_1 = require("./utils/parse-tron-error");
|
|
15
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
15
16
|
class TronAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
16
17
|
async needPreswapAction() {
|
|
17
18
|
return false;
|
|
@@ -29,6 +30,23 @@ class TronAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
29
30
|
const response = await contract[methodName](...methodArguments).call();
|
|
30
31
|
return tron_web3_pure_1.TronWeb3Pure.flattenParameterToPrimitive(response);
|
|
31
32
|
}
|
|
33
|
+
async getTransactionStatus(srcTxHash) {
|
|
34
|
+
const txReceipt = await this.getTransactionInfo(srcTxHash);
|
|
35
|
+
if (txReceipt?.receipt) {
|
|
36
|
+
if (txReceipt.result === 'FAILED') {
|
|
37
|
+
return tx_status_1.TX_STATUS.FAIL;
|
|
38
|
+
}
|
|
39
|
+
return tx_status_1.TX_STATUS.SUCCESS;
|
|
40
|
+
}
|
|
41
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets mined transaction info.
|
|
45
|
+
* @param hash Transaction hash.
|
|
46
|
+
*/
|
|
47
|
+
async getTransactionInfo(hash) {
|
|
48
|
+
return this.public.trx.getTransactionInfo(hash);
|
|
49
|
+
}
|
|
32
50
|
async getTokensBalances(userAddress, tokensAddresses) {
|
|
33
51
|
const indexOfNativeCoin = tokensAddresses.findIndex((address) => web3_pure_1.Web3Pure.isNativeAddress(core_1.CHAIN_TYPE.TRON, address));
|
|
34
52
|
const promises = [];
|
|
@@ -5,6 +5,7 @@ import { AbstractAdapterSigner } from './signer/abstract-adapter-signer';
|
|
|
5
5
|
import { MethodData } from '../models/web3-public-models/method-data';
|
|
6
6
|
import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
|
|
7
7
|
import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
|
|
8
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
8
9
|
export declare abstract class AbstractAdapter<P, W, B extends BlockchainName, SendTxParams extends object = {}, SendTxResponse = {}> {
|
|
9
10
|
abstract signer: AbstractAdapterSigner<W, SendTxParams, SendTxResponse>;
|
|
10
11
|
protected readonly logger?: ICustomLogger;
|
|
@@ -65,4 +66,6 @@ export declare abstract class AbstractAdapter<P, W, B extends BlockchainName, Se
|
|
|
65
66
|
handlePreswap(contractAddress: string, walletAddress: string, tokenAmount: TokenAmount): Promise<void>;
|
|
66
67
|
static getRandomBytes(bytes: number): string;
|
|
67
68
|
abstract read<T>(...args: unknown[]): Promise<T>;
|
|
69
|
+
abstract getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
70
|
+
getSrcTxStatus(blockchain: BlockchainName, srcTxHash: string): Promise<TxStatus>;
|
|
68
71
|
}
|
|
@@ -4,6 +4,8 @@ exports.AbstractAdapter = void 0;
|
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const core_1 = require("@cryptorubic/core");
|
|
6
6
|
const insufficient_funds_error_1 = require("../../../errors/swap/insufficient-funds.error");
|
|
7
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
8
|
+
const waitFor_1 = require("../utils/waitFor");
|
|
7
9
|
class AbstractAdapter {
|
|
8
10
|
set public(value) {
|
|
9
11
|
this._public = value;
|
|
@@ -53,5 +55,19 @@ class AbstractAdapter {
|
|
|
53
55
|
const randomBytes = crypto.getRandomValues(new Uint8Array(bytes));
|
|
54
56
|
return (0, viem_1.bytesToHex)(randomBytes);
|
|
55
57
|
}
|
|
58
|
+
async getSrcTxStatus(blockchain, srcTxHash) {
|
|
59
|
+
try {
|
|
60
|
+
const status = await this.getTransactionStatus(srcTxHash);
|
|
61
|
+
if (status === tx_status_1.TX_STATUS.FAIL && blockchain === core_1.BLOCKCHAIN_NAME.ZK_SYNC) {
|
|
62
|
+
const zkSyncAwarenessTime = 4000;
|
|
63
|
+
await (0, waitFor_1.waitFor)(zkSyncAwarenessTime);
|
|
64
|
+
return this.getTransactionStatus(srcTxHash);
|
|
65
|
+
}
|
|
66
|
+
return status;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return tx_status_1.TX_STATUS.PENDING;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
56
72
|
}
|
|
57
73
|
exports.AbstractAdapter = AbstractAdapter;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BlockchainName, HttpClient, ICustomLogger } from '@cryptorubic/core';
|
|
2
2
|
import { ClientAdaptersFactoryParams } from '../../../models/create-factory-params';
|
|
3
|
-
import { TxStatus } from '../../models/web3-public-models/tx-status';
|
|
4
3
|
export declare abstract class AbstractAdapterSigner<ClientWallet, SendTxParams, SendTxResponse> {
|
|
5
4
|
protected readonly httpClient: HttpClient;
|
|
6
5
|
protected readonly logger?: ICustomLogger | undefined;
|
|
@@ -13,13 +12,11 @@ export declare abstract class AbstractAdapterSigner<ClientWallet, SendTxParams,
|
|
|
13
12
|
constructor(httpClient: HttpClient, logger?: ICustomLogger | undefined, clientParams?: ClientAdaptersFactoryParams | undefined);
|
|
14
13
|
abstract getBlockchainName(): Promise<BlockchainName | undefined>;
|
|
15
14
|
abstract sendTransaction(params: SendTxParams): Promise<SendTxResponse>;
|
|
16
|
-
abstract getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
17
15
|
abstract write(...args: unknown[]): Promise<string>;
|
|
18
16
|
/**
|
|
19
17
|
* Checks, that selected blockchain in wallet is equal to passed blockchain.
|
|
20
18
|
*/
|
|
21
19
|
checkBlockchainCorrect(blockchainName: BlockchainName): Promise<void | never>;
|
|
22
|
-
getSrcTxStatus(blockchain: BlockchainName, srcTxHash: string): Promise<TxStatus>;
|
|
23
20
|
setWalletAddress(newWalletAddress: string): void;
|
|
24
21
|
setWallet(wallet: ClientWallet): void;
|
|
25
22
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractAdapterSigner = void 0;
|
|
4
|
-
const core_1 = require("@cryptorubic/core");
|
|
5
4
|
const rubic_api_link_mapping_1 = require("../../../constants/rubic-api-link-mapping");
|
|
6
|
-
const tx_status_1 = require("../../models/web3-public-models/tx-status");
|
|
7
|
-
const waitFor_1 = require("../../utils/waitFor");
|
|
8
5
|
const wrong_network_error_1 = require("../../../../errors/swap/wrong-network.error");
|
|
9
6
|
class AbstractAdapterSigner {
|
|
10
7
|
get apiUrl() {
|
|
@@ -35,20 +32,6 @@ class AbstractAdapterSigner {
|
|
|
35
32
|
throw new wrong_network_error_1.WrongNetworkError(blockchainName);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
async getSrcTxStatus(blockchain, srcTxHash) {
|
|
39
|
-
try {
|
|
40
|
-
const status = await this.getTransactionStatus(srcTxHash);
|
|
41
|
-
if (status === tx_status_1.TX_STATUS.FAIL && blockchain === core_1.BLOCKCHAIN_NAME.ZK_SYNC) {
|
|
42
|
-
const zkSyncAwarenessTime = 4000;
|
|
43
|
-
await (0, waitFor_1.waitFor)(zkSyncAwarenessTime);
|
|
44
|
-
return this.getTransactionStatus(srcTxHash);
|
|
45
|
-
}
|
|
46
|
-
return status;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return tx_status_1.TX_STATUS.PENDING;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
35
|
setWalletAddress(newWalletAddress) {
|
|
53
36
|
this._walletAddress = newWalletAddress;
|
|
54
37
|
}
|
|
@@ -2,48 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isApprovableAdapter = isApprovableAdapter;
|
|
4
4
|
function isApprovableAdapter(adapter) {
|
|
5
|
-
return 'needApprove' in adapter && '
|
|
5
|
+
return 'needApprove' in adapter && 'approveTokens' in adapter && 'getAllowance' in adapter && 'encodeApprove' in adapter;
|
|
6
6
|
}
|
|
7
|
-
// export interface ApproveAdapterClient<T> extends AbstractAdapterSigner<{}, {}, {}> {
|
|
8
|
-
// /**
|
|
9
|
-
// * @param fromTokenAddress erc20 address of checked token
|
|
10
|
-
// * @param walletAddress owner wallet address
|
|
11
|
-
// * @param spenderAddress spender address
|
|
12
|
-
// * @return allowance wei amount
|
|
13
|
-
// */
|
|
14
|
-
// getAllowance(fromTokenAddress: string, walletAddress: string, spenderAddress: string): Promise<AllowanceInfo>;
|
|
15
|
-
// /**
|
|
16
|
-
// * Get data for tokens approve
|
|
17
|
-
// * @param tokenAddress erc20 token address
|
|
18
|
-
// * @param spenderAddress spender address
|
|
19
|
-
// * @param amount amount in non wei
|
|
20
|
-
// */
|
|
21
|
-
// encodeApprove(tokenAddress: string, spenderAddress: string, amount?: string): T;
|
|
22
|
-
// /**
|
|
23
|
-
// * Check if approve needed.
|
|
24
|
-
// * @param token
|
|
25
|
-
// * @param contractAddress
|
|
26
|
-
// * @param walletAddress
|
|
27
|
-
// * @param amount
|
|
28
|
-
// */
|
|
29
|
-
// needApprove(token: TokenAmount, contractAddress: string, walletAddress: string, amount: string): Promise<boolean>;
|
|
30
|
-
// /**
|
|
31
|
-
// * Executes approve method in ERC-20 token contract.
|
|
32
|
-
// * @param tokenAddress Address of the smart-contract corresponding to the token.
|
|
33
|
-
// * @param spenderAddress Wallet or contract address to approve.
|
|
34
|
-
// * @param amount Token amount to approve in wei.
|
|
35
|
-
// * @param [options] Additional options.
|
|
36
|
-
// * @returns Approval transaction receipt.
|
|
37
|
-
// */
|
|
38
|
-
// approveTokens(
|
|
39
|
-
// tokenAddress: string,
|
|
40
|
-
// spenderAddress: string,
|
|
41
|
-
// amount: BigNumber | 'infinity',
|
|
42
|
-
// options: BasicSendTransactionOptions
|
|
43
|
-
// ): Promise<string>;
|
|
44
|
-
// }
|
|
45
|
-
// export function isApprovableAdapterClient(
|
|
46
|
-
// adapterClient: AbstractAdapterSigner<{}, {}, {}>
|
|
47
|
-
// ): adapterClient is ApproveAdapterClient<EvmTransactionConfig | TronTransactionConfig> {
|
|
48
|
-
// return 'needApprove' in adapterClient && 'approveTokens' in adapterClient && 'getAllowance' in adapterClient;
|
|
49
|
-
// }
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TonClientInstance = void 0;
|
|
4
|
-
const ton_1 = require("@ton/ton");
|
|
5
|
-
class TonClientInstance {
|
|
6
|
-
constructor() { }
|
|
7
|
-
static getInstance() {
|
|
8
|
-
if (!this.instance) {
|
|
9
|
-
this.instance = new ton_1.TonClient({
|
|
10
|
-
endpoint: 'https://x-api.rubic.exchange/toncenter/api/v2/jsonRPC',
|
|
11
|
-
apiKey: 'sndfje3u4b3fnNSDNFUSDNVSunw345842hrnfd3b4nt4'
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return this.instance;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.TonClientInstance = TonClientInstance;
|
|
18
|
-
TonClientInstance.instance = null;
|