carbon-js-sdk 0.3.20 → 0.3.21

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 (59) hide show
  1. package/lib/CarbonSDK.d.ts +5 -1
  2. package/lib/CarbonSDK.js +24 -4
  3. package/lib/clients/CarbonQueryClient.js +2 -2
  4. package/lib/clients/ETHClient.js +15 -15
  5. package/lib/clients/HydrogenClient.js +1 -1
  6. package/lib/clients/NEOClient.js +7 -7
  7. package/lib/clients/ZILClient.js +16 -16
  8. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  9. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  10. package/lib/codec/cosmos/tx/v1beta1/tx.js +2 -2
  11. package/lib/constant/generic.js +1 -1
  12. package/lib/constant/ibc.js +41 -41
  13. package/lib/constant/network.d.ts +6 -0
  14. package/lib/constant/network.js +7 -1
  15. package/lib/index.d.ts +1 -1
  16. package/lib/index.js +2 -1
  17. package/lib/modules/cdp.js +43 -43
  18. package/lib/modules/gov.js +14 -14
  19. package/lib/modules/liquiditypool.js +1 -1
  20. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  21. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  22. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  23. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  24. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  25. package/lib/provider/amino/types/admin.js +30 -30
  26. package/lib/provider/amino/types/bank.js +1 -1
  27. package/lib/provider/amino/types/broker.js +1 -1
  28. package/lib/provider/amino/types/cdp.js +22 -22
  29. package/lib/provider/amino/types/coin.js +2 -2
  30. package/lib/provider/amino/types/gov.js +4 -4
  31. package/lib/provider/amino/types/ibc.js +1 -1
  32. package/lib/provider/amino/types/leverage.js +1 -1
  33. package/lib/provider/amino/types/liquidityPool.js +7 -7
  34. package/lib/provider/amino/types/market.js +1 -1
  35. package/lib/provider/amino/types/oracle.js +1 -1
  36. package/lib/provider/amino/types/order.js +4 -4
  37. package/lib/provider/amino/types/position.js +1 -1
  38. package/lib/provider/amino/types/profile.js +1 -1
  39. package/lib/provider/amino/types/staking.js +4 -4
  40. package/lib/provider/amino/types/subaccount.js +3 -3
  41. package/lib/provider/amino/utils.js +11 -11
  42. package/lib/provider/index.d.ts +1 -0
  43. package/lib/provider/index.js +3 -1
  44. package/lib/provider/keplr/KeplrStore.d.ts +9 -3
  45. package/lib/provider/keplr/KeplrStore.js +69 -18
  46. package/lib/provider/ledger/ledger.js +2 -2
  47. package/lib/provider/metamask/MetaMask.js +1 -1
  48. package/lib/provider/o3/O3Wallet.js +2 -2
  49. package/lib/util/address.js +13 -13
  50. package/lib/util/api.js +4 -4
  51. package/lib/util/fetch.js +1 -1
  52. package/lib/util/generic.js +3 -3
  53. package/lib/util/number.js +5 -5
  54. package/lib/wallet/CarbonSigner.js +2 -2
  55. package/lib/wallet/CarbonSigningClient.js +8 -8
  56. package/lib/wallet/CarbonWallet.d.ts +3 -0
  57. package/lib/wallet/CarbonWallet.js +12 -6
  58. package/lib/websocket/connector.js +3 -3
  59. package/package.json +8 -4
@@ -34,7 +34,7 @@ const MsgMintToken = {
34
34
  valueMap: {},
35
35
  };
36
36
  const CoinAmino = {
37
- [CarbonTx.Types.MsgWithdraw]: utils_1.generateAminoType(MsgWithdraw),
38
- [CarbonTx.Types.MsgMintToken]: utils_1.generateAminoType(MsgMintToken),
37
+ [CarbonTx.Types.MsgWithdraw]: (0, utils_1.generateAminoType)(MsgWithdraw),
38
+ [CarbonTx.Types.MsgMintToken]: (0, utils_1.generateAminoType)(MsgMintToken),
39
39
  };
40
40
  exports.default = CoinAmino;
@@ -172,7 +172,7 @@ const SettlementPrice = {
172
172
  };
173
173
  ;
174
174
  const preProcessAmino = (value, valueMap) => {
175
- return utils_1.mapEachIndiv(value, valueMap, false);
175
+ return (0, utils_1.mapEachIndiv)(value, valueMap, false);
176
176
  };
177
177
  const checkDecodeProposal = (content, amino) => {
178
178
  const decodedValue = util_1.GovUtils.decodeContent(content);
@@ -403,8 +403,8 @@ const proposalAminoProcess = {
403
403
  },
404
404
  };
