essential-eth 0.9.2 → 0.10.2

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.
@@ -5,81 +5,6 @@ exports.abi =
5
5
  // 20210406000308
6
6
  // http://api.etherscan.io/api?module=contract&action=getabi&address=0x575CCD8e2D300e2377B43478339E364000318E2c&format=raw
7
7
  [
8
- {
9
- name: 'Fund',
10
- inputs: [
11
- {
12
- type: 'address',
13
- name: 'recipient',
14
- indexed: true,
15
- },
16
- {
17
- type: 'uint256',
18
- name: 'amount',
19
- indexed: false,
20
- },
21
- ],
22
- anonymous: false,
23
- type: 'event',
24
- },
25
- {
26
- name: 'Claim',
27
- inputs: [
28
- {
29
- type: 'address',
30
- name: 'recipient',
31
- indexed: true,
32
- },
33
- {
34
- type: 'uint256',
35
- name: 'claimed',
36
- indexed: false,
37
- },
38
- ],
39
- anonymous: false,
40
- type: 'event',
41
- },
42
- {
43
- name: 'ToggleDisable',
44
- inputs: [
45
- {
46
- type: 'address',
47
- name: 'recipient',
48
- indexed: false,
49
- },
50
- {
51
- type: 'bool',
52
- name: 'disabled',
53
- indexed: false,
54
- },
55
- ],
56
- anonymous: false,
57
- type: 'event',
58
- },
59
- {
60
- name: 'CommitOwnership',
61
- inputs: [
62
- {
63
- type: 'address',
64
- name: 'admin',
65
- indexed: false,
66
- },
67
- ],
68
- anonymous: false,
69
- type: 'event',
70
- },
71
- {
72
- name: 'ApplyOwnership',
73
- inputs: [
74
- {
75
- type: 'address',
76
- name: 'admin',
77
- indexed: false,
78
- },
79
- ],
80
- anonymous: false,
81
- type: 'event',
82
- },
83
8
  {
84
9
  outputs: [],
85
10
  inputs: [
@@ -0,0 +1,2 @@
1
+ import type { JSONABI } from '../../../types/Contract.types';
2
+ export declare const abi: JSONABI;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.abi = void 0;
4
+ // https://github.com/jk-labs-inc/jokerace/blob/2c92a4ba052d3c4bbf4b2a768ed43d28c90df160/packages/forge/src/governance/Governor.sol#L214-L216
5
+ exports.abi = [
6
+ {
7
+ payable: false,
8
+ name: 'getAllAddressesThatHaveVoted',
9
+ outputs: [{ type: 'address[]', name: '' }],
10
+ inputs: [],
11
+ type: 'function',
12
+ stateMutability: 'view',
13
+ },
14
+ {
15
+ payable: false,
16
+ name: 'getAllProposalIds',
17
+ outputs: [{ type: 'uint256[]', name: '' }],
18
+ inputs: [],
19
+ type: 'function',
20
+ stateMutability: 'view',
21
+ },
22
+ ];
@@ -48,7 +48,7 @@ function expandType(type) {
48
48
  if (type === 'uint[]') {
49
49
  return 'uint256[]';
50
50
  }
51
- else if (type === 'int[]') {
51
+ if (type === 'int[]') {
52
52
  return 'int256[]';
53
53
  }
54
54
  return type;
@@ -135,10 +135,9 @@ exports.encodeData = encodeData;
135
135
  * @example
136
136
  */
137
137
  function decodeRPCResponse(jsonABIArgument, nodeResponse) {
138
- const rawOutputs = jsonABIArgument.outputs;
138
+ const rawOutputs = jsonABIArgument.outputs || [];
139
139
  const slicedResponse = nodeResponse.slice(2);
140
- if (jsonABIArgument?.outputs?.length === 1 &&
141
- jsonABIArgument.outputs[0].type === 'string') {
140
+ if (rawOutputs.length === 1 && rawOutputs[0].type === 'string') {
142
141
  const [hexOffset, responseData] = [
143
142
  slicedResponse.slice(0, 64),
144
143
  slicedResponse.slice(64),
@@ -150,9 +149,21 @@ function decodeRPCResponse(jsonABIArgument, nodeResponse) {
150
149
  return hexToUtf8(hexToDecode);
151
150
  }
152
151
  // chunk response every 64 characters
153
- const encodedOutputs = slicedResponse.match(/.{1,64}/g);
154
- const outputs = (encodedOutputs || []).map((output, i) => {
155
- const outputType = (rawOutputs || [])[i].type;
152
+ const encodedOutputs = slicedResponse.match(/.{1,64}/g) || [];
153
+ if (rawOutputs.length === 1 && rawOutputs[0].type === 'address[]') {
154
+ const unformattedAddresses = encodedOutputs.slice(2);
155
+ return unformattedAddresses.map((unformattedAddress) => {
156
+ return (0, to_checksum_address_1.toChecksumAddress)(`0x${unformattedAddress.slice(24)}`);
157
+ });
158
+ }
159
+ if (rawOutputs?.length === 1 && rawOutputs[0].type === 'uint256[]') {
160
+ const outputs = encodedOutputs.slice(2);
161
+ return outputs.map((output) => {
162
+ return (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(`0x${output}`));
163
+ });
164
+ }
165
+ const outputs = encodedOutputs.map((output, i) => {
166
+ const outputType = rawOutputs[i].type;
156
167
  switch (outputType) {
157
168
  case 'bool':
158
169
  return output === hexTrue;
@@ -1,13 +1,14 @@
1
- export { Contract, BaseContract } from './classes/Contract';
1
+ export { BaseContract, Contract } from './classes/Contract';
2
2
  export { AlchemyProvider } from './providers/AlchemyProvider';
3
- export { FallthroughProvider, ConstructorOptions, } from './providers/FallthroughProvider';
3
+ export { ConstructorOptions, FallthroughProvider, } from './providers/FallthroughProvider';
4
4
  export { jsonRpcProvider, JsonRpcProvider } from './providers/JsonRpcProvider';
5
5
  export { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
6
- export { BlockResponse, RPCBlock, BlockTag } from './types/Block.types';
6
+ export { BlockResponse, BlockTag, RPCBlock } from './types/Block.types';
7
7
  export { ContractTypes, JSONABI, JSONABIArgument, } from './types/Contract.types';
8
8
  export { Filter, FilterByBlockHash } from './types/Filter.types';
9
9
  export { Network } from './types/Network.types';
10
- export { TransactionResponse, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, RPCLog, Log, BlockTransactionResponse, } from './types/Transaction.types';
10
+ export { BlockTransactionResponse, Log, RPCLog, RPCTransaction, RPCTransactionReceipt, RPCTransactionRequest, TransactionReceipt, TransactionRequest, TransactionResponse, } from './types/Transaction.types';
11
+ export { arrayify, Bytes, BytesLike, BytesLikeWithNumber, concat, DataOptions, Hexable, hexConcat, hexDataLength, hexDataSlice, hexlify, hexStripZeros, hexValue, hexZeroPad, isBytes, isBytesLike, isHexString, Signature, SignatureLike, stripZeros, zeroPad, } from './utils/bytes';
11
12
  export { computeAddress } from './utils/compute-address';
12
13
  export { computePublicKey } from './utils/compute-public-key';
13
14
  export { etherToGwei } from './utils/ether-to-gwei';
@@ -15,10 +16,9 @@ export { etherToWei } from './utils/ether-to-wei';
15
16
  export { gweiToEther } from './utils/gwei-to-ether';
16
17
  export { hashMessage } from './utils/hash-message';
17
18
  export { isAddress } from './utils/is-address';
19
+ export { keccak256 } from './utils/keccak256';
20
+ export { pack, solidityKeccak256 } from './utils/solidity-keccak256';
18
21
  export { splitSignature } from './utils/split-signature';
19
22
  export { toChecksumAddress } from './utils/to-checksum-address';
20
23
  export { toUtf8Bytes } from './utils/to-utf8-bytes';
21
24
  export { weiToEther } from './utils/wei-to-ether';
22
- export { Bytes, BytesLike, BytesLikeWithNumber, DataOptions, Hexable, SignatureLike, Signature, isBytesLike, isBytes, arrayify, concat, stripZeros, zeroPad, isHexString, hexlify, hexDataLength, hexDataSlice, hexConcat, hexValue, hexStripZeros, hexZeroPad, } from './utils/bytes';
23
- export { keccak256 } from './utils/keccak256';
24
- export { pack, solidityKeccak256 } from './utils/solidity-keccak256';
package/dist/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.solidityKeccak256 = exports.pack = exports.keccak256 = exports.hexZeroPad = exports.hexStripZeros = exports.hexValue = exports.hexConcat = exports.hexDataSlice = exports.hexDataLength = exports.hexlify = exports.isHexString = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.isBytes = exports.isBytesLike = exports.weiToEther = exports.toUtf8Bytes = exports.toChecksumAddress = exports.splitSignature = exports.isAddress = exports.hashMessage = exports.gweiToEther = exports.etherToWei = exports.etherToGwei = exports.computePublicKey = exports.computeAddress = exports.TinyBig = exports.tinyBig = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.FallthroughProvider = exports.AlchemyProvider = exports.BaseContract = exports.Contract = void 0;
3
+ exports.weiToEther = exports.toUtf8Bytes = exports.toChecksumAddress = exports.splitSignature = exports.solidityKeccak256 = exports.pack = exports.keccak256 = exports.isAddress = exports.hashMessage = exports.gweiToEther = exports.etherToWei = exports.etherToGwei = exports.computePublicKey = exports.computeAddress = exports.zeroPad = exports.stripZeros = exports.isHexString = exports.isBytesLike = exports.isBytes = exports.hexZeroPad = exports.hexValue = exports.hexStripZeros = exports.hexlify = exports.hexDataSlice = exports.hexDataLength = exports.hexConcat = exports.concat = exports.arrayify = exports.TinyBig = exports.tinyBig = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.FallthroughProvider = exports.AlchemyProvider = exports.Contract = exports.BaseContract = void 0;
4
4
  var Contract_1 = require("./classes/Contract");
5
- Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return Contract_1.Contract; } });
6
5
  Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return Contract_1.BaseContract; } });
6
+ Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return Contract_1.Contract; } });
7
7
  var AlchemyProvider_1 = require("./providers/AlchemyProvider");
8
8
  Object.defineProperty(exports, "AlchemyProvider", { enumerable: true, get: function () { return AlchemyProvider_1.AlchemyProvider; } });
9
9
  var FallthroughProvider_1 = require("./providers/FallthroughProvider");
@@ -14,6 +14,21 @@ Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: funct
14
14
  var tiny_big_1 = require("./shared/tiny-big/tiny-big");
15
15
  Object.defineProperty(exports, "tinyBig", { enumerable: true, get: function () { return tiny_big_1.tinyBig; } });
16
16
  Object.defineProperty(exports, "TinyBig", { enumerable: true, get: function () { return tiny_big_1.TinyBig; } });
17
+ var bytes_1 = require("./utils/bytes");
18
+ Object.defineProperty(exports, "arrayify", { enumerable: true, get: function () { return bytes_1.arrayify; } });
19
+ Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return bytes_1.concat; } });
20
+ Object.defineProperty(exports, "hexConcat", { enumerable: true, get: function () { return bytes_1.hexConcat; } });
21
+ Object.defineProperty(exports, "hexDataLength", { enumerable: true, get: function () { return bytes_1.hexDataLength; } });
22
+ Object.defineProperty(exports, "hexDataSlice", { enumerable: true, get: function () { return bytes_1.hexDataSlice; } });
23
+ Object.defineProperty(exports, "hexlify", { enumerable: true, get: function () { return bytes_1.hexlify; } });
24
+ Object.defineProperty(exports, "hexStripZeros", { enumerable: true, get: function () { return bytes_1.hexStripZeros; } });
25
+ Object.defineProperty(exports, "hexValue", { enumerable: true, get: function () { return bytes_1.hexValue; } });
26
+ Object.defineProperty(exports, "hexZeroPad", { enumerable: true, get: function () { return bytes_1.hexZeroPad; } });
27
+ Object.defineProperty(exports, "isBytes", { enumerable: true, get: function () { return bytes_1.isBytes; } });
28
+ Object.defineProperty(exports, "isBytesLike", { enumerable: true, get: function () { return bytes_1.isBytesLike; } });
29
+ Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return bytes_1.isHexString; } });
30
+ Object.defineProperty(exports, "stripZeros", { enumerable: true, get: function () { return bytes_1.stripZeros; } });
31
+ Object.defineProperty(exports, "zeroPad", { enumerable: true, get: function () { return bytes_1.zeroPad; } });
17
32
  var compute_address_1 = require("./utils/compute-address");
