carbon-js-sdk 0.3.47 → 0.3.49

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 (78) hide show
  1. package/lib/clients/EvmIbcClient.d.ts +86 -0
  2. package/lib/clients/EvmIbcClient.js +90 -0
  3. package/lib/clients/TokenClient.js +5 -4
  4. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/keys.d.ts +39 -0
  5. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/keys.js +138 -0
  6. package/lib/codec/ethermint/evm/v1/evm.d.ts +239 -0
  7. package/lib/codec/ethermint/evm/v1/evm.js +1140 -0
  8. package/lib/codec/ethermint/evm/v1/genesis.d.ts +43 -0
  9. package/lib/codec/ethermint/evm/v1/genesis.js +153 -0
  10. package/lib/codec/ethermint/evm/v1/query.d.ts +424 -0
  11. package/lib/codec/ethermint/evm/v1/query.js +1637 -0
  12. package/lib/codec/ethermint/evm/v1/tx.d.ts +183 -0
  13. package/lib/codec/ethermint/evm/v1/tx.js +836 -0
  14. package/lib/codec/ethermint/feemarket/v1/feemarket.d.ts +41 -0
  15. package/lib/codec/ethermint/feemarket/v1/feemarket.js +149 -0
  16. package/lib/codec/ethermint/feemarket/v1/genesis.d.ts +26 -0
  17. package/lib/codec/ethermint/feemarket/v1/genesis.js +79 -0
  18. package/lib/codec/ethermint/feemarket/v1/query.d.ts +100 -0
  19. package/lib/codec/ethermint/feemarket/v1/query.js +276 -0
  20. package/lib/codec/ethermint/types/v1/account.d.ts +26 -0
  21. package/lib/codec/ethermint/types/v1/account.js +78 -0
  22. package/lib/codec/ethermint/types/v1/dynamic_fee.d.ts +20 -0
  23. package/lib/codec/ethermint/types/v1/dynamic_fee.js +60 -0
  24. package/lib/codec/ethermint/types/v1/indexer.d.ts +41 -0
  25. package/lib/codec/ethermint/types/v1/indexer.js +153 -0
  26. package/lib/codec/ethermint/types/v1/web3.d.ts +36 -0
  27. package/lib/codec/ethermint/types/v1/web3.js +124 -0
  28. package/lib/codec/evmbank/genesis.d.ts +32 -0
  29. package/lib/codec/evmbank/genesis.js +152 -0
  30. package/lib/codec/evmbank/query.d.ts +40 -0
  31. package/lib/codec/evmbank/query.js +116 -0
  32. package/lib/codec/{liquiditypool/legacy.d.ts → evmmerge/event.d.ts} +11 -9
  33. package/lib/codec/evmmerge/event.js +90 -0
  34. package/lib/codec/evmmerge/genesis.d.ts +48 -0
  35. package/lib/codec/evmmerge/genesis.js +216 -0
  36. package/lib/codec/evmmerge/offchain.d.ts +22 -0
  37. package/lib/codec/evmmerge/offchain.js +105 -0
  38. package/lib/codec/evmmerge/query.d.ts +43 -0
  39. package/lib/codec/evmmerge/query.js +117 -0
  40. package/lib/codec/evmmerge/tx.d.ts +45 -0
  41. package/lib/codec/evmmerge/tx.js +128 -0
  42. package/lib/codec/ibc/applications/fee/v1/ack.d.ts +24 -0
  43. package/lib/codec/ibc/applications/fee/v1/ack.js +125 -0
  44. package/lib/codec/ibc/applications/fee/v1/fee.d.ts +68 -0
  45. package/lib/codec/ibc/applications/fee/v1/fee.js +289 -0
  46. package/lib/codec/ibc/applications/fee/v1/genesis.d.ts +93 -0
  47. package/lib/codec/ibc/applications/fee/v1/genesis.js +390 -0
  48. package/lib/codec/ibc/applications/fee/v1/metadata.d.ts +25 -0
  49. package/lib/codec/ibc/applications/fee/v1/metadata.js +71 -0
  50. package/lib/codec/ibc/applications/fee/v1/query.d.ts +312 -0
  51. package/lib/codec/ibc/applications/fee/v1/query.js +1187 -0
  52. package/lib/codec/ibc/applications/fee/v1/tx.d.ts +171 -0
  53. package/lib/codec/ibc/applications/fee/v1/tx.js +524 -0
  54. package/lib/codec/ibc/applications/interchain_accounts/controller/v1/tx.d.ts +78 -0
  55. package/lib/codec/ibc/applications/interchain_accounts/controller/v1/tx.js +296 -0
  56. package/lib/codec/ibc/applications/interchain_accounts/genesis/v1/genesis.d.ts +80 -0
  57. package/lib/codec/ibc/applications/interchain_accounts/genesis/v1/genesis.js +439 -0
  58. package/lib/codec/index.d.ts +2 -0
  59. package/lib/codec/index.js +556 -551
  60. package/lib/constant/ibc.d.ts +7 -0
  61. package/lib/constant/ibc.js +84 -37
  62. package/lib/constant/network.js +1 -1
  63. package/lib/modules/index.d.ts +1 -0
  64. package/lib/modules/index.js +1 -0
  65. package/lib/provider/keplr/KeplrStore.js +3 -1
  66. package/lib/util/ethermint/evm-ibc.d.ts +97 -0
  67. package/lib/util/ethermint/evm-ibc.js +134 -0
  68. package/lib/util/ethermint/index.d.ts +3 -0
  69. package/lib/util/ethermint/index.js +12 -0
  70. package/lib/util/ethermint/keys.d.ts +39 -0
  71. package/lib/util/ethermint/keys.js +138 -0
  72. package/lib/util/ethermint/web3.d.ts +36 -0
  73. package/lib/util/ethermint/web3.js +124 -0
  74. package/lib/util/ibc.d.ts +2 -0
  75. package/lib/util/ibc.js +19 -6
  76. package/lib/util/tx.d.ts +1 -0
  77. package/package.json +1 -1
  78. package/lib/codec/liquiditypool/legacy.js +0 -64
