carbon-js-sdk 0.4.32 → 0.5.0-alpha.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 (192) hide show
  1. package/lib/CarbonSDK.d.ts +12 -2
  2. package/lib/CarbonSDK.js +31 -3
  3. package/lib/clients/BatchQueryClient.d.ts +26 -0
  4. package/lib/clients/BatchQueryClient.js +100 -0
  5. package/lib/clients/CarbonQueryClient.d.ts +15 -0
  6. package/lib/clients/CarbonQueryClient.js +81 -66
  7. package/lib/clients/ETHClient.js +15 -15
  8. package/lib/clients/HydrogenClient.js +1 -1
  9. package/lib/clients/InsightsQueryClient.d.ts +2 -0
  10. package/lib/clients/InsightsQueryClient.js +14 -0
  11. package/lib/clients/NEOClient.js +7 -7
  12. package/lib/clients/TokenClient.js +3 -3
  13. package/lib/clients/ZILClient.js +17 -17
  14. package/lib/clients/index.d.ts +4 -3
  15. package/lib/clients/index.js +9 -7
  16. package/lib/codec/bank/query.d.ts +14 -1
  17. package/lib/codec/bank/query.js +148 -29
  18. package/lib/codec/broker/amm.d.ts +35 -7
  19. package/lib/codec/broker/amm.js +185 -6
  20. package/lib/codec/broker/candlestick.d.ts +1 -0
  21. package/lib/codec/broker/candlestick.js +19 -0
  22. package/lib/codec/broker/genesis.d.ts +2 -2
  23. package/lib/codec/broker/genesis.js +9 -9
  24. package/lib/codec/cdp/event.d.ts +2 -0
  25. package/lib/codec/cdp/event.js +34 -0
  26. package/lib/codec/coin/token.d.ts +0 -2
  27. package/lib/codec/coin/token.js +2 -29
  28. package/lib/codec/cosmos/gov/v1/query.js +2 -2
  29. package/lib/codec/cosmos/gov/v1/tx.js +2 -2
  30. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  31. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  32. package/lib/codec/cosmos/group/v1/events.js +2 -2
  33. package/lib/codec/cosmos/group/v1/query.d.ts +41 -0
  34. package/lib/codec/cosmos/group/v1/query.js +124 -1
  35. package/lib/codec/cosmos/group/v1/tx.js +4 -4
  36. package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
  37. package/lib/codec/cosmos/vesting/v1beta1/tx.d.ts +2 -0
  38. package/lib/codec/cosmos/vesting/v1beta1/vesting.d.ts +3 -0
  39. package/lib/codec/erc20/erc20.d.ts +41 -0
  40. package/lib/codec/erc20/erc20.js +144 -0
  41. package/lib/codec/erc20/events.d.ts +76 -0
  42. package/lib/codec/erc20/events.js +330 -0
  43. package/lib/codec/erc20/genesis.d.ts +40 -0
  44. package/lib/codec/erc20/genesis.js +139 -0
  45. package/lib/codec/erc20/query.d.ts +117 -0
  46. package/lib/codec/erc20/query.js +333 -0
  47. package/lib/codec/erc20/tx.d.ts +232 -0
  48. package/lib/codec/erc20/tx.js +765 -0
  49. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.d.ts +1 -0
  50. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +6 -0
  51. package/lib/codec/ethermint/evm/v1/export.d.ts +5 -0
  52. package/lib/codec/ethermint/evm/v1/export.js +53 -0
  53. package/lib/codec/ethermint/feemarket/v1/export.d.ts +4 -0
  54. package/lib/codec/ethermint/feemarket/v1/export.js +18 -0
  55. package/lib/codec/ethermint/types/v1/export.d.ts +4 -0
  56. package/lib/codec/ethermint/types/v1/export.js +11 -0
  57. package/lib/codec/ethermint-models.d.ts +4 -0
  58. package/lib/codec/ethermint-models.js +26 -0
  59. package/lib/codec/evmmerge/address.d.ts +19 -0
  60. package/lib/codec/evmmerge/address.js +75 -0
  61. package/lib/codec/evmmerge/query.d.ts +32 -0
  62. package/lib/codec/evmmerge/query.js +138 -1
  63. package/lib/codec/index.d.ts +57 -5
  64. package/lib/codec/index.js +25025 -812
  65. package/lib/codec/market/fee.d.ts +123 -0
  66. package/lib/codec/market/fee.js +334 -0
  67. package/lib/codec/market/genesis.d.ts +3 -0
  68. package/lib/codec/market/genesis.js +33 -2
  69. package/lib/codec/market/market.d.ts +12 -0
  70. package/lib/codec/market/market.js +61 -1
  71. package/lib/codec/market/query.d.ts +93 -0
  72. package/lib/codec/market/query.js +420 -1
  73. package/lib/codec/market/tx.d.ts +135 -3
  74. package/lib/codec/market/tx.js +731 -7
  75. package/lib/codec/perpsliquidity/event.d.ts +103 -0
  76. package/lib/codec/perpsliquidity/event.js +596 -0
  77. package/lib/codec/perpsliquidity/genesis.d.ts +35 -0
  78. package/lib/codec/perpsliquidity/genesis.js +162 -0
  79. package/lib/codec/perpsliquidity/params.d.ts +22 -0
  80. package/lib/codec/perpsliquidity/params.js +86 -0
  81. package/lib/codec/perpsliquidity/pool.d.ts +155 -0
  82. package/lib/codec/perpsliquidity/pool.js +871 -0
  83. package/lib/codec/perpsliquidity/query.d.ts +194 -0
  84. package/lib/codec/perpsliquidity/query.js +876 -0
  85. package/lib/codec/perpsliquidity/tx.d.ts +202 -0
  86. package/lib/codec/perpsliquidity/tx.js +970 -0
  87. package/lib/codec/tendermint/abci/types.d.ts +1 -1
  88. package/lib/codec/tendermint/crypto/keys.d.ts +1 -1
  89. package/lib/codec/tendermint/types/types.d.ts +1 -1
  90. package/lib/constant/eip712.d.ts +46 -0
  91. package/lib/constant/eip712.js +106 -0
  92. package/lib/constant/generic.js +1 -1
  93. package/lib/constant/network.d.ts +9 -1
  94. package/lib/constant/network.js +19 -5
  95. package/lib/constant/walletProvider.d.ts +3 -1
  96. package/lib/constant/walletProvider.js +3 -0
  97. package/lib/insights/common.d.ts +2 -0
  98. package/lib/insights/common.js +4 -0
  99. package/lib/insights/delegation.d.ts +26 -0
  100. package/lib/insights/delegation.js +2 -0
  101. package/lib/insights/index.d.ts +2 -0
  102. package/lib/insights/index.js +2 -0
  103. package/lib/insights/oracles.d.ts +17 -0
  104. package/lib/insights/oracles.js +2 -0
  105. package/lib/modules/cdp.d.ts +1 -1
  106. package/lib/modules/cdp.js +99 -86
  107. package/lib/modules/cosmwasm.js +1 -1
  108. package/lib/modules/erc20.d.ts +26 -0
  109. package/lib/modules/erc20.js +79 -0
  110. package/lib/modules/evm.d.ts +46 -0
  111. package/lib/modules/evm.js +127 -0
  112. package/lib/modules/evmmerge.d.ts +12 -0
  113. package/lib/modules/evmmerge.js +35 -0
  114. package/lib/modules/feemarket.d.ts +20 -0
  115. package/lib/modules/feemarket.js +45 -0
  116. package/lib/modules/gov.js +12 -12
  117. package/lib/modules/index.d.ts +5 -0
  118. package/lib/modules/index.js +5 -0
  119. package/lib/modules/liquiditypool.js +1 -1
  120. package/lib/modules/market.d.ts +36 -0
  121. package/lib/modules/market.js +94 -1
  122. package/lib/modules/order.d.ts +2 -0
  123. package/lib/modules/order.js +11 -4
  124. package/lib/modules/perpsliquidity.d.ts +51 -0
  125. package/lib/modules/perpsliquidity.js +129 -0
  126. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  127. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  128. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  129. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  130. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  131. package/lib/provider/amino/AminoTypesMap.js +1 -1
  132. package/lib/provider/amino/types/admin.js +27 -27
  133. package/lib/provider/amino/types/bank.js +1 -1
  134. package/lib/provider/amino/types/broker.js +1 -1
  135. package/lib/provider/amino/types/cdp.js +25 -25
  136. package/lib/provider/amino/types/coin.js +4 -4
  137. package/lib/provider/amino/types/erc20.d.ts +4 -0
  138. package/lib/provider/amino/types/erc20.js +40 -0
  139. package/lib/provider/amino/types/evm.d.ts +4 -0
  140. package/lib/provider/amino/types/evm.js +40 -0
  141. package/lib/provider/amino/types/evmmerge.d.ts +4 -0
  142. package/lib/provider/amino/types/evmmerge.js +34 -0
  143. package/lib/provider/amino/types/feemarket.d.ts +4 -0
  144. package/lib/provider/amino/types/feemarket.js +34 -0
  145. package/lib/provider/amino/types/gov.js +24 -4
  146. package/lib/provider/amino/types/ibc.js +1 -1
  147. package/lib/provider/amino/types/index.d.ts +5 -0
  148. package/lib/provider/amino/types/index.js +11 -1
  149. package/lib/provider/amino/types/leverage.js +1 -1
  150. package/lib/provider/amino/types/liquidityPool.js +8 -15
  151. package/lib/provider/amino/types/market.js +40 -2
  152. package/lib/provider/amino/types/oracle.js +7 -1
  153. package/lib/provider/amino/types/order.js +4 -4
  154. package/lib/provider/amino/types/perpsliquidity.d.ts +4 -0
  155. package/lib/provider/amino/types/perpsliquidity.js +73 -0
  156. package/lib/provider/amino/types/position.js +1 -1
  157. package/lib/provider/amino/types/profile.js +1 -1
  158. package/lib/provider/amino/types/staking.js +4 -4
  159. package/lib/provider/amino/types/subaccount.js +3 -3
  160. package/lib/provider/amino/utils.js +11 -11
  161. package/lib/provider/keplr/KeplrAccount.d.ts +2 -0
  162. package/lib/provider/keplr/KeplrAccount.js +41 -0
  163. package/lib/provider/leap/LeapAccount.js +4 -0
  164. package/lib/provider/ledger/ledger.js +7 -8
  165. package/lib/provider/metamask/MetaMask.d.ts +27 -2
  166. package/lib/provider/metamask/MetaMask.js +318 -13
  167. package/lib/provider/metamask/legacy-accounts.d.ts +11 -0
  168. package/lib/provider/metamask/legacy-accounts.js +2233 -0
  169. package/lib/provider/o3/O3Wallet.js +5 -2
  170. package/lib/util/address.d.ts +5 -1
  171. package/lib/util/address.js +24 -13
  172. package/lib/util/api.js +4 -4
  173. package/lib/util/blockchain.d.ts +4 -5
  174. package/lib/util/blockchain.js +9 -3
  175. package/lib/util/eip712.d.ts +10 -0
  176. package/lib/util/eip712.js +195 -0
  177. package/lib/util/ethermint.d.ts +8 -0
  178. package/lib/util/ethermint.js +70 -0
  179. package/lib/util/fetch.js +1 -1
  180. package/lib/util/generic.js +3 -3
  181. package/lib/util/legacyEIP712.d.ts +20 -0
  182. package/lib/util/legacyEIP712.js +98 -0
  183. package/lib/util/number.js +5 -5
  184. package/lib/util/tx.d.ts +41 -0
  185. package/lib/wallet/CarbonSigner.d.ts +21 -4
  186. package/lib/wallet/CarbonSigner.js +22 -3
  187. package/lib/wallet/CarbonSigningClient.d.ts +1 -0
  188. package/lib/wallet/CarbonSigningClient.js +58 -10
  189. package/lib/wallet/CarbonWallet.d.ts +41 -2
  190. package/lib/wallet/CarbonWallet.js +205 -26
  191. package/lib/websocket/connector.js +3 -3
  192. package/package.json +8 -16