405
405
  const GovAmino = {
406
- [CarbonTx.Types.MsgSubmitProposal]: utils_1.generateAminoType(SubmitProposalMsg, proposalAminoProcess),
407
- [CarbonTx.Types.MsgDeposit]: utils_1.generateAminoType(MsgDeposit),
408
- [CarbonTx.Types.MsgVote]: utils_1.generateAminoType(MsgVote),
406
+ [CarbonTx.Types.MsgSubmitProposal]: (0, utils_1.generateAminoType)(SubmitProposalMsg, proposalAminoProcess),
407
+ [CarbonTx.Types.MsgDeposit]: (0, utils_1.generateAminoType)(MsgDeposit),
408
+ [CarbonTx.Types.MsgVote]: (0, utils_1.generateAminoType)(MsgVote),
409
409
  };
410
410
  exports.default = GovAmino;
@@ -55,6 +55,6 @@ const pruneTransferProcess = {
55
55
  },
56
56
  };
57
57
  const IbcAmino = {
58
- [CarbonTx.Types.MsgTransfer]: utils_1.generateAminoType(MsgTransfer, pruneTransferProcess),
58
+ [CarbonTx.Types.MsgTransfer]: (0, utils_1.generateAminoType)(MsgTransfer, pruneTransferProcess),
59
59
  };
60
60
  exports.default = IbcAmino;
@@ -31,6 +31,6 @@ const MsgSetLeverage = {
31
31
  },
32
32
  };
33
33
  const LeverageAmino = {
34
- [CarbonTx.Types.MsgSetLeverage]: utils_1.generateAminoType(MsgSetLeverage),
34
+ [CarbonTx.Types.MsgSetLeverage]: (0, utils_1.generateAminoType)(MsgSetLeverage),
35
35
  };
36
36
  exports.default = LeverageAmino;
@@ -95,12 +95,12 @@ const commitTokensProcess = {
95
95
  },
96
96
  };
97
97
  const LiquidityPoolAmino = {
98
- [CarbonTx.Types.MsgCreatePool]: utils_1.generateAminoType(MsgCreatePool),
99
- [CarbonTx.Types.MsgCreatePoolWithLiquidity]: utils_1.generateAminoType(MsgCreatePoolWithLiquidity),
100
- [CarbonTx.Types.MsgAddLiquidity]: utils_1.generateAminoType(MsgAddLiquidity),
101
- [CarbonTx.Types.MsgRemoveLiquidity]: utils_1.generateAminoType(MsgRemoveLiquidity),
102
- [CarbonTx.Types.MsgStakePoolToken]: utils_1.generateAminoType(MsgStakePoolToken, commitTokensProcess),
103
- [CarbonTx.Types.MsgUnstakePoolToken]: utils_1.generateAminoType(MsgUnstakePoolToken),
104
- [CarbonTx.Types.MsgClaimPoolRewards]: utils_1.generateAminoType(MsgClaimPoolRewards),
98
+ [CarbonTx.Types.MsgCreatePool]: (0, utils_1.generateAminoType)(MsgCreatePool),
99
+ [CarbonTx.Types.MsgCreatePoolWithLiquidity]: (0, utils_1.generateAminoType)(MsgCreatePoolWithLiquidity),
100
+ [CarbonTx.Types.MsgAddLiquidity]: (0, utils_1.generateAminoType)(MsgAddLiquidity),
101
+ [CarbonTx.Types.MsgRemoveLiquidity]: (0, utils_1.generateAminoType)(MsgRemoveLiquidity),
102
+ [CarbonTx.Types.MsgStakePoolToken]: (0, utils_1.generateAminoType)(MsgStakePoolToken, commitTokensProcess),
103
+ [CarbonTx.Types.MsgUnstakePoolToken]: (0, utils_1.generateAminoType)(MsgUnstakePoolToken),
104
+ [CarbonTx.Types.MsgClaimPoolRewards]: (0, utils_1.generateAminoType)(MsgClaimPoolRewards),
105
105
  };
106
106
  exports.default = LiquidityPoolAmino;
@@ -41,6 +41,6 @@ const MsgUpdateMarket = {
41
41
  },
42
42
  };
43
43
  const MarketAmino = {
44
- [CarbonTx.Types.MsgUpdateMarket]: utils_1.generateAminoType(MsgUpdateMarket),
44
+ [CarbonTx.Types.MsgUpdateMarket]: (0, utils_1.generateAminoType)(MsgUpdateMarket),
45
45
  };
46
46
  exports.default = MarketAmino;
@@ -31,6 +31,6 @@ const MsgCreateVote = {
31
31
  },
32
32
  };
33
33
  const OracleAmino = {
34
- [CarbonTx.Types.MsgCreateVote]: utils_1.generateAminoType(MsgCreateVote),
34
+ [CarbonTx.Types.MsgCreateVote]: (0, utils_1.generateAminoType)(MsgCreateVote),
35
35
  };
36
36
  exports.default = OracleAmino;
@@ -80,9 +80,9 @@ const createOrderProcess = {
80
80
  },
