carbon-js-sdk 0.3.28 → 0.3.29

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 (54) hide show
  1. package/lib/CarbonSDK.d.ts +3 -3
  2. package/lib/CarbonSDK.js +2 -0
  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/index.d.ts +1 -1
  13. package/lib/modules/cdp.js +43 -43
  14. package/lib/modules/gov.js +14 -14
  15. package/lib/modules/liquiditypool.js +1 -1
  16. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  17. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  18. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  19. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  20. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  21. package/lib/provider/amino/types/admin.js +30 -30
  22. package/lib/provider/amino/types/bank.js +1 -1
  23. package/lib/provider/amino/types/broker.js +1 -1
  24. package/lib/provider/amino/types/cdp.js +22 -22
  25. package/lib/provider/amino/types/coin.js +2 -2
  26. package/lib/provider/amino/types/gov.js +4 -4
  27. package/lib/provider/amino/types/ibc.js +1 -1
  28. package/lib/provider/amino/types/leverage.js +1 -1
  29. package/lib/provider/amino/types/liquidityPool.js +7 -7
  30. package/lib/provider/amino/types/market.js +1 -1
  31. package/lib/provider/amino/types/oracle.js +1 -1
  32. package/lib/provider/amino/types/order.js +4 -4
  33. package/lib/provider/amino/types/position.js +1 -1
  34. package/lib/provider/amino/types/profile.js +1 -1
  35. package/lib/provider/amino/types/staking.js +4 -4
  36. package/lib/provider/amino/types/subaccount.js +3 -3
  37. package/lib/provider/amino/utils.js +11 -11
  38. package/lib/provider/index.d.ts +1 -1
  39. package/lib/provider/leap/LeapAccount.d.ts +23 -0
  40. package/lib/provider/leap/LeapAccount.js +62 -0
  41. package/lib/provider/leap/index.d.ts +1 -1
  42. package/lib/provider/ledger/ledger.js +2 -2
  43. package/lib/provider/metamask/MetaMask.js +1 -1
  44. package/lib/provider/o3/O3Wallet.js +2 -2
  45. package/lib/util/address.js +13 -13
  46. package/lib/util/api.js +4 -4
  47. package/lib/util/fetch.js +1 -1
  48. package/lib/util/generic.js +3 -3
  49. package/lib/util/number.js +5 -5
  50. package/lib/wallet/CarbonSigner.js +2 -2
  51. package/lib/wallet/CarbonSigningClient.js +8 -8
  52. package/lib/wallet/CarbonWallet.js +6 -6
  53. package/lib/websocket/connector.js +3 -3
  54. package/package.json +1 -1
@@ -34,7 +34,7 @@ const MsgMintToken = {
34
34
  valueMap: {},
35
35
  };
36
36
  const CoinAmino = {
37
- [CarbonTx.Types.MsgWithdraw]: (0, utils_1.generateAminoType)(MsgWithdraw),
38
- [CarbonTx.Types.MsgMintToken]: (0, utils_1.generateAminoType)(MsgMintToken),
37
+ [CarbonTx.Types.MsgWithdraw]: utils_1.generateAminoType(MsgWithdraw),
38
+ [CarbonTx.Types.MsgMintToken]: 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 (0, utils_1.mapEachIndiv)(value, valueMap, false);
175
+ return 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]: (0, utils_1.generateAminoType)(SubmitProposalMsg, proposalAminoProcess),
407
- [CarbonTx.Types.MsgDeposit]: (0, utils_1.generateAminoType)(MsgDeposit),
408
- [CarbonTx.Types.MsgVote]: (0, utils_1.generateAminoType)(MsgVote),
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),
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]: (0, utils_1.generateAminoType)(MsgTransfer, pruneTransferProcess),
58
+ [CarbonTx.Types.MsgTransfer]: 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]: (0, utils_1.generateAminoType)(MsgSetLeverage),
34
+ [CarbonTx.Types.MsgSetLeverage]: 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]: (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),
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),
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]: (0, utils_1.generateAminoType)(MsgUpdateMarket),
44
+ [CarbonTx.Types.MsgUpdateMarket]: 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]: (0, utils_1.generateAminoType)(MsgCreateVote),
34
+ [CarbonTx.Types.MsgCreateVote]: 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]: (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),
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),
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]: (0, utils_1.generateAminoType)(MsgSetMargin),
32
+ [CarbonTx.Types.MsgSetMargin]: 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]: (0, utils_1.generateAminoType)(MsgUpdateProfile, updateProfileProcess),
48
+ [CarbonTx.Types.MsgUpdateProfile]: 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]: (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),
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),
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]: (0, utils_1.generateAminoType)(MsgCreateSubAccount),
43
- [CarbonTx.Types.MsgActivateSubAccount]: (0, utils_1.generateAminoType)(MsgActivateSubAccount),
44
- [CarbonTx.Types.MsgRemoveSubAccount]: (0, utils_1.generateAminoType)(MsgRemoveSubAccount),
42
+ [CarbonTx.Types.MsgCreateSubAccount]: utils_1.generateAminoType(MsgCreateSubAccount),
43
+ [CarbonTx.Types.MsgActivateSubAccount]: utils_1.generateAminoType(MsgActivateSubAccount),
44
+ [CarbonTx.Types.MsgRemoveSubAccount]: 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] = (0, exports.paramConverter)(mapItem[key], keyMap, toAmino);
51
+ directMap[altKey] = 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 (0, exports.mapEachIndiv)(newMap, valueKey, toAmino);
58
+ return 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] = (0, exports.paramConverter)(mapItem[key], keyMap, toAmino);
64
+ directMap[altKey] = exports.paramConverter(mapItem[key], keyMap, toAmino);
65
65
  return;
