Refactor built-in constants.
This commit is contained in:
parent
fe3270a6fe
commit
16f3c44daa
@ -2,5 +2,5 @@
|
||||
/**
|
||||
* A constant for the zero address.
|
||||
*/
|
||||
export const ZeroAddress = "0x0000000000000000000000000000000000000000";
|
||||
export const ZeroAddress: string = "0x0000000000000000000000000000000000000000";
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* A constant for the zero hash.
|
||||
*/
|
||||
export const ZeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
||||
export const ZeroHash: string = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
/**
|
||||
* Some common constants useful for Ethereum.
|
||||
*
|
||||
* @_section: api/constants: Constants [constants]
|
||||
*/
|
||||
|
||||
export { ZeroAddress } from "./addresses.js";
|
||||
export { ZeroHash } from "./hashes.js";
|
||||
export {
|
||||
NegativeOne,
|
||||
Zero,
|
||||
One,
|
||||
Two,
|
||||
N,
|
||||
WeiPerEther,
|
||||
MaxUint256,
|
||||
|
@ -1,57 +1,25 @@
|
||||
|
||||
/**
|
||||
* A constant for the BigInt of -1.
|
||||
*/
|
||||
const NegativeOne = BigInt(-1);
|
||||
|
||||
/**
|
||||
* A constant for the BigInt of 0.
|
||||
*/
|
||||
const Zero = BigInt(0);
|
||||
|
||||
/**
|
||||
* A constant for the BigInt of 1.
|
||||
*/
|
||||
const One = BigInt(1);
|
||||
|
||||
/**
|
||||
* A constant for the BigInt of 2.
|
||||
*/
|
||||
const Two = BigInt(2);
|
||||
|
||||
/**
|
||||
* A constant for the order N for the secp256k1 curve.
|
||||
*/
|
||||
const N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
||||
export const N: bigint = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
||||
|
||||
/**
|
||||
* A constant for the number of wei in a single ether.
|
||||
*/
|
||||
const WeiPerEther = BigInt("1000000000000000000");
|
||||
export const WeiPerEther: bigint = BigInt("1000000000000000000");
|
||||
|
||||
/**
|
||||
* A constant for the maximum value for a ``uint256``.
|
||||
*/
|
||||
const MaxUint256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
export const MaxUint256: bigint = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
|
||||
/**
|
||||
* A constant for the minimum value for an ``int256``.
|
||||
*/
|
||||
const MinInt256 = BigInt("0x8000000000000000000000000000000000000000000000000000000000000000") * NegativeOne;
|
||||
export const MinInt256: bigint = BigInt("0x8000000000000000000000000000000000000000000000000000000000000000") * BigInt(-1);
|
||||
|
||||
/**
|
||||
* A constant for the maximum value for an ``int256``.
|
||||
*/
|
||||
const MaxInt256 = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
|
||||
export {
|
||||
NegativeOne,
|
||||
Zero,
|
||||
One,
|
||||
Two,
|
||||
N,
|
||||
WeiPerEther,
|
||||
MaxUint256,
|
||||
MinInt256,
|
||||
MaxInt256,
|
||||
};
|
||||
export const MaxInt256: bigint = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* A constant for the ether symbol (normalized using NFKC).
|
||||
*/
|
||||
export const EtherSymbol = "\u039e"; // "\uD835\uDF63";
|
||||
export const EtherSymbol: string = "\u039e"; // "\uD835\uDF63";
|
||||
|
||||
|
||||
export const MessagePrefix = "\x19Ethereum Signed Message:\n";
|
||||
export const MessagePrefix: string = "\x19Ethereum Signed Message:\n";
|
||||
|
Loading…
Reference in New Issue
Block a user