81
81
  };
82
82
  const OrderAmino = {
83
- [CarbonTx.Types.MsgCreateOrder]: utils_1.generateAminoType(MsgCreateOrder, createOrderProcess),
84
- [CarbonTx.Types.MsgCancelOrder]: utils_1.generateAminoType(MsgCancelOrder),
85
- [CarbonTx.Types.MsgEditOrder]: utils_1.generateAminoType(MsgEditOrder),
86
- [CarbonTx.Types.MsgCancelAll]: utils_1.generateAminoType(MsgCancelAll),
83
+ [CarbonTx.Types.MsgCreateOrder]: (0, utils_1.generateAminoType)(MsgCreateOrder, createOrderProcess),
84
+ [CarbonTx.Types.MsgCancelOrder]: (0, utils_1.generateAminoType)(MsgCancelOrder),
85
+ [CarbonTx.Types.MsgEditOrder]: (0, utils_1.generateAminoType)(MsgEditOrder),
86
+ [CarbonTx.Types.MsgCancelAll]: (0, utils_1.generateAminoType)(MsgCancelAll),
87
87
  };
88
88
  exports.default = OrderAmino;
@@ -29,6 +29,6 @@ const MsgSetMargin = {
29
29
  valueMap: {},
30
30
  };
31
31
  const PositionAmino = {
32
- [CarbonTx.Types.MsgSetMargin]: utils_1.generateAminoType(MsgSetMargin),
32
+ [CarbonTx.Types.MsgSetMargin]: (0, utils_1.generateAminoType)(MsgSetMargin),
33
33
  };
34
34
  exports.default = PositionAmino;
@@ -45,6 +45,6 @@ const updateProfileProcess = {
45
45
  },
46
46
  };
47
47
  const ProfileAmino = {
48
- [CarbonTx.Types.MsgUpdateProfile]: utils_1.generateAminoType(MsgUpdateProfile, updateProfileProcess),
48
+ [CarbonTx.Types.MsgUpdateProfile]: (0, utils_1.generateAminoType)(MsgUpdateProfile, updateProfileProcess),
49
49
  };
50
50
  exports.default = ProfileAmino;
@@ -44,9 +44,9 @@ const MsgWithdrawDelegatorReward = {
44
44
  valueMap: {},
45
45
  };
46
46
  const StakingAmino = {
47
- [CarbonTx.Types.MsgDelegate]: utils_1.generateAminoType(MsgDelegate),
48
- [CarbonTx.Types.MsgUndelegate]: utils_1.generateAminoType(MsgUndelegate),
49
- [CarbonTx.Types.MsgBeginRedelegate]: utils_1.generateAminoType(MsgBeginRedelegate),
50
- [CarbonTx.Types.MsgWithdrawDelegatorReward]: utils_1.generateAminoType(MsgWithdrawDelegatorReward),
47
+ [CarbonTx.Types.MsgDelegate]: (0, utils_1.generateAminoType)(MsgDelegate),
48
+ [CarbonTx.Types.MsgUndelegate]: (0, utils_1.generateAminoType)(MsgUndelegate),
49
+ [CarbonTx.Types.MsgBeginRedelegate]: (0, utils_1.generateAminoType)(MsgBeginRedelegate),
50
+ [CarbonTx.Types.MsgWithdrawDelegatorReward]: (0, utils_1.generateAminoType)(MsgWithdrawDelegatorReward),
51
51
  };
52
52
  exports.default = StakingAmino;
@@ -39,8 +39,8 @@ const MsgRemoveSubAccount = {
39
39
  valueMap: {},
40
40
  };
41
41
  const SubAccountAmino = {
42
- [CarbonTx.Types.MsgCreateSubAccount]: utils_1.generateAminoType(MsgCreateSubAccount),
43
- [CarbonTx.Types.MsgActivateSubAccount]: utils_1.generateAminoType(MsgActivateSubAccount),
44
- [CarbonTx.Types.MsgRemoveSubAccount]: utils_1.generateAminoType(MsgRemoveSubAccount),
42
+ [CarbonTx.Types.MsgCreateSubAccount]: (0, utils_1.generateAminoType)(MsgCreateSubAccount),
43
+ [CarbonTx.Types.MsgActivateSubAccount]: (0, utils_1.generateAminoType)(MsgActivateSubAccount),
44
+ [CarbonTx.Types.MsgRemoveSubAccount]: (0, utils_1.generateAminoType)(MsgRemoveSubAccount),
45
45
  };
46
46
  exports.default = SubAccountAmino;