@@ -0,0 +1,36 @@
1
+ import Long from "long";
2
+ import _m0 from "protobufjs/minimal";
3
+ export declare const protobufPackage = "ethermint.types.v1";
4
+ /**
5
+ * ExtensionOptionsWeb3Tx is an extension option that specifies the typed chain id,
6
+ * the fee payer as well as its signature data.
7
+ */
8
+ export interface ExtensionOptionsWeb3Tx {
9
+ /**
10
+ * typed_data_chain_id is used only in EIP712 Domain and should match
11
+ * Ethereum network ID in a Web3 provider (e.g. Metamask).
12
+ */
13
+ typedDataChainId: Long;
14
+ /**
15
+ * fee_payer is an account address for the fee payer. It will be validated
16
+ * during EIP712 signature checking.
17
+ */
18
+ feePayer: string;
19
+ /**
20
+ * fee_payer_sig is a signature data from the fee paying account,
21
+ * allows to perform fee delegation when using EIP712 Domain.
22
+ */
23
+ feePayerSig: Uint8Array;
24
+ }
25
+ export declare const ExtensionOptionsWeb3Tx: {
26
+ encode(message: ExtensionOptionsWeb3Tx, writer?: _m0.Writer): _m0.Writer;
27
+ decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ExtensionOptionsWeb3Tx;
28
+ fromJSON(object: any): ExtensionOptionsWeb3Tx;
29
+ toJSON(message: ExtensionOptionsWeb3Tx): unknown;
30
+ fromPartial(object: DeepPartial<ExtensionOptionsWeb3Tx>): ExtensionOptionsWeb3Tx;
31
+ };
32
+ declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
33
+ export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
34
+ [K in keyof T]?: DeepPartial<T[K]>;
35
+ } : Partial<T>;
36
+ export {};
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ExtensionOptionsWeb3Tx = exports.protobufPackage = void 0;
7
+ /* eslint-disable */
8
+ const long_1 = __importDefault(require("long"));
9
+ const minimal_1 = __importDefault(require("protobufjs/minimal"));
10
+ exports.protobufPackage = "ethermint.types.v1";
11
+ const baseExtensionOptionsWeb3Tx = {
12
+ typedDataChainId: long_1.default.UZERO,
13
+ feePayer: "",
14
+ };
15
+ exports.ExtensionOptionsWeb3Tx = {
16
+ encode(message, writer = minimal_1.default.Writer.create()) {
17
+ if (!message.typedDataChainId.isZero()) {
18
+ writer.uint32(8).uint64(message.typedDataChainId);
19
+ }
20
+ if (message.feePayer !== "") {
21
+ writer.uint32(18).string(message.feePayer);
22
+ }
23
+ if (message.feePayerSig.length !== 0) {
24
+ writer.uint32(26).bytes(message.feePayerSig);
25
+ }
26
+ return writer;
27
+ },
28
+ decode(input, length) {
29
+ const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
30
+ let end = length === undefined ? reader.len : reader.pos + length;
31
+ const message = Object.assign({}, baseExtensionOptionsWeb3Tx);
32
+ message.feePayerSig = new Uint8Array();
33
+ while (reader.pos < end) {
34
+ const tag = reader.uint32();
35
+ switch (tag >>> 3) {
36
+ case 1:
37
+ message.typedDataChainId = reader.uint64();
38
+ break;
39
+ case 2:
40
+ message.feePayer = reader.string();
41
+ break;
42
+ case 3:
43
+ message.feePayerSig = reader.bytes();
44
+ break;
45
+ default:
46
+ reader.skipType(tag & 7);
47
+ break;
48
+ }
49
+ }
50
+ return message;
51
+ },
52
+ fromJSON(object) {
53
+ const message = Object.assign({}, baseExtensionOptionsWeb3Tx);
54
+ message.typedDataChainId =
55
+ object.typedDataChainId !== undefined && object.typedDataChainId !== null
56
+ ? long_1.default.fromString(object.typedDataChainId)
57
+ : long_1.default.UZERO;
58
+ message.feePayer =
59
+ object.feePayer !== undefined && object.feePayer !== null
60
+ ? String(object.feePayer)
61
+ : "";
62
+ message.feePayerSig =
63
+ object.feePayerSig !== undefined && object.feePayerSig !== null
64
+ ? bytesFromBase64(object.feePayerSig)
65
+ : new Uint8Array();
66
+ return message;
67
+ },
68
+ toJSON(message) {
69
+ const obj = {};
70
+ message.typedDataChainId !== undefined &&
71
+ (obj.typedDataChainId = (message.typedDataChainId || long_1.default.UZERO).toString());
72
+ message.feePayer !== undefined && (obj.feePayer = message.feePayer);
73
+ message.feePayerSig !== undefined &&
74
+ (obj.feePayerSig = base64FromBytes(message.feePayerSig !== undefined
75
+ ? message.feePayerSig
76
+ : new Uint8Array()));
77
+ return obj;
78
+ },
79
+ fromPartial(object) {
80
+ var _a, _b;
81
+ const message = Object.assign({}, baseExtensionOptionsWeb3Tx);
82
+ message.typedDataChainId =
83
+ object.typedDataChainId !== undefined && object.typedDataChainId !== null
84
+ ? long_1.default.fromValue(object.typedDataChainId)
85
+ : long_1.default.UZERO;
86
+ message.feePayer = (_a = object.feePayer) !== null && _a !== void 0 ? _a : "";
87
+ message.feePayerSig = (_b = object.feePayerSig) !== null && _b !== void 0 ? _b : new Uint8Array();
88
+ return message;
89
+ },
90
+ };
91
+ var globalThis = (() => {
92
+ if (typeof globalThis !== "undefined")
93
+ return globalThis;
94
+ if (typeof self !== "undefined")
95
+ return self;
96
+ if (typeof window !== "undefined")
97
+ return window;
98
+ if (typeof global !== "undefined")
99
+ return global;
100
+ throw "Unable to locate global object";
101
+ })();
102
+ const atob = globalThis.atob ||
103
+ ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
104
+ function bytesFromBase64(b64) {
105
+ const bin = atob(b64);
106
+ const arr = new Uint8Array(bin.length);
107
+ for (let i = 0; i < bin.length; ++i) {
108
+ arr[i] = bin.charCodeAt(i);
109
+ }
110
+ return arr;
111
+ }
112
+ const btoa = globalThis.btoa ||
113
+ ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
114
+ function base64FromBytes(arr) {
115
+ const bin = [];
116
+ for (const byte of arr) {
117
+ bin.push(String.fromCharCode(byte));
118
+ }
119
+ return btoa(bin.join(""));
120
+ }
121
+ if (minimal_1.default.util.Long !== long_1.default) {
122
+ minimal_1.default.util.Long = long_1.default;
123
+ minimal_1.default.configure();
124
+ }
package/lib/util/ibc.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ChainInfoExplorerTmRpc, ChainIds, GasPriceStep, AssetListObj } from "../constant";
2
+ import { AppCurrency } from "@keplr-wallet/types";
2
3
  import { Blockchain } from "./blockchain";
