carbon-js-sdk 0.3.53-beta.1 → 0.3.53-dev.2
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/lib/CarbonSDK.js +1 -1
- package/lib/clients/CarbonQueryClient.d.ts +6 -0
- package/lib/clients/CarbonQueryClient.js +36 -30
- package/lib/clients/ETHClient.d.ts +11 -4
- package/lib/clients/ETHClient.js +32 -18
- package/lib/clients/HydrogenClient.d.ts +16 -7
- package/lib/clients/HydrogenClient.js +56 -10
- package/lib/clients/NEOClient.d.ts +1 -1
- package/lib/clients/NEOClient.js +15 -10
- package/lib/clients/TokenClient.d.ts +19 -4
- package/lib/clients/TokenClient.js +187 -10
- package/lib/clients/ZILClient.d.ts +1 -1
- package/lib/clients/ZILClient.js +25 -20
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/tx/v1beta1/tx.js +2 -2
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/keys.d.ts +39 -0
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/keys.js +138 -0
- package/lib/codec/ethermint/evm/v1/events.d.ts +72 -0
- package/lib/codec/ethermint/evm/v1/events.js +303 -0
- package/lib/codec/ethermint/evm/v1/evm.d.ts +239 -0
- package/lib/codec/ethermint/evm/v1/evm.js +1140 -0
- package/lib/codec/ethermint/evm/v1/genesis.d.ts +43 -0
- package/lib/codec/ethermint/evm/v1/genesis.js +153 -0
- package/lib/codec/ethermint/evm/v1/query.d.ts +424 -0
- package/lib/codec/ethermint/evm/v1/query.js +1637 -0
- package/lib/codec/ethermint/evm/v1/tx.d.ts +219 -0
- package/lib/codec/ethermint/evm/v1/tx.js +935 -0
- package/lib/codec/ethermint/feemarket/v1/events.d.ts +34 -0
- package/lib/codec/ethermint/feemarket/v1/events.js +116 -0
- package/lib/codec/ethermint/feemarket/v1/feemarket.d.ts +51 -0
- package/lib/codec/ethermint/feemarket/v1/feemarket.js +176 -0
- package/lib/codec/ethermint/feemarket/v1/genesis.d.ts +26 -0
- package/lib/codec/ethermint/feemarket/v1/genesis.js +79 -0
- package/lib/codec/ethermint/feemarket/v1/query.d.ts +100 -0
- package/lib/codec/ethermint/feemarket/v1/query.js +276 -0
- package/lib/codec/ethermint/feemarket/v1/tx.d.ts +55 -0
- package/lib/codec/ethermint/feemarket/v1/tx.js +120 -0
- package/lib/codec/ethermint/types/v1/account.d.ts +26 -0
- package/lib/codec/ethermint/types/v1/account.js +78 -0
- package/lib/codec/ethermint/types/v1/dynamic_fee.d.ts +20 -0
- package/lib/codec/ethermint/types/v1/dynamic_fee.js +60 -0
- package/lib/codec/ethermint/types/v1/indexer.d.ts +41 -0
- package/lib/codec/ethermint/types/v1/indexer.js +153 -0
- package/lib/codec/ethermint/types/v1/web3.d.ts +36 -0
- package/lib/codec/ethermint/types/v1/web3.js +124 -0
- package/lib/codec/evmbank/genesis.d.ts +32 -0
- package/lib/codec/evmbank/genesis.js +152 -0
- package/lib/codec/evmbank/query.d.ts +40 -0
- package/lib/codec/evmbank/query.js +116 -0
- package/lib/codec/evmmerge/event.d.ts +20 -0
- package/lib/codec/evmmerge/event.js +90 -0
- package/lib/codec/evmmerge/genesis.d.ts +48 -0
- package/lib/codec/evmmerge/genesis.js +216 -0
- package/lib/codec/evmmerge/offchain.d.ts +22 -0
- package/lib/codec/evmmerge/offchain.js +105 -0
- package/lib/codec/evmmerge/query.d.ts +43 -0
- package/lib/codec/evmmerge/query.js +117 -0
- package/lib/codec/evmmerge/tx.d.ts +45 -0
- package/lib/codec/evmmerge/tx.js +128 -0
- package/lib/constant/generic.js +1 -1
- package/lib/hydrogen/transfer.d.ts +5 -5
- package/lib/modules/cdp.js +43 -43
- package/lib/modules/cosmwasm.js +1 -1
- package/lib/modules/gov.js +12 -12
- package/lib/modules/liquiditypool.js +1 -1
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
- package/lib/provider/amino/types/admin.js +28 -28
- package/lib/provider/amino/types/bank.js +1 -1
- package/lib/provider/amino/types/broker.js +1 -1
- package/lib/provider/amino/types/cdp.js +22 -22
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/gov.js +4 -4
- package/lib/provider/amino/types/ibc.js +1 -1
- package/lib/provider/amino/types/leverage.js +1 -1
- package/lib/provider/amino/types/liquidityPool.js +7 -7
- package/lib/provider/amino/types/market.js +1 -1
- package/lib/provider/amino/types/oracle.js +1 -1
- package/lib/provider/amino/types/order.js +4 -4
- package/lib/provider/amino/types/position.js +1 -1
- package/lib/provider/amino/types/profile.js +1 -1
- package/lib/provider/amino/types/staking.js +4 -4
- package/lib/provider/amino/types/subaccount.js +3 -3
- package/lib/provider/amino/utils.js +11 -11
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.d.ts +5 -5
- package/lib/provider/metamask/MetaMask.js +35 -35
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +13 -13
- package/lib/util/api.js +4 -4
- package/lib/util/blockchain.d.ts +12 -0
- package/lib/util/blockchain.js +143 -1
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/ibc.d.ts +4 -4
- package/lib/util/ibc.js +17 -18
- package/lib/util/number.js +5 -5
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +8 -8
- package/lib/wallet/CarbonWallet.js +6 -6
- package/lib/websocket/connector.js +3 -3
- package/package.json +1 -1
package/lib/CarbonSDK.js
CHANGED
|
@@ -68,8 +68,8 @@ class CarbonSDK {
|
|
|
68
68
|
this.chainId = (_d = (_c = opts.chainId) !== null && _c !== void 0 ? _c : constant_1.CarbonChainIDs[this.network]) !== null && _d !== void 0 ? _d : constant_1.CarbonChainIDs[constant_1.Network.MainNet];
|
|
69
69
|
this.query = new clients_1.CarbonQueryClient(opts.tmClient);
|
|
70
70
|
this.insights = new clients_1.InsightsQueryClient(this.networkConfig);
|
|
71
|
-
this.hydrogen = new clients_1.HydrogenClient(this.networkConfig);
|
|
72
71
|
this.token = (_e = opts.token) !== null && _e !== void 0 ? _e : clients_1.TokenClient.instance(this.query, this);
|
|
72
|
+
this.hydrogen = clients_1.HydrogenClient.instance(this.networkConfig, this.token);
|
|
73
73
|
this.admin = new modules_1.AdminModule(this);
|
|
74
74
|
this.order = new modules_1.OrderModule(this);
|
|
75
75
|
this.lp = new modules_1.LiquidityPoolModule(this);
|
|
@@ -19,6 +19,9 @@ import { QueryClientImpl as HeadersyncQueryClient } from "../codec/headersync/qu
|
|
|
19
19
|
import { QueryClientImpl as IBCInterchainControlQueryClient } from "../codec/ibc/applications/interchain_accounts/controller/v1/query";
|
|
20
20
|
import { QueryClientImpl as IBCInterchainHostQueryClient } from "../codec/ibc/applications/interchain_accounts/host/v1/query";
|
|
21
21
|
import { QueryClientImpl as IBCTransferQueryClient } from "../codec/ibc/applications/transfer/v1/query";
|
|
22
|
+
import { QueryClientImpl as IBCClientQueryClient } from "../codec/ibc/core/client/v1/query";
|
|
23
|
+
import { QueryClientImpl as IBCConnectionQueryClient } from "../codec/ibc/core/connection/v1/query";
|
|
24
|
+
import { QueryClientImpl as IBCChannelQueryClient } from "../codec/ibc/core/channel/v1/query";
|
|
22
25
|
import { QueryClientImpl as InflationQueryClient } from "../codec/inflation/query";
|
|
23
26
|
import { QueryClientImpl as InsuranceQueryClient } from "../codec/insurance/query";
|
|
24
27
|
import { QueryClientImpl as LeverageQueryClient } from "../codec/leverage/query";
|
|
@@ -39,6 +42,9 @@ export interface IBCClientGroup {
|
|
|
39
42
|
controller: IBCInterchainControlQueryClient;
|
|
40
43
|
host: IBCInterchainHostQueryClient;
|
|
41
44
|
transfer: IBCTransferQueryClient;
|
|
45
|
+
client: IBCClientQueryClient;
|
|
46
|
+
connection: IBCConnectionQueryClient;
|
|
47
|
+
channel: IBCChannelQueryClient;
|
|
42
48
|
}
|
|
43
49
|
declare class CarbonQueryClient {
|
|
44
50
|
private readonly tmClient;
|
|
@@ -24,27 +24,30 @@ const query_18 = require("../codec/headersync/query");
|
|
|
24
24
|
const query_19 = require("../codec/ibc/applications/interchain_accounts/controller/v1/query");
|
|
25
25
|
const query_20 = require("../codec/ibc/applications/interchain_accounts/host/v1/query");
|
|
26
26
|
const query_21 = require("../codec/ibc/applications/transfer/v1/query");
|
|
27
|
-
const query_22 = require("../codec/
|
|
28
|
-
const query_23 = require("../codec/
|
|
29
|
-
const query_24 = require("../codec/
|
|
30
|
-
const query_25 = require("../codec/
|
|
31
|
-
const query_26 = require("../codec/
|
|
32
|
-
const query_27 = require("../codec/
|
|
33
|
-
const query_28 = require("../codec/
|
|
34
|
-
const query_29 = require("../codec/
|
|
35
|
-
const query_30 = require("../codec/
|
|
36
|
-
const query_31 = require("../codec/
|
|
37
|
-
const query_32 = require("../codec/
|
|
38
|
-
const query_33 = require("../codec/
|
|
39
|
-
const query_34 = require("../codec/
|
|
40
|
-
const query_35 = require("../codec/
|
|
27
|
+
const query_22 = require("../codec/ibc/core/client/v1/query");
|
|
28
|
+
const query_23 = require("../codec/ibc/core/connection/v1/query");
|
|
29
|
+
const query_24 = require("../codec/ibc/core/channel/v1/query");
|
|
30
|
+
const query_25 = require("../codec/inflation/query");
|
|
31
|
+
const query_26 = require("../codec/insurance/query");
|
|
32
|
+
const query_27 = require("../codec/leverage/query");
|
|
33
|
+
const query_28 = require("../codec/liquidation/query");
|
|
34
|
+
const query_29 = require("../codec/liquiditypool/query");
|
|
35
|
+
const query_30 = require("../codec/market/query");
|
|
36
|
+
const query_31 = require("../codec/marketstats/query");
|
|
37
|
+
const query_32 = require("../codec/misc/query");
|
|
38
|
+
const query_33 = require("../codec/oracle/query");
|
|
39
|
+
const query_34 = require("../codec/order/query");
|
|
40
|
+
const query_35 = require("../codec/position/query");
|
|
41
|
+
const query_36 = require("../codec/pricing/query");
|
|
42
|
+
const query_37 = require("../codec/profile/query");
|
|
43
|
+
const query_38 = require("../codec/subaccount/query");
|
|
41
44
|
const stargate_1 = require("@cosmjs/stargate");
|
|
42
45
|
const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
|
|
43
46
|
class CarbonQueryClient {
|
|
44
47
|
constructor(tmClient) {
|
|
45
48
|
this.tmClient = tmClient;
|
|
46
49
|
this.baseClient = new stargate_1.QueryClient(this.tmClient);
|
|
47
|
-
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
50
|
+
const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
48
51
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
49
52
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
50
53
|
this.book = new query_2.QueryClientImpl(rpcClient);
|
|
@@ -52,20 +55,20 @@ class CarbonQueryClient {
|
|
|
52
55
|
this.coin = new query_5.QueryClientImpl(rpcClient);
|
|
53
56
|
this.cdp = new query_4.QueryClientImpl(rpcClient);
|
|
54
57
|
this.fee = new query_17.QueryClientImpl(rpcClient);
|
|
55
|
-
this.inflation = new
|
|
56
|
-
this.insurance = new
|
|
57
|
-
this.leverage = new
|
|
58
|
-
this.liquidation = new
|
|
59
|
-
this.liquiditypool = new
|
|
60
|
-
this.market = new
|
|
61
|
-
this.marketstats = new
|
|
62
|
-
this.misc = new
|
|
63
|
-
this.oracle = new
|
|
64
|
-
this.order = new
|
|
65
|
-
this.position = new
|
|
66
|
-
this.pricing = new
|
|
67
|
-
this.profile = new
|
|
68
|
-
this.subaccount = new
|
|
58
|
+
this.inflation = new query_25.QueryClientImpl(rpcClient);
|
|
59
|
+
this.insurance = new query_26.QueryClientImpl(rpcClient);
|
|
60
|
+
this.leverage = new query_27.QueryClientImpl(rpcClient);
|
|
61
|
+
this.liquidation = new query_28.QueryClientImpl(rpcClient);
|
|
62
|
+
this.liquiditypool = new query_29.QueryClientImpl(rpcClient);
|
|
63
|
+
this.market = new query_30.QueryClientImpl(rpcClient);
|
|
64
|
+
this.marketstats = new query_31.QueryClientImpl(rpcClient);
|
|
65
|
+
this.misc = new query_32.QueryClientImpl(rpcClient);
|
|
66
|
+
this.oracle = new query_33.QueryClientImpl(rpcClient);
|
|
67
|
+
this.order = new query_34.QueryClientImpl(rpcClient);
|
|
68
|
+
this.position = new query_35.QueryClientImpl(rpcClient);
|
|
69
|
+
this.pricing = new query_36.QueryClientImpl(rpcClient);
|
|
70
|
+
this.profile = new query_37.QueryClientImpl(rpcClient);
|
|
71
|
+
this.subaccount = new query_38.QueryClientImpl(rpcClient);
|
|
69
72
|
this.headersync = new query_18.QueryClientImpl(rpcClient);
|
|
70
73
|
this.auth = new query_6.QueryClientImpl(rpcClient);
|
|
71
74
|
this.bank = new query_7.QueryClientImpl(rpcClient);
|
|
@@ -82,10 +85,13 @@ class CarbonQueryClient {
|
|
|
82
85
|
controller: new query_19.QueryClientImpl(rpcClient),
|
|
83
86
|
host: new query_20.QueryClientImpl(rpcClient),
|
|
84
87
|
transfer: new query_21.QueryClientImpl(rpcClient),
|
|
88
|
+
client: new query_22.QueryClientImpl(rpcClient),
|
|
89
|
+
connection: new query_23.QueryClientImpl(rpcClient),
|
|
90
|
+
channel: new query_24.QueryClientImpl(rpcClient),
|
|
85
91
|
};
|
|
86
92
|
}
|
|
87
93
|
getProtobufRpcClient() {
|
|
88
|
-
return stargate_1.createProtobufRpcClient(this.baseClient);
|
|
94
|
+
return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
exports.default = CarbonQueryClient;
|
|
@@ -9,7 +9,7 @@ import TokenClient from "./TokenClient";
|
|
|
9
9
|
export interface ETHClientOpts {
|
|
10
10
|
configProvider: NetworkConfigProvider;
|
|
11
11
|
tokenClient: TokenClient;
|
|
12
|
-
blockchain:
|
|
12
|
+
blockchain: typeof ETHClient.SUPPORTED_BLOCKCHAINS[number];
|
|
13
13
|
}
|
|
14
14
|
interface ETHTxParams {
|
|
15
15
|
gasPriceGwei: BigNumber;
|
|
@@ -47,9 +47,9 @@ export interface EthersTransactionResponse extends ethers.Transaction {
|
|
|
47
47
|
export declare const FEE_MULTIPLIER: ethers.BigNumber;
|
|
48
48
|
export declare class ETHClient {
|
|
49
49
|
readonly configProvider: NetworkConfigProvider;
|
|
50
|
-
readonly blockchain:
|
|
50
|
+
readonly blockchain: typeof ETHClient.SUPPORTED_BLOCKCHAINS[number];
|
|
51
51
|
readonly tokenClient: TokenClient;
|
|
52
|
-
static SUPPORTED_BLOCKCHAINS: Blockchain
|
|
52
|
+
static SUPPORTED_BLOCKCHAINS: readonly [Blockchain.BinanceSmartChain, Blockchain.Ethereum, Blockchain.Arbitrum, Blockchain.Polygon, Blockchain.Okc];
|
|
53
53
|
static BLOCKCHAIN_KEY: {
|
|
54
54
|
bsc: string;
|
|
55
55
|
eth: string;
|
|
@@ -57,9 +57,16 @@ export declare class ETHClient {
|
|
|
57
57
|
polygon: string;
|
|
58
58
|
okc: string;
|
|
59
59
|
};
|
|
60
|
+
static BLOCKCHAINV2_MAPPING: {
|
|
61
|
+
bsc: string;
|
|
62
|
+
eth: string;
|
|
63
|
+
arbitrum: string;
|
|
64
|
+
polygon: string;
|
|
65
|
+
okc: string;
|
|
66
|
+
};
|
|
60
67
|
private constructor();
|
|
61
68
|
static instance(opts: ETHClientOpts): CarbonSDK.ETHClient;
|
|
62
|
-
getExternalBalances(api: CarbonSDK, address: string, whitelistDenoms?: string[]): Promise<TokensWithExternalBalance[]>;
|
|
69
|
+
getExternalBalances(api: CarbonSDK, address: string, whitelistDenoms?: string[], version?: string): Promise<TokensWithExternalBalance[]>;
|
|
63
70
|
approveERC20(params: ApproveERC20Params): Promise<EthersTransactionResponse>;
|
|
64
71
|
checkAllowanceERC20(token: Models.Token, owner: string, spender: string): Promise<BigNumber>;
|
|
65
72
|
bridgeTokens(params: BridgeParams): Promise<EthersTransactionResponse>;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -35,17 +35,24 @@ class ETHClient {
|
|
|
35
35
|
throw new Error(`unsupported blockchain - ${blockchain}`);
|
|
36
36
|
return new ETHClient(configProvider, blockchain, tokenClient);
|
|
37
37
|
}
|
|
38
|
-
getExternalBalances(api, address, whitelistDenoms) {
|
|
38
|
+
getExternalBalances(api, address, whitelistDenoms, version = "V1") {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const tokenQueryResults = yield api.token.getAllTokens();
|
|
41
41
|
const lockProxyAddress = this.getLockProxyAddress().toLowerCase();
|
|
42
|
-
const tokens = tokenQueryResults.filter((token) =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const tokens = tokenQueryResults.filter((token) => {
|
|
43
|
+
const isCorrectBlockchain = version === "V2"
|
|
44
|
+
?
|
|
45
|
+
this.tokenClient.getBlockchainV2(token.denom) == ETHClient.BLOCKCHAINV2_MAPPING[this.blockchain]
|
|
46
|
+
:
|
|
47
|
+
(0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), api.network) == this.blockchain;
|
|
48
|
+
return isCorrectBlockchain &&
|
|
49
|
+
token.tokenAddress.length == 40 &&
|
|
50
|
+
token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
|
|
51
|
+
(!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
|
|
52
|
+
this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
53
|
+
});
|
|
47
54
|
const assetIds = tokens.map((token) => {
|
|
48
|
-
return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
55
|
+
return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
49
56
|
});
|
|
50
57
|
const provider = this.getProvider();
|
|
51
58
|
const contractAddress = this.getBalanceReaderAddress();
|
|
@@ -96,14 +103,14 @@ class ETHClient {
|
|
|
96
103
|
}
|
|
97
104
|
const carbonNetwork = networkConfig.network;
|
|
98
105
|
const fromTokenId = fromToken.id;
|
|
99
|
-
const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
106
|
+
const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
100
107
|
const toTokenDenom = toToken.denom;
|
|
101
108
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
102
109
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
103
110
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
104
111
|
const nonce = yield rpcProvider.getTransactionCount(fromAddress);
|
|
105
112
|
const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
|
|
106
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
113
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
107
114
|
const tokenCreator = fromToken.creator;
|
|
108
115
|
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, carbonNetwork);
|
|
109
116
|
const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
|
|
@@ -138,9 +145,9 @@ class ETHClient {
|
|
|
138
145
|
throw new Error("Minimum gas required: 150,000");
|
|
139
146
|
}
|
|
140
147
|
const networkConfig = this.getNetworkConfig();
|
|
141
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
142
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
143
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
148
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
149
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
150
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
144
151
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
145
152
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
146
153
|
const contractAddress = this.getLockProxyAddress();
|
|
@@ -191,16 +198,16 @@ class ETHClient {
|
|
|
191
198
|
return "insufficient balance";
|
|
192
199
|
}
|
|
193
200
|
const networkConfig = this.getNetworkConfig();
|
|
194
|
-
const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
|
|
195
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
196
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
201
|
+
const assetId = (0, generic_1.appendHexPrefix)(tokenWithExternalBalances.tokenAddress);
|
|
202
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
203
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
197
204
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
|
|
198
205
|
const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
|
|
199
206
|
const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
|
|
200
207
|
// logger("sendDeposit message", message)
|
|
201
208
|
let signatureResult;
|
|
202
209
|
const { address, signature } = yield getSignatureCallback(message);
|
|
203
|
-
const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
|
|
210
|
+
const signatureBytes = ethers_1.ethers.utils.arrayify((0, generic_1.appendHexPrefix)(signature));
|
|
204
211
|
const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
|
|
205
212
|
// logger("sign result", address, signature)
|
|
206
213
|
signatureResult = {
|
|
@@ -239,7 +246,7 @@ class ETHClient {
|
|
|
239
246
|
if (!feeInfo.deposit_fee) {
|
|
240
247
|
throw new Error("unsupported token");
|
|
241
248
|
}
|
|
242
|
-
if (blockchain_1.blockchainForChainId(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
249
|
+
if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
243
250
|
throw new Error("unsupported token");
|
|
244
251
|
}
|
|
245
252
|
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
|
|
@@ -305,7 +312,7 @@ class ETHClient {
|
|
|
305
312
|
getTargetProxyHash(token) {
|
|
306
313
|
const networkConfig = this.getNetworkConfig();
|
|
307
314
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
308
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
315
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
309
316
|
return addressHex;
|
|
310
317
|
}
|
|
311
318
|
getProvider() {
|
|
@@ -358,4 +365,11 @@ ETHClient.BLOCKCHAIN_KEY = {
|
|
|
358
365
|
[blockchain_1.Blockchain.Polygon]: "polygon",
|
|
359
366
|
[blockchain_1.Blockchain.Okc]: "okc",
|
|
360
367
|
};
|
|
368
|
+
ETHClient.BLOCKCHAINV2_MAPPING = {
|
|
369
|
+
[blockchain_1.Blockchain.BinanceSmartChain]: "Binance Smart Chain",
|
|
370
|
+
[blockchain_1.Blockchain.Ethereum]: "Ethereum",
|
|
371
|
+
[blockchain_1.Blockchain.Arbitrum]: "Arbitrum",
|
|
372
|
+
[blockchain_1.Blockchain.Polygon]: "Polygon",
|
|
373
|
+
[blockchain_1.Blockchain.Okc]: "Okc",
|
|
374
|
+
};
|
|
361
375
|
exports.default = ETHClient;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NetworkConfig } from "../constant";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { BlockchainUtils } from "../util";
|
|
3
|
+
import { ChainTransaction, CrossChainTransfer, CrossChainTransferDetailed, GetDetailedTransfersResponse, GetRelaysRequest, GetRelaysResponse, GetStatsResponse, GetTransfersRequest, GetTransfersResponse, RelaysResponse } from "../hydrogen";
|
|
4
|
+
import { FeeQuote, GetFeeQuoteRequest, GetFeeQuoteResponse } from "../hydrogen/feeQuote";
|
|
5
|
+
import TokenClient from './TokenClient';
|
|
4
6
|
export declare const HydrogenEndpoints: {
|
|
5
7
|
stats: string;
|
|
6
8
|
transfer_payloads: string;
|
|
@@ -10,12 +12,19 @@ export declare const HydrogenEndpoints: {
|
|
|
10
12
|
declare class HydrogenClient {
|
|
11
13
|
private config;
|
|
12
14
|
private readonly apiManager;
|
|
13
|
-
|
|
15
|
+
private readonly tokenClient;
|
|
16
|
+
constructor(config: NetworkConfig, tokenClient: TokenClient);
|
|
17
|
+
static instance(config: NetworkConfig, tokenClient: TokenClient): HydrogenClient;
|
|
14
18
|
checkState(): void;
|
|
19
|
+
formatCrossChainTransferV2: (value: any) => CrossChainTransfer;
|
|
20
|
+
formatCrossChainTransferDetailedV2: (value: any) => CrossChainTransferDetailed;
|
|
21
|
+
formatRelaysTransfersV2: (value: any) => RelaysResponse;
|
|
22
|
+
formatChainEventV2: (value: any, blockchain: BlockchainUtils.BlockchainV2) => ChainTransaction | null;
|
|
23
|
+
formatFeeQuoteV2: (value: any, blockchain: BlockchainUtils.BlockchainV2) => FeeQuote;
|
|
15
24
|
getStats(): Promise<GetStatsResponse>;
|
|
16
|
-
getTransfers(req: GetTransfersRequest): Promise<GetTransfersResponse>;
|
|
17
|
-
getDetailedTransfers(req: GetTransfersRequest): Promise<GetDetailedTransfersResponse>;
|
|
18
|
-
getRelaysTransfers(req: GetRelaysRequest): Promise<GetRelaysResponse>;
|
|
19
|
-
getFeeQuote(req: GetFeeQuoteRequest): Promise<GetFeeQuoteResponse>;
|
|
25
|
+
getTransfers(req: GetTransfersRequest, version?: string): Promise<GetTransfersResponse>;
|
|
26
|
+
getDetailedTransfers(req: GetTransfersRequest, version?: string): Promise<GetDetailedTransfersResponse>;
|
|
27
|
+
getRelaysTransfers(req: GetRelaysRequest, version?: string): Promise<GetRelaysResponse>;
|
|
28
|
+
getFeeQuote(req: GetFeeQuoteRequest, blockchain?: BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2 | undefined, version?: string): Promise<GetFeeQuoteResponse>;
|
|
20
29
|
}
|
|
21
30
|
export default HydrogenClient;
|
|
@@ -29,7 +29,7 @@ exports.HydrogenEndpoints = {
|
|
|
29
29
|
const formatDateField = (value) => {
|
|
30
30
|
if (typeof value !== "string")
|
|
31
31
|
return null;
|
|
32
|
-
return dayjs_1.default(value);
|
|
32
|
+
return (0, dayjs_1.default)(value);
|
|
33
33
|
};
|
|
34
34
|
const formatCrossChainTransfer = (value) => {
|
|
35
35
|
var _a, _b;
|
|
@@ -60,10 +60,56 @@ const formatFeeQuote = (value) => {
|
|
|
60
60
|
return value;
|
|
61
61
|
return Object.assign(Object.assign({}, value), { blockchain: util_1.BlockchainUtils.parseBlockchain(value.blockchain), created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), expires_at: formatDateField((_b = value.expires_at) === null || _b === void 0 ? void 0 : _b.toString()) });
|
|
62
62
|
};
|
|
63
|
+
const getBridgeBlockchainFromId = (bridgeId) => {
|
|
64
|
+
switch (bridgeId) {
|
|
65
|
+
case 1:
|
|
66
|
+
return 'Polynetwork';
|
|
67
|
+
case 2:
|
|
68
|
+
return 'Ibc';
|
|
69
|
+
default:
|
|
70
|
+
return 'Polynetwork';
|
|
71
|
+
}
|
|
72
|
+
};
|
|
63
73
|
class HydrogenClient {
|
|
64
|
-
constructor(config) {
|
|
74
|
+
constructor(config, tokenClient) {
|
|
65
75
|
this.config = config;
|
|
76
|
+
this.formatCrossChainTransferV2 = (value) => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
if (typeof value !== "object")
|
|
79
|
+
return value;
|
|
80
|
+
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()), source_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.from_chain_id, value.bridge_id), bridging_blockchain: getBridgeBlockchainFromId(value.bridge_id), destination_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.to_chain_id, value.bridge_id) });
|
|
81
|
+
};
|
|
82
|
+
this.formatCrossChainTransferDetailedV2 = (value) => {
|
|
83
|
+
if (!value || typeof value !== "object")
|
|
84
|
+
return value;
|
|
85
|
+
const source_blockchain = this.tokenClient.getBlockchainV2FromIDs(value.from_chain_id, value.bridge_id);
|
|
86
|
+
const destination_blockchain = this.tokenClient.getBlockchainV2FromIDs(value.to_chain_id, value.bridge_id);
|
|
87
|
+
const bridging_blockchain = getBridgeBlockchainFromId(value.bridge_id);
|
|
88
|
+
return Object.assign(Object.assign({}, this.formatCrossChainTransferV2(value)), { source_event: this.formatChainEventV2(value.source_event, source_blockchain !== null && source_blockchain !== void 0 ? source_blockchain : ''), bridging_event: this.formatChainEventV2(value.bridging_event, bridging_blockchain), destination_event: this.formatChainEventV2(value.destination_event, destination_blockchain !== null && destination_blockchain !== void 0 ? destination_blockchain : '') });
|
|
89
|
+
};
|
|
90
|
+
this.formatRelaysTransfersV2 = (value) => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
if (!value || typeof value !== "object")
|
|
93
|
+
return value;
|
|
94
|
+
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()), source_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.from_chain_id, value.bridge_id), bridging_blockchain: getBridgeBlockchainFromId(value.bridge_id), destination_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.to_chain_id, value.bridge_id) });
|
|
95
|
+
};
|
|
96
|
+
this.formatChainEventV2 = (value, blockchain) => {
|
|
97
|
+
var _a, _b, _c;
|
|
98
|
+
if (!value || typeof value !== "object")
|
|
99
|
+
return value;
|
|
100
|
+
return Object.assign(Object.assign({}, value), { confirmed_at: formatDateField((_a = value.confirmed_at) === null || _a === void 0 ? void 0 : _a.toString()), created_at: formatDateField((_b = value.created_at) === null || _b === void 0 ? void 0 : _b.toString()), updated_at: formatDateField((_c = value.updated_at) === null || _c === void 0 ? void 0 : _c.toString()), blockchain });
|
|
101
|
+
};
|
|
102
|
+
this.formatFeeQuoteV2 = (value, blockchain) => {
|
|
103
|
+
var _a, _b;
|
|
104
|
+
if (typeof value !== "object")
|
|
105
|
+
return value;
|
|
106
|
+
return Object.assign(Object.assign({}, value), { blockchain, created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), expires_at: formatDateField((_b = value.expires_at) === null || _b === void 0 ? void 0 : _b.toString()) });
|
|
107
|
+
};
|
|
66
108
|
this.apiManager = new util_1.APIUtils.APIManager(config.hydrogenUrl, exports.HydrogenEndpoints);
|
|
109
|
+
this.tokenClient = tokenClient;
|
|
110
|
+
}
|
|
111
|
+
static instance(config, tokenClient) {
|
|
112
|
+
return new HydrogenClient(config, tokenClient);
|
|
67
113
|
}
|
|
68
114
|
checkState() {
|
|
69
115
|
var _a;
|
|
@@ -82,40 +128,40 @@ class HydrogenClient {
|
|
|
82
128
|
return response.data;
|
|
83
129
|
});
|
|
84
130
|
}
|
|
85
|
-
getTransfers(req) {
|
|
131
|
+
getTransfers(req, version = "V1") {
|
|
86
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
133
|
this.checkState();
|
|
88
134
|
const request = this.apiManager.path("transfer_payloads", {}, Object.assign(Object.assign({}, req), { include_tx: false }));
|
|
89
135
|
const response = yield request.get();
|
|
90
136
|
const result = response.data;
|
|
91
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(formatCrossChainTransfer) });
|
|
137
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(version === "V1" ? formatCrossChainTransfer : this.formatCrossChainTransferV2) });
|
|
92
138
|
});
|
|
93
139
|
}
|
|
94
|
-
getDetailedTransfers(req) {
|
|
140
|
+
getDetailedTransfers(req, version = "V1") {
|
|
95
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
142
|
this.checkState();
|
|
97
143
|
const request = this.apiManager.path("transfer_payloads", {}, Object.assign(Object.assign({}, req), { include_tx: true }));
|
|
98
144
|
const response = yield request.get();
|
|
99
145
|
const result = response.data;
|
|
100
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(formatCrossChainTransferDetailed) });
|
|
146
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(version === "V1" ? formatCrossChainTransferDetailed : this.formatCrossChainTransferDetailedV2) });
|
|
101
147
|
});
|
|
102
148
|
}
|
|
103
|
-
getRelaysTransfers(req) {
|
|
149
|
+
getRelaysTransfers(req, version = "V1") {
|
|
104
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
151
|
this.checkState();
|
|
106
152
|
const request = this.apiManager.path("relays", {}, Object.assign(Object.assign({}, req), { include_tx: true }));
|
|
107
153
|
const response = yield request.get();
|
|
108
154
|
const result = response.data;
|
|
109
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(formatRelaysTransfers) });
|
|
155
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(version === "V1" ? formatRelaysTransfers : this.formatRelaysTransfersV2) });
|
|
110
156
|
});
|
|
111
157
|
}
|
|
112
|
-
getFeeQuote(req) {
|
|
158
|
+
getFeeQuote(req, blockchain = undefined, version = "V1") {
|
|
113
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
160
|
this.checkState();
|
|
115
161
|
const request = this.apiManager.path("fee_quote", {}, Object.assign({}, req));
|
|
116
162
|
const response = yield request.get();
|
|
117
163
|
const result = response.data;
|
|
118
|
-
return formatFeeQuote(result);
|
|
164
|
+
return version === "V1" ? formatFeeQuote(result) : this.formatFeeQuoteV2(result, blockchain);
|
|
119
165
|
});
|
|
120
166
|
}
|
|
121
167
|
}
|
|
@@ -36,7 +36,7 @@ export declare class NEOClient {
|
|
|
36
36
|
private constructor();
|
|
37
37
|
static instance(opts: NEOClientOpts): CarbonSDK.NEOClient;
|
|
38
38
|
static parseHexNum(hex: string, exp?: number): string;
|
|
39
|
-
getExternalBalances(sdk: CarbonSDK, address: string, url: string, whitelistDenoms?: string[]): Promise<TokensWithExternalBalance[]>;
|
|
39
|
+
getExternalBalances(sdk: CarbonSDK, address: string, url: string, whitelistDenoms?: string[], version?: string): Promise<TokensWithExternalBalance[]>;
|
|
40
40
|
lockDeposit(token: TokensWithExternalBalance, feeAmountInput: string, swthAddress: string, neoPrivateKey: string): Promise<false | import("@cityofzion/neon-api/lib/funcs/types").DoInvokeConfig>;
|
|
41
41
|
lockO3Deposit(params: LockO3DepositParams): Promise<any>;
|
|
42
42
|
lockLedgerDeposit(params: LockLedgerDepositParams): Promise<any>;
|
package/lib/clients/NEOClient.js
CHANGED
|
@@ -60,17 +60,22 @@ class NEOClient {
|
|
|
60
60
|
const res = hex.length % 2 !== 0 ? `0${hex}` : hex;
|
|
61
61
|
return new bignumber_js_1.default(res ? Neon.u.reverseHex(res) : "00", 16).shiftedBy(-exp).toString();
|
|
62
62
|
}
|
|
63
|
-
getExternalBalances(sdk, address, url, whitelistDenoms) {
|
|
63
|
+
getExternalBalances(sdk, address, url, whitelistDenoms, version = "V1") {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
66
66
|
const account = new Neon.wallet.Account(address);
|
|
67
|
-
const tokens = tokenQueryResults.filter((token) =>
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const tokens = tokenQueryResults.filter((token) => {
|
|
68
|
+
const isCorrectBlockchain = version === "V2"
|
|
69
|
+
?
|
|
70
|
+
sdk.token.getBlockchainV2(token.denom) == this.blockchain
|
|
71
|
+
:
|
|
72
|
+
(0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), sdk.network) == this.blockchain;
|
|
73
|
+
return isCorrectBlockchain && token.tokenAddress.length == 40 && token.bridgeAddress.length == 40;
|
|
74
|
+
});
|
|
70
75
|
const client = new Neon.rpc.RPCClient(url, "2.5.2"); // TODO: should we change the RPC version??
|
|
71
76
|
// NOTE: fetching of tokens is chunked in sets of 15 as we may hit
|
|
72
77
|
// the gas limit on the RPC node and error out otherwise
|
|
73
|
-
const promises = lodash_1.chunk(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const promises = (0, lodash_1.chunk)(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
|
|
74
79
|
var _a, _b, _c;
|
|
75
80
|
let acc = {};
|
|
76
81
|
for (const token of partition) {
|
|
@@ -112,8 +117,8 @@ class NEOClient {
|
|
|
112
117
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
113
118
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
114
119
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(swthAddress, networkConfig.network);
|
|
115
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
116
|
-
const zeroAddressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(constant_1.ZeroAddress));
|
|
120
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
121
|
+
const zeroAddressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(constant_1.ZeroAddress));
|
|
117
122
|
const amount = ethers_1.ethers.BigNumber.from(token.externalBalance);
|
|
118
123
|
const feeAmount = ethers_1.ethers.BigNumber.from(feeAmountInput !== null && feeAmountInput !== void 0 ? feeAmountInput : "100000000");
|
|
119
124
|
const feeAddress = feeAmount.isZero() ? zeroAddressHex : networkConfig.feeAddress;
|
|
@@ -160,7 +165,7 @@ class NEOClient {
|
|
|
160
165
|
const fromAddress = util_1.AddressUtils.NEOAddress.publicKeyToAddress(publicKeyOutput.publicKey);
|
|
161
166
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
162
167
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
163
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
168
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
164
169
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
165
170
|
if (amount.lt(feeAmount)) {
|
|
166
171
|
throw new Error("Invalid amount");
|
|
@@ -196,7 +201,7 @@ class NEOClient {
|
|
|
196
201
|
const fromAddress = ledger.scriptHash;
|
|
197
202
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
198
203
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
199
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
204
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
200
205
|
const feeAddress = networkConfig.feeAddress;
|
|
201
206
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
202
207
|
if (amount.lt(feeAmount)) {
|
|
@@ -316,7 +321,7 @@ class NEOClient {
|
|
|
316
321
|
getTargetProxyHash(token) {
|
|
317
322
|
const networkConfig = this.getNetworkConfig();
|
|
318
323
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
319
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
324
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
320
325
|
return addressHex;
|
|
321
326
|
}
|
|
322
327
|
getNetworkConfig() {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Token, TokenPrice } from "../codec";
|
|
1
|
+
import { Bridge, Token, TokenPrice } from "../codec";
|
|
2
2
|
import { NetworkConfigProvider } from "../constant";
|
|
3
3
|
import { FeeQuote } from "../hydrogen/feeQuote";
|
|
4
4
|
import { BlockchainUtils, TypeUtils } from "../util";
|
|
5
5
|
import BigNumber from "bignumber.js";
|
|
6
6
|
import CarbonQueryClient from "./CarbonQueryClient";
|
|
7
|
+
import { BlockchainV2, BridgeMap, ChainIdName } from '../util/blockchain';
|
|
7
8
|
declare class TokenClient {
|
|
8
9
|
readonly query: CarbonQueryClient;
|
|
9
10
|
readonly configProvider: NetworkConfigProvider;
|
|
@@ -12,6 +13,7 @@ declare class TokenClient {
|
|
|
12
13
|
readonly wrapperMap: TypeUtils.SimpleMap<string>;
|
|
13
14
|
readonly poolTokens: TypeUtils.SimpleMap<Token>;
|
|
14
15
|
readonly cdpTokens: TypeUtils.SimpleMap<Token>;
|
|
16
|
+
readonly bridges: BridgeMap;
|
|
15
17
|
readonly symbols: TypeUtils.SimpleMap<string>;
|
|
16
18
|
readonly usdValues: TypeUtils.SimpleMap<BigNumber>;
|
|
17
19
|
readonly commonAssetNames: TypeUtils.SimpleMap<string>;
|
|
@@ -23,7 +25,8 @@ declare class TokenClient {
|
|
|
23
25
|
registerGeckoIdMap(map: TypeUtils.SimpleMap<string>): void;
|
|
24
26
|
getCommonDenom(denom: string): string;
|
|
25
27
|
getDecimals(denom: string): number | undefined;
|
|
26
|
-
getBlockchain(denom: string): BlockchainUtils.Blockchain | undefined;
|
|
28
|
+
getBlockchain(denom: string): BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2 | undefined;
|
|
29
|
+
getBlockchainV2(denom: string | undefined): BlockchainUtils.BlockchainV2 | undefined;
|
|
27
30
|
getSymbol(denom: string): string;
|
|
28
31
|
getUSDValue(denom: string): BigNumber | undefined;
|
|
29
32
|
toHuman(denom: string, unitlessAmt: BigNumber): BigNumber;
|
|
@@ -42,15 +45,27 @@ declare class TokenClient {
|
|
|
42
45
|
isWrappedToken(denom?: string): boolean;
|
|
43
46
|
hasWrappedToken(denom?: string): boolean;
|
|
44
47
|
getWrappedTokens(denom: string): Token[];
|
|
45
|
-
getWrappedToken(denom: string, blockchain?: BlockchainUtils.Blockchain): Token | null;
|
|
48
|
+
getWrappedToken(denom: string, blockchain?: BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2, version?: string): Token | null;
|
|
46
49
|
getSourceToken(denom: string): Token | null;
|
|
47
50
|
getNativeToken(): Token | undefined;
|
|
48
51
|
getNativeStablecoin(): Token | undefined;
|
|
49
52
|
isNativeToken(denom: string): boolean;
|
|
50
53
|
isNativeStablecoin(denom: string): boolean;
|
|
51
|
-
|
|
54
|
+
isGroupedToken(denom: string): boolean;
|
|
55
|
+
getDepositTokenFor(tokenDenom: string, chain: BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2, version?: string): Token | undefined;
|
|
52
56
|
getAllTokens(): Promise<Token[]>;
|
|
53
57
|
reloadTokens(): Promise<TypeUtils.SimpleMap<Token>>;
|
|
58
|
+
getBridges(): Promise<BridgeMap>;
|
|
59
|
+
matchChainsWithDifferentChainIds(bridges: Bridge[]): Promise<(Bridge & ChainIdName)[]>;
|
|
60
|
+
getIbcBlockchainNames(): string[];
|
|
61
|
+
getIbcChainFromBlockchainV2: (blockchain: BlockchainV2 | undefined) => string | undefined;
|
|
62
|
+
getPolynetworkBlockchainNames(): string[];
|
|
63
|
+
getAllBlockchainNames(): string[];
|
|
64
|
+
getBridgesFromBridgeId(bridgeId: number): Bridge[];
|
|
65
|
+
getIbcTokens(): TypeUtils.SimpleMap<Token>;
|
|
66
|
+
getPolyNetworkTokens(): TypeUtils.SimpleMap<Token>;
|
|
67
|
+
getBlockchainV2FromIDs(chainId: string, bridgeId: string): BlockchainV2 | undefined;
|
|
68
|
+
getBridgeFromToken(token: Token | undefined): Bridge | undefined;
|
|
54
69
|
getCarbonIbcTokens(): Token[];
|
|
55
70
|
getCdpUnderlyingToken(cdpDenom: string): Token | undefined;
|
|
56
71
|
reloadWrapperMap(): Promise<TypeUtils.SimpleMap<string>>;
|