@@ -48,23 +48,23 @@ const mapEachIndiv = (mapItem, valueKey, toAmino = false) => {
48
48
  if (typeof keyMap !== "object") {
49
49
  // Check if this is a Long/BigNumber/Buffer/Date/Duration obj or a non-object/array
50
50
  if (typeCheck(mapItem[key]) || typeof mapItem[key] !== "object") {
51
- directMap[altKey] = exports.paramConverter(mapItem[key], keyMap, toAmino);
51
+ directMap[altKey] = (0, exports.paramConverter)(mapItem[key], keyMap, toAmino);
52
52
  return;
53
53
  }
54
54
  }
55
55
  if (mapItem[key].length && typeof mapItem[key] === "object") {
56
56
  // If value is an array of objects, iterate through objects and call mapToObj function
57
57
  directMap[altKey] = mapItem[key].map((newMap) => {
58
- return exports.mapEachIndiv(newMap, valueKey, toAmino);
58
+ return (0, exports.mapEachIndiv)(newMap, valueKey, toAmino);
59
59
  });
60
60
  return;
61
61
  }
62
62
  else {
63
63
  if (util_1.TypeUtils.isDurationType(mapItem[key])) {
64
- directMap[altKey] = exports.paramConverter(mapItem[key], keyMap, toAmino);
64
+ directMap[altKey] = (0, exports.paramConverter)(mapItem[key], keyMap, toAmino);
65
65
  return;
66
66
  }
67
- directMap[altKey] = exports.mapEachIndiv(mapItem[key], keyMap, toAmino);
67
+ directMap[altKey] = (0, exports.mapEachIndiv)(mapItem[key], keyMap, toAmino);
68
68
  }
69
69
  });
70
70
  return directMap;
@@ -147,18 +147,18 @@ const generateAminoType = (amino, aminoProcess = {}) => {
147
147
  if (!newInput[key])
148
148
  return;
149
149
  if (typeCheck(newInput[key])) {
150
- aminoObj[snakeKey] = exports.paramConverter(newInput[key], newAminoMap[key], true);
150
+ aminoObj[snakeKey] = (0, exports.paramConverter)(newInput[key], newAminoMap[key], true);
151
151
  return;
152
152
  }
153
153
  if (typeof newInput[key] !== "object" && typeof newAminoMap[key] !== "object") {
154
- aminoObj[snakeKey] = exports.paramConverter(newInput[key], newAminoMap[key], true);
154
+ aminoObj[snakeKey] = (0, exports.paramConverter)(newInput[key], newAminoMap[key], true);
155
155
  }
156
156
  else {
157
157
  if (((_a = newInput[key]) === null || _a === void 0 ? void 0 : _a.length) && typeof newInput[key] === "object") {
158
- aminoObj[snakeKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[key], true));
158
+ aminoObj[snakeKey] = newInput[key].map((newItem) => (0, exports.mapEachIndiv)(newItem, newAminoMap[key], true));
159
159
  return;
160
160
  }
161
- aminoObj[snakeKey] = exports.mapEachIndiv(newInput[key], newAminoMap[key], true);
161
+ aminoObj[snakeKey] = (0, exports.mapEachIndiv)(newInput[key], newAminoMap[key], true);
162
162
  }
163
163
  });
164
164
  return aminoObj;
@@ -172,14 +172,14 @@ const generateAminoType = (amino, aminoProcess = {}) => {
172
172
  var _a;
173
173
  const camelKey = util_1.TypeUtils.snakeToCamel(key);
174
174
  if (typeof newInput[key] !== "object" && typeof newAminoMap[key] !== "object") {
175
- aminoObj[camelKey] = exports.paramConverter(newInput[key], newAminoMap[camelKey], false);
175
+ aminoObj[camelKey] = (0, exports.paramConverter)(newInput[key], newAminoMap[camelKey], false);
176
176
  }
177
177
  else {
178
178
  if (((_a = newInput[key]) === null || _a === void 0 ? void 0 : _a.length) && typeof newInput[key] === "object") {
179
- aminoObj[camelKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[camelKey], false));
179
+ aminoObj[camelKey] = newInput[key].map((newItem) => (0, exports.mapEachIndiv)(newItem, newAminoMap[camelKey], false));
180
180
  return;
181
181
  }
182
- aminoObj[camelKey] = exports.mapEachIndiv(newInput[key], newAminoMap[camelKey], false);
182
+ aminoObj[camelKey] = (0, exports.mapEachIndiv)(newInput[key], newAminoMap[camelKey], false);
183
183
  }
184
184
  });
185
185
  return aminoObj;
@@ -1,6 +1,7 @@
1
1
  export { EthLedgerAccount, EthLedgerSigner, NeoLedgerAccount } from "./account";
2
2
  export { AminoTypesMap } from "./amino";
3
3
  export { ChainInfo, CoinPretty, default as KeplrAccount, Keplr, KeplrWindow } from "./keplr";
4
+ export { default as LeapAccount, Leap } from "./leap";
4
5
  export { default as CosmosLedger } from "./ledger";
5
6
  export { CallContractArgs, EVMChain, MetaMask, MetaMaskChangeNetworkParam, MetaMaskSyncResult } from "./metamask";
