@mentaproject/client 0.0.3
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/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/managers/AccountManager.d.ts +8 -0
- package/dist/managers/AccountManager.js +11 -0
- package/dist/managers/BlockManager.d.ts +8 -0
- package/dist/managers/BlockManager.js +13 -0
- package/dist/managers/ContractManager.d.ts +7 -0
- package/dist/managers/ContractManager.js +12 -0
- package/dist/managers/TransactionManager.d.ts +8 -0
- package/dist/managers/TransactionManager.js +19 -0
- package/dist/managers/index.d.ts +4 -0
- package/dist/managers/index.js +4 -0
- package/dist/structures/Account.d.ts +41 -0
- package/dist/structures/Account.js +86 -0
- package/dist/structures/Block.d.ts +36 -0
- package/dist/structures/Block.js +37 -0
- package/dist/structures/MentaClient.d.ts +13 -0
- package/dist/structures/MentaClient.js +16 -0
- package/dist/structures/Transaction.d.ts +30 -0
- package/dist/structures/Transaction.js +45 -0
- package/dist/structures/TransactionReceipt.d.ts +0 -0
- package/dist/structures/TransactionReceipt.js +1 -0
- package/dist/structures/index.d.ts +5 -0
- package/dist/structures/index.js +5 -0
- package/dist/types/Account.d.ts +5 -0
- package/dist/types/Account.js +1 -0
- package/dist/types/Block.d.ts +56 -0
- package/dist/types/Block.js +2 -0
- package/dist/types/Transaction.d.ts +45 -0
- package/dist/types/Transaction.js +1 -0
- package/dist/types/TransactionReceipt.d.ts +9 -0
- package/dist/types/TransactionReceipt.js +3 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/IsContractCompliantWithAbi.d.ts +15 -0
- package/dist/utils/IsContractCompliantWithAbi.js +280 -0
- package/dist/utils/abis/ERC20.d.ts +168 -0
- package/dist/utils/abis/ERC20.js +222 -0
- package/dist/utils/abis/index.d.ts +1 -0
- package/dist/utils/abis/index.js +1 -0
- package/package.json +53 -0
- package/test.ts +60 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { Account } from "../structures/Account";
|
|
3
|
+
import { CoreClient } from "@mentaproject/core/types";
|
|
4
|
+
export declare class AccountManager {
|
|
5
|
+
rpcClient: CoreClient;
|
|
6
|
+
constructor(rpcClient: CoreClient);
|
|
7
|
+
get(address: Address): Account;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BlockTag, GetBlockParameters } from "viem";
|
|
2
|
+
import { Block } from "../structures/Block";
|
|
3
|
+
import { CoreClient } from "@mentaproject/core/types";
|
|
4
|
+
export declare class BlockManager {
|
|
5
|
+
client: CoreClient;
|
|
6
|
+
constructor(client: CoreClient);
|
|
7
|
+
get(params: GetBlockParameters<boolean, BlockTag>): Promise<Block>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Block } from "../structures/Block";
|
|
2
|
+
import { getBlock } from "@mentaproject/core/actions";
|
|
3
|
+
export class BlockManager {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
;
|
|
8
|
+
async get(params) {
|
|
9
|
+
const data = await getBlock(this.client, params);
|
|
10
|
+
return new Block(this.client, data);
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AbiItem, CoreClient } from "@mentaproject/core/types";
|
|
2
|
+
import { GetContractParameters } from "@mentaproject/contracts";
|
|
3
|
+
export declare class ContractManager {
|
|
4
|
+
protected rpcClient: CoreClient;
|
|
5
|
+
constructor(rpcClient: CoreClient);
|
|
6
|
+
get<P extends GetContractParameters<ReadonlyArray<AbiItem>>>(params: P): import("@mentaproject/contracts").GetContractReturnType<P>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CoreClient, GetTransactionParameters, SendTransactionParameters } from "@mentaproject/core/types";
|
|
2
|
+
import { Transaction } from "../structures/Transaction";
|
|
3
|
+
export declare class TransactionManager {
|
|
4
|
+
rpcClient: CoreClient;
|
|
5
|
+
constructor(rpcClient: CoreClient);
|
|
6
|
+
get(params: GetTransactionParameters): Promise<Transaction>;
|
|
7
|
+
send(params: SendTransactionParameters): Promise<Transaction>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Transaction } from "../structures/Transaction";
|
|
2
|
+
import { getTransaction, sendTransaction } from "@mentaproject/core/actions";
|
|
3
|
+
export class TransactionManager {
|
|
4
|
+
constructor(rpcClient) {
|
|
5
|
+
this.rpcClient = rpcClient;
|
|
6
|
+
}
|
|
7
|
+
;
|
|
8
|
+
async get(params) {
|
|
9
|
+
const data = await getTransaction(this.rpcClient, params);
|
|
10
|
+
return new Transaction(this.rpcClient, data);
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
async send(params) {
|
|
14
|
+
const hash = await sendTransaction(this.rpcClient, params);
|
|
15
|
+
return await this.get({ hash });
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
}
|
|
19
|
+
;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Address, CoreClient } from "@mentaproject/core/types";
|
|
2
|
+
import { Transaction } from "./Transaction";
|
|
3
|
+
import { GetTransactionsReturnType } from "../types/Account";
|
|
4
|
+
/**
|
|
5
|
+
* Represents a user account with methods for interacting with the blockchain.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Account {
|
|
8
|
+
protected rpcClient: CoreClient;
|
|
9
|
+
address: Address;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of Account.
|
|
12
|
+
* @param client The CoreClient instance used for blockchain interactions.
|
|
13
|
+
* @param address The blockchain address of the account.
|
|
14
|
+
*/
|
|
15
|
+
constructor(rpcClient: CoreClient, address: Address);
|
|
16
|
+
/**
|
|
17
|
+
* Sends native cryptocurrency (ETH) to the account.
|
|
18
|
+
* @param amount The amount of ETH to send (in wei).
|
|
19
|
+
* @returns A Promise that resolves to a Transaction object representing the sent transaction.
|
|
20
|
+
*/
|
|
21
|
+
sendETH(amount: bigint): Promise<Transaction>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the native cryptocurrency (ETH) balance of the account.
|
|
24
|
+
* @returns A Promise that resolves to the ETH balance (in wei).
|
|
25
|
+
*/
|
|
26
|
+
getETHBalance(): Promise<bigint>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the transaction count (nonce) for the account.
|
|
29
|
+
* @returns A Promise that resolves to the transaction count.
|
|
30
|
+
**/
|
|
31
|
+
getTransactionCount(): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Get all transactions involving this account in the given block range.
|
|
34
|
+
* NOTE: This method relies on the non-standard 'trace_filter' method of the RPC. It may not be supported by all nodes.
|
|
35
|
+
*
|
|
36
|
+
* @param toRetreive The number of transactions to retrieve.
|
|
37
|
+
*
|
|
38
|
+
* @returns A paginated result containing the transaction hashes.
|
|
39
|
+
*/
|
|
40
|
+
getTransactions(toRetreive: number): Promise<GetTransactionsReturnType>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createBlockRangePager, getBalance, getBlockNumber, getTransaction, getTransactionCount, sendTransaction, traceFilter } from "@mentaproject/core/actions";
|
|
2
|
+
import { Transaction } from "./Transaction";
|
|
3
|
+
import { toHex } from "@mentaproject/core/utils";
|
|
4
|
+
/**
|
|
5
|
+
* Represents a user account with methods for interacting with the blockchain.
|
|
6
|
+
*/
|
|
7
|
+
export class Account {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of Account.
|
|
10
|
+
* @param client The CoreClient instance used for blockchain interactions.
|
|
11
|
+
* @param address The blockchain address of the account.
|
|
12
|
+
*/
|
|
13
|
+
constructor(rpcClient, address) {
|
|
14
|
+
this.rpcClient = rpcClient;
|
|
15
|
+
this.address = address;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Sends native cryptocurrency (ETH) to the account.
|
|
19
|
+
* @param amount The amount of ETH to send (in wei).
|
|
20
|
+
* @returns A Promise that resolves to a Transaction object representing the sent transaction.
|
|
21
|
+
*/
|
|
22
|
+
async sendETH(amount) {
|
|
23
|
+
const hash = await sendTransaction(this.rpcClient, {
|
|
24
|
+
calls: [{
|
|
25
|
+
to: this.address,
|
|
26
|
+
value: amount,
|
|
27
|
+
}]
|
|
28
|
+
});
|
|
29
|
+
const data = await getTransaction(this.rpcClient, { hash });
|
|
30
|
+
return new Transaction(this.rpcClient, data);
|
|
31
|
+
}
|
|
32
|
+
;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the native cryptocurrency (ETH) balance of the account.
|
|
35
|
+
* @returns A Promise that resolves to the ETH balance (in wei).
|
|
36
|
+
*/
|
|
37
|
+
async getETHBalance() {
|
|
38
|
+
// Assurez-vous que rpcClient est bien un PublicClient ou WalletClient
|
|
39
|
+
return await getBalance(this.rpcClient, {
|
|
40
|
+
address: this.address,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the transaction count (nonce) for the account.
|
|
46
|
+
* @returns A Promise that resolves to the transaction count.
|
|
47
|
+
**/
|
|
48
|
+
async getTransactionCount() {
|
|
49
|
+
return await getTransactionCount(this.rpcClient, { address: this.address });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get all transactions involving this account in the given block range.
|
|
53
|
+
* NOTE: This method relies on the non-standard 'trace_filter' method of the RPC. It may not be supported by all nodes.
|
|
54
|
+
*
|
|
55
|
+
* @param toRetreive The number of transactions to retrieve.
|
|
56
|
+
*
|
|
57
|
+
* @returns A paginated result containing the transaction hashes.
|
|
58
|
+
*/
|
|
59
|
+
async getTransactions(toRetreive) {
|
|
60
|
+
const currentBlock = await getBlockNumber(this.rpcClient);
|
|
61
|
+
const onBlockRange = async ({ fromBlock, toBlock }) => {
|
|
62
|
+
const outgoing = await traceFilter(this.rpcClient, {
|
|
63
|
+
fromBlock: toHex(fromBlock),
|
|
64
|
+
toBlock: toHex(toBlock),
|
|
65
|
+
fromAddress: this.address
|
|
66
|
+
});
|
|
67
|
+
const incoming = await traceFilter(this.rpcClient, {
|
|
68
|
+
fromBlock: toHex(fromBlock),
|
|
69
|
+
toBlock: toHex(toBlock),
|
|
70
|
+
toAddress: this.address
|
|
71
|
+
});
|
|
72
|
+
const traces = outgoing.concat(incoming);
|
|
73
|
+
return traces.map(t => ({
|
|
74
|
+
blockNumber: BigInt(t.blockNumber),
|
|
75
|
+
index: t.transactionPosition,
|
|
76
|
+
hash: t.transactionHash
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
return await createBlockRangePager({
|
|
80
|
+
blockLimit: 0n,
|
|
81
|
+
startBlock: currentBlock,
|
|
82
|
+
direction: "backward",
|
|
83
|
+
itemsPerPage: toRetreive
|
|
84
|
+
}, onBlockRange);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Hash, Hex, Withdrawal } from "viem";
|
|
2
|
+
import { Account } from "./Account";
|
|
3
|
+
import { Transaction } from "./Transaction";
|
|
4
|
+
import { IBlockData } from "../types/Block";
|
|
5
|
+
import type { CoreClient } from "@mentaproject/core/types";
|
|
6
|
+
export declare class Block implements Omit<IBlockData, "miner" | "transactions"> {
|
|
7
|
+
rpcClient: CoreClient;
|
|
8
|
+
baseFeePerGas: bigint | null;
|
|
9
|
+
blobGasUsed: bigint;
|
|
10
|
+
difficulty: bigint;
|
|
11
|
+
excessBlobGas: bigint;
|
|
12
|
+
extraData: Hex;
|
|
13
|
+
gasLimit: bigint;
|
|
14
|
+
gasUsed?: bigint;
|
|
15
|
+
hash?: Hash | null;
|
|
16
|
+
logsBloom?: Hex | null;
|
|
17
|
+
mixHash: Hash;
|
|
18
|
+
nonce?: Hex | null;
|
|
19
|
+
number?: bigint | null;
|
|
20
|
+
parentBeaconBlockRoot?: Hex | undefined;
|
|
21
|
+
parentHash: Hash;
|
|
22
|
+
receiptsRoot: Hex;
|
|
23
|
+
sealFields: Hex[];
|
|
24
|
+
sha3Uncles: Hash;
|
|
25
|
+
size: bigint;
|
|
26
|
+
stateRoot: Hash;
|
|
27
|
+
timestamp: bigint;
|
|
28
|
+
totalDifficulty?: bigint | null;
|
|
29
|
+
transactionsRoot: Hash;
|
|
30
|
+
uncles: Hash[];
|
|
31
|
+
withdrawals?: Withdrawal[];
|
|
32
|
+
withdrawalsRoot?: Hex | null;
|
|
33
|
+
miner: Account;
|
|
34
|
+
transactions?: Transaction[];
|
|
35
|
+
constructor(rpcClient: CoreClient, data: IBlockData, includeTransactions?: boolean);
|
|
36
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Account } from "./Account";
|
|
2
|
+
import { Transaction } from "./Transaction";
|
|
3
|
+
export class Block {
|
|
4
|
+
constructor(rpcClient, data, includeTransactions = false) {
|
|
5
|
+
this.rpcClient = rpcClient;
|
|
6
|
+
this.baseFeePerGas = data.baseFeePerGas;
|
|
7
|
+
this.blobGasUsed = data.blobGasUsed;
|
|
8
|
+
this.difficulty = data.difficulty;
|
|
9
|
+
this.excessBlobGas = data.excessBlobGas;
|
|
10
|
+
this.extraData = data.extraData;
|
|
11
|
+
this.gasLimit = data.gasLimit;
|
|
12
|
+
this.gasUsed = data.gasUsed;
|
|
13
|
+
this.hash = data.hash;
|
|
14
|
+
this.logsBloom = data.logsBloom;
|
|
15
|
+
this.mixHash = data.mixHash;
|
|
16
|
+
this.nonce = data.nonce;
|
|
17
|
+
this.number = data.number;
|
|
18
|
+
this.parentBeaconBlockRoot = data.parentBeaconBlockRoot;
|
|
19
|
+
this.parentHash = data.parentHash;
|
|
20
|
+
this.receiptsRoot = data.receiptsRoot;
|
|
21
|
+
this.sealFields = data.sealFields;
|
|
22
|
+
this.sha3Uncles = data.sha3Uncles;
|
|
23
|
+
this.size = data.size;
|
|
24
|
+
this.stateRoot = data.stateRoot;
|
|
25
|
+
this.timestamp = data.timestamp;
|
|
26
|
+
this.totalDifficulty = data.totalDifficulty;
|
|
27
|
+
this.transactionsRoot = data.transactionsRoot;
|
|
28
|
+
this.uncles = data.uncles;
|
|
29
|
+
this.withdrawals = data.withdrawals;
|
|
30
|
+
this.withdrawalsRoot = data.withdrawalsRoot;
|
|
31
|
+
this.miner = new Account(this.rpcClient, data.miner);
|
|
32
|
+
if (includeTransactions)
|
|
33
|
+
this.transactions = data.transactions.map((txData) => new Transaction(this.rpcClient, txData));
|
|
34
|
+
}
|
|
35
|
+
;
|
|
36
|
+
}
|
|
37
|
+
;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CoreClient, CoreClientConfig } from "@mentaproject/core/types";
|
|
2
|
+
import { BlockManager } from "../managers/BlockManager";
|
|
3
|
+
import { TransactionManager } from "../managers/TransactionManager";
|
|
4
|
+
import { ContractManager } from "../managers/ContractManager";
|
|
5
|
+
import { AccountManager } from "../managers/AccountManager";
|
|
6
|
+
export declare class MentaClient {
|
|
7
|
+
rpcClient: CoreClient;
|
|
8
|
+
blocks: BlockManager;
|
|
9
|
+
transactions: TransactionManager;
|
|
10
|
+
contracts: ContractManager;
|
|
11
|
+
accounts: AccountManager;
|
|
12
|
+
constructor(params: CoreClientConfig);
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createClient } from "@mentaproject/core";
|
|
2
|
+
import { BlockManager } from "../managers/BlockManager";
|
|
3
|
+
import { TransactionManager } from "../managers/TransactionManager";
|
|
4
|
+
import { ContractManager } from "../managers/ContractManager";
|
|
5
|
+
import { AccountManager } from "../managers/AccountManager";
|
|
6
|
+
export class MentaClient {
|
|
7
|
+
constructor(params) {
|
|
8
|
+
this.rpcClient = createClient(params);
|
|
9
|
+
this.blocks = new BlockManager(this.rpcClient);
|
|
10
|
+
this.transactions = new TransactionManager(this.rpcClient);
|
|
11
|
+
this.contracts = new ContractManager(this.rpcClient);
|
|
12
|
+
this.accounts = new AccountManager(this.rpcClient);
|
|
13
|
+
}
|
|
14
|
+
;
|
|
15
|
+
}
|
|
16
|
+
;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Account } from './Account';
|
|
2
|
+
import { Block } from './Block';
|
|
3
|
+
import { ITransactionData } from '../types/Transaction';
|
|
4
|
+
import { AccessList, CoreClient, Hash, Hex, TransactionType, WaitForTransactionReceiptReturnType } from '@mentaproject/core/types';
|
|
5
|
+
export declare class Transaction implements Omit<ITransactionData, "from" | "to"> {
|
|
6
|
+
protected rpcClient: CoreClient;
|
|
7
|
+
accessList?: AccessList;
|
|
8
|
+
blobVersionedHashes?: readonly Hex[];
|
|
9
|
+
gas: bigint;
|
|
10
|
+
gasPrice?: bigint;
|
|
11
|
+
hash: Hash;
|
|
12
|
+
input?: Hex;
|
|
13
|
+
maxFeePerGas?: bigint;
|
|
14
|
+
maxPriorityFeePerGas?: bigint;
|
|
15
|
+
nonce: number;
|
|
16
|
+
r: Hex;
|
|
17
|
+
s: Hex;
|
|
18
|
+
transactionIndex?: number | null;
|
|
19
|
+
type: TransactionType;
|
|
20
|
+
v: bigint;
|
|
21
|
+
value: bigint;
|
|
22
|
+
yParity?: number;
|
|
23
|
+
blockHash?: Hash;
|
|
24
|
+
from?: Account;
|
|
25
|
+
to?: Account;
|
|
26
|
+
constructor(rpcClient: CoreClient, data: ITransactionData);
|
|
27
|
+
waitForReceipt(confirmations?: number): Promise<WaitForTransactionReceiptReturnType>;
|
|
28
|
+
receipt(): Promise<WaitForTransactionReceiptReturnType>;
|
|
29
|
+
block(): Promise<Block>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Account } from './Account';
|
|
2
|
+
import { Block } from './Block';
|
|
3
|
+
import { getBlock, getTransactionReceipt, waitForTransactionReceipt } from '@mentaproject/core/actions';
|
|
4
|
+
export class Transaction {
|
|
5
|
+
constructor(rpcClient, data) {
|
|
6
|
+
this.rpcClient = rpcClient;
|
|
7
|
+
this.accessList = data.accessList;
|
|
8
|
+
this.blobVersionedHashes = data.blobVersionedHashes;
|
|
9
|
+
this.gas = data.gas;
|
|
10
|
+
this.gasPrice = data.gasPrice;
|
|
11
|
+
this.hash = data.hash;
|
|
12
|
+
this.input = data.input;
|
|
13
|
+
this.maxFeePerGas = data.maxFeePerGas;
|
|
14
|
+
this.maxPriorityFeePerGas = data.maxPriorityFeePerGas;
|
|
15
|
+
this.nonce = data.nonce;
|
|
16
|
+
this.r = data.r;
|
|
17
|
+
this.s = data.s;
|
|
18
|
+
this.transactionIndex = data.transactionIndex;
|
|
19
|
+
this.type = data.type;
|
|
20
|
+
this.v = data.v;
|
|
21
|
+
this.value = data.value;
|
|
22
|
+
this.yParity = data.yParity;
|
|
23
|
+
this.blockHash = data.blockHash;
|
|
24
|
+
this.from = new Account(this.rpcClient, data.from);
|
|
25
|
+
this.to = data.to ? new Account(this.rpcClient, data.to) : undefined;
|
|
26
|
+
}
|
|
27
|
+
;
|
|
28
|
+
async waitForReceipt(confirmations) {
|
|
29
|
+
return await waitForTransactionReceipt(this.rpcClient, {
|
|
30
|
+
hash: this.hash,
|
|
31
|
+
confirmations: confirmations || 1,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
;
|
|
35
|
+
async receipt() {
|
|
36
|
+
return await getTransactionReceipt(this.rpcClient, { hash: this.hash });
|
|
37
|
+
}
|
|
38
|
+
;
|
|
39
|
+
async block() {
|
|
40
|
+
const data = await getBlock(this.rpcClient, { blockHash: this.blockHash });
|
|
41
|
+
return new Block(this.rpcClient, data);
|
|
42
|
+
}
|
|
43
|
+
;
|
|
44
|
+
}
|
|
45
|
+
;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Address, Hash, Hex, Transaction, Withdrawal } from "viem";
|
|
2
|
+
export interface IBlockData {
|
|
3
|
+
/** Base fee per gas */
|
|
4
|
+
baseFeePerGas: bigint | null;
|
|
5
|
+
/** Total used blob gas by all transactions in this block */
|
|
6
|
+
blobGasUsed: bigint;
|
|
7
|
+
/** Difficulty for this block */
|
|
8
|
+
difficulty: bigint;
|
|
9
|
+
/** Excess blob gas */
|
|
10
|
+
excessBlobGas: bigint;
|
|
11
|
+
/** "Extra data" field of this block */
|
|
12
|
+
extraData: Hex;
|
|
13
|
+
/** Maximum gas allowed in this block */
|
|
14
|
+
gasLimit: bigint;
|
|
15
|
+
/** Total used gas by all transactions in this block */
|
|
16
|
+
gasUsed?: bigint;
|
|
17
|
+
/** Block hash or `null` if pending */
|
|
18
|
+
hash?: Hash | null;
|
|
19
|
+
/** Logs bloom filter or `null` if pending */
|
|
20
|
+
logsBloom?: Hex | null;
|
|
21
|
+
/** Address that received this block’s mining rewards, COINBASE address */
|
|
22
|
+
miner: Address;
|
|
23
|
+
/** Unique identifier for the block. */
|
|
24
|
+
mixHash: Hash;
|
|
25
|
+
/** Proof-of-work hash or `null` if pending */
|
|
26
|
+
nonce?: Hex | null;
|
|
27
|
+
/** Block number or `null` if pending */
|
|
28
|
+
number?: bigint | null;
|
|
29
|
+
/** Root of the parent beacon chain block */
|
|
30
|
+
parentBeaconBlockRoot?: Hex;
|
|
31
|
+
/** Parent block hash */
|
|
32
|
+
parentHash: Hash;
|
|
33
|
+
/** Root of the this block’s receipts trie */
|
|
34
|
+
receiptsRoot: Hex;
|
|
35
|
+
sealFields: Hex[];
|
|
36
|
+
/** SHA3 of the uncles data in this block */
|
|
37
|
+
sha3Uncles: Hash;
|
|
38
|
+
/** Size of this block in bytes */
|
|
39
|
+
size: bigint;
|
|
40
|
+
/** Root of this block’s final state trie */
|
|
41
|
+
stateRoot: Hash;
|
|
42
|
+
/** Unix timestamp of when this block was collated */
|
|
43
|
+
timestamp: bigint;
|
|
44
|
+
/** Total difficulty of the chain until this block */
|
|
45
|
+
totalDifficulty?: bigint | null;
|
|
46
|
+
/** List of transaction object or hashes */
|
|
47
|
+
transactions: Transaction[] | Hash[];
|
|
48
|
+
/** Root of this block’s transaction trie */
|
|
49
|
+
transactionsRoot: Hash;
|
|
50
|
+
/** List of uncle hashes */
|
|
51
|
+
uncles: Hash[];
|
|
52
|
+
/** List of withdrawal objects */
|
|
53
|
+
withdrawals?: Withdrawal[];
|
|
54
|
+
/** Root of the this block’s withdrawals trie */
|
|
55
|
+
withdrawalsRoot?: Hex | null;
|
|
56
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AccessList, Address, Hash, Hex, TransactionType } from "@mentaproject/core/types";
|
|
2
|
+
export type TransactionDirection = "in" | "out";
|
|
3
|
+
export interface ITransactionData {
|
|
4
|
+
/** EIP-2930 Access List. */
|
|
5
|
+
accessList?: AccessList;
|
|
6
|
+
/** List of versioned blob hashes associated with the transaction's blobs. */
|
|
7
|
+
blobVersionedHashes?: readonly Hex[];
|
|
8
|
+
/** Gas provided for transaction execution */
|
|
9
|
+
gas: bigint;
|
|
10
|
+
/** Base fee per gas. */
|
|
11
|
+
gasPrice?: bigint;
|
|
12
|
+
/** Hash of the transaction. */
|
|
13
|
+
hash: Hash;
|
|
14
|
+
/** Contract code or a hashed method call */
|
|
15
|
+
input?: Hex;
|
|
16
|
+
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas) */
|
|
17
|
+
maxFeePerGas?: bigint;
|
|
18
|
+
/** Max priority fee per gas (in wei). */
|
|
19
|
+
maxPriorityFeePerGas?: bigint;
|
|
20
|
+
/** Unique number identifying this transaction */
|
|
21
|
+
nonce: number;
|
|
22
|
+
/** ECDSA signature r */
|
|
23
|
+
r: Hex;
|
|
24
|
+
/** ECDSA signature s */
|
|
25
|
+
s: Hex;
|
|
26
|
+
/** Index of this transaction in the block or null if pending */
|
|
27
|
+
transactionIndex?: number | null;
|
|
28
|
+
/** The type of transaction */
|
|
29
|
+
type: TransactionType;
|
|
30
|
+
/** ECDSA recovery ID */
|
|
31
|
+
v: bigint;
|
|
32
|
+
/** Value in wei sent with this transaction */
|
|
33
|
+
value: bigint;
|
|
34
|
+
/** The parity of the y-value of the secp256k1 signature. */
|
|
35
|
+
yParity?: number;
|
|
36
|
+
/** Block from which the transaction was included */
|
|
37
|
+
blockHash?: Hash;
|
|
38
|
+
/** Transaction sender */
|
|
39
|
+
from: Address;
|
|
40
|
+
/** Transaction recipient or `null` if deploying a contract */
|
|
41
|
+
to?: Address | null;
|
|
42
|
+
}
|
|
43
|
+
export interface IGetTransactionBlockParams {
|
|
44
|
+
includeTransactions?: boolean;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GetTransactionReceiptReturnType } from "@mentaproject/core/types";
|
|
2
|
+
export interface IDecodedLog<T extends {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
} = {}> {
|
|
5
|
+
eventName: string;
|
|
6
|
+
args: T;
|
|
7
|
+
}
|
|
8
|
+
export interface ITransactionReceiptData extends GetTransactionReceiptReturnType {
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Abi, Address } from 'viem';
|
|
2
|
+
import { CoreClient } from '@mentaproject/core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Vérifie de manière plus "absolue" si un contrat est conforme à une ABI
|
|
5
|
+
* en utilisant ERC-165 (if applicable) et en simulant les appels de fonctions.
|
|
6
|
+
*
|
|
7
|
+
* @param client - Le client viem connecté au réseau.
|
|
8
|
+
* @param contractAddress - L'adresse du contrat à vérifier.
|
|
9
|
+
* @param contractAbi - L'ABI complète du contrat.
|
|
10
|
+
* @param options - Options pour la vérification : { erc165InterfaceId?: any } // Utilisation de 'any' pour contourner l'erreur de type bytes4
|
|
11
|
+
* @returns True si le contrat semble implémenter toutes les fonctions de l'ABI (Selon les checks), False sinon.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isContractCompliantWithAbi(client: CoreClient, contractAddress: Address, contractAbi: Abi, options?: {
|
|
14
|
+
erc165InterfaceId?: any;
|
|
15
|
+
}): Promise<boolean>;
|