carbon-js-sdk 0.6.2 → 0.6.3

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 (106) hide show
  1. package/lib/CarbonSDK.d.ts +1 -0
  2. package/lib/CarbonSDK.js +8 -6
  3. package/lib/clients/BatchQueryClient.js +4 -4
  4. package/lib/clients/CarbonQueryClient.js +1 -1
  5. package/lib/clients/ETHClient.d.ts +1 -0
  6. package/lib/clients/ETHClient.js +17 -17
  7. package/lib/clients/HydrogenClient.js +1 -1
  8. package/lib/clients/InsightsQueryClient.js +3 -3
  9. package/lib/clients/NEOClient.js +7 -7
  10. package/lib/clients/TokenClient.js +2 -2
  11. package/lib/clients/ZILClient.js +17 -17
  12. package/lib/codec/book/book.d.ts +14 -2
  13. package/lib/codec/book/book.js +80 -13
  14. package/lib/codec/book/legacy.d.ts +22 -0
  15. package/lib/codec/book/legacy.js +120 -0
  16. package/lib/codec/book/query.d.ts +48 -1
  17. package/lib/codec/book/query.js +224 -1
  18. package/lib/codec/cdp/event.d.ts +12 -6
  19. package/lib/codec/cdp/event.js +146 -68
  20. package/lib/codec/cdp/params.d.ts +0 -2
  21. package/lib/codec/cdp/params.js +8 -23
  22. package/lib/codec/cdp/query.d.ts +22 -1
  23. package/lib/codec/cdp/query.js +104 -17
  24. package/lib/codec/cosmos/gov/v1/query.js +2 -2
  25. package/lib/codec/cosmos/gov/v1/tx.js +2 -2
  26. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  27. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  28. package/lib/codec/cosmos/group/v1/events.js +2 -2
  29. package/lib/codec/cosmos/group/v1/tx.js +4 -4
  30. package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
  31. package/lib/codec/index.d.ts +11 -9
  32. package/lib/codec/index.js +405 -133
  33. package/lib/codec/liquiditypool/event.d.ts +25 -1
  34. package/lib/codec/liquiditypool/event.js +147 -1
  35. package/lib/codec/liquiditypool/genesis.d.ts +4 -5
  36. package/lib/codec/liquiditypool/genesis.js +34 -49
  37. package/lib/codec/liquiditypool/query.d.ts +2 -51
  38. package/lib/codec/liquiditypool/query.js +18 -265
  39. package/lib/codec/liquiditypool/reward.d.ts +21 -21
  40. package/lib/codec/liquiditypool/reward.js +97 -111
  41. package/lib/codec/oracle/query.d.ts +37 -34
  42. package/lib/codec/oracle/query.js +37 -31
  43. package/lib/codec/position/position.d.ts +2 -0
  44. package/lib/codec/position/position.js +34 -0
  45. package/lib/codec/subaccount/genesis.d.ts +5 -1
  46. package/lib/codec/subaccount/genesis.js +48 -2
  47. package/lib/codec/subaccount/query.d.ts +110 -21
  48. package/lib/codec/subaccount/query.js +503 -47
  49. package/lib/codec/subaccount/subaccount.d.ts +29 -3
  50. package/lib/codec/subaccount/subaccount.js +234 -31
  51. package/lib/codec/subaccount/tx.d.ts +7 -1
  52. package/lib/codec/subaccount/tx.js +101 -16
  53. package/lib/constant/generic.js +1 -1
  54. package/lib/modules/cdp.js +45 -45
  55. package/lib/modules/cosmwasm.js +2 -2
  56. package/lib/modules/evm.js +5 -5
  57. package/lib/modules/gov.js +12 -12
  58. package/lib/modules/liquiditypool.js +1 -1
  59. package/lib/modules/order.js +2 -2
  60. package/lib/modules/subaccount.js +1 -1
  61. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  62. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  63. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  64. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  65. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  66. package/lib/provider/amino/types/admin.js +27 -27
  67. package/lib/provider/amino/types/bank.js +1 -1
  68. package/lib/provider/amino/types/broker.js +1 -1
  69. package/lib/provider/amino/types/cdp.js +25 -25
  70. package/lib/provider/amino/types/coin.js +4 -4
  71. package/lib/provider/amino/types/evm.js +2 -2
  72. package/lib/provider/amino/types/evmmerge.js +1 -1
  73. package/lib/provider/amino/types/feemarket.js +1 -1
  74. package/lib/provider/amino/types/gov.js +5 -5
  75. package/lib/provider/amino/types/ibc.js +1 -1
  76. package/lib/provider/amino/types/leverage.js +1 -1
  77. package/lib/provider/amino/types/liquidityPool.js +7 -7
  78. package/lib/provider/amino/types/market.js +6 -6
  79. package/lib/provider/amino/types/oracle.js +2 -2
  80. package/lib/provider/amino/types/order.js +4 -4
  81. package/lib/provider/amino/types/position.js +1 -1
  82. package/lib/provider/amino/types/profile.js +1 -1
  83. package/lib/provider/amino/types/staking.js +4 -4
  84. package/lib/provider/amino/types/subaccount.js +3 -3
  85. package/lib/provider/amino/utils.js +11 -11
  86. package/lib/provider/keplr/KeplrAccount.js +2 -2
  87. package/lib/provider/ledger/ledger.js +2 -2
  88. package/lib/provider/metamask/MetaMask.js +13 -13
  89. package/lib/provider/o3/O3Wallet.js +2 -2
  90. package/lib/util/address.js +14 -14
  91. package/lib/util/api.js +4 -4
  92. package/lib/util/blockchain.d.ts +1 -1
  93. package/lib/util/blockchain.js +4 -4
  94. package/lib/util/eip712.js +3 -3
  95. package/lib/util/fetch.js +1 -1
  96. package/lib/util/generic.js +3 -3
  97. package/lib/util/legacyEIP712.js +2 -2
  98. package/lib/util/network.js +3 -3
  99. package/lib/util/number.js +5 -5
  100. package/lib/wallet/CarbonSigner.js +2 -2
  101. package/lib/wallet/CarbonSigningClient.js +15 -15
  102. package/lib/wallet/CarbonWallet.js +9 -9
  103. package/lib/websocket/connector.js +3 -3
  104. package/package.json +1 -1
  105. package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.d.ts +0 -76
  106. package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.js +0 -424