6
7
  export { O3Types, O3Wallet } from "./o3";
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Zilpay = exports.O3Wallet = exports.O3Types = exports.MetaMask = exports.CosmosLedger = exports.KeplrAccount = exports.CoinPretty = exports.AminoTypesMap = exports.NeoLedgerAccount = exports.EthLedgerSigner = exports.EthLedgerAccount = void 0;
6
+ exports.Zilpay = exports.O3Wallet = exports.O3Types = exports.MetaMask = exports.CosmosLedger = exports.LeapAccount = exports.KeplrAccount = exports.CoinPretty = exports.AminoTypesMap = exports.NeoLedgerAccount = exports.EthLedgerSigner = exports.EthLedgerAccount = void 0;
7
7
  var account_1 = require("./account");
8
8
  Object.defineProperty(exports, "EthLedgerAccount", { enumerable: true, get: function () { return account_1.EthLedgerAccount; } });
9
9
  Object.defineProperty(exports, "EthLedgerSigner", { enumerable: true, get: function () { return account_1.EthLedgerSigner; } });
@@ -13,6 +13,8 @@ Object.defineProperty(exports, "AminoTypesMap", { enumerable: true, get: functio
13
13
  var keplr_1 = require("./keplr");
14
14
  Object.defineProperty(exports, "CoinPretty", { enumerable: true, get: function () { return keplr_1.CoinPretty; } });
15
15
  Object.defineProperty(exports, "KeplrAccount", { enumerable: true, get: function () { return __importDefault(keplr_1).default; } });
16
+ var leap_1 = require("./leap");
17
+ Object.defineProperty(exports, "LeapAccount", { enumerable: true, get: function () { return __importDefault(leap_1).default; } });
16
18
  var ledger_1 = require("./ledger");
17
19
  Object.defineProperty(exports, "CosmosLedger", { enumerable: true, get: function () { return __importDefault(ledger_1).default; } });
18
20
  var metamask_1 = require("./metamask");
@@ -1,9 +1,15 @@
1
- import { AccountStore, ChainStore, QueriesStore, AccountWithCosmos, QueriesWithCosmos } from "@keplr-wallet/stores";
1
+ import { AccountStore, ChainStore, CosmosAccount, CosmosQueries, CosmwasmAccount, CosmwasmQueries, QueriesStore } from "@keplr-wallet/stores";
2
2
  import { ChainInfo } from "@keplr-wallet/types";
3
3
  export declare class RootStore {
4
4
  readonly chainStore: ChainStore;
5
- readonly queriesStore: QueriesStore<QueriesWithCosmos>;
6
- readonly accountStore: AccountStore<AccountWithCosmos>;
5
+ readonly queriesStore: QueriesStore<[
6
+ CosmosQueries,
7
+ CosmwasmQueries
8
+ ]>;
9
+ readonly accountStore: AccountStore<[
10
+ CosmosAccount,
11
+ CosmwasmAccount
12
+ ]>;
7
13
  constructor(getKeplr: () => Promise<any>, additionalChains?: ChainInfo[]);
8
14
  }
9
15
  export declare function createRootStore(getKeplr: () => Promise<any>, additionalChains?: ChainInfo[]): RootStore | null;
@@ -1,11 +1,25 @@
1
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
3
15
  exports.createRootStore = exports.RootStore = void 0;
4
16
  const ibc_1 = require("../../constant/ibc");
5
- const stores_1 = require("@keplr-wallet/stores");
6
- const common_1 = require("@keplr-wallet/common");
7
- const external_1 = require("../../util/external");
17
+ // import { iOS } from "../../util/external";
8
18
  const ibc_2 = require("../../util/ibc");
19
+ const common_1 = require("@keplr-wallet/common");
20
+ const stores_1 = require("@keplr-wallet/stores");
21
+ const eventemitter3_1 = __importDefault(require("eventemitter3"));
22
+ const semver_1 = __importDefault(require("semver"));
9
23
  class RootStore {
10
24
  constructor(getKeplr, additionalChains) {
11
25
  const embedChainInfos = Object.values(ibc_2.EmbedChainInfos).map((chainInfo) => {
@@ -19,29 +33,66 @@ class RootStore {
19
33
  if (additionalChains && (additionalChains === null || additionalChains === void 0 ? void 0 : additionalChains.length) > 0) {
20
34
  embedChainInfos.push(...additionalChains);
21
35
  }
36
+ const eventListener = (() => {
37
+ // On client-side (web browser), use the global window object.
38
+ if (typeof window !== "undefined") {
39
+ return window;
40
+ }
41
+ // On server-side (nodejs), there is no global window object.
42
+ // Alternatively, use the event emitter library.
43
+ const emitter = new eventemitter3_1.default();
44
+ return {
45
+ addEventListener: (type, fn) => {
46
+ emitter.addListener(type, fn);
47
+ },
48
+ removeEventListener: (type, fn) => {
49
+ emitter.removeListener(type, fn);
50
+ },
51
+ };
52
+ })();
53
+ function suggestChainFromWindow(keplr, chainInfo) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const info = Object.assign(Object.assign({}, chainInfo), { stakeCurrency: Object.assign(Object.assign({}, chainInfo.stakeCurrency), { coinImageUrl: chainInfo.stakeCurrency.coinImageUrl
56
+ ? window.origin + chainInfo.stakeCurrency.coinImageUrl
57
+ : undefined }), currencies: chainInfo.currencies.map((currency) => (Object.assign(Object.assign({}, currency), { coinImageUrl: currency.coinImageUrl
58
+ ? window.origin + currency.coinImageUrl
59
+ : undefined }))), feeCurrencies: chainInfo.feeCurrencies.map((currency) => (Object.assign(Object.assign({}, currency), { coinImageUrl: currency.coinImageUrl
60
+ ? window.origin + currency.coinImageUrl
61
+ : undefined }))) });
62
+ yield keplr.experimentalSuggestChain(info);
63
+ });
64
+ }
22
65
  this.chainStore = new stores_1.ChainStore(embedChainInfos);
23
- this.queriesStore = new stores_1.QueriesStore(new common_1.IndexedDBKVStore("store_queries"), this.chainStore, getKeplr, stores_1.QueriesWithCosmos);
24
- this.accountStore = new stores_1.AccountStore(window, stores_1.AccountWithCosmos, this.chainStore, this.queriesStore, {
25
- defaultOpts: {
26
- prefetching: false,
66
+ this.queriesStore = new stores_1.QueriesStore(new common_1.IndexedDBKVStore("store_web_queries"), this.chainStore, stores_1.CosmosQueries.use(), stores_1.CosmwasmQueries.use());
67
+ this.accountStore = new stores_1.AccountStore(eventListener, this.chainStore, () => {
68
+ return {
27
69
  suggestChain: true,
70
+ suggestChainFn: (keplr, chainInfo) => __awaiter(this, void 0, void 0, function* () {
71
+ if (keplr.mode === "mobile-web" &&
72
+ // In keplr mobile below 0.10.9, there is no receiver for the suggest chain.
73
+ // Therefore, it cannot be processed because it takes infinite pending.
74
+ // As of 0.10.10, experimental support was added.
75
+ !semver_1.default.satisfies(keplr.version, ">=0.10.10")) {
76
+ // Can't suggest the chain on mobile web.
77
+ return;
78
+ }
79
+ yield suggestChainFromWindow(keplr, chainInfo.raw);
80
+ }),
28
81
  autoInit: true,
29
82
  getKeplr,
30
- msgOpts: {
31
- ibcTransfer: {
32
- type: 'cosmos-sdk/MsgTransfer',
33
- gas: ibc_1.ibcDefaultGas,
34
- },
35
- },
36
- },
37
- });
83
+ };
84
+ }, stores_1.CosmosAccount.use({
85
+ queriesStore: this.queriesStore,
86
+ msgOptsCreator: () => ({ ibcTransfer: { gas: ibc_1.ibcDefaultGas } }),
87
+ }), stores_1.CosmwasmAccount.use({ queriesStore: this.queriesStore }));
38
88
  }
39
89
  }
40
90
  exports.RootStore = RootStore;
41
91
  function createRootStore(getKeplr, additionalChains) {
42
- if (external_1.iOS()) {
43
- return null;
44
- }
92
+ // TODO: Un-comment if Safari iOS mobile crashes the page
93
+ // if (iOS()) {
94
+ // return null
95
+ // }
45
96
  return new RootStore(getKeplr, additionalChains);
46
97
  }
47
98
  exports.createRootStore = createRootStore;
@@ -149,7 +149,7 @@ class CosmosLedger {
149
149
  const response = yield this.cosmosApp.getVersion();
150
150
  this.checkLedgerErrors(response);
151
151
  const { major, minor, patch, test_mode } = response;
152
- exports.checkAppMode(this.testModeAllowed, test_mode);
152
+ (0, exports.checkAppMode)(this.testModeAllowed, test_mode);
153
153
  const version = versionString({ major, minor, patch });
154
154
  return version;
155
155
  });
@@ -218,7 +218,7 @@ class CosmosLedger {
218
218
  const response = yield this.cosmosApp.sign(this.hdPath, signMessage);
219
219
  this.checkLedgerErrors(response);
220
220
  // we have to parse the signature from Ledger as it's in DER format
221
- const parsedSignature = secp256k1_1.signatureImport(response.signature);
221
+ const parsedSignature = (0, secp256k1_1.signatureImport)(response.signature);
222
222
  return parsedSignature;
223
223
  });
