quantumcoin 6.14.2 → 6.14.5
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/CHANGELOG.md +442 -442
- package/FUNDING.json +10 -10
- package/LICENSE.md +21 -21
- package/README.md +132 -142
- package/SECURITY.md +34 -34
- package/dist/README.md +22 -22
- package/dist/quantumcoin.js +1127 -1324
- package/dist/quantumcoin.js.map +1 -1
- package/dist/quantumcoin.min.js +1 -1
- package/dist/quantumcoin.umd.js +1128 -1327
- package/dist/quantumcoin.umd.js.map +1 -1
- package/dist/quantumcoin.umd.min.js +1 -1
- package/dist/wordlists-extra.js +1 -1
- package/dist/wordlists-extra.js.map +1 -1
- package/dist/wordlists-extra.min.js +1 -1
- package/lib.commonjs/README.md +16 -16
- package/lib.commonjs/_version.js +1 -1
- package/lib.commonjs/crypto/signature.d.ts +3 -76
- package/lib.commonjs/crypto/signature.d.ts.map +1 -1
- package/lib.commonjs/crypto/signature.js +15 -199
- package/lib.commonjs/crypto/signature.js.map +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
- package/lib.commonjs/crypto/signing-key.js +19 -10
- package/lib.commonjs/crypto/signing-key.js.map +1 -1
- package/lib.commonjs/package.json +12 -12
- package/lib.commonjs/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.commonjs/providers/provider-jsonrpc.js +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.js.map +1 -1
- package/lib.commonjs/quantumcoin.d.ts +2 -0
- package/lib.commonjs/quantumcoin.d.ts.map +1 -1
- package/lib.commonjs/quantumcoin.js +11 -5
- package/lib.commonjs/quantumcoin.js.map +1 -1
- package/lib.commonjs/transaction/address.d.ts.map +1 -1
- package/lib.commonjs/transaction/address.js +8 -3
- package/lib.commonjs/transaction/address.js.map +1 -1
- package/lib.commonjs/transaction/transaction.d.ts.map +1 -1
- package/lib.commonjs/transaction/transaction.js +7 -40
- package/lib.commonjs/transaction/transaction.js.map +1 -1
- package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
- package/lib.commonjs/wallet/json-keystore.js +7 -7
- package/lib.commonjs/wallet/json-keystore.js.map +1 -1
- package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
- package/lib.commonjs/wallet/wallet.js +2 -2
- package/lib.commonjs/wallet/wallet.js.map +1 -1
- package/lib.esm/README.md +16 -16
- package/lib.esm/_version.js +1 -1
- package/lib.esm/crypto/signature.d.ts +3 -76
- package/lib.esm/crypto/signature.d.ts.map +1 -1
- package/lib.esm/crypto/signature.js +16 -202
- package/lib.esm/crypto/signature.js.map +1 -1
- package/lib.esm/crypto/signing-key.d.ts +1 -1
- package/lib.esm/crypto/signing-key.d.ts.map +1 -1
- package/lib.esm/crypto/signing-key.js +20 -9
- package/lib.esm/crypto/signing-key.js.map +1 -1
- package/lib.esm/package.json +12 -12
- package/lib.esm/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.esm/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.esm/providers/provider-jsonrpc.js +0 -1
- package/lib.esm/providers/provider-jsonrpc.js.map +1 -1
- package/lib.esm/quantumcoin.d.ts +2 -0
- package/lib.esm/quantumcoin.d.ts.map +1 -1
- package/lib.esm/quantumcoin.js +6 -0
- package/lib.esm/quantumcoin.js.map +1 -1
- package/lib.esm/transaction/address.d.ts.map +1 -1
- package/lib.esm/transaction/address.js +8 -2
- package/lib.esm/transaction/address.js.map +1 -1
- package/lib.esm/transaction/transaction.d.ts.map +1 -1
- package/lib.esm/transaction/transaction.js +7 -40
- package/lib.esm/transaction/transaction.js.map +1 -1
- package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
- package/lib.esm/wallet/json-keystore.js +11 -5
- package/lib.esm/wallet/json-keystore.js.map +1 -1
- package/lib.esm/wallet/wallet.d.ts.map +1 -1
- package/lib.esm/wallet/wallet.js +3 -1
- package/lib.esm/wallet/wallet.js.map +1 -1
- package/package.json +6 -5
- package/rollup.config.mjs +50 -50
- package/src.ts/_version.ts +1 -1
- package/src.ts/abi/abi-coder.ts +237 -237
- package/src.ts/abi/bytes32.ts +45 -45
- package/src.ts/abi/coders/abstract-coder.ts +541 -541
- package/src.ts/abi/coders/address.ts +36 -36
- package/src.ts/abi/coders/anonymous.ts +29 -29
- package/src.ts/abi/coders/array.ts +199 -199
- package/src.ts/abi/coders/boolean.ts +27 -27
- package/src.ts/abi/coders/bytes.ts +43 -43
- package/src.ts/abi/coders/fixed-bytes.ts +37 -37
- package/src.ts/abi/coders/null.ts +28 -28
- package/src.ts/abi/coders/number.ts +63 -63
- package/src.ts/abi/coders/string.ts +29 -29
- package/src.ts/abi/coders/tuple.ts +69 -69
- package/src.ts/abi/fragments.ts +1617 -1617
- package/src.ts/abi/index.ts +41 -41
- package/src.ts/abi/interface.ts +1271 -1271
- package/src.ts/abi/typed.ts +796 -796
- package/src.ts/address/address.ts +148 -148
- package/src.ts/address/checks.ts +123 -123
- package/src.ts/address/contract-address.ts +80 -80
- package/src.ts/address/index.ts +57 -57
- package/src.ts/constants/addresses.ts +8 -8
- package/src.ts/constants/hashes.ts +7 -7
- package/src.ts/constants/index.ts +16 -16
- package/src.ts/constants/numbers.ts +35 -35
- package/src.ts/constants/strings.ts +16 -16
- package/src.ts/contract/contract.ts +1120 -1120
- package/src.ts/contract/factory.ts +143 -143
- package/src.ts/contract/index.ts +31 -31
- package/src.ts/contract/types.ts +236 -236
- package/src.ts/contract/wrappers.ts +225 -225
- package/src.ts/crypto/crypto-browser.ts +64 -64
- package/src.ts/crypto/crypto.ts +4 -4
- package/src.ts/crypto/hmac.ts +51 -51
- package/src.ts/crypto/index.ts +59 -59
- package/src.ts/crypto/keccak.ts +54 -54
- package/src.ts/crypto/pbkdf2.ts +55 -55
- package/src.ts/crypto/random.ts +36 -36
- package/src.ts/crypto/ripemd160.ts +43 -43
- package/src.ts/crypto/scrypt.ts +114 -114
- package/src.ts/crypto/sha2.ts +78 -78
- package/src.ts/crypto/signature.ts +145 -349
- package/src.ts/crypto/signing-key.ts +126 -118
- package/src.ts/hash/authorization.ts +38 -38
- package/src.ts/hash/id.ts +17 -17
- package/src.ts/hash/index.ts +18 -18
- package/src.ts/hash/message.ts +51 -51
- package/src.ts/hash/namehash.ts +101 -101
- package/src.ts/hash/solidity.ts +117 -117
- package/src.ts/hash/typed-data.ts +658 -658
- package/src.ts/index.ts +12 -12
- package/src.ts/providers/abstract-provider.ts +1761 -1761
- package/src.ts/providers/abstract-signer.ts +314 -314
- package/src.ts/providers/community.ts +49 -49
- package/src.ts/providers/contracts.ts +42 -42
- package/src.ts/providers/default-provider.ts +96 -96
- package/src.ts/providers/ens-resolver.ts +606 -606
- package/src.ts/providers/format.ts +320 -320
- package/src.ts/providers/formatting.ts +418 -418
- package/src.ts/providers/index.ts +125 -125
- package/src.ts/providers/network.ts +327 -327
- package/src.ts/providers/pagination.ts +8 -8
- package/src.ts/providers/plugin-fallback.ts +35 -35
- package/src.ts/providers/plugins-network.ts +281 -281
- package/src.ts/providers/provider-browser.ts +334 -334
- package/src.ts/providers/provider-fallback.ts +801 -801
- package/src.ts/providers/provider-ipcsocket-browser.ts +3 -3
- package/src.ts/providers/provider-ipcsocket.ts +81 -81
- package/src.ts/providers/provider-jsonrpc.ts +1334 -1335
- package/src.ts/providers/provider-socket.ts +352 -352
- package/src.ts/providers/provider-websocket.ts +103 -103
- package/src.ts/providers/provider.ts +2136 -2136
- package/src.ts/providers/signer-noncemanager.ts +98 -98
- package/src.ts/providers/signer.ts +166 -166
- package/src.ts/providers/subscriber-connection.ts +74 -74
- package/src.ts/providers/subscriber-filterid.ts +199 -199
- package/src.ts/providers/subscriber-polling.ts +321 -321
- package/src.ts/providers/ws-browser.ts +11 -11
- package/src.ts/providers/ws.ts +3 -3
- package/src.ts/quantumcoin.ts +219 -211
- package/src.ts/thirdparty.d.ts +16 -16
- package/src.ts/transaction/accesslist.ts +43 -43
- package/src.ts/transaction/address.ts +35 -31
- package/src.ts/transaction/authorization.ts +14 -14
- package/src.ts/transaction/index.ts +51 -51
- package/src.ts/transaction/transaction.ts +1349 -1379
- package/src.ts/utils/base58.ts +73 -73
- package/src.ts/utils/base64-browser.ts +25 -25
- package/src.ts/utils/base64.ts +56 -56
- package/src.ts/utils/data.ts +199 -199
- package/src.ts/utils/errors.ts +793 -793
- package/src.ts/utils/events.ts +105 -105
- package/src.ts/utils/fetch.ts +970 -970
- package/src.ts/utils/fixednumber.ts +643 -643
- package/src.ts/utils/geturl-browser.ts +81 -81
- package/src.ts/utils/geturl.ts +134 -134
- package/src.ts/utils/index.ts +95 -95
- package/src.ts/utils/maths.ts +240 -240
- package/src.ts/utils/properties.ts +60 -60
- package/src.ts/utils/rlp-decode.ts +104 -104
- package/src.ts/utils/rlp-encode.ts +64 -64
- package/src.ts/utils/rlp.ts +20 -20
- package/src.ts/utils/units.ts +91 -91
- package/src.ts/utils/utf8.ts +325 -325
- package/src.ts/utils/uuid.ts +36 -36
- package/src.ts/wallet/base-wallet.ts +160 -160
- package/src.ts/wallet/index.ts +32 -32
- package/src.ts/wallet/json-keystore.ts +108 -106
- package/src.ts/wallet/utils.ts +147 -147
- package/src.ts/wallet/wallet.ts +138 -139
- package/src.ts/wordlists/bit-reader.ts +35 -35
- package/src.ts/wordlists/decode-owl.ts +58 -58
- package/src.ts/wordlists/decode-owla.ts +33 -33
- package/src.ts/wordlists/generation/encode-latin.ts +370 -370
- package/src.ts/wordlists/index.ts +26 -26
- package/src.ts/wordlists/lang-cz.ts +33 -33
- package/src.ts/wordlists/lang-en.ts +33 -33
- package/src.ts/wordlists/lang-es.ts +35 -35
- package/src.ts/wordlists/lang-fr.ts +34 -34
- package/src.ts/wordlists/lang-it.ts +33 -33
- package/src.ts/wordlists/lang-ja.ts +181 -181
- package/src.ts/wordlists/lang-ko.ts +104 -104
- package/src.ts/wordlists/lang-pt.ts +34 -34
- package/src.ts/wordlists/lang-zh.ts +112 -112
- package/src.ts/wordlists/wordlist-owl.ts +77 -77
- package/src.ts/wordlists/wordlist-owla.ts +41 -41
- package/src.ts/wordlists/wordlist.ts +59 -59
- package/src.ts/wordlists/wordlists-browser.ts +8 -8
- package/src.ts/wordlists/wordlists-extra.ts +9 -9
- package/src.ts/wordlists/wordlists.ts +38 -38
- package/dist/quantumcoin.min.js'.gz' +0 -0
- package/dist/quantumcoin.umd.min.js'.gz' +0 -0
- package/dist/wordlists-extra.min.js'.gz' +0 -0
- package/lib.commonjs/providers/provider-alchemy.d.ts +0 -50
- package/lib.commonjs/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-alchemy.js +0 -151
- package/lib.commonjs/providers/provider-alchemy.js.map +0 -1
- package/lib.commonjs/providers/provider-ankr.d.ts +0 -61
- package/lib.commonjs/providers/provider-ankr.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-ankr.js +0 -137
- package/lib.commonjs/providers/provider-ankr.js.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.d.ts +0 -59
- package/lib.commonjs/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.js +0 -145
- package/lib.commonjs/providers/provider-blockscout.js.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.d.ts +0 -46
- package/lib.commonjs/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.js +0 -102
- package/lib.commonjs/providers/provider-chainstack.js.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.d.ts +0 -14
- package/lib.commonjs/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.js +0 -26
- package/lib.commonjs/providers/provider-cloudflare.js.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.d.ts +0 -147
- package/lib.commonjs/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.js +0 -587
- package/lib.commonjs/providers/provider-etherscan.js.map +0 -1
- package/lib.commonjs/providers/provider-infura.d.ts +0 -101
- package/lib.commonjs/providers/provider-infura.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-infura.js +0 -206
- package/lib.commonjs/providers/provider-infura.js.map +0 -1
- package/lib.commonjs/providers/provider-pocket.d.ts +0 -54
- package/lib.commonjs/providers/provider-pocket.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-pocket.js +0 -109
- package/lib.commonjs/providers/provider-pocket.js.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.d.ts +0 -59
- package/lib.commonjs/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.js +0 -163
- package/lib.commonjs/providers/provider-quicknode.js.map +0 -1
- package/lib.commonjs/wallet/hdwallet.d.ts +0 -248
- package/lib.commonjs/wallet/hdwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/hdwallet.js +0 -505
- package/lib.commonjs/wallet/hdwallet.js.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.d.ts +0 -27
- package/lib.commonjs/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.js +0 -60
- package/lib.commonjs/wallet/json-crowdsale.js.map +0 -1
- package/lib.commonjs/wallet/mnemonic.d.ts +0 -65
- package/lib.commonjs/wallet/mnemonic.d.ts.map +0 -1
- package/lib.commonjs/wallet/mnemonic.js +0 -169
- package/lib.commonjs/wallet/mnemonic.js.map +0 -1
- package/lib.commonjs/wallet/seedwallet.d.ts +0 -4
- package/lib.commonjs/wallet/seedwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/seedwallet.js +0 -8
- package/lib.commonjs/wallet/seedwallet.js.map +0 -1
- package/lib.esm/providers/provider-alchemy.d.ts +0 -50
- package/lib.esm/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.esm/providers/provider-alchemy.js +0 -147
- package/lib.esm/providers/provider-alchemy.js.map +0 -1
- package/lib.esm/providers/provider-ankr.d.ts +0 -61
- package/lib.esm/providers/provider-ankr.d.ts.map +0 -1
- package/lib.esm/providers/provider-ankr.js +0 -133
- package/lib.esm/providers/provider-ankr.js.map +0 -1
- package/lib.esm/providers/provider-blockscout.d.ts +0 -59
- package/lib.esm/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.esm/providers/provider-blockscout.js +0 -141
- package/lib.esm/providers/provider-blockscout.js.map +0 -1
- package/lib.esm/providers/provider-chainstack.d.ts +0 -46
- package/lib.esm/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.esm/providers/provider-chainstack.js +0 -98
- package/lib.esm/providers/provider-chainstack.js.map +0 -1
- package/lib.esm/providers/provider-cloudflare.d.ts +0 -14
- package/lib.esm/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.esm/providers/provider-cloudflare.js +0 -22
- package/lib.esm/providers/provider-cloudflare.js.map +0 -1
- package/lib.esm/providers/provider-etherscan.d.ts +0 -147
- package/lib.esm/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.esm/providers/provider-etherscan.js +0 -584
- package/lib.esm/providers/provider-etherscan.js.map +0 -1
- package/lib.esm/providers/provider-infura.d.ts +0 -101
- package/lib.esm/providers/provider-infura.d.ts.map +0 -1
- package/lib.esm/providers/provider-infura.js +0 -201
- package/lib.esm/providers/provider-infura.js.map +0 -1
- package/lib.esm/providers/provider-pocket.d.ts +0 -54
- package/lib.esm/providers/provider-pocket.d.ts.map +0 -1
- package/lib.esm/providers/provider-pocket.js +0 -105
- package/lib.esm/providers/provider-pocket.js.map +0 -1
- package/lib.esm/providers/provider-quicknode.d.ts +0 -59
- package/lib.esm/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.esm/providers/provider-quicknode.js +0 -159
- package/lib.esm/providers/provider-quicknode.js.map +0 -1
- package/lib.esm/wallet/hdwallet.d.ts +0 -248
- package/lib.esm/wallet/hdwallet.d.ts.map +0 -1
- package/lib.esm/wallet/hdwallet.js +0 -498
- package/lib.esm/wallet/hdwallet.js.map +0 -1
- package/lib.esm/wallet/json-crowdsale.d.ts +0 -27
- package/lib.esm/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.esm/wallet/json-crowdsale.js +0 -55
- package/lib.esm/wallet/json-crowdsale.js.map +0 -1
- package/lib.esm/wallet/mnemonic.d.ts +0 -65
- package/lib.esm/wallet/mnemonic.d.ts.map +0 -1
- package/lib.esm/wallet/mnemonic.js +0 -165
- package/lib.esm/wallet/mnemonic.js.map +0 -1
- package/lib.esm/wallet/seedwallet.d.ts +0 -4
- package/lib.esm/wallet/seedwallet.d.ts.map +0 -1
- package/lib.esm/wallet/seedwallet.js +0 -4
- package/lib.esm/wallet/seedwallet.js.map +0 -1
|
@@ -1,320 +1,320 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @_ignore
|
|
3
|
-
*/
|
|
4
|
-
import { getAddress, getCreateAddress } from "../address/index.js";
|
|
5
|
-
import { Signature } from "../crypto/index.js"
|
|
6
|
-
import { accessListify } from "../transaction/index.js";
|
|
7
|
-
import {
|
|
8
|
-
getBigInt, getNumber, hexlify, isHexString, zeroPadValue,
|
|
9
|
-
assert, assertArgument
|
|
10
|
-
} from "../utils/index.js";
|
|
11
|
-
|
|
12
|
-
import type {
|
|
13
|
-
BlockParams, LogParams,
|
|
14
|
-
TransactionReceiptParams, TransactionResponseParams,
|
|
15
|
-
} from "./formatting.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const BN_0 = BigInt(0);
|
|
19
|
-
|
|
20
|
-
export type FormatFunc = (value: any) => any;
|
|
21
|
-
|
|
22
|
-
export function allowNull(format: FormatFunc, nullValue?: any): FormatFunc {
|
|
23
|
-
return (function(value: any) {
|
|
24
|
-
if (value == null) { return nullValue; }
|
|
25
|
-
return format(value);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function arrayOf(format: FormatFunc, allowNull?: boolean): FormatFunc {
|
|
30
|
-
return ((array: any) => {
|
|
31
|
-
if (allowNull && array == null) { return null; }
|
|
32
|
-
if (!Array.isArray(array)) { throw new Error("not an array"); }
|
|
33
|
-
return array.map((i) => format(i));
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Requires an object which matches a fleet of other formatters
|
|
38
|
-
// Any FormatFunc may return `undefined` to have the value omitted
|
|
39
|
-
// from the result object. Calls preserve `this`.
|
|
40
|
-
export function object(format: Record<string, FormatFunc>, altNames?: Record<string, Array<string>>): FormatFunc {
|
|
41
|
-
return ((value: any) => {
|
|
42
|
-
const result: any = { };
|
|
43
|
-
for (const key in format) {
|
|
44
|
-
let srcKey = key;
|
|
45
|
-
if (altNames && key in altNames && !(srcKey in value)) {
|
|
46
|
-
for (const altKey of altNames[key]) {
|
|
47
|
-
if (altKey in value) {
|
|
48
|
-
srcKey = altKey;
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const nv = format[key](value[srcKey]);
|
|
56
|
-
if (nv !== undefined) { result[key] = nv; }
|
|
57
|
-
} catch (error) {
|
|
58
|
-
const message = (error instanceof Error) ? error.message: "not-an-error";
|
|
59
|
-
assert(false, `invalid value for value.${ key } (${ message })`, "BAD_DATA", { value })
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function formatBoolean(value: any): boolean {
|
|
67
|
-
switch (value) {
|
|
68
|
-
case true: case "true":
|
|
69
|
-
return true;
|
|
70
|
-
case false: case "false":
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
assertArgument(false, `invalid boolean; ${ JSON.stringify(value) }`, "value", value);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function formatData(value: string): string {
|
|
77
|
-
assertArgument(isHexString(value, true), "invalid data", "value", value);
|
|
78
|
-
return value;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function formatHash(value: any): string {
|
|
82
|
-
assertArgument(isHexString(value, 32), "invalid hash", "value", value);
|
|
83
|
-
return value;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function formatUint256(value: any): string {
|
|
87
|
-
if (!isHexString(value)) {
|
|
88
|
-
throw new Error("invalid uint256");
|
|
89
|
-
}
|
|
90
|
-
return zeroPadValue(value, 32);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const _formatLog = object({
|
|
94
|
-
address: getAddress,
|
|
95
|
-
blockHash: formatHash,
|
|
96
|
-
blockNumber: getNumber,
|
|
97
|
-
data: formatData,
|
|
98
|
-
index: getNumber,
|
|
99
|
-
removed: allowNull(formatBoolean, false),
|
|
100
|
-
topics: arrayOf(formatHash),
|
|
101
|
-
transactionHash: formatHash,
|
|
102
|
-
transactionIndex: getNumber,
|
|
103
|
-
}, {
|
|
104
|
-
index: [ "logIndex" ]
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
export function formatLog(value: any): LogParams {
|
|
108
|
-
return _formatLog(value);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const _formatBlock = object({
|
|
112
|
-
hash: allowNull(formatHash),
|
|
113
|
-
parentHash: formatHash,
|
|
114
|
-
parentBeaconBlockRoot: allowNull(formatHash, null),
|
|
115
|
-
|
|
116
|
-
number: getNumber,
|
|
117
|
-
|
|
118
|
-
timestamp: getNumber,
|
|
119
|
-
nonce: allowNull(formatData),
|
|
120
|
-
difficulty: getBigInt,
|
|
121
|
-
|
|
122
|
-
gasLimit: getBigInt,
|
|
123
|
-
gasUsed: getBigInt,
|
|
124
|
-
|
|
125
|
-
stateRoot: allowNull(formatHash, null),
|
|
126
|
-
receiptsRoot: allowNull(formatHash, null),
|
|
127
|
-
|
|
128
|
-
blobGasUsed: allowNull(getBigInt, null),
|
|
129
|
-
excessBlobGas: allowNull(getBigInt, null),
|
|
130
|
-
|
|
131
|
-
miner: allowNull(getAddress),
|
|
132
|
-
prevRandao: allowNull(formatHash, null),
|
|
133
|
-
extraData: formatData,
|
|
134
|
-
|
|
135
|
-
baseFeePerGas: allowNull(getBigInt)
|
|
136
|
-
}, {
|
|
137
|
-
prevRandao: [ "mixHash" ]
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
export function formatBlock(value: any): BlockParams {
|
|
141
|
-
const result = _formatBlock(value);
|
|
142
|
-
result.transactions = value.transactions.map((tx: string | TransactionResponseParams) => {
|
|
143
|
-
if (typeof(tx) === "string") { return tx; }
|
|
144
|
-
return formatTransactionResponse(tx);
|
|
145
|
-
});
|
|
146
|
-
return result;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const _formatReceiptLog = object({
|
|
150
|
-
transactionIndex: getNumber,
|
|
151
|
-
blockNumber: getNumber,
|
|
152
|
-
transactionHash: formatHash,
|
|
153
|
-
address: getAddress,
|
|
154
|
-
topics: arrayOf(formatHash),
|
|
155
|
-
data: formatData,
|
|
156
|
-
index: getNumber,
|
|
157
|
-
blockHash: formatHash,
|
|
158
|
-
}, {
|
|
159
|
-
index: [ "logIndex" ]
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
export function formatReceiptLog(value: any): LogParams {
|
|
163
|
-
return _formatReceiptLog(value);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const _formatTransactionReceipt = object({
|
|
167
|
-
to: allowNull(getAddress, null),
|
|
168
|
-
from: allowNull(getAddress, null),
|
|
169
|
-
contractAddress: allowNull(getAddress, null),
|
|
170
|
-
// should be allowNull(hash), but broken-EIP-658 support is handled in receipt
|
|
171
|
-
index: getNumber,
|
|
172
|
-
root: allowNull(hexlify),
|
|
173
|
-
gasUsed: getBigInt,
|
|
174
|
-
blobGasUsed: allowNull(getBigInt, null),
|
|
175
|
-
logsBloom: allowNull(formatData),
|
|
176
|
-
blockHash: formatHash,
|
|
177
|
-
hash: formatHash,
|
|
178
|
-
logs: arrayOf(formatReceiptLog),
|
|
179
|
-
blockNumber: getNumber,
|
|
180
|
-
//confirmations: allowNull(getNumber, null),
|
|
181
|
-
cumulativeGasUsed: getBigInt,
|
|
182
|
-
effectiveGasPrice: allowNull(getBigInt),
|
|
183
|
-
blobGasPrice: allowNull(getBigInt, null),
|
|
184
|
-
status: allowNull(getNumber),
|
|
185
|
-
type: allowNull(getNumber, 0)
|
|
186
|
-
}, {
|
|
187
|
-
effectiveGasPrice: [ "gasPrice" ],
|
|
188
|
-
hash: [ "transactionHash" ],
|
|
189
|
-
index: [ "transactionIndex" ],
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
export function formatTransactionReceipt(value: any): TransactionReceiptParams {
|
|
193
|
-
return _formatTransactionReceipt(value);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export function formatTransactionResponse(value: any): TransactionResponseParams {
|
|
197
|
-
|
|
198
|
-
// Some clients (TestRPC) do strange things like return 0x0 for the
|
|
199
|
-
// 0 address; correct this to be a real address
|
|
200
|
-
if (value.to && getBigInt(value.to) === BN_0) {
|
|
201
|
-
value.to = "0x0000000000000000000000000000000000000000";
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const result = object({
|
|
205
|
-
hash: formatHash,
|
|
206
|
-
|
|
207
|
-
// Some nodes do not return this, usually test nodes (like Ganache)
|
|
208
|
-
index: allowNull(getNumber, undefined),
|
|
209
|
-
|
|
210
|
-
type: (value: any) => {
|
|
211
|
-
if (value === "0x" || value == null) { return 0; }
|
|
212
|
-
return getNumber(value);
|
|
213
|
-
},
|
|
214
|
-
accessList: allowNull(accessListify, null),
|
|
215
|
-
blobVersionedHashes: allowNull(arrayOf(formatHash, true), null),
|
|
216
|
-
|
|
217
|
-
authorizationList: allowNull(arrayOf((v: any) => {
|
|
218
|
-
return {
|
|
219
|
-
address: getAddress(v.address),
|
|
220
|
-
chainId: getBigInt(v.chainId),
|
|
221
|
-
nonce: getBigInt(v.nonce),
|
|
222
|
-
signature: Signature.from(v.signature ? v.signature: v)
|
|
223
|
-
};
|
|
224
|
-
}, false), null),
|
|
225
|
-
|
|
226
|
-
blockHash: allowNull(formatHash, null),
|
|
227
|
-
blockNumber: allowNull(getNumber, null),
|
|
228
|
-
transactionIndex: allowNull(getNumber, null),
|
|
229
|
-
|
|
230
|
-
from: getAddress,
|
|
231
|
-
|
|
232
|
-
// either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set
|
|
233
|
-
gasPrice: allowNull(getBigInt),
|
|
234
|
-
maxPriorityFeePerGas: allowNull(getBigInt),
|
|
235
|
-
maxFeePerGas: allowNull(getBigInt),
|
|
236
|
-
maxFeePerBlobGas: allowNull(getBigInt, null),
|
|
237
|
-
|
|
238
|
-
gasLimit: getBigInt,
|
|
239
|
-
to: allowNull(getAddress, null),
|
|
240
|
-
value: getBigInt,
|
|
241
|
-
nonce: getNumber,
|
|
242
|
-
data: formatData,
|
|
243
|
-
|
|
244
|
-
creates: allowNull(getAddress, null),
|
|
245
|
-
|
|
246
|
-
chainId: allowNull(getBigInt, null)
|
|
247
|
-
}, {
|
|
248
|
-
data: [ "input" ],
|
|
249
|
-
gasLimit: [ "gas" ],
|
|
250
|
-
index: [ "transactionIndex" ]
|
|
251
|
-
})(value);
|
|
252
|
-
|
|
253
|
-
// If to and creates are empty, populate the creates from the value
|
|
254
|
-
if (result.to == null && result.creates == null) {
|
|
255
|
-
result.creates = getCreateAddress(result);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// @TODO: Check fee data
|
|
259
|
-
|
|
260
|
-
// Add an access list to supported transaction types
|
|
261
|
-
if ((value.type === 1 || value.type === 2) && value.accessList == null) {
|
|
262
|
-
result.accessList = [ ];
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Compute the signature
|
|
266
|
-
if (value.signature) {
|
|
267
|
-
result.signature = Signature.from(value.signature);
|
|
268
|
-
} else {
|
|
269
|
-
result.signature = Signature.from(value);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Some backends omit ChainId on legacy transactions, but we can compute it
|
|
273
|
-
if (result.chainId == null) {
|
|
274
|
-
const chainId = result.signature.legacyChainId;
|
|
275
|
-
if (chainId != null) { result.chainId = chainId; }
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
// @TODO: check chainID
|
|
280
|
-
/*
|
|
281
|
-
if (value.chainId != null) {
|
|
282
|
-
let chainId = value.chainId;
|
|
283
|
-
|
|
284
|
-
if (isHexString(chainId)) {
|
|
285
|
-
chainId = BigNumber.from(chainId).toNumber();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
result.chainId = chainId;
|
|
289
|
-
|
|
290
|
-
} else {
|
|
291
|
-
let chainId = value.networkId;
|
|
292
|
-
|
|
293
|
-
// geth-etc returns chainId
|
|
294
|
-
if (chainId == null && result.v == null) {
|
|
295
|
-
chainId = value.chainId;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (isHexString(chainId)) {
|
|
299
|
-
chainId = BigNumber.from(chainId).toNumber();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (typeof(chainId) !== "number" && result.v != null) {
|
|
303
|
-
chainId = (result.v - 35) / 2;
|
|
304
|
-
if (chainId < 0) { chainId = 0; }
|
|
305
|
-
chainId = parseInt(chainId);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (typeof(chainId) !== "number") { chainId = 0; }
|
|
309
|
-
|
|
310
|
-
result.chainId = chainId;
|
|
311
|
-
}
|
|
312
|
-
*/
|
|
313
|
-
|
|
314
|
-
// 0x0000... should actually be null
|
|
315
|
-
if (result.blockHash && getBigInt(result.blockHash) === BN_0) {
|
|
316
|
-
result.blockHash = null;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return result;
|
|
320
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @_ignore
|
|
3
|
+
*/
|
|
4
|
+
import { getAddress, getCreateAddress } from "../address/index.js";
|
|
5
|
+
import { Signature } from "../crypto/index.js"
|
|
6
|
+
import { accessListify } from "../transaction/index.js";
|
|
7
|
+
import {
|
|
8
|
+
getBigInt, getNumber, hexlify, isHexString, zeroPadValue,
|
|
9
|
+
assert, assertArgument
|
|
10
|
+
} from "../utils/index.js";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
BlockParams, LogParams,
|
|
14
|
+
TransactionReceiptParams, TransactionResponseParams,
|
|
15
|
+
} from "./formatting.js";
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const BN_0 = BigInt(0);
|
|
19
|
+
|
|
20
|
+
export type FormatFunc = (value: any) => any;
|
|
21
|
+
|
|
22
|
+
export function allowNull(format: FormatFunc, nullValue?: any): FormatFunc {
|
|
23
|
+
return (function(value: any) {
|
|
24
|
+
if (value == null) { return nullValue; }
|
|
25
|
+
return format(value);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function arrayOf(format: FormatFunc, allowNull?: boolean): FormatFunc {
|
|
30
|
+
return ((array: any) => {
|
|
31
|
+
if (allowNull && array == null) { return null; }
|
|
32
|
+
if (!Array.isArray(array)) { throw new Error("not an array"); }
|
|
33
|
+
return array.map((i) => format(i));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Requires an object which matches a fleet of other formatters
|
|
38
|
+
// Any FormatFunc may return `undefined` to have the value omitted
|
|
39
|
+
// from the result object. Calls preserve `this`.
|
|
40
|
+
export function object(format: Record<string, FormatFunc>, altNames?: Record<string, Array<string>>): FormatFunc {
|
|
41
|
+
return ((value: any) => {
|
|
42
|
+
const result: any = { };
|
|
43
|
+
for (const key in format) {
|
|
44
|
+
let srcKey = key;
|
|
45
|
+
if (altNames && key in altNames && !(srcKey in value)) {
|
|
46
|
+
for (const altKey of altNames[key]) {
|
|
47
|
+
if (altKey in value) {
|
|
48
|
+
srcKey = altKey;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const nv = format[key](value[srcKey]);
|
|
56
|
+
if (nv !== undefined) { result[key] = nv; }
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const message = (error instanceof Error) ? error.message: "not-an-error";
|
|
59
|
+
assert(false, `invalid value for value.${ key } (${ message })`, "BAD_DATA", { value })
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function formatBoolean(value: any): boolean {
|
|
67
|
+
switch (value) {
|
|
68
|
+
case true: case "true":
|
|
69
|
+
return true;
|
|
70
|
+
case false: case "false":
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
assertArgument(false, `invalid boolean; ${ JSON.stringify(value) }`, "value", value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function formatData(value: string): string {
|
|
77
|
+
assertArgument(isHexString(value, true), "invalid data", "value", value);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function formatHash(value: any): string {
|
|
82
|
+
assertArgument(isHexString(value, 32), "invalid hash", "value", value);
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function formatUint256(value: any): string {
|
|
87
|
+
if (!isHexString(value)) {
|
|
88
|
+
throw new Error("invalid uint256");
|
|
89
|
+
}
|
|
90
|
+
return zeroPadValue(value, 32);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const _formatLog = object({
|
|
94
|
+
address: getAddress,
|
|
95
|
+
blockHash: formatHash,
|
|
96
|
+
blockNumber: getNumber,
|
|
97
|
+
data: formatData,
|
|
98
|
+
index: getNumber,
|
|
99
|
+
removed: allowNull(formatBoolean, false),
|
|
100
|
+
topics: arrayOf(formatHash),
|
|
101
|
+
transactionHash: formatHash,
|
|
102
|
+
transactionIndex: getNumber,
|
|
103
|
+
}, {
|
|
104
|
+
index: [ "logIndex" ]
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export function formatLog(value: any): LogParams {
|
|
108
|
+
return _formatLog(value);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const _formatBlock = object({
|
|
112
|
+
hash: allowNull(formatHash),
|
|
113
|
+
parentHash: formatHash,
|
|
114
|
+
parentBeaconBlockRoot: allowNull(formatHash, null),
|
|
115
|
+
|
|
116
|
+
number: getNumber,
|
|
117
|
+
|
|
118
|
+
timestamp: getNumber,
|
|
119
|
+
nonce: allowNull(formatData),
|
|
120
|
+
difficulty: getBigInt,
|
|
121
|
+
|
|
122
|
+
gasLimit: getBigInt,
|
|
123
|
+
gasUsed: getBigInt,
|
|
124
|
+
|
|
125
|
+
stateRoot: allowNull(formatHash, null),
|
|
126
|
+
receiptsRoot: allowNull(formatHash, null),
|
|
127
|
+
|
|
128
|
+
blobGasUsed: allowNull(getBigInt, null),
|
|
129
|
+
excessBlobGas: allowNull(getBigInt, null),
|
|
130
|
+
|
|
131
|
+
miner: allowNull(getAddress),
|
|
132
|
+
prevRandao: allowNull(formatHash, null),
|
|
133
|
+
extraData: formatData,
|
|
134
|
+
|
|
135
|
+
baseFeePerGas: allowNull(getBigInt)
|
|
136
|
+
}, {
|
|
137
|
+
prevRandao: [ "mixHash" ]
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export function formatBlock(value: any): BlockParams {
|
|
141
|
+
const result = _formatBlock(value);
|
|
142
|
+
result.transactions = value.transactions.map((tx: string | TransactionResponseParams) => {
|
|
143
|
+
if (typeof(tx) === "string") { return tx; }
|
|
144
|
+
return formatTransactionResponse(tx);
|
|
145
|
+
});
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const _formatReceiptLog = object({
|
|
150
|
+
transactionIndex: getNumber,
|
|
151
|
+
blockNumber: getNumber,
|
|
152
|
+
transactionHash: formatHash,
|
|
153
|
+
address: getAddress,
|
|
154
|
+
topics: arrayOf(formatHash),
|
|
155
|
+
data: formatData,
|
|
156
|
+
index: getNumber,
|
|
157
|
+
blockHash: formatHash,
|
|
158
|
+
}, {
|
|
159
|
+
index: [ "logIndex" ]
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
export function formatReceiptLog(value: any): LogParams {
|
|
163
|
+
return _formatReceiptLog(value);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const _formatTransactionReceipt = object({
|
|
167
|
+
to: allowNull(getAddress, null),
|
|
168
|
+
from: allowNull(getAddress, null),
|
|
169
|
+
contractAddress: allowNull(getAddress, null),
|
|
170
|
+
// should be allowNull(hash), but broken-EIP-658 support is handled in receipt
|
|
171
|
+
index: getNumber,
|
|
172
|
+
root: allowNull(hexlify),
|
|
173
|
+
gasUsed: getBigInt,
|
|
174
|
+
blobGasUsed: allowNull(getBigInt, null),
|
|
175
|
+
logsBloom: allowNull(formatData),
|
|
176
|
+
blockHash: formatHash,
|
|
177
|
+
hash: formatHash,
|
|
178
|
+
logs: arrayOf(formatReceiptLog),
|
|
179
|
+
blockNumber: getNumber,
|
|
180
|
+
//confirmations: allowNull(getNumber, null),
|
|
181
|
+
cumulativeGasUsed: getBigInt,
|
|
182
|
+
effectiveGasPrice: allowNull(getBigInt),
|
|
183
|
+
blobGasPrice: allowNull(getBigInt, null),
|
|
184
|
+
status: allowNull(getNumber),
|
|
185
|
+
type: allowNull(getNumber, 0)
|
|
186
|
+
}, {
|
|
187
|
+
effectiveGasPrice: [ "gasPrice" ],
|
|
188
|
+
hash: [ "transactionHash" ],
|
|
189
|
+
index: [ "transactionIndex" ],
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
export function formatTransactionReceipt(value: any): TransactionReceiptParams {
|
|
193
|
+
return _formatTransactionReceipt(value);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function formatTransactionResponse(value: any): TransactionResponseParams {
|
|
197
|
+
|
|
198
|
+
// Some clients (TestRPC) do strange things like return 0x0 for the
|
|
199
|
+
// 0 address; correct this to be a real address
|
|
200
|
+
if (value.to && getBigInt(value.to) === BN_0) {
|
|
201
|
+
value.to = "0x0000000000000000000000000000000000000000";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const result = object({
|
|
205
|
+
hash: formatHash,
|
|
206
|
+
|
|
207
|
+
// Some nodes do not return this, usually test nodes (like Ganache)
|
|
208
|
+
index: allowNull(getNumber, undefined),
|
|
209
|
+
|
|
210
|
+
type: (value: any) => {
|
|
211
|
+
if (value === "0x" || value == null) { return 0; }
|
|
212
|
+
return getNumber(value);
|
|
213
|
+
},
|
|
214
|
+
accessList: allowNull(accessListify, null),
|
|
215
|
+
blobVersionedHashes: allowNull(arrayOf(formatHash, true), null),
|
|
216
|
+
|
|
217
|
+
authorizationList: allowNull(arrayOf((v: any) => {
|
|
218
|
+
return {
|
|
219
|
+
address: getAddress(v.address),
|
|
220
|
+
chainId: getBigInt(v.chainId),
|
|
221
|
+
nonce: getBigInt(v.nonce),
|
|
222
|
+
signature: Signature.from(v.signature ? v.signature: v)
|
|
223
|
+
};
|
|
224
|
+
}, false), null),
|
|
225
|
+
|
|
226
|
+
blockHash: allowNull(formatHash, null),
|
|
227
|
+
blockNumber: allowNull(getNumber, null),
|
|
228
|
+
transactionIndex: allowNull(getNumber, null),
|
|
229
|
+
|
|
230
|
+
from: getAddress,
|
|
231
|
+
|
|
232
|
+
// either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set
|
|
233
|
+
gasPrice: allowNull(getBigInt),
|
|
234
|
+
maxPriorityFeePerGas: allowNull(getBigInt),
|
|
235
|
+
maxFeePerGas: allowNull(getBigInt),
|
|
236
|
+
maxFeePerBlobGas: allowNull(getBigInt, null),
|
|
237
|
+
|
|
238
|
+
gasLimit: getBigInt,
|
|
239
|
+
to: allowNull(getAddress, null),
|
|
240
|
+
value: getBigInt,
|
|
241
|
+
nonce: getNumber,
|
|
242
|
+
data: formatData,
|
|
243
|
+
|
|
244
|
+
creates: allowNull(getAddress, null),
|
|
245
|
+
|
|
246
|
+
chainId: allowNull(getBigInt, null)
|
|
247
|
+
}, {
|
|
248
|
+
data: [ "input" ],
|
|
249
|
+
gasLimit: [ "gas" ],
|
|
250
|
+
index: [ "transactionIndex" ]
|
|
251
|
+
})(value);
|
|
252
|
+
|
|
253
|
+
// If to and creates are empty, populate the creates from the value
|
|
254
|
+
if (result.to == null && result.creates == null) {
|
|
255
|
+
result.creates = getCreateAddress(result);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// @TODO: Check fee data
|
|
259
|
+
|
|
260
|
+
// Add an access list to supported transaction types
|
|
261
|
+
if ((value.type === 1 || value.type === 2) && value.accessList == null) {
|
|
262
|
+
result.accessList = [ ];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Compute the signature
|
|
266
|
+
if (value.signature) {
|
|
267
|
+
result.signature = Signature.from(value.signature);
|
|
268
|
+
} else {
|
|
269
|
+
result.signature = Signature.from(value);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Some backends omit ChainId on legacy transactions, but we can compute it
|
|
273
|
+
if (result.chainId == null) {
|
|
274
|
+
const chainId = result.signature.legacyChainId;
|
|
275
|
+
if (chainId != null) { result.chainId = chainId; }
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
// @TODO: check chainID
|
|
280
|
+
/*
|
|
281
|
+
if (value.chainId != null) {
|
|
282
|
+
let chainId = value.chainId;
|
|
283
|
+
|
|
284
|
+
if (isHexString(chainId)) {
|
|
285
|
+
chainId = BigNumber.from(chainId).toNumber();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
result.chainId = chainId;
|
|
289
|
+
|
|
290
|
+
} else {
|
|
291
|
+
let chainId = value.networkId;
|
|
292
|
+
|
|
293
|
+
// geth-etc returns chainId
|
|
294
|
+
if (chainId == null && result.v == null) {
|
|
295
|
+
chainId = value.chainId;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (isHexString(chainId)) {
|
|
299
|
+
chainId = BigNumber.from(chainId).toNumber();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (typeof(chainId) !== "number" && result.v != null) {
|
|
303
|
+
chainId = (result.v - 35) / 2;
|
|
304
|
+
if (chainId < 0) { chainId = 0; }
|
|
305
|
+
chainId = parseInt(chainId);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (typeof(chainId) !== "number") { chainId = 0; }
|
|
309
|
+
|
|
310
|
+
result.chainId = chainId;
|
|
311
|
+
}
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
// 0x0000... should actually be null
|
|
315
|
+
if (result.blockHash && getBigInt(result.blockHash) === BN_0) {
|
|
316
|
+
result.blockHash = null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return result;
|
|
320
|
+
}
|