UNPKG

2.74 kBPlain TextView Raw
1import * as ethers from "ethers";
2import { providers, utils } from "ethers";
3
4export { Contract } from "ethers";
5
6export type JsonRpcProvider = providers.JsonRpcProvider;
7export const JsonRpcProvider = providers.JsonRpcProvider;
8
9export type TransactionReceipt = providers.TransactionReceipt;
10
11export type TransactionResponse = providers.TransactionResponse;
12
13export type BigNumberish = ethers.BigNumberish;
14export type Network = providers.Network;
15export type Transaction = providers.TransactionRequest;
16
17// special strings
18// these function more as documentation for devs than checked types
19export type ABIEncoding = string; // eg "tuple(address to, uint256 amount)"
20export type Address = string; // aka HexString of length 42
21export type AssetId = string; // aka Address of ERC20 token contract or AddressZero for ETH
22export type Bytes32 = string; // aka HexString of length 66
23export type DecString = string; // eg "3.14"
24export type HexString = string; // eg "0xabc123" of arbitrary length
25export type PublicIdentifier = string; // "indra" + base58(<publicKey>)
26export type PublicKey = string; // aka HexString of length 132
27export type PrivateKey = string; // aka Bytes32
28export type SignatureString = string; // aka HexString of length 132
29export type UrlString = string; // eg "<protocol>://<host>[:<port>]/<path>
30
31export type BigNumber = ethers.BigNumber;
32export const BigNumber = ethers.BigNumber;
33
34// result of JSON.stringify(toBN(1))
35// bigNumberifyJson & deBigNumberifyJson convert values between BigNumber & BigNumberJson
36export type BigNumberJson = { _hex: HexString; _isBigNumber: true };
37
38export type StringMapping = { [key: string]: string };
39
40export interface EthSignature {
41 r: string;
42 s: string;
43 v: string;
44}
45
46// This is copied from the ethers definition of how an ABI is typed.
47export type ContractABI = Array<string | utils.ParamType> | string | utils.Interface;
48
49export type SolidityPrimitiveType = string | ethers.BigNumberish | boolean;
50
51type SolidityABIEncoderV2Struct = {
52 [x: string]: SolidityValueType;
53};
54
55// TODO: fix circular type def
56// @ts-ignore
57type SolidityABIEncoderV2SArray = Array<SolidityValueType>;
58
59// The application-specific state of an app instance, to be interpreted by the
60// app developer. We just treat it as an opaque blob; however since we pass this
61// around in protocol messages and include this in transaction data in challenges,
62// we impose some restrictions on the type; they must be serializable both as
63// JSON and as solidity structs.
64
65// TODO: fix circular type def
66// @ts-ignore
67export type SolidityValueType =
68 | SolidityPrimitiveType
69 | SolidityABIEncoderV2Struct
70 | SolidityABIEncoderV2SArray;
71
72export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;