224
224
  }
@@ -167,7 +167,7 @@ class MetaMask {
167
167
  return __awaiter(this, void 0, void 0, function* () {
168
168
  const chainIdHex = yield ((_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.request({ method: 'eth_chainId' }));
169
169
  const chainId = !!chainIdHex ? parseInt(chainIdHex, 16) : undefined;
170
- const blockchain = blockchain_1.getBlockchainFromChain(chainId);
170
+ const blockchain = (0, blockchain_1.getBlockchainFromChain)(chainId);
171
171
  this.blockchain = blockchain;
172
172
  return { chainId, blockchain };
173
173
  });
@@ -60,9 +60,9 @@ class O3Wallet {
60
60
  return {
61
61
  type: index_1.CarbonSignerTypes.BrowserInjected,
62
62
  signAmino: (_, doc) => __awaiter(this, void 0, void 0, function* () {
63
- const msg = JSON.stringify(generic_1.sortObject(doc));
63
+ const msg = JSON.stringify((0, generic_1.sortObject)(doc));
64
64
  const signBytes = yield dapi.signMessage(msg);
65
- const signature = amino_1.encodeSecp256k1Signature(pubKey, signBytes);
65
+ const signature = (0, amino_1.encodeSecp256k1Signature)(pubKey, signBytes);
66
66
  return {
67
67
  signed: doc,
68
68
  signature,
@@ -100,13 +100,13 @@ const randomMnemonic = () => {
100
100
  };
101
101
  exports.randomMnemonic = randomMnemonic;
102
102
  const wifEncodePrivateKey = (privateKey, iter = 128) => {
103
- const privateKeyBuf = exports.stringOrBufferToBuffer(privateKey);
103
+ const privateKeyBuf = (0, exports.stringOrBufferToBuffer)(privateKey);
104
104
  return wif.encode(iter, privateKeyBuf, true);
105
105
  };
106
106
  exports.wifEncodePrivateKey = wifEncodePrivateKey;
107
107
  exports.SWTHAddress = {
108
108
  newMnemonic: () => {
109
- return exports.randomMnemonic();
109
+ return (0, exports.randomMnemonic)();
110
110
  },
111
111
  coinType: () => {
112
112
  return SWTH_COIN_TYPE;
@@ -116,10 +116,10 @@ exports.SWTHAddress = {
116
116
  return new BIP44Path(BIP44_PURPOSE, coinType).update(index, change, account).toArray();
117
117
  },
118
118
  publicKeyToScriptHash: (publicKey) => {
119
- const pubKeyBuffer = exports.stringOrBufferToBuffer(publicKey);
119
+ const pubKeyBuffer = (0, exports.stringOrBufferToBuffer)(publicKey);
120
120
  const sha256Hash = ethers_1.ethers.utils.sha256(pubKeyBuffer);
121
121
  const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
122
- return generic_1.stripHexPrefix(ripemdHash);
122
+ return (0, generic_1.stripHexPrefix)(ripemdHash);
123
123
  },
124
124
  publicKeyToAddress: (publicKey, opts) => {
125
125
  const scriptHash = exports.SWTHAddress.publicKeyToScriptHash(publicKey);
@@ -141,7 +141,7 @@ exports.SWTHAddress = {
141
141
  return privateKey;
142
142
  },
143
143
  privateToPublicKey: (privateKey) => {
144
- const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
144
+ const privateKeyBuff = (0, exports.stringOrBufferToBuffer)(privateKey);
145
145
  const publicKeyUint8Array = secp256k1.publicKeyCreate(privateKeyBuff, true);
146
146
  const publicKey = Buffer.from(publicKeyUint8Array);
147
147
  return publicKey;
@@ -152,7 +152,7 @@ exports.SWTHAddress = {
152
152
  return address;
153
153
  },
154
154
  encode: (hash, opts) => {
155
- const hashBuff = exports.stringOrBufferToBuffer(hash, 'hex');
155
+ const hashBuff = (0, exports.stringOrBufferToBuffer)(hash, 'hex');
156
156
  const words = bech32.toWords(hashBuff.slice(0, 20));
157
157
  const addressPrefix = exports.SWTHAddress.getBech32Prefix(opts === null || opts === void 0 ? void 0 : opts.network, opts === null || opts === void 0 ? void 0 : opts.bech32Prefix, opts === null || opts === void 0 ? void 0 : opts.type);
158
158
  const address = bech32.encode(addressPrefix, words);
@@ -211,7 +211,7 @@ exports.NEOAddress = {
211
211
  ]);
212
212
  const sha256Hash = ethers_1.ethers.utils.sha256(addressScript);
213
213
  const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
214
- return generic_1.stripHexPrefix(ripemdHash);
214
+ return (0, generic_1.stripHexPrefix)(ripemdHash);
215
215
  },
216
216
  publicKeyToAddress: (publicKey) => {
217
217
  const addressScript = exports.NEOAddress.publicKeyToScriptHash(publicKey);
@@ -219,7 +219,7 @@ exports.NEOAddress = {
219
219
  return address;
220
220
  },
221
221
  encodePublicKey: (unencodedPublicKey) => {
222
- const unencPubKeyBuf = exports.stringOrBufferToBuffer(unencodedPublicKey);
222
+ const unencPubKeyBuf = (0, exports.stringOrBufferToBuffer)(unencodedPublicKey);
223
223
  if (unencPubKeyBuf.length <= 33) {
224
224
  // length indicates already encoded
225
225
  return unencPubKeyBuf;
@@ -244,7 +244,7 @@ exports.NEOAddress = {
244
244
  return privateKey;
245
245
  },
246
246
  privateToPublicKey: (privateKey) => {
247
- const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
247
+ const privateKeyBuff = (0, exports.stringOrBufferToBuffer)(privateKey);
248
248
  const publicKeyUint8Array = secp256r1.publicKeyCreate(privateKeyBuff, true);
249
249
  return Buffer.from(publicKeyUint8Array);
250
250
  },
@@ -262,7 +262,7 @@ exports.NEOAddress = {
262
262
  },
263
263
  };
264
264
  exports.N3Address = Object.assign(Object.assign({}, exports.NEOAddress), { publicKeyToScriptHash: (publicKey) => {
265
- const publicKeyHex = exports.stringOrBufferToBuffer(publicKey).toString("hex");
265
+ const publicKeyHex = (0, exports.stringOrBufferToBuffer)(publicKey).toString("hex");
266
266
  return neon_core_next_1.wallet.getScriptHashFromPublicKey(publicKeyHex);
267
267
  }, publicKeyToAddress: (publicKey) => {
268
268
  const addressScript = exports.N3Address.publicKeyToScriptHash(publicKey);
@@ -288,11 +288,11 @@ exports.ETHAddress = {
288
288
  return ethers_1.ethers.utils.keccak256(encodedPublicKey);
289
289
  },
290
290
  publicKeyToAddress: (publicKey) => {
291
- const publicKeyBuff = exports.stringOrBufferToBuffer(publicKey);
291
+ const publicKeyBuff = (0, exports.stringOrBufferToBuffer)(publicKey);
292
292
  return ethers_1.ethers.utils.computeAddress(publicKeyBuff);
293
293
  },
294
294
  encodePublicKey: (unencodedPublicKey) => {
295
- const unencodedPublicKeyBuff = exports.stringOrBufferToBuffer(unencodedPublicKey);
295
+ const unencodedPublicKeyBuff = (0, exports.stringOrBufferToBuffer)(unencodedPublicKey);
296
296
  const publicKey = ethers_1.ethers.utils.computePublicKey(unencodedPublicKeyBuff, true);
297
297
  return Buffer.from(publicKey, "hex");
298
298
  },
@@ -304,7 +304,7 @@ exports.ETHAddress = {
304
304
  return Buffer.from((_a = wallet.privateKey) === null || _a === void 0 ? void 0 : _a.replace(/^0x/, ""), "hex");
305
305
  },
306
306
  privateToPublicKey: (privateKey) => {
307
- const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
307
+ const privateKeyBuff = (0, exports.stringOrBufferToBuffer)(privateKey);
308
308
  return Buffer.from(ethers_1.ethers.utils.computePublicKey(privateKeyBuff).replace(/^0x/, ""), "hex");
309
309
  },
310
310
  privateKeyToAddress: (privateKey) => {
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;
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;
@@ -22,7 +22,7 @@ const overrideConfig = (defaults, override) => {
22
22
  continue;
23
23
  if (typeof member === "object") {
24
24
  // @ts-ignore
25
- result[key] = exports.overrideConfig(result[key], member);
25
+ result[key] = (0, exports.overrideConfig)(result[key], member);
26
26
  }
27
27
  else {
28
28
  // @ts-ignore
@@ -41,7 +41,7 @@ const sortObject = (input) => {
41
41
  Object.keys(input)
42
42
  .sort()
43
43
  // @ts-ignore noImplicitAny
44
- .forEach((key) => (output[key] = exports.sortObject(input[key])));
44
+ .forEach((key) => (output[key] = (0, exports.sortObject)(input[key])));
45
45
  return output;
46
46
  };
47
47
  exports.sortObject = sortObject;
@@ -56,7 +56,7 @@ exports.appendHexPrefix = appendHexPrefix;
56
56
  const computeTxHash = (bytes) => {
57
57
  if (!bytes)
58
58
  return bytes;
59
- return exports.toTxHash(crypto_1.sha256(bytes));
59
+ return (0, exports.toTxHash)((0, crypto_1.sha256)(bytes));
60
60
  };
61
61
  exports.computeTxHash = computeTxHash;
62
62
  const toTxHash = (bytes) => {
@@ -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;