carbon-js-sdk 0.5.13 → 0.5.14-rc2
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/BatchQueryClient.js +4 -4
- package/lib/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/GrpcNodeQueryClient.d.ts +12 -0
- package/lib/clients/GrpcNodeQueryClient.js +53 -0
- package/lib/clients/GrpcQueryClient.d.ts +1 -1
- package/lib/clients/GrpcQueryClient.js +1 -1
- package/lib/clients/GrpcWebQueryClient.d.ts +22 -0
- package/lib/clients/GrpcWebQueryClient.js +56 -0
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.d.ts +0 -8
- package/lib/clients/TokenClient.js +4 -60
- 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/codec/ibc/applications/interchain_accounts/v1/genesis.d.ts +76 -0
- package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.js +424 -0
- package/lib/constant/generic.js +1 -1
- package/lib/constant/ibc.d.ts +2 -0
- package/lib/constant/network.d.ts +0 -2
- package/lib/constant/network.js +1 -5
- package/lib/modules/cdp.js +44 -44
- package/lib/modules/cosmwasm.d.ts +6 -2
- package/lib/modules/cosmwasm.js +26 -6
- package/lib/modules/evm.js +5 -5
- package/lib/modules/gov.js +12 -12
- package/lib/modules/ibc.d.ts +3 -3
- package/lib/modules/ibc.js +33 -49
- package/lib/modules/liquiditypool.js +1 -1
- package/lib/modules/order.js +2 -2
- 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/erc20.js +2 -2
- package/lib/provider/amino/types/evm.js +2 -2
- package/lib/provider/amino/types/evmmerge.js +1 -1
- package/lib/provider/amino/types/feemarket.js +1 -1
- package/lib/provider/amino/types/gov.js +5 -5
- 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 +6 -6
- package/lib/provider/amino/types/oracle.js +2 -2
- package/lib/provider/amino/types/order.js +4 -4
- package/lib/provider/amino/types/perpsliquidity.js +6 -6
- 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/keplr/KeplrAccount.js +2 -2
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +10 -10
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +14 -14
- package/lib/util/api.js +4 -4
- package/lib/util/blockchain.js +4 -4
- package/lib/util/eip712.js +3 -3
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.d.ts +4 -0
- package/lib/util/generic.js +22 -4
- package/lib/util/legacyEIP712.js +2 -2
- package/lib/util/number.js +5 -5
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +15 -15
- package/lib/wallet/CarbonWallet.js +9 -9
- package/lib/websocket/connector.js +3 -3
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ class BatchQueryClient {
|
|
|
29
29
|
};
|
|
30
30
|
if (typeof endpoint === "string") {
|
|
31
31
|
// accept host.name:port and assume http protocol
|
|
32
|
-
this.url = rpcclient_1.hasProtocol(endpoint) ? endpoint : "http://" + endpoint;
|
|
32
|
+
this.url = (0, rpcclient_1.hasProtocol)(endpoint) ? endpoint : "http://" + endpoint;
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
this.url = endpoint.url;
|
|
@@ -71,7 +71,7 @@ class BatchQueryClient {
|
|
|
71
71
|
return;
|
|
72
72
|
const requests = batch.map((s) => s.request);
|
|
73
73
|
const requestIds = requests.map((request) => request.id);
|
|
74
|
-
http_1.http("POST", this.url, this.headers, requests).then((raw) => {
|
|
74
|
+
(0, http_1.http)("POST", this.url, this.headers, requests).then((raw) => {
|
|
75
75
|
// Requests with a single entry return as an object
|
|
76
76
|
const arr = Array.isArray(raw) ? raw : [raw];
|
|
77
77
|
arr.forEach((el, i) => {
|
|
@@ -79,8 +79,8 @@ class BatchQueryClient {
|
|
|
79
79
|
if (!req)
|
|
80
80
|
return;
|
|
81
81
|
const { reject, resolve } = req;
|
|
82
|
-
const response = json_rpc_1.parseJsonRpcResponse(el);
|
|
83
|
-
if (json_rpc_1.isJsonRpcErrorResponse(response)) {
|
|
82
|
+
const response = (0, json_rpc_1.parseJsonRpcResponse)(el);
|
|
83
|
+
if ((0, json_rpc_1.isJsonRpcErrorResponse)(response)) {
|
|
84
84
|
reject(new Error(JSON.stringify(response.error)));
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
@@ -53,7 +53,7 @@ class CarbonQueryClient {
|
|
|
53
53
|
constructor(tmClient) {
|
|
54
54
|
this.tmClient = tmClient;
|
|
55
55
|
this.baseClient = new stargate_1.QueryClient(this.tmClient);
|
|
56
|
-
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
56
|
+
const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
57
57
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
58
58
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
59
59
|
this.alliance = new query_44.QueryClientImpl(rpcClient);
|
|
@@ -106,7 +106,7 @@ class CarbonQueryClient {
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
getProtobufRpcClient() {
|
|
109
|
-
return stargate_1.createProtobufRpcClient(this.baseClient);
|
|
109
|
+
return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
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() {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GrpcQueryClient } from "../util/type";
|
|
2
|
+
import * as grpc from "@grpc/grpc-js";
|
|
3
|
+
export declare class GrpcNodeQueryClient implements GrpcQueryClient {
|
|
4
|
+
private host;
|
|
5
|
+
private options;
|
|
6
|
+
private client;
|
|
7
|
+
constructor(host: string, options?: {
|
|
8
|
+
metadata?: grpc.Metadata;
|
|
9
|
+
});
|
|
10
|
+
request(serviceName: string, methodName: string, data: Uint8Array): Promise<Uint8Array>;
|
|
11
|
+
}
|
|
12
|
+
export default GrpcNodeQueryClient;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.GrpcNodeQueryClient = void 0;
|
|
27
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
28
|
+
const PASS_THROUGH_SERIALIZE = (bytes) => Buffer.from(bytes);
|
|
29
|
+
const PASS_THROUGH_DESERIALIZE = (buffer) => new Uint8Array(buffer);
|
|
30
|
+
class GrpcNodeQueryClient {
|
|
31
|
+
constructor(host, options = {}) {
|
|
32
|
+
this.host = host;
|
|
33
|
+
this.options = options;
|
|
34
|
+
this.client = new grpc.Client(this.host, grpc.credentials.createSsl());
|
|
35
|
+
}
|
|
36
|
+
request(serviceName, methodName, data) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const method = `/${serviceName}/${methodName}`;
|
|
40
|
+
const metadata = (_a = this.options.metadata) !== null && _a !== void 0 ? _a : grpc.Metadata.fromHttp2Headers({});
|
|
41
|
+
this.client.makeUnaryRequest(method, PASS_THROUGH_SERIALIZE, PASS_THROUGH_DESERIALIZE, data, metadata, (error, result) => {
|
|
42
|
+
if (error || !result) {
|
|
43
|
+
reject(error);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
resolve(result);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.GrpcNodeQueryClient = GrpcNodeQueryClient;
|
|
53
|
+
exports.default = GrpcNodeQueryClient;
|
|
@@ -7,7 +7,7 @@ export declare class GrpcWebError extends Error {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Uses grpc-web module on cosmos-sdk to simulate gRPC queries
|
|
10
|
-
*
|
|
10
|
+
* through HTTP/1.1.
|
|
11
11
|
* see https://github.com/cosmos/cosmos-sdk/issues/7345
|
|
12
12
|
*/
|
|
13
13
|
export declare class GrpcQueryClient implements ProtobufRpcClient {
|
|
@@ -12,7 +12,7 @@ class GrpcWebError extends Error {
|
|
|
12
12
|
exports.GrpcWebError = GrpcWebError;
|
|
13
13
|
/**
|
|
14
14
|
* Uses grpc-web module on cosmos-sdk to simulate gRPC queries
|
|
15
|
-
*
|
|
15
|
+
* through HTTP/1.1.
|
|
16
16
|
* see https://github.com/cosmos/cosmos-sdk/issues/7345
|
|
17
17
|
*/
|
|
18
18
|
class GrpcQueryClient {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GrpcQueryClient } from "../util/type";
|
|
2
|
+
import { grpc } from "@improbable-eng/grpc-web";
|
|
3
|
+
export declare class GrpcWebError extends Error {
|
|
4
|
+
code: grpc.Code;
|
|
5
|
+
metadata: grpc.Metadata;
|
|
6
|
+
constructor(message: string, code: grpc.Code, metadata: grpc.Metadata);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Uses grpc-web module on cosmos-sdk to simulate gRPC queries
|
|
10
|
+
* through HTTP/1.1.
|
|
11
|
+
* see https://github.com/cosmos/cosmos-sdk/issues/7345
|
|
12
|
+
*/
|
|
13
|
+
export declare class GrpcWebQueryClient implements GrpcQueryClient {
|
|
14
|
+
private host;
|
|
15
|
+
private options;
|
|
16
|
+
constructor(host: string, options?: {
|
|
17
|
+
transport?: grpc.TransportFactory;
|
|
18
|
+
metadata?: grpc.Metadata;
|
|
19
|
+
});
|
|
20
|
+
request(serviceName: string, methodName: string, data: Uint8Array): Promise<Uint8Array>;
|
|
21
|
+
}
|
|
22
|
+
export default GrpcWebQueryClient;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GrpcWebQueryClient = exports.GrpcWebError = void 0;
|
|
4
|
+
const grpc_web_1 = require("@improbable-eng/grpc-web");
|
|
5
|
+
class GrpcWebError extends Error {
|
|
6
|
+
constructor(message, code, metadata) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.metadata = metadata;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.GrpcWebError = GrpcWebError;
|
|
13
|
+
/**
|
|
14
|
+
* Uses grpc-web module on cosmos-sdk to simulate gRPC queries
|
|
15
|
+
* through HTTP/1.1.
|
|
16
|
+
* see https://github.com/cosmos/cosmos-sdk/issues/7345
|
|
17
|
+
*/
|
|
18
|
+
class GrpcWebQueryClient {
|
|
19
|
+
constructor(host, options = {}) {
|
|
20
|
+
this.host = host;
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
23
|
+
request(serviceName, methodName, data) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
grpc_web_1.grpc.unary({
|
|
26
|
+
methodName,
|
|
27
|
+
service: { serviceName },
|
|
28
|
+
requestStream: false,
|
|
29
|
+
responseStream: false,
|
|
30
|
+
requestType: {},
|
|
31
|
+
responseType: {
|
|
32
|
+
deserializeBinary: (data) => data,
|
|
33
|
+
},
|
|
34
|
+
}, {
|
|
35
|
+
request: Object.assign(Object.assign({}, data), { toObject: () => data, serializeBinary: () => data }),
|
|
36
|
+
host: this.host,
|
|
37
|
+
metadata: this.options.metadata,
|
|
38
|
+
transport: this.options.transport,
|
|
39
|
+
debug: false,
|
|
40
|
+
onEnd: function (response) {
|
|
41
|
+
if (response.status === grpc_web_1.grpc.Code.OK) {
|
|
42
|
+
resolve(response.message);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const err = new Error(response.statusMessage);
|
|
46
|
+
err.code = response.status;
|
|
47
|
+
err.metadata = response.trailers;
|
|
48
|
+
reject(err);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.GrpcWebQueryClient = GrpcWebQueryClient;
|
|
56
|
+
exports.default = GrpcWebQueryClient;
|
|
@@ -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() {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { Bridge, Token, TokenPrice } from "../codec";
|
|
2
|
-
import { DenomTrace } from "../codec/ibc/applications/transfer/v1/transfer";
|
|
3
2
|
import { NetworkConfigProvider } from "../constant";
|
|
4
3
|
import { GetFeeQuoteResponse } from "../hydrogen/feeQuote";
|
|
5
4
|
import { BlockchainUtils, TypeUtils } from "../util";
|
|
6
5
|
import { BlockchainV2, BridgeMap, IbcBridge } from '../util/blockchain';
|
|
7
6
|
import BigNumber from "bignumber.js";
|
|
8
7
|
import CarbonQueryClient from "./CarbonQueryClient";
|
|
9
|
-
export interface DenomTraceExtended extends DenomTrace {
|
|
10
|
-
token?: Token;
|
|
11
|
-
}
|
|
12
8
|
declare class TokenClient {
|
|
13
9
|
readonly query: CarbonQueryClient;
|
|
14
10
|
readonly configProvider: NetworkConfigProvider;
|
|
@@ -22,7 +18,6 @@ declare class TokenClient {
|
|
|
22
18
|
readonly usdValues: TypeUtils.SimpleMap<BigNumber>;
|
|
23
19
|
readonly commonAssetNames: TypeUtils.SimpleMap<string>;
|
|
24
20
|
readonly geckoTokenNames: TypeUtils.SimpleMap<string>;
|
|
25
|
-
readonly denomTraces: TypeUtils.SimpleMap<DenomTraceExtended>;
|
|
26
21
|
private additionalGeckoDenoms;
|
|
27
22
|
private constructor();
|
|
28
23
|
static instance(query: CarbonQueryClient, configProvider: NetworkConfigProvider): TokenClient;
|
|
@@ -61,8 +56,6 @@ declare class TokenClient {
|
|
|
61
56
|
getDepositTokenFor(tokenDenom: string, chain: BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2, version?: string): Token | undefined;
|
|
62
57
|
getAllTokens(): Promise<Token[]>;
|
|
63
58
|
reloadTokens(): Promise<TypeUtils.SimpleMap<Token>>;
|
|
64
|
-
reloadDenomTraces(): Promise<TypeUtils.SimpleMap<DenomTraceExtended>>;
|
|
65
|
-
getDenomTraceData(denom: string): DenomTrace | undefined;
|
|
66
59
|
getBridges(): Promise<BridgeMap>;
|
|
67
60
|
matchChainsWithDifferentChainIds(bridges: Bridge[]): Promise<IbcBridge[]>;
|
|
68
61
|
getIbcBlockchainNames(): string[];
|
|
@@ -75,7 +68,6 @@ declare class TokenClient {
|
|
|
75
68
|
getBlockchainV2FromIDs(chainId: string, bridgeId: string): BlockchainV2 | undefined;
|
|
76
69
|
getBridgeFromToken(token: Token | null): Bridge | IbcBridge | undefined;
|
|
77
70
|
getIbcChainIdFromToken(token: Token | null): string | undefined;
|
|
78
|
-
getCarbonDenomTraces(): Promise<TypeUtils.SimpleMap<DenomTrace>>;
|
|
79
71
|
getCdpUnderlyingToken(cdpDenom: string): Token | undefined;
|
|
80
72
|
reloadWrapperMap(): Promise<TypeUtils.SimpleMap<string>>;
|
|
81
73
|
reloadDenomGeckoMap(): Promise<void>;
|
|
@@ -16,13 +16,9 @@ const pagination_1 = require("../codec/cosmos/base/query/v1beta1/pagination");
|
|
|
16
16
|
const tendermint_1 = require("../codec/ibc/lightclients/tendermint/v1/tendermint");
|
|
17
17
|
const constant_1 = require("../constant");
|
|
18
18
|
const ibc_1 = require("../constant/ibc");
|
|
19
|
-
const network_1 = require("../constant/network");
|
|
20
19
|
const util_1 = require("../util");
|
|
21
20
|
const blockchain_1 = require("../util/blockchain");
|
|
22
21
|
const number_1 = require("../util/number");
|
|
23
|
-
const query_1 = require("../codec/ibc/applications/transfer/v1/query");
|
|
24
|
-
const stargate_1 = require("@cosmjs/stargate");
|
|
25
|
-
const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
26
22
|
const long_1 = __importDefault(require("long"));
|
|
27
23
|
const InsightsQueryClient_1 = __importDefault(require("./InsightsQueryClient"));
|
|
28
24
|
const SYMBOL_OVERRIDE = {
|
|
@@ -53,8 +49,6 @@ class TokenClient {
|
|
|
53
49
|
this.usdValues = {};
|
|
54
50
|
this.commonAssetNames = constant_1.CommonAssetName;
|
|
55
51
|
this.geckoTokenNames = constant_1.CoinGeckoTokenNames;
|
|
56
|
-
// ibc apis
|
|
57
|
-
this.denomTraces = {};
|
|
58
52
|
this.additionalGeckoDenoms = {};
|
|
59
53
|
this.getIbcChainFromBlockchainV2 = (blockchain) => {
|
|
60
54
|
const ibcBridge = this.bridges.ibc.find(bridge => (bridge.chainName === blockchain || bridge.chainName.toLowerCase() === blockchain));
|
|
@@ -79,7 +73,6 @@ class TokenClient {
|
|
|
79
73
|
try {
|
|
80
74
|
this.reloadDenomGeckoMap().finally(() => {
|
|
81
75
|
this.reloadUSDValues();
|
|
82
|
-
this.reloadDenomTraces();
|
|
83
76
|
});
|
|
84
77
|
}
|
|
85
78
|
catch (error) {
|
|
@@ -348,7 +341,7 @@ class TokenClient {
|
|
|
348
341
|
const networkConfig = this.configProvider.getConfig();
|
|
349
342
|
const token = this.tokenForDenom(tokenDenom);
|
|
350
343
|
if (!token) {
|
|
351
|
-
console.
|
|
344
|
+
console.debug("getDepositTokenFor token not found for", tokenDenom);
|
|
352
345
|
return;
|
|
353
346
|
}
|
|
354
347
|
let targetChain = "";
|
|
@@ -366,7 +359,7 @@ class TokenClient {
|
|
|
366
359
|
// if not source token find wrapped token for chain
|
|
367
360
|
const depositToken = isSourceToken ? token : this.getWrappedToken(token.denom, chain, version);
|
|
368
361
|
if (!depositToken) {
|
|
369
|
-
console.
|
|
362
|
+
console.debug(`getDepositTokenFor wrapped token not found for "${token.denom}"`);
|
|
370
363
|
return;
|
|
371
364
|
}
|
|
372
365
|
return depositToken;
|
|
@@ -411,29 +404,6 @@ class TokenClient {
|
|
|
411
404
|
return this.tokens;
|
|
412
405
|
});
|
|
413
406
|
}
|
|
414
|
-
reloadDenomTraces() {
|
|
415
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
416
|
-
const result = yield this.query.ibc.transfer.DenomTraces({
|
|
417
|
-
pagination: {
|
|
418
|
-
limit: new long_1.default(1000000),
|
|
419
|
-
offset: long_1.default.UZERO,
|
|
420
|
-
key: new Uint8Array(),
|
|
421
|
-
countTotal: false,
|
|
422
|
-
reverse: false,
|
|
423
|
-
},
|
|
424
|
-
});
|
|
425
|
-
result.denomTraces.forEach((denomTrace) => {
|
|
426
|
-
const ibcDenom = util_1.IBCUtils.makeIBCMinimalDenom(denomTrace.path, denomTrace.baseDenom);
|
|
427
|
-
const token = this.tokenForDenom(ibcDenom);
|
|
428
|
-
this.denomTraces[ibcDenom] = Object.assign(Object.assign({}, denomTrace), { token });
|
|
429
|
-
});
|
|
430
|
-
const swthTraces = yield this.getCarbonDenomTraces();
|
|
431
|
-
return Object.assign(Object.assign({}, this.denomTraces), swthTraces);
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
getDenomTraceData(denom) {
|
|
435
|
-
return this.denomTraces[denom];
|
|
436
|
-
}
|
|
437
407
|
getBridges() {
|
|
438
408
|
return __awaiter(this, void 0, void 0, function* () {
|
|
439
409
|
const allBridges = yield this.query.coin.BridgeAll({
|
|
@@ -576,36 +546,10 @@ class TokenClient {
|
|
|
576
546
|
if (!token)
|
|
577
547
|
return undefined;
|
|
578
548
|
const bridge = this.getBridgeFromToken(token);
|
|
579
|
-
if (!bridge || !blockchain_1.isIbcBridge(bridge))
|
|
549
|
+
if (!bridge || !(0, blockchain_1.isIbcBridge)(bridge))
|
|
580
550
|
return undefined;
|
|
581
551
|
return bridge.chain_id_name;
|
|
582
552
|
}
|
|
583
|
-
getCarbonDenomTraces() {
|
|
584
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
585
|
-
// get swth on osmosis
|
|
586
|
-
const osmoTmClient = yield tendermint_rpc_1.Tendermint34Client.connect(network_1.publicRpcNodes.Osmosis);
|
|
587
|
-
const osmoClient = new stargate_1.QueryClient(osmoTmClient);
|
|
588
|
-
const osmosRpcClient = stargate_1.createProtobufRpcClient(osmoClient);
|
|
589
|
-
const osmoIbcClient = new query_1.QueryClientImpl(osmosRpcClient);
|
|
590
|
-
const osmoDenomTraces = yield osmoIbcClient.DenomTraces({
|
|
591
|
-
pagination: pagination_1.PageRequest.fromPartial({
|
|
592
|
-
limit: new long_1.default(1000000),
|
|
593
|
-
}),
|
|
594
|
-
});
|
|
595
|
-
const osmoSwthDenomTrace = osmoDenomTraces.denomTraces.filter((trace) => {
|
|
596
|
-
return trace.baseDenom === "swth";
|
|
597
|
-
});
|
|
598
|
-
return osmoSwthDenomTrace.reduce((prev, trace) => {
|
|
599
|
-
var _a;
|
|
600
|
-
const coinMinimalDenom = util_1.IBCUtils.makeIBCMinimalDenom(trace.path, trace.baseDenom);
|
|
601
|
-
const token = (_a = this.tokenForDenom(coinMinimalDenom)) !== null && _a !== void 0 ? _a : this.tokenForDenom(trace.baseDenom);
|
|
602
|
-
const traceExtended = Object.assign(Object.assign({}, trace), { token });
|
|
603
|
-
this.denomTraces[coinMinimalDenom] = traceExtended;
|
|
604
|
-
prev[coinMinimalDenom] = traceExtended;
|
|
605
|
-
return prev;
|
|
606
|
-
}, {});
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
553
|
getCdpUnderlyingToken(cdpDenom) {
|
|
610
554
|
if (!this.cdpTokens[cdpDenom]) {
|
|
611
555
|
console.error("not a CDP denom");
|
|
@@ -678,7 +622,7 @@ class TokenClient {
|
|
|
678
622
|
processTokenPrices(tokenPrices) {
|
|
679
623
|
return tokenPrices.reduce((prevPrices, price) => {
|
|
680
624
|
const newPrev = prevPrices;
|
|
681
|
-
newPrev[price.denom] = number_1.bnOrZero(price.twap).shiftedBy(-constant_1.decTypeDecimals);
|
|
625
|
+
newPrev[price.denom] = (0, number_1.bnOrZero)(price.twap).shiftedBy(-constant_1.decTypeDecimals);
|
|
682
626
|
return newPrev;
|
|
683
627
|
}, {});
|
|
684
628
|
}
|
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() {
|