carbon-js-sdk 0.4.21 → 0.4.23

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 (133) hide show
  1. package/lib/clients/CarbonQueryClient.js +2 -2
  2. package/lib/clients/ETHClient.js +15 -15
  3. package/lib/clients/EvmIbcClient.d.ts +86 -0
  4. package/lib/clients/EvmIbcClient.js +90 -0
  5. package/lib/clients/HydrogenClient.js +1 -1
  6. package/lib/clients/NEOClient.js +7 -7
  7. package/lib/clients/TokenClient.js +4 -4
  8. package/lib/clients/ZILClient.js +17 -17
  9. package/lib/codec/alliance/alliance.d.ts +65 -0
  10. package/lib/codec/alliance/alliance.js +354 -0
  11. package/lib/codec/alliance/delegations.d.ts +86 -0
  12. package/lib/codec/alliance/delegations.js +489 -0
  13. package/lib/codec/alliance/events.d.ts +61 -0
  14. package/lib/codec/alliance/events.js +403 -0
  15. package/lib/codec/alliance/genesis.d.ts +74 -0
  16. package/lib/codec/alliance/genesis.js +469 -0
  17. package/lib/codec/alliance/gov.d.ts +78 -0
  18. package/lib/codec/alliance/gov.js +380 -0
  19. package/lib/codec/{perpsliquidity → alliance}/params.d.ts +18 -8
  20. package/lib/codec/alliance/params.js +182 -0
  21. package/lib/codec/alliance/query.d.ts +312 -0
  22. package/lib/codec/alliance/query.js +1497 -0
  23. package/lib/codec/alliance/tx.d.ts +111 -0
  24. package/lib/codec/alliance/tx.js +495 -0
  25. package/lib/codec/broker/incoming_pool_swap.d.ts +23 -0
  26. package/lib/codec/broker/incoming_pool_swap.js +136 -0
  27. package/lib/codec/cosmos/gov/v1/query.js +2 -2
  28. package/lib/codec/cosmos/gov/v1/tx.js +2 -2
  29. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  30. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  31. package/lib/codec/cosmos/group/v1/events.js +2 -2
  32. package/lib/codec/cosmos/group/v1/tx.js +4 -4
  33. package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
  34. package/lib/codec/google/protobuf/any.d.ts +4 -1
  35. package/lib/codec/google/protobuf/timestamp.d.ts +0 -2
  36. package/lib/codec/index.d.ts +58 -35
  37. package/lib/codec/index.js +788 -697
  38. package/lib/constant/generic.js +1 -1
  39. package/lib/modules/cdp.js +43 -43
  40. package/lib/modules/cosmwasm.js +1 -1
  41. package/lib/modules/gov.js +12 -12
  42. package/lib/modules/liquiditypool.js +1 -1
  43. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  44. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  45. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  46. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  47. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  48. package/lib/provider/amino/types/admin.js +27 -27
  49. package/lib/provider/amino/types/bank.js +1 -1
  50. package/lib/provider/amino/types/broker.js +1 -1
  51. package/lib/provider/amino/types/cdp.js +25 -25
  52. package/lib/provider/amino/types/coin.js +4 -4
  53. package/lib/provider/amino/types/gov.js +4 -4
  54. package/lib/provider/amino/types/ibc.js +1 -1
  55. package/lib/provider/amino/types/leverage.js +1 -1
  56. package/lib/provider/amino/types/liquidityPool.js +7 -7
  57. package/lib/provider/amino/types/market.js +2 -2
  58. package/lib/provider/amino/types/oracle.js +1 -1
  59. package/lib/provider/amino/types/order.js +4 -4
  60. package/lib/provider/amino/types/position.js +1 -1
  61. package/lib/provider/amino/types/profile.js +1 -1
  62. package/lib/provider/amino/types/staking.js +4 -4
  63. package/lib/provider/amino/types/subaccount.js +3 -3
  64. package/lib/provider/amino/utils.js +11 -11
  65. package/lib/provider/ledger/ledger.js +2 -2
  66. package/lib/provider/metamask/MetaMask.js +1 -1
  67. package/lib/provider/o3/O3Wallet.js +2 -2
  68. package/lib/util/address.js +13 -13
  69. package/lib/util/api.js +4 -4
  70. package/lib/util/ethermint/evm-ibc.d.ts +97 -0
  71. package/lib/util/ethermint/evm-ibc.js +134 -0
  72. package/lib/util/ethermint/index.d.ts +3 -0
  73. package/lib/util/ethermint/index.js +12 -0
  74. package/lib/util/ethermint/keys.d.ts +39 -0
  75. package/lib/util/ethermint/keys.js +138 -0
  76. package/lib/util/ethermint/web3.d.ts +36 -0
  77. package/lib/util/ethermint/web3.js +124 -0
  78. package/lib/util/fetch.js +1 -1
  79. package/lib/util/generic.js +3 -3
  80. package/lib/util/number.js +5 -5
  81. package/lib/util/tx.d.ts +51 -34
  82. package/lib/wallet/CarbonSigner.js +2 -2
  83. package/lib/wallet/CarbonSigningClient.js +8 -8
  84. package/lib/wallet/CarbonWallet.js +6 -6
  85. package/lib/websocket/connector.js +3 -3
  86. package/package.json +1 -1
  87. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.d.ts +0 -1
  88. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +0 -6
  89. package/lib/codec/ethermint/evm/v1/export.d.ts +0 -5
  90. package/lib/codec/ethermint/evm/v1/export.js +0 -53
  91. package/lib/codec/ethermint/feemarket/v1/export.d.ts +0 -4
  92. package/lib/codec/ethermint/feemarket/v1/export.js +0 -18
  93. package/lib/codec/ethermint/types/v1/export.d.ts +0 -4
  94. package/lib/codec/ethermint/types/v1/export.js +0 -11
  95. package/lib/codec/ethermint-models.d.ts +0 -4
  96. package/lib/codec/ethermint-models.js +0 -26
  97. package/lib/codec/market/fee.d.ts +0 -123
  98. package/lib/codec/market/fee.js +0 -334
  99. package/lib/codec/perpsliquidity/event.d.ts +0 -102
  100. package/lib/codec/perpsliquidity/event.js +0 -581
  101. package/lib/codec/perpsliquidity/genesis.d.ts +0 -35
  102. package/lib/codec/perpsliquidity/genesis.js +0 -162
  103. package/lib/codec/perpsliquidity/params.js +0 -103
  104. package/lib/codec/perpsliquidity/pool.d.ts +0 -137
  105. package/lib/codec/perpsliquidity/pool.js +0 -747
  106. package/lib/codec/perpsliquidity/query.d.ts +0 -167
  107. package/lib/codec/perpsliquidity/query.js +0 -719
  108. package/lib/codec/perpsliquidity/tx.d.ts +0 -199
  109. package/lib/codec/perpsliquidity/tx.js +0 -940
  110. package/lib/constant/eip712.d.ts +0 -46
  111. package/lib/constant/eip712.js +0 -106
  112. package/lib/modules/evm.d.ts +0 -46
  113. package/lib/modules/evm.js +0 -127
  114. package/lib/modules/evmmerge.d.ts +0 -12
  115. package/lib/modules/evmmerge.js +0 -35
  116. package/lib/modules/feemarket.d.ts +0 -20
  117. package/lib/modules/feemarket.js +0 -45
  118. package/lib/modules/vault.d.ts +0 -44
  119. package/lib/modules/vault.js +0 -95
  120. package/lib/provider/amino/types/evm.d.ts +0 -4
  121. package/lib/provider/amino/types/evm.js +0 -40
  122. package/lib/provider/amino/types/evmmerge.d.ts +0 -4
  123. package/lib/provider/amino/types/evmmerge.js +0 -34
  124. package/lib/provider/amino/types/feemarket.d.ts +0 -4
  125. package/lib/provider/amino/types/feemarket.js +0 -34
  126. package/lib/provider/metamask/legacy-accounts.d.ts +0 -6
  127. package/lib/provider/metamask/legacy-accounts.js +0 -44
  128. package/lib/util/eip712.d.ts +0 -10
  129. package/lib/util/eip712.js +0 -195
  130. package/lib/util/ethermint.d.ts +0 -8
  131. package/lib/util/ethermint.js +0 -68
  132. package/lib/util/legacyEIP712.d.ts +0 -20
  133. package/lib/util/legacyEIP712.js +0 -98