3
4
  import { SimpleMap } from "./type";
4
5
  export declare function makeIBCMinimalDenom(sourceChannelId: string, coinMinimalDenom: string): string;
@@ -13,3 +14,4 @@ export interface ChainIdOutput {
13
14
  }
14
15
  export declare const parseChainId: (chainId: string) => ChainIdOutput;
15
16
  export declare const calculateMaxFee: (gasStep?: GasPriceStep, gas?: number) => number;
17
+ export declare const isCw20Token: (currency: AppCurrency) => boolean;
package/lib/util/ibc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateMaxFee = exports.parseChainId = exports.BlockchainMap = exports.getIbcChainFromBlockchain = exports.ChainIdBlockchainMap = exports.totalAssetObj = exports.EmbedChainInfos = exports.makeIBCMinimalDenom = void 0;
3
+ exports.isCw20Token = exports.calculateMaxFee = exports.parseChainId = exports.BlockchainMap = exports.getIbcChainFromBlockchain = exports.ChainIdBlockchainMap = exports.totalAssetObj = exports.EmbedChainInfos = exports.makeIBCMinimalDenom = void 0;
4
4
  const constant_1 = require("../constant");
5
5
  const provider_1 = require("../provider");
6
6
  const crypto_1 = require("@keplr-wallet/crypto");
