@cryptorubic/web3 1.0.0-alpha.no-sdk.9 → 1.0.0-alpha.no-sdk.10
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/lib/adapter/adapters/adapter-bitcoin/bitcoin-adapter.d.ts +1 -1
- package/src/lib/adapter/adapters/adapter-bitcoin/bitcoin-adapter.js +1 -1
- package/src/lib/adapter/adapters/adapter-evm/evm-adapter.js +8 -7
- package/src/lib/adapter/adapters/adapter-solana/solana-adapter.d.ts +1 -1
- package/src/lib/adapter/adapters/adapter-sui/sui-adapter.d.ts +1 -1
- package/src/lib/adapter/adapters/common/abstract-adapter.d.ts +6 -0
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ export declare class BitcoinAdapter extends AbstractAdapter<BtcWallet, BtcWallet
|
|
|
14
14
|
readonly client: BitcoinAdapterClient;
|
|
15
15
|
constructor(httpClient: HttpClient, logger?: ICustomLogger, clientParams?: ClientAdaptersFactoryParams);
|
|
16
16
|
callContractMethod<T extends Web3PrimitiveType = string>(): Promise<T>;
|
|
17
|
-
getBalance(userAddress: string): Promise<BigNumber>;
|
|
17
|
+
getBalance(userAddress: string, _tokenAddress?: string): Promise<BigNumber>;
|
|
18
18
|
getTokensBalances(userAddress: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
19
19
|
multicallContractsMethods<Output extends Web3PrimitiveType>(contractAbi: Abi, contractsData: {
|
|
20
20
|
contractAddress: string;
|
|
@@ -14,7 +14,7 @@ class BitcoinAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
14
14
|
callContractMethod() {
|
|
15
15
|
throw new Error('Method not implemented.');
|
|
16
16
|
}
|
|
17
|
-
async getBalance(userAddress) {
|
|
17
|
+
async getBalance(userAddress, _tokenAddress) {
|
|
18
18
|
const url = `https://api.blockcypher.com/v1/btc/main/addrs/${userAddress}/balance`;
|
|
19
19
|
const response = await this.httpClient.get(url);
|
|
20
20
|
return new bignumber_js_1.default(response.final_balance);
|
|
@@ -258,14 +258,15 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
258
258
|
* @returns wei amount
|
|
259
259
|
*/
|
|
260
260
|
async getBalance(walletAddress, tokenAddress) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return new bignumber_js_1.default(nativeBalance.toString());
|
|
261
|
+
const isToken = tokenAddress && !web3_pure_1.Web3Pure.isNativeAddress(core_1.CHAIN_TYPE.EVM, tokenAddress);
|
|
262
|
+
if (isToken) {
|
|
263
|
+
const tokenBalance = await this.client.read(tokenAddress, erc20_token_abi_1.erc20TokenAbi, 'balanceOf', [walletAddress]);
|
|
264
|
+
return new bignumber_js_1.default(tokenBalance);
|
|
266
265
|
}
|
|
267
|
-
const
|
|
268
|
-
|
|
266
|
+
const nativeBalance = await this.public.getBalance({
|
|
267
|
+
address: walletAddress
|
|
268
|
+
});
|
|
269
|
+
return new bignumber_js_1.default(nativeBalance.toString());
|
|
269
270
|
}
|
|
270
271
|
async getTransactionCount(walletAddress) {
|
|
271
272
|
const transactionCount = await this.public?.getTransactionCount({
|
|
@@ -28,7 +28,7 @@ export declare class SolanaAdapter extends AbstractAdapter<Connection, SolanaWeb
|
|
|
28
28
|
private createConection;
|
|
29
29
|
simulateTransaction(_config: object, _from: string): Promise<void>;
|
|
30
30
|
checkEnoughBalance(token: TokenAmount | PriceTokenAmount, walletAddress: string): Promise<boolean>;
|
|
31
|
-
getBalance(userAddress: string, tokenAddress
|
|
31
|
+
getBalance(userAddress: string, tokenAddress?: string): Promise<BigNumber>;
|
|
32
32
|
callForTokensInfo(tokenAddresses: string[] | ReadonlyArray<string>): Promise<Token<SolanaBlockchainName>[]>;
|
|
33
33
|
parseRawInstruction(rawInstruction: SolanaRawInstruction[], dataFormat: BufferEncoding): TransactionInstruction[];
|
|
34
34
|
parseLUTAddresses(lookupTableAddresses: string[]): Promise<AddressLookupTableAccount[]>;
|
|
@@ -22,6 +22,6 @@ export declare class SuiAdapter extends AbstractAdapter<SuiClient, WalletAdapter
|
|
|
22
22
|
simulateTransaction(_config: object, _from: string): Promise<void>;
|
|
23
23
|
callForTokensInfo(tokenAddresses: string[] | ReadonlyArray<string>): Promise<Token<SuiBlockchainName>[]>;
|
|
24
24
|
checkEnoughBalance(token: TokenAmount | PriceTokenAmount, walletAddress: string): Promise<boolean>;
|
|
25
|
-
getBalance(userAddress: string, tokenAddress
|
|
25
|
+
getBalance(userAddress: string, tokenAddress?: string): Promise<BigNumber>;
|
|
26
26
|
compareSuiAddress(addressA: string, addressB: string): boolean;
|
|
27
27
|
}
|
|
@@ -13,6 +13,12 @@ export declare abstract class AbstractAdapter<P, W, B extends BlockchainName, Se
|
|
|
13
13
|
protected set public(value: P | null);
|
|
14
14
|
get public(): P;
|
|
15
15
|
protected constructor(blockchain: B, logger?: ICustomLogger);
|
|
16
|
+
/**
|
|
17
|
+
* Gets account native or token balance in wei.
|
|
18
|
+
* @param userAddress Wallet address, whose balance you want to find out.
|
|
19
|
+
* @param tokenAddress Address of the smart-contract corresponding to the token,
|
|
20
|
+
*/
|
|
21
|
+
abstract getBalance(userAddress: string, tokenAddress?: string): Promise<BigNumber>;
|
|
16
22
|
abstract getTokensBalances(userAddress: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
17
23
|
abstract checkEnoughBalance(token: TokenAmount, walletAddress: string): Promise<boolean>;
|
|
18
24
|
abstract callForTokensInfo(tokenAddresses: string[] | ReadonlyArray<string>): Promise<Token<BlockchainName>[]>;
|