carbon-js-sdk 0.4.24 → 0.4.25-beta.1

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 (178) hide show
  1. package/lib/CarbonSDK.d.ts +12 -1
  2. package/lib/CarbonSDK.js +30 -2
  3. package/lib/clients/CarbonQueryClient.d.ts +13 -0
  4. package/lib/clients/CarbonQueryClient.js +58 -46
  5. package/lib/clients/ETHClient.js +15 -15
  6. package/lib/clients/HydrogenClient.js +1 -1
  7. package/lib/clients/NEOClient.js +7 -7
  8. package/lib/clients/TokenClient.js +3 -3
  9. package/lib/clients/ZILClient.js +17 -17
  10. package/lib/codec/bank/query.d.ts +14 -1
  11. package/lib/codec/bank/query.js +148 -29
  12. package/lib/codec/broker/amm.d.ts +35 -7
  13. package/lib/codec/broker/amm.js +185 -6
  14. package/lib/codec/broker/genesis.d.ts +2 -2
  15. package/lib/codec/broker/genesis.js +9 -9
  16. package/lib/codec/cosmos/gov/v1/query.js +2 -2
  17. package/lib/codec/cosmos/gov/v1/tx.js +2 -2
  18. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  19. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  20. package/lib/codec/cosmos/group/v1/events.js +2 -2
  21. package/lib/codec/cosmos/group/v1/query.d.ts +41 -0
  22. package/lib/codec/cosmos/group/v1/query.js +124 -1
  23. package/lib/codec/cosmos/group/v1/tx.js +4 -4
  24. package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
  25. package/lib/codec/cosmos/vesting/v1beta1/tx.d.ts +2 -0
  26. package/lib/codec/cosmos/vesting/v1beta1/vesting.d.ts +3 -0
  27. package/lib/codec/erc20/erc20.d.ts +41 -0
  28. package/lib/codec/erc20/erc20.js +144 -0
  29. package/lib/codec/erc20/events.d.ts +76 -0
  30. package/lib/codec/erc20/events.js +330 -0
  31. package/lib/codec/erc20/genesis.d.ts +40 -0
  32. package/lib/codec/erc20/genesis.js +139 -0
  33. package/lib/codec/erc20/query.d.ts +117 -0
  34. package/lib/codec/erc20/query.js +333 -0
  35. package/lib/codec/erc20/tx.d.ts +232 -0
  36. package/lib/codec/erc20/tx.js +765 -0
  37. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.d.ts +1 -0
  38. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +6 -0
  39. package/lib/codec/ethermint/evm/v1/export.d.ts +5 -0
  40. package/lib/codec/ethermint/evm/v1/export.js +53 -0
  41. package/lib/codec/ethermint/feemarket/v1/export.d.ts +4 -0
  42. package/lib/codec/ethermint/feemarket/v1/export.js +18 -0
  43. package/lib/codec/ethermint/types/v1/export.d.ts +4 -0
  44. package/lib/codec/ethermint/types/v1/export.js +11 -0
  45. package/lib/codec/ethermint-models.d.ts +4 -0
  46. package/lib/codec/ethermint-models.js +26 -0
  47. package/lib/codec/index.d.ts +53 -4
  48. package/lib/codec/index.js +24902 -812
  49. package/lib/codec/market/fee.d.ts +123 -0
  50. package/lib/codec/market/fee.js +334 -0
  51. package/lib/codec/market/genesis.d.ts +3 -0
  52. package/lib/codec/market/genesis.js +33 -2
  53. package/lib/codec/market/market.d.ts +8 -0
  54. package/lib/codec/market/query.d.ts +93 -0
  55. package/lib/codec/market/query.js +420 -1
  56. package/lib/codec/market/tx.d.ts +100 -3
  57. package/lib/codec/market/tx.js +553 -7
  58. package/lib/codec/perpsliquidity/event.d.ts +102 -0
  59. package/lib/codec/perpsliquidity/event.js +581 -0
  60. package/lib/codec/perpsliquidity/genesis.d.ts +35 -0
  61. package/lib/codec/perpsliquidity/genesis.js +162 -0
  62. package/lib/codec/perpsliquidity/params.d.ts +24 -0
  63. package/lib/codec/perpsliquidity/params.js +103 -0
  64. package/lib/codec/perpsliquidity/pool.d.ts +137 -0
  65. package/lib/codec/perpsliquidity/pool.js +747 -0
  66. package/lib/codec/perpsliquidity/query.d.ts +194 -0
  67. package/lib/codec/perpsliquidity/query.js +876 -0
  68. package/lib/codec/perpsliquidity/tx.d.ts +199 -0
  69. package/lib/codec/perpsliquidity/tx.js +940 -0
  70. package/lib/codec/tendermint/abci/types.d.ts +1 -1
  71. package/lib/codec/tendermint/crypto/keys.d.ts +1 -1
  72. package/lib/codec/tendermint/types/types.d.ts +1 -1
  73. package/lib/constant/eip712.d.ts +46 -0
  74. package/lib/constant/eip712.js +106 -0
  75. package/lib/constant/generic.js +1 -1
  76. package/lib/constant/ibc.d.ts +94 -0
  77. package/lib/constant/network.d.ts +9 -1
  78. package/lib/constant/network.js +19 -5
  79. package/lib/constant/walletProvider.d.ts +3 -1
  80. package/lib/constant/walletProvider.js +3 -0
  81. package/lib/modules/cdp.d.ts +1 -1
  82. package/lib/modules/cdp.js +98 -85
  83. package/lib/modules/cosmwasm.js +1 -1
  84. package/lib/modules/evm.d.ts +46 -0
  85. package/lib/modules/evm.js +127 -0
  86. package/lib/modules/evmmerge.d.ts +12 -0
  87. package/lib/modules/evmmerge.js +35 -0
  88. package/lib/modules/feemarket.d.ts +20 -0
  89. package/lib/modules/feemarket.js +45 -0
  90. package/lib/modules/gov.js +12 -12
  91. package/lib/modules/ibc.d.ts +3 -2
  92. package/lib/modules/ibc.js +111 -8
  93. package/lib/modules/index.d.ts +4 -0
  94. package/lib/modules/index.js +4 -0
  95. package/lib/modules/liquiditypool.js +1 -1
  96. package/lib/modules/market.d.ts +34 -0
  97. package/lib/modules/market.js +73 -1
  98. package/lib/modules/perpsliquidity.d.ts +56 -0
  99. package/lib/modules/perpsliquidity.js +128 -0
  100. package/lib/modules/vault.d.ts +56 -0
  101. package/lib/modules/vault.js +128 -0
  102. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  103. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  104. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  105. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  106. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  107. package/lib/provider/amino/AminoTypesMap.js +5 -1
  108. package/lib/provider/amino/types/admin.js +27 -27
  109. package/lib/provider/amino/types/bank.js +1 -1
  110. package/lib/provider/amino/types/broker.js +1 -1
  111. package/lib/provider/amino/types/cdp.js +25 -25
  112. package/lib/provider/amino/types/coin.js +4 -4
  113. package/lib/provider/amino/types/evm.d.ts +4 -0
  114. package/lib/provider/amino/types/evm.js +40 -0
  115. package/lib/provider/amino/types/evmmerge.d.ts +4 -0
  116. package/lib/provider/amino/types/evmmerge.js +34 -0
  117. package/lib/provider/amino/types/feemarket.d.ts +4 -0
  118. package/lib/provider/amino/types/feemarket.js +34 -0
  119. package/lib/provider/amino/types/gov.js +24 -4
  120. package/lib/provider/amino/types/ibc.js +1 -1
  121. package/lib/provider/amino/types/index.d.ts +3 -0
  122. package/lib/provider/amino/types/index.js +7 -1
  123. package/lib/provider/amino/types/leverage.js +1 -1
  124. package/lib/provider/amino/types/liquidityPool.js +10 -7
  125. package/lib/provider/amino/types/market.js +40 -2
  126. package/lib/provider/amino/types/oracle.js +7 -1
  127. package/lib/provider/amino/types/order.js +4 -4
  128. package/lib/provider/amino/types/perpsliquidity.d.ts +4 -0
  129. package/lib/provider/amino/types/perpsliquidity.js +72 -0
  130. package/lib/provider/amino/types/position.js +1 -1
  131. package/lib/provider/amino/types/profile.js +1 -1
  132. package/lib/provider/amino/types/staking.js +4 -4
  133. package/lib/provider/amino/types/subaccount.js +3 -3
  134. package/lib/provider/amino/utils.js +11 -11
  135. package/lib/provider/keplr/KeplrAccount.d.ts +2 -0
  136. package/lib/provider/keplr/KeplrAccount.js +38 -0
  137. package/lib/provider/leap/LeapAccount.js +4 -0
  138. package/lib/provider/ledger/ledger.js +2 -2
  139. package/lib/provider/metamask/MetaMask.d.ts +25 -1
  140. package/lib/provider/metamask/MetaMask.js +310 -8
  141. package/lib/provider/metamask/legacy-accounts.d.ts +6 -0
  142. package/lib/provider/metamask/legacy-accounts.js +44 -0
  143. package/lib/provider/o3/O3Wallet.js +5 -2
  144. package/lib/util/address.d.ts +5 -1
  145. package/lib/util/address.js +24 -13
  146. package/lib/util/api.js +4 -4
  147. package/lib/util/blockchain.d.ts +4 -5
  148. package/lib/util/blockchain.js +9 -3
  149. package/lib/util/eip712.d.ts +10 -0
  150. package/lib/util/eip712.js +195 -0
  151. package/lib/util/ethermint.d.ts +8 -0
  152. package/lib/util/ethermint.js +68 -0
  153. package/lib/util/fetch.js +1 -1
  154. package/lib/util/generic.js +3 -3
  155. package/lib/util/legacyEIP712.d.ts +20 -0
  156. package/lib/util/legacyEIP712.js +98 -0
  157. package/lib/util/number.js +5 -5
  158. package/lib/util/tx.d.ts +38 -0
  159. package/lib/wallet/CarbonSigner.d.ts +21 -4
  160. package/lib/wallet/CarbonSigner.js +22 -3
  161. package/lib/wallet/CarbonSigningClient.d.ts +1 -0
  162. package/lib/wallet/CarbonSigningClient.js +58 -10
  163. package/lib/wallet/CarbonWallet.d.ts +14 -2
  164. package/lib/wallet/CarbonWallet.js +147 -22
  165. package/lib/websocket/connector.js +3 -3
  166. package/package.json +2 -1
  167. package/lib/clients/EvmIbcClient.d.ts +0 -86
  168. package/lib/clients/EvmIbcClient.js +0 -90
  169. package/lib/codec/broker/incoming_pool_swap.d.ts +0 -23
  170. package/lib/codec/broker/incoming_pool_swap.js +0 -136
  171. package/lib/util/ethermint/evm-ibc.d.ts +0 -97
  172. package/lib/util/ethermint/evm-ibc.js +0 -134
  173. package/lib/util/ethermint/index.d.ts +0 -3
  174. package/lib/util/ethermint/index.js +0 -12
  175. package/lib/util/ethermint/keys.d.ts +0 -39
  176. package/lib/util/ethermint/keys.js +0 -138
  177. package/lib/util/ethermint/web3.d.ts +0 -36
  178. package/lib/util/ethermint/web3.js +0 -124