@@ -44,9 +44,9 @@ const MsgWithdrawFromGroup = {
44
44
  valueMap: {},
45
45
  };
46
46
  const CoinAmino = {
47
- [CarbonTx.Types.MsgWithdraw]: utils_1.generateAminoType(MsgWithdraw),
48
- [CarbonTx.Types.MsgMintToken]: utils_1.generateAminoType(MsgMintToken),
49
- [CarbonTx.Types.MsgDepositToGroup]: utils_1.generateAminoType(MsgDepositToGroup),
50
- [CarbonTx.Types.MsgWithdrawFromGroup]: utils_1.generateAminoType(MsgWithdrawFromGroup),
47
+ [CarbonTx.Types.MsgWithdraw]: (0, utils_1.generateAminoType)(MsgWithdraw),
48
+ [CarbonTx.Types.MsgMintToken]: (0, utils_1.generateAminoType)(MsgMintToken),
49
+ [CarbonTx.Types.MsgDepositToGroup]: (0, utils_1.generateAminoType)(MsgDepositToGroup),
50
+ [CarbonTx.Types.MsgWithdrawFromGroup]: (0, utils_1.generateAminoType)(MsgWithdrawFromGroup),
51
51
  };
52
52
  exports.default = CoinAmino;
@@ -217,7 +217,7 @@ const SettlementPrice = {
217
217
  },