66
66
  }
67
- directMap[altKey] = (0, exports.mapEachIndiv)(mapItem[key], keyMap, toAmino);
67
+ directMap[altKey] = 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] = (0, exports.paramConverter)(newInput[key], newAminoMap[key], true);
150
+ aminoObj[snakeKey] = 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] = (0, exports.paramConverter)(newInput[key], newAminoMap[key], true);
154
+ aminoObj[snakeKey] = 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) => (0, exports.mapEachIndiv)(newItem, newAminoMap[key], true));
158
+ aminoObj[snakeKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[key], true));
159
159
  return;
160
160
  }
161
- aminoObj[snakeKey] = (0, exports.mapEachIndiv)(newInput[key], newAminoMap[key], true);
161
+ aminoObj[snakeKey] = 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] = (0, exports.paramConverter)(newInput[key], newAminoMap[camelKey], false);
175
+ aminoObj[camelKey] = 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) => (0, exports.mapEachIndiv)(newItem, newAminoMap[camelKey], false));
179
+ aminoObj[camelKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[camelKey], false));
180
180
  return;
181
181
  }
182
- aminoObj[camelKey] = (0, exports.mapEachIndiv)(newInput[key], newAminoMap[camelKey], false);
182
+ aminoObj[camelKey] = exports.mapEachIndiv(newInput[key], newAminoMap[camelKey], false);
183
183
  }
184
184
  });
185
185
  return aminoObj;
@@ -1,7 +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, Key } from "./leap";
4
+ export { default as LeapAccount, Leap, Key, LeapExtended } from "./leap";
5
5
  export { default as CosmosLedger } from "./ledger";
6
6
  export { CallContractArgs, EVMChain, MetaMask, MetaMaskChangeNetworkParam, MetaMaskSyncResult } from "./metamask";
7
7
  export { O3Types, O3Wallet } from "./o3";
@@ -1,10 +1,33 @@
1
1
  import { CarbonSigner } from "../../wallet";
2
2
  import { Leap } from "@cosmos-kit/leap";
3
+ import { AppCurrency, ChainInfo } from "@keplr-wallet/types";
3
4
  import SDKProvider from "../sdk";
4
5
  declare class LeapAccount {
6
+ static SWTH_CURRENCY: AppCurrency;
7
+ static BASE_CHAIN_INFO: {
8
+ readonly bip44: {
9
+ readonly coinType: number;
10
+ };
11
+ readonly currencies: readonly [];
12
+ readonly feeCurrencies: readonly [{
13
+ coinDenom: string;
14
+ coinMinimalDenom: string;
15
+ coinDecimals: number;
16
+ coinGeckoId: string;
17
+ }];
18
+ readonly gasPriceStep: {
19
+ readonly low: 1;
20
+ readonly average: 1.5;
21
+ readonly high: 2;
22
+ };
23
+ };
5
24
  static createLeapSigner(leap: Leap, chainId: string): CarbonSigner;
6
25
  static getChainId(configProvider: SDKProvider): Promise<string>;
26
+ static getChainInfo(configProvider: SDKProvider): Promise<ChainInfo>;
7
27
  }
8
28
  declare namespace LeapAccount {
9
29
  }
30
+ export interface LeapExtended extends Leap {
31
+ experimentalSuggestChain(chainInfo: ChainInfo): Promise<void>;
32
+ }
10
33
  export default LeapAccount;
@@ -9,7 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const constant_1 = require("../../constant");
13
+ const util_1 = require("../../util");
12
14
  const wallet_1 = require("../../wallet");
