essential-eth 0.5.4 → 0.5.9
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.
- package/lib/cjs/classes/Contract.d.ts +10 -4
- package/lib/cjs/classes/Contract.js +15 -4
- package/lib/cjs/classes/utils/clean-block.d.ts +115 -0
- package/lib/cjs/classes/utils/clean-block.js +122 -9
- package/lib/cjs/classes/utils/clean-log.d.ts +9 -0
- package/lib/cjs/classes/utils/clean-log.js +37 -0
- package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +9 -0
- package/lib/cjs/classes/utils/clean-transaction-receipt.js +11 -16
- package/lib/cjs/classes/utils/clean-transaction.d.ts +9 -0
- package/lib/cjs/classes/utils/clean-transaction.js +10 -1
- package/lib/cjs/classes/utils/encode-decode-transaction.d.ts +12 -0
- package/lib/cjs/classes/utils/encode-decode-transaction.js +24 -0
- package/lib/cjs/classes/utils/fetchers.d.ts +31 -1
- package/lib/cjs/classes/utils/fetchers.js +30 -0
- package/lib/cjs/classes/utils/hex-to-decimal.d.ts +14 -1
- package/lib/cjs/classes/utils/hex-to-decimal.js +14 -1
- package/lib/cjs/classes/utils/prepare-transaction.d.ts +6 -0
- package/lib/cjs/classes/utils/prepare-transaction.js +45 -0
- package/lib/cjs/index.d.ts +10 -5
- package/lib/cjs/index.js +10 -2
- package/lib/cjs/logger/package-version.d.ts +1 -1
- package/lib/cjs/logger/package-version.js +1 -1
- package/lib/cjs/providers/BaseProvider.d.ts +282 -199
- package/lib/cjs/providers/BaseProvider.js +365 -214
- package/lib/cjs/providers/FallthroughProvider.d.ts +1 -2
- package/lib/cjs/providers/JsonRpcProvider.d.ts +6 -0
- package/lib/cjs/providers/JsonRpcProvider.js +6 -0
- package/lib/cjs/providers/utils/chains-info.d.ts +27 -0
- package/lib/cjs/providers/utils/chains-info.js +84 -3
- package/lib/cjs/shared/tiny-big/helpers.d.ts +16 -0
- package/lib/cjs/shared/tiny-big/helpers.js +27 -1
- package/lib/cjs/shared/tiny-big/tiny-big.d.ts +30 -4
- package/lib/cjs/shared/tiny-big/tiny-big.js +34 -4
- package/lib/cjs/types/Block.types.d.ts +11 -7
- package/lib/cjs/types/Filter.types.d.ts +16 -0
- package/lib/cjs/types/Filter.types.js +2 -0
- package/lib/cjs/types/Transaction.types.d.ts +33 -6
- package/lib/cjs/utils/bytes.d.ts +150 -33
- package/lib/cjs/utils/bytes.js +179 -32
- package/lib/cjs/utils/compute-address.d.ts +17 -0
- package/lib/cjs/utils/compute-address.js +33 -0
- package/lib/cjs/utils/compute-public-key.d.ts +18 -0
- package/lib/cjs/utils/compute-public-key.js +26 -0
- package/lib/cjs/utils/ether-to-gwei.d.ts +2 -1
- package/lib/cjs/utils/ether-to-gwei.js +2 -1
- package/lib/cjs/utils/ether-to-wei.d.ts +2 -1
- package/lib/cjs/utils/ether-to-wei.js +2 -1
- package/lib/cjs/utils/gwei-to-ether.d.ts +2 -1
- package/lib/cjs/utils/gwei-to-ether.js +2 -1
- package/lib/cjs/utils/hash-message.d.ts +3 -1
- package/lib/cjs/utils/hash-message.js +3 -1
- package/lib/cjs/utils/is-address.d.ts +2 -2
- package/lib/cjs/utils/is-address.js +2 -2
- package/lib/cjs/utils/keccak256.d.ts +15 -1
- package/lib/cjs/utils/keccak256.js +16 -2
- package/lib/cjs/utils/solidity-keccak256.d.ts +17 -7
- package/lib/cjs/utils/solidity-keccak256.js +27 -7
- package/lib/cjs/utils/split-signature.d.ts +24 -0
- package/lib/cjs/utils/split-signature.js +163 -0
- package/lib/cjs/utils/to-checksum-address.d.ts +2 -2
- package/lib/cjs/utils/to-checksum-address.js +2 -2
- package/lib/cjs/utils/to-utf8-bytes.d.ts +14 -0
- package/lib/cjs/utils/to-utf8-bytes.js +14 -0
- package/lib/cjs/utils/wei-to-ether.d.ts +2 -1
- package/lib/cjs/utils/wei-to-ether.js +14 -3
- package/lib/esm/classes/utils/clean-block.js +7 -8
- package/lib/esm/classes/utils/clean-log.d.ts +2 -0
- package/lib/esm/classes/utils/clean-log.js +26 -0
- package/lib/esm/classes/utils/clean-transaction-receipt.js +2 -16
- package/lib/esm/classes/utils/clean-transaction.js +1 -1
- package/lib/esm/classes/utils/fetchers.d.ts +1 -1
- package/lib/esm/classes/utils/prepare-transaction.d.ts +2 -0
- package/lib/esm/classes/utils/prepare-transaction.js +34 -0
- package/lib/esm/index.d.ts +10 -5
- package/lib/esm/index.js +7 -3
- package/lib/esm/logger/package-version.d.ts +1 -1
- package/lib/esm/logger/package-version.js +1 -1
- package/lib/esm/providers/BaseProvider.d.ts +7 -1
- package/lib/esm/providers/BaseProvider.js +67 -11
- package/lib/esm/providers/FallthroughProvider.d.ts +1 -2
- package/lib/esm/providers/utils/chains-info.d.ts +27 -0
- package/lib/esm/providers/utils/chains-info.js +84 -3
- package/lib/esm/shared/tiny-big/tiny-big.js +4 -0
- package/lib/esm/types/Block.types.d.ts +11 -7
- package/lib/esm/types/Filter.types.d.ts +12 -0
- package/lib/esm/types/Filter.types.js +1 -0
- package/lib/esm/types/Transaction.types.d.ts +31 -5
- package/lib/esm/utils/compute-address.d.ts +1 -0
- package/lib/esm/utils/compute-address.js +11 -0
- package/lib/esm/utils/compute-public-key.d.ts +2 -0
- package/lib/esm/utils/compute-public-key.js +6 -0
- package/lib/esm/utils/keccak256.d.ts +1 -1
- package/lib/esm/utils/keccak256.js +2 -2
- package/lib/esm/utils/split-signature.d.ts +2 -0
- package/lib/esm/utils/split-signature.js +126 -0
- package/lib/esm/utils/wei-to-ether.js +11 -2
- package/package.json +38 -11
- package/readme.md +1209 -335
|
@@ -7,20 +7,26 @@ export declare class BaseContract {
|
|
|
7
7
|
private readonly _address;
|
|
8
8
|
private readonly _provider;
|
|
9
9
|
/**
|
|
10
|
-
* @param addressOrName
|
|
11
|
-
* @param contractInterface
|
|
12
|
-
* @param signerOrProvider
|
|
10
|
+
* @param addressOrName The ethereum address of the smart-contract
|
|
11
|
+
* @param contractInterface The JSON ABI of the smart-contract (like http://api.etherscan.io/api?module=contract&action=getabi&address=0x090d4613473dee047c3f2706764f49e0821d256e&format=raw)
|
|
12
|
+
* @param signerOrProvider An instantiated essential-eth provider
|
|
13
|
+
* @example
|
|
13
14
|
*/
|
|
14
15
|
constructor(addressOrName: string, contractInterface: ContractInterface, signerOrProvider: JsonRpcProvider);
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Applies the unique contract's methods to the instantiated Contract in the constructor based-upon the provided ABI
|
|
19
|
+
*
|
|
20
|
+
* @param object
|
|
21
|
+
* @param name
|
|
22
|
+
* @param value
|
|
23
|
+
* @example
|
|
18
24
|
*/
|
|
19
25
|
export declare function defineReadOnly<T>(object: T, name: string, value: any): void;
|
|
20
26
|
/**
|
|
21
27
|
* @alpha
|
|
22
28
|
* Only accepts ABIS in JSON format. This allows for stronger typing and assurances of data-types
|
|
23
|
-
*
|
|
29
|
+
* Only read-only function calls currently supported.
|
|
24
30
|
* @example
|
|
25
31
|
* ```typescript
|
|
26
32
|
* import { Contract, JsonRpcProvider } from 'essential-eth';
|
|
@@ -12,6 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Contract = exports.defineReadOnly = exports.BaseContract = void 0;
|
|
13
13
|
const encode_decode_transaction_1 = require("./utils/encode-decode-transaction");
|
|
14
14
|
const fetchers_1 = require("./utils/fetchers");
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param txnData
|
|
18
|
+
* @example
|
|
19
|
+
*/
|
|
15
20
|
function estimateGas(txnData) {
|
|
16
21
|
// https://ethereum.stackexchange.com/questions/1570/what-does-intrinsic-gas-too-low-mean/1694
|
|
17
22
|
txnData.split('').reduce((previousValue, currentValue) => {
|
|
@@ -22,9 +27,10 @@ function estimateGas(txnData) {
|
|
|
22
27
|
}
|
|
23
28
|
class BaseContract {
|
|
24
29
|
/**
|
|
25
|
-
* @param addressOrName
|
|
26
|
-
* @param contractInterface
|
|
27
|
-
* @param signerOrProvider
|
|
30
|
+
* @param addressOrName The ethereum address of the smart-contract
|
|
31
|
+
* @param contractInterface The JSON ABI of the smart-contract (like http://api.etherscan.io/api?module=contract&action=getabi&address=0x090d4613473dee047c3f2706764f49e0821d256e&format=raw)
|
|
32
|
+
* @param signerOrProvider An instantiated essential-eth provider
|
|
33
|
+
* @example
|
|
28
34
|
*/
|
|
29
35
|
constructor(addressOrName, contractInterface, signerOrProvider) {
|
|
30
36
|
this._address = addressOrName;
|
|
@@ -68,6 +74,11 @@ class BaseContract {
|
|
|
68
74
|
exports.BaseContract = BaseContract;
|
|
69
75
|
/**
|
|
70
76
|
* Applies the unique contract's methods to the instantiated Contract in the constructor based-upon the provided ABI
|
|
77
|
+
*
|
|
78
|
+
* @param object
|
|
79
|
+
* @param name
|
|
80
|
+
* @param value
|
|
81
|
+
* @example
|
|
71
82
|
*/
|
|
72
83
|
function defineReadOnly(object, name, value) {
|
|
73
84
|
Object.defineProperty(object, name, {
|
|
@@ -80,7 +91,7 @@ exports.defineReadOnly = defineReadOnly;
|
|
|
80
91
|
/**
|
|
81
92
|
* @alpha
|
|
82
93
|
* Only accepts ABIS in JSON format. This allows for stronger typing and assurances of data-types
|
|
83
|
-
*
|
|
94
|
+
* Only read-only function calls currently supported.
|
|
84
95
|
* @example
|
|
85
96
|
* ```typescript
|
|
86
97
|
* import { Contract, JsonRpcProvider } from 'essential-eth';
|
|
@@ -2,5 +2,120 @@ import { BlockResponse } from '../..';
|
|
|
2
2
|
import { RPCBlock } from '../../types/Block.types';
|
|
3
3
|
/**
|
|
4
4
|
* Converts RPC block response to more JS-friendly format
|
|
5
|
+
*
|
|
6
|
+
* @param block the RPCBlock to clean
|
|
7
|
+
* @param returnTransactionObjects whether or not to return the transactions specified in this block
|
|
8
|
+
* @returns a cleaned block
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* const rpcBlock = {
|
|
12
|
+
* number: '0x40f9de',
|
|
13
|
+
* hash: '0x4cbaa942e48a91108f38e2a250f6dbaff7fffe3027f5ebf76701929eed2b2970',
|
|
14
|
+
* parentHash: '0xc8de1e513f74cbc5cc77e2a39e4cada6504469a5d0e87200b708319c1e9ef154',
|
|
15
|
+
* sha3Uncles: '0x04d250716296c9662314b37c112e5ce8b1c9ad7fd7820a39482a3688a2078f2b',
|
|
16
|
+
* logsBloom: '0x0000400004000000040010100200000000000000000000000000000000000000001000000001000000000000000000000004010000000000000a800000000000040000000001000400000000000000000000000000000000000002000000000000000000000004000040000000800000000001000000000000000000000000000000000000000001000000000004200000000000000000000000000124400000000000000200100020000000000000000080000000000080001000000000000000000081000000000000000000008000000020000100000000200020100800000000000000000008002000000080001000020c00000000000000200000000000',
|
|
17
|
+
* transactionsRoot: '0xfc79f4f620cb69861ac67ceee5e1ddf3e45da95be230d4064be234f1ee491aa5',
|
|
18
|
+
* stateRoot: '0xfa5ef7e368997d70670b0ea3172aabefc2dee285786ce69c7165d8d854f8b292',
|
|
19
|
+
* receiptsRoot: '0x7fa0679e88fef8a8f7f5865dc4e6000ddcc267b14d2904948e3b1576a18a3bbd',
|
|
20
|
+
* miner: '0x1b7a75ef070ff49e6b9491a26403d799f2099ebd',
|
|
21
|
+
* difficulty: '0x47ede14fcbe635706e',
|
|
22
|
+
* totalDifficulty: '0x139e1de9b8404dedc5d30959',
|
|
23
|
+
* extraData: '0xce018c495249532d62613031656132',
|
|
24
|
+
* size: '0xb4f',
|
|
25
|
+
* gasLimit: '0x67c280',
|
|
26
|
+
* gasUsed: '0x56e2d',
|
|
27
|
+
* timestamp: '0x62648dc2',
|
|
28
|
+
* transactions: [
|
|
29
|
+
* '0xd53800afc69e55cc7a64b927803b46a5b4c5ddccbaafb6b32fe0ec883739b825',
|
|
30
|
+
* '0x4b8b07f35a1f911a80a0ffeebe3d3c41cd393b4d5e1ce0a408026705913d6760',
|
|
31
|
+
* '0xa50eac0ea8005cb1e4b95be4e64c24035d9c41adb164c49477c3169870f02fb1',
|
|
32
|
+
* '0x413e5293786f8b63e73adf0b74ab56067da4b564d01936b88b138d48cc414a42',
|
|
33
|
+
* '0xd4e4969365d144b0b987632dca36ba9e272254bdc687245987a57666d6afa148'
|
|
34
|
+
* ],
|
|
35
|
+
* uncles: [
|
|
36
|
+
* '0x36cd3869fd17a285b984dea8b705d34096e1fbdfe48df69ae530fbe921ba83fa'
|
|
37
|
+
* ],
|
|
38
|
+
* minimumGasPrice: '0x387ee40',
|
|
39
|
+
* bitcoinMergedMiningHeader: '0x0040502d717ae205da048b0ffb8e110603564d8677ca8bd3a54601000000000000000000e722e86bfebcae00bffb46c663fa0241b63a27f0c98fa710e421d5cc1afa2448d08d6462d9f809172f5e30aa',
|
|
40
|
+
* bitcoinMergedMiningCoinbaseTransaction: '0x00000000000001003f8757a906f0159f882f0968788a2e396b7bf8090e1b926fb2bb46789ac32d55082aca4e0800000000000000002b6a2952534b424c4f434b3a831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de00000000',
|
|
41
|
+
* bitcoinMergedMiningMerkleProof: '0xb53111a4e11bc19bf90268485d1b957d908ebc6a4cd9862aca3fc6ed3dcf3240b14c316de8521369d55dbfeb2b0116bcc10f40e999c4885e1bd2a08691bdea1c43862d590390a227a379d5677b958f1a23eecc16ac590ad675b8a4cea0c10da3ef597acb9ca1fe0a21fc408f09e0c7169d83aca8ddd636d8cc155f922e1d36c74b7cc11e9ee98dd1bf2100a55d59630c65da3db1575d58f165c5753c1779df90efcff9017b73cc32f4c87178bd0eae6a6dd0357047be70d6c4af17fcef097e80a9f1751447f4eee3831fc79f2d894934694149bcb99840a525f5128215eca6b54642af452ee7568a9281f40560afffd35725df31b98155d7813dea12e42f2a8052c7d98bcf62c9cdc66c40fb12b729b685a31aec4970ea5316640691ae5eb616808656a2bde4e9f5920ff178bf9d1f84e96a0d0bd048a3a8ca0d60970d02aacf7ecfb6e7feaec5c4a764873531cfd630e9430840cfe8b88154da25d6b94b706fe678d0efc1ecafed5a1f539e34552bea65622513b663e17e121f3c4548942584',
|
|
42
|
+
* hashForMergedMining: '0x831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de',
|
|
43
|
+
* paidFees: '0x1fb451615b58',
|
|
44
|
+
* cumulativeDifficulty: '0x8fdbe015f7248cf993'
|
|
45
|
+
* };
|
|
46
|
+
* const returnTransactionObjects = false;
|
|
47
|
+
*
|
|
48
|
+
* await cleanBlock(rpcBlock, returnTransactionObjects);
|
|
49
|
+
* // {
|
|
50
|
+
* // number: 4258270,
|
|
51
|
+
* // hash: '0x4cbaa942e48a91108f38e2a250f6dbaff7fffe3027f5ebf76701929eed2b2970',
|
|
52
|
+
* // parentHash: '0xc8de1e513f74cbc5cc77e2a39e4cada6504469a5d0e87200b708319c1e9ef154',
|
|
53
|
+
* // sha3Uncles: '0x04d250716296c9662314b37c112e5ce8b1c9ad7fd7820a39482a3688a2078f2b',
|
|
54
|
+
* // logsBloom: '0x0000400004000000040010100200000000000000000000000000000000000000001000000001000000000000000000000004010000000000000a800000000000040000000001000400000000000000000000000000000000000002000000000000000000000004000040000000800000000001000000000000000000000000000000000000000001000000000004200000000000000000000000000124400000000000000200100020000000000000000080000000000080001000000000000000000081000000000000000000008000000020000100000000200020100800000000000000000008002000000080001000020c00000000000000200000000000',
|
|
55
|
+
* // transactionsRoot: '0xfc79f4f620cb69861ac67ceee5e1ddf3e45da95be230d4064be234f1ee491aa5',
|
|
56
|
+
* // stateRoot: '0xfa5ef7e368997d70670b0ea3172aabefc2dee285786ce69c7165d8d854f8b292',
|
|
57
|
+
* // receiptsRoot: '0x7fa0679e88fef8a8f7f5865dc4e6000ddcc267b14d2904948e3b1576a18a3bbd',
|
|
58
|
+
* // miner: '0x1b7A75Ef070Ff49E6B9491a26403D799f2099EbD',
|
|
59
|
+
* // difficulty: Big {
|
|
60
|
+
* // s: 1,
|
|
61
|
+
* // e: 21,
|
|
62
|
+
* // c: [Array],
|
|
63
|
+
* // constructor: [Function],
|
|
64
|
+
* // padAndChop: [Function (anonymous)]
|
|
65
|
+
* // },
|
|
66
|
+
* // totalDifficulty: Big {
|
|
67
|
+
* // s: 1,
|
|
68
|
+
* // e: 27,
|
|
69
|
+
* // c: [Array],
|
|
70
|
+
* // constructor: [Function],
|
|
71
|
+
* // padAndChop: [Function (anonymous)]
|
|
72
|
+
* // },
|
|
73
|
+
* // extraData: '0xce018c495249532d62613031656132',
|
|
74
|
+
* // size: Big {
|
|
75
|
+
* // s: 1,
|
|
76
|
+
* // e: 3,
|
|
77
|
+
* // c: [Array],
|
|
78
|
+
* // constructor: [Function],
|
|
79
|
+
* // padAndChop: [Function (anonymous)]
|
|
80
|
+
* // },
|
|
81
|
+
* // gasLimit: Big {
|
|
82
|
+
* // s: 1,
|
|
83
|
+
* // e: 6,
|
|
84
|
+
* // c: [Array],
|
|
85
|
+
* // constructor: [Function],
|
|
86
|
+
* // padAndChop: [Function (anonymous)]
|
|
87
|
+
* // },
|
|
88
|
+
* // gasUsed: Big {
|
|
89
|
+
* // s: 1,
|
|
90
|
+
* // e: 5,
|
|
91
|
+
* // c: [Array],
|
|
92
|
+
* // constructor: [Function],
|
|
93
|
+
* // padAndChop: [Function (anonymous)]
|
|
94
|
+
* // },
|
|
95
|
+
* // timestamp: Big {
|
|
96
|
+
* // s: 1,
|
|
97
|
+
* // e: 9,
|
|
98
|
+
* // c: [Array],
|
|
99
|
+
* // constructor: [Function],
|
|
100
|
+
* // padAndChop: [Function (anonymous)]
|
|
101
|
+
* // },
|
|
102
|
+
* // transactions: [
|
|
103
|
+
* // '0xd53800afc69e55cc7a64b927803b46a5b4c5ddccbaafb6b32fe0ec883739b825',
|
|
104
|
+
* // '0x4b8b07f35a1f911a80a0ffeebe3d3c41cd393b4d5e1ce0a408026705913d6760',
|
|
105
|
+
* // '0xa50eac0ea8005cb1e4b95be4e64c24035d9c41adb164c49477c3169870f02fb1',
|
|
106
|
+
* // '0x413e5293786f8b63e73adf0b74ab56067da4b564d01936b88b138d48cc414a42',
|
|
107
|
+
* // '0xd4e4969365d144b0b987632dca36ba9e272254bdc687245987a57666d6afa148'
|
|
108
|
+
* // ],
|
|
109
|
+
* // uncles: [
|
|
110
|
+
* // '0x36cd3869fd17a285b984dea8b705d34096e1fbdfe48df69ae530fbe921ba83fa'
|
|
111
|
+
* // ],
|
|
112
|
+
* // minimumGasPrice: '0x387ee40',
|
|
113
|
+
* // bitcoinMergedMiningHeader: '0x0040502d717ae205da048b0ffb8e110603564d8677ca8bd3a54601000000000000000000e722e86bfebcae00bffb46c663fa0241b63a27f0c98fa710e421d5cc1afa2448d08d6462d9f809172f5e30aa',
|
|
114
|
+
* // bitcoinMergedMiningCoinbaseTransaction: '0x00000000000001003f8757a906f0159f882f0968788a2e396b7bf8090e1b926fb2bb46789ac32d55082aca4e0800000000000000002b6a2952534b424c4f434b3a831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de00000000',
|
|
115
|
+
* // bitcoinMergedMiningMerkleProof: '0xb53111a4e11bc19bf90268485d1b957d908ebc6a4cd9862aca3fc6ed3dcf3240b14c316de8521369d55dbfeb2b0116bcc10f40e999c4885e1bd2a08691bdea1c43862d590390a227a379d5677b958f1a23eecc16ac590ad675b8a4cea0c10da3ef597acb9ca1fe0a21fc408f09e0c7169d83aca8ddd636d8cc155f922e1d36c74b7cc11e9ee98dd1bf2100a55d59630c65da3db1575d58f165c5753c1779df90efcff9017b73cc32f4c87178bd0eae6a6dd0357047be70d6c4af17fcef097e80a9f1751447f4eee3831fc79f2d894934694149bcb99840a525f5128215eca6b54642af452ee7568a9281f40560afffd35725df31b98155d7813dea12e42f2a8052c7d98bcf62c9cdc66c40fb12b729b685a31aec4970ea5316640691ae5eb616808656a2bde4e9f5920ff178bf9d1f84e96a0d0bd048a3a8ca0d60970d02aacf7ecfb6e7feaec5c4a764873531cfd630e9430840cfe8b88154da25d6b94b706fe678d0efc1ecafed5a1f539e34552bea65622513b663e17e121f3c4548942584',
|
|
116
|
+
* // hashForMergedMining: '0x831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de',
|
|
117
|
+
* // paidFees: '0x1fb451615b58',
|
|
118
|
+
* // cumulativeDifficulty: '0x8fdbe015f7248cf993'
|
|
119
|
+
* // }
|
|
5
120
|
*/
|
|
6
121
|
export declare function cleanBlock(block: RPCBlock, returnTransactionObjects: boolean): BlockResponse;
|
|
@@ -2,10 +2,126 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cleanBlock = void 0;
|
|
4
4
|
const __1 = require("../..");
|
|
5
|
+
const tiny_big_1 = require("../../shared/tiny-big/tiny-big");
|
|
5
6
|
const clean_transaction_1 = require("./clean-transaction");
|
|
6
7
|
const hex_to_decimal_1 = require("./hex-to-decimal");
|
|
7
8
|
/**
|
|
8
9
|
* Converts RPC block response to more JS-friendly format
|
|
10
|
+
*
|
|
11
|
+
* @param block the RPCBlock to clean
|
|
12
|
+
* @param returnTransactionObjects whether or not to return the transactions specified in this block
|
|
13
|
+
* @returns a cleaned block
|
|
14
|
+
* @example
|
|
15
|
+
* ```js
|
|
16
|
+
* const rpcBlock = {
|
|
17
|
+
* number: '0x40f9de',
|
|
18
|
+
* hash: '0x4cbaa942e48a91108f38e2a250f6dbaff7fffe3027f5ebf76701929eed2b2970',
|
|
19
|
+
* parentHash: '0xc8de1e513f74cbc5cc77e2a39e4cada6504469a5d0e87200b708319c1e9ef154',
|
|
20
|
+
* sha3Uncles: '0x04d250716296c9662314b37c112e5ce8b1c9ad7fd7820a39482a3688a2078f2b',
|
|
21
|
+
* logsBloom: '0x0000400004000000040010100200000000000000000000000000000000000000001000000001000000000000000000000004010000000000000a800000000000040000000001000400000000000000000000000000000000000002000000000000000000000004000040000000800000000001000000000000000000000000000000000000000001000000000004200000000000000000000000000124400000000000000200100020000000000000000080000000000080001000000000000000000081000000000000000000008000000020000100000000200020100800000000000000000008002000000080001000020c00000000000000200000000000',
|
|
22
|
+
* transactionsRoot: '0xfc79f4f620cb69861ac67ceee5e1ddf3e45da95be230d4064be234f1ee491aa5',
|
|
23
|
+
* stateRoot: '0xfa5ef7e368997d70670b0ea3172aabefc2dee285786ce69c7165d8d854f8b292',
|
|
24
|
+
* receiptsRoot: '0x7fa0679e88fef8a8f7f5865dc4e6000ddcc267b14d2904948e3b1576a18a3bbd',
|
|
25
|
+
* miner: '0x1b7a75ef070ff49e6b9491a26403d799f2099ebd',
|
|
26
|
+
* difficulty: '0x47ede14fcbe635706e',
|
|
27
|
+
* totalDifficulty: '0x139e1de9b8404dedc5d30959',
|
|
28
|
+
* extraData: '0xce018c495249532d62613031656132',
|
|
29
|
+
* size: '0xb4f',
|
|
30
|
+
* gasLimit: '0x67c280',
|
|
31
|
+
* gasUsed: '0x56e2d',
|
|
32
|
+
* timestamp: '0x62648dc2',
|
|
33
|
+
* transactions: [
|
|
34
|
+
* '0xd53800afc69e55cc7a64b927803b46a5b4c5ddccbaafb6b32fe0ec883739b825',
|
|
35
|
+
* '0x4b8b07f35a1f911a80a0ffeebe3d3c41cd393b4d5e1ce0a408026705913d6760',
|
|
36
|
+
* '0xa50eac0ea8005cb1e4b95be4e64c24035d9c41adb164c49477c3169870f02fb1',
|
|
37
|
+
* '0x413e5293786f8b63e73adf0b74ab56067da4b564d01936b88b138d48cc414a42',
|
|
38
|
+
* '0xd4e4969365d144b0b987632dca36ba9e272254bdc687245987a57666d6afa148'
|
|
39
|
+
* ],
|
|
40
|
+
* uncles: [
|
|
41
|
+
* '0x36cd3869fd17a285b984dea8b705d34096e1fbdfe48df69ae530fbe921ba83fa'
|
|
42
|
+
* ],
|
|
43
|
+
* minimumGasPrice: '0x387ee40',
|
|
44
|
+
* bitcoinMergedMiningHeader: '0x0040502d717ae205da048b0ffb8e110603564d8677ca8bd3a54601000000000000000000e722e86bfebcae00bffb46c663fa0241b63a27f0c98fa710e421d5cc1afa2448d08d6462d9f809172f5e30aa',
|
|
45
|
+
* bitcoinMergedMiningCoinbaseTransaction: '0x00000000000001003f8757a906f0159f882f0968788a2e396b7bf8090e1b926fb2bb46789ac32d55082aca4e0800000000000000002b6a2952534b424c4f434b3a831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de00000000',
|
|
46
|
+
* bitcoinMergedMiningMerkleProof: '0xb53111a4e11bc19bf90268485d1b957d908ebc6a4cd9862aca3fc6ed3dcf3240b14c316de8521369d55dbfeb2b0116bcc10f40e999c4885e1bd2a08691bdea1c43862d590390a227a379d5677b958f1a23eecc16ac590ad675b8a4cea0c10da3ef597acb9ca1fe0a21fc408f09e0c7169d83aca8ddd636d8cc155f922e1d36c74b7cc11e9ee98dd1bf2100a55d59630c65da3db1575d58f165c5753c1779df90efcff9017b73cc32f4c87178bd0eae6a6dd0357047be70d6c4af17fcef097e80a9f1751447f4eee3831fc79f2d894934694149bcb99840a525f5128215eca6b54642af452ee7568a9281f40560afffd35725df31b98155d7813dea12e42f2a8052c7d98bcf62c9cdc66c40fb12b729b685a31aec4970ea5316640691ae5eb616808656a2bde4e9f5920ff178bf9d1f84e96a0d0bd048a3a8ca0d60970d02aacf7ecfb6e7feaec5c4a764873531cfd630e9430840cfe8b88154da25d6b94b706fe678d0efc1ecafed5a1f539e34552bea65622513b663e17e121f3c4548942584',
|
|
47
|
+
* hashForMergedMining: '0x831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de',
|
|
48
|
+
* paidFees: '0x1fb451615b58',
|
|
49
|
+
* cumulativeDifficulty: '0x8fdbe015f7248cf993'
|
|
50
|
+
* };
|
|
51
|
+
* const returnTransactionObjects = false;
|
|
52
|
+
*
|
|
53
|
+
* await cleanBlock(rpcBlock, returnTransactionObjects);
|
|
54
|
+
* // {
|
|
55
|
+
* // number: 4258270,
|
|
56
|
+
* // hash: '0x4cbaa942e48a91108f38e2a250f6dbaff7fffe3027f5ebf76701929eed2b2970',
|
|
57
|
+
* // parentHash: '0xc8de1e513f74cbc5cc77e2a39e4cada6504469a5d0e87200b708319c1e9ef154',
|
|
58
|
+
* // sha3Uncles: '0x04d250716296c9662314b37c112e5ce8b1c9ad7fd7820a39482a3688a2078f2b',
|
|
59
|
+
* // logsBloom: '0x0000400004000000040010100200000000000000000000000000000000000000001000000001000000000000000000000004010000000000000a800000000000040000000001000400000000000000000000000000000000000002000000000000000000000004000040000000800000000001000000000000000000000000000000000000000001000000000004200000000000000000000000000124400000000000000200100020000000000000000080000000000080001000000000000000000081000000000000000000008000000020000100000000200020100800000000000000000008002000000080001000020c00000000000000200000000000',
|
|
60
|
+
* // transactionsRoot: '0xfc79f4f620cb69861ac67ceee5e1ddf3e45da95be230d4064be234f1ee491aa5',
|
|
61
|
+
* // stateRoot: '0xfa5ef7e368997d70670b0ea3172aabefc2dee285786ce69c7165d8d854f8b292',
|
|
62
|
+
* // receiptsRoot: '0x7fa0679e88fef8a8f7f5865dc4e6000ddcc267b14d2904948e3b1576a18a3bbd',
|
|
63
|
+
* // miner: '0x1b7A75Ef070Ff49E6B9491a26403D799f2099EbD',
|
|
64
|
+
* // difficulty: Big {
|
|
65
|
+
* // s: 1,
|
|
66
|
+
* // e: 21,
|
|
67
|
+
* // c: [Array],
|
|
68
|
+
* // constructor: [Function],
|
|
69
|
+
* // padAndChop: [Function (anonymous)]
|
|
70
|
+
* // },
|
|
71
|
+
* // totalDifficulty: Big {
|
|
72
|
+
* // s: 1,
|
|
73
|
+
* // e: 27,
|
|
74
|
+
* // c: [Array],
|
|
75
|
+
* // constructor: [Function],
|
|
76
|
+
* // padAndChop: [Function (anonymous)]
|
|
77
|
+
* // },
|
|
78
|
+
* // extraData: '0xce018c495249532d62613031656132',
|
|
79
|
+
* // size: Big {
|
|
80
|
+
* // s: 1,
|
|
81
|
+
* // e: 3,
|
|
82
|
+
* // c: [Array],
|
|
83
|
+
* // constructor: [Function],
|
|
84
|
+
* // padAndChop: [Function (anonymous)]
|
|
85
|
+
* // },
|
|
86
|
+
* // gasLimit: Big {
|
|
87
|
+
* // s: 1,
|
|
88
|
+
* // e: 6,
|
|
89
|
+
* // c: [Array],
|
|
90
|
+
* // constructor: [Function],
|
|
91
|
+
* // padAndChop: [Function (anonymous)]
|
|
92
|
+
* // },
|
|
93
|
+
* // gasUsed: Big {
|
|
94
|
+
* // s: 1,
|
|
95
|
+
* // e: 5,
|
|
96
|
+
* // c: [Array],
|
|
97
|
+
* // constructor: [Function],
|
|
98
|
+
* // padAndChop: [Function (anonymous)]
|
|
99
|
+
* // },
|
|
100
|
+
* // timestamp: Big {
|
|
101
|
+
* // s: 1,
|
|
102
|
+
* // e: 9,
|
|
103
|
+
* // c: [Array],
|
|
104
|
+
* // constructor: [Function],
|
|
105
|
+
* // padAndChop: [Function (anonymous)]
|
|
106
|
+
* // },
|
|
107
|
+
* // transactions: [
|
|
108
|
+
* // '0xd53800afc69e55cc7a64b927803b46a5b4c5ddccbaafb6b32fe0ec883739b825',
|
|
109
|
+
* // '0x4b8b07f35a1f911a80a0ffeebe3d3c41cd393b4d5e1ce0a408026705913d6760',
|
|
110
|
+
* // '0xa50eac0ea8005cb1e4b95be4e64c24035d9c41adb164c49477c3169870f02fb1',
|
|
111
|
+
* // '0x413e5293786f8b63e73adf0b74ab56067da4b564d01936b88b138d48cc414a42',
|
|
112
|
+
* // '0xd4e4969365d144b0b987632dca36ba9e272254bdc687245987a57666d6afa148'
|
|
113
|
+
* // ],
|
|
114
|
+
* // uncles: [
|
|
115
|
+
* // '0x36cd3869fd17a285b984dea8b705d34096e1fbdfe48df69ae530fbe921ba83fa'
|
|
116
|
+
* // ],
|
|
117
|
+
* // minimumGasPrice: '0x387ee40',
|
|
118
|
+
* // bitcoinMergedMiningHeader: '0x0040502d717ae205da048b0ffb8e110603564d8677ca8bd3a54601000000000000000000e722e86bfebcae00bffb46c663fa0241b63a27f0c98fa710e421d5cc1afa2448d08d6462d9f809172f5e30aa',
|
|
119
|
+
* // bitcoinMergedMiningCoinbaseTransaction: '0x00000000000001003f8757a906f0159f882f0968788a2e396b7bf8090e1b926fb2bb46789ac32d55082aca4e0800000000000000002b6a2952534b424c4f434b3a831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de00000000',
|
|
120
|
+
* // bitcoinMergedMiningMerkleProof: '0xb53111a4e11bc19bf90268485d1b957d908ebc6a4cd9862aca3fc6ed3dcf3240b14c316de8521369d55dbfeb2b0116bcc10f40e999c4885e1bd2a08691bdea1c43862d590390a227a379d5677b958f1a23eecc16ac590ad675b8a4cea0c10da3ef597acb9ca1fe0a21fc408f09e0c7169d83aca8ddd636d8cc155f922e1d36c74b7cc11e9ee98dd1bf2100a55d59630c65da3db1575d58f165c5753c1779df90efcff9017b73cc32f4c87178bd0eae6a6dd0357047be70d6c4af17fcef097e80a9f1751447f4eee3831fc79f2d894934694149bcb99840a525f5128215eca6b54642af452ee7568a9281f40560afffd35725df31b98155d7813dea12e42f2a8052c7d98bcf62c9cdc66c40fb12b729b685a31aec4970ea5316640691ae5eb616808656a2bde4e9f5920ff178bf9d1f84e96a0d0bd048a3a8ca0d60970d02aacf7ecfb6e7feaec5c4a764873531cfd630e9430840cfe8b88154da25d6b94b706fe678d0efc1ecafed5a1f539e34552bea65622513b663e17e121f3c4548942584',
|
|
121
|
+
* // hashForMergedMining: '0x831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de',
|
|
122
|
+
* // paidFees: '0x1fb451615b58',
|
|
123
|
+
* // cumulativeDifficulty: '0x8fdbe015f7248cf993'
|
|
124
|
+
* // }
|
|
9
125
|
*/
|
|
10
126
|
function cleanBlock(block, returnTransactionObjects) {
|
|
11
127
|
const cleanedBlock = Object.assign({}, block);
|
|
@@ -15,29 +131,26 @@ function cleanBlock(block, returnTransactionObjects) {
|
|
|
15
131
|
if (!block[key])
|
|
16
132
|
return;
|
|
17
133
|
switch (key) {
|
|
134
|
+
case 'difficulty':
|
|
135
|
+
case 'totalDifficulty':
|
|
18
136
|
case 'gasLimit':
|
|
19
137
|
case 'gasUsed':
|
|
20
|
-
case 'number':
|
|
21
138
|
case 'size':
|
|
22
139
|
case 'timestamp':
|
|
23
140
|
case 'baseFeePerGas':
|
|
24
|
-
cleanedBlock[key] =
|
|
141
|
+
cleanedBlock[key] = (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(block[key]));
|
|
25
142
|
break;
|
|
26
|
-
case '
|
|
27
|
-
|
|
28
|
-
cleanedBlock[key] = (0, hex_to_decimal_1.hexToDecimal)(block[key]);
|
|
143
|
+
case 'number':
|
|
144
|
+
cleanedBlock[key] = Number((0, hex_to_decimal_1.hexToDecimal)(block[key]));
|
|
29
145
|
break;
|
|
30
146
|
case 'miner':
|
|
31
|
-
|
|
32
|
-
cleanedBlock[key] = (0, __1.toChecksumAddress)(block[key]);
|
|
33
|
-
}
|
|
147
|
+
cleanedBlock[key] = (0, __1.toChecksumAddress)(block[key]);
|
|
34
148
|
break;
|
|
35
149
|
}
|
|
36
150
|
});
|
|
37
151
|
// for all full transactions
|
|
38
152
|
if (returnTransactionObjects) {
|
|
39
153
|
const txns = block.transactions;
|
|
40
|
-
// could be renamed "cleanTransaction" in the future
|
|
41
154
|
txns.forEach((transaction, index) => {
|
|
42
155
|
cleanedBlock.transactions[index] = (0, clean_transaction_1.cleanTransaction)(transaction);
|
|
43
156
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Log, RPCLog } from './../../types/Transaction.types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts RPC log receipt response to more JS-friendly format
|
|
4
|
+
*
|
|
5
|
+
* @param log the log to clean
|
|
6
|
+
* @param receiptLog if the log is part of a transaction receipt. Used to remove certain keys from log
|
|
7
|
+
* @example
|
|
8
|
+
*/
|
|
9
|
+
export declare function cleanLog(log: RPCLog, receiptLog: boolean): Log;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanLog = void 0;
|
|
4
|
+
const to_checksum_address_1 = require("../../utils/to-checksum-address");
|
|
5
|
+
const hex_to_decimal_1 = require("./hex-to-decimal");
|
|
6
|
+
/**
|
|
7
|
+
* Converts RPC log receipt response to more JS-friendly format
|
|
8
|
+
*
|
|
9
|
+
* @param log the log to clean
|
|
10
|
+
* @param receiptLog if the log is part of a transaction receipt. Used to remove certain keys from log
|
|
11
|
+
* @example
|
|
12
|
+
*/
|
|
13
|
+
function cleanLog(log, receiptLog) {
|
|
14
|
+
const cleanedLog = Object.assign({}, log);
|
|
15
|
+
Object.keys(log).forEach((key) => {
|
|
16
|
+
switch (key) {
|
|
17
|
+
case 'address':
|
|
18
|
+
cleanedLog[key] = (0, to_checksum_address_1.toChecksumAddress)(log[key]);
|
|
19
|
+
break;
|
|
20
|
+
case 'blockNumber':
|
|
21
|
+
case 'logIndex':
|
|
22
|
+
case 'transactionIndex':
|
|
23
|
+
cleanedLog[key] = Number((0, hex_to_decimal_1.hexToDecimal)(log[key]));
|
|
24
|
+
break;
|
|
25
|
+
case 'removed':
|
|
26
|
+
if (receiptLog) {
|
|
27
|
+
delete cleanedLog[key];
|
|
28
|
+
}
|
|
29
|
+
else if (log[key] == null) {
|
|
30
|
+
cleanedLog[key] === false;
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return cleanedLog;
|
|
36
|
+
}
|
|
37
|
+
exports.cleanLog = cleanLog;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { RPCTransactionReceipt, TransactionReceipt } from '../../types/Transaction.types';
|
|
2
2
|
/**
|
|
3
3
|
* Converts RPC transaction receipt response to more JS-friendly format
|
|
4
|
+
*
|
|
5
|
+
* @param transactionReceipt the transaction receipt to clean
|
|
6
|
+
* @returns a cleaned transaction receipt
|
|
7
|
+
* @example
|
|
8
|
+
* ```javascript
|
|
9
|
+
* const RPCTransactionReceipt = { blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: '0xe28f62', contractAddress: null, cumulativeGasUsed: '0x37a2b9', effectiveGasPrice: '0x62df1c62c', from: '0x642824fab1d0141073ed74326332950bec4701e3', gasUsed: '0x1a325', logs: [ { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 84, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074d' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 85, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074e' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 86, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074f' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 87, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000750' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 88, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000751' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 89, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000752' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 90, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000753' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 91, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000754' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 92, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000755' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 93, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000756' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 } ], logsBloom: '0x20000080004000000000000400000000000001000000000400000000000000000000000000000000000000000008000000000000000000000000000000004000000000000008000000000008000000010080000014000004000000000000000000100000020800000000000000001800000080000000002000000010000000000000000000000200000200000000002000000000000400000000000000000000000000000000000000000040000000000000000100000000000000000000040002100002000000000000080000000000000100000002000000040000001220000000000000000000000000000000000000000000000000000000000000004000', status: '0x1', to: '0x84f80ea01e26b7c11bdd241970982c7eeab6ddcc', transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: '0x29', type: '0x2' }
|
|
10
|
+
* cleanTransactionReceipt(RPCTransactionReceipt);
|
|
11
|
+
* // { blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, contractAddress: null, cumulativeGasUsed: Big { s: 1, e: 6, c: [ 3, 6, 4, 6, 1, 3, 7 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, effectiveGasPrice: Big { s: 1, e: 10, c: [ 2, 6, 5, 4, 0, 6, 2, 3, 4, 0, 4 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, from: '0x642824FaB1D0141073ed74326332950bEc4701e3', gasUsed: Big { s: 1, e: 5, c: [ 1, 0, 7, 3, 0, 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, logs: [ { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 84, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074d' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 85, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074e' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 86, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074f' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 87, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000750' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 88, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000751' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 89, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000752' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 90, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000753' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 91, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000754' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 92, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000755' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 93, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000756' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 } ], logsBloom: '0x20000080004000000000000400000000000001000000000400000000000000000000000000000000000000000008000000000000000000000000000000004000000000000008000000000008000000010080000014000004000000000000000000100000020800000000000000001800000080000000002000000010000000000000000000000200000200000000002000000000000400000000000000000000000000000000000000000040000000000000000100000000000000000000040002100002000000000000080000000000000100000002000000040000001220000000000000000000000000000000000000000000000000000000000000004000', status: 1, to: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41, type: 2, byzantium: true, confirmations: 40 }
|
|
12
|
+
* ```
|
|
4
13
|
*/
|
|
5
14
|
export declare function cleanTransactionReceipt(transactionReceipt: RPCTransactionReceipt): TransactionReceipt;
|
|
@@ -2,10 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cleanTransactionReceipt = void 0;
|
|
4
4
|
const __1 = require("../..");
|
|
5
|
+
const clean_log_1 = require("./clean-log");
|
|
5
6
|
const clean_transaction_1 = require("./clean-transaction");
|
|
6
7
|
const hex_to_decimal_1 = require("./hex-to-decimal");
|
|
7
8
|
/**
|
|
8
9
|
* Converts RPC transaction receipt response to more JS-friendly format
|
|
10
|
+
*
|
|
11
|
+
* @param transactionReceipt the transaction receipt to clean
|
|
12
|
+
* @returns a cleaned transaction receipt
|
|
13
|
+
* @example
|
|
14
|
+
* ```javascript
|
|
15
|
+
* const RPCTransactionReceipt = { blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: '0xe28f62', contractAddress: null, cumulativeGasUsed: '0x37a2b9', effectiveGasPrice: '0x62df1c62c', from: '0x642824fab1d0141073ed74326332950bec4701e3', gasUsed: '0x1a325', logs: [ { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 84, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074d' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 85, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074e' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 86, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074f' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 87, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000750' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 88, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000751' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 89, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000752' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 90, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000753' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 91, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000754' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 92, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000755' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 93, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000756' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 } ], logsBloom: '0x20000080004000000000000400000000000001000000000400000000000000000000000000000000000000000008000000000000000000000000000000004000000000000008000000000008000000010080000014000004000000000000000000100000020800000000000000001800000080000000002000000010000000000000000000000200000200000000002000000000000400000000000000000000000000000000000000000040000000000000000100000000000000000000040002100002000000000000080000000000000100000002000000040000001220000000000000000000000000000000000000000000000000000000000000004000', status: '0x1', to: '0x84f80ea01e26b7c11bdd241970982c7eeab6ddcc', transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: '0x29', type: '0x2' }
|
|
16
|
+
* cleanTransactionReceipt(RPCTransactionReceipt);
|
|
17
|
+
* // { blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, contractAddress: null, cumulativeGasUsed: Big { s: 1, e: 6, c: [ 3, 6, 4, 6, 1, 3, 7 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, effectiveGasPrice: Big { s: 1, e: 10, c: [ 2, 6, 5, 4, 0, 6, 2, 3, 4, 0, 4 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, from: '0x642824FaB1D0141073ed74326332950bEc4701e3', gasUsed: Big { s: 1, e: 5, c: [ 1, 0, 7, 3, 0, 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, logs: [ { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 84, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074d' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 85, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074e' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 86, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074f' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 87, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000750' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 88, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000751' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 89, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000752' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 90, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000753' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 91, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000754' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 92, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000755' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 93, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000756' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 } ], logsBloom: '0x20000080004000000000000400000000000001000000000400000000000000000000000000000000000000000008000000000000000000000000000000004000000000000008000000000008000000010080000014000004000000000000000000100000020800000000000000001800000080000000002000000010000000000000000000000200000200000000002000000000000400000000000000000000000000000000000000000040000000000000000100000000000000000000040002100002000000000000080000000000000100000002000000040000001220000000000000000000000000000000000000000000000000000000000000004000', status: 1, to: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41, type: 2, byzantium: true, confirmations: 40 }
|
|
18
|
+
* ```
|
|
9
19
|
*/
|
|
10
20
|
function cleanTransactionReceipt(transactionReceipt) {
|
|
11
21
|
const cleanedTransaction = (0, clean_transaction_1.cleanTransaction)(transactionReceipt);
|
|
@@ -29,22 +39,7 @@ function cleanTransactionReceipt(transactionReceipt) {
|
|
|
29
39
|
break;
|
|
30
40
|
case 'logs':
|
|
31
41
|
transactionReceipt[key].forEach((log, index) => {
|
|
32
|
-
|
|
33
|
-
switch (logKey) {
|
|
34
|
-
case 'address':
|
|
35
|
-
cleanedTransactionReceipt[key][index][logKey] =
|
|
36
|
-
(0, __1.toChecksumAddress)(log[logKey]);
|
|
37
|
-
break;
|
|
38
|
-
case 'blockNumber':
|
|
39
|
-
case 'logIndex':
|
|
40
|
-
case 'transactionIndex':
|
|
41
|
-
cleanedTransactionReceipt[key][index][logKey] = Number((0, hex_to_decimal_1.hexToDecimal)(log[logKey]));
|
|
42
|
-
break;
|
|
43
|
-
case 'removed':
|
|
44
|
-
delete log[logKey];
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
42
|
+
cleanedTransactionReceipt[key][index] = (0, clean_log_1.cleanLog)(log, true);
|
|
48
43
|
});
|
|
49
44
|
}
|
|
50
45
|
});
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { RPCTransaction, TransactionResponse } from '../../types/Transaction.types';
|
|
2
2
|
/**
|
|
3
3
|
* Converts RPC transaction response to more JS-friendly format
|
|
4
|
+
*
|
|
5
|
+
* @param transaction the transaction to clean
|
|
6
|
+
* @returns a cleaned transaction
|
|
7
|
+
* @example
|
|
8
|
+
* ```javascript
|
|
9
|
+
* const RPCTransaction = { accessList: [], blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: '0xe28f62', chainId: '0x1', from: '0x642824fab1d0141073ed74326332950bec4701e3', gas: '0x274b7', gasPrice: '0x62df1c62c', hash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', input: '0xa0712d68000000000000000000000000000000000000000000000000000000000000000a', maxFeePerGas: '0x98808e3f0', maxPriorityFeePerGas: '0x3b9aca00', nonce: '0x42', r: '0x304682f8b22006dd1347c3722f6e43a5ad8e3a1ae51939cc0d6f07981602f5c0', s: '0x207ad110eb5c014cb628814b92396785fabfbe74542293300eeadf156f50f105', to: '0x84f80ea01e26b7c11bdd241970982c7eeab6ddcc', transactionIndex: '0x29', type: '0x2', v: '0x1', value: '0x470de4df820000' }
|
|
10
|
+
* cleanTransaction(RPCTransaction);
|
|
11
|
+
* // { accessList: [], blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, chainId: 1, from: '0x642824FaB1D0141073ed74326332950bEc4701e3', gas: Big { s: 1, e: 5, c: [ 1, 6, 0, 9, 5, 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, gasPrice: Big { s: 1, e: 10, c: [ 2, 6, 5, 4, 0, 6, 2, 3, 4, 0, 4 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, hash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', input: '0xa0712d68000000000000000000000000000000000000000000000000000000000000000a', maxFeePerGas: Big { s: 1, e: 10, c: [ 4, 0, 9, 3, 6, 9, 8, 9, 6, 8 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, maxPriorityFeePerGas: Big { s: 1, e: 9, c: [ 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, nonce: 66, r: '0x304682f8b22006dd1347c3722f6e43a5ad8e3a1ae51939cc0d6f07981602f5c0', s: '0x207ad110eb5c014cb628814b92396785fabfbe74542293300eeadf156f50f105', to: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', transactionIndex: 41, type: 2, v: 1, value: Big { s: 1, e: 16, c: [ 2 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, confirmations: 53 }
|
|
12
|
+
* ```
|
|
4
13
|
*/
|
|
5
14
|
export declare function cleanTransaction(transaction: RPCTransaction): TransactionResponse;
|
|
@@ -5,6 +5,15 @@ const __1 = require("../..");
|
|
|
5
5
|
const hex_to_decimal_1 = require("./hex-to-decimal");
|
|
6
6
|
/**
|
|
7
7
|
* Converts RPC transaction response to more JS-friendly format
|
|
8
|
+
*
|
|
9
|
+
* @param transaction the transaction to clean
|
|
10
|
+
* @returns a cleaned transaction
|
|
11
|
+
* @example
|
|
12
|
+
* ```javascript
|
|
13
|
+
* const RPCTransaction = { accessList: [], blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: '0xe28f62', chainId: '0x1', from: '0x642824fab1d0141073ed74326332950bec4701e3', gas: '0x274b7', gasPrice: '0x62df1c62c', hash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', input: '0xa0712d68000000000000000000000000000000000000000000000000000000000000000a', maxFeePerGas: '0x98808e3f0', maxPriorityFeePerGas: '0x3b9aca00', nonce: '0x42', r: '0x304682f8b22006dd1347c3722f6e43a5ad8e3a1ae51939cc0d6f07981602f5c0', s: '0x207ad110eb5c014cb628814b92396785fabfbe74542293300eeadf156f50f105', to: '0x84f80ea01e26b7c11bdd241970982c7eeab6ddcc', transactionIndex: '0x29', type: '0x2', v: '0x1', value: '0x470de4df820000' }
|
|
14
|
+
* cleanTransaction(RPCTransaction);
|
|
15
|
+
* // { accessList: [], blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, chainId: 1, from: '0x642824FaB1D0141073ed74326332950bEc4701e3', gas: Big { s: 1, e: 5, c: [ 1, 6, 0, 9, 5, 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, gasPrice: Big { s: 1, e: 10, c: [ 2, 6, 5, 4, 0, 6, 2, 3, 4, 0, 4 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, hash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', input: '0xa0712d68000000000000000000000000000000000000000000000000000000000000000a', maxFeePerGas: Big { s: 1, e: 10, c: [ 4, 0, 9, 3, 6, 9, 8, 9, 6, 8 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, maxPriorityFeePerGas: Big { s: 1, e: 9, c: [ 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, nonce: 66, r: '0x304682f8b22006dd1347c3722f6e43a5ad8e3a1ae51939cc0d6f07981602f5c0', s: '0x207ad110eb5c014cb628814b92396785fabfbe74542293300eeadf156f50f105', to: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', transactionIndex: 41, type: 2, v: 1, value: Big { s: 1, e: 16, c: [ 2 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, confirmations: 53 }
|
|
16
|
+
* ```
|
|
8
17
|
*/
|
|
9
18
|
function cleanTransaction(transaction) {
|
|
10
19
|
const cleanedTransaction = Object.assign({}, transaction);
|
|
@@ -16,7 +25,6 @@ function cleanTransaction(transaction) {
|
|
|
16
25
|
switch (key) {
|
|
17
26
|
case 'blockNumber':
|
|
18
27
|
case 'chainId':
|
|
19
|
-
case 'nonce':
|
|
20
28
|
case 'transactionIndex':
|
|
21
29
|
case 'type':
|
|
22
30
|
case 'v':
|
|
@@ -33,6 +41,7 @@ function cleanTransaction(transaction) {
|
|
|
33
41
|
case 'gasPrice':
|
|
34
42
|
case 'maxFeePerGas':
|
|
35
43
|
case 'maxPriorityFeePerGas':
|
|
44
|
+
case 'nonce':
|
|
36
45
|
cleanedTransaction[key] = (0, __1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(transaction[key]));
|
|
37
46
|
break;
|
|
38
47
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { JSONABIArgument } from '../../types/Contract.types';
|
|
2
2
|
export declare const hexFalse: string;
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param jsonABIArgument
|
|
6
|
+
* @param args
|
|
7
|
+
* @example
|
|
8
|
+
*/
|
|
3
9
|
export declare function encodeData(jsonABIArgument: JSONABIArgument, args: any[]): string;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param jsonABIArgument
|
|
13
|
+
* @param nodeResponse
|
|
14
|
+
* @example
|
|
15
|
+
*/
|
|
4
16
|
export declare function decodeRPCResponse(jsonABIArgument: JSONABIArgument, nodeResponse: string): string | number | boolean | import("../..").TinyBig | (string | number | boolean | import("../..").TinyBig)[];
|