218
218
  };
219
219
  const preProcessAmino = (value, valueMap) => {
220
- return utils_1.mapEachIndiv(value, valueMap, false);
220
+ return (0, utils_1.mapEachIndiv)(value, valueMap, false);
221
221
  };
222
222
  const checkDecodeProposal = (content, amino) => {
223
223
  const decodedValue = util_1.GovUtils.decodeContent(content);
@@ -437,8 +437,8 @@ const proposalAminoProcess = {
437
437
  },
438
438
  };
439
439
  const GovAmino = {
440
- [CarbonTx.Types.MsgSubmitProposal]: utils_1.generateAminoType(SubmitProposalMsg, proposalAminoProcess),
441
- [CarbonTx.Types.MsgDeposit]: utils_1.generateAminoType(MsgDeposit),
442
- [CarbonTx.Types.MsgVote]: utils_1.generateAminoType(MsgVote),
440
+ [CarbonTx.Types.MsgSubmitProposal]: (0, utils_1.generateAminoType)(SubmitProposalMsg, proposalAminoProcess),
441
+ [CarbonTx.Types.MsgDeposit]: (0, utils_1.generateAminoType)(MsgDeposit),
442
+ [CarbonTx.Types.MsgVote]: (0, utils_1.generateAminoType)(MsgVote),
443
443
  };
444
444
  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;
@@ -93,12 +93,12 @@ const commitTokensProcess = {
93
93
  },
94
94
  };
95
95
  const LiquidityPoolAmino = {
96
- [CarbonTx.Types.MsgCreatePool]: utils_1.generateAminoType(MsgCreatePool),
97
- [CarbonTx.Types.MsgCreatePoolWithLiquidity]: utils_1.generateAminoType(MsgCreatePoolWithLiquidity),
98
- [CarbonTx.Types.MsgAddLiquidity]: utils_1.generateAminoType(MsgAddLiquidity),
99
- [CarbonTx.Types.MsgRemoveLiquidity]: utils_1.generateAminoType(MsgRemoveLiquidity),
100
- [CarbonTx.Types.MsgStakePoolToken]: utils_1.generateAminoType(MsgStakePoolToken, commitTokensProcess),
101
- [CarbonTx.Types.MsgUnstakePoolToken]: utils_1.generateAminoType(MsgUnstakePoolToken),
102
- [CarbonTx.Types.MsgClaimPoolRewards]: utils_1.generateAminoType(MsgClaimPoolRewards),
96
+ [CarbonTx.Types.MsgCreatePool]: (0, utils_1.generateAminoType)(MsgCreatePool),
97
+ [CarbonTx.Types.MsgCreatePoolWithLiquidity]: (0, utils_1.generateAminoType)(MsgCreatePoolWithLiquidity),
98
+ [CarbonTx.Types.MsgAddLiquidity]: (0, utils_1.generateAminoType)(MsgAddLiquidity),
99
+ [CarbonTx.Types.MsgRemoveLiquidity]: (0, utils_1.generateAminoType)(MsgRemoveLiquidity),
100
+ [CarbonTx.Types.MsgStakePoolToken]: (0, utils_1.generateAminoType)(MsgStakePoolToken, commitTokensProcess),
101
+ [CarbonTx.Types.MsgUnstakePoolToken]: (0, utils_1.generateAminoType)(MsgUnstakePoolToken),
102
+ [CarbonTx.Types.MsgClaimPoolRewards]: (0, utils_1.generateAminoType)(MsgClaimPoolRewards),
103
103
  };
104
104
  exports.default = LiquidityPoolAmino;
@@ -46,7 +46,7 @@ const MsgDisableSpotMarket = {
46
46
  valueMap: {},
47
47
  };
48
48
  const MarketAmino = {
49
- [CarbonTx.Types.MsgUpdateMarket]: utils_1.generateAminoType(MsgUpdateMarket),
50
- [CarbonTx.Types.MsgDisableSpotMarket]: utils_1.generateAminoType(MsgDisableSpotMarket),
49
+ [CarbonTx.Types.MsgUpdateMarket]: (0, utils_1.generateAminoType)(MsgUpdateMarket),
50
+ [CarbonTx.Types.MsgDisableSpotMarket]: (0, utils_1.generateAminoType)(MsgDisableSpotMarket),
51
51
  };
52
52
  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;
@@ -76,9 +76,9 @@ const createOrderProcess = {
76
76
  },
77
77
  };