15
+ const SWTH = {
16
+ coinDenom: "SWTH",
17
+ coinMinimalDenom: "swth",
18
+ coinDecimals: 8,
19
+ coinGeckoId: "switcheo",
20
+ };
13
21
  class LeapAccount {
14
22
  static createLeapSigner(leap, chainId) {
15
23
  const signDirect = (signerAddress, doc) => __awaiter(this, void 0, void 0, function* () {
@@ -41,5 +49,59 @@ class LeapAccount {
41
49
  return chainId;
42
50
  });
43
51
  }
52
+ static getChainInfo(configProvider) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const config = configProvider.getConfig();
55
+ const bech32Prefix = config.Bech32Prefix;
56
+ const chainId = yield configProvider.query.chain.getChainId();
57
+ const gasPricesResult = yield configProvider.query.fee.MinGasPriceAll({});
58
+ const tokenClient = configProvider.getTokenClient();
59
+ const coingeckoIdMap = tokenClient.geckoTokenNames;
60
+ const feeCurrencies = gasPricesResult.minGasPrices.reduce((result, price) => {
61
+ var _a;
62
+ const token = tokenClient.tokenForDenom(price.denom);
63
+ if (!token || token.denom === 'swth')
64
+ return result;
65
+ result.push({
66
+ coinDenom: (_a = token.symbol) !== null && _a !== void 0 ? _a : token.denom,
67
+ coinMinimalDenom: token.denom,
68
+ coinDecimals: token.decimals.toNumber(),
69
+ coinGeckoId: coingeckoIdMap[token.denom],
70
+ });
71
+ return result;
72
+ }, []);
73
+ return {
74
+ feeCurrencies: [LeapAccount.SWTH_CURRENCY, ...feeCurrencies],
75
+ gasPriceStep: LeapAccount.BASE_CHAIN_INFO.gasPriceStep,
76
+ bip44: LeapAccount.BASE_CHAIN_INFO.bip44,
77
+ currencies: [LeapAccount.SWTH_CURRENCY, ...feeCurrencies],
78
+ stakeCurrency: LeapAccount.SWTH_CURRENCY,
79
+ rest: config.restUrl,
80
+ rpc: config.tmRpcUrl,
81
+ chainName: config.network === constant_1.Network.MainNet ? `Carbon` : `Carbon (${config.network})`,
82
+ chainId: chainId,
83
+ bech32Config: {
84
+ bech32PrefixAccAddr: `${bech32Prefix}`,
85
+ bech32PrefixAccPub: `${bech32Prefix}pub`,
86
+ bech32PrefixValAddr: `${bech32Prefix}valoper`,
87
+ bech32PrefixValPub: `${bech32Prefix}valoperpub`,
88
+ bech32PrefixConsAddr: `${bech32Prefix}valcons`,
89
+ bech32PrefixConsPub: `${bech32Prefix}valconspub`,
90
+ },
91
+ features: ["stargate", "ibc-transfer", "ibc-go"],
92
+ };
93
+ });
94
+ }
44
95
  }
96
+ LeapAccount.SWTH_CURRENCY = SWTH;
97
+ LeapAccount.BASE_CHAIN_INFO = {
98
+ bip44: { coinType: util_1.AddressUtils.SWTHAddress.coinType() },
99
+ currencies: [],
100
+ feeCurrencies: [SWTH],
101
+ gasPriceStep: {
102
+ low: 1,
103
+ average: 1.5,
104
+ high: 2,
105
+ },
106
+ };
45
107
  exports.default = LeapAccount;
@@ -1,3 +1,3 @@
1
- export { default } from "./LeapAccount";
1
+ export { default, LeapExtended } from "./LeapAccount";
2
2
  export { Key } from "@cosmos-kit/core";
3
3
  export { Leap } from "@cosmos-kit/leap";
@@ -147,7 +147,7 @@ class CosmosLedger {
147
147
  const response = yield this.cosmosApp.getVersion();
148
148
  this.checkLedgerErrors(response);
149
149
  const { major, minor, patch, test_mode } = response;
150
- (0, exports.checkAppMode)(this.testModeAllowed, test_mode);
150
+ exports.checkAppMode(this.testModeAllowed, test_mode);
151
151
  const version = versionString({ major, minor, patch });
152
152
  return version;
153
153
  });
@@ -238,7 +238,7 @@ class CosmosLedger {
238
238
  const response = yield this.cosmosApp.sign(this.hdPath, signMessage);
239
239
  this.checkLedgerErrors(response);
240
240
  // we have to parse the signature from Ledger as it's in DER format
241
- const parsedSignature = (0, secp256k1_1.signatureImport)(response.signature);
241
+ const parsedSignature = secp256k1_1.signatureImport(response.signature);
242
242
  return parsedSignature;
243
243
  });
244
244
  }
