carbon-js-sdk 0.3.32 → 0.3.34
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.js +2 -2
- package/lib/clients/HydrogenClient.js +9 -9
- package/lib/clients/InsightsQueryClient.js +45 -45
- package/lib/clients/N3Client.js +28 -25
- package/lib/clients/NEOClient.js +15 -14
- package/lib/clients/TokenClient.js +24 -27
- package/lib/clients/ZILClient.d.ts +1 -1
- package/lib/clients/ZILClient.js +52 -51
- package/lib/codec/bank/query.d.ts +2 -0
- package/lib/codec/bank/query.js +35 -6
- package/lib/constant/ibc.d.ts +5 -2
- package/lib/constant/ibc.js +164 -18
- package/lib/constant/network.d.ts +1 -1
- package/lib/constant/network.js +18 -18
- package/lib/constant/node.js +16 -11
- package/lib/constant/token.js +348 -348
- package/lib/eth/abis/index.d.ts +7 -7
- package/lib/eth/index.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/insights/common.d.ts +29 -29
- package/lib/insights/common.js +29 -29
- package/lib/modules/admin.js +29 -30
- package/lib/modules/bank.js +1 -2
- package/lib/modules/broker.js +1 -2
- package/lib/modules/cdp.d.ts +3 -3
- package/lib/modules/cdp.js +33 -34
- package/lib/modules/coin.js +0 -1
- package/lib/modules/fee.js +2 -2
- package/lib/modules/gov.js +12 -13
- package/lib/modules/ibc.js +2 -3
- package/lib/modules/leverage.js +1 -2
- package/lib/modules/liquiditypool.d.ts +1 -1
- package/lib/modules/liquiditypool.js +2 -3
- package/lib/modules/market.js +1 -2
- package/lib/modules/oracle.js +0 -1
- package/lib/modules/order.js +4 -5
- package/lib/modules/position.js +1 -2
- package/lib/modules/profile.js +0 -1
- package/lib/modules/staking.js +1 -2
- package/lib/modules/subaccount.js +0 -1
- package/lib/modules/xchain.js +1 -1
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.d.ts +2 -2
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +9 -7
- package/lib/provider/account/EthLedgerAccount/EthLedgerSigner.d.ts +2 -2
- package/lib/provider/account/EthLedgerAccount/EthLedgerSigner.js +5 -4
- package/lib/provider/account/EthLedgerAccount/index.d.ts +2 -2
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +5 -3
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -2
- package/lib/provider/amino/types/gov.js +3 -4
- package/lib/provider/amino/types/order.js +2 -6
- package/lib/provider/amino/utils.js +6 -16
- package/lib/provider/chainProvider/GetSigningCosmosClientOptions.d.ts +1 -1
- package/lib/provider/chainProvider/GetSigningCosmosClientOptions.js +1 -1
- package/lib/provider/chainProvider/index.d.ts +2 -2
- package/lib/provider/keplr/KeplrAccount.d.ts +1 -2
- package/lib/provider/keplr/KeplrAccount.js +7 -5
- package/lib/provider/keplr/KeplrStore.d.ts +2 -8
- package/lib/provider/keplr/KeplrStore.js +1 -7
- package/lib/provider/leap/LeapAccount.d.ts +1 -2
- package/lib/provider/leap/LeapAccount.js +7 -5
- package/lib/provider/metamask/MetaMask.d.ts +3 -3
- package/lib/provider/metamask/MetaMask.js +98 -93
- package/lib/provider/metamask/index.d.ts +1 -1
- package/lib/provider/o3/O3Wallet.js +12 -8
- package/lib/provider/zilpay/Zilpay.js +9 -9
- package/lib/util/address.js +2 -8
- package/lib/util/api.js +7 -7
- package/lib/util/blockchain.d.ts +5 -2
- package/lib/util/blockchain.js +55 -44
- package/lib/util/external.js +1 -2
- package/lib/util/fetch.js +1 -2
- package/lib/util/generic.js +3 -3
- package/lib/util/gov.js +1 -2
- package/lib/util/ibc.js +7 -7
- package/lib/util/token.js +3 -3
- package/lib/util/tx.js +5 -5
- package/lib/util/type.js +6 -10
- package/lib/wallet/CarbonSigner.d.ts +3 -3
- package/lib/wallet/CarbonSigningClient.js +4 -5
- package/lib/wallet/CarbonWallet.js +7 -10
- package/lib/websocket/channel.d.ts +1 -1
- package/lib/websocket/channel.js +30 -30
- package/lib/websocket/connector.d.ts +3 -3
- package/lib/websocket/connector.js +20 -20
- package/lib/websocket/index.d.ts +1 -1
- package/lib/websocket/models.d.ts +3 -3
- package/package.json +5 -3
- package/lib/codec/ibc/applications/fee/v1/ack.d.ts +0 -24
- package/lib/codec/ibc/applications/fee/v1/ack.js +0 -125
- package/lib/codec/ibc/applications/fee/v1/fee.d.ts +0 -68
- package/lib/codec/ibc/applications/fee/v1/fee.js +0 -289
- package/lib/codec/ibc/applications/fee/v1/genesis.d.ts +0 -93
- package/lib/codec/ibc/applications/fee/v1/genesis.js +0 -390
- package/lib/codec/ibc/applications/fee/v1/metadata.d.ts +0 -25
- package/lib/codec/ibc/applications/fee/v1/metadata.js +0 -71
- package/lib/codec/ibc/applications/fee/v1/query.d.ts +0 -312
- package/lib/codec/ibc/applications/fee/v1/query.js +0 -1187
- package/lib/codec/ibc/applications/fee/v1/tx.d.ts +0 -171
- package/lib/codec/ibc/applications/fee/v1/tx.js +0 -524
- package/lib/codec/ibc/applications/interchain_accounts/controller/v1/tx.d.ts +0 -78
- package/lib/codec/ibc/applications/interchain_accounts/controller/v1/tx.js +0 -296
- package/lib/codec/ibc/applications/interchain_accounts/genesis/v1/genesis.d.ts +0 -80
- package/lib/codec/ibc/applications/interchain_accounts/genesis/v1/genesis.js +0 -439
|
@@ -21,16 +21,16 @@ const number_1 = require("../util/number");
|
|
|
21
21
|
const long_1 = __importDefault(require("long"));
|
|
22
22
|
const InsightsQueryClient_1 = __importDefault(require("./InsightsQueryClient"));
|
|
23
23
|
const SYMBOL_OVERRIDE = {
|
|
24
|
-
swth:
|
|
25
|
-
NNEO:
|
|
26
|
-
YAM1:
|
|
27
|
-
YAM2:
|
|
28
|
-
ASA1:
|
|
29
|
-
ASA2:
|
|
30
|
-
DBC1:
|
|
31
|
-
DBC2:
|
|
32
|
-
AVA1:
|
|
33
|
-
TSWTH:
|
|
24
|
+
swth: "SWTH",
|
|
25
|
+
NNEO: "nNEO",
|
|
26
|
+
YAM1: "YAM",
|
|
27
|
+
YAM2: "YAM",
|
|
28
|
+
ASA1: "ASA",
|
|
29
|
+
ASA2: "ASA",
|
|
30
|
+
DBC1: "DBC",
|
|
31
|
+
DBC2: "DBC",
|
|
32
|
+
AVA1: "AVA",
|
|
33
|
+
TSWTH: "tSWTH",
|
|
34
34
|
};
|
|
35
35
|
const regexCdpDenom = RegExp(`^${constant_1.DenomPrefix.CDPToken}/`, "i");
|
|
36
36
|
const regexLPDenom = RegExp(`^${constant_1.DenomPrefix.LPToken}/(\\d+)$`, "i");
|
|
@@ -115,7 +115,7 @@ class TokenClient {
|
|
|
115
115
|
return (_a = util_1.NumberUtils.toUnitless(humanAmt, decimals)) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
|
|
116
116
|
}
|
|
117
117
|
tokenForId(id) {
|
|
118
|
-
return Object.values(this.tokens).find(token => token.id === id);
|
|
118
|
+
return Object.values(this.tokens).find((token) => token.id === id);
|
|
119
119
|
}
|
|
120
120
|
tokenForDenom(denom) {
|
|
121
121
|
return this.tokens[denom];
|
|
@@ -124,14 +124,14 @@ class TokenClient {
|
|
|
124
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
125
|
const config = this.configProvider.getConfig();
|
|
126
126
|
const url = `${config.hydrogenUrl}/fee_quote?token_denom=${denom}`;
|
|
127
|
-
const result = yield fetch(url).then(res => res.json());
|
|
127
|
+
const result = yield fetch(url).then((res) => res.json());
|
|
128
128
|
return result;
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
getTokenName(denom, overrideMap) {
|
|
132
132
|
var _a;
|
|
133
|
-
if (typeof denom !==
|
|
134
|
-
return
|
|
133
|
+
if (typeof denom !== "string")
|
|
134
|
+
return "";
|
|
135
135
|
if (!TokenClient.isIBCDenom(denom) && !TokenClient.isCdpIbcDenom(denom)) {
|
|
136
136
|
denom = denom.toLowerCase();
|
|
137
137
|
}
|
|
@@ -148,7 +148,7 @@ class TokenClient {
|
|
|
148
148
|
return `${symbolA}-${symbolB}`;
|
|
149
149
|
}
|
|
150
150
|
if (TokenClient.isIBCDenom(denom)) {
|
|
151
|
-
const splitDenom = denom.split(
|
|
151
|
+
const splitDenom = denom.split("/");
|
|
152
152
|
denom = `${splitDenom[0].toLowerCase()}/${splitDenom[1].toUpperCase()}`;
|
|
153
153
|
return (_a = this.symbols[denom]) !== null && _a !== void 0 ? _a : denom.toUpperCase();
|
|
154
154
|
}
|
|
@@ -162,8 +162,8 @@ class TokenClient {
|
|
|
162
162
|
}
|
|
163
163
|
getTokenDesc(denom) {
|
|
164
164
|
var _a, _b, _c, _d;
|
|
165
|
-
if (typeof denom !==
|
|
166
|
-
return
|
|
165
|
+
if (typeof denom !== "string")
|
|
166
|
+
return "";
|
|
167
167
|
denom = denom.toLowerCase();
|
|
168
168
|
if (TokenClient.isPoolTokenLegacy(denom)) {
|
|
169
169
|
const match = denom.match(/^([a-z\d.-\/]+)-(\d+)-([a-z\d.-\/]+)-(\d+)-lp\d+$/i);
|
|
@@ -283,7 +283,7 @@ class TokenClient {
|
|
|
283
283
|
getDepositTokenFor(tokenDenom, chain) {
|
|
284
284
|
const token = this.tokenForDenom(tokenDenom);
|
|
285
285
|
if (!token) {
|
|
286
|
-
console.error(
|
|
286
|
+
console.error("getDepositTokenFor token not found for", tokenDenom);
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
289
|
// check if selected token is a source token
|
|
@@ -291,8 +291,7 @@ class TokenClient {
|
|
|
291
291
|
if (TokenClient.isIBCDenom(token.denom)) {
|
|
292
292
|
targetChain = util_1.IBCUtils.BlockchainMap[token.denom];
|
|
293
293
|
}
|
|
294
|
-
const isSourceToken = targetChain === chain
|
|
295
|
-
&& token.denom !== "swth";
|
|
294
|
+
const isSourceToken = targetChain === chain && token.denom !== "swth";
|
|
296
295
|
// if not source token find wrapped token for chain
|
|
297
296
|
const depositToken = isSourceToken ? token : this.getWrappedToken(token.denom, chain);
|
|
298
297
|
if (!depositToken) {
|
|
@@ -315,7 +314,7 @@ class TokenClient {
|
|
|
315
314
|
});
|
|
316
315
|
const networkConfig = this.configProvider.getConfig();
|
|
317
316
|
const tokenBlacklist = (_a = constant_1.TokenBlacklist[networkConfig.network]) !== null && _a !== void 0 ? _a : [];
|
|
318
|
-
return result.tokens.filter(token => !tokenBlacklist.includes(token.denom));
|
|
317
|
+
return result.tokens.filter((token) => !tokenBlacklist.includes(token.denom));
|
|
319
318
|
});
|
|
320
319
|
}
|
|
321
320
|
reloadTokens() {
|
|
@@ -332,7 +331,7 @@ class TokenClient {
|
|
|
332
331
|
else {
|
|
333
332
|
if (this.isNativeToken(token.denom)) {
|
|
334
333
|
// Change token name to Carbon
|
|
335
|
-
token.name =
|
|
334
|
+
token.name = "Carbon";
|
|
336
335
|
}
|
|
337
336
|
this.tokens[token.denom] = token;
|
|
338
337
|
this.symbols[token.denom] = token.symbol;
|
|
@@ -364,8 +363,8 @@ class TokenClient {
|
|
|
364
363
|
const swthTokens = ibc_1.swthIbcWhitelist.map((chainId) => {
|
|
365
364
|
var _a, _b;
|
|
366
365
|
const blockchain = util_1.IBCUtils.BlockchainMap[chainId];
|
|
367
|
-
const carbonBlockchain = util_1.IBCUtils.ChainIdBlockchainMap[blockchain !== null && blockchain !== void 0 ? blockchain :
|
|
368
|
-
const blockchainNum = (_a = util_1.BlockchainUtils.CHAIN_IDS[carbonBlockchain !== null && carbonBlockchain !== void 0 ? carbonBlockchain :
|
|
366
|
+
const carbonBlockchain = util_1.IBCUtils.ChainIdBlockchainMap[blockchain !== null && blockchain !== void 0 ? blockchain : ""];
|
|
367
|
+
const blockchainNum = (_a = util_1.BlockchainUtils.CHAIN_IDS[carbonBlockchain !== null && carbonBlockchain !== void 0 ? carbonBlockchain : ""]) !== null && _a !== void 0 ? _a : 0;
|
|
369
368
|
const swthChannel = ibc_1.swthChannels[chainId];
|
|
370
369
|
const assetDenom = util_1.IBCUtils.makeIBCMinimalDenom((_b = swthChannel.dstChannel) !== null && _b !== void 0 ? _b : "channel-0", KeplrAccount_1.default.SWTH_CURRENCY.coinMinimalDenom);
|
|
371
370
|
return {
|
|
@@ -470,9 +469,7 @@ class TokenClient {
|
|
|
470
469
|
const channelObj = ibc_1.swthChannels[chainId];
|
|
471
470
|
currencies.forEach((asset) => {
|
|
472
471
|
var _a, _b;
|
|
473
|
-
const channel = asset.coinMinimalDenom !== "swth"
|
|
474
|
-
? ((_a = channelObj === null || channelObj === void 0 ? void 0 : channelObj.sourceChannel) !== null && _a !== void 0 ? _a : "channel-0")
|
|
475
|
-
: ((_b = channelObj === null || channelObj === void 0 ? void 0 : channelObj.dstChannel) !== null && _b !== void 0 ? _b : "channel-0");
|
|
472
|
+
const channel = asset.coinMinimalDenom !== "swth" ? (_a = channelObj === null || channelObj === void 0 ? void 0 : channelObj.sourceChannel) !== null && _a !== void 0 ? _a : "channel-0" : (_b = channelObj === null || channelObj === void 0 ? void 0 : channelObj.dstChannel) !== null && _b !== void 0 ? _b : "channel-0";
|
|
476
473
|
const assetDenom = TokenClient.isIBCDenom(asset.coinMinimalDenom)
|
|
477
474
|
? asset.coinMinimalDenom
|
|
478
475
|
: util_1.IBCUtils.makeIBCMinimalDenom(channel, asset.coinMinimalDenom);
|
|
@@ -15,7 +15,7 @@ export declare type WalletProvider = Omit<Zilliqa & {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
}, // ugly hack for zilpay non-standard API
|
|
18
|
-
|
|
18
|
+
"subscriptionBuilder">;
|
|
19
19
|
export interface ZILClientOpts {
|
|
20
20
|
configProvider: NetworkConfigProvider;
|
|
21
21
|
blockchain: Blockchain;
|
package/lib/clients/ZILClient.js
CHANGED
|
@@ -30,7 +30,6 @@ var BatchRequestType;
|
|
|
30
30
|
BatchRequestType["TokenBalance"] = "tokenBalance";
|
|
31
31
|
BatchRequestType["TokenAllowance"] = "tokenAllowance";
|
|
32
32
|
})(BatchRequestType = exports.BatchRequestType || (exports.BatchRequestType = {}));
|
|
33
|
-
;
|
|
34
33
|
const tokenBalanceBatchRequest = (tokenAddress, walletAddress) => {
|
|
35
34
|
return {
|
|
36
35
|
type: BatchRequestType.TokenBalance,
|
|
@@ -74,10 +73,12 @@ class ZILClient {
|
|
|
74
73
|
getExternalBalances(sdk, address, whitelistDenoms) {
|
|
75
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
75
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
77
|
-
const tokens = tokenQueryResults.filter(token => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
|
|
76
|
+
const tokens = tokenQueryResults.filter((token) => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
|
|
78
77
|
token.tokenAddress.length == 40 &&
|
|
79
78
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)));
|
|
80
|
-
const requests = tokens.map(token => token.tokenAddress === zeroAddress
|
|
79
|
+
const requests = tokens.map((token) => token.tokenAddress === zeroAddress
|
|
80
|
+
? (0, exports.balanceBatchRequest)(address.replace(/^0x/i, ""))
|
|
81
|
+
: (0, exports.tokenBalanceBatchRequest)(token.tokenAddress, address));
|
|
81
82
|
const response = yield fetch(this.getProviderUrl(), {
|
|
82
83
|
method: "post",
|
|
83
84
|
headers: { "content-type": "application/json" },
|
|
@@ -110,7 +111,7 @@ class ZILClient {
|
|
|
110
111
|
// const lock_tx = await zilclient.lockDeposit()
|
|
111
112
|
// const emptyTx = new Transaction({ toAddr: toAddr }, new HTTPProvider(sdk.zil.getProviderUrl())
|
|
112
113
|
// const confirmedTxn = await emptyTx.confirm(lock_tx.id)
|
|
113
|
-
//
|
|
114
|
+
//
|
|
114
115
|
// to confirm the privatekey method use :
|
|
115
116
|
// const lock_tx = await zilclient.lockDeposit()
|
|
116
117
|
// const txn = await lock_tx.confirm(lock_tx.id)
|
|
@@ -136,7 +137,7 @@ class ZILClient {
|
|
|
136
137
|
const { token, gasPrice, gasLimit, zilAddress, spenderAddress, signer } = params;
|
|
137
138
|
const contractAddress = token.tokenAddress;
|
|
138
139
|
let zilliqa;
|
|
139
|
-
if (typeof signer ===
|
|
140
|
+
if (typeof signer === "string") {
|
|
140
141
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
141
142
|
zilliqa.wallet.addByPrivateKey(signer);
|
|
142
143
|
}
|
|
@@ -163,20 +164,20 @@ class ZILClient {
|
|
|
163
164
|
};
|
|
164
165
|
const transitionParams = [
|
|
165
166
|
{
|
|
166
|
-
vname:
|
|
167
|
-
type:
|
|
167
|
+
vname: "spender",
|
|
168
|
+
type: "ByStr20",
|
|
168
169
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
169
170
|
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : (0, generic_1.appendHexPrefix)(token.bridgeAddress),
|
|
170
171
|
},
|
|
171
172
|
{
|
|
172
|
-
vname:
|
|
173
|
-
type:
|
|
173
|
+
vname: "amount",
|
|
174
|
+
type: "Uint128",
|
|
174
175
|
value: uint128Max,
|
|
175
176
|
},
|
|
176
177
|
];
|
|
177
178
|
const data = {
|
|
178
179
|
_tag: "IncreaseAllowance",
|
|
179
|
-
params: [...transitionParams]
|
|
180
|
+
params: [...transitionParams],
|
|
180
181
|
};
|
|
181
182
|
const callTx = yield this.callContract(deployedContract, data._tag, data.params, callParams, true);
|
|
182
183
|
return callTx;
|
|
@@ -198,7 +199,7 @@ class ZILClient {
|
|
|
198
199
|
}
|
|
199
200
|
bridgeTokens(params) {
|
|
200
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
const { fromToken, toToken, amount, fromAddress, recoveryAddress, toAddress, signer, gasPrice, gasLimit, feeAmount, signCompleteCallback } = params;
|
|
202
|
+
const { fromToken, toToken, amount, fromAddress, recoveryAddress, toAddress, signer, gasPrice, gasLimit, feeAmount, signCompleteCallback, } = params;
|
|
202
203
|
const networkConfig = this.getNetworkConfig();
|
|
203
204
|
if (!recoveryAddress.match(/^swth[a-z0-9]{39}$/)) {
|
|
204
205
|
throw new Error("Invalid recovery address");
|
|
@@ -213,7 +214,7 @@ class ZILClient {
|
|
|
213
214
|
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
214
215
|
const contractAddress = this.getBridgeEntranceAddr();
|
|
215
216
|
let zilliqa;
|
|
216
|
-
if (typeof signer ===
|
|
217
|
+
if (typeof signer === "string") {
|
|
217
218
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
218
219
|
zilliqa.wallet.addByPrivateKey(signer);
|
|
219
220
|
}
|
|
@@ -244,50 +245,50 @@ class ZILClient {
|
|
|
244
245
|
};
|
|
245
246
|
const transitionParams = [
|
|
246
247
|
{
|
|
247
|
-
vname:
|
|
248
|
-
type:
|
|
248
|
+
vname: "tokenAddr",
|
|
249
|
+
type: "ByStr20",
|
|
249
250
|
value: fromTokenAddr,
|
|
250
251
|
},
|
|
251
252
|
{
|
|
252
|
-
vname:
|
|
253
|
-
type:
|
|
253
|
+
vname: "targetProxyHash",
|
|
254
|
+
type: "ByStr",
|
|
254
255
|
value: targetProxyHash,
|
|
255
256
|
},
|
|
256
257
|
{
|
|
257
|
-
vname:
|
|
258
|
-
type:
|
|
258
|
+
vname: "recoveryAddress",
|
|
259
|
+
type: "ByStr",
|
|
259
260
|
value: recoveryAddressHex,
|
|
260
261
|
},
|
|
261
262
|
{
|
|
262
|
-
vname:
|
|
263
|
-
type:
|
|
263
|
+
vname: "fromAssetDenom",
|
|
264
|
+
type: "ByStr",
|
|
264
265
|
value: fromAssetHash,
|
|
265
266
|
},
|
|
266
267
|
{
|
|
267
|
-
vname:
|
|
268
|
-
type:
|
|
268
|
+
vname: "withdrawFeeAddress",
|
|
269
|
+
type: "ByStr",
|
|
269
270
|
value: feeAddress,
|
|
270
271
|
},
|
|
271
272
|
{
|
|
272
|
-
vname:
|
|
273
|
-
type:
|
|
273
|
+
vname: "toAddress",
|
|
274
|
+
type: "ByStr",
|
|
274
275
|
value: toAddress,
|
|
275
276
|
},
|
|
276
277
|
{
|
|
277
|
-
vname:
|
|
278
|
-
type:
|
|
278
|
+
vname: "toAssetDenom",
|
|
279
|
+
type: "ByStr",
|
|
279
280
|
value: toAssetHash,
|
|
280
281
|
},
|
|
281
282
|
{
|
|
282
|
-
vname:
|
|
283
|
-
type:
|
|
284
|
-
value: amount.toString()
|
|
283
|
+
vname: "amount",
|
|
284
|
+
type: "Uint256",
|
|
285
|
+
value: amount.toString(),
|
|
285
286
|
},
|
|
286
287
|
{
|
|
287
|
-
vname:
|
|
288
|
-
type:
|
|
289
|
-
value: feeAmount.toString()
|
|
290
|
-
}
|
|
288
|
+
vname: "withdrawFeeAmount",
|
|
289
|
+
type: "Uint256",
|
|
290
|
+
value: feeAmount.toString(),
|
|
291
|
+
},
|
|
291
292
|
];
|
|
292
293
|
const data = {
|
|
293
294
|
_tag: "Lock",
|
|
@@ -310,7 +311,7 @@ class ZILClient {
|
|
|
310
311
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
311
312
|
const contractAddress = (0, generic_1.appendHexPrefix)(token.bridgeAddress);
|
|
312
313
|
let zilliqa;
|
|
313
|
-
if (typeof signer ===
|
|
314
|
+
if (typeof signer === "string") {
|
|
314
315
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
315
316
|
zilliqa.wallet.addByPrivateKey(signer);
|
|
316
317
|
}
|
|
@@ -341,38 +342,38 @@ class ZILClient {
|
|
|
341
342
|
};
|
|
342
343
|
const transitionParams = [
|
|
343
344
|
{
|
|
344
|
-
vname:
|
|
345
|
-
type:
|
|
345
|
+
vname: "tokenAddr",
|
|
346
|
+
type: "ByStr20",
|
|
346
347
|
value: assetId,
|
|
347
348
|
},
|
|
348
349
|
{
|
|
349
|
-
vname:
|
|
350
|
-
type:
|
|
350
|
+
vname: "targetProxyHash",
|
|
351
|
+
type: "ByStr",
|
|
351
352
|
value: targetProxyHash,
|
|
352
353
|
},
|
|
353
354
|
{
|
|
354
|
-
vname:
|
|
355
|
-
type:
|
|
355
|
+
vname: "toAddress",
|
|
356
|
+
type: "ByStr",
|
|
356
357
|
value: swthAddress,
|
|
357
358
|
},
|
|
358
359
|
{
|
|
359
|
-
vname:
|
|
360
|
-
type:
|
|
360
|
+
vname: "toAssetHash",
|
|
361
|
+
type: "ByStr",
|
|
361
362
|
value: toAssetHash,
|
|
362
363
|
},
|
|
363
364
|
{
|
|
364
|
-
vname:
|
|
365
|
-
type:
|
|
365
|
+
vname: "feeAddr",
|
|
366
|
+
type: "ByStr",
|
|
366
367
|
value: feeAddress,
|
|
367
368
|
},
|
|
368
369
|
{
|
|
369
|
-
vname:
|
|
370
|
-
type:
|
|
370
|
+
vname: "amount",
|
|
371
|
+
type: "Uint256",
|
|
371
372
|
value: amount.toString(),
|
|
372
373
|
},
|
|
373
374
|
{
|
|
374
|
-
vname:
|
|
375
|
-
type:
|
|
375
|
+
vname: "feeAmount",
|
|
376
|
+
type: "Uint256",
|
|
376
377
|
value: "0",
|
|
377
378
|
},
|
|
378
379
|
];
|
|
@@ -388,13 +389,13 @@ class ZILClient {
|
|
|
388
389
|
return __awaiter(this, void 0, void 0, function* () {
|
|
389
390
|
const zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
390
391
|
const smartContractInit = yield zilliqa.blockchain.getSmartContractInit(address);
|
|
391
|
-
const mask = [
|
|
392
|
+
const mask = ["name", "_this_address", "symbol", "decimals"];
|
|
392
393
|
const result = smartContractInit.result;
|
|
393
394
|
if (result === undefined)
|
|
394
395
|
throw new Error(`token contract ${address} is not found`);
|
|
395
396
|
const intermediate = result
|
|
396
397
|
.filter(({ vname }) => mask.includes(vname))
|
|
397
|
-
.reduce((prev, cur) => (Object.assign(Object.assign({}, prev), { [cur.vname ===
|
|
398
|
+
.reduce((prev, cur) => (Object.assign(Object.assign({}, prev), { [cur.vname === "_this_address" ? "address" : cur.vname]: cur.value })), {});
|
|
398
399
|
return Object.assign(Object.assign({}, intermediate), { decimals: Number(intermediate.decimals) });
|
|
399
400
|
});
|
|
400
401
|
}
|
|
@@ -431,6 +432,6 @@ class ZILClient {
|
|
|
431
432
|
exports.ZILClient = ZILClient;
|
|
432
433
|
ZILClient.SUPPORTED_BLOCKCHAINS = [blockchain_1.Blockchain.Zilliqa];
|
|
433
434
|
ZILClient.BLOCKCHAIN_KEY = {
|
|
434
|
-
[blockchain_1.Blockchain.Zilliqa]: "zil"
|
|
435
|
+
[blockchain_1.Blockchain.Zilliqa]: "zil",
|
|
435
436
|
};
|
|
436
437
|
exports.default = ZILClient;
|
package/lib/codec/bank/query.js
CHANGED
|
@@ -109,17 +109,28 @@ exports.InternalTransfer = {
|
|
|
109
109
|
return message;
|
|
110
110
|
},
|
|
111
111
|
};
|
|
112
|
-
const baseQueryInternalTransfersRequest = {
|
|
112
|
+
const baseQueryInternalTransfersRequest = {
|
|
113
|
+
address: "",
|
|
114
|
+
sender: "",
|
|
115
|
+
receiver: "",
|
|
116
|
+
denom: "",
|
|
117
|
+
};
|
|
113
118
|
exports.QueryInternalTransfersRequest = {
|
|
114
119
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
115
120
|
if (message.address !== "") {
|
|
116
121
|
writer.uint32(10).string(message.address);
|
|
117
122
|
}
|
|
123
|
+
if (message.sender !== "") {
|
|
124
|
+
writer.uint32(18).string(message.sender);
|
|
125
|
+
}
|
|
126
|
+
if (message.receiver !== "") {
|
|
127
|
+
writer.uint32(26).string(message.receiver);
|
|
128
|
+
}
|
|
118
129
|
if (message.denom !== "") {
|
|
119
|
-
writer.uint32(
|
|
130
|
+
writer.uint32(34).string(message.denom);
|
|
120
131
|
}
|
|
121
132
|
if (message.pagination !== undefined) {
|
|
122
|
-
pagination_1.PageRequest.encode(message.pagination, writer.uint32(
|
|
133
|
+
pagination_1.PageRequest.encode(message.pagination, writer.uint32(42).fork()).ldelim();
|
|
123
134
|
}
|
|
124
135
|
return writer;
|
|
125
136
|
},
|
|
@@ -134,9 +145,15 @@ exports.QueryInternalTransfersRequest = {
|
|
|
134
145
|
message.address = reader.string();
|
|
135
146
|
break;
|
|
136
147
|
case 2:
|
|
137
|
-
message.
|
|
148
|
+
message.sender = reader.string();
|
|
138
149
|
break;
|
|
139
150
|
case 3:
|
|
151
|
+
message.receiver = reader.string();
|
|
152
|
+
break;
|
|
153
|
+
case 4:
|
|
154
|
+
message.denom = reader.string();
|
|
155
|
+
break;
|
|
156
|
+
case 5:
|
|
140
157
|
message.pagination = pagination_1.PageRequest.decode(reader, reader.uint32());
|
|
141
158
|
break;
|
|
142
159
|
default:
|
|
@@ -152,6 +169,14 @@ exports.QueryInternalTransfersRequest = {
|
|
|
152
169
|
object.address !== undefined && object.address !== null
|
|
153
170
|
? String(object.address)
|
|
154
171
|
: "";
|
|
172
|
+
message.sender =
|
|
173
|
+
object.sender !== undefined && object.sender !== null
|
|
174
|
+
? String(object.sender)
|
|
175
|
+
: "";
|
|
176
|
+
message.receiver =
|
|
177
|
+
object.receiver !== undefined && object.receiver !== null
|
|
178
|
+
? String(object.receiver)
|
|
179
|
+
: "";
|
|
155
180
|
message.denom =
|
|
156
181
|
object.denom !== undefined && object.denom !== null
|
|
157
182
|
? String(object.denom)
|
|
@@ -165,6 +190,8 @@ exports.QueryInternalTransfersRequest = {
|
|
|
165
190
|
toJSON(message) {
|
|
166
191
|
const obj = {};
|
|
167
192
|
message.address !== undefined && (obj.address = message.address);
|
|
193
|
+
message.sender !== undefined && (obj.sender = message.sender);
|
|
194
|
+
message.receiver !== undefined && (obj.receiver = message.receiver);
|
|
168
195
|
message.denom !== undefined && (obj.denom = message.denom);
|
|
169
196
|
message.pagination !== undefined &&
|
|
170
197
|
(obj.pagination = message.pagination
|
|
@@ -173,10 +200,12 @@ exports.QueryInternalTransfersRequest = {
|
|
|
173
200
|
return obj;
|
|
174
201
|
},
|
|
175
202
|
fromPartial(object) {
|
|
176
|
-
var _a, _b;
|
|
203
|
+
var _a, _b, _c, _d;
|
|
177
204
|
const message = Object.assign({}, baseQueryInternalTransfersRequest);
|
|
178
205
|
message.address = (_a = object.address) !== null && _a !== void 0 ? _a : "";
|
|
179
|
-
message.
|
|
206
|
+
message.sender = (_b = object.sender) !== null && _b !== void 0 ? _b : "";
|
|
207
|
+
message.receiver = (_c = object.receiver) !== null && _c !== void 0 ? _c : "";
|
|
208
|
+
message.denom = (_d = object.denom) !== null && _d !== void 0 ? _d : "";
|
|
180
209
|
message.pagination =
|
|
181
210
|
object.pagination !== undefined && object.pagination !== null
|
|
182
211
|
? pagination_1.PageRequest.fromPartial(object.pagination)
|
package/lib/constant/ibc.d.ts
CHANGED
|
@@ -54,8 +54,11 @@ export declare enum ChainIds {
|
|
|
54
54
|
Stride = "stride-1",
|
|
55
55
|
Kujira = "kaiyo-1",
|
|
56
56
|
Terra2 = "phoenix-1",
|
|
57
|
-
Quicksilver = "quicksilver-
|
|
58
|
-
StafiHub = "stafihub-1"
|
|
57
|
+
Quicksilver = "quicksilver-2",
|
|
58
|
+
StafiHub = "stafihub-1",
|
|
59
|
+
Canto = "canto_7700-1",
|
|
60
|
+
OmniFlixHub = "omniflixhub-1",
|
|
61
|
+
Agoric = "agoric-3"
|
|
59
62
|
}
|
|
60
63
|
export declare const swthIbcWhitelist: string[];
|
|
61
64
|
export declare const ibcWhitelist: string[];
|