78
78
  const OrderAmino = {
79
- [CarbonTx.Types.MsgCreateOrder]: utils_1.generateAminoType(MsgCreateOrder, createOrderProcess),
80
- [CarbonTx.Types.MsgCancelOrder]: utils_1.generateAminoType(MsgCancelOrder),
81
- [CarbonTx.Types.MsgEditOrder]: utils_1.generateAminoType(MsgEditOrder),
82
- [CarbonTx.Types.MsgCancelAll]: utils_1.generateAminoType(MsgCancelAll),
79
+ [CarbonTx.Types.MsgCreateOrder]: (0, utils_1.generateAminoType)(MsgCreateOrder, createOrderProcess),
80
+ [CarbonTx.Types.MsgCancelOrder]: (0, utils_1.generateAminoType)(MsgCancelOrder),
81
+ [CarbonTx.Types.MsgEditOrder]: (0, utils_1.generateAminoType)(MsgEditOrder),
82
+ [CarbonTx.Types.MsgCancelAll]: (0, utils_1.generateAminoType)(MsgCancelAll),
83
83
  };
84
84
  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;
@@ -44,23 +44,23 @@ const mapEachIndiv = (mapItem, valueKey, toAmino = false) => {
44
44
  if (typeof keyMap !== "object") {
45
45
  // Check if this is a Long/BigNumber/Buffer/Date/Duration obj or a non-object/array
46
46
  if (typeCheck(mapItem[key]) || typeof mapItem[key] !== "object") {
47
- directMap[altKey] = exports.paramConverter(mapItem[key], keyMap, toAmino);
47
+ directMap[altKey] = (0, exports.paramConverter)(mapItem[key], keyMap, toAmino);
48
48
  return;
49
49
  }
50
50
  }
51
51
  if (mapItem[key].length && typeof mapItem[key] === "object") {
52
52
  // If value is an array of objects, iterate through objects and call mapToObj function
53
53
  directMap[altKey] = mapItem[key].map((newMap) => {
54
- return exports.mapEachIndiv(newMap, valueKey, toAmino);
54
+ return (0, exports.mapEachIndiv)(newMap, valueKey, toAmino);
55
55
  });
56
56
  return;
57
57
  }
58
58
  else {
59
59
  if (util_1.TypeUtils.isDurationType(mapItem[key])) {
60
- directMap[altKey] = exports.paramConverter(mapItem[key], keyMap, toAmino);
60
+ directMap[altKey] = (0, exports.paramConverter)(mapItem[key], keyMap, toAmino);
61
61
  return;
62
62
  }
63
- directMap[altKey] = exports.mapEachIndiv(mapItem[key], keyMap, toAmino);
63
+ directMap[altKey] = (0, exports.mapEachIndiv)(mapItem[key], keyMap, toAmino);
64
64
  }
65
65
  });
66
66
  return directMap;
@@ -137,18 +137,18 @@ const generateAminoType = (amino, aminoProcess = {}) => {
137
137
  if (!newInput[key])
138
138
  return;
139
139
  if (typeCheck(newInput[key])) {
140
- aminoObj[snakeKey] = exports.paramConverter(newInput[key], newAminoMap[key], true);
140
+ aminoObj[snakeKey] = (0, exports.paramConverter)(newInput[key], newAminoMap[key], true);
141
141
  return;
142
142
  }
143
143
  if (typeof newInput[key] !== "object" && typeof newAminoMap[key] !== "object") {
144
- aminoObj[snakeKey] = exports.paramConverter(newInput[key], newAminoMap[key], true);
144
+ aminoObj[snakeKey] = (0, exports.paramConverter)(newInput[key], newAminoMap[key], true);
145
145
  }
146
146
  else {
147
147
  if (((_a = newInput[key]) === null || _a === void 0 ? void 0 : _a.length) && typeof newInput[key] === "object") {
148
- aminoObj[snakeKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[key], true));
148
+ aminoObj[snakeKey] = newInput[key].map((newItem) => (0, exports.mapEachIndiv)(newItem, newAminoMap[key], true));
149
149
  return;
150
150
  }
151
- aminoObj[snakeKey] = exports.mapEachIndiv(newInput[key], newAminoMap[key], true);
151
+ aminoObj[snakeKey] = (0, exports.mapEachIndiv)(newInput[key], newAminoMap[key], true);
152
152
  }
153
153
  });
154
154
  return aminoObj;
@@ -162,14 +162,14 @@ const generateAminoType = (amino, aminoProcess = {}) => {
162
162
  var _a;
163
163
  const camelKey = util_1.TypeUtils.snakeToCamel(key);
164
164
  if (typeof newInput[key] !== "object" && typeof newAminoMap[key] !== "object") {
165
- aminoObj[camelKey] = exports.paramConverter(newInput[key], newAminoMap[camelKey], false);
165
+ aminoObj[camelKey] = (0, exports.paramConverter)(newInput[key], newAminoMap[camelKey], false);
166
166
  }
167
167
  else {
168
168
  if (((_a = newInput[key]) === null || _a === void 0 ? void 0 : _a.length) && typeof newInput[key] === "object") {
169
- aminoObj[camelKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[camelKey], false));
169
+ aminoObj[camelKey] = newInput[key].map((newItem) => (0, exports.mapEachIndiv)(newItem, newAminoMap[camelKey], false));
170
170
  return;
171
171
  }
172
- aminoObj[camelKey] = exports.mapEachIndiv(newInput[key], newAminoMap[camelKey], false);
172
+ aminoObj[camelKey] = (0, exports.mapEachIndiv)(newInput[key], newAminoMap[camelKey], false);
173
173
  }