18
33
  Object.defineProperty(exports, "computeAddress", { enumerable: true, get: function () { return compute_address_1.computeAddress; } });
19
34
  var compute_public_key_1 = require("./utils/compute-public-key");
@@ -28,6 +43,11 @@ var hash_message_1 = require("./utils/hash-message");
28
43
  Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return hash_message_1.hashMessage; } });
29
44
  var is_address_1 = require("./utils/is-address");
30
45
  Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return is_address_1.isAddress; } });
46
+ var keccak256_1 = require("./utils/keccak256");
47
+ Object.defineProperty(exports, "keccak256", { enumerable: true, get: function () { return keccak256_1.keccak256; } });
48
+ var solidity_keccak256_1 = require("./utils/solidity-keccak256");
49
+ Object.defineProperty(exports, "pack", { enumerable: true, get: function () { return solidity_keccak256_1.pack; } });
50
+ Object.defineProperty(exports, "solidityKeccak256", { enumerable: true, get: function () { return solidity_keccak256_1.solidityKeccak256; } });
31
51
  var split_signature_1 = require("./utils/split-signature");
32
52
  Object.defineProperty(exports, "splitSignature", { enumerable: true, get: function () { return split_signature_1.splitSignature; } });
33
53
  var to_checksum_address_1 = require("./utils/to-checksum-address");
