diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-28 22:26:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-28 22:26:05 +0800 |
commit | 8926dac78c3ac8d75ad5ffd5b4febe36def4e53c (patch) | |
tree | 01c1b3f8dba486beb4e83e67ad0bc35c3da6a14e /packages/types | |
parent | 18cac3f0927a0424e3618fd56dba73fc9dfc0288 (diff) | |
parent | 01e27426d643b525661e044dbb8c8f27734329e7 (diff) | |
download | dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar.gz dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar.zst dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.zip |
Merge pull request #482 from 0xProject/feature/web3-types
Move common types out of web3 types
Diffstat (limited to 'packages/types')
-rw-r--r-- | packages/types/package.json | 5 | ||||
-rw-r--r-- | packages/types/src/index.ts | 201 | ||||
-rw-r--r-- | packages/types/tsconfig.json | 1 |
3 files changed, 194 insertions, 13 deletions
diff --git a/packages/types/package.json b/packages/types/package.json index 1142d252a..16737f5ea 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -22,15 +22,14 @@ "devDependencies": { "@0xproject/monorepo-scripts": "^0.1.14", "@0xproject/tslint-config": "^0.4.12", + "@types/node": "^8.0.53", "copyfiles": "^1.2.0", "shx": "^0.2.2", "tslint": "5.8.0", "typescript": "2.7.1" }, "dependencies": { - "@0xproject/typescript-typings": "^0.0.1", - "bignumber.js": "~4.1.0", - "web3": "^0.20.0" + "bignumber.js": "~4.1.0" }, "publishConfig": { "access": "public" diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 2147a3edb..57b14e230 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,14 +1,195 @@ import { BigNumber } from 'bignumber.js'; -import * as Web3 from 'web3'; -export interface TxData { +export type ContractAbi = AbiDefinition[]; + +export type AbiDefinition = FunctionAbi | EventAbi; + +export type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi; + +export type ConstructorStateMutability = 'nonpayable' | 'payable'; +export type StateMutability = 'pure' | 'view' | ConstructorStateMutability; + +export interface MethodAbi { + type: AbiType.Function; + name: string; + inputs: DataItem[]; + outputs: DataItem[]; + constant: boolean; + stateMutability: StateMutability; + payable: boolean; +} + +export interface ConstructorAbi { + type: AbiType.Constructor; + inputs: DataItem[]; + payable: boolean; + stateMutability: ConstructorStateMutability; +} + +export interface FallbackAbi { + type: AbiType.Fallback; + payable: boolean; +} + +export interface EventParameter extends DataItem { + indexed: boolean; +} + +export interface EventAbi { + type: AbiType.Event; + name: string; + inputs: EventParameter[]; + anonymous: boolean; +} + +export interface DataItem { + name: string; + type: string; + components: DataItem[]; +} + +export type OpCode = string; + +export interface StructLog { + depth: number; + error: string; + gas: number; + gasCost: number; + memory: string[]; + op: OpCode; + pc: number; + stack: string[]; + storage: { [location: string]: string }; +} + +export interface TransactionTrace { + gas: number; + returnValue: any; + structLogs: StructLog[]; +} + +export type Unit = + | 'kwei' + | 'ada' + | 'mwei' + | 'babbage' + | 'gwei' + | 'shannon' + | 'szabo' + | 'finney' + | 'ether' + | 'kether' + | 'grand' + | 'einstein' + | 'mether' + | 'gether' + | 'tether'; + +export interface JSONRPCRequestPayload { + params: any[]; + method: string; + id: number; + jsonrpc: string; +} + +export interface JSONRPCResponsePayload { + result: any; + id: number; + jsonrpc: string; +} + +export interface AbstractBlock { + number: number | null; + hash: string | null; + parentHash: string; + nonce: string | null; + sha3Uncles: string; + logsBloom: string | null; + transactionsRoot: string; + stateRoot: string; + miner: string; + difficulty: BigNumber; + totalDifficulty: BigNumber; + extraData: string; + size: number; + gasLimit: number; + gasUsed: number; + timestamp: number; + uncles: string[]; +} + +export interface BlockWithoutTransactionData extends AbstractBlock { + transactions: string[]; +} + +export interface BlockWithTransactionData extends AbstractBlock { + transactions: Transaction[]; +} + +export interface Transaction { + hash: string; + nonce: number; + blockHash: string | null; + blockNumber: number | null; + transactionIndex: number | null; + from: string; + to: string | null; + value: BigNumber; + gasPrice: BigNumber; + gas: number; + input: string; +} + +export interface CallTxDataBase { + to?: string; + value?: number | string | BigNumber; + gas?: number | string | BigNumber; + gasPrice?: number | string | BigNumber; data?: string; - from?: string; - gas?: number; - gasPrice?: BigNumber; nonce?: number; } +export interface TxData extends CallTxDataBase { + from: string; +} + +export interface CallData extends CallTxDataBase { + from?: string; +} + +export interface FilterObject { + fromBlock?: number | string; + toBlock?: number | string; + address?: string; + topics?: LogTopic[]; +} + +export type LogTopic = null | string | string[]; + +export interface DecodedLogEntry<A> extends LogEntry { + event: string; + args: A; +} + +export interface DecodedLogEntryEvent<A> extends DecodedLogEntry<A> { + removed: boolean; +} + +export interface LogEntryEvent extends LogEntry { + removed: boolean; +} + +export interface LogEntry { + logIndex: number | null; + transactionIndex: number | null; + transactionHash: string; + blockHash: string | null; + blockNumber: number | null; + address: string; + data: string; + topics: string[]; +} + export interface TxDataPayable extends TxData { value?: BigNumber; } @@ -20,11 +201,11 @@ export interface TransactionReceipt { transactionIndex: number; from: string; to: string; - status: null | 0 | 1; + status: null | string | 0 | 1; cumulativeGasUsed: number; gasUsed: number; contractAddress: string | null; - logs: Web3.LogEntry[]; + logs: LogEntry[]; } export enum AbiType { @@ -40,8 +221,8 @@ export interface DecodedLogArgs { [argName: string]: ContractEventArg; } -export interface LogWithDecodedArgs<ArgsType> extends Web3.DecodedLogEntry<ArgsType> {} -export type RawLog = Web3.LogEntry; +export interface LogWithDecodedArgs<ArgsType> extends DecodedLogEntry<ArgsType> {} +export type RawLog = LogEntry; export enum SolidityTypes { Address = 'address', Uint256 = 'uint256', @@ -50,7 +231,7 @@ export enum SolidityTypes { } export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt { - logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>; + logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>; } // Earliest is omitted by design. It is simply an alias for the `0` constant and diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index c56d255d5..5ec2db5e0 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig", "compilerOptions": { + "typeRoots": ["node_modules/@types"], "outDir": "lib" }, "include": ["./src/**/*"] |