carbon-js-sdk 0.4.31 → 0.4.32
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/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +3 -3
- package/lib/clients/ZILClient.js +17 -17
- package/lib/codec/cosmos/gov/v1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1/tx.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/group/v1/events.js +2 -2
- package/lib/codec/cosmos/group/v1/tx.js +4 -4
- package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
- package/lib/constant/generic.js +1 -1
- package/lib/modules/cdp.js +44 -44
- package/lib/modules/cosmwasm.js +1 -1
- package/lib/modules/gov.js +12 -12
- package/lib/modules/ibc.d.ts +3 -0
- package/lib/modules/ibc.js +16 -18
- 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 +27 -27
- 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 +25 -25
- 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 +2 -2
- 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.js +1 -1
- 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/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- 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/clients/BatchQueryClient.d.ts +0 -26
- package/lib/clients/BatchQueryClient.js +0 -100
- package/lib/codec/crisis/genesis.d.ts +0 -18
- package/lib/codec/crisis/genesis.js +0 -46
- package/lib/codec/crisis/query.d.ts +0 -43
- package/lib/codec/crisis/query.js +0 -103
- package/lib/codec/crisis/tx.d.ts +0 -12
- package/lib/codec/crisis/tx.js +0 -20
- package/lib/codec/erc20/erc20.d.ts +0 -41
- package/lib/codec/erc20/erc20.js +0 -144
- package/lib/codec/erc20/events.d.ts +0 -76
- package/lib/codec/erc20/events.js +0 -330
- package/lib/codec/erc20/genesis.d.ts +0 -40
- package/lib/codec/erc20/genesis.js +0 -139
- package/lib/codec/erc20/query.d.ts +0 -117
- package/lib/codec/erc20/query.js +0 -333
- package/lib/codec/erc20/tx.d.ts +0 -232
- package/lib/codec/erc20/tx.js +0 -765
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.d.ts +0 -1
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +0 -6
- package/lib/codec/ethermint/evm/v1/export.d.ts +0 -5
- package/lib/codec/ethermint/evm/v1/export.js +0 -53
- package/lib/codec/ethermint/feemarket/v1/export.d.ts +0 -4
- package/lib/codec/ethermint/feemarket/v1/export.js +0 -18
- package/lib/codec/ethermint/types/v1/export.d.ts +0 -4
- package/lib/codec/ethermint/types/v1/export.js +0 -11
- package/lib/codec/ethermint-models.d.ts +0 -4
- package/lib/codec/ethermint-models.js +0 -26
- package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.d.ts +0 -76
- package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.js +0 -424
- package/lib/codec/market/fee.d.ts +0 -123
- package/lib/codec/market/fee.js +0 -334
- package/lib/codec/market/legacy.d.ts +0 -62
- package/lib/codec/market/legacy.js +0 -630
- package/lib/codec/perpsliquidity/event.d.ts +0 -102
- package/lib/codec/perpsliquidity/event.js +0 -581
- package/lib/codec/perpsliquidity/genesis.d.ts +0 -35
- package/lib/codec/perpsliquidity/genesis.js +0 -162
- package/lib/codec/perpsliquidity/params.d.ts +0 -24
- package/lib/codec/perpsliquidity/params.js +0 -103
- package/lib/codec/perpsliquidity/pool.d.ts +0 -137
- package/lib/codec/perpsliquidity/pool.js +0 -747
- package/lib/codec/perpsliquidity/query.d.ts +0 -194
- package/lib/codec/perpsliquidity/query.js +0 -876
- package/lib/codec/perpsliquidity/tx.d.ts +0 -199
- package/lib/codec/perpsliquidity/tx.js +0 -940
- package/lib/codec/query/pagination.d.ts +0 -29
- package/lib/codec/query/pagination.js +0 -126
- package/lib/constant/eip712.d.ts +0 -46
- package/lib/constant/eip712.js +0 -106
- package/lib/insights/delegation.d.ts +0 -26
- package/lib/insights/delegation.js +0 -2
- package/lib/insights/oracles.d.ts +0 -17
- package/lib/insights/oracles.js +0 -2
- package/lib/modules/evm.d.ts +0 -46
- package/lib/modules/evm.js +0 -127
- package/lib/modules/evmmerge.d.ts +0 -12
- package/lib/modules/evmmerge.js +0 -35
- package/lib/modules/feemarket.d.ts +0 -20
- package/lib/modules/feemarket.js +0 -45
- package/lib/modules/perpsliquidity.d.ts +0 -56
- package/lib/modules/perpsliquidity.js +0 -128
- package/lib/modules/vault.d.ts +0 -56
- package/lib/modules/vault.js +0 -128
- package/lib/provider/amino/types/evm.d.ts +0 -4
- package/lib/provider/amino/types/evm.js +0 -40
- package/lib/provider/amino/types/evmmerge.d.ts +0 -4
- package/lib/provider/amino/types/evmmerge.js +0 -34
- package/lib/provider/amino/types/feemarket.d.ts +0 -4
- package/lib/provider/amino/types/feemarket.js +0 -34
- package/lib/provider/amino/types/perpsliquidity.d.ts +0 -4
- package/lib/provider/amino/types/perpsliquidity.js +0 -72
- package/lib/provider/metamask/legacy-accounts.d.ts +0 -10
- package/lib/provider/metamask/legacy-accounts.js +0 -2208
- package/lib/util/eip712.d.ts +0 -10
- package/lib/util/eip712.js +0 -195
- package/lib/util/ethermint.d.ts +0 -8
- package/lib/util/ethermint.js +0 -68
- package/lib/util/legacyEIP712.d.ts +0 -20
- package/lib/util/legacyEIP712.js +0 -98
|
@@ -48,7 +48,7 @@ class CarbonQueryClient {
|
|
|
48
48
|
constructor(tmClient) {
|
|
49
49
|
this.tmClient = tmClient;
|
|
50
50
|
this.baseClient = new stargate_1.QueryClient(this.tmClient);
|
|
51
|
-
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
51
|
+
const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
52
52
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
53
53
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
54
54
|
this.alliance = new query_39.QueryClientImpl(rpcClient);
|
|
@@ -93,7 +93,7 @@ class CarbonQueryClient {
|
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
getProtobufRpcClient() {
|
|
96
|
-
return stargate_1.createProtobufRpcClient(this.baseClient);
|
|
96
|
+
return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
exports.default = CarbonQueryClient;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -44,15 +44,15 @@ class ETHClient {
|
|
|
44
44
|
?
|
|
45
45
|
this.tokenClient.getBlockchainV2(token.denom) == ETHClient.BLOCKCHAINV2_MAPPING[this.blockchain]
|
|
46
46
|
:
|
|
47
|
-
blockchain_1.blockchainForChainId(token.chainId.toNumber(), api.network) == this.blockchain;
|
|
47
|
+
(0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), api.network) == this.blockchain;
|
|
48
48
|
return isCorrectBlockchain &&
|
|
49
49
|
token.tokenAddress.length == 40 &&
|
|
50
|
-
token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
|
|
50
|
+
token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
|
|
51
51
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
|
|
52
|
-
this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
52
|
+
this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
53
53
|
});
|
|
54
54
|
const assetIds = tokens.map((token) => {
|
|
55
|
-
return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
55
|
+
return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
56
56
|
});
|
|
57
57
|
const provider = this.getProvider();
|
|
58
58
|
const contractAddress = this.getBalanceReaderAddress();
|
|
@@ -99,14 +99,14 @@ class ETHClient {
|
|
|
99
99
|
}
|
|
100
100
|
const carbonNetwork = networkConfig.network;
|
|
101
101
|
const fromTokenId = fromToken.id;
|
|
102
|
-
const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
102
|
+
const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
103
103
|
const toTokenDenom = toToken.denom;
|
|
104
104
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
105
105
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
106
106
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
107
107
|
const nonce = yield this.getTxNonce(fromAddress, params.nonce, rpcProvider);
|
|
108
108
|
const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
|
|
109
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
109
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
110
110
|
const tokenCreator = fromToken.creator;
|
|
111
111
|
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, carbonNetwork);
|
|
112
112
|
const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
|
|
@@ -135,9 +135,9 @@ class ETHClient {
|
|
|
135
135
|
throw new Error("Minimum gas required: 150,000");
|
|
136
136
|
}
|
|
137
137
|
const networkConfig = this.getNetworkConfig();
|
|
138
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
139
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
140
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
138
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
139
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
140
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
141
141
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
142
142
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
143
143
|
const contractAddress = this.getLockProxyAddress();
|
|
@@ -188,16 +188,16 @@ class ETHClient {
|
|
|
188
188
|
return "insufficient balance";
|
|
189
189
|
}
|
|
190
190
|
const networkConfig = this.getNetworkConfig();
|
|
191
|
-
const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
|
|
192
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
193
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
191
|
+
const assetId = (0, generic_1.appendHexPrefix)(tokenWithExternalBalances.tokenAddress);
|
|
192
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
193
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
194
194
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
|
|
195
195
|
const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
|
|
196
196
|
const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
|
|
197
197
|
// logger("sendDeposit message", message)
|
|
198
198
|
let signatureResult;
|
|
199
199
|
const { address, signature } = yield getSignatureCallback(message);
|
|
200
|
-
const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
|
|
200
|
+
const signatureBytes = ethers_1.ethers.utils.arrayify((0, generic_1.appendHexPrefix)(signature));
|
|
201
201
|
const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
|
|
202
202
|
// logger("sign result", address, signature)
|
|
203
203
|
signatureResult = {
|
|
@@ -236,7 +236,7 @@ class ETHClient {
|
|
|
236
236
|
if (!feeInfo.deposit_fee) {
|
|
237
237
|
throw new Error("unsupported token");
|
|
238
238
|
}
|
|
239
|
-
if (blockchain_1.blockchainForChainId(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
239
|
+
if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
240
240
|
throw new Error("unsupported token");
|
|
241
241
|
}
|
|
242
242
|
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
|
|
@@ -302,7 +302,7 @@ class ETHClient {
|
|
|
302
302
|
getTargetProxyHash(token) {
|
|
303
303
|
const networkConfig = this.getNetworkConfig();
|
|
304
304
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
305
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
305
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
306
306
|
return addressHex;
|
|
307
307
|
}
|
|
308
308
|
getProvider() {
|
|
@@ -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
|
// temporary function to parse okt/okc blockchain
|
|
35
35
|
// to remove when automatic deposit/withdraw feature is deployed
|
package/lib/clients/NEOClient.js
CHANGED
|
@@ -69,13 +69,13 @@ class NEOClient {
|
|
|
69
69
|
?
|
|
70
70
|
!!sdk.token.getBlockchainV2(token.denom) && (blockchain_1.BLOCKCHAIN_V2_TO_V1_MAPPING[sdk.token.getBlockchainV2(token.denom)] == this.blockchain)
|
|
71
71
|
:
|
|
72
|
-
blockchain_1.blockchainForChainId(token.chainId.toNumber(), sdk.network) == this.blockchain;
|
|
72
|
+
(0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), sdk.network) == this.blockchain;
|
|
73
73
|
return (isCorrectBlockchain || token.denom === "swth") && token.tokenAddress.length == 40 && token.bridgeAddress.length == 40;
|
|
74
74
|
});
|
|
75
75
|
const client = new Neon.rpc.RPCClient(url, "2.5.2"); // TODO: should we change the RPC version??
|
|
76
76
|
// NOTE: fetching of tokens is chunked in sets of 15 as we may hit
|
|
77
77
|
// the gas limit on the RPC node and error out otherwise
|
|
78
|
-
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* () {
|
|
79
79
|
var _a, _b, _c;
|
|
80
80
|
let acc = {};
|
|
81
81
|
for (const token of partition) {
|
|
@@ -117,8 +117,8 @@ class NEOClient {
|
|
|
117
117
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
118
118
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
119
119
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(swthAddress, networkConfig.network);
|
|
120
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
121
|
-
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));
|
|
122
122
|
const amount = ethers_1.ethers.BigNumber.from(token.externalBalance);
|
|
123
123
|
const feeAmount = ethers_1.ethers.BigNumber.from(feeAmountInput !== null && feeAmountInput !== void 0 ? feeAmountInput : "100000000");
|
|
124
124
|
const feeAddress = feeAmount.isZero() ? zeroAddressHex : networkConfig.feeAddress;
|
|
@@ -165,7 +165,7 @@ class NEOClient {
|
|
|
165
165
|
const fromAddress = util_1.AddressUtils.NEOAddress.publicKeyToAddress(publicKeyOutput.publicKey);
|
|
166
166
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
167
167
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
168
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
168
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
169
169
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
170
170
|
if (amount.lt(feeAmount)) {
|
|
171
171
|
throw new Error("Invalid amount");
|
|
@@ -201,7 +201,7 @@ class NEOClient {
|
|
|
201
201
|
const fromAddress = ledger.scriptHash;
|
|
202
202
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
203
203
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
204
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
204
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
205
205
|
const feeAddress = networkConfig.feeAddress;
|
|
206
206
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
207
207
|
if (amount.lt(feeAmount)) {
|
|
@@ -321,7 +321,7 @@ class NEOClient {
|
|
|
321
321
|
getTargetProxyHash(token) {
|
|
322
322
|
const networkConfig = this.getNetworkConfig();
|
|
323
323
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
324
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
324
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
325
325
|
return addressHex;
|
|
326
326
|
}
|
|
327
327
|
getNetworkConfig() {
|
|
@@ -570,7 +570,7 @@ class TokenClient {
|
|
|
570
570
|
if (!token)
|
|
571
571
|
return undefined;
|
|
572
572
|
const bridge = this.getBridgeFromToken(token);
|
|
573
|
-
if (!bridge || !blockchain_1.isIbcBridge(bridge))
|
|
573
|
+
if (!bridge || !(0, blockchain_1.isIbcBridge)(bridge))
|
|
574
574
|
return undefined;
|
|
575
575
|
return bridge.chain_id_name;
|
|
576
576
|
}
|
|
@@ -579,7 +579,7 @@ class TokenClient {
|
|
|
579
579
|
// get swth on osmosis
|
|
580
580
|
const osmoTmClient = yield tendermint_rpc_1.Tendermint34Client.connect(network_1.publicRpcNodes.Osmosis);
|
|
581
581
|
const osmoClient = new stargate_1.QueryClient(osmoTmClient);
|
|
582
|
-
const osmosRpcClient = stargate_1.createProtobufRpcClient(osmoClient);
|
|
582
|
+
const osmosRpcClient = (0, stargate_1.createProtobufRpcClient)(osmoClient);
|
|
583
583
|
const osmoIbcClient = new query_1.QueryClientImpl(osmosRpcClient);
|
|
584
584
|
const osmoDenomTraces = yield osmoIbcClient.DenomTraces({
|
|
585
585
|
pagination: pagination_1.PageRequest.fromPartial({
|
|
@@ -672,7 +672,7 @@ class TokenClient {
|
|
|
672
672
|
processTokenPrices(tokenPrices) {
|
|
673
673
|
return tokenPrices.reduce((prevPrices, price) => {
|
|
674
674
|
const newPrev = prevPrices;
|
|
675
|
-
newPrev[price.denom] = number_1.bnOrZero(price.twap).shiftedBy(-constant_1.decTypeDecimals);
|
|
675
|
+
newPrev[price.denom] = (0, number_1.bnOrZero)(price.twap).shiftedBy(-constant_1.decTypeDecimals);
|
|
676
676
|
return newPrev;
|
|
677
677
|
}, {});
|
|
678
678
|
}
|
package/lib/clients/ZILClient.js
CHANGED
|
@@ -77,12 +77,12 @@ class ZILClient {
|
|
|
77
77
|
?
|
|
78
78
|
!!sdk.token.getBlockchainV2(token.denom) && (blockchain_1.BLOCKCHAIN_V2_TO_V1_MAPPING[sdk.token.getBlockchainV2(token.denom)] == this.blockchain)
|
|
79
79
|
:
|
|
80
|
-
blockchain_1.blockchainForChainId(token.chainId.toNumber(), sdk.network) == this.blockchain;
|
|
80
|
+
(0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), sdk.network) == this.blockchain;
|
|
81
81
|
return isCorrectBlockchain && token.tokenAddress.length == 40 && (!whitelistDenoms || whitelistDenoms.includes(token.denom));
|
|
82
82
|
});
|
|
83
83
|
const requests = tokens.map((token) => token.tokenAddress === zeroAddress
|
|
84
|
-
? exports.balanceBatchRequest(address.replace(/^0x/i, ""))
|
|
85
|
-
: exports.tokenBalanceBatchRequest(token.tokenAddress, address));
|
|
84
|
+
? (0, exports.balanceBatchRequest)(address.replace(/^0x/i, ""))
|
|
85
|
+
: (0, exports.tokenBalanceBatchRequest)(token.tokenAddress, address));
|
|
86
86
|
const response = yield fetch(this.getProviderUrl(), {
|
|
87
87
|
method: "post",
|
|
88
88
|
headers: { "content-type": "application/json" },
|
|
@@ -107,7 +107,7 @@ class ZILClient {
|
|
|
107
107
|
// if (!isValidAddress) {
|
|
108
108
|
// throw new Error("invalid address")
|
|
109
109
|
// }
|
|
110
|
-
return zilliqa_1.fromBech32Address(bech32Address).toLowerCase().substr(2);
|
|
110
|
+
return (0, zilliqa_1.fromBech32Address)(bech32Address).toLowerCase().substr(2);
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
// see examplesV2/zil_client.ts on how to confirm the transactions
|
|
@@ -153,7 +153,7 @@ class ZILClient {
|
|
|
153
153
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
154
154
|
}
|
|
155
155
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
156
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
156
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
|
|
157
157
|
if (balanceAndNonceResp.error !== undefined) {
|
|
158
158
|
throw new Error(balanceAndNonceResp.error.message);
|
|
159
159
|
}
|
|
@@ -171,7 +171,7 @@ class ZILClient {
|
|
|
171
171
|
vname: "spender",
|
|
172
172
|
type: "ByStr20",
|
|
173
173
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
174
|
-
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : generic_1.appendHexPrefix(token.bridgeAddress),
|
|
174
|
+
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : (0, generic_1.appendHexPrefix)(token.bridgeAddress),
|
|
175
175
|
},
|
|
176
176
|
{
|
|
177
177
|
vname: "amount",
|
|
@@ -189,7 +189,7 @@ class ZILClient {
|
|
|
189
189
|
}
|
|
190
190
|
checkAllowanceZRC2(token, owner, spender) {
|
|
191
191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
const contractAddress = generic_1.appendHexPrefix(token.tokenAddress);
|
|
192
|
+
const contractAddress = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
193
193
|
const zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
194
194
|
const resp = yield zilliqa.blockchain.getSmartContractSubState(contractAddress, "allowances", [owner, spender]);
|
|
195
195
|
if (resp.error !== undefined) {
|
|
@@ -211,13 +211,13 @@ class ZILClient {
|
|
|
211
211
|
}
|
|
212
212
|
const carbonNetwork = networkConfig.network;
|
|
213
213
|
const fromTokenId = fromToken.id;
|
|
214
|
-
const fromTokenAddr = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
214
|
+
const fromTokenAddr = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
215
215
|
const toTokenDenom = toToken.denom;
|
|
216
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(fromToken));
|
|
216
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(fromToken));
|
|
217
217
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
218
218
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
219
219
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
220
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
220
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
221
221
|
const contractAddress = this.getBridgeEntranceAddr();
|
|
222
222
|
let zilliqa;
|
|
223
223
|
if (typeof signer === "string") {
|
|
@@ -232,7 +232,7 @@ class ZILClient {
|
|
|
232
232
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
233
233
|
}
|
|
234
234
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
235
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(fromAddress));
|
|
235
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(fromAddress));
|
|
236
236
|
if (balanceAndNonceResp.error !== undefined) {
|
|
237
237
|
throw new Error(balanceAndNonceResp.error.message);
|
|
238
238
|
}
|
|
@@ -309,13 +309,13 @@ class ZILClient {
|
|
|
309
309
|
return __awaiter(this, void 0, void 0, function* () {
|
|
310
310
|
const { address, amount, token, gasPrice, gasLimit, zilAddress, signer } = params;
|
|
311
311
|
const networkConfig = this.getNetworkConfig();
|
|
312
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
313
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
314
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
312
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
313
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
314
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
315
315
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
316
316
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
317
317
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
318
|
-
const contractAddress = generic_1.appendHexPrefix(token.bridgeAddress);
|
|
318
|
+
const contractAddress = (0, generic_1.appendHexPrefix)(token.bridgeAddress);
|
|
319
319
|
let zilliqa;
|
|
320
320
|
if (typeof signer === "string") {
|
|
321
321
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
@@ -329,7 +329,7 @@ class ZILClient {
|
|
|
329
329
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
330
330
|
}
|
|
331
331
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
332
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
332
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
|
|
333
333
|
if (balanceAndNonceResp.error !== undefined) {
|
|
334
334
|
throw new Error(balanceAndNonceResp.error.message);
|
|
335
335
|
}
|
|
@@ -414,7 +414,7 @@ class ZILClient {
|
|
|
414
414
|
getTargetProxyHash(token) {
|
|
415
415
|
const networkConfig = this.getNetworkConfig();
|
|
416
416
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
417
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
417
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
418
418
|
return addressHex;
|
|
419
419
|
}
|
|
420
420
|
getNetworkConfig() {
|
|
@@ -159,7 +159,7 @@ exports.QueryProposalsRequest = {
|
|
|
159
159
|
const message = Object.assign({}, baseQueryProposalsRequest);
|
|
160
160
|
message.proposalStatus =
|
|
161
161
|
object.proposalStatus !== undefined && object.proposalStatus !== null
|
|
162
|
-
? gov_1.proposalStatusFromJSON(object.proposalStatus)
|
|
162
|
+
? (0, gov_1.proposalStatusFromJSON)(object.proposalStatus)
|
|
163
163
|
: 0;
|
|
164
164
|
message.voter =
|
|
165
165
|
object.voter !== undefined && object.voter !== null
|
|
@@ -178,7 +178,7 @@ exports.QueryProposalsRequest = {
|
|
|
178
178
|
toJSON(message) {
|
|
179
179
|
const obj = {};
|
|
180
180
|
message.proposalStatus !== undefined &&
|
|
181
|
-
(obj.proposalStatus = gov_1.proposalStatusToJSON(message.proposalStatus));
|
|
181
|
+
(obj.proposalStatus = (0, gov_1.proposalStatusToJSON)(message.proposalStatus));
|
|
182
182
|
message.voter !== undefined && (obj.voter = message.voter);
|
|
183
183
|
message.depositor !== undefined && (obj.depositor = message.depositor);
|
|
184
184
|
message.pagination !== undefined &&
|
|
@@ -300,7 +300,7 @@ exports.MsgVote = {
|
|
|
300
300
|
: "";
|
|
301
301
|
message.option =
|
|
302
302
|
object.option !== undefined && object.option !== null
|
|
303
|
-
? gov_1.voteOptionFromJSON(object.option)
|
|
303
|
+
? (0, gov_1.voteOptionFromJSON)(object.option)
|
|
304
304
|
: 0;
|
|
305
305
|
message.metadata =
|
|
306
306
|
object.metadata !== undefined && object.metadata !== null
|
|
@@ -314,7 +314,7 @@ exports.MsgVote = {
|
|
|
314
314
|
(obj.proposalId = (message.proposalId || long_1.default.UZERO).toString());
|
|
315
315
|
message.voter !== undefined && (obj.voter = message.voter);
|
|
316
316
|
message.option !== undefined &&
|
|
317
|
-
(obj.option = gov_1.voteOptionToJSON(message.option));
|
|
317
|
+
(obj.option = (0, gov_1.voteOptionToJSON)(message.option));
|
|
318
318
|
message.metadata !== undefined && (obj.metadata = message.metadata);
|
|
319
319
|
return obj;
|
|
320
320
|
},
|
|
@@ -159,7 +159,7 @@ exports.QueryProposalsRequest = {
|
|
|
159
159
|
const message = Object.assign({}, baseQueryProposalsRequest);
|
|
160
160
|
message.proposalStatus =
|
|
161
161
|
object.proposalStatus !== undefined && object.proposalStatus !== null
|
|
162
|
-
? gov_1.proposalStatusFromJSON(object.proposalStatus)
|
|
162
|
+
? (0, gov_1.proposalStatusFromJSON)(object.proposalStatus)
|
|
163
163
|
: 0;
|
|
164
164
|
message.voter =
|
|
165
165
|
object.voter !== undefined && object.voter !== null
|
|
@@ -178,7 +178,7 @@ exports.QueryProposalsRequest = {
|
|
|
178
178
|
toJSON(message) {
|
|
179
179
|
const obj = {};
|
|
180
180
|
message.proposalStatus !== undefined &&
|
|
181
|
-
(obj.proposalStatus = gov_1.proposalStatusToJSON(message.proposalStatus));
|
|
181
|
+
(obj.proposalStatus = (0, gov_1.proposalStatusToJSON)(message.proposalStatus));
|
|
182
182
|
message.voter !== undefined && (obj.voter = message.voter);
|
|
183
183
|
message.depositor !== undefined && (obj.depositor = message.depositor);
|
|
184
184
|
message.pagination !== undefined &&
|
|
@@ -185,7 +185,7 @@ exports.MsgVote = {
|
|
|
185
185
|
: "";
|
|
186
186
|
message.option =
|
|
187
187
|
object.option !== undefined && object.option !== null
|
|
188
|
-
? gov_1.voteOptionFromJSON(object.option)
|
|
188
|
+
? (0, gov_1.voteOptionFromJSON)(object.option)
|
|
189
189
|
: 0;
|
|
190
190
|
return message;
|
|
191
191
|
},
|
|
@@ -195,7 +195,7 @@ exports.MsgVote = {
|
|
|
195
195
|
(obj.proposalId = (message.proposalId || long_1.default.UZERO).toString());
|
|
196
196
|
message.voter !== undefined && (obj.voter = message.voter);
|
|
197
197
|
message.option !== undefined &&
|
|
198
|
-
(obj.option = gov_1.voteOptionToJSON(message.option));
|
|
198
|
+
(obj.option = (0, gov_1.voteOptionToJSON)(message.option));
|
|
199
199
|
return obj;
|
|
200
200
|
},
|
|
201
201
|
fromPartial(object) {
|
|
@@ -384,7 +384,7 @@ exports.EventExec = {
|
|
|
384
384
|
: long_1.default.UZERO;
|
|
385
385
|
message.result =
|
|
386
386
|
object.result !== undefined && object.result !== null
|
|
387
|
-
? types_1.proposalExecutorResultFromJSON(object.result)
|
|
387
|
+
? (0, types_1.proposalExecutorResultFromJSON)(object.result)
|
|
388
388
|
: 0;
|
|
389
389
|
message.logs =
|
|
390
390
|
object.logs !== undefined && object.logs !== null
|
|
@@ -397,7 +397,7 @@ exports.EventExec = {
|
|
|
397
397
|
message.proposalId !== undefined &&
|
|
398
398
|
(obj.proposalId = (message.proposalId || long_1.default.UZERO).toString());
|
|
399
399
|
message.result !== undefined &&
|
|
400
|
-
(obj.result = types_1.proposalExecutorResultToJSON(message.result));
|
|
400
|
+
(obj.result = (0, types_1.proposalExecutorResultToJSON)(message.result));
|
|
401
401
|
message.logs !== undefined && (obj.logs = message.logs);
|
|
402
402
|
return obj;
|
|
403
403
|
},
|
|
@@ -1474,7 +1474,7 @@ exports.MsgVote = {
|
|
|
1474
1474
|
: "";
|
|
1475
1475
|
message.option =
|
|
1476
1476
|
object.option !== undefined && object.option !== null
|
|
1477
|
-
? types_1.voteOptionFromJSON(object.option)
|
|
1477
|
+
? (0, types_1.voteOptionFromJSON)(object.option)
|
|
1478
1478
|
: 0;
|
|
1479
1479
|
message.metadata =
|
|
1480
1480
|
object.metadata !== undefined && object.metadata !== null
|
|
@@ -1492,7 +1492,7 @@ exports.MsgVote = {
|
|
|
1492
1492
|
(obj.proposalId = (message.proposalId || long_1.default.UZERO).toString());
|
|
1493
1493
|
message.voter !== undefined && (obj.voter = message.voter);
|
|
1494
1494
|
message.option !== undefined &&
|
|
1495
|
-
(obj.option = types_1.voteOptionToJSON(message.option));
|
|
1495
|
+
(obj.option = (0, types_1.voteOptionToJSON)(message.option));
|
|
1496
1496
|
message.metadata !== undefined && (obj.metadata = message.metadata);
|
|
1497
1497
|
message.exec !== undefined && (obj.exec = execToJSON(message.exec));
|
|
1498
1498
|
return obj;
|
|
@@ -1633,14 +1633,14 @@ exports.MsgExecResponse = {
|
|
|
1633
1633
|
const message = Object.assign({}, baseMsgExecResponse);
|
|
1634
1634
|
message.result =
|
|
1635
1635
|
object.result !== undefined && object.result !== null
|
|
1636
|
-
? types_1.proposalExecutorResultFromJSON(object.result)
|
|
1636
|
+
? (0, types_1.proposalExecutorResultFromJSON)(object.result)
|
|
1637
1637
|
: 0;
|
|
1638
1638
|
return message;
|
|
1639
1639
|
},
|
|
1640
1640
|
toJSON(message) {
|
|
1641
1641
|
const obj = {};
|
|
1642
1642
|
message.result !== undefined &&
|
|
1643
|
-
(obj.result = types_1.proposalExecutorResultToJSON(message.result));
|
|
1643
|
+
(obj.result = (0, types_1.proposalExecutorResultToJSON)(message.result));
|
|
1644
1644
|
return obj;
|
|
1645
1645
|
},
|
|
1646
1646
|
fromPartial(object) {
|
|
@@ -763,13 +763,13 @@ exports.ModeInfo_Single = {
|
|
|
763
763
|
const message = Object.assign({}, baseModeInfo_Single);
|
|
764
764
|
message.mode =
|
|
765
765
|
object.mode !== undefined && object.mode !== null
|
|
766
|
-
? signing_1.signModeFromJSON(object.mode)
|
|
766
|
+
? (0, signing_1.signModeFromJSON)(object.mode)
|
|
767
767
|
: 0;
|
|
768
768
|
return message;
|
|
769
769
|
},
|
|
770
770
|
toJSON(message) {
|
|
771
771
|
const obj = {};
|
|
772
|
-
message.mode !== undefined && (obj.mode = signing_1.signModeToJSON(message.mode));
|
|
772
|
+
message.mode !== undefined && (obj.mode = (0, signing_1.signModeToJSON)(message.mode));
|
|
773
773
|
return obj;
|
|
774
774
|
},
|
|
775
775
|
fromPartial(object) {
|
|
@@ -1052,7 +1052,7 @@ exports.AuxSignerData = {
|
|
|
1052
1052
|
: undefined;
|
|
1053
1053
|
message.mode =
|
|
1054
1054
|
object.mode !== undefined && object.mode !== null
|
|
1055
|
-
? signing_1.signModeFromJSON(object.mode)
|
|
1055
|
+
? (0, signing_1.signModeFromJSON)(object.mode)
|
|
1056
1056
|
: 0;
|
|
1057
1057
|
message.sig =
|
|
1058
1058
|
object.sig !== undefined && object.sig !== null
|
|
@@ -1067,7 +1067,7 @@ exports.AuxSignerData = {
|
|
|
1067
1067
|
(obj.signDoc = message.signDoc
|
|
1068
1068
|
? exports.SignDocDirectAux.toJSON(message.signDoc)
|
|
1069
1069
|
: undefined);
|
|
1070
|
-
message.mode !== undefined && (obj.mode = signing_1.signModeToJSON(message.mode));
|
|
1070
|
+
message.mode !== undefined && (obj.mode = (0, signing_1.signModeToJSON)(message.mode));
|
|
1071
1071
|
message.sig !== undefined &&
|
|
1072
1072
|
(obj.sig = base64FromBytes(message.sig !== undefined ? message.sig : new Uint8Array()));
|
|
1073
1073
|
return obj;
|
package/lib/constant/generic.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.DEFAULT_FEE_DENOM = "swth";
|
|
|
12
12
|
exports.DEFAULT_GAS_PRICE = new bignumber_js_1.default(10);
|
|
13
13
|
exports.DEFAULT_GAS = new bignumber_js_1.default(10000000);
|
|
14
14
|
exports.DEFAULT_FEE = {
|
|
15
|
-
amount: proto_signing_1.coins(exports.DEFAULT_GAS_PRICE.times(exports.DEFAULT_GAS).dp(0).toString(), "swth"),
|
|
15
|
+
amount: (0, proto_signing_1.coins)(exports.DEFAULT_GAS_PRICE.times(exports.DEFAULT_GAS).dp(0).toString(), "swth"),
|
|
16
16
|
gas: exports.DEFAULT_GAS.toString(10),
|
|
17
17
|
};
|
|
18
18
|
exports.CARBON_GAS_PRICE = {
|