@@ -202,7 +202,7 @@ class MetaMask {
202
202
  return __awaiter(this, void 0, void 0, function* () {
203
203
  const chainIdHex = yield ((_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.request({ method: 'eth_chainId' }));
204
204
  const chainId = !!chainIdHex ? parseInt(chainIdHex, 16) : undefined;
205
- const blockchain = (0, blockchain_1.getBlockchainFromChain)(chainId);
205
+ const blockchain = blockchain_1.getBlockchainFromChain(chainId);
206
206
  this.blockchain = blockchain;
207
207
  return { chainId, blockchain };
208
208
  });
@@ -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((0, generic_1.sortObject)(doc));
63
+ const msg = JSON.stringify(generic_1.sortObject(doc));
64
64
  const signBytes = yield dapi.signMessage(msg);
65
- const signature = (0, amino_1.encodeSecp256k1Signature)(pubKey, signBytes);
65
+ const signature = 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 = (0, exports.stringOrBufferToBuffer)(privateKey);
103
+ const privateKeyBuf = 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 (0, exports.randomMnemonic)();
109
+ return 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 = (0, exports.stringOrBufferToBuffer)(publicKey);
119
+ const pubKeyBuffer = 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 (0, generic_1.stripHexPrefix)(ripemdHash);
122
+ return 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 = (0, exports.stringOrBufferToBuffer)(privateKey);
144
+ const privateKeyBuff = 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 = (0, exports.stringOrBufferToBuffer)(hash, 'hex');
155
+ const hashBuff = 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 (0, generic_1.stripHexPrefix)(ripemdHash);
214
+ return 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 = (0, exports.stringOrBufferToBuffer)(unencodedPublicKey);
222
+ const unencPubKeyBuf = 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 = (0, exports.stringOrBufferToBuffer)(privateKey);
247
+ const privateKeyBuff = 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 = (0, exports.stringOrBufferToBuffer)(publicKey).toString("hex");
265
+ const publicKeyHex = 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 = (0, exports.stringOrBufferToBuffer)(publicKey);
291
+ const publicKeyBuff = exports.stringOrBufferToBuffer(publicKey);
292
292
  return ethers_1.ethers.utils.computeAddress(publicKeyBuff);
293
293
  },
294
294
  encodePublicKey: (unencodedPublicKey) => {
295
- const unencodedPublicKeyBuff = (0, exports.stringOrBufferToBuffer)(unencodedPublicKey);
295
+ const unencodedPublicKeyBuff = 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 = (0, exports.stringOrBufferToBuffer)(privateKey);
307
+ const privateKeyBuff = 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 (0, fetch_1.fetch)(url, {
87
+ return 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 (0, fetch_1.fetch)(options.url, {
96
+ return 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 (0, fetch_1.fetch)(options.url, {
106
+ return 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 (0, fetch_1.fetch)(url, otherOpts);
117
+ return 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 (0, node_fetch_1.default)(url, init);
13
+ return 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] = (0, exports.overrideConfig)(result[key], member);
25
+ result[key] = 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] = (0, exports.sortObject)(input[key])));
44
+ .forEach((key) => (output[key] = 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 (0, exports.toTxHash)((0, crypto_1.sha256)(bytes));
59
+ return exports.toTxHash(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 (0, exports.parseBN)(input, defaultValue);
21
+ return 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 = (0, exports.bnOrZero)(value);
27
+ const valueBN = exports.bnOrZero(value);
28
28
  if (!decimals)
29
29
  return valueBN; // decimals = 0 or nullish
30
- const decimalsBN = (0, exports.bnOrZero)(decimals);
30
+ const decimalsBN = 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 = (0, exports.bnOrZero)(value);
37
+ const valueBN = exports.bnOrZero(value);
38
38
  if (!decimals)
39
39
  return valueBN; // decimals = 0 or nullish
40
- const decimalsBN = (0, exports.bnOrZero)(decimals);
40
+ const decimalsBN = exports.bnOrZero(decimals);
41
41
  return valueBN.shiftedBy(decimalsBN.toNumber());
42
42
  };
43
43
  exports.toUnitless = toUnitless;
@@ -106,9 +106,9 @@ class CarbonLedgerSigner {
106
106
  return __awaiter(this, void 0, void 0, function* () {
107
107
  const account = yield this.retrieveAccount();
108
108
  const { pubkey } = account;
109
- const msg = JSON.stringify((0, generic_1.sortObject)(doc));
109
+ const msg = JSON.stringify(generic_1.sortObject(doc));
110
110
  const signBytes = yield this.ledger.sign(msg);
111
- const signature = (0, amino_1.encodeSecp256k1Signature)(pubkey, signBytes);
111
+ const signature = amino_1.encodeSecp256k1Signature(pubkey, signBytes);
112
112
  return {
113
113
  signed: doc,
114
114
  signature,