@@ -4,10 +4,12 @@ import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
4
4
  import { CarbonQueryClient, ETHClient, HydrogenClient, InsightsQueryClient, NEOClient, TokenClient, ZILClient } from "./clients";
5
5
  import * as clients from "./clients";
6
6
  import N3Client from "./clients/N3Client";
7
- import { AdminModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
7
+ import { AdminModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule, EvmModule, FeemarketModule, EvmMergeModule, PerpsLiquidityModule } from "./modules";
8
8
  import { StakingModule } from "./modules/staking";
9
9
  import { CosmosLedger, Keplr, LeapExtended } from "./provider";
10
10
  import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts } from "./wallet";
11
+ import { MetaMask } from "./provider/metamask/MetaMask";
12
+ import { ethers } from "ethers";
11
13
  export { CarbonTx } from "./util";
12
14
  export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
13
15
  export { DenomPrefix } from "./constant";
@@ -15,6 +17,7 @@ export interface CarbonSDKOpts {
15
17
  network: Network;
16
18
  tmClient: Tendermint34Client;
17
19
  chainId?: string;
20
+ evmChainId?: string;
18
21
  token?: TokenClient;
19
22
  config?: Partial<NetworkConfig>;
20
23
  defaultTimeoutBlocks?: number;
@@ -41,6 +44,7 @@ declare class CarbonSDK {
41
44
  readonly query: CarbonQueryClient;
42
45
  insights: InsightsQueryClient;
43
46
  hydrogen: HydrogenClient;
47
+ evmJsonRpc: ethers.providers.JsonRpcProvider;
44
48
  wallet?: CarbonWallet;
45
49
  network: Network;
46
50
  configOverride: Partial<NetworkConfig>;
@@ -50,6 +54,7 @@ declare class CarbonSDK {
50
54
  admin: AdminModule;
51
55
  order: OrderModule;
52
56
  lp: LiquidityPoolModule;
57
+ perpsliquidity: PerpsLiquidityModule;
53
58
  subaccount: SubAccountModule;
54
59
  profile: ProfileModule;
55
60
  cdp: CDPModule;
@@ -65,6 +70,9 @@ declare class CarbonSDK {
65
70
  fee: FeeModule;
66
71
  ibc: IBCModule;
67
72
  xchain: XChainModule;
73
+ evm: EvmModule;
74
+ evmmerge: EvmMergeModule;
75
+ feemarket: FeemarketModule;
68
76
  neo: NEOClient;
69
77
  eth: ETHClient;
70
78
  bsc: ETHClient;
@@ -74,6 +82,7 @@ declare class CarbonSDK {
74
82
  zil: ZILClient;
75
83
  n3: N3Client;
76
84
  chainId: string;
85
+ evmChainId: string;
77
86
  constructor(opts: CarbonSDKOpts);
78
87
  static instance(opts?: CarbonSDKInitOpts): Promise<CarbonSDK>;
79
88
  static instanceWithWallet(wallet: CarbonWallet, sdkOpts?: CarbonSDKInitOpts): Promise<ConnectedCarbonSDK>;
@@ -83,6 +92,7 @@ declare class CarbonSDK {
83
92
  static instanceWithLedger(ledger: CosmosLedger, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
84
93
  static instanceWithKeplr(keplr: Keplr, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
85
94
  static instanceWithLeap(leap: LeapExtended, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
95
+ static instanceWithMetamask(metamask: MetaMask, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
86
96
  static instanceViewOnly(bech32Address: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
87
97
  initialize(): Promise<CarbonSDK>;
88
98
  clone(): CarbonSDK;
@@ -95,6 +105,7 @@ declare class CarbonSDK {
95
105
  connectWithLedger(ledger: CosmosLedger, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
96
106
  connectWithKeplr(keplr: Keplr, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
97
107
  connectWithLeap(leap: LeapExtended, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
108
+ connectWithMetamask(metamask: MetaMask, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
98
109
  connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
99
110
  getConfig(): NetworkConfig;
100
111
  getTokenClient(): TokenClient;
package/lib/CarbonSDK.js CHANGED
@@ -43,6 +43,7 @@ const staking_1 = require("./modules/staking");
43
43
  const provider_1 = require("./provider");
44
44
  const blockchain_1 = require("./util/blockchain");
45
45
  const wallet_1 = require("./wallet");
46
+ const ethers_1 = require("ethers");
46
47
  var util_2 = require("./util");
47
48
  Object.defineProperty(exports, "CarbonTx", { enumerable: true, get: function () { return util_2.CarbonTx; } });
48
49
  var wallet_2 = require("./wallet");
@@ -60,19 +61,23 @@ const DEFAULT_SDK_INIT_OPTS = {
60
61
  */
61
62
  class CarbonSDK {
62
63
  constructor(opts) {
63
- var _a, _b, _c, _d, _e;
64
+ var _a, _b, _c, _d, _e, _f, _g;
64
65
  this.network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
65
66
  this.configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
66
67
  this.networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[this.network], this.configOverride);
67
68
  this.tmClient = opts.tmClient;
68
69
  this.chainId = (_d = (_c = opts.chainId) !== null && _c !== void 0 ? _c : constant_1.CarbonChainIDs[this.network]) !== null && _d !== void 0 ? _d : constant_1.CarbonChainIDs[constant_1.Network.MainNet];
70
+ 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];
69
71
  this.query = new clients_1.CarbonQueryClient(opts.tmClient);
70
72
  this.insights = new clients_1.InsightsQueryClient(this.networkConfig);
71
- this.token = (_e = opts.token) !== null && _e !== void 0 ? _e : clients_1.TokenClient.instance(this.query, this);
73
+ this.token = (_g = opts.token) !== null && _g !== void 0 ? _g : clients_1.TokenClient.instance(this.query, this);
74
+ this.hydrogen = new clients_1.HydrogenClient(this.networkConfig, this.token);
75
+ this.evmJsonRpc = new ethers_1.ethers.providers.JsonRpcProvider(constant_1.NetworkConfigs[this.network].evmJsonRpcUrl);
72
76
  this.hydrogen = clients_1.HydrogenClient.instance(this.networkConfig, this.token);
73
77
  this.admin = new modules_1.AdminModule(this);
74
78
  this.order = new modules_1.OrderModule(this);
75
79
  this.lp = new modules_1.LiquidityPoolModule(this);
80
+ this.perpsliquidity = new modules_1.PerpsLiquidityModule(this);
76
81
  this.subaccount = new modules_1.SubAccountModule(this);
77
82
  this.profile = new modules_1.ProfileModule(this);
78
83
  this.cdp = new modules_1.CDPModule(this);
@@ -88,6 +93,9 @@ class CarbonSDK {
88
93
  this.fee = new modules_1.FeeModule(this);
89
94
  this.ibc = new modules_1.IBCModule(this);
90
95
  this.xchain = new modules_1.XChainModule(this);
96
+ this.evm = new modules_1.EvmModule(this);
97
+ this.evmmerge = new modules_1.EvmMergeModule(this);
98
+ this.feemarket = new modules_1.FeemarketModule(this);
91
99
  this.neo = clients_1.NEOClient.instance({
92
100
  configProvider: this,
93
101
  blockchain: blockchain_1.Blockchain.Neo,
@@ -187,6 +195,12 @@ class CarbonSDK {
187
195
  return sdk.connectWithLeap(leap, walletOpts);
188
196
  });
189
197
  }
198
+ static instanceWithMetamask(metamask, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
199
+ return __awaiter(this, void 0, void 0, function* () {
200
+ const sdk = yield CarbonSDK.instance(sdkOpts);
201
+ return sdk.connectWithMetamask(metamask, walletOpts);
202
+ });
203
+ }
190
204
  static instanceViewOnly(bech32Address, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
191
205
  return __awaiter(this, void 0, void 0, function* () {
192
206
  const sdk = yield CarbonSDK.instance(sdkOpts);
@@ -290,6 +304,20 @@ class CarbonSDK {
290
304
  return this.connect(wallet);
291
305
  });
292
306
  }
307
+ connectWithMetamask(metamask, opts) {
308
+ return __awaiter(this, void 0, void 0, function* () {
309
+ const evmChainId = this.evmChainId;
310
+ const addressOptions = {
311
+ network: this.networkConfig.network,
312
+ bech32Prefix: this.networkConfig.Bech32Prefix
313
+ };
314
+ const address = yield metamask.defaultAccount();
315
+ const publicKeyHex = yield metamask.getPublicKey(address);
316
+ const publicKeyBase64 = Buffer.from(publicKeyHex, 'hex').toString('base64');
317
+ const wallet = wallet_1.CarbonWallet.withMetamask(metamask, evmChainId, publicKeyBase64, addressOptions, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
318
+ return this.connect(wallet);
319
+ });
320
+ }
293
321
  connectViewOnly(bech32Address, opts) {
294
322
  return __awaiter(this, void 0, void 0, function* () {
295
323
  const wallet = wallet_1.CarbonWallet.withAddress(bech32Address, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
@@ -14,6 +14,10 @@ import { QueryClientImpl as ParamsQueryClient } from "../codec/cosmos/params/v1b
14
14
  import { QueryClientImpl as SlashingQueryClient } from "../codec/cosmos/slashing/v1beta1/query";
15
15
  import { QueryClientImpl as StakingQueryClient } from "../codec/cosmos/staking/v1beta1/query";
16
16
  import { QueryClientImpl as UpgradeQueryClient } from "../codec/cosmos/upgrade/v1beta1/query";
17
+ import { QueryClientImpl as EthermintEVMQueryClient } from "../codec/ethermint/evm/v1/query";
18
+ import { QueryClientImpl as EvmMergeQueryClient } from "../codec/evmmerge/query";
19
+ import { QueryClientImpl as EvmBankQueryClient } from "../codec/evmbank/query";
20
+ import { QueryClientImpl as EthermintFeeMarketQueryClient } from "../codec/ethermint/feemarket/v1/query";
17
21
  import { QueryClientImpl as FeeQueryClient } from "../codec/fee/query";
18
22
  import { QueryClientImpl as HeadersyncQueryClient } from "../codec/headersync/query";
19
23
  import { QueryClientImpl as IBCInterchainControlQueryClient } from "../codec/ibc/applications/interchain_accounts/controller/v1/query";
@@ -27,6 +31,7 @@ import { QueryClientImpl as InsuranceQueryClient } from "../codec/insurance/quer
27
31
  import { QueryClientImpl as LeverageQueryClient } from "../codec/leverage/query";
28
32
  import { QueryClientImpl as LiquidationQueryClient } from "../codec/liquidation/query";
29
33
  import { QueryClientImpl as LiquidityPoolQueryClient } from "../codec/liquiditypool/query";
34
+ import { QueryClientImpl as PerpLiquidityPoolQueryClient } from "../codec/perpsliquidity/query";
30
35
  import { QueryClientImpl as MarketQueryClient } from "../codec/market/query";
31
36
  import { QueryClientImpl as MarketStatsQueryClient } from "../codec/marketstats/query";
32
37
  import { QueryClientImpl as MiscQueryClient } from "../codec/misc/query";
@@ -46,6 +51,10 @@ export interface IBCClientGroup {
46
51
  connection: IBCConnectionQueryClient;
47
52
  channel: IBCChannelQueryClient;
48
53
  }
54
+ export interface EthermintClientGroup {
55
+ evm: EthermintEVMQueryClient;
56
+ feeMarket: EthermintFeeMarketQueryClient;
57
+ }
49
58
  declare class CarbonQueryClient {
50
59
  private readonly tmClient;
51
60
  adl: ADLQueryClient;
@@ -59,6 +68,7 @@ declare class CarbonQueryClient {
59
68
  leverage: LeverageQueryClient;
60
69
  liquidation: LiquidationQueryClient;
61
70
  liquiditypool: LiquidityPoolQueryClient;
71
+ perpetualpool: PerpLiquidityPoolQueryClient;
62
72
  market: MarketQueryClient;
63
73
  marketstats: MarketStatsQueryClient;
64
74
  misc: MiscQueryClient;
@@ -82,6 +92,9 @@ declare class CarbonQueryClient {
82
92
  cosmosTm: CosmosTmClient;
83
93
  chain: BlockchainClient;
84
94
  ibc: IBCClientGroup;
95
+ ethermint: EthermintClientGroup;
96
+ evmmerge: EvmMergeQueryClient;
97
+ evmbank: EvmBankQueryClient;
85
98
  private baseClient;
86
99
  constructor(tmClient: Tendermint34Client);
87
100
  getProtobufRpcClient(): import("@cosmjs/stargate").ProtobufRpcClient;
@@ -19,57 +19,65 @@ const query_13 = require("../codec/cosmos/params/v1beta1/query");
19
19
  const query_14 = require("../codec/cosmos/slashing/v1beta1/query");
20
20
  const query_15 = require("../codec/cosmos/staking/v1beta1/query");
21
21
  const query_16 = require("../codec/cosmos/upgrade/v1beta1/query");
22
- const query_17 = require("../codec/fee/query");
23
- const query_18 = require("../codec/headersync/query");
24
- const query_19 = require("../codec/ibc/applications/interchain_accounts/controller/v1/query");
25
- const query_20 = require("../codec/ibc/applications/interchain_accounts/host/v1/query");
26
- const query_21 = require("../codec/ibc/applications/transfer/v1/query");
27
- const query_22 = require("../codec/ibc/core/client/v1/query");
28
- const query_23 = require("../codec/ibc/core/connection/v1/query");
29
- const query_24 = require("../codec/ibc/core/channel/v1/query");
30
- const query_25 = require("../codec/inflation/query");
31
- const query_26 = require("../codec/insurance/query");
32
- const query_27 = require("../codec/leverage/query");
33
- const query_28 = require("../codec/liquidation/query");
34
- const query_29 = require("../codec/liquiditypool/query");
35
- const query_30 = require("../codec/market/query");
36
- const query_31 = require("../codec/marketstats/query");
37
- const query_32 = require("../codec/misc/query");
38
- const query_33 = require("../codec/oracle/query");
39
- const query_34 = require("../codec/order/query");
40
- const query_35 = require("../codec/position/query");
41
- const query_36 = require("../codec/pricing/query");
42
- const query_37 = require("../codec/profile/query");
43
- const query_38 = require("../codec/subaccount/query");
22
+ const query_17 = require("../codec/ethermint/evm/v1/query");
23
+ const query_18 = require("../codec/evmmerge/query");
24
+ const query_19 = require("../codec/evmbank/query");
25
+ const query_20 = require("../codec/ethermint/feemarket/v1/query");
26
+ const query_21 = require("../codec/fee/query");
27
+ const query_22 = require("../codec/headersync/query");
28
+ const query_23 = require("../codec/ibc/applications/interchain_accounts/controller/v1/query");
29
+ const query_24 = require("../codec/ibc/applications/interchain_accounts/host/v1/query");
30
+ const query_25 = require("../codec/ibc/applications/transfer/v1/query");
31
+ const query_26 = require("../codec/ibc/core/client/v1/query");
32
+ const query_27 = require("../codec/ibc/core/connection/v1/query");
33
+ const query_28 = require("../codec/ibc/core/channel/v1/query");
34
+ const query_29 = require("../codec/inflation/query");
35
+ const query_30 = require("../codec/insurance/query");
36
+ const query_31 = require("../codec/leverage/query");
37
+ const query_32 = require("../codec/liquidation/query");
38
+ const query_33 = require("../codec/liquiditypool/query");
39
+ const query_34 = require("../codec/perpsliquidity/query");
40
+ const query_35 = require("../codec/market/query");
41
+ const query_36 = require("../codec/marketstats/query");
42
+ const query_37 = require("../codec/misc/query");
43
+ const query_38 = require("../codec/oracle/query");
44
+ const query_39 = require("../codec/order/query");
45
+ const query_40 = require("../codec/position/query");
46
+ const query_41 = require("../codec/pricing/query");
47
+ const query_42 = require("../codec/profile/query");
48
+ const query_43 = require("../codec/subaccount/query");
44
49
  const stargate_1 = require("@cosmjs/stargate");
45
50
  const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
46
51
  class CarbonQueryClient {
47
52
  constructor(tmClient) {
48
53
  this.tmClient = tmClient;
49
54
  this.baseClient = new stargate_1.QueryClient(this.tmClient);
50
- const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
55
+ const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
51
56
  this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
52
57
  this.adl = new query_1.QueryClientImpl(rpcClient);
53
58
  this.book = new query_2.QueryClientImpl(rpcClient);
54
59
  this.broker = new query_3.QueryClientImpl(rpcClient);
55
60
  this.coin = new query_5.QueryClientImpl(rpcClient);
56
61
  this.cdp = new query_4.QueryClientImpl(rpcClient);
57
- this.fee = new query_17.QueryClientImpl(rpcClient);
58
- this.inflation = new query_25.QueryClientImpl(rpcClient);
59
- this.insurance = new query_26.QueryClientImpl(rpcClient);
60
- this.leverage = new query_27.QueryClientImpl(rpcClient);
61
- this.liquidation = new query_28.QueryClientImpl(rpcClient);
62
- this.liquiditypool = new query_29.QueryClientImpl(rpcClient);
63
- this.market = new query_30.QueryClientImpl(rpcClient);
64
- this.marketstats = new query_31.QueryClientImpl(rpcClient);
65
- this.misc = new query_32.QueryClientImpl(rpcClient);
66
- this.oracle = new query_33.QueryClientImpl(rpcClient);
67
- this.order = new query_34.QueryClientImpl(rpcClient);
68
- this.position = new query_35.QueryClientImpl(rpcClient);
69
- this.pricing = new query_36.QueryClientImpl(rpcClient);
70
- this.profile = new query_37.QueryClientImpl(rpcClient);
71
- this.subaccount = new query_38.QueryClientImpl(rpcClient);
72
- this.headersync = new query_18.QueryClientImpl(rpcClient);
62
+ this.fee = new query_21.QueryClientImpl(rpcClient);
63
+ this.inflation = new query_29.QueryClientImpl(rpcClient);
64
+ this.insurance = new query_30.QueryClientImpl(rpcClient);
65
+ this.leverage = new query_31.QueryClientImpl(rpcClient);
66
+ this.liquidation = new query_32.QueryClientImpl(rpcClient);
67
+ this.liquiditypool = new query_33.QueryClientImpl(rpcClient);
68
+ this.perpetualpool = new query_34.QueryClientImpl(rpcClient);
69
+ this.market = new query_35.QueryClientImpl(rpcClient);
70
+ this.marketstats = new query_36.QueryClientImpl(rpcClient);
71
+ this.misc = new query_37.QueryClientImpl(rpcClient);
72
+ this.oracle = new query_38.QueryClientImpl(rpcClient);
73
+ this.order = new query_39.QueryClientImpl(rpcClient);
74
+ this.position = new query_40.QueryClientImpl(rpcClient);
75
+ this.pricing = new query_41.QueryClientImpl(rpcClient);
76
+ this.profile = new query_42.QueryClientImpl(rpcClient);
77
+ this.subaccount = new query_43.QueryClientImpl(rpcClient);
78
+ this.headersync = new query_22.QueryClientImpl(rpcClient);
79
+ this.evmmerge = new query_18.QueryClientImpl(rpcClient);
80
+ this.evmbank = new query_19.QueryClientImpl(rpcClient);
73
81
  this.auth = new query_6.QueryClientImpl(rpcClient);
74
82
  this.bank = new query_7.QueryClientImpl(rpcClient);
75
83
  this.distribution = new query_9.QueryClientImpl(rpcClient);
@@ -82,16 +90,20 @@ class CarbonQueryClient {
82
90
  this.upgrade = new query_16.QueryClientImpl(rpcClient);
83
91
  this.cosmosTm = new query_8.ServiceClientImpl(rpcClient);
84
92
  this.ibc = {
85
- controller: new query_19.QueryClientImpl(rpcClient),
86
- host: new query_20.QueryClientImpl(rpcClient),
87
- transfer: new query_21.QueryClientImpl(rpcClient),
88
- client: new query_22.QueryClientImpl(rpcClient),
89
- connection: new query_23.QueryClientImpl(rpcClient),
90
- channel: new query_24.QueryClientImpl(rpcClient),
93
+ controller: new query_23.QueryClientImpl(rpcClient),
94
+ host: new query_24.QueryClientImpl(rpcClient),
95
+ transfer: new query_25.QueryClientImpl(rpcClient),
96
+ client: new query_26.QueryClientImpl(rpcClient),
97
+ connection: new query_27.QueryClientImpl(rpcClient),
98
+ channel: new query_28.QueryClientImpl(rpcClient),
99
+ };
100
+ this.ethermint = {
101
+ evm: new query_17.QueryClientImpl(rpcClient),
102
+ feeMarket: new query_20.QueryClientImpl(rpcClient),
91
103
  };
92
104
  }
93
105
  getProtobufRpcClient() {
94
- return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
106
+ return stargate_1.createProtobufRpcClient(this.baseClient);
95
107
  }
96
108
  }
97
109
  exports.default = CarbonQueryClient;
@@ -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() {
@@ -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
@@ -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() {
@@ -570,7 +570,7 @@ class TokenClient {
570
570
  if (!token)
571
571
  return undefined;
572
572
  const bridge = this.getBridgeFromToken(token);
573
- if (!bridge || !(0, blockchain_1.isIbcBridge)(bridge))
573
+ if (!bridge || !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 = (0, stargate_1.createProtobufRpcClient)(osmoClient);
582
+ const osmosRpcClient = 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] = (0, number_1.bnOrZero)(price.twap).shiftedBy(-constant_1.decTypeDecimals);
675
+ newPrev[price.denom] = number_1.bnOrZero(price.twap).shiftedBy(-constant_1.decTypeDecimals);
676
676
  return newPrev;
677
677
  }, {});
678
678
  }
@@ -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() {