carbon-js-sdk 0.4.21 → 0.4.22

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 (113) 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/broker/incoming_pool_swap.d.ts +23 -0
  10. package/lib/codec/broker/incoming_pool_swap.js +136 -0
  11. package/lib/codec/cosmos/gov/v1/query.js +2 -2
  12. package/lib/codec/cosmos/gov/v1/tx.js +2 -2
  13. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  14. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  15. package/lib/codec/cosmos/group/v1/events.js +2 -2
  16. package/lib/codec/cosmos/group/v1/tx.js +4 -4
  17. package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
  18. package/lib/constant/generic.js +1 -1
  19. package/lib/modules/cdp.js +43 -43
  20. package/lib/modules/cosmwasm.js +1 -1
  21. package/lib/modules/gov.js +12 -12
  22. package/lib/modules/liquiditypool.js +1 -1
  23. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  24. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  25. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  26. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  27. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  28. package/lib/provider/amino/types/admin.js +27 -27
  29. package/lib/provider/amino/types/bank.js +1 -1
  30. package/lib/provider/amino/types/broker.js +1 -1
  31. package/lib/provider/amino/types/cdp.js +25 -25
  32. package/lib/provider/amino/types/coin.js +4 -4
  33. package/lib/provider/amino/types/gov.js +4 -4
  34. package/lib/provider/amino/types/ibc.js +1 -1
  35. package/lib/provider/amino/types/leverage.js +1 -1
  36. package/lib/provider/amino/types/liquidityPool.js +7 -7
  37. package/lib/provider/amino/types/market.js +2 -2
  38. package/lib/provider/amino/types/oracle.js +1 -1
  39. package/lib/provider/amino/types/order.js +4 -4
  40. package/lib/provider/amino/types/position.js +1 -1
  41. package/lib/provider/amino/types/profile.js +1 -1
  42. package/lib/provider/amino/types/staking.js +4 -4
  43. package/lib/provider/amino/types/subaccount.js +3 -3
  44. package/lib/provider/amino/utils.js +11 -11
  45. package/lib/provider/ledger/ledger.js +2 -2
  46. package/lib/provider/metamask/MetaMask.js +1 -1
  47. package/lib/provider/o3/O3Wallet.js +2 -2
  48. package/lib/util/address.js +13 -13
  49. package/lib/util/api.js +4 -4
  50. package/lib/util/ethermint/evm-ibc.d.ts +97 -0
  51. package/lib/util/ethermint/evm-ibc.js +134 -0
  52. package/lib/util/ethermint/index.d.ts +3 -0
  53. package/lib/util/ethermint/index.js +12 -0
  54. package/lib/util/ethermint/keys.d.ts +39 -0
  55. package/lib/util/ethermint/keys.js +138 -0
  56. package/lib/util/ethermint/web3.d.ts +36 -0
  57. package/lib/util/ethermint/web3.js +124 -0
  58. package/lib/util/fetch.js +1 -1
  59. package/lib/util/generic.js +3 -3
  60. package/lib/util/number.js +5 -5
  61. package/lib/wallet/CarbonSigner.js +2 -2
  62. package/lib/wallet/CarbonSigningClient.js +8 -8
  63. package/lib/wallet/CarbonWallet.js +6 -6
  64. package/lib/websocket/connector.js +3 -3
  65. package/package.json +1 -1
  66. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.d.ts +0 -1
  67. package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +0 -6
  68. package/lib/codec/ethermint/evm/v1/export.d.ts +0 -5
  69. package/lib/codec/ethermint/evm/v1/export.js +0 -53
  70. package/lib/codec/ethermint/feemarket/v1/export.d.ts +0 -4
  71. package/lib/codec/ethermint/feemarket/v1/export.js +0 -18
  72. package/lib/codec/ethermint/types/v1/export.d.ts +0 -4
  73. package/lib/codec/ethermint/types/v1/export.js +0 -11
  74. package/lib/codec/ethermint-models.d.ts +0 -4
  75. package/lib/codec/ethermint-models.js +0 -26
  76. package/lib/codec/market/fee.d.ts +0 -123
  77. package/lib/codec/market/fee.js +0 -334
  78. package/lib/codec/perpsliquidity/event.d.ts +0 -102
  79. package/lib/codec/perpsliquidity/event.js +0 -581
  80. package/lib/codec/perpsliquidity/genesis.d.ts +0 -35
  81. package/lib/codec/perpsliquidity/genesis.js +0 -162
  82. package/lib/codec/perpsliquidity/params.d.ts +0 -24
  83. package/lib/codec/perpsliquidity/params.js +0 -103
  84. package/lib/codec/perpsliquidity/pool.d.ts +0 -137
  85. package/lib/codec/perpsliquidity/pool.js +0 -747
  86. package/lib/codec/perpsliquidity/query.d.ts +0 -167
  87. package/lib/codec/perpsliquidity/query.js +0 -719
  88. package/lib/codec/perpsliquidity/tx.d.ts +0 -199
  89. package/lib/codec/perpsliquidity/tx.js +0 -940
  90. package/lib/constant/eip712.d.ts +0 -46
  91. package/lib/constant/eip712.js +0 -106
  92. package/lib/modules/evm.d.ts +0 -46
  93. package/lib/modules/evm.js +0 -127
  94. package/lib/modules/evmmerge.d.ts +0 -12
  95. package/lib/modules/evmmerge.js +0 -35
  96. package/lib/modules/feemarket.d.ts +0 -20
  97. package/lib/modules/feemarket.js +0 -45
  98. package/lib/modules/vault.d.ts +0 -44
  99. package/lib/modules/vault.js +0 -95
  100. package/lib/provider/amino/types/evm.d.ts +0 -4
  101. package/lib/provider/amino/types/evm.js +0 -40
  102. package/lib/provider/amino/types/evmmerge.d.ts +0 -4
  103. package/lib/provider/amino/types/evmmerge.js +0 -34
  104. package/lib/provider/amino/types/feemarket.d.ts +0 -4
  105. package/lib/provider/amino/types/feemarket.js +0 -34
  106. package/lib/provider/metamask/legacy-accounts.d.ts +0 -6
  107. package/lib/provider/metamask/legacy-accounts.js +0 -44
  108. package/lib/util/eip712.d.ts +0 -10
  109. package/lib/util/eip712.js +0 -195
  110. package/lib/util/ethermint.d.ts +0 -8
  111. package/lib/util/ethermint.js +0 -68
  112. package/lib/util/legacyEIP712.d.ts +0 -20
  113. package/lib/util/legacyEIP712.js +0 -98