package/lib/util/api.js CHANGED
@@ -84,7 +84,7 @@ class HTTP {
84
84
  * Executes HTTP GET request with fetch
85
85
  */
86
86
  this.get = ({ url, headers }) => {
87
- return fetch_1.fetch(url, {
87
+ return (0, fetch_1.fetch)(url, {
88
88
  method: "GET",
89
89
  headers,
90
90
  });
@@ -93,7 +93,7 @@ class HTTP {
93
93
  * Executes HTTP POST request with fetch
94
94
  */
95
95
  this.post = (options) => {
96
- return fetch_1.fetch(options.url, {
96
+ return (0, fetch_1.fetch)(options.url, {
97
97
  method: "POST",
98
98
  headers: Object.assign({ "Content-Type": options.content_type || "application/json" }, options.headers),
99
99
  body: JSON.stringify(options.body),
@@ -103,7 +103,7 @@ class HTTP {
103
103
  * Executes HTTP DELETE request with fetch
104
104
  */
105
105
  this.del = (options) => {
106
- return fetch_1.fetch(options.url, {
106
+ return (0, fetch_1.fetch)(options.url, {
107
107
  method: "DELETE",
108
108
  headers: Object.assign({ "Content-Type": options.content_type || "application/json" }, options.headers),
109
109
  body: JSON.stringify(options.body),
@@ -114,7 +114,7 @@ class HTTP {
114
114
  */
115
115
  this.raw = (options) => {
116
116
  const { url } = options, otherOpts = __rest(options, ["url"]);
117
- return fetch_1.fetch(url, otherOpts);
117
+ return (0, fetch_1.fetch)(url, otherOpts);
118
118
  };
119
119
  this.apiPrefix = apiPrefix;
120
120
  this.apiEndpoints = apiEndpoints;
@@ -84,7 +84,7 @@ export declare function parseBlockchain(value: string | null): Blockchain | null
84
84
  export declare function getChainFromID(id: number): string | undefined;
85
85
  export declare const getBlockchainFromChain: (chainId?: number | undefined) => Blockchain.Ethereum | Blockchain.BinanceSmartChain | Blockchain.Zilliqa | Blockchain.Arbitrum | Blockchain.Polygon | Blockchain.Okc | undefined;
86
86
  export declare const blockchainForChainId: (chainId?: number | undefined, network?: Network) => Blockchain | undefined;
87
- export declare const getBlockchainFromChainV2: (chainId?: number | undefined) => "Carbon" | "Ethereum" | "Binance Smart Chain" | "Arbitrum" | "Polygon" | "Okc" | "Zilliqa" | undefined;
87
+ export declare const getBlockchainFromChainV2: (chainId?: number | undefined) => "Carbon" | "Ethereum" | "Binance Smart Chain" | "Arbitrum" | "Polygon" | "Zilliqa" | "Okc" | undefined;
88
88
  export declare const blockchainForChainIdV2: (chainId?: number | undefined, network?: Network) => Blockchain | BlockchainV2 | undefined;
89
89
  export declare const EvmChains: readonly ["Ethereum", "Binance Smart Chain", "Arbitrum", "Polygon", "OKC", "Carbon"];
90
90
  export declare type EVMChain = (typeof EvmChains)[number];
@@ -297,10 +297,10 @@ const getBlockchainFromChainV2 = (chainId) => {
297
297
  case 42161:
298
298
  case 421611:
299
299
  return 'Arbitrum';
300
- case Number(ethermint_1.parseChainId((network_1.CarbonEvmChainIDs[network_1.Network.LocalHost]))):
301
- case Number(ethermint_1.parseChainId((network_1.CarbonEvmChainIDs[network_1.Network.DevNet]))):
302
- case Number(ethermint_1.parseChainId((network_1.CarbonEvmChainIDs[network_1.Network.TestNet]))):
303
- case Number(ethermint_1.parseChainId((network_1.CarbonEvmChainIDs[network_1.Network.MainNet]))):
300
+ case Number((0, ethermint_1.parseChainId)((network_1.CarbonEvmChainIDs[network_1.Network.LocalHost]))):
301
+ case Number((0, ethermint_1.parseChainId)((network_1.CarbonEvmChainIDs[network_1.Network.DevNet]))):
302
+ case Number((0, ethermint_1.parseChainId)((network_1.CarbonEvmChainIDs[network_1.Network.TestNet]))):
303
+ case Number((0, ethermint_1.parseChainId)((network_1.CarbonEvmChainIDs[network_1.Network.MainNet]))):
304
304
  return 'Carbon';
305
305
  }
306
306
  return undefined;
@@ -114,7 +114,7 @@ function getMsgValueType(msgTypeUrl, msgValue, msgTypeName, msgTypeIndex, types,
114
114
  const isArray = type.includes('[]') ? true : false;
115
115
  // TypeValue0 --> Value
116
116
  const objectName = typeName.split('Type')[1].split(`${msgTypeIndex}`)[0];
117
- const nestedTypeName = `Type${objectName ? objectName : ''}${name.split('_').map((subName) => lodash_1.capitalize(subName)).join('')}`;
117
+ const nestedTypeName = `Type${objectName ? objectName : ''}${name.split('_').map((subName) => (0, lodash_1.capitalize)(subName)).join('')}`;
118
118
  const nestedMsgTypeIndex = getLatestMsgTypeIndex(nestedTypeName, types);
119
119
  const nestedType = getTypeName(name, nestedMsgTypeIndex, objectName, true, isArray);
120
120
  msgTypeDefinitions[typeName] = [...msgTypeDefinitions[typeName], { name, type: nestedType }];
@@ -153,7 +153,7 @@ function getGjsonPrimitiveType(value) {
153
153
  }
154
154
  function getTypeName(name, index, objectName, nestedType = false, isArray = false) {
155
155
  if (nestedType) {
156
- return `Type${objectName ? objectName : ''}${name.split('_').map(subName => lodash_1.capitalize(subName)).join('')}${index}${isArray ? '[]' : ''}`;
156
+ return `Type${objectName ? objectName : ''}${name.split('_').map(subName => (0, lodash_1.capitalize)(subName)).join('')}${index}${isArray ? '[]' : ''}`;
157
157
  }
158
158
  return name;
159
159
  }
@@ -180,7 +180,7 @@ function constructEIP712Tx(doc) {
180
180
  const eip712Tx = {
181
181
  types: getTypes(doc.msgs),
182
182
  primaryType: "Tx",
183
- domain: Object.assign(Object.assign({}, eip712_1.DEFAULT_CARBON_DOMAIN_FIELDS), { chainId: ethermint_1.parseChainId(doc.chain_id) }),
183
+ domain: Object.assign(Object.assign({}, eip712_1.DEFAULT_CARBON_DOMAIN_FIELDS), { chainId: (0, ethermint_1.parseChainId)(doc.chain_id) }),
184
184
  message: Object.assign({ account_number, chain_id, fee, memo, sequence }, convertMsgs(doc.msgs))
185
185
  };
186
186
  return eip712Tx;
package/lib/util/fetch.js CHANGED
@@ -10,7 +10,7 @@ function fetch(url, init) {
10
10
  return window.fetch(url, Object.assign({}, init));
11
11
  }
12
12
  else {
13
- return node_fetch_1.default(url, init);
13
+ return (0, node_fetch_1.default)(url, init);
14
14
  }
15
15
  }
16
16
  exports.fetch = fetch;
@@ -23,7 +23,7 @@ const overrideConfig = (defaults, override) => {
23
23
  continue;
24
24
  if (typeof member === "object") {
25
25
  // @ts-ignore
26
- result[key] = exports.overrideConfig(result[key], member);
26
+ result[key] = (0, exports.overrideConfig)(result[key], member);
27
27
  }
28
28
  else {
29
29
  // @ts-ignore
@@ -42,7 +42,7 @@ const sortObject = (input) => {
42
42
  Object.keys(input)
43
43
  .sort()
44
44
  // @ts-ignore noImplicitAny
45
- .forEach((key) => (output[key] = exports.sortObject(input[key])));
45
+ .forEach((key) => (output[key] = (0, exports.sortObject)(input[key])));
46
46
  return output;
47
47
  };
48
48
  exports.sortObject = sortObject;
@@ -57,7 +57,7 @@ exports.appendHexPrefix = appendHexPrefix;
57
57
  const computeTxHash = (bytes) => {
58
58
  if (!bytes)
59
59
  return bytes;
60
- return exports.toTxHash(crypto_1.sha256(bytes));
60
+ return (0, exports.toTxHash)((0, crypto_1.sha256)(bytes));
61
61
  };
62
62
  exports.computeTxHash = computeTxHash;
63
63
  const toTxHash = (bytes) => {
@@ -62,7 +62,7 @@ function getMsgValueType(msgTypeUrl, msgValue, msgTypeName, objectName, nestedTy
62
62
  }
63
63
  function getTypeName(name, objectName, nestedType = false, isArray = false) {
64
64
  if (nestedType) {
65
- return `Type${objectName === 'MsgValue' ? '' : objectName}${name.split('_').map(subName => lodash_1.capitalize(subName)).join('')}${isArray ? '[]' : ''}`;
65
+ return `Type${objectName === 'MsgValue' ? '' : objectName}${name.split('_').map(subName => (0, lodash_1.capitalize)(subName)).join('')}${isArray ? '[]' : ''}`;
66
66
  }
67
67
  return name;
68
68
  }
@@ -90,7 +90,7 @@ function legacyConstructEIP712Tx(doc) {
90
90
  const eip712Tx = {
91
91
  types: getTypes(AminoTypesMap_1.default.fromAmino(msg).typeUrl, msg.value),
92
92
  primaryType: "Tx",
93
- domain: Object.assign(Object.assign({}, eip712_1.DEFAULT_CARBON_DOMAIN_FIELDS), { chainId: ethermint_1.parseChainId(doc.chain_id) }),
93
+ domain: Object.assign(Object.assign({}, eip712_1.DEFAULT_CARBON_DOMAIN_FIELDS), { chainId: (0, ethermint_1.parseChainId)(doc.chain_id) }),
94
94
  message: doc
95
95
  };
96
96
  return eip712Tx;
@@ -31,9 +31,9 @@ const parseNetwork = (network, defaultNetwork = constant_1.DEFAULT_NETWORK) => {
31
31
  exports.parseNetwork = parseNetwork;
32
32
  const carbonNetworkFromChainId = (parsedEvmChainId) => {
33
33
  switch (parsedEvmChainId) {
34
- case ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[__1.CarbonSDK.Network.LocalHost]): return __1.CarbonSDK.Network.LocalHost;
35
- case ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[__1.CarbonSDK.Network.DevNet]): return __1.CarbonSDK.Network.DevNet;
36
- case ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[__1.CarbonSDK.Network.TestNet]): return __1.CarbonSDK.Network.TestNet;
34
+ case (0, ethermint_1.parseChainId)(constant_1.CarbonEvmChainIDs[__1.CarbonSDK.Network.LocalHost]): return __1.CarbonSDK.Network.LocalHost;
35
+ case (0, ethermint_1.parseChainId)(constant_1.CarbonEvmChainIDs[__1.CarbonSDK.Network.DevNet]): return __1.CarbonSDK.Network.DevNet;
36
+ case (0, ethermint_1.parseChainId)(constant_1.CarbonEvmChainIDs[__1.CarbonSDK.Network.TestNet]): return __1.CarbonSDK.Network.TestNet;
37
37
  default: return __1.CarbonSDK.Network.MainNet;
38
38
  }
39
39
  };
@@ -18,26 +18,26 @@ const parseBN = (input, defaultValue) => {
18
18
  };
19
19
  exports.parseBN = parseBN;
20
20
  const bnOrZero = (input, defaultValue = exports.BN_ZERO) => {
21
- return exports.parseBN(input, defaultValue);
21
+ return (0, exports.parseBN)(input, defaultValue);
22
22
  };
23
23
  exports.bnOrZero = bnOrZero;
24
24
  const toHuman = (value, decimals) => {
25
25
  if (value === undefined || value === null)
26
26
  return undefined;
27
- const valueBN = exports.bnOrZero(value);
27
+ const valueBN = (0, exports.bnOrZero)(value);
28
28
  if (!decimals)
29
29
  return valueBN; // decimals = 0 or nullish
30
- const decimalsBN = exports.bnOrZero(decimals);
30
+ const decimalsBN = (0, exports.bnOrZero)(decimals);
31
31
  return valueBN.shiftedBy(decimalsBN.negated().toNumber());
32
32
  };
33
33
  exports.toHuman = toHuman;
34
34
  const toUnitless = (value, decimals) => {
35
35
  if (value === undefined || value === null)
36
36
  return undefined;
37
- const valueBN = exports.bnOrZero(value);
37
+ const valueBN = (0, exports.bnOrZero)(value);
38
38
  if (!decimals)
39
39
  return valueBN; // decimals = 0 or nullish
40
- const decimalsBN = exports.bnOrZero(decimals);
40
+ const decimalsBN = (0, exports.bnOrZero)(decimals);
41
41
  return valueBN.shiftedBy(decimalsBN.toNumber());
42
42
  };
43
43
  exports.toUnitless = toUnitless;
@@ -120,9 +120,9 @@ class CarbonLedgerSigner {
120
120
  return __awaiter(this, void 0, void 0, function* () {
121
121
  const account = yield this.retrieveAccount();
122
122
  const { pubkey } = account;
123
- const msg = JSON.stringify(generic_1.sortObject(doc));
123
+ const msg = JSON.stringify((0, generic_1.sortObject)(doc));
124
124
  const signBytes = yield this.ledger.sign(msg);
125
- const signature = amino_1.encodeSecp256k1Signature(pubkey, signBytes);
125
+ const signature = (0, amino_1.encodeSecp256k1Signature)(pubkey, signBytes);
126
126
  return {
127
127
  signed: doc,
128
128
  signature,
@@ -90,10 +90,10 @@ class CarbonSigningClient extends stargate_1.StargateClient {
90
90
  */
91
91
  sign(signerAddress, messages, fee, memo, signerData) {
92
92
  return __awaiter(this, void 0, void 0, function* () {
93
- if (CarbonSigner_1.isCarbonEIP712Signer(this.signer) && this.signer.legacyEip712SignMode) {
93
+ if ((0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer) && this.signer.legacyEip712SignMode) {
94
94
  return this.signLegacyEip712(signerAddress, messages, fee, memo, signerData);
95
95
  }
96
- return proto_signing_1.isOfflineDirectSigner(this.signer)
96
+ return (0, proto_signing_1.isOfflineDirectSigner)(this.signer)
97
97
  ? this.signDirect(signerAddress, messages, fee, memo, signerData)
98
98
  : this.signAmino(signerAddress, messages, fee, memo, signerData);
99
99
  });
@@ -102,11 +102,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
102
102
  return __awaiter(this, void 0, void 0, function* () {
103
103
  const signer = this.signer;
104
104
  const accountFromSigner = (yield this.signer.getAccounts()).find((account) => account.address === signerAddress);
105
- if (!CarbonSigner_1.isCarbonEIP712Signer(this.signer) && !accountFromSigner) {
105
+ if (!(0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer) && !accountFromSigner) {
106
106
  throw new Error("Failed to retrieve account from signer");
107
107
  }
108
108
  const pubKeyBz = accountFromSigner ? accountFromSigner.pubkey : (yield this.signer.getAccounts())[0].pubkey;
109
- const pubkey = CarbonSigner_1.isCarbonEIP712Signer(this.signer) ? ethermint_1.encodeAnyEthSecp256k1PubKey(pubKeyBz) : proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(pubKeyBz));
109
+ const pubkey = (0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer) ? (0, ethermint_1.encodeAnyEthSecp256k1PubKey)(pubKeyBz) : (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(pubKeyBz));
110
110
  const txBodyEncodeObject = {
111
111
  typeUrl: "/cosmos.tx.v1beta1.TxBody",
112
112
  value: Object.assign({ messages: messages, memo: memo }, (timeoutHeight && {
@@ -115,13 +115,13 @@ class CarbonSigningClient extends stargate_1.StargateClient {
115
115
  };
116
116
  const txBodyBytes = this.registry.encode(txBodyEncodeObject);
117
117
  const gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
118
- const authInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, undefined, undefined);
119
- const signDoc = proto_signing_1.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
118
+ const authInfoBytes = (0, proto_signing_1.makeAuthInfoBytes)([{ pubkey, sequence }], fee.amount, gasLimit, undefined, undefined);
119
+ const signDoc = (0, proto_signing_1.makeSignDoc)(txBodyBytes, authInfoBytes, chainId, accountNumber);
120
120
  const { signature, signed } = yield signer.signDirect(signerAddress, signDoc);
121
121
  return tx_1.TxRaw.fromPartial({
122
122
  bodyBytes: signed.bodyBytes,
123
123
  authInfoBytes: signed.authInfoBytes,
124
- signatures: [encoding_1.fromBase64(signature.signature)],
124
+ signatures: [(0, encoding_1.fromBase64)(signature.signature)],
125
125
  });
126
126
  });
127
127
  }
@@ -129,11 +129,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
129
129
  return __awaiter(this, void 0, void 0, function* () {
130
130
  const signer = this.signer;
131
131
  const accountFromSigner = (yield this.signer.getAccounts()).find((account) => account.address === signerAddress);
132
- if (!CarbonSigner_1.isCarbonEIP712Signer(this.signer) && !accountFromSigner) {
132
+ if (!(0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer) && !accountFromSigner) {
133
133
  throw new Error("Failed to retrieve account from signer");
134
134
  }
135
135
  const pubKeyBz = accountFromSigner ? accountFromSigner.pubkey : (yield this.signer.getAccounts())[0].pubkey;
136
- const pubkey = CarbonSigner_1.isCarbonEIP712Signer(this.signer) ? ethermint_1.encodeAnyEthSecp256k1PubKey(pubKeyBz) : proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(pubKeyBz));
136
+ const pubkey = (0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer) ? (0, ethermint_1.encodeAnyEthSecp256k1PubKey)(pubKeyBz) : (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(pubKeyBz));
137
137
  const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
138
138
  const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
139
139
  const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight !== null && timeoutHeight !== void 0 ? timeoutHeight : 0);
@@ -148,11 +148,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
148
148
  const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
149
149
  const signedGasLimit = math_1.Int53.fromString(signed.fee.gas).toNumber();
150
150
  const signedSequence = math_1.Int53.fromString(signed.sequence).toNumber();
151
- const signedAuthInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, undefined, undefined, signMode);
151
+ const signedAuthInfoBytes = (0, proto_signing_1.makeAuthInfoBytes)([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, undefined, undefined, signMode);
152
152
  return tx_1.TxRaw.fromPartial({
153
153
  bodyBytes: signedTxBodyBytes,
154
154
  authInfoBytes: signedAuthInfoBytes,
155
- signatures: [encoding_1.fromBase64(signature.signature)],
155
+ signatures: [(0, encoding_1.fromBase64)(signature.signature)],
156
156
  });
157
157
  });
158
158
  }
@@ -163,7 +163,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
163
163
  }
164
164
  const signer = this.signer;
165
165
  const pubKeyBz = (yield this.signer.getAccounts())[0].pubkey;
166
- const pubkey = ethermint_1.encodeAnyEthSecp256k1PubKey(pubKeyBz);
166
+ const pubkey = (0, ethermint_1.encodeAnyEthSecp256k1PubKey)(pubKeyBz);
167
167
  const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
168
168
  const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
169
169
  const signDoc = makeSignDocAmino(msgs, fee, evmChainId, memo, accountNumber, sequence);
@@ -171,14 +171,14 @@ class CarbonSigningClient extends stargate_1.StargateClient {
171
171
  const eip712ExtensionOptions = {
172
172
  typeUrl: "/ethermint.types.v1.ExtensionOptionsWeb3Tx",
173
173
  value: web3_1.ExtensionOptionsWeb3Tx.encode(web3_1.ExtensionOptionsWeb3Tx.fromPartial({
174
- typedDataChainId: ethermint_1.parseChainId(evmChainId),
174
+ typedDataChainId: (0, ethermint_1.parseChainId)(evmChainId),
175
175
  feePayer,
176
- feePayerSig: encoding_1.fromBase64(signature.signature),
176
+ feePayerSig: (0, encoding_1.fromBase64)(signature.signature),
177
177
  })).finish(),
178
178
  };
179
179
  const signedGasLimit = math_1.Int53.fromString(signed.fee.gas).toNumber();
180
180
  const signedSequence = math_1.Int53.fromString(signed.sequence).toNumber();
181
- const signedAuthInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, undefined, undefined, signMode);
181
+ const signedAuthInfoBytes = (0, proto_signing_1.makeAuthInfoBytes)([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, undefined, undefined, signMode);
182
182
  const signedTxBody = {
183
183
  messages: signed.msgs.map((msg) => this.aminoTypes.fromAmino(msg)),
184
184
  memo: signed.memo,
@@ -168,7 +168,7 @@ class CarbonWallet {
168
168
  const fee = (_a = opts === null || opts === void 0 ? void 0 : opts.fee) !== null && _a !== void 0 ? _a : this.estimateTxFee(messages, feeDenom);
169
169
  const txRaw = yield signingClient.sign(signerAddress, messages, fee, memo, signerData);
170
170
  let sig;
171
- if (CarbonSigner_1.isCarbonEIP712Signer(this.signer)) {
171
+ if ((0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer)) {
172
172
  if (this.signer.legacyEip712SignMode) {
173
173
  const feePayerSigBz = web3_1.ExtensionOptionsWeb3Tx.decode(tx_2.TxBody.decode(txRaw.bodyBytes).extensionOptions[0].value).feePayerSig;
174
174
  sig = Uint8Array.from(Buffer.from(feePayerSigBz.slice(0, -1)));
@@ -176,11 +176,11 @@ class CarbonWallet {
176
176
  else {
177
177
  sig = txRaw.signatures[0];
178
178
  }
179
- signature = amino_1.encodeSecp256k1Signature(account.pubkey, sig);
179
+ signature = (0, amino_1.encodeSecp256k1Signature)(account.pubkey, sig);
180
180
  signature = Object.assign(Object.assign({}, signature), { pub_key: Object.assign(Object.assign({}, signature.pub_key), { type: ethermint_1.ETH_SECP256K1_TYPE }) });
181
181
  return txRaw;
182
182
  }
183
- signature = amino_1.encodeSecp256k1Signature(account.pubkey, txRaw.signatures[0]);
183
+ signature = (0, amino_1.encodeSecp256k1Signature)(account.pubkey, txRaw.signatures[0]);
184
184
  return txRaw;
185
185
  }
186
186
  finally {
@@ -219,7 +219,7 @@ class CarbonWallet {
219
219
  const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
220
220
  const carbonClient = this.getSigningClient();
221
221
  const response = yield carbonClient.broadcastTx(tx, timeoutMs, pollIntervalMs);
222
- if (stargate_1.isDeliverTxFailure(response)) {
222
+ if ((0, stargate_1.isDeliverTxFailure)(response)) {
223
223
  // tx failed
224
224
  throw new tx_1.CarbonTxError(`[${response.code}] ${response.rawLog}`, response);
225
225
  }
@@ -268,12 +268,12 @@ class CarbonWallet {
268
268
  || ((_a = this.accountInfo) === null || _a === void 0 ? void 0 : _a.address) === this.evmBech32Address // refresh to check if carbon acc is present
269
269
  || this.sequenceInvalidated)
270
270
  yield this.reloadAccountSequence();
271
- const heightResponse = yield fetch_1.fetch(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
271
+ const heightResponse = yield (0, fetch_1.fetch)(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
272
272
  const heightRes = yield heightResponse.json();
273
- const height = number_1.bnOrZero((_b = heightRes.result) === null || _b === void 0 ? void 0 : _b.last_height);
273
+ const height = (0, number_1.bnOrZero)((_b = heightRes.result) === null || _b === void 0 ? void 0 : _b.last_height);
274
274
  let timeoutHeight;
275
275
  // timeoutHeight is not supported for EIP-712
276
- if (!CarbonSigner_1.isCarbonEIP712Signer(this.signer)) {
276
+ if (!(0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer)) {
277
277
  timeoutHeight = height.isZero() ? undefined : height.toNumber() + this.defaultTimeoutBlocks;
278
278
  }
279
279
  let sequence;
@@ -468,12 +468,12 @@ class CarbonWallet {
468
468
  const queryClient = this.getQueryClient();
469
469
  const { msgGasCosts } = yield queryClient.fee.MsgGasCostAll({});
470
470
  this.txGasCosts = msgGasCosts.reduce((result, item) => {
471
- result[item.msgType] = number_1.bnOrZero(item.gasCost);
471
+ result[item.msgType] = (0, number_1.bnOrZero)(item.gasCost);
472
472
  return result;
473
473
  }, {});
474
474
  const { minGasPrices } = yield queryClient.fee.MinGasPriceAll({});
475
475
  this.txGasPrices = minGasPrices.reduce((result, item) => {
476
- result[item.denom] = number_1.bnOrZero(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
476
+ result[item.denom] = (0, number_1.bnOrZero)(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
477
477
  return result;
478
478
  }, {});
479
479
  if (!this.txGasPrices[this.defaultFeeDenom]) {
@@ -171,7 +171,7 @@ class WSConnector {
171
171
  params = [params]; // eslint-disable-line no-param-reassign
172
172
  }
173
173
  for (const param of params) {
174
- const channelId = channel_1.generateChannelId(param);
174
+ const channelId = (0, channel_1.generateChannelId)(param);
175
175
  const shouldSubscribe = this.channelHandlers[channelId] === undefined;
176
176
  this.channelHandlers[channelId] = handler;
177
177
  if (shouldSubscribe) {
@@ -193,7 +193,7 @@ class WSConnector {
193
193
  }
194
194
  const channelIds = [];
195
195
  for (const param of params) {
196
- const channelId = channel_1.generateChannelId(param);
196
+ const channelId = (0, channel_1.generateChannelId)(param);
197
197
  const shouldUnsubscribe = this.channelHandlers[channelId] !== undefined;
198
198
  delete this.channelHandlers[channelId];
199
199
  if (shouldUnsubscribe) {
@@ -281,7 +281,7 @@ class WSConnector {
281
281
  if (!channelHandler) {
282
282
  this.debugLog(`handler not found for channel: ${message.channel}`);
283
283
  try {
284
- const params = channel_1.parseChannelId(message.channel);
284
+ const params = (0, channel_1.parseChannelId)(message.channel);
285
285
  this.unsubscribe({ channel: params.channel });
286
286
  }
287
287
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,76 +0,0 @@
1
- import Long from "long";
2
- import _m0 from "protobufjs/minimal";
3
- import { Params } from "../controller/v1/controller";
4
- import { Params as Params1 } from "../host/v1/host";
5
- export declare const protobufPackage = "ibc.applications.interchain_accounts.v1";
6
- /** GenesisState defines the interchain accounts genesis state */
7
- export interface GenesisState {
8
- controllerGenesisState?: ControllerGenesisState;
9
- hostGenesisState?: HostGenesisState;
10
- }
11
- /** ControllerGenesisState defines the interchain accounts controller genesis state */
12
- export interface ControllerGenesisState {
13
- activeChannels: ActiveChannel[];
14
- interchainAccounts: RegisteredInterchainAccount[];
15
- ports: string[];
16
- params?: Params;
17
- }
18
- /** HostGenesisState defines the interchain accounts host genesis state */
19
- export interface HostGenesisState {
20
- activeChannels: ActiveChannel[];
21
- interchainAccounts: RegisteredInterchainAccount[];
22
- port: string;
23
- params?: Params1;
24
- }
25
- /** ActiveChannel contains a connection ID, port ID and associated active channel ID */
26
- export interface ActiveChannel {
27
- connectionId: string;
28
- portId: string;
29
- channelId: string;
30
- }
31
- /** RegisteredInterchainAccount contains a connection ID, port ID and associated interchain account address */
32
- export interface RegisteredInterchainAccount {
33
- connectionId: string;
34
- portId: string;
35
- accountAddress: string;
36
- }
37
- export declare const GenesisState: {
38
- encode(message: GenesisState, writer?: _m0.Writer): _m0.Writer;
39
- decode(input: _m0.Reader | Uint8Array, length?: number | undefined): GenesisState;
40
- fromJSON(object: any): GenesisState;
41
- toJSON(message: GenesisState): unknown;
42
- fromPartial(object: DeepPartial<GenesisState>): GenesisState;
43
- };
44
- export declare const ControllerGenesisState: {
45
- encode(message: ControllerGenesisState, writer?: _m0.Writer): _m0.Writer;
46
- decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ControllerGenesisState;
47
- fromJSON(object: any): ControllerGenesisState;
48
- toJSON(message: ControllerGenesisState): unknown;
49
- fromPartial(object: DeepPartial<ControllerGenesisState>): ControllerGenesisState;
50
- };
51
- export declare const HostGenesisState: {
52
- encode(message: HostGenesisState, writer?: _m0.Writer): _m0.Writer;
53
- decode(input: _m0.Reader | Uint8Array, length?: number | undefined): HostGenesisState;
54
- fromJSON(object: any): HostGenesisState;
55
- toJSON(message: HostGenesisState): unknown;
56
- fromPartial(object: DeepPartial<HostGenesisState>): HostGenesisState;
57
- };
58
- export declare const ActiveChannel: {
59
- encode(message: ActiveChannel, writer?: _m0.Writer): _m0.Writer;
60
- decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ActiveChannel;
61
- fromJSON(object: any): ActiveChannel;
62
- toJSON(message: ActiveChannel): unknown;
63
- fromPartial(object: DeepPartial<ActiveChannel>): ActiveChannel;
64
- };
65
- export declare const RegisteredInterchainAccount: {
66
- encode(message: RegisteredInterchainAccount, writer?: _m0.Writer): _m0.Writer;
67
- decode(input: _m0.Reader | Uint8Array, length?: number | undefined): RegisteredInterchainAccount;
68
- fromJSON(object: any): RegisteredInterchainAccount;
69
- toJSON(message: RegisteredInterchainAccount): unknown;
70
- fromPartial(object: DeepPartial<RegisteredInterchainAccount>): RegisteredInterchainAccount;
71
- };
72
- declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
73
- export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
74
- [K in keyof T]?: DeepPartial<T[K]>;
75
- } : Partial<T>;
76
- export {};