1 | /// <reference types="bn.js" />
|
2 | /// <reference types="node" />
|
3 | import { BN } from './externals';
|
4 | import { BNLike, BufferLike } from './types';
|
5 | export interface AccountData {
|
6 | nonce?: BNLike;
|
7 | balance?: BNLike;
|
8 | stateRoot?: BufferLike;
|
9 | codeHash?: BufferLike;
|
10 | }
|
11 | export declare class Account {
|
12 | nonce: BN;
|
13 | balance: BN;
|
14 | stateRoot: Buffer;
|
15 | codeHash: Buffer;
|
16 | static fromAccountData(accountData: AccountData): Account;
|
17 | static fromRlpSerializedAccount(serialized: Buffer): Account;
|
18 | static fromValuesArray(values: Buffer[]): Account;
|
19 | /**
|
20 | * This constructor assigns and validates the values.
|
21 | * Use the static factory methods to assist in creating an Account from varying data types.
|
22 | */
|
23 | constructor(nonce?: BN, balance?: BN, stateRoot?: Buffer, codeHash?: Buffer);
|
24 | private _validate;
|
25 | /**
|
26 | * Returns a Buffer Array of the raw Buffers for the account, in order.
|
27 | */
|
28 | raw(): Buffer[];
|
29 | /**
|
30 | * Returns the RLP serialization of the account as a `Buffer`.
|
31 | */
|
32 | serialize(): Buffer;
|
33 | /**
|
34 | * Returns a `Boolean` determining if the account is a contract.
|
35 | */
|
36 | isContract(): boolean;
|
37 | /**
|
38 | * Returns a `Boolean` determining if the account is empty complying to the definition of
|
39 | * account emptiness in [EIP-161](https://eips.ethereum.org/EIPS/eip-161):
|
40 | * "An account is considered empty when it has no code and zero nonce and zero balance."
|
41 | */
|
42 | isEmpty(): boolean;
|
43 | }
|
44 | /**
|
45 | * Checks if the address is a valid. Accepts checksummed addresses too.
|
46 | */
|
47 | export declare const isValidAddress: (hexAddress: string) => boolean;
|
48 | /**
|
49 | * Returns a checksummed address.
|
50 | *
|
51 | * If an eip1191ChainId is provided, the chainId will be included in the checksum calculation. This
|
52 | * has the effect of checksummed addresses for one chain having invalid checksums for others.
|
53 | * For more details see [EIP-1191](https://eips.ethereum.org/EIPS/eip-1191).
|
54 | *
|
55 | * WARNING: Checksums with and without the chainId will differ and the EIP-1191 checksum is not
|
56 | * backwards compatible to the original widely adopted checksum format standard introduced in
|
57 | * [EIP-55](https://eips.ethereum.org/EIPS/eip-55), so this will break in existing applications.
|
58 | * Usage of this EIP is therefore discouraged unless you have a very targeted use case.
|
59 | */
|
60 | export declare const toChecksumAddress: (hexAddress: string, eip1191ChainId?: BNLike) => string;
|
61 | /**
|
62 | * Checks if the address is a valid checksummed address.
|
63 | *
|
64 | * See toChecksumAddress' documentation for details about the eip1191ChainId parameter.
|
65 | */
|
66 | export declare const isValidChecksumAddress: (hexAddress: string, eip1191ChainId?: BNLike) => boolean;
|
67 | /**
|
68 | * Generates an address of a newly created contract.
|
69 | * @param from The address which is creating this new address
|
70 | * @param nonce The nonce of the from account
|
71 | */
|
72 | export declare const generateAddress: (from: Buffer, nonce: Buffer) => Buffer;
|
73 | /**
|
74 | * Generates an address for a contract created using CREATE2.
|
75 | * @param from The address which is creating this new address
|
76 | * @param salt A salt
|
77 | * @param initCode The init code of the contract being created
|
78 | */
|
79 | export declare const generateAddress2: (from: Buffer, salt: Buffer, initCode: Buffer) => Buffer;
|
80 | /**
|
81 | * Checks if the private key satisfies the rules of the curve secp256k1.
|
82 | */
|
83 | export declare const isValidPrivate: (privateKey: Buffer) => boolean;
|
84 | /**
|
85 | * Checks if the public key satisfies the rules of the curve secp256k1
|
86 | * and the requirements of Ethereum.
|
87 | * @param publicKey The two points of an uncompressed key, unless sanitize is enabled
|
88 | * @param sanitize Accept public keys in other formats
|
89 | */
|
90 | export declare const isValidPublic: (publicKey: Buffer, sanitize?: boolean) => boolean;
|
91 | /**
|
92 | * Returns the ethereum address of a given public key.
|
93 | * Accepts "Ethereum public keys" and SEC1 encoded keys.
|
94 | * @param pubKey The two points of an uncompressed key, unless sanitize is enabled
|
95 | * @param sanitize Accept public keys in other formats
|
96 | */
|
97 | export declare const pubToAddress: (pubKey: Buffer, sanitize?: boolean) => Buffer;
|
98 | export declare const publicToAddress: (pubKey: Buffer, sanitize?: boolean) => Buffer;
|
99 | /**
|
100 | * Returns the ethereum public key of a given private key.
|
101 | * @param privateKey A private key must be 256 bits wide
|
102 | */
|
103 | export declare const privateToPublic: (privateKey: Buffer) => Buffer;
|
104 | /**
|
105 | * Returns the ethereum address of a given private key.
|
106 | * @param privateKey A private key must be 256 bits wide
|
107 | */
|
108 | export declare const privateToAddress: (privateKey: Buffer) => Buffer;
|
109 | /**
|
110 | * Converts a public key to the Ethereum format.
|
111 | */
|
112 | export declare const importPublic: (publicKey: Buffer) => Buffer;
|
113 | /**
|
114 | * Returns the zero address.
|
115 | */
|
116 | export declare const zeroAddress: () => string;
|
117 | /**
|
118 | * Checks if a given address is the zero address.
|
119 | */
|
120 | export declare const isZeroAddress: (hexAddress: string) => boolean;
|
121 |
|
\ | No newline at end of file |