carbon-js-sdk 0.6.1-test1 → 0.6.1-test2

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.
Files changed (69) hide show
  1. package/lib/CarbonSDK.js +5 -2
  2. package/lib/clients/BatchQueryClient.js +4 -4
  3. package/lib/clients/CarbonQueryClient.js +1 -1
  4. package/lib/clients/ETHClient.js +15 -15
  5. package/lib/clients/GrpcQueryClient.d.ts +2 -0
  6. package/lib/clients/GrpcQueryClient.js +40 -22
  7. package/lib/clients/HydrogenClient.js +1 -1
  8. package/lib/clients/InsightsQueryClient.js +3 -3
  9. package/lib/clients/NEOClient.js +7 -7
  10. package/lib/clients/TokenClient.js +2 -2
  11. package/lib/clients/ZILClient.js +17 -17
  12. package/lib/codec/cosmos/gov/v1/query.js +2 -2
  13. package/lib/codec/cosmos/gov/v1/tx.js +2 -2
  14. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  15. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  16. package/lib/codec/cosmos/group/v1/events.js +2 -2
  17. package/lib/codec/cosmos/group/v1/tx.js +4 -4
  18. package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
  19. package/lib/constant/generic.js +1 -1
  20. package/lib/modules/cdp.js +44 -44
  21. package/lib/modules/cosmwasm.js +2 -2
  22. package/lib/modules/evm.js +5 -5
  23. package/lib/modules/gov.js +12 -12
  24. package/lib/modules/liquiditypool.js +1 -1
  25. package/lib/modules/order.js +2 -2
  26. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  27. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  28. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  29. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  30. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  31. package/lib/provider/amino/types/admin.js +27 -27
  32. package/lib/provider/amino/types/bank.js +1 -1
  33. package/lib/provider/amino/types/broker.js +1 -1
  34. package/lib/provider/amino/types/cdp.js +25 -25
  35. package/lib/provider/amino/types/coin.js +4 -4
  36. package/lib/provider/amino/types/evm.js +2 -2
  37. package/lib/provider/amino/types/evmmerge.js +1 -1
  38. package/lib/provider/amino/types/feemarket.js +1 -1
  39. package/lib/provider/amino/types/gov.js +5 -5
  40. package/lib/provider/amino/types/ibc.js +1 -1
  41. package/lib/provider/amino/types/leverage.js +1 -1
  42. package/lib/provider/amino/types/liquidityPool.js +7 -7
  43. package/lib/provider/amino/types/market.js +6 -6
  44. package/lib/provider/amino/types/oracle.js +2 -2
  45. package/lib/provider/amino/types/order.js +4 -4
  46. package/lib/provider/amino/types/position.js +1 -1
  47. package/lib/provider/amino/types/profile.js +1 -1
  48. package/lib/provider/amino/types/staking.js +4 -4
  49. package/lib/provider/amino/types/subaccount.js +3 -3
  50. package/lib/provider/amino/utils.js +11 -11
  51. package/lib/provider/keplr/KeplrAccount.js +2 -2
  52. package/lib/provider/ledger/ledger.js +2 -2
  53. package/lib/provider/metamask/MetaMask.js +13 -13
  54. package/lib/provider/o3/O3Wallet.js +2 -2
  55. package/lib/util/address.js +14 -14
  56. package/lib/util/api.js +4 -4
  57. package/lib/util/blockchain.d.ts +1 -1
  58. package/lib/util/blockchain.js +4 -4
  59. package/lib/util/eip712.js +3 -3
  60. package/lib/util/fetch.js +1 -1
  61. package/lib/util/generic.js +3 -3
  62. package/lib/util/legacyEIP712.js +2 -2
  63. package/lib/util/network.js +3 -3
  64. package/lib/util/number.js +5 -5
  65. package/lib/wallet/CarbonSigner.js +2 -2
  66. package/lib/wallet/CarbonSigningClient.js +15 -15
  67. package/lib/wallet/CarbonWallet.js +9 -9
  68. package/lib/websocket/connector.js +3 -3
  69. package/package.json +1 -2
package/lib/CarbonSDK.js CHANGED
@@ -35,6 +35,7 @@ exports.ConnectedCarbonSDK = exports.DenomPrefix = exports.CarbonWallet = export
35
35
  const constant_1 = require("./constant");
36
36
  const util_1 = require("./util");
37
37
  const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
38
+ const grpc_web_node_http_transport_1 = require("@improbable-eng/grpc-web-node-http-transport");
38
39
  const clients = __importStar(require("./clients"));
39
40
  const clients_1 = require("./clients");
40
41
  const GrpcQueryClient_1 = __importDefault(require("./clients/GrpcQueryClient"));