@@ -36,23 +56,3 @@ var to_utf8_bytes_1 = require("./utils/to-utf8-bytes");
36
56
  Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return to_utf8_bytes_1.toUtf8Bytes; } });
37
57
  var wei_to_ether_1 = require("./utils/wei-to-ether");
38
58
  Object.defineProperty(exports, "weiToEther", { enumerable: true, get: function () { return wei_to_ether_1.weiToEther; } });
39
- var bytes_1 = require("./utils/bytes");
40
- Object.defineProperty(exports, "isBytesLike", { enumerable: true, get: function () { return bytes_1.isBytesLike; } });
41
- Object.defineProperty(exports, "isBytes", { enumerable: true, get: function () { return bytes_1.isBytes; } });
42
- Object.defineProperty(exports, "arrayify", { enumerable: true, get: function () { return bytes_1.arrayify; } });
43
- Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return bytes_1.concat; } });
44
- Object.defineProperty(exports, "stripZeros", { enumerable: true, get: function () { return bytes_1.stripZeros; } });
45
- Object.defineProperty(exports, "zeroPad", { enumerable: true, get: function () { return bytes_1.zeroPad; } });
46
- Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return bytes_1.isHexString; } });
47
- Object.defineProperty(exports, "hexlify", { enumerable: true, get: function () { return bytes_1.hexlify; } });
48
- Object.defineProperty(exports, "hexDataLength", { enumerable: true, get: function () { return bytes_1.hexDataLength; } });
49
- Object.defineProperty(exports, "hexDataSlice", { enumerable: true, get: function () { return bytes_1.hexDataSlice; } });
50
- Object.defineProperty(exports, "hexConcat", { enumerable: true, get: function () { return bytes_1.hexConcat; } });
51
- Object.defineProperty(exports, "hexValue", { enumerable: true, get: function () { return bytes_1.hexValue; } });
52
- Object.defineProperty(exports, "hexStripZeros", { enumerable: true, get: function () { return bytes_1.hexStripZeros; } });
53
- Object.defineProperty(exports, "hexZeroPad", { enumerable: true, get: function () { return bytes_1.hexZeroPad; } });
54
- var keccak256_1 = require("./utils/keccak256");
55
- Object.defineProperty(exports, "keccak256", { enumerable: true, get: function () { return keccak256_1.keccak256; } });
56
- var solidity_keccak256_1 = require("./utils/solidity-keccak256");
57
- Object.defineProperty(exports, "pack", { enumerable: true, get: function () { return solidity_keccak256_1.pack; } });
58
- Object.defineProperty(exports, "solidityKeccak256", { enumerable: true, get: function () { return solidity_keccak256_1.solidityKeccak256; } });