essential-eth 0.5.4-alpha.0 → 0.5.6
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/utils/clean-transaction-receipt.d.ts +5 -0
- package/lib/cjs/classes/utils/clean-transaction-receipt.js +55 -0
- package/lib/cjs/classes/utils/fetchers.d.ts +1 -1
- package/lib/cjs/index.d.ts +13 -5
- package/lib/cjs/index.js +15 -1
- 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 +44 -1
- package/lib/cjs/providers/BaseProvider.js +65 -0
- package/lib/cjs/providers/FallthroughProvider.d.ts +1 -2
- package/lib/cjs/providers/types.d.ts +7 -0
- package/lib/cjs/providers/types.js +2 -0
- package/lib/cjs/providers/utils/chains-info.d.ts +16 -0
- package/lib/cjs/providers/utils/chains-info.js +50 -2
- package/lib/cjs/types/Transaction.types.d.ts +53 -0
- package/lib/cjs/utils/bytes.d.ts +5 -4
- package/lib/cjs/utils/compute-address.d.ts +8 -0
- package/lib/cjs/utils/compute-address.js +24 -0
- package/lib/cjs/utils/compute-public-key.d.ts +9 -0
- package/lib/cjs/utils/compute-public-key.js +17 -0
- package/lib/cjs/utils/hash-message.d.ts +12 -0
- package/lib/cjs/utils/hash-message.js +26 -0
- package/lib/cjs/utils/keccak256.d.ts +2 -0
- package/lib/cjs/utils/keccak256.js +17 -0
- package/lib/cjs/utils/solidity-keccak256.d.ts +0 -1
- package/lib/cjs/utils/solidity-keccak256.js +3 -10
- package/lib/cjs/utils/split-signature.d.ts +26 -0
- package/lib/cjs/utils/split-signature.js +165 -0
- package/lib/cjs/utils/to-utf8-bytes.d.ts +1 -0
- package/lib/cjs/utils/to-utf8-bytes.js +7 -0
- package/lib/cjs/utils/wei-to-ether.js +12 -2
- package/lib/esm/classes/utils/clean-transaction-receipt.d.ts +2 -0
- package/lib/esm/classes/utils/clean-transaction-receipt.js +48 -0
- package/lib/esm/classes/utils/fetchers.d.ts +1 -1
- package/lib/esm/index.d.ts +13 -5
- package/lib/esm/index.js +11 -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 +5 -1
- package/lib/esm/providers/BaseProvider.js +26 -0
- package/lib/esm/providers/FallthroughProvider.d.ts +1 -2
- package/lib/esm/providers/types.d.ts +7 -0
- package/lib/esm/providers/types.js +1 -0
- package/lib/esm/providers/utils/chains-info.d.ts +16 -0
- package/lib/esm/providers/utils/chains-info.js +50 -2
- package/lib/esm/types/Transaction.types.d.ts +45 -0
- package/lib/esm/utils/bytes.d.ts +5 -4
- 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/hash-message.d.ts +2 -0
- package/lib/esm/utils/hash-message.js +12 -0
- package/lib/esm/utils/keccak256.d.ts +2 -0
- package/lib/esm/utils/keccak256.js +13 -0
- package/lib/esm/utils/solidity-keccak256.d.ts +0 -1
- package/lib/esm/utils/solidity-keccak256.js +2 -8
- package/lib/esm/utils/split-signature.d.ts +2 -0
- package/lib/esm/utils/split-signature.js +126 -0
- package/lib/esm/utils/to-utf8-bytes.d.ts +1 -0
- package/lib/esm/utils/to-utf8-bytes.js +3 -0
- package/lib/esm/utils/wei-to-ether.js +11 -2
- package/package.json +14 -11
- package/readme.md +619 -93
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RPCTransactionReceipt, TransactionReceipt } from '../../types/Transaction.types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts RPC transaction receipt response to more JS-friendly format
|
|
4
|
+
*/
|
|
5
|
+
export declare function cleanTransactionReceipt(transactionReceipt: RPCTransactionReceipt): TransactionReceipt;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanTransactionReceipt = void 0;
|
|
4
|
+
const __1 = require("../..");
|
|
5
|
+
const clean_transaction_1 = require("./clean-transaction");
|
|
6
|
+
const hex_to_decimal_1 = require("./hex-to-decimal");
|
|
7
|
+
/**
|
|
8
|
+
* Converts RPC transaction receipt response to more JS-friendly format
|
|
9
|
+
*/
|
|
10
|
+
function cleanTransactionReceipt(transactionReceipt) {
|
|
11
|
+
const cleanedTransaction = (0, clean_transaction_1.cleanTransaction)(transactionReceipt);
|
|
12
|
+
const cleanedTransactionReceipt = Object.assign({}, cleanedTransaction);
|
|
13
|
+
Object.keys(transactionReceipt).forEach((key) => {
|
|
14
|
+
if (!transactionReceipt[key])
|
|
15
|
+
return;
|
|
16
|
+
switch (key) {
|
|
17
|
+
case 'status':
|
|
18
|
+
cleanedTransactionReceipt[key] = Number((0, hex_to_decimal_1.hexToDecimal)(transactionReceipt[key]));
|
|
19
|
+
break;
|
|
20
|
+
case 'contractAddress':
|
|
21
|
+
if (transactionReceipt[key]) {
|
|
22
|
+
cleanedTransactionReceipt[key] = (0, __1.toChecksumAddress)(transactionReceipt[key]);
|
|
23
|
+
}
|
|
24
|
+
break;
|
|
25
|
+
case 'cumulativeGasUsed':
|
|
26
|
+
case 'effectiveGasPrice':
|
|
27
|
+
case 'gasUsed':
|
|
28
|
+
cleanedTransactionReceipt[key] = (0, __1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(transactionReceipt[key]));
|
|
29
|
+
break;
|
|
30
|
+
case 'logs':
|
|
31
|
+
transactionReceipt[key].forEach((log, index) => {
|
|
32
|
+
Object.keys(log).forEach((logKey) => {
|
|
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
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
cleanedTransactionReceipt.byzantium =
|
|
52
|
+
cleanedTransactionReceipt.blockNumber >= 4370000;
|
|
53
|
+
return cleanedTransactionReceipt;
|
|
54
|
+
}
|
|
55
|
+
exports.cleanTransactionReceipt = cleanTransactionReceipt;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function post(url: string, body: Record<string, unknown>): Promise<any>;
|
|
2
|
-
declare type RPCMethodName = 'eth_getBlockByNumber' | 'eth_getBlockByHash' | 'eth_call' | 'eth_chainId' | 'eth_gasPrice' | 'eth_getBalance' | 'eth_getTransactionByHash' | 'eth_getTransactionCount';
|
|
2
|
+
declare type RPCMethodName = 'eth_getBlockByNumber' | 'eth_getBlockByHash' | 'eth_call' | 'eth_chainId' | 'eth_gasPrice' | 'eth_getBalance' | 'eth_getTransactionByHash' | 'eth_getTransactionReceipt' | 'eth_getTransactionCount' | 'eth_blockNumber' | 'eth_estimateGas';
|
|
3
3
|
export declare function buildRPCPostBody(method: RPCMethodName, params: unknown[]): {
|
|
4
4
|
jsonrpc: string;
|
|
5
5
|
id: number;
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { Contract } from './classes/Contract';
|
|
2
|
-
import { FallthroughProvider } from './providers/FallthroughProvider';
|
|
1
|
+
import { BaseContract, Contract } from './classes/Contract';
|
|
2
|
+
import { ConstructorOptions, FallthroughProvider } from './providers/FallthroughProvider';
|
|
3
3
|
import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
|
|
4
4
|
import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
|
|
5
|
-
import { BlockResponse } from './types/Block.types';
|
|
5
|
+
import { BlockResponse, BlockTag, RPCBlock } from './types/Block.types';
|
|
6
6
|
import { ContractTypes, JSONABI, JSONABIArgument } from './types/Contract.types';
|
|
7
7
|
import { Network } from './types/Network.types';
|
|
8
|
-
import { TransactionResponse } from './types/Transaction.types';
|
|
8
|
+
import { BlockTransactionResponse, Log, RPCLog, RPCTransaction, RPCTransactionReceipt, TransactionReceipt, TransactionResponse } from './types/Transaction.types';
|
|
9
|
+
import { computeAddress } from './utils/compute-address';
|
|
10
|
+
import { computePublicKey } from './utils/compute-public-key';
|
|
9
11
|
import { etherToGwei } from './utils/ether-to-gwei';
|
|
10
12
|
import { etherToWei } from './utils/ether-to-wei';
|
|
11
13
|
import { gweiToEther } from './utils/gwei-to-ether';
|
|
14
|
+
import { hashMessage } from './utils/hash-message';
|
|
12
15
|
import { isAddress } from './utils/is-address';
|
|
16
|
+
import { splitSignature } from './utils/split-signature';
|
|
13
17
|
import { toChecksumAddress } from './utils/to-checksum-address';
|
|
18
|
+
import { toUtf8Bytes } from './utils/to-utf8-bytes';
|
|
14
19
|
import { weiToEther } from './utils/wei-to-ether';
|
|
20
|
+
export * from './providers/types';
|
|
15
21
|
export * from './utils/bytes';
|
|
22
|
+
export * from './utils/hash-message';
|
|
23
|
+
export * from './utils/keccak256';
|
|
16
24
|
export * from './utils/solidity-keccak256';
|
|
17
|
-
export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, BlockResponse, ContractTypes, JSONABI, JSONABIArgument, Network, TransactionResponse, };
|
|
25
|
+
export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, Contract, TinyBig, BaseContract, BlockResponse, ContractTypes, JSONABI, JSONABIArgument, Network, TransactionResponse, RPCBlock, RPCTransaction, RPCTransactionReceipt, TransactionReceipt, BlockTag, RPCLog, Log, BlockTransactionResponse, ConstructorOptions, };
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.TinyBig = exports.Contract = exports.gweiToEther = exports.weiToEther = exports.toChecksumAddress = exports.tinyBig = exports.FallthroughProvider = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.isAddress = exports.etherToGwei = exports.etherToWei = void 0;
|
|
17
|
+
exports.BaseContract = exports.TinyBig = exports.Contract = exports.computePublicKey = exports.computeAddress = exports.toUtf8Bytes = exports.splitSignature = exports.hashMessage = exports.gweiToEther = exports.weiToEther = exports.toChecksumAddress = exports.tinyBig = exports.FallthroughProvider = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.isAddress = exports.etherToGwei = exports.etherToWei = void 0;
|
|
18
18
|
const Contract_1 = require("./classes/Contract");
|
|
19
|
+
Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return Contract_1.BaseContract; } });
|
|
19
20
|
Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return Contract_1.Contract; } });
|
|
20
21
|
const FallthroughProvider_1 = require("./providers/FallthroughProvider");
|
|
21
22
|
Object.defineProperty(exports, "FallthroughProvider", { enumerable: true, get: function () { return FallthroughProvider_1.FallthroughProvider; } });
|
|
@@ -25,17 +26,30 @@ Object.defineProperty(exports, "jsonRpcProvider", { enumerable: true, get: funct
|
|
|
25
26
|
const tiny_big_1 = require("./shared/tiny-big/tiny-big");
|
|
26
27
|
Object.defineProperty(exports, "tinyBig", { enumerable: true, get: function () { return tiny_big_1.tinyBig; } });
|
|
27
28
|
Object.defineProperty(exports, "TinyBig", { enumerable: true, get: function () { return tiny_big_1.TinyBig; } });
|
|
29
|
+
const compute_address_1 = require("./utils/compute-address");
|
|
30
|
+
Object.defineProperty(exports, "computeAddress", { enumerable: true, get: function () { return compute_address_1.computeAddress; } });
|
|
31
|
+
const compute_public_key_1 = require("./utils/compute-public-key");
|
|
32
|
+
Object.defineProperty(exports, "computePublicKey", { enumerable: true, get: function () { return compute_public_key_1.computePublicKey; } });
|
|
28
33
|
const ether_to_gwei_1 = require("./utils/ether-to-gwei");
|
|
29
34
|
Object.defineProperty(exports, "etherToGwei", { enumerable: true, get: function () { return ether_to_gwei_1.etherToGwei; } });
|
|
30
35
|
const ether_to_wei_1 = require("./utils/ether-to-wei");
|
|
31
36
|
Object.defineProperty(exports, "etherToWei", { enumerable: true, get: function () { return ether_to_wei_1.etherToWei; } });
|
|
32
37
|
const gwei_to_ether_1 = require("./utils/gwei-to-ether");
|
|
33
38
|
Object.defineProperty(exports, "gweiToEther", { enumerable: true, get: function () { return gwei_to_ether_1.gweiToEther; } });
|
|
39
|
+
const hash_message_1 = require("./utils/hash-message");
|
|
40
|
+
Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return hash_message_1.hashMessage; } });
|
|
34
41
|
const is_address_1 = require("./utils/is-address");
|
|
35
42
|
Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return is_address_1.isAddress; } });
|
|
43
|
+
const split_signature_1 = require("./utils/split-signature");
|
|
44
|
+
Object.defineProperty(exports, "splitSignature", { enumerable: true, get: function () { return split_signature_1.splitSignature; } });
|
|
36
45
|
const to_checksum_address_1 = require("./utils/to-checksum-address");
|
|
37
46
|
Object.defineProperty(exports, "toChecksumAddress", { enumerable: true, get: function () { return to_checksum_address_1.toChecksumAddress; } });
|
|
47
|
+
const to_utf8_bytes_1 = require("./utils/to-utf8-bytes");
|
|
48
|
+
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return to_utf8_bytes_1.toUtf8Bytes; } });
|
|
38
49
|
const wei_to_ether_1 = require("./utils/wei-to-ether");
|
|
39
50
|
Object.defineProperty(exports, "weiToEther", { enumerable: true, get: function () { return wei_to_ether_1.weiToEther; } });
|
|
51
|
+
__exportStar(require("./providers/types"), exports);
|
|
40
52
|
__exportStar(require("./utils/bytes"), exports);
|
|
53
|
+
__exportStar(require("./utils/hash-message"), exports);
|
|
54
|
+
__exportStar(require("./utils/keccak256"), exports);
|
|
41
55
|
__exportStar(require("./utils/solidity-keccak256"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.5.
|
|
1
|
+
export declare const version = "0.5.6";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TinyBig } from '../shared/tiny-big/tiny-big';
|
|
2
2
|
import { BlockResponse, BlockTag } from '../types/Block.types';
|
|
3
3
|
import { Network } from '../types/Network.types';
|
|
4
|
-
import { TransactionResponse } from '../types/Transaction.types';
|
|
4
|
+
import { TransactionReceipt, TransactionResponse } from '../types/Transaction.types';
|
|
5
|
+
import { TransactionRequest } from './types';
|
|
5
6
|
export declare abstract class BaseProvider {
|
|
6
7
|
/**
|
|
7
8
|
* ignore
|
|
@@ -24,6 +25,20 @@ export declare abstract class BaseProvider {
|
|
|
24
25
|
* Returns the network this provider is connected to
|
|
25
26
|
*/
|
|
26
27
|
getNetwork(): Promise<Network>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the number of the most recently mined block on the network the provider is connected to
|
|
30
|
+
*
|
|
31
|
+
* * Identical to [`ethers.provider.getBlockNumber`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBlockNumber)
|
|
32
|
+
* * Identical to [`web3.eth.getBlockNumber`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getblocknumber)
|
|
33
|
+
*
|
|
34
|
+
* @returns the number of the most recently mined block
|
|
35
|
+
* @example
|
|
36
|
+
* ```js
|
|
37
|
+
* await provider.getBlockNumber();
|
|
38
|
+
* // 1053312
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
getBlockNumber(): Promise<number>;
|
|
27
42
|
/**
|
|
28
43
|
* * Similar to [`ethers.provider.getTransaction`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransaction), some information not included
|
|
29
44
|
*
|
|
@@ -149,6 +164,15 @@ export declare abstract class BaseProvider {
|
|
|
149
164
|
* ```
|
|
150
165
|
*/
|
|
151
166
|
getTransaction(transactionHash: string): Promise<TransactionResponse>;
|
|
167
|
+
/**
|
|
168
|
+
* Gives information about a transaction that has already been mined. Includes additional information beyond what's provided by `getTransaction()`
|
|
169
|
+
*
|
|
170
|
+
* * Similar to [`ethers.provider.getTransactionReceipt`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionReceipt), some information not included
|
|
171
|
+
*
|
|
172
|
+
* @param transactionHash the hash of the transaction to get information about
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
|
|
152
176
|
/**
|
|
153
177
|
* Returns the transaction count from genesis up to specified blockTag
|
|
154
178
|
*
|
|
@@ -258,4 +282,23 @@ export declare abstract class BaseProvider {
|
|
|
258
282
|
* ```
|
|
259
283
|
*/
|
|
260
284
|
getBalance(address: string, blockTag?: BlockTag): Promise<TinyBig>;
|
|
285
|
+
/**
|
|
286
|
+
* Returns an estimate of the amount of gas that would be required to submit transaction to the network.
|
|
287
|
+
* An estimate may not be accurate since there could be another transaction on the network that was not accounted for, but after being mined affected relevant state.
|
|
288
|
+
*
|
|
289
|
+
* * Same as ["estimateGas" in ethers.js](https://docs.ethers.io/v5/api/providers/provider/#Provider-estimateGas)
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```js
|
|
293
|
+
* await provider.estimateGas({
|
|
294
|
+
* // Wrapped ETH address
|
|
295
|
+
* to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
296
|
+
* data: "0xd0e30db0",
|
|
297
|
+
* value: etherToWei('1.0').toHexString(),
|
|
298
|
+
* });
|
|
299
|
+
* // { TinyBig: "27938" }
|
|
300
|
+
*
|
|
301
|
+
* ```
|
|
302
|
+
* */
|
|
303
|
+
estimateGas(transaction: TransactionRequest): Promise<TinyBig>;
|
|
261
304
|
}
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.BaseProvider = void 0;
|
|
16
16
|
const clean_block_1 = require("../classes/utils/clean-block");
|
|
17
17
|
const clean_transaction_1 = require("../classes/utils/clean-transaction");
|
|
18
|
+
const clean_transaction_receipt_1 = require("../classes/utils/clean-transaction-receipt");
|
|
18
19
|
const fetchers_1 = require("../classes/utils/fetchers");
|
|
19
20
|
const hex_to_decimal_1 = require("../classes/utils/hex-to-decimal");
|
|
20
21
|
const tiny_big_1 = require("../shared/tiny-big/tiny-big");
|
|
@@ -49,6 +50,25 @@ class BaseProvider {
|
|
|
49
50
|
};
|
|
50
51
|
});
|
|
51
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets the number of the most recently mined block on the network the provider is connected to
|
|
55
|
+
*
|
|
56
|
+
* * Identical to [`ethers.provider.getBlockNumber`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBlockNumber)
|
|
57
|
+
* * Identical to [`web3.eth.getBlockNumber`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getblocknumber)
|
|
58
|
+
*
|
|
59
|
+
* @returns the number of the most recently mined block
|
|
60
|
+
* @example
|
|
61
|
+
* ```js
|
|
62
|
+
* await provider.getBlockNumber();
|
|
63
|
+
* // 1053312
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
getBlockNumber() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const currentBlockNumber = (yield this.post((0, fetchers_1.buildRPCPostBody)('eth_blockNumber', [])));
|
|
69
|
+
return Number((0, hex_to_decimal_1.hexToDecimal)(currentBlockNumber));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
52
72
|
/**
|
|
53
73
|
* * Similar to [`ethers.provider.getTransaction`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransaction), some information not included
|
|
54
74
|
*
|
|
@@ -186,6 +206,26 @@ class BaseProvider {
|
|
|
186
206
|
return cleanedTransaction;
|
|
187
207
|
});
|
|
188
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Gives information about a transaction that has already been mined. Includes additional information beyond what's provided by `getTransaction()`
|
|
211
|
+
*
|
|
212
|
+
* * Similar to [`ethers.provider.getTransactionReceipt`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionReceipt), some information not included
|
|
213
|
+
*
|
|
214
|
+
* @param transactionHash the hash of the transaction to get information about
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
217
|
+
getTransactionReceipt(transactionHash) {
|
|
218
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
+
const [rpcTransaction, blockNumber] = yield Promise.all([
|
|
220
|
+
this.post((0, fetchers_1.buildRPCPostBody)('eth_getTransactionReceipt', [transactionHash])),
|
|
221
|
+
this.getBlock('latest'),
|
|
222
|
+
]);
|
|
223
|
+
const cleanedTransactionReceipt = (0, clean_transaction_receipt_1.cleanTransactionReceipt)(rpcTransaction);
|
|
224
|
+
cleanedTransactionReceipt.confirmations =
|
|
225
|
+
blockNumber.number - cleanedTransactionReceipt.blockNumber + 1;
|
|
226
|
+
return cleanedTransactionReceipt;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
189
229
|
/**
|
|
190
230
|
* Returns the transaction count from genesis up to specified blockTag
|
|
191
231
|
*
|
|
@@ -336,5 +376,30 @@ class BaseProvider {
|
|
|
336
376
|
return (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(hexBalance));
|
|
337
377
|
});
|
|
338
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Returns an estimate of the amount of gas that would be required to submit transaction to the network.
|
|
381
|
+
* An estimate may not be accurate since there could be another transaction on the network that was not accounted for, but after being mined affected relevant state.
|
|
382
|
+
*
|
|
383
|
+
* * Same as ["estimateGas" in ethers.js](https://docs.ethers.io/v5/api/providers/provider/#Provider-estimateGas)
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```js
|
|
387
|
+
* await provider.estimateGas({
|
|
388
|
+
* // Wrapped ETH address
|
|
389
|
+
* to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
390
|
+
* data: "0xd0e30db0",
|
|
391
|
+
* value: etherToWei('1.0').toHexString(),
|
|
392
|
+
* });
|
|
393
|
+
* // { TinyBig: "27938" }
|
|
394
|
+
*
|
|
395
|
+
* ```
|
|
396
|
+
* */
|
|
397
|
+
estimateGas(transaction) {
|
|
398
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
399
|
+
const body = (0, fetchers_1.buildRPCPostBody)('eth_estimateGas', [transaction]);
|
|
400
|
+
const gasUsed = (yield this.post(body));
|
|
401
|
+
return (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(gasUsed));
|
|
402
|
+
});
|
|
403
|
+
}
|
|
339
404
|
}
|
|
340
405
|
exports.BaseProvider = BaseProvider;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseProvider } from './BaseProvider';
|
|
2
|
-
interface ConstructorOptions {
|
|
2
|
+
export interface ConstructorOptions {
|
|
3
3
|
timeoutDuration?: number;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
@@ -22,4 +22,3 @@ export declare class FallthroughProvider extends BaseProvider {
|
|
|
22
22
|
*/
|
|
23
23
|
post: (body: Record<string, unknown>) => Promise<any>;
|
|
24
24
|
}
|
|
25
|
-
export {};
|
|
@@ -119,6 +119,7 @@ declare const _default: {
|
|
|
119
119
|
"222": string[];
|
|
120
120
|
"225": string[];
|
|
121
121
|
"226": string[];
|
|
122
|
+
"239": string[];
|
|
122
123
|
"246": string[];
|
|
123
124
|
"250": string[];
|
|
124
125
|
"256": string[];
|
|
@@ -143,10 +144,14 @@ declare const _default: {
|
|
|
143
144
|
"499": string[];
|
|
144
145
|
"512": string[];
|
|
145
146
|
"513": string[];
|
|
147
|
+
"534": string[];
|
|
146
148
|
"555": string[];
|
|
147
149
|
"558": string[];
|
|
148
150
|
"588": string[];
|
|
151
|
+
"592": string[];
|
|
149
152
|
"595": string[];
|
|
153
|
+
"596": string[];
|
|
154
|
+
"597": string[];
|
|
150
155
|
"600": string[];
|
|
151
156
|
"666": string[];
|
|
152
157
|
"686": string[];
|
|
@@ -154,6 +159,7 @@ declare const _default: {
|
|
|
154
159
|
"707": string[];
|
|
155
160
|
"708": string[];
|
|
156
161
|
"721": string[];
|
|
162
|
+
"776": string[];
|
|
157
163
|
"777": string[];
|
|
158
164
|
"787": string[];
|
|
159
165
|
"788": string[];
|
|
@@ -201,14 +207,18 @@ declare const _default: {
|
|
|
201
207
|
"1620": string[];
|
|
202
208
|
"1657": string[];
|
|
203
209
|
"1688": string[];
|
|
210
|
+
"1819": string[];
|
|
204
211
|
"1856": string[];
|
|
205
212
|
"1898": string[];
|
|
206
213
|
"1984": string[];
|
|
207
214
|
"1987": string[];
|
|
208
215
|
"2001": string[];
|
|
216
|
+
"2008": string[];
|
|
217
|
+
"2009": string[];
|
|
209
218
|
"2020": string[];
|
|
210
219
|
"2021": string[];
|
|
211
220
|
"2022": string[];
|
|
221
|
+
"2023": string[];
|
|
212
222
|
"2025": string[];
|
|
213
223
|
"2100": string[];
|
|
214
224
|
"2101": string[];
|
|
@@ -219,6 +229,8 @@ declare const _default: {
|
|
|
219
229
|
"2223": string[];
|
|
220
230
|
"2559": string[];
|
|
221
231
|
"2569": string[];
|
|
232
|
+
"2612": string[];
|
|
233
|
+
"2613": string[];
|
|
222
234
|
"3000": string[];
|
|
223
235
|
"3001": string[];
|
|
224
236
|
"3331": string[];
|
|
@@ -254,6 +266,7 @@ declare const _default: {
|
|
|
254
266
|
"8723": string[];
|
|
255
267
|
"8724": string[];
|
|
256
268
|
"8888": string[];
|
|
269
|
+
"8898": string[];
|
|
257
270
|
"8995": string[];
|
|
258
271
|
"9000": string[];
|
|
259
272
|
"9001": string[];
|
|
@@ -274,10 +287,13 @@ declare const _default: {
|
|
|
274
287
|
"19845": string[];
|
|
275
288
|
"21337": string[];
|
|
276
289
|
"21816": string[];
|
|
290
|
+
"22023": string[];
|
|
277
291
|
"24484": string[];
|
|
278
292
|
"24734": string[];
|
|
293
|
+
"30067": string[];
|
|
279
294
|
"31102": string[];
|
|
280
295
|
"31337": string[];
|
|
296
|
+
"32520": string[];
|
|
281
297
|
"32659": string[];
|
|
282
298
|
"39797": string[];
|
|
283
299
|
"42069": string[];
|
|
@@ -367,6 +367,9 @@ exports.default = {
|
|
|
367
367
|
"226": [
|
|
368
368
|
"TLA"
|
|
369
369
|
],
|
|
370
|
+
"239": [
|
|
371
|
+
"AITD"
|
|
372
|
+
],
|
|
370
373
|
"246": [
|
|
371
374
|
"ewt"
|
|
372
375
|
],
|
|
@@ -439,6 +442,9 @@ exports.default = {
|
|
|
439
442
|
"513": [
|
|
440
443
|
"aact"
|
|
441
444
|
],
|
|
445
|
+
"534": [
|
|
446
|
+
"CNDL"
|
|
447
|
+
],
|
|
442
448
|
"555": [
|
|
443
449
|
"CLASS"
|
|
444
450
|
],
|
|
@@ -448,9 +454,18 @@ exports.default = {
|
|
|
448
454
|
"588": [
|
|
449
455
|
"metis-stardust"
|
|
450
456
|
],
|
|
457
|
+
"592": [
|
|
458
|
+
"astr"
|
|
459
|
+
],
|
|
451
460
|
"595": [
|
|
452
461
|
"maca"
|
|
453
462
|
],
|
|
463
|
+
"596": [
|
|
464
|
+
"tkar"
|
|
465
|
+
],
|
|
466
|
+
"597": [
|
|
467
|
+
"taca"
|
|
468
|
+
],
|
|
454
469
|
"600": [
|
|
455
470
|
"mesh-chain-testnet"
|
|
456
471
|
],
|
|
@@ -472,6 +487,9 @@ exports.default = {
|
|
|
472
487
|
"721": [
|
|
473
488
|
"tfeth"
|
|
474
489
|
],
|
|
490
|
+
"776": [
|
|
491
|
+
"opc"
|
|
492
|
+
],
|
|
475
493
|
"777": [
|
|
476
494
|
"cth"
|
|
477
495
|
],
|
|
@@ -613,6 +631,9 @@ exports.default = {
|
|
|
613
631
|
"1688": [
|
|
614
632
|
"LUDAN"
|
|
615
633
|
],
|
|
634
|
+
"1819": [
|
|
635
|
+
"cubet"
|
|
636
|
+
],
|
|
616
637
|
"1856": [
|
|
617
638
|
"tsf"
|
|
618
639
|
],
|
|
@@ -628,6 +649,12 @@ exports.default = {
|
|
|
628
649
|
"2001": [
|
|
629
650
|
"milkAda"
|
|
630
651
|
],
|
|
652
|
+
"2008": [
|
|
653
|
+
"cloudwalk_testnet"
|
|
654
|
+
],
|
|
655
|
+
"2009": [
|
|
656
|
+
"cloudwalk_mainnet"
|
|
657
|
+
],
|
|
631
658
|
"2020": [
|
|
632
659
|
"420"
|
|
633
660
|
],
|
|
@@ -637,6 +664,9 @@ exports.default = {
|
|
|
637
664
|
"2022": [
|
|
638
665
|
"edgt"
|
|
639
666
|
],
|
|
667
|
+
"2023": [
|
|
668
|
+
"taycan-testnet"
|
|
669
|
+
],
|
|
640
670
|
"2025": [
|
|
641
671
|
"rpg"
|
|
642
672
|
],
|
|
@@ -667,6 +697,12 @@ exports.default = {
|
|
|
667
697
|
"2569": [
|
|
668
698
|
"tpc"
|
|
669
699
|
],
|
|
700
|
+
"2612": [
|
|
701
|
+
"EZChain"
|
|
702
|
+
],
|
|
703
|
+
"2613": [
|
|
704
|
+
"Fuji-EZChain"
|
|
705
|
+
],
|
|
670
706
|
"3000": [
|
|
671
707
|
"cennz-r"
|
|
672
708
|
],
|
|
@@ -772,6 +808,9 @@ exports.default = {
|
|
|
772
808
|
"8888": [
|
|
773
809
|
"ambrostestnet"
|
|
774
810
|
],
|
|
811
|
+
"8898": [
|
|
812
|
+
"mmt"
|
|
813
|
+
],
|
|
775
814
|
"8995": [
|
|
776
815
|
"berg"
|
|
777
816
|
],
|
|
@@ -830,7 +869,10 @@ exports.default = {
|
|
|
830
869
|
"cennz-a"
|
|
831
870
|
],
|
|
832
871
|
"21816": [
|
|
833
|
-
"
|
|
872
|
+
"omc"
|
|
873
|
+
],
|
|
874
|
+
"22023": [
|
|
875
|
+
"SFL"
|
|
834
876
|
],
|
|
835
877
|
"24484": [
|
|
836
878
|
"web"
|
|
@@ -838,12 +880,18 @@ exports.default = {
|
|
|
838
880
|
"24734": [
|
|
839
881
|
"mintme"
|
|
840
882
|
],
|
|
883
|
+
"30067": [
|
|
884
|
+
"Piece"
|
|
885
|
+
],
|
|
841
886
|
"31102": [
|
|
842
887
|
"esn"
|
|
843
888
|
],
|
|
844
889
|
"31337": [
|
|
845
890
|
"got"
|
|
846
891
|
],
|
|
892
|
+
"32520": [
|
|
893
|
+
"Brise"
|
|
894
|
+
],
|
|
847
895
|
"32659": [
|
|
848
896
|
"fsn"
|
|
849
897
|
],
|
|
@@ -878,7 +926,7 @@ exports.default = {
|
|
|
878
926
|
"ALFA"
|
|
879
927
|
],
|
|
880
928
|
"45000": [
|
|
881
|
-
"
|
|
929
|
+
"Autobahn Network"
|
|
882
930
|
],
|
|
883
931
|
"47805": [
|
|
884
932
|
"REI"
|
|
@@ -20,6 +20,32 @@ export declare type TransactionResponse = Modify<RPCTransaction, {
|
|
|
20
20
|
maxPriorityFeePerGas: TinyBig;
|
|
21
21
|
confirmations: number;
|
|
22
22
|
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Type that contains information from the receipt of a transaction
|
|
25
|
+
* * Similar to [`Type TransactionReceipt on ethers.providers`](https://docs.ethers.io/v5/api/providers/types/#providers-TransactionReceipt)
|
|
26
|
+
*/
|
|
27
|
+
export declare type TransactionReceipt = Modify<RPCTransactionReceipt, {
|
|
28
|
+
blockNumber: number;
|
|
29
|
+
cumulativeGasUsed: TinyBig;
|
|
30
|
+
effectiveGasPrice: TinyBig;
|
|
31
|
+
gasUsed: TinyBig;
|
|
32
|
+
logs: Array<Log>;
|
|
33
|
+
status: number;
|
|
34
|
+
transactionIndex: number;
|
|
35
|
+
type: number;
|
|
36
|
+
} & {
|
|
37
|
+
byzantium: boolean;
|
|
38
|
+
confirmations: number;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Type for the logs that are included in transaction receipts
|
|
42
|
+
* * Similar to [`Type Log on ethers.providers`](https://docs.ethers.io/v5/api/providers/types/#providers-Log)
|
|
43
|
+
*/
|
|
44
|
+
export declare type Log = Modify<Omit<RPCLog, 'removed'>, {
|
|
45
|
+
blockNumber: number;
|
|
46
|
+
logIndex: number;
|
|
47
|
+
transactionIndex: number;
|
|
48
|
+
}>;
|
|
23
49
|
export declare type BlockTransactionResponse = Omit<TransactionResponse, 'maxFeePerGas' | 'maxPriorityFeePerGas'>;
|
|
24
50
|
/** What JSONRPC responds with in getBlock transaction array */
|
|
25
51
|
export interface RPCBlockTransaction {
|
|
@@ -40,4 +66,31 @@ export interface RPCBlockTransaction {
|
|
|
40
66
|
v: string;
|
|
41
67
|
value: string;
|
|
42
68
|
}
|
|
69
|
+
export interface RPCTransactionReceipt {
|
|
70
|
+
blockHash: string;
|
|
71
|
+
blockNumber: string;
|
|
72
|
+
contractAddress: string;
|
|
73
|
+
cumulativeGasUsed: string;
|
|
74
|
+
effectiveGasPrice: string;
|
|
75
|
+
from: string;
|
|
76
|
+
gasUsed: string;
|
|
77
|
+
logs: Array<RPCLog>;
|
|
78
|
+
logsBloom: string;
|
|
79
|
+
status: string;
|
|
80
|
+
to: string;
|
|
81
|
+
transactionHash: string;
|
|
82
|
+
transactionIndex: string;
|
|
83
|
+
type: string;
|
|
84
|
+
}
|
|
85
|
+
export interface RPCLog {
|
|
86
|
+
address: string;
|
|
87
|
+
blockHash: string;
|
|
88
|
+
blockNumber: string;
|
|
89
|
+
data: string;
|
|
90
|
+
logIndex: string;
|
|
91
|
+
removed?: boolean;
|
|
92
|
+
topics: Array<string>;
|
|
93
|
+
transactionHash: string;
|
|
94
|
+
transactionIndex: string;
|
|
95
|
+
}
|
|
43
96
|
export {};
|
package/lib/cjs/utils/bytes.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export declare type Bytes = ArrayLike<number>;
|
|
|
9
9
|
* @example
|
|
10
10
|
* '0x123'
|
|
11
11
|
*/
|
|
12
|
-
export declare type BytesLike = Bytes | string
|
|
12
|
+
export declare type BytesLike = Bytes | string;
|
|
13
|
+
export declare type BytesLikeWithNumber = BytesLike | number;
|
|
13
14
|
export interface DataOptions {
|
|
14
15
|
allowMissingPrefix?: boolean;
|
|
15
16
|
hexPad?: 'left' | 'right' | null;
|
|
@@ -112,7 +113,7 @@ export declare function arrayify(value: BytesLike | Hexable | number, options?:
|
|
|
112
113
|
* // Uint8Array(2) [ 0, 1 ]
|
|
113
114
|
* ```
|
|
114
115
|
*/
|
|
115
|
-
export declare function concat(arrayOfBytesLike: ReadonlyArray<
|
|
116
|
+
export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
|
|
116
117
|
export declare function stripZeros(value: BytesLike): Uint8Array;
|
|
117
118
|
export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
118
119
|
/**
|
|
@@ -133,7 +134,7 @@ export declare function isHexString(value: any, length?: number): boolean;
|
|
|
133
134
|
*/
|
|
134
135
|
export declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
135
136
|
export declare function hexDataLength(data: BytesLike): number | null;
|
|
136
|
-
export declare function hexDataSlice(data:
|
|
137
|
+
export declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
|
|
137
138
|
export declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
138
139
|
export declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
139
140
|
export declare function hexStripZeros(value: BytesLike): string;
|
|
@@ -168,4 +169,4 @@ export declare function hexStripZeros(value: BytesLike): string;
|
|
|
168
169
|
* // Throws
|
|
169
170
|
* ```
|
|
170
171
|
*/
|
|
171
|
-
export declare function hexZeroPad(value:
|
|
172
|
+
export declare function hexZeroPad(value: BytesLikeWithNumber, length: number): string;
|