@@ -15,10 +15,10 @@ function makeIBCMinimalDenom(sourceChannelId, coinMinimalDenom) {
15
15
  }
16
16
  exports.makeIBCMinimalDenom = makeIBCMinimalDenom;
17
17
  exports.EmbedChainInfos = Object.values(constant_1.EmbedChainInfosInit).reduce((prev, chainInfo) => {
18
- var _a;
18
+ var _a, _b;
19
19
  if (constant_1.swthIbcWhitelist.includes(chainInfo.chainId)) {
20
- const chainChannels = constant_1.swthChannels[chainInfo.chainId];
21
- chainInfo.currencies.push(Object.assign(Object.assign({}, provider_1.KeplrAccount.SWTH_CURRENCY), { coinMinimalDenom: makeIBCMinimalDenom((_a = chainChannels === null || chainChannels === void 0 ? void 0 : chainChannels.dstChannel) !== null && _a !== void 0 ? _a : "channel-0", provider_1.KeplrAccount.SWTH_CURRENCY.coinMinimalDenom) }));
20
+ const chainChannels = (_a = constant_1.swthChannels[chainInfo.chainId]) === null || _a === void 0 ? void 0 : _a.ibc;
21
+ chainInfo.currencies.push(Object.assign(Object.assign({}, provider_1.KeplrAccount.SWTH_CURRENCY), { coinMinimalDenom: makeIBCMinimalDenom((_b = chainChannels === null || chainChannels === void 0 ? void 0 : chainChannels.dstChannel) !== null && _b !== void 0 ? _b : "channel-0", provider_1.KeplrAccount.SWTH_CURRENCY.coinMinimalDenom) }));
22
22
  }
23
23
  prev[chainInfo.chainId] = chainInfo;
24
24
  return prev;
@@ -31,9 +31,12 @@ exports.totalAssetObj = Object.values(exports.EmbedChainInfos).reduce((prev, cha
31
31
  const channelsObj = constant_1.swthChannels[chainInfo.chainId];
32
32
  chainInfo.currencies.forEach((currency) => {
33
33
  var _a;
34
+ const channelSet = currency.hasOwnProperty('type') && channelsObj.cw20
35
+ ? channelsObj.cw20
36
+ : channelsObj.ibc;
34
37
  let ibcAddr = currency.coinDenom.toLowerCase() === "swth"
35
38
  ? currency.coinMinimalDenom
36
- : makeIBCMinimalDenom((_a = channelsObj === null || channelsObj === void 0 ? void 0 : channelsObj.sourceChannel) !== null && _a !== void 0 ? _a : "channel-0", currency.coinMinimalDenom);
39
+ : makeIBCMinimalDenom((_a = channelSet === null || channelSet === void 0 ? void 0 : channelSet.sourceChannel) !== null && _a !== void 0 ? _a : "channel-0", currency.coinMinimalDenom);
37
40
  // TODO: Remove when implementing dynamic ibc chain info
38
41
  if (currency.coinMinimalDenom === "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858") {
39
42
  ibcAddr = "ibc/7FBDBEEEBA9C50C4BCDF7BF438EAB99E64360833D240B32655C96E319559E911";
@@ -89,7 +92,10 @@ exports.BlockchainMap = Object.values(exports.EmbedChainInfos).reduce((prev, cha
89
92
  newPrev[currency.coinMinimalDenom] = exports.ChainIdBlockchainMap[chainInfo.chainId];
90
93
  }
91
94
  else {
92
- const ibcAddr = makeIBCMinimalDenom((_a = channelsObj === null || channelsObj === void 0 ? void 0 : channelsObj.sourceChannel) !== null && _a !== void 0 ? _a : "channel-0", currency.coinMinimalDenom);
95
+ const channelSet = currency.hasOwnProperty('type') && channelsObj.cw20
96
+ ? channelsObj.cw20
97
+ : channelsObj.ibc;
98
+ const ibcAddr = makeIBCMinimalDenom((_a = channelSet === null || channelSet === void 0 ? void 0 : channelSet.sourceChannel) !== null && _a !== void 0 ? _a : "channel-0", currency.coinMinimalDenom);
93
99
  newPrev[ibcAddr] = exports.ChainIdBlockchainMap[chainInfo.chainId];
94
100
  }
95
101
  });
@@ -108,3 +114,10 @@ const calculateMaxFee = (gasStep = constant_1.DefaultGasPriceStep, gas = 0) => {
108
114
  return gasStep.high * gas;
109
115
  };
110
116
  exports.calculateMaxFee = calculateMaxFee;
117
+ const isCw20Token = (currency) => {
118
+ if (!currency.hasOwnProperty("type"))
119
+ return false;
120
+ const depositCurrency = currency;
121
+ return depositCurrency.type === "cw20";
122
+ };
123
+ exports.isCw20Token = isCw20Token;
package/lib/util/tx.d.ts CHANGED
@@ -387,6 +387,7 @@ export declare const Types: {
387
387
  MsgSetWrapperMappingResponse: string;
388
388
  MsgDeleteWrapperMapping: string;
389
389
  MsgDeleteWrapperMappingResponse: string;
390
+ MsgExecuteContract: string;
390
391
  };
391
392
  export declare const DEFAULT_SIGN_OPTS: SignTxOpts;
392
393
  export declare const TxGasCostTypeDefaultKey = "default_fee";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.3.47",
3
+ "version": "0.3.49",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ParamsV2170 = exports.protobufPackage = void 0;
7
- /* eslint-disable */
8
- const long_1 = __importDefault(require("long"));
9
- const minimal_1 = __importDefault(require("protobufjs/minimal"));
10
- exports.protobufPackage = "Switcheo.carbon.liquiditypool";
11
- const baseParamsV2170 = { rewardReductionThreshold: long_1.default.UZERO };
12
- exports.ParamsV2170 = {
13
- encode(message, writer = minimal_1.default.Writer.create()) {
14
- if (!message.rewardReductionThreshold.isZero()) {
15
- writer.uint32(8).uint64(message.rewardReductionThreshold);
16
- }
17
- return writer;
18
- },
19
- decode(input, length) {
20
- const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
21
- let end = length === undefined ? reader.len : reader.pos + length;
22
- const message = Object.assign({}, baseParamsV2170);
23
- while (reader.pos < end) {
24
- const tag = reader.uint32();
25
- switch (tag >>> 3) {
26
- case 1:
27
- message.rewardReductionThreshold = reader.uint64();
28
- break;
29
- default:
30
- reader.skipType(tag & 7);
31
- break;
32
- }
33
- }
34
- return message;
35
- },
36
- fromJSON(object) {
37
- const message = Object.assign({}, baseParamsV2170);
38
- message.rewardReductionThreshold =
39
- object.rewardReductionThreshold !== undefined &&
40
- object.rewardReductionThreshold !== null
41
- ? long_1.default.fromString(object.rewardReductionThreshold)
42
- : long_1.default.UZERO;
43
- return message;
44
- },
45
- toJSON(message) {
46
- const obj = {};
47
- message.rewardReductionThreshold !== undefined &&
48
- (obj.rewardReductionThreshold = (message.rewardReductionThreshold || long_1.default.UZERO).toString());
49
- return obj;
50
- },
51
- fromPartial(object) {
52
- const message = Object.assign({}, baseParamsV2170);
53
- message.rewardReductionThreshold =
54
- object.rewardReductionThreshold !== undefined &&
55
- object.rewardReductionThreshold !== null
56
- ? long_1.default.fromValue(object.rewardReductionThreshold)
57
- : long_1.default.UZERO;
58
- return message;
59
- },
60
- };
61
- if (minimal_1.default.util.Long !== long_1.default) {
62
- minimal_1.default.util.Long = long_1.default;
63
- minimal_1.default.configure();
64
- }