@@ -4,10 +4,11 @@ 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, AllianceModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
7
+ import { AdminModule, AllianceModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule, EvmModule, ERC20Module, FeemarketModule, EvmMergeModule, PerpsLiquidityModule } from "./modules";
8
8
  import { StakingModule } from "./modules/staking";
9
9
  import { CosmosLedger, Keplr, LeapExtended } from "./provider";
10
- import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts } from "./wallet";
10
+ import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts, MetaMaskWalletOpts } from "./wallet";
11
+ import { MetaMask } from "./provider/metamask/MetaMask";
11
12
  export { CarbonTx } from "./util";
12
13
  export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
13
14
  export { DenomPrefix } from "./constant";
@@ -15,6 +16,7 @@ export interface CarbonSDKOpts {
15
16
  network: Network;
16
17
  tmClient: Tendermint34Client;
17
18
  chainId?: string;
19
+ evmChainId?: string;
18
20
  token?: TokenClient;
19
21
  config?: Partial<NetworkConfig>;
20
22
  defaultTimeoutBlocks?: number;
@@ -51,6 +53,8 @@ declare class CarbonSDK {
51
53
  alliance: AllianceModule;
52
54
  order: OrderModule;
53
55
  lp: LiquidityPoolModule;
56
+ erc20: ERC20Module;
57
+ plp: PerpsLiquidityModule;
54
58
  subaccount: SubAccountModule;
55
59
  profile: ProfileModule;
56
60
  cdp: CDPModule;
@@ -66,6 +70,9 @@ declare class CarbonSDK {
66
70
  fee: FeeModule;
67
71
  ibc: IBCModule;
68
72
  xchain: XChainModule;
73
+ evm: EvmModule;
74
+ evmmerge: EvmMergeModule;
75
+ feemarket: FeemarketModule;
69
76
  neo: NEOClient;
70
77
  eth: ETHClient;
71
78
  bsc: ETHClient;
@@ -75,6 +82,7 @@ declare class CarbonSDK {
75
82
  zil: ZILClient;
76
83
  n3: N3Client;
77
84
  chainId: string;
85
+ evmChainId: string;
78
86
  constructor(opts: CarbonSDKOpts);
79
87
  static instance(opts?: CarbonSDKInitOpts): Promise<CarbonSDK>;
80
88
  static instanceWithWallet(wallet: CarbonWallet, sdkOpts?: CarbonSDKInitOpts): Promise<ConnectedCarbonSDK>;
@@ -84,6 +92,7 @@ declare class CarbonSDK {
84
92
  static instanceWithLedger(ledger: CosmosLedger, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
85
93
  static instanceWithKeplr(keplr: Keplr, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
86
94
  static instanceWithLeap(leap: LeapExtended, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
95
+ static instanceWithMetamask(metamask: MetaMask, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts, metamaskWalletOpts?: MetaMaskWalletOpts): Promise<ConnectedCarbonSDK>;
87
96
  static instanceViewOnly(bech32Address: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
88
97
  initialize(): Promise<CarbonSDK>;
89
98
  clone(): CarbonSDK;
@@ -96,6 +105,7 @@ declare class CarbonSDK {
96
105
  connectWithLedger(ledger: CosmosLedger, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
97
106
  connectWithKeplr(keplr: Keplr, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
98
107
  connectWithLeap(leap: LeapExtended, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
108
+ connectWithMetamask(metamask: MetaMask, opts?: CarbonWalletGenericOpts, metamaskWalletOpts?: MetaMaskWalletOpts): Promise<ConnectedCarbonSDK>;
99
109
  connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
100
110
  getConfig(): NetworkConfig;
101
111
  getTokenClient(): TokenClient;
package/lib/CarbonSDK.js CHANGED
@@ -60,20 +60,24 @@ const DEFAULT_SDK_INIT_OPTS = {
60
60
  */
61
61
  class CarbonSDK {
62
62
  constructor(opts) {
63
- var _a, _b, _c, _d, _e;
63
+ var _a, _b, _c, _d, _e, _f, _g;
64
64
  this.network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
65
65
  this.configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
66
66
  this.networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[this.network], this.configOverride);
67
67
  this.tmClient = opts.tmClient;
68
68
  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];
69
+ 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
70
  this.query = new clients_1.CarbonQueryClient(opts.tmClient);
70
71
  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);
72
+ this.token = (_g = opts.token) !== null && _g !== void 0 ? _g : clients_1.TokenClient.instance(this.query, this);
73
+ this.hydrogen = new clients_1.HydrogenClient(this.networkConfig, this.token);
72
74
  this.hydrogen = clients_1.HydrogenClient.instance(this.networkConfig, this.token);
73
75
  this.admin = new modules_1.AdminModule(this);
74
76
  this.alliance = new modules_1.AllianceModule(this);
75
77
  this.order = new modules_1.OrderModule(this);
76
78
  this.lp = new modules_1.LiquidityPoolModule(this);
79
+ this.erc20 = new modules_1.ERC20Module(this);
80
+ this.plp = new modules_1.PerpsLiquidityModule(this);
77
81
  this.subaccount = new modules_1.SubAccountModule(this);
78
82
  this.profile = new modules_1.ProfileModule(this);
79
83
  this.cdp = new modules_1.CDPModule(this);
@@ -89,6 +93,9 @@ class CarbonSDK {
89
93
  this.fee = new modules_1.FeeModule(this);
90
94
  this.ibc = new modules_1.IBCModule(this);
91
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);
92
99
  this.neo = clients_1.NEOClient.instance({
93
100
  configProvider: this,
94
101
  blockchain: blockchain_1.Blockchain.Neo,
@@ -133,7 +140,8 @@ class CarbonSDK {
133
140
  const network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
134
141
  const configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
135
142
  const networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[network], configOverride);
136
- const tmClient = (_c = opts.tmClient) !== null && _c !== void 0 ? _c : util_1.GenericUtils.modifyTmClient(yield tendermint_rpc_1.Tendermint34Client.connect(networkConfig.tmRpcUrl));
143
+ const batchQueryClient = new clients.BatchQueryClient(networkConfig.tmRpcUrl);
144
+ const tmClient = (_c = opts.tmClient) !== null && _c !== void 0 ? _c : util_1.GenericUtils.modifyTmClient(yield tendermint_rpc_1.Tendermint34Client.create(batchQueryClient));
137
145
  const defaultTimeoutBlocks = opts.defaultTimeoutBlocks;
138
146
  const chainId = (_d = (yield tmClient.status())) === null || _d === void 0 ? void 0 : _d.nodeInfo.network;
139
147
  const sdk = new CarbonSDK({ network, config: configOverride, tmClient, defaultTimeoutBlocks, chainId });
@@ -188,6 +196,12 @@ class CarbonSDK {
188
196
  return sdk.connectWithLeap(leap, walletOpts);
189
197
  });
190
198
  }
199
+ static instanceWithMetamask(metamask, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts, metamaskWalletOpts) {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ const sdk = yield CarbonSDK.instance(sdkOpts);
202
+ return sdk.connectWithMetamask(metamask, walletOpts, metamaskWalletOpts);
203
+ });
204
+ }
191
205
  static instanceViewOnly(bech32Address, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
192
206
  return __awaiter(this, void 0, void 0, function* () {
193
207
  const sdk = yield CarbonSDK.instance(sdkOpts);
@@ -291,6 +305,20 @@ class CarbonSDK {
291
305
  return this.connect(wallet);
292
306
  });
293
307
  }
308
+ connectWithMetamask(metamask, opts, metamaskWalletOpts) {
309
+ return __awaiter(this, void 0, void 0, function* () {
310
+ const evmChainId = this.evmChainId;
311
+ const addressOptions = {
312
+ network: this.networkConfig.network,
313
+ bech32Prefix: this.networkConfig.Bech32Prefix,
314
+ };
315
+ const address = yield metamask.defaultAccount();
316
+ const publicKeyHex = yield metamask.getPublicKey(address, metamaskWalletOpts === null || metamaskWalletOpts === void 0 ? void 0 : metamaskWalletOpts.publicKeyMessage);
317
+ const publicKeyBase64 = Buffer.from(publicKeyHex, "hex").toString("base64");
318
+ const wallet = wallet_1.CarbonWallet.withMetamask(metamask, evmChainId, publicKeyBase64, addressOptions, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
319
+ return this.connect(wallet);
320
+ });
321
+ }
294
322
  connectViewOnly(bech32Address, opts) {
295
323
  return __awaiter(this, void 0, void 0, function* () {
296
324
  const wallet = wallet_1.CarbonWallet.withAddress(bech32Address, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
@@ -0,0 +1,26 @@
1
+ import { JsonRpcRequest, JsonRpcSuccessResponse } from "@cosmjs/json-rpc";
2
+ import { HttpEndpoint } from "@cosmjs/tendermint-rpc/build/rpcclients/httpclient";
3
+ import { RpcClient } from "@cosmjs/tendermint-rpc/build/rpcclients/rpcclient";
4
+ export interface BatchQueryClientOptions {
5
+ /** Interval for dispatching batches (in milliseconds) */
6
+ dispatchInterval: number;
7
+ /** Max number of items sent in one request */
8
+ batchSizeLimit: number;
9
+ }
10
+ declare class BatchQueryClient implements RpcClient {
11
+ protected readonly url: string;
12
+ protected readonly headers: Record<string, string> | undefined;
13
+ protected readonly options: BatchQueryClientOptions;
14
+ private timer?;
15
+ private readonly queue;
16
+ constructor(endpoint: string | HttpEndpoint, options?: Partial<BatchQueryClientOptions>);
17
+ disconnect(): void;
18
+ execute(request: JsonRpcRequest): Promise<JsonRpcSuccessResponse>;
19
+ private validate;
20
+ /**
21
+ * This is called in an interval where promise rejections cannot be handled.
22
+ * So this is not async and HTTP errors need to be handled by the queued promises.
23
+ */
24
+ private tick;
25
+ }
26
+ export default BatchQueryClient;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const json_rpc_1 = require("@cosmjs/json-rpc");
13
+ const http_1 = require("@cosmjs/tendermint-rpc/build/rpcclients/http");
14
+ const rpcclient_1 = require("@cosmjs/tendermint-rpc/build/rpcclients/rpcclient");
15
+ // Those values are private and can change any time.
16
+ // Does a user need to know them? I don't think so. You either set
17
+ // a custom value or leave the option field unset.
18
+ const defaultBatchQueryClientOptions = {
19
+ dispatchInterval: 20,
20
+ batchSizeLimit: 20,
21
+ };
22
+ class BatchQueryClient {
23
+ constructor(endpoint, options = {}) {
24
+ var _a, _b;
25
+ this.queue = [];
26
+ this.options = {
27
+ batchSizeLimit: (_a = options.batchSizeLimit) !== null && _a !== void 0 ? _a : defaultBatchQueryClientOptions.batchSizeLimit,
28
+ dispatchInterval: (_b = options.dispatchInterval) !== null && _b !== void 0 ? _b : defaultBatchQueryClientOptions.dispatchInterval,
29
+ };
30
+ if (typeof endpoint === "string") {
31
+ // accept host.name:port and assume http protocol
32
+ this.url = rpcclient_1.hasProtocol(endpoint) ? endpoint : "http://" + endpoint;
33
+ }
34
+ else {
35
+ this.url = endpoint.url;
36
+ this.headers = endpoint.headers;
37
+ }
38
+ this.timer = (setInterval(() => this.tick(), options.dispatchInterval));
39
+ this.validate();
40
+ }
41
+ disconnect() {
42
+ this.timer && clearInterval(this.timer);
43
+ this.timer = undefined;
44
+ }
45
+ execute(request) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ return new Promise((resolve, reject) => {
48
+ this.queue.push({ request, resolve, reject });
49
+ if (this.queue.length >= this.options.batchSizeLimit) {
50
+ // this train is full, let's go
51
+ this.tick();
52
+ }
53
+ });
54
+ });
55
+ }
56
+ validate() {
57
+ if (!this.options.batchSizeLimit ||
58
+ !Number.isSafeInteger(this.options.batchSizeLimit) ||
59
+ this.options.batchSizeLimit < 1) {
60
+ throw new Error("batchSizeLimit must be a safe integer >= 1");
61
+ }
62
+ }
63
+ /**
64
+ * This is called in an interval where promise rejections cannot be handled.
65
+ * So this is not async and HTTP errors need to be handled by the queued promises.
66
+ */
67
+ tick() {
68
+ // Avoid race conditions
69
+ const batch = this.queue.splice(0, this.options.batchSizeLimit);
70
+ if (!batch.length)
71
+ return;
72
+ const requests = batch.map((s) => s.request);
73
+ const requestIds = requests.map((request) => request.id);
74
+ http_1.http("POST", this.url, this.headers, requests).then((raw) => {
75
+ // Requests with a single entry return as an object
76
+ const arr = Array.isArray(raw) ? raw : [raw];
77
+ arr.forEach((el, i) => {
78
+ const req = batch[i];
79
+ if (!req)
80
+ return;
81
+ const { reject, resolve } = req;
82
+ const response = json_rpc_1.parseJsonRpcResponse(el);
83
+ if (json_rpc_1.isJsonRpcErrorResponse(response)) {
84
+ reject(new Error(JSON.stringify(response.error)));
85
+ }
86
+ else {
87
+ resolve(response);
88
+ }
89
+ });
90
+ }, (error) => {
91
+ for (const requestId of requestIds) {
92
+ const req = batch.find((s) => s.request.id === requestId);
93
+ if (!req)
94
+ return;
95
+ req.reject(error);
96
+ }
97
+ });
98
+ }
99
+ }
100
+ exports.default = BatchQueryClient;
@@ -5,6 +5,7 @@ import { QueryClientImpl as CDPQueryClient } from "../codec/cdp/query";
5
5
  import { QueryClientImpl as CoinQueryClient } from "../codec/coin/query";
6
6
  import { QueryClientImpl as AuthQueryClient } from "../codec/cosmos/auth/v1beta1/query";
7
7
  import { QueryClientImpl as BankQueryClient } from "../codec/cosmos/bank/v1beta1/query";
8
+ import { QueryClientImpl as NativeBankQueryClient } from "../codec/bank/query";
8
9
  import { ServiceClientImpl as CosmosTmClient } from "../codec/cosmos/base/tendermint/v1beta1/query";
9
10
  import { QueryClientImpl as DistributionQueryClient } from "../codec/cosmos/distribution/v1beta1/query";
10
11
  import { QueryClientImpl as EvidenceQueryClient } from "../codec/cosmos/evidence/v1beta1/query";
@@ -14,6 +15,10 @@ import { QueryClientImpl as ParamsQueryClient } from "../codec/cosmos/params/v1b
14
15
  import { QueryClientImpl as SlashingQueryClient } from "../codec/cosmos/slashing/v1beta1/query";
15
16
  import { QueryClientImpl as StakingQueryClient } from "../codec/cosmos/staking/v1beta1/query";
16
17
  import { QueryClientImpl as UpgradeQueryClient } from "../codec/cosmos/upgrade/v1beta1/query";
18
+ import { QueryClientImpl as EthermintEVMQueryClient } from "../codec/ethermint/evm/v1/query";
19
+ import { QueryClientImpl as EvmMergeQueryClient } from "../codec/evmmerge/query";
20
+ import { QueryClientImpl as EvmBankQueryClient } from "../codec/evmbank/query";
21
+ import { QueryClientImpl as EthermintFeeMarketQueryClient } from "../codec/ethermint/feemarket/v1/query";
17
22
  import { QueryClientImpl as FeeQueryClient } from "../codec/fee/query";
18
23
  import { QueryClientImpl as HeadersyncQueryClient } from "../codec/headersync/query";
19
24
  import { QueryClientImpl as IBCInterchainControlQueryClient } from "../codec/ibc/applications/interchain_accounts/controller/v1/query";
@@ -37,6 +42,7 @@ import { QueryClientImpl as PricingQueryClient } from "../codec/pricing/query";
37
42
  import { QueryClientImpl as ProfileQueryClient } from "../codec/profile/query";
38
43
  import { QueryClientImpl as SubaccountQueryClient } from "../codec/subaccount/query";
39
44
  import { QueryClientImpl as AllianceClient } from "../codec/alliance/query";
45
+ import { QueryClientImpl as PerpsLiquidityQueryClient } from "../codec/perpsliquidity/query";
40
46
  import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
41
47
  import BlockchainClient from "./BlockchainClient";
42
48
  export interface IBCClientGroup {
@@ -47,6 +53,10 @@ export interface IBCClientGroup {
47
53
  connection: IBCConnectionQueryClient;
48
54
  channel: IBCChannelQueryClient;
49
55
  }
56
+ export interface EthermintClientGroup {
57
+ evm: EthermintEVMQueryClient;
58
+ feeMarket: EthermintFeeMarketQueryClient;
59
+ }
50
60
  declare class CarbonQueryClient {
51
61
  private readonly tmClient;
52
62
  adl: ADLQueryClient;
@@ -70,8 +80,10 @@ declare class CarbonQueryClient {
70
80
  profile: ProfileQueryClient;
71
81
  subaccount: SubaccountQueryClient;
72
82
  headersync: HeadersyncQueryClient;
83
+ perpsliquidity: PerpsLiquidityQueryClient;
73
84
  auth: AuthQueryClient;
74
85
  bank: BankQueryClient;
86
+ nativeBank: NativeBankQueryClient;
75
87
  distribution: DistributionQueryClient;
76
88
  evidence: EvidenceQueryClient;
77
89
  gov: GovQueryClient;
@@ -84,6 +96,9 @@ declare class CarbonQueryClient {
84
96
  alliance: AllianceClient;
85
97
  chain: BlockchainClient;
86
98
  ibc: IBCClientGroup;
99
+ ethermint: EthermintClientGroup;
100
+ evmmerge: EvmMergeQueryClient;
101
+ evmbank: EvmBankQueryClient;
87
102
  private baseClient;
88
103
  constructor(tmClient: Tendermint34Client);
89
104
  getProtobufRpcClient(): import("@cosmjs/stargate").ProtobufRpcClient;
@@ -10,90 +10,105 @@ const query_4 = require("../codec/cdp/query");
10
10
  const query_5 = require("../codec/coin/query");
11
11
  const query_6 = require("../codec/cosmos/auth/v1beta1/query");
12
12
  const query_7 = require("../codec/cosmos/bank/v1beta1/query");
13
- const query_8 = require("../codec/cosmos/base/tendermint/v1beta1/query");
14
- const query_9 = require("../codec/cosmos/distribution/v1beta1/query");
15
- const query_10 = require("../codec/cosmos/evidence/v1beta1/query");
16
- const query_11 = require("../codec/cosmos/gov/v1beta1/query");
17
- const query_12 = require("../codec/cosmos/mint/v1beta1/query");
18
- const query_13 = require("../codec/cosmos/params/v1beta1/query");
19
- const query_14 = require("../codec/cosmos/slashing/v1beta1/query");
20
- const query_15 = require("../codec/cosmos/staking/v1beta1/query");
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");
44
- const query_39 = require("../codec/alliance/query");
13
+ const query_8 = require("../codec/bank/query");
14
+ const query_9 = require("../codec/cosmos/base/tendermint/v1beta1/query");
15
+ const query_10 = require("../codec/cosmos/distribution/v1beta1/query");
16
+ const query_11 = require("../codec/cosmos/evidence/v1beta1/query");
17
+ const query_12 = require("../codec/cosmos/gov/v1beta1/query");
18
+ const query_13 = require("../codec/cosmos/mint/v1beta1/query");
19
+ const query_14 = require("../codec/cosmos/params/v1beta1/query");
20
+ const query_15 = require("../codec/cosmos/slashing/v1beta1/query");
21
+ const query_16 = require("../codec/cosmos/staking/v1beta1/query");
22
+ const query_17 = require("../codec/cosmos/upgrade/v1beta1/query");
23
+ const query_18 = require("../codec/ethermint/evm/v1/query");
24
+ const query_19 = require("../codec/evmmerge/query");
25
+ const query_20 = require("../codec/evmbank/query");
26
+ const query_21 = require("../codec/ethermint/feemarket/v1/query");
27
+ const query_22 = require("../codec/fee/query");
28
+ const query_23 = require("../codec/headersync/query");
29
+ const query_24 = require("../codec/ibc/applications/interchain_accounts/controller/v1/query");
30
+ const query_25 = require("../codec/ibc/applications/interchain_accounts/host/v1/query");
31
+ const query_26 = require("../codec/ibc/applications/transfer/v1/query");
32
+ const query_27 = require("../codec/ibc/core/client/v1/query");
33
+ const query_28 = require("../codec/ibc/core/connection/v1/query");
34
+ const query_29 = require("../codec/ibc/core/channel/v1/query");
35
+ const query_30 = require("../codec/inflation/query");
36
+ const query_31 = require("../codec/insurance/query");
37
+ const query_32 = require("../codec/leverage/query");
38
+ const query_33 = require("../codec/liquidation/query");
39
+ const query_34 = require("../codec/liquiditypool/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");
49
+ const query_44 = require("../codec/alliance/query");
50
+ const query_45 = require("../codec/perpsliquidity/query");
45
51
  const stargate_1 = require("@cosmjs/stargate");
46
52
  const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
47
53
  class CarbonQueryClient {
48
54
  constructor(tmClient) {
49
55
  this.tmClient = tmClient;
50
56
  this.baseClient = new stargate_1.QueryClient(this.tmClient);
51
- const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
57
+ const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
52
58
  this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
53
59
  this.adl = new query_1.QueryClientImpl(rpcClient);
54
- this.alliance = new query_39.QueryClientImpl(rpcClient);
60
+ this.alliance = new query_44.QueryClientImpl(rpcClient);
55
61
  this.book = new query_2.QueryClientImpl(rpcClient);
56
62
  this.broker = new query_3.QueryClientImpl(rpcClient);
57
63
  this.coin = new query_5.QueryClientImpl(rpcClient);
58
64
  this.cdp = new query_4.QueryClientImpl(rpcClient);
59
- this.fee = new query_17.QueryClientImpl(rpcClient);
60
- this.inflation = new query_25.QueryClientImpl(rpcClient);
61
- this.insurance = new query_26.QueryClientImpl(rpcClient);
62
- this.leverage = new query_27.QueryClientImpl(rpcClient);
63
- this.liquidation = new query_28.QueryClientImpl(rpcClient);
64
- this.liquiditypool = new query_29.QueryClientImpl(rpcClient);
65
- this.market = new query_30.QueryClientImpl(rpcClient);
66
- this.marketstats = new query_31.QueryClientImpl(rpcClient);
67
- this.misc = new query_32.QueryClientImpl(rpcClient);
68
- this.oracle = new query_33.QueryClientImpl(rpcClient);
69
- this.order = new query_34.QueryClientImpl(rpcClient);
70
- this.position = new query_35.QueryClientImpl(rpcClient);
71
- this.pricing = new query_36.QueryClientImpl(rpcClient);
72
- this.profile = new query_37.QueryClientImpl(rpcClient);
73
- this.subaccount = new query_38.QueryClientImpl(rpcClient);
74
- this.headersync = new query_18.QueryClientImpl(rpcClient);
65
+ this.fee = new query_22.QueryClientImpl(rpcClient);
66
+ this.inflation = new query_30.QueryClientImpl(rpcClient);
67
+ this.insurance = new query_31.QueryClientImpl(rpcClient);
68
+ this.leverage = new query_32.QueryClientImpl(rpcClient);
69
+ this.liquidation = new query_33.QueryClientImpl(rpcClient);
70
+ this.liquiditypool = new query_34.QueryClientImpl(rpcClient);
71
+ this.market = new query_35.QueryClientImpl(rpcClient);
72
+ this.marketstats = new query_36.QueryClientImpl(rpcClient);
73
+ this.misc = new query_37.QueryClientImpl(rpcClient);
74
+ this.oracle = new query_38.QueryClientImpl(rpcClient);
75
+ this.order = new query_39.QueryClientImpl(rpcClient);
76
+ this.position = new query_40.QueryClientImpl(rpcClient);
77
+ this.pricing = new query_41.QueryClientImpl(rpcClient);
78
+ this.profile = new query_42.QueryClientImpl(rpcClient);
79
+ this.subaccount = new query_43.QueryClientImpl(rpcClient);
80
+ this.headersync = new query_23.QueryClientImpl(rpcClient);
81
+ this.evmmerge = new query_19.QueryClientImpl(rpcClient);
82
+ this.evmbank = new query_20.QueryClientImpl(rpcClient);
83
+ this.perpsliquidity = new query_45.QueryClientImpl(rpcClient);
75
84
  this.auth = new query_6.QueryClientImpl(rpcClient);
76
85
  this.bank = new query_7.QueryClientImpl(rpcClient);
77
- this.distribution = new query_9.QueryClientImpl(rpcClient);
78
- this.evidence = new query_10.QueryClientImpl(rpcClient);
79
- this.gov = new query_11.QueryClientImpl(rpcClient);
80
- this.mint = new query_12.QueryClientImpl(rpcClient);
81
- this.params = new query_13.QueryClientImpl(rpcClient);
82
- this.slashing = new query_14.QueryClientImpl(rpcClient);
83
- this.staking = new query_15.QueryClientImpl(rpcClient);
84
- this.upgrade = new query_16.QueryClientImpl(rpcClient);
85
- this.cosmosTm = new query_8.ServiceClientImpl(rpcClient);
86
+ this.nativeBank = new query_8.QueryClientImpl(rpcClient);
87
+ this.distribution = new query_10.QueryClientImpl(rpcClient);
88
+ this.evidence = new query_11.QueryClientImpl(rpcClient);
89
+ this.gov = new query_12.QueryClientImpl(rpcClient);
90
+ this.mint = new query_13.QueryClientImpl(rpcClient);
91
+ this.params = new query_14.QueryClientImpl(rpcClient);
92
+ this.slashing = new query_15.QueryClientImpl(rpcClient);
93
+ this.staking = new query_16.QueryClientImpl(rpcClient);
94
+ this.upgrade = new query_17.QueryClientImpl(rpcClient);
95
+ this.cosmosTm = new query_9.ServiceClientImpl(rpcClient);
96
+ this.alliance = new query_44.QueryClientImpl(rpcClient);
86
97
  this.ibc = {
87
- controller: new query_19.QueryClientImpl(rpcClient),
88
- host: new query_20.QueryClientImpl(rpcClient),
89
- transfer: new query_21.QueryClientImpl(rpcClient),
90
- client: new query_22.QueryClientImpl(rpcClient),
91
- connection: new query_23.QueryClientImpl(rpcClient),
92
- channel: new query_24.QueryClientImpl(rpcClient),
98
+ controller: new query_24.QueryClientImpl(rpcClient),
99
+ host: new query_25.QueryClientImpl(rpcClient),
100
+ transfer: new query_26.QueryClientImpl(rpcClient),
101
+ client: new query_27.QueryClientImpl(rpcClient),
102
+ connection: new query_28.QueryClientImpl(rpcClient),
103
+ channel: new query_29.QueryClientImpl(rpcClient),
104
+ };
105
+ this.ethermint = {
106
+ evm: new query_18.QueryClientImpl(rpcClient),
107
+ feeMarket: new query_21.QueryClientImpl(rpcClient),
93
108
  };
94
109
  }
95
110
  getProtobufRpcClient() {
96
- return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
111
+ return stargate_1.createProtobufRpcClient(this.baseClient);
97
112
  }
98
113
  }
99
114
  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
@@ -37,5 +37,7 @@ declare class InsightsQueryClient {
37
37
  DenomToGeckoIdMap(): Promise<Insights.InsightsQueryResponse<Insights.QueryDenomToGeckoIdMap>>;
38
38
  FundingHistory(query: Insights.QueryGetFundingRateRequest): Promise<Insights.InsightsQueryResponse<Insights.QueryGetFundingRateResponse>>;
39
39
  ProposalVotes(req: Insights.GetProposalVotesPathParams, query: Insights.GetProposalVotesQueryParams): Promise<Insights.InsightsQueryResponse<Insights.QueryGetProposalVotesResponse>>;
40
+ Delegations(req: Insights.GetDelegationsPathParams, query: Insights.GetDelegationsQueryParams): Promise<Insights.InsightsQueryResponse<Insights.QueryGetDelegationsResponse>>;
41
+ OraclePrices(req?: Insights.QueryGetOraclesPriceRequest): Promise<Insights.InsightsQueryResponse<Insights.QueryGetOraclesPriceResponse>>;
40
42
  }
41
43
  export default InsightsQueryClient;
@@ -340,5 +340,19 @@ class InsightsQueryClient {
340
340
  return response.data;
341
341
  });
342
342
  }
343
+ Delegations(req, query) {
344
+ return __awaiter(this, void 0, void 0, function* () {
345
+ const request = this.apiManager.path("delegations/delegator", req, query);
346
+ const response = yield request.get();
347
+ return response.data;
348
+ });
349
+ }
350
+ OraclePrices(req = {}) {
351
+ return __awaiter(this, void 0, void 0, function* () {
352
+ const request = this.apiManager.path("info/oracles_price", {}, req);
353
+ const response = yield request.get();
354
+ return response.data;
355
+ });
356
+ }
343
357
  }
344
358
  exports.default = InsightsQueryClient;