174
174
  });
175
175
  return aminoObj;
@@ -153,7 +153,7 @@ class CosmosLedger {
153
153
  const response = yield this.cosmosApp.getVersion();
154
154
  this.checkLedgerErrors(response);
155
155
  const { major, minor, patch, test_mode } = response;
156
- exports.checkAppMode(this.testModeAllowed, test_mode);
156
+ (0, exports.checkAppMode)(this.testModeAllowed, test_mode);
157
157
  const version = versionString({ major, minor, patch });
158
158
  return version;
159
159
  });
@@ -244,7 +244,7 @@ class CosmosLedger {
244
244
  const response = yield this.cosmosApp.sign(this.hdPath, signMessage);
245
245
  this.checkLedgerErrors(response);
246
246
  // we have to parse the signature from Ledger as it's in DER format
247
- const parsedSignature = secp256k1_1.signatureImport(response.signature);
247
+ const parsedSignature = (0, secp256k1_1.signatureImport)(response.signature);
248
248
  return parsedSignature;
249
249
  });
250
250
  }
@@ -284,7 +284,7 @@ class MetaMask {
284
284
  return __awaiter(this, void 0, void 0, function* () {
285
285
  const chainIdHex = (yield ((_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.request({ method: "eth_chainId" })));
286
286
  const chainId = !!chainIdHex ? parseInt(chainIdHex, 16) : undefined;
287
- const blockchain = blockchain_1.getBlockchainFromChainV2(chainId);
287
+ const blockchain = (0, blockchain_1.getBlockchainFromChainV2)(chainId);
288
288
  this.blockchain = blockchain;
289
289
  return { chainId, blockchain };
290
290
  });
@@ -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,
@@ -94,13 +94,13 @@ const randomMnemonic = () => {
94
94
  };
95
95
  exports.randomMnemonic = randomMnemonic;
96
96
  const wifEncodePrivateKey = (privateKey, iter = 128) => {
97
- const privateKeyBuf = exports.stringOrBufferToBuffer(privateKey);
97
+ const privateKeyBuf = (0, exports.stringOrBufferToBuffer)(privateKey);
98
98
  return wif.encode(iter, privateKeyBuf, true);
99
99
  };
100
100
  exports.wifEncodePrivateKey = wifEncodePrivateKey;
101
101
  exports.SWTHAddress = {
102
102
  newMnemonic: () => {
103
- return exports.randomMnemonic();
103
+ return (0, exports.randomMnemonic)();
104
104
  },
105
105
  coinType: () => {
106
106
  return SWTH_COIN_TYPE;
@@ -110,10 +110,10 @@ exports.SWTHAddress = {
110
110
  return new BIP44Path(BIP44_PURPOSE, coinType).update(index, change, account).toArray();
111
111
  },
112
112
  publicKeyToScriptHash: (publicKey) => {
113
- const pubKeyBuffer = exports.stringOrBufferToBuffer(publicKey);
113
+ const pubKeyBuffer = (0, exports.stringOrBufferToBuffer)(publicKey);
114
114
  const sha256Hash = ethers_1.ethers.utils.sha256(pubKeyBuffer);
115
115
  const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
116
- return generic_1.stripHexPrefix(ripemdHash);
116
+ return (0, generic_1.stripHexPrefix)(ripemdHash);
117
117
  },
118
118
  publicKeyToAddress: (publicKey, opts) => {
119
119
  const scriptHash = exports.SWTHAddress.publicKeyToScriptHash(publicKey);
@@ -135,7 +135,7 @@ exports.SWTHAddress = {
135
135
  return privateKey;
136
136
  },
137
137
  privateToPublicKey: (privateKey) => {
138
- const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
138
+ const privateKeyBuff = (0, exports.stringOrBufferToBuffer)(privateKey);
139
139
  const publicKeyUint8Array = secp256k1.publicKeyCreate(privateKeyBuff, true);
140
140
  const publicKey = Buffer.from(publicKeyUint8Array);
141
141
  return publicKey;
@@ -146,7 +146,7 @@ exports.SWTHAddress = {
146
146
  return address;
147
147
  },
148
148
  encode: (hash, opts) => {
149
- const hashBuff = exports.stringOrBufferToBuffer(hash, "hex");
149
+ const hashBuff = (0, exports.stringOrBufferToBuffer)(hash, "hex");
150
150
  const words = bech32.toWords(hashBuff.slice(0, 20));
151
151
  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);
152
152
  const address = bech32.encode(addressPrefix, words);
@@ -205,7 +205,7 @@ exports.NEOAddress = {
205
205
  ]);
206
206
  const sha256Hash = ethers_1.ethers.utils.sha256(addressScript);
207
207
  const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
208
- return generic_1.stripHexPrefix(ripemdHash);
208
+ return (0, generic_1.stripHexPrefix)(ripemdHash);
209
209
  },
210
210
  publicKeyToAddress: (publicKey) => {
211
211
  const addressScript = exports.NEOAddress.publicKeyToScriptHash(publicKey);
@@ -213,7 +213,7 @@ exports.NEOAddress = {
213
213
  return address;
214
214
  },
215
215
  encodePublicKey: (unencodedPublicKey) => {
216
- const unencPubKeyBuf = exports.stringOrBufferToBuffer(unencodedPublicKey);
216
+ const unencPubKeyBuf = (0, exports.stringOrBufferToBuffer)(unencodedPublicKey);
217
217
  if (unencPubKeyBuf.length <= 33) {
218
218
  // length indicates already encoded
219
219
  return unencPubKeyBuf;
@@ -238,7 +238,7 @@ exports.NEOAddress = {
238
238
  return privateKey;
239
239
  },
240
240
  privateToPublicKey: (privateKey) => {
241
- const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
241
+ const privateKeyBuff = (0, exports.stringOrBufferToBuffer)(privateKey);
242
242
  const publicKeyUint8Array = secp256r1.publicKeyCreate(privateKeyBuff, true);
243
243
  return Buffer.from(publicKeyUint8Array);
244
244
  },
@@ -256,7 +256,7 @@ exports.NEOAddress = {
256
256
  },
257
257
  };
258
258
  exports.N3Address = Object.assign(Object.assign({}, exports.NEOAddress), { publicKeyToScriptHash: (publicKey) => {
259
- const publicKeyHex = exports.stringOrBufferToBuffer(publicKey).toString("hex");
259
+ const publicKeyHex = (0, exports.stringOrBufferToBuffer)(publicKey).toString("hex");
260
260
  return neon_core_next_1.wallet.getScriptHashFromPublicKey(publicKeyHex);
261
261
  }, publicKeyToAddress: (publicKey) => {
262
262
  const addressScript = exports.N3Address.publicKeyToScriptHash(publicKey);
@@ -282,11 +282,11 @@ exports.ETHAddress = {
282
282
  return ethers_1.ethers.utils.keccak256(encodedPublicKey);
283
283
  },
284
284
  publicKeyToAddress: (publicKey) => {
285
- const publicKeyBuff = exports.stringOrBufferToBuffer(publicKey);
285
+ const publicKeyBuff = (0, exports.stringOrBufferToBuffer)(publicKey);
286
286
  return ethers_1.ethers.utils.computeAddress(publicKeyBuff);
287
287
  },
288
288
  encodePublicKey: (unencodedPublicKey) => {
289
- const unencodedPublicKeyBuff = exports.stringOrBufferToBuffer(unencodedPublicKey);
289
+ const unencodedPublicKeyBuff = (0, exports.stringOrBufferToBuffer)(unencodedPublicKey);
290
290
  const publicKey = ethers_1.ethers.utils.computePublicKey(unencodedPublicKeyBuff, true);
291
291
  return Buffer.from(publicKey, "hex");
292
292
  },
@@ -298,7 +298,7 @@ exports.ETHAddress = {
298
298
  return Buffer.from((_a = wallet.privateKey) === null || _a === void 0 ? void 0 : _a.replace(/^0x/, ""), "hex");
299
299
  },
300
300
  privateToPublicKey: (privateKey) => {
301
- const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
301
+ const privateKeyBuff = (0, exports.stringOrBufferToBuffer)(privateKey);
302
302
  return Buffer.from(ethers_1.ethers.utils.computePublicKey(privateKeyBuff).replace(/^0x/, ""), "hex");
303
303
  },
304
304
  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;
@@ -0,0 +1,97 @@
1
+ import { TxRaw } from "../../codec/cosmos/tx/v1beta1/tx";
2
+ import { Network } from "../../constant";
3
+ import { StdFee, StdSignDoc } from "@cosmjs/amino";
4
+ import { EncodeObject, Registry } from "@cosmjs/proto-signing";
5
+ import { Blockchain } from "../blockchain";
6
+ declare type SupportedBlockchains = Blockchain.Canto | Blockchain.Evmos;
7
+ declare namespace EvmIbcHelper {
8
+ interface TypedDomain {
9
+ name: string;
10
+ version: string;
11
+ chainId: number;
12
+ verifyingContract: string;
13
+ salt: string;
14
+ }
15
+ interface TypedDataV4 {
16
+ types: object;
17
+ primaryType: string;
18
+ message: StdSignDoc;
19
+ domain: TypedDomain;
20
+ }
21
+ interface SignFee extends StdFee {
22
+ feePayer: string;
23
+ }
24
+ interface SignDoc extends StdSignDoc {
25
+ fee: SignFee;
26
+ }
27
+ const TYPED_DATA_REQUEST_METHOD = "eth_signTypedData_v4";
28
+ const DEFAULT_EIP712_TYPES: {
29
+ EIP712Domain: {
30
+ name: string;
31
+ type: string;
32
+ }[];
33
+ Tx: {
34
+ name: string;
35
+ type: string;
36
+ }[];
37
+ Fee: {
38
+ name: string;
39
+ type: string;
40
+ }[];
41
+ Coin: {
42
+ name: string;
43
+ type: string;
44
+ }[];
45
+ Msg: {
46
+ name: string;
47
+ type: string;
48
+ }[];
49
+ };
50
+ const getEvmChainId: (blockchain: SupportedBlockchains, network?: Network) => 7700 | 9001;
51
+ const getIbcTransferTypes: () => {
52
+ MsgValue: {
53
+ name: string;
54
+ type: string;
55
+ }[];
56
+ TypeToken: {
57
+ name: string;
58
+ type: string;
59
+ }[];
60
+ TypeTimeoutHeight: {
61
+ name: string;
62
+ type: string;
63
+ }[];
64
+ EIP712Domain: {
65
+ name: string;
66
+ type: string;
67
+ }[];
68
+ Tx: {
69
+ name: string;
70
+ type: string;
71
+ }[];
72
+ Fee: {
73
+ name: string;
74
+ type: string;
75
+ }[];
76
+ Coin: {
77
+ name: string;
78
+ type: string;
79
+ }[];
80
+ Msg: {
81
+ name: string;
82
+ type: string;
83
+ }[];
84
+ };
85
+ const getCosmosWeb3Domain: (blockchain: SupportedBlockchains) => {
86
+ name: string;
87
+ version: string;
88
+ chainId: number;
89
+ verifyingContract: string;
90
+ salt: string;
91
+ };
92
+ const getSignatureExtension: (blockchain: SupportedBlockchains, address: string, signature: Uint8Array) => EncodeObject;
93
+ const getEIP712TypedData: (blockchain: SupportedBlockchains, tx: EvmIbcHelper.SignDoc, types?: object, domain?: EvmIbcHelper.TypedDomain, primaryType?: string) => TypedDataV4;
94
+ const makeSignedTx: (blockchain: SupportedBlockchains, msgs: EncodeObject[], tx: EvmIbcHelper.SignDoc, address: string, publicKey: Uint8Array, signature: Uint8Array, registry: Registry) => TxRaw;
95
+ const registerEthermintCodec: (registry: Registry) => void;
96
+ }
97
+ export default EvmIbcHelper;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tx_1 = require("../../codec/cosmos/tx/v1beta1/tx");
4
+ const constant_1 = require("../../constant");
5
+ const proto_signing_1 = require("@cosmjs/proto-signing");
6
+ const signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
7
+ const blockchain_1 = require("../blockchain");
8
+ const keys_1 = require("./keys");
9
+ const web3_1 = require("./web3");
10
+ const _DEFAULT_EIP712_TYPES = {
11
+ EIP712Domain: [
12
+ { name: 'name', type: 'string' },
13
+ { name: 'version', type: 'string' },
14
+ { name: 'chainId', type: 'uint256' },
15
+ { name: 'verifyingContract', type: 'string' },
16
+ { name: 'salt', type: 'string' },
17
+ ],
18
+ Tx: [
19
+ { name: 'account_number', type: 'string' },
20
+ { name: 'chain_id', type: 'string' },
21
+ { name: 'fee', type: 'Fee' },
22
+ { name: 'memo', type: 'string' },
23
+ { name: 'msgs', type: 'Msg[]' },
24
+ { name: 'sequence', type: 'string' },
25
+ ],
26
+ Fee: [
27
+ { name: 'feePayer', type: 'string' },
28
+ { name: 'amount', type: 'Coin[]' },
29
+ { name: 'gas', type: 'string' },
30
+ ],
31
+ Coin: [
32
+ { name: 'denom', type: 'string' },
33
+ { name: 'amount', type: 'string' },
34
+ ],
35
+ Msg: [
36
+ { name: 'type', type: 'string' },
37
+ { name: 'value', type: 'MsgValue' },
38
+ ],
39
+ };
40
+ var EvmIbcHelper;
41
+ (function (EvmIbcHelper) {
42
+ ;
43
+ EvmIbcHelper.TYPED_DATA_REQUEST_METHOD = "eth_signTypedData_v4";
44
+ EvmIbcHelper.DEFAULT_EIP712_TYPES = _DEFAULT_EIP712_TYPES;
45
+ EvmIbcHelper.getEvmChainId = (blockchain, network = constant_1.Network.MainNet) => {
46
+ switch (network) {
47
+ case constant_1.Network.MainNet:
48
+ switch (blockchain) {
49
+ case blockchain_1.Blockchain.Canto:
50
+ return 7700;
51
+ case blockchain_1.Blockchain.Evmos:
52
+ return 9001;
53
+ default:
54
+ throw new Error("network not supported");
55
+ }
56
+ default:
57
+ throw new Error("network not supported");
58
+ }
59
+ };
60
+ EvmIbcHelper.getIbcTransferTypes = () => {
61
+ return Object.assign(Object.assign({}, EvmIbcHelper.DEFAULT_EIP712_TYPES), { MsgValue: [
62
+ { name: 'source_port', type: 'string' },
63
+ { name: 'source_channel', type: 'string' },
64
+ { name: 'token', type: 'TypeToken' },
65
+ { name: 'sender', type: 'string' },
66
+ { name: 'receiver', type: 'string' },
67
+ { name: 'timeout_height', type: 'TypeTimeoutHeight' },
68
+ { name: 'timeout_timestamp', type: 'uint64' },
69
+ ], TypeToken: [
70
+ { name: 'denom', type: 'string' },
71
+ { name: 'amount', type: 'string' },
72
+ ], TypeTimeoutHeight: [
73
+ { name: 'revision_number', type: 'uint64' },
74
+ { name: 'revision_height', type: 'uint64' },
75
+ ] });
76
+ };
77
+ EvmIbcHelper.getCosmosWeb3Domain = (blockchain) => {
78
+ return {
79
+ name: "Cosmos Web3",
80
+ version: "1.0.0",
81
+ chainId: EvmIbcHelper.getEvmChainId(blockchain),
82
+ verifyingContract: "cosmos",
83
+ salt: "0",
84
+ };
85
+ };
86
+ EvmIbcHelper.getSignatureExtension = (blockchain, address, signature) => {
87
+ return {
88
+ typeUrl: "/ethermint.types.v1.ExtensionOptionsWeb3Tx",
89
+ value: web3_1.ExtensionOptionsWeb3Tx.encode(web3_1.ExtensionOptionsWeb3Tx.fromPartial({
90
+ typedDataChainId: EvmIbcHelper.getEvmChainId(blockchain),
91
+ feePayer: address,
92
+ feePayerSig: signature,
93
+ })).finish(),
94
+ };
95
+ };
96
+ EvmIbcHelper.getEIP712TypedData = (blockchain, tx, types = EvmIbcHelper.getIbcTransferTypes(), domain = EvmIbcHelper.getCosmosWeb3Domain(blockchain), primaryType = "Tx") => {
97
+ const typedData = {
98
+ types,
99
+ primaryType,
100
+ domain,
101
+ message: tx,
102
+ };
103
+ return typedData;
104
+ };
105
+ EvmIbcHelper.makeSignedTx = (blockchain, msgs, tx, address, publicKey, signature, registry) => {
106
+ EvmIbcHelper.registerEthermintCodec(registry);
107
+ const pubkey = registry.encodeAsAny({
108
+ typeUrl: '/ethermint.crypto.v1.ethsecp256k1.PubKey',
109
+ value: keys_1.PubKey.fromPartial({
110
+ key: publicKey,
111
+ }),
112
+ });
113
+ const signatureExtension = EvmIbcHelper.getSignatureExtension(blockchain, address, signature);
114
+ const txBodyBytes = registry.encodeTxBody({
115
+ extensionOptions: [signatureExtension],
116
+ messages: msgs,
117
+ memo: tx.memo,
118
+ });
119
+ const txRaw = tx_1.TxRaw.fromPartial({
120
+ authInfoBytes: proto_signing_1.makeAuthInfoBytes([{
121
+ pubkey,
122
+ sequence: parseInt(tx.sequence),
123
+ }], tx.fee.amount, parseInt(tx.fee.gas), signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON),
124
+ bodyBytes: txBodyBytes,
125
+ signatures: [new Uint8Array()],
126
+ });
127
+ return txRaw;
128
+ };
129
+ EvmIbcHelper.registerEthermintCodec = (registry) => {
130
+ registry.register('/ethermint.types.v1.ExtensionOptionsWeb3Tx', web3_1.ExtensionOptionsWeb3Tx);
131
+ registry.register('/ethermint.crypto.v1.ethsecp256k1.PubKey', keys_1.PubKey);
132
+ };
133
+ })(EvmIbcHelper || (EvmIbcHelper = {}));
134
+ exports.default = EvmIbcHelper;
@@ -0,0 +1,3 @@
1
+ export { PubKey } from "./keys";
2
+ export { ExtensionOptionsWeb3Tx } from "./web3";
3
+ export { default as EvmIbcHelper } from "./evm-ibc";