@@ -70,8 +71,10 @@ class CarbonSDK {
70
71
  this.evmChainId = (_f = (_e = opts.evmChainId) !== null && _e !== void 0 ? _e : constant_1.CarbonEvmChainIDs[this.network]) !== null && _f !== void 0 ? _f : constant_1.CarbonEvmChainIDs[constant_1.Network.MainNet];
71
72
  let grpcClient;
72
73
  if (opts.useTmAbciQuery !== true && this.networkConfig.grpcUrl) {
73
- const grpcUrl = typeof window === "undefined" ? this.networkConfig.grpcUrl : this.networkConfig.grpcWebUrl;
74
- grpcClient = (_g = opts.grpcQueryClient) !== null && _g !== void 0 ? _g : new GrpcQueryClient_1.default(grpcUrl);
74
+ const hasNodeGrpc = GrpcQueryClient_1.default.hasNodeGrpc();
75
+ const grpcUrl = hasNodeGrpc ? this.networkConfig.grpcUrl : this.networkConfig.grpcWebUrl;
76
+ const transport = typeof window === "undefined" ? grpc_web_node_http_transport_1.NodeHttpTransport() : undefined;
77
+ grpcClient = (_g = opts.grpcQueryClient) !== null && _g !== void 0 ? _g : new GrpcQueryClient_1.default(grpcUrl, { transport });
75
78
  }
76
79
  this.query = new clients_1.CarbonQueryClient({
77
80
  tmClient: this.tmClient,
@@ -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 = (0, rpcclient_1.hasProtocol)(endpoint) ? endpoint : "http://" + endpoint;
32
+ this.url = 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
- (0, http_1.http)("POST", this.url, this.headers, requests).then((raw) => {
74
+ 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 = (0, json_rpc_1.parseJsonRpcResponse)(el);
83
- if ((0, json_rpc_1.isJsonRpcErrorResponse)(response)) {
82
+ const response = json_rpc_1.parseJsonRpcResponse(el);
83
+ if (json_rpc_1.isJsonRpcErrorResponse(response)) {
84
84
  reject(new Error(JSON.stringify(response.error)));
85
85
  }
86
86
  else {
@@ -52,7 +52,7 @@ const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
52
52
  class CarbonQueryClient {
53
53
  constructor(opts) {
54
54
  var _a;
55
- const rpcClient = (_a = opts.grpcClient) !== null && _a !== void 0 ? _a : (0, stargate_1.createProtobufRpcClient)(new stargate_1.QueryClient(opts.tmClient));
55
+ const rpcClient = (_a = opts.grpcClient) !== null && _a !== void 0 ? _a : stargate_1.createProtobufRpcClient(new stargate_1.QueryClient(opts.tmClient));
56
56
  this.tmClient = opts.tmClient;
57
57
  this.baseClient = rpcClient;
58
58
  this.chain = BlockchainClient_1.default.connectWithTm(opts.tmClient);
@@ -44,15 +44,15 @@ class ETHClient {
44
44
  ?
45
45
  this.tokenClient.getBlockchainV2(token.denom) == ETHClient.BLOCKCHAINV2_MAPPING[this.blockchain]
46
46
  :
47
- (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), api.network) == this.blockchain;
47
+ blockchain_1.blockchainForChainId(token.chainId.toNumber(), api.network) == this.blockchain;
48
48
  return isCorrectBlockchain &&
49
49
  token.tokenAddress.length == 40 &&
50
- token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
50
+ token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
51
51
  (!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
52
- this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
52
+ this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
53
53
  });
54
54
  const assetIds = tokens.map((token) => {
55
- return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
55
+ return this.verifyChecksum(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 = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
102
+ const fromTokenAddress = 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 = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
109
+ const feeAddress = 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 = (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);
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);
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 = (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);
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);
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((0, generic_1.appendHexPrefix)(signature));
200
+ const signatureBytes = ethers_1.ethers.utils.arrayify(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 ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
239
+ if (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 = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
305
+ const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
306
306
  return addressHex;
307
307
  }
308
308
  getProvider() {
@@ -8,10 +8,12 @@ export declare class GrpcWebError extends Error {
8
8
  export declare class GrpcQueryClient implements ProtobufRpcClient {
9
9
  private host;
10
10
  private options;
11
+ private useGrpcJs;
11
12
  constructor(host: string, options?: {
12
13
  transport?: grpc.TransportFactory;
13
14
  metadata?: grpc.Metadata;
14
15
  });
16
+ static hasNodeGrpc(): boolean;
15
17
  request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
16
18
  _requestGrpc(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
17
19
  /**
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GrpcQueryClient = exports.GrpcWebError = void 0;
4
- const grpc_js_1 = require("@grpc/grpc-js");
5
4
  const grpc_web_1 = require("@improbable-eng/grpc-web");
5
+ const grpc_web_node_http_transport_1 = require("@improbable-eng/grpc-web-node-http-transport");
6
6
  class GrpcWebError extends Error {
7
7
  constructor(message, code, metadata) {
8
8
  super(message);
@@ -17,32 +17,50 @@ class GrpcQueryClient {
17
17
  constructor(host, options = {}) {
18
18
  this.host = host;
19
19
  this.options = options;
20
+ this.useGrpcJs = GrpcQueryClient.hasNodeGrpc() && typeof window === "undefined";
21
+ }
22
+ static hasNodeGrpc() {
23
+ try {
24
+ return require("@grpc/grpc-js").version; // eslint-disable-line
25
+ }
26
+ catch (error) {
27
+ return false;
28
+ }
20
29
  }
21
30
  request(service, method, data) {
22
- const isNode = typeof window === "undefined";
23
- return isNode ? this._requestGrpc(service, method, data) : this._requestGrpcWeb(service, method, data);
31
+ return this.useGrpcJs ? this._requestGrpc(service, method, data) : this._requestGrpcWeb(service, method, data);
24
32
  }
25
33
  _requestGrpc(service, method, data) {
34
+ var _a, _b;
26
35
  const path = ["", service, method].join("/");
27
- const client = new ((0, grpc_js_1.makeGenericClientConstructor)({
28
- runQuery: {
29
- path,
30
- requestStream: false,
31
- responseStream: false,
32
- requestSerialize: passThroughBuffer,
33
- requestDeserialize: passThrough,
34
- responseSerialize: passThroughBuffer,
35
- responseDeserialize: passThrough,
36
- }
37
- }, service))(this.host, grpc_js_1.credentials.createSsl());
38
- return new Promise((resolve, reject) => {
39
- client.runQuery(data, (error, value) => {
40
- if (error)
41
- reject(error);
42
- else
43
- resolve(value);
36
+ try {
37
+ const { credentials, makeGenericClientConstructor } = require("@grpc/grpc-js"); // eslint-disable-line
38
+ const client = new (makeGenericClientConstructor({
39
+ runQuery: {
40
+ path,
41
+ requestStream: false,
42
+ responseStream: false,
43
+ requestSerialize: passThroughBuffer,
44
+ requestDeserialize: passThrough,
45
+ responseSerialize: passThroughBuffer,
46
+ responseDeserialize: passThrough,
47
+ }
48
+ }, service))(this.host, credentials.createSsl());
49
+ return new Promise((resolve, reject) => {
50
+ client.runQuery(data, (error, value) => {
51
+ if (error)
52
+ reject(error);
53
+ else
54
+ resolve(value);
55
+ });
44
56
  });
45
- });
57
+ }
58
+ catch (error) {
59
+ if ((_b = (_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.startsWith) === null || _b === void 0 ? void 0 : _b.call(_a, "Cannot find module '@grpc/grpc-js'")) {
60
+ throw new Error("Please install @grpc/grpc-js, refer to README.md for more information.");
61
+ }
62
+ throw error;
63
+ }
46
64
  }
47
65
  /**
48
66
  * Uses grpc-web module on cosmos-sdk to simulate gRPC queries
@@ -64,7 +82,7 @@ class GrpcQueryClient {
64
82
  request: Object.assign(Object.assign({}, data), { toObject: () => data, serializeBinary: () => data }),
65
83
  host: this.host,
66
84
  metadata: this.options.metadata,
67
- transport: this.options.transport,
85
+ transport: grpc_web_node_http_transport_1.NodeHttpTransport(),
68
86
  debug: false,
69
87
  onEnd: function (response) {
70
88
  if (response.status === grpc_web_1.grpc.Code.OK) {
@@ -29,7 +29,7 @@ exports.HydrogenEndpoints = {
29
29
  const formatDateField = (value) => {
30
30
  if (typeof value !== "string")
31
31
  return null;
32
- return (0, dayjs_1.default)(value);
32
+ return 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
@@ -101,12 +101,12 @@ class InsightsQueryClient {
101
101
  const meta = response.data.result.meta;
102
102
  const parsedEntries = rawEntries.map(entry => ({
103
103
  lastHeight: entry.lastHeight,
104
- time: (0, dayjs_1.default)(entry.time),
104
+ time: dayjs_1.default(entry.time),
105
105
  volumeValue: new bignumber_js_1.default(entry.volumeValue)
106
106
  }));
107
107
  const parsedMeta = {
108
- from: (0, dayjs_1.default)(meta.from),
109
- until: (0, dayjs_1.default)(meta.until),
108
+ from: dayjs_1.default(meta.from),
109
+ until: dayjs_1.default(meta.until),
110
110
  interval: meta.interval,
111
111
  };
112
112
  return { result: { entries: parsedEntries, meta: parsedMeta } };
@@ -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
- (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), sdk.network) == this.blockchain;
72
+ 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 = (0, lodash_1.chunk)(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
78
+ const promises = 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 = (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));
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));
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 = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
168
+ const toAddress = 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 = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
204
+ const toAddress = 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 = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
324
+ const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
325
325
  return addressHex;
326
326
  }
327
327
  getNetworkConfig() {
@@ -544,7 +544,7 @@ class TokenClient {
544
544
  if (!token)
545
545
  return undefined;
546
546
  const bridge = this.getBridgeFromToken(token);
547
- if (!bridge || !(0, blockchain_1.isIbcBridge)(bridge))
547
+ if (!bridge || !blockchain_1.isIbcBridge(bridge))
548
548
  return undefined;
549
549
  return bridge.chain_id_name;
550
550
  }
@@ -620,7 +620,7 @@ class TokenClient {
620
620
  processTokenPrices(tokenPrices) {
621
621
  return tokenPrices.reduce((prevPrices, price) => {
622
622
  const newPrev = prevPrices;
623
- newPrev[price.denom] = (0, number_1.bnOrZero)(price.twap).shiftedBy(-constant_1.decTypeDecimals);
623
+ newPrev[price.denom] = number_1.bnOrZero(price.twap).shiftedBy(-constant_1.decTypeDecimals);
624
624
  return newPrev;
625
625
  }, {});
626
626
  }
@@ -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
- (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), sdk.network) == this.blockchain;
80
+ 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
- ? (0, exports.balanceBatchRequest)(address.replace(/^0x/i, ""))
85
- : (0, exports.tokenBalanceBatchRequest)(token.tokenAddress, address));
84
+ ? exports.balanceBatchRequest(address.replace(/^0x/i, ""))
85
+ : 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 (0, zilliqa_1.fromBech32Address)(bech32Address).toLowerCase().substr(2);
110
+ return 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((0, generic_1.stripHexPrefix)(zilAddress));
156
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(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 : (0, generic_1.appendHexPrefix)(token.bridgeAddress),
174
+ value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : 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 = (0, generic_1.appendHexPrefix)(token.tokenAddress);
192
+ const contractAddress = 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 = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
214
+ const fromTokenAddr = generic_1.appendHexPrefix(fromToken.tokenAddress);
215
215
  const toTokenDenom = toToken.denom;
216
- const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(fromToken));
216
+ const targetProxyHash = 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 = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
220
+ const feeAddress = 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((0, generic_1.stripHexPrefix)(fromAddress));
235
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(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 = (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);
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);
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 = (0, generic_1.appendHexPrefix)(token.bridgeAddress);
318
+ const contractAddress = 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((0, generic_1.stripHexPrefix)(zilAddress));
332
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(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 = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
417
+ const addressHex = 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
- ? (0, gov_1.proposalStatusFromJSON)(object.proposalStatus)
162
+ ? 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 = (0, gov_1.proposalStatusToJSON)(message.proposalStatus));
181
+ (obj.proposalStatus = 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
- ? (0, gov_1.voteOptionFromJSON)(object.option)
303
+ ? 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 = (0, gov_1.voteOptionToJSON)(message.option));
317
+ (obj.option = 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
- ? (0, gov_1.proposalStatusFromJSON)(object.proposalStatus)
162
+ ? 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 = (0, gov_1.proposalStatusToJSON)(message.proposalStatus));
181
+ (obj.proposalStatus = 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
- ? (0, gov_1.voteOptionFromJSON)(object.option)
188
+ ? 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 = (0, gov_1.voteOptionToJSON)(message.option));
198
+ (obj.option = 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
- ? (0, types_1.proposalExecutorResultFromJSON)(object.result)
387
+ ? 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 = (0, types_1.proposalExecutorResultToJSON)(message.result));
400
+ (obj.result = 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
- ? (0, types_1.voteOptionFromJSON)(object.option)
1477
+ ? 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 = (0, types_1.voteOptionToJSON)(message.option));
1495
+ (obj.option = 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
- ? (0, types_1.proposalExecutorResultFromJSON)(object.result)
1636
+ ? 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 = (0, types_1.proposalExecutorResultToJSON)(message.result));
1643
+ (obj.result = 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
- ? (0, signing_1.signModeFromJSON)(object.mode)
766
+ ? 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 = (0, signing_1.signModeToJSON)(message.mode));
772
+ message.mode !== undefined && (obj.mode = 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
- ? (0, signing_1.signModeFromJSON)(object.mode)
1055
+ ? 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 = (0, signing_1.signModeToJSON)(message.mode));
1070
+ message.mode !== undefined && (obj.mode = 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;