@@ -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";
@@ -0,0 +1,12 @@
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.EvmIbcHelper = exports.ExtensionOptionsWeb3Tx = exports.PubKey = void 0;
7
+ var keys_1 = require("./keys");
8
+ Object.defineProperty(exports, "PubKey", { enumerable: true, get: function () { return keys_1.PubKey; } });
9
+ var web3_1 = require("./web3");
10
+ Object.defineProperty(exports, "ExtensionOptionsWeb3Tx", { enumerable: true, get: function () { return web3_1.ExtensionOptionsWeb3Tx; } });
11
+ var evm_ibc_1 = require("./evm-ibc");
12
+ Object.defineProperty(exports, "EvmIbcHelper", { enumerable: true, get: function () { return __importDefault(evm_ibc_1).default; } });
@@ -0,0 +1,39 @@
1
+ import Long from "long";
2
+ import _m0 from "protobufjs/minimal";
3
+ export declare const protobufPackage = "ethermint.crypto.v1.ethsecp256k1";
4
+ /**
5
+ * PubKey defines a type alias for an ecdsa.PublicKey that implements
6
+ * Tendermint's PubKey interface. It represents the 33-byte compressed public
7
+ * key format.
8
+ */
9
+ export interface PubKey {
10
+ /** key is the public key in byte form */
11
+ key: Uint8Array;
12
+ }
13
+ /**
14
+ * PrivKey defines a type alias for an ecdsa.PrivateKey that implements
15
+ * Tendermint's PrivateKey interface.
16
+ */
17
+ export interface PrivKey {
18
+ /** key is the private key in byte form */
19
+ key: Uint8Array;
20
+ }
21
+ export declare const PubKey: {
22
+ encode(message: PubKey, writer?: _m0.Writer): _m0.Writer;
23
+ decode(input: _m0.Reader | Uint8Array, length?: number | undefined): PubKey;
24
+ fromJSON(object: any): PubKey;
25
+ toJSON(message: PubKey): unknown;
26
+ fromPartial(object: DeepPartial<PubKey>): PubKey;
27
+ };
28
+ export declare const PrivKey: {
29
+ encode(message: PrivKey, writer?: _m0.Writer): _m0.Writer;
30
+ decode(input: _m0.Reader | Uint8Array, length?: number | undefined): PrivKey;
31
+ fromJSON(object: any): PrivKey;
32
+ toJSON(message: PrivKey): unknown;
33
+ fromPartial(object: DeepPartial<PrivKey>): PrivKey;
34
+ };
35
+ declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
36
+ 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 {} ? {
37
+ [K in keyof T]?: DeepPartial<T[K]>;
38
+ } : Partial<T>;
39
+ export {};
@@ -0,0 +1,138 @@
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.PrivKey = exports.PubKey = 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.crypto.v1.ethsecp256k1";
11
+ const basePubKey = {};
12
+ exports.PubKey = {
13
+ encode(message, writer = minimal_1.default.Writer.create()) {
14
+ if (message.key.length !== 0) {
15
+ writer.uint32(10).bytes(message.key);
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({}, basePubKey);
23
+ message.key = new Uint8Array();
24
+ while (reader.pos < end) {
25
+ const tag = reader.uint32();
26
+ switch (tag >>> 3) {
27
+ case 1:
28
+ message.key = reader.bytes();
29
+ break;
30
+ default:
31
+ reader.skipType(tag & 7);
32
+ break;
33
+ }
34
+ }
35
+ return message;
36
+ },
37
+ fromJSON(object) {
38
+ const message = Object.assign({}, basePubKey);
39
+ message.key =
40
+ object.key !== undefined && object.key !== null
41
+ ? bytesFromBase64(object.key)
42
+ : new Uint8Array();
43
+ return message;
44
+ },
45
+ toJSON(message) {
46
+ const obj = {};
47
+ message.key !== undefined &&
48
+ (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
49
+ return obj;
50
+ },
51
+ fromPartial(object) {
52
+ var _a;
53
+ const message = Object.assign({}, basePubKey);
54
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : new Uint8Array();
55
+ return message;
56
+ },
57
+ };
58
+ const basePrivKey = {};
59
+ exports.PrivKey = {
60
+ encode(message, writer = minimal_1.default.Writer.create()) {
61
+ if (message.key.length !== 0) {
62
+ writer.uint32(10).bytes(message.key);
63
+ }
64
+ return writer;
65
+ },
66
+ decode(input, length) {
67
+ const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
68
+ let end = length === undefined ? reader.len : reader.pos + length;
69
+ const message = Object.assign({}, basePrivKey);
70
+ message.key = new Uint8Array();
71
+ while (reader.pos < end) {
72
+ const tag = reader.uint32();
73
+ switch (tag >>> 3) {
74
+ case 1:
75
+ message.key = reader.bytes();
76
+ break;
77
+ default:
78
+ reader.skipType(tag & 7);
79
+ break;
80
+ }
81
+ }
82
+ return message;
83
+ },
84
+ fromJSON(object) {
85
+ const message = Object.assign({}, basePrivKey);
86
+ message.key =
87
+ object.key !== undefined && object.key !== null
88
+ ? bytesFromBase64(object.key)
89
+ : new Uint8Array();
90
+ return message;
91
+ },
92
+ toJSON(message) {
93
+ const obj = {};
94
+ message.key !== undefined &&
95
+ (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
96
+ return obj;
97
+ },
98
+ fromPartial(object) {
99
+ var _a;
100
+ const message = Object.assign({}, basePrivKey);
101
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : new Uint8Array();
102
+ return message;
103
+ },
104
+ };
105
+ var globalThis = (() => {
106
+ if (typeof globalThis !== "undefined")
107
+ return globalThis;
108
+ if (typeof self !== "undefined")
109
+ return self;
110
+ if (typeof window !== "undefined")
111
+ return window;
112
+ if (typeof global !== "undefined")
113
+ return global;
114
+ throw "Unable to locate global object";
115
+ })();
116
+ const atob = globalThis.atob ||
117
+ ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
118
+ function bytesFromBase64(b64) {
119
+ const bin = atob(b64);
120
+ const arr = new Uint8Array(bin.length);
121
+ for (let i = 0; i < bin.length; ++i) {
122
+ arr[i] = bin.charCodeAt(i);
123
+ }
124
+ return arr;
125
+ }
126
+ const btoa = globalThis.btoa ||
127
+ ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
128
+ function base64FromBytes(arr) {
129
+ const bin = [];
130
+ for (const byte of arr) {
131
+ bin.push(String.fromCharCode(byte));
132
+ }
133
+ return btoa(bin.join(""));
134
+ }
135
+ if (minimal_1.default.util.Long !== long_1.default) {
136
+ minimal_1.default.util.Long = long_1.default;
137
+ minimal_1.default.configure();
138
+ }
@@ -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/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;
@@ -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(generic_1.sortObject(doc));
109
+ const msg = JSON.stringify((0, generic_1.sortObject)(doc));
110
110
  const signBytes = yield this.ledger.sign(msg);
111
- const signature = amino_1.encodeSecp256k1Signature(pubkey, signBytes);
111
+ const signature = (0, amino_1.encodeSecp256k1Signature)(pubkey, signBytes);
112
112
  return {
113
113
  signed: doc,
114
114
  signature,