carbon-js-sdk 0.4.6 → 0.4.7
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/ETHClient.d.ts +11 -4
- package/lib/clients/ETHClient.js +20 -6
- package/lib/clients/HydrogenClient.d.ts +16 -7
- package/lib/clients/HydrogenClient.js +55 -9
- package/lib/clients/NEOClient.d.ts +1 -1
- package/lib/clients/NEOClient.js +9 -4
- package/lib/clients/TokenClient.d.ts +29 -5
- package/lib/clients/TokenClient.js +257 -52
- package/lib/clients/ZILClient.d.ts +1 -1
- package/lib/clients/ZILClient.js +9 -4
- package/lib/codec/ethermint-models.d.ts +1 -1
- package/lib/codec/ethermint-models.js +2 -2
- package/lib/codec/index.d.ts +2 -2
- package/lib/codec/index.js +2 -2
- package/lib/constant/ibc.d.ts +7 -0
- package/lib/constant/ibc.js +4 -1
- package/lib/constant/network.d.ts +2 -0
- package/lib/constant/network.js +5 -1
- package/lib/hydrogen/transfer.d.ts +5 -5
- package/lib/modules/ibc.d.ts +5 -1
- package/lib/modules/ibc.js +78 -0
- package/lib/provider/keplr/KeplrStore.d.ts +1 -1
- package/lib/provider/keplr/KeplrStore.js +2 -5
- package/lib/provider/metamask/MetaMask.d.ts +5 -5
- package/lib/provider/metamask/MetaMask.js +37 -37
- package/lib/util/blockchain.d.ts +26 -0
- package/lib/util/blockchain.js +160 -1
- package/lib/util/ibc.d.ts +5 -3
- package/lib/util/ibc.js +26 -1
- package/lib/util/tx.d.ts +2 -2
- 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);
|
|
@@ -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,15 +35,22 @@ 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
|
+
blockchain_1.blockchainForChainId(token.chainId.toNumber(), api.network) == this.blockchain;
|
|
48
|
+
return isCorrectBlockchain &&
|
|
49
|
+
token.tokenAddress.length == 40 &&
|
|
50
|
+
token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
|
|
51
|
+
(!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
|
|
52
|
+
this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
53
|
+
});
|
|
47
54
|
const assetIds = tokens.map((token) => {
|
|
48
55
|
return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
49
56
|
});
|
|
@@ -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;
|
|
@@ -67,10 +67,56 @@ const formatFeeQuote = (value) => {
|
|
|
67
67
|
return value;
|
|
68
68
|
return Object.assign(Object.assign({}, value), { blockchain: parseHydrogenBlockchain(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()) });
|
|
69
69
|
};
|
|
70
|
+
const getBridgeBlockchainFromId = (bridgeId) => {
|
|
71
|
+
switch (bridgeId) {
|
|
72
|
+
case 1:
|
|
73
|
+
return 'Polynetwork';
|
|
74
|
+
case 2:
|
|
75
|
+
return 'Ibc';
|
|
76
|
+
default:
|
|
77
|
+
return 'Polynetwork';
|
|
78
|
+
}
|
|
79
|
+
};
|
|
70
80
|
class HydrogenClient {
|
|
71
|
-
constructor(config) {
|
|
81
|
+
constructor(config, tokenClient) {
|
|
72
82
|
this.config = config;
|
|
83
|
+
this.formatCrossChainTransferV2 = (value) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
if (typeof value !== "object")
|
|
86
|
+
return value;
|
|
87
|
+
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) });
|
|
88
|
+
};
|
|
89
|
+
this.formatCrossChainTransferDetailedV2 = (value) => {
|
|
90
|
+
if (!value || typeof value !== "object")
|
|
91
|
+
return value;
|
|
92
|
+
const source_blockchain = this.tokenClient.getBlockchainV2FromIDs(value.from_chain_id, value.bridge_id);
|
|
93
|
+
const destination_blockchain = this.tokenClient.getBlockchainV2FromIDs(value.to_chain_id, value.bridge_id);
|
|
94
|
+
const bridging_blockchain = getBridgeBlockchainFromId(value.bridge_id);
|
|
95
|
+
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 : '') });
|
|
96
|
+
};
|
|
97
|
+
this.formatRelaysTransfersV2 = (value) => {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
if (!value || typeof value !== "object")
|
|
100
|
+
return value;
|
|
101
|
+
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) });
|
|
102
|
+
};
|
|
103
|
+
this.formatChainEventV2 = (value, blockchain) => {
|
|
104
|
+
var _a, _b, _c;
|
|
105
|
+
if (!value || typeof value !== "object")
|
|
106
|
+
return value;
|
|
107
|
+
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 });
|
|
108
|
+
};
|
|
109
|
+
this.formatFeeQuoteV2 = (value, blockchain) => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
if (typeof value !== "object")
|
|
112
|
+
return value;
|
|
113
|
+
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()) });
|
|
114
|
+
};
|
|
73
115
|
this.apiManager = new util_1.APIUtils.APIManager(config.hydrogenUrl, exports.HydrogenEndpoints);
|
|
116
|
+
this.tokenClient = tokenClient;
|
|
117
|
+
}
|
|
118
|
+
static instance(config, tokenClient) {
|
|
119
|
+
return new HydrogenClient(config, tokenClient);
|
|
74
120
|
}
|
|
75
121
|
checkState() {
|
|
76
122
|
var _a;
|
|
@@ -89,40 +135,40 @@ class HydrogenClient {
|
|
|
89
135
|
return response.data;
|
|
90
136
|
});
|
|
91
137
|
}
|
|
92
|
-
getTransfers(req) {
|
|
138
|
+
getTransfers(req, version = "V1") {
|
|
93
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
140
|
this.checkState();
|
|
95
141
|
const request = this.apiManager.path("transfer_payloads", {}, Object.assign(Object.assign({}, req), { include_tx: false }));
|
|
96
142
|
const response = yield request.get();
|
|
97
143
|
const result = response.data;
|
|
98
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(formatCrossChainTransfer) });
|
|
144
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(version === "V1" ? formatCrossChainTransfer : this.formatCrossChainTransferV2) });
|
|
99
145
|
});
|
|
100
146
|
}
|
|
101
|
-
getDetailedTransfers(req) {
|
|
147
|
+
getDetailedTransfers(req, version = "V1") {
|
|
102
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
149
|
this.checkState();
|
|
104
150
|
const request = this.apiManager.path("transfer_payloads", {}, Object.assign(Object.assign({}, req), { include_tx: true }));
|
|
105
151
|
const response = yield request.get();
|
|
106
152
|
const result = response.data;
|
|
107
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(formatCrossChainTransferDetailed) });
|
|
153
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(version === "V1" ? formatCrossChainTransferDetailed : this.formatCrossChainTransferDetailedV2) });
|
|
108
154
|
});
|
|
109
155
|
}
|
|
110
|
-
getRelaysTransfers(req) {
|
|
156
|
+
getRelaysTransfers(req, version = "V1") {
|
|
111
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
158
|
this.checkState();
|
|
113
159
|
const request = this.apiManager.path("relays", {}, Object.assign(Object.assign({}, req), { include_tx: true }));
|
|
114
160
|
const response = yield request.get();
|
|
115
161
|
const result = response.data;
|
|
116
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(formatRelaysTransfers) });
|
|
162
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(version === "V1" ? formatRelaysTransfers : this.formatRelaysTransfersV2) });
|
|
117
163
|
});
|
|
118
164
|
}
|
|
119
|
-
getFeeQuote(req) {
|
|
165
|
+
getFeeQuote(req, blockchain = undefined, version = "V1") {
|
|
120
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
167
|
this.checkState();
|
|
122
168
|
const request = this.apiManager.path("fee_quote", {}, Object.assign({}, req));
|
|
123
169
|
const response = yield request.get();
|
|
124
170
|
const result = response.data;
|
|
125
|
-
return formatFeeQuote(result);
|
|
171
|
+
return version === "V1" ? formatFeeQuote(result) : this.formatFeeQuoteV2(result, blockchain);
|
|
126
172
|
});
|
|
127
173
|
}
|
|
128
174
|
}
|
|
@@ -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,13 +60,18 @@ 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) && (blockchain_1.BLOCKCHAIN_V2_TO_V1_MAPPING[sdk.token.getBlockchainV2(token.denom)] == this.blockchain)
|
|
71
|
+
:
|
|
72
|
+
blockchain_1.blockchainForChainId(token.chainId.toNumber(), sdk.network) == this.blockchain;
|
|
73
|
+
return (isCorrectBlockchain || token.denom === "swth") && 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
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { Token, TokenPrice } from "../codec";
|
|
1
|
+
import { Bridge, Token, TokenPrice } from "../codec";
|
|
2
|
+
import { DenomTrace } from "../codec/ibc/applications/transfer/v1/transfer";
|
|
2
3
|
import { NetworkConfigProvider } from "../constant";
|
|
3
4
|
import { FeeQuote } from "../hydrogen/feeQuote";
|
|
4
5
|
import { BlockchainUtils, TypeUtils } from "../util";
|
|
6
|
+
import { BlockchainV2, BridgeMap, IbcBridge } from '../util/blockchain';
|
|
5
7
|
import BigNumber from "bignumber.js";
|
|
6
8
|
import CarbonQueryClient from "./CarbonQueryClient";
|
|
9
|
+
export interface DenomTraceExtended extends DenomTrace {
|
|
10
|
+
token?: Token;
|
|
11
|
+
}
|
|
7
12
|
declare class TokenClient {
|
|
8
13
|
readonly query: CarbonQueryClient;
|
|
9
14
|
readonly configProvider: NetworkConfigProvider;
|
|
@@ -12,10 +17,12 @@ declare class TokenClient {
|
|
|
12
17
|
readonly wrapperMap: TypeUtils.SimpleMap<string>;
|
|
13
18
|
readonly poolTokens: TypeUtils.SimpleMap<Token>;
|
|
14
19
|
readonly cdpTokens: TypeUtils.SimpleMap<Token>;
|
|
20
|
+
readonly bridges: BridgeMap;
|
|
15
21
|
readonly symbols: TypeUtils.SimpleMap<string>;
|
|
16
22
|
readonly usdValues: TypeUtils.SimpleMap<BigNumber>;
|
|
17
23
|
readonly commonAssetNames: TypeUtils.SimpleMap<string>;
|
|
18
24
|
readonly geckoTokenNames: TypeUtils.SimpleMap<string>;
|
|
25
|
+
readonly denomTraces: TypeUtils.SimpleMap<DenomTraceExtended>;
|
|
19
26
|
private additionalGeckoDenoms;
|
|
20
27
|
private constructor();
|
|
21
28
|
static instance(query: CarbonQueryClient, configProvider: NetworkConfigProvider): TokenClient;
|
|
@@ -23,7 +30,8 @@ declare class TokenClient {
|
|
|
23
30
|
registerGeckoIdMap(map: TypeUtils.SimpleMap<string>): void;
|
|
24
31
|
getCommonDenom(denom: string): string;
|
|
25
32
|
getDecimals(denom: string): number | undefined;
|
|
26
|
-
getBlockchain(denom: string): BlockchainUtils.Blockchain | undefined;
|
|
33
|
+
getBlockchain(denom: string): BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2 | undefined;
|
|
34
|
+
getBlockchainV2(denom: string | undefined): BlockchainUtils.BlockchainV2 | undefined;
|
|
27
35
|
getSymbol(denom: string): string;
|
|
28
36
|
getUSDValue(denom: string): BigNumber | undefined;
|
|
29
37
|
toHuman(denom: string, unitlessAmt: BigNumber): BigNumber;
|
|
@@ -42,16 +50,32 @@ declare class TokenClient {
|
|
|
42
50
|
isWrappedToken(denom?: string): boolean;
|
|
43
51
|
hasWrappedToken(denom?: string): boolean;
|
|
44
52
|
getWrappedTokens(denom: string): Token[];
|
|
45
|
-
getWrappedToken(denom: string, blockchain?: BlockchainUtils.Blockchain): Token | null;
|
|
53
|
+
getWrappedToken(denom: string, blockchain?: BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2, version?: string): Token | null;
|
|
46
54
|
getSourceToken(denom: string): Token | null;
|
|
47
55
|
getNativeToken(): Token | undefined;
|
|
48
56
|
getNativeStablecoin(): Token | undefined;
|
|
49
57
|
isNativeToken(denom: string): boolean;
|
|
50
58
|
isNativeStablecoin(denom: string): boolean;
|
|
51
|
-
|
|
59
|
+
isGroupedToken(denom: string): boolean;
|
|
60
|
+
isCarbonToken(token?: Token | null): boolean;
|
|
61
|
+
getDepositTokenFor(tokenDenom: string, chain: BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2, version?: string): Token | undefined;
|
|
52
62
|
getAllTokens(): Promise<Token[]>;
|
|
53
63
|
reloadTokens(): Promise<TypeUtils.SimpleMap<Token>>;
|
|
54
|
-
|
|
64
|
+
reloadDenomTraces(): Promise<TypeUtils.SimpleMap<DenomTraceExtended>>;
|
|
65
|
+
getDenomTraceData(denom: string): DenomTrace | undefined;
|
|
66
|
+
getBridges(): Promise<BridgeMap>;
|
|
67
|
+
matchChainsWithDifferentChainIds(bridges: Bridge[]): Promise<IbcBridge[]>;
|
|
68
|
+
getIbcBlockchainNames(): string[];
|
|
69
|
+
getIbcChainFromBlockchainV2: (blockchain: BlockchainV2 | undefined) => string | undefined;
|
|
70
|
+
getPolynetworkBlockchainNames(): string[];
|
|
71
|
+
getAllBlockchainNames(): string[];
|
|
72
|
+
getBridgesFromBridgeId(bridgeId: number): Bridge[] | IbcBridge[];
|
|
73
|
+
getIbcTokens(): TypeUtils.SimpleMap<Token>;
|
|
74
|
+
getPolyNetworkTokens(): TypeUtils.SimpleMap<Token>;
|
|
75
|
+
getBlockchainV2FromIDs(chainId: string, bridgeId: string): BlockchainV2 | undefined;
|
|
76
|
+
getBridgeFromToken(token: Token | null): Bridge | IbcBridge | undefined;
|
|
77
|
+
getIbcChainIdFromToken(token: Token | null): string | undefined;
|
|
78
|
+
getCarbonDenomTraces(): Promise<TypeUtils.SimpleMap<DenomTrace>>;
|
|
55
79
|
getCdpUnderlyingToken(cdpDenom: string): Token | undefined;
|
|
56
80
|
reloadWrapperMap(): Promise<TypeUtils.SimpleMap<string>>;
|
|
57
81
|
reloadDenomGeckoMap(): Promise<void>;
|