UNPKG

19 kBTypeScriptView Raw
1import { BigNumber } from 'bignumber.js';
2export declare type JSONRPCErrorCallback = (err: Error | null, result?: JSONRPCResponsePayload) => void;
3/**
4 * Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library
5 * Read more about Providers in the guides section of the 0x docs.
6 */
7export declare type SupportedProvider = Web3JsProvider | GanacheProvider | EIP1193Provider | ZeroExProvider;
8export declare type Web3JsProvider = Web3JsV1Provider | Web3JsV2Provider | Web3JsV3Provider;
9export interface GanacheProvider {
10 sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
11}
12export interface Provider {
13 sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
14}
15/**
16 * The interface for the provider used internally by 0x libraries
17 * Any property we use from any SupportedProvider should we explicitly
18 * add here
19 */
20export interface ZeroExProvider {
21 isZeroExProvider?: boolean;
22 isMetaMask?: boolean;
23 isParity?: boolean;
24 stop?(): void;
25 enable?(): Promise<void>;
26 sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
27}
28/**
29 * Web3.js version 1 provider interface
30 * This provider interface was implemented in the pre-1.0Beta releases for Web3.js.
31 * This interface allowed sending synchonous requests, support for which was later dropped.
32 */
33export interface Web3JsV1Provider {
34 sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
35 send(payload: JSONRPCRequestPayload): JSONRPCResponsePayload;
36}
37/**
38 * Web3.js version 2 provider interface
39 * This provider interface was used in a couple of Web3.js 1.0 beta releases
40 * before the first attempts to conform to EIP1193
41 */
42export interface Web3JsV2Provider {
43 send(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
44}
45/**
46 * Web3.js version 3 provider interface
47 * This provider interface was implemented with the hopes for conforming to the EIP1193 spec,
48 * however it does not conform entirely.
49 */
50export interface Web3JsV3Provider {
51 send(method: string, params?: any[]): Promise<any>;
52}
53/**
54 * Interface for providers that conform to EIP 1193
55 * Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md
56 */
57export declare type EIP1193Event = 'accountsChanged' | 'networkChanged' | 'close' | 'connect' | 'notification';
58export interface EIP1193Provider {
59 isEIP1193: boolean;
60 send(method: string, params?: any[]): Promise<any>;
61 on(event: EIP1193Event, listener: (result: any) => void): this;
62}
63export declare type ContractAbi = AbiDefinition[];
64export declare type AbiDefinition = FunctionAbi | EventAbi | RevertErrorAbi;
65export declare type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi;
66export declare type ConstructorStateMutability = 'nonpayable' | 'payable';
67export declare type StateMutability = 'pure' | 'view' | ConstructorStateMutability;
68export interface MethodAbi {
69 type: string;
70 name: string;
71 inputs: DataItem[];
72 outputs: DataItem[];
73 constant?: boolean;
74 stateMutability: StateMutability;
75 payable?: boolean;
76}
77export interface ConstructorAbi {
78 type: string;
79 inputs: DataItem[];
80 payable?: boolean;
81 stateMutability: ConstructorStateMutability;
82}
83export interface FallbackAbi {
84 type: string;
85 payable: boolean;
86}
87export interface EventParameter extends DataItem {
88 indexed: boolean;
89}
90export interface RevertErrorAbi {
91 type: 'error';
92 name: string;
93 arguments?: DataItem[];
94}
95export interface EventAbi {
96 type: string;
97 name: string;
98 inputs: EventParameter[];
99 anonymous: boolean;
100}
101export interface DataItem {
102 name: string;
103 type: string;
104 internalType?: string;
105 components?: DataItem[];
106}
107export interface TupleDataItem extends DataItem {
108 components: DataItem[];
109}
110export declare enum OpCode {
111 Stop = "STOP",
112 Add = "ADD",
113 Mul = "MUL",
114 Sub = "SUB",
115 Div = "DIV",
116 SDiv = "SDIV",
117 Mod = "MOD",
118 SMod = "SMOD",
119 AddMod = "ADDMOD",
120 MulMod = "MULMOD",
121 Exp = "EXP",
122 SignExtend = "SIGNEXTEND",
123 Lt = "LT",
124 Gt = "GT",
125 SLt = "SLT",
126 SGt = "SGT",
127 Eq = "EQ",
128 IsZero = "ISZERO",
129 And = "AND",
130 Or = "OR",
131 Xor = "XOR",
132 Not = "NOT",
133 Byte = "BYTE",
134 Sha3 = "SHA3",
135 Address = "ADDRESS",
136 Balance = "BALANCE",
137 Origin = "ORIGIN",
138 Caller = "CALLER",
139 CallValue = "CALLVALUE",
140 CallDataLoad = "CALLDATALOAD",
141 CallDataSize = "CALLDATASIZE",
142 CallDataCopy = "CALLDATACOPY",
143 CodeSize = "CODESIZE",
144 CodeCopy = "CODECOPY",
145 GasPrice = "GASPRICE",
146 ExtCodeSize = "EXTCODESIZE",
147 ExtCodeCopy = "EXTCODECOPY",
148 ReturnDataSize = "RETURNDATASIZE",
149 ReturnDataCopy = "RETURNDATACOPY",
150 BlockHash = "BLOCKHASH",
151 Coinbase = "COINBASE",
152 TimeStamp = "TimeStamp",
153 Number = "NUMBER",
154 Difficulty = "DIFFICULTY",
155 Gaslimit = "GASLIMIT",
156 Pop = "POP",
157 MLoad = "MLOAD",
158 MStore = "MSTORE",
159 MStore8 = "MSTORE8",
160 SLoad = "SLOAD",
161 SStore = "SSTORE",
162 Jump = "JUMP",
163 Jumpi = "JUMPI",
164 Pc = "PC",
165 MSize = "MSIZE",
166 Gas = "GAS",
167 JumpDest = "JUMPDEST",
168 Push1 = "PUSH1",
169 Push2 = "PUSH2",
170 Push3 = "PUSH3",
171 Push4 = "PUSH4",
172 Push5 = "PUSH5",
173 Push6 = "PUSH6",
174 Push7 = "PUSH7",
175 Push8 = "PUSH8",
176 Push9 = "PUSH9",
177 Push10 = "PUSH10",
178 Push11 = "PUSH11",
179 Push12 = "PUSH12",
180 Push13 = "PUSH13",
181 Push14 = "PUSH14",
182 Push15 = "PUSH15",
183 Push16 = "PUSH16",
184 Push17 = "PUSH17",
185 Push18 = "PUSH18",
186 Push19 = "PUSH19",
187 Push20 = "PUSH20",
188 Push21 = "PUSH21",
189 Push22 = "PUSH22",
190 Push23 = "PUSH23",
191 Push24 = "PUSH24",
192 Push25 = "PUSH25",
193 Push26 = "PUSH26",
194 Push27 = "PUSH27",
195 Push28 = "PUSH28",
196 Push29 = "PUSH29",
197 Push30 = "PUSH30",
198 Push31 = "PUSH31",
199 Push32 = "PUSH32",
200 Dup1 = "DUP1",
201 Dup2 = "DUP2",
202 Dup3 = "DUP3",
203 Dup4 = "DUP4",
204 Dup5 = "DUP5",
205 Dup6 = "DUP6",
206 Dup7 = "DUP7",
207 Dup8 = "DUP8",
208 Dup9 = "DUP9",
209 Dup10 = "DUP10",
210 Dup11 = "DUP11",
211 Dup12 = "DUP12",
212 Dup13 = "DUP13",
213 Dup14 = "DUP14",
214 Dup15 = "DUP15",
215 Dup16 = "DUP16",
216 Swap1 = "SWAP1",
217 Swap2 = "SWAP2",
218 Swap3 = "SWAP3",
219 Swap4 = "SWAP4",
220 Swap5 = "SWAP5",
221 Swap6 = "SWAP6",
222 Swap7 = "SWAP7",
223 Swap8 = "SWAP8",
224 Swap9 = "SWAP9",
225 Swap10 = "SWAP10",
226 Swap11 = "SWAP11",
227 Swap12 = "SWAP12",
228 Swap13 = "SWAP13",
229 Swap14 = "SWAP14",
230 Swap15 = "SWAP15",
231 Swap16 = "SWAP16",
232 Log1 = "LOG1",
233 Log2 = "LOG2",
234 Log3 = "LOG3",
235 Log4 = "LOG4",
236 Create = "CREATE",
237 Call = "CALL",
238 CallCode = "CALLCODE",
239 Return = "RETURN",
240 DelegateCall = "DELEGATECALL",
241 StaticCall = "STATICCALL",
242 Revert = "REVERT",
243 Invalid = "INVALID",
244 SelfDestruct = "SELFDESTRUCT"
245}
246export interface StructLog {
247 depth: number;
248 error: string;
249 gas: number;
250 gasCost: number;
251 memory: string[];
252 op: OpCode;
253 pc: number;
254 stack: string[];
255 storage: {
256 [location: string]: string;
257 };
258}
259export interface TransactionTrace {
260 gas: number;
261 returnValue: any;
262 structLogs: StructLog[];
263}
264export declare type Unit = 'kwei' | 'ada' | 'mwei' | 'babbage' | 'gwei' | 'shannon' | 'szabo' | 'finney' | 'ether' | 'kether' | 'grand' | 'einstein' | 'mether' | 'gether' | 'tether';
265export interface JSONRPCRequestPayload {
266 params: any[];
267 method: string;
268 id: number;
269 jsonrpc: string;
270}
271export interface JSONRPCResponseError {
272 message: string;
273 code: number;
274}
275export interface JSONRPCResponsePayload {
276 result: any;
277 id: number;
278 jsonrpc: string;
279 error?: JSONRPCResponseError;
280}
281export interface AbstractBlock {
282 number: number | null;
283 hash: string | null;
284 parentHash: string;
285 nonce: string | null;
286 sha3Uncles: string;
287 logsBloom: string | null;
288 transactionsRoot: string;
289 stateRoot: string;
290 miner: string;
291 difficulty: BigNumber;
292 totalDifficulty: BigNumber;
293 extraData: string;
294 size: number;
295 gasLimit: number;
296 gasUsed: number;
297 timestamp: number;
298 uncles: string[];
299}
300export interface BlockWithoutTransactionData extends AbstractBlock {
301 transactions: string[];
302}
303export interface BlockWithTransactionData extends AbstractBlock {
304 transactions: Transaction[];
305}
306export interface Transaction {
307 hash: string;
308 nonce: number;
309 blockHash: string | null;
310 blockNumber: number | null;
311 transactionIndex: number | null;
312 from: string;
313 to: string | null;
314 value: BigNumber;
315 gasPrice?: BigNumber;
316 maxFeePerGas?: BigNumber;
317 maxPriorityFeePerGas?: BigNumber;
318 gas: number;
319 input: string;
320}
321export interface CallTxDataBase {
322 to?: string;
323 value?: number | string | BigNumber;
324 gas?: number | string | BigNumber;
325 gasPrice?: number | string | BigNumber;
326 maxFeePerGas?: number | string | BigNumber;
327 maxPriorityFeePerGas?: number | string | BigNumber;
328 data?: string;
329 nonce?: number;
330 accessList?: TxAccessList;
331}
332export interface TxData extends CallTxDataBase {
333 from: string;
334}
335export interface TxAccessList {
336 [address: string]: string[];
337}
338export interface TxAccessListWithGas {
339 accessList: TxAccessList;
340 gasUsed: number;
341}
342export interface GethCallOverrides {
343 [address: string]: {
344 code?: string;
345 nonce?: number;
346 balance?: number | string | BigNumber;
347 };
348}
349export interface CallData extends CallTxDataBase {
350 from?: string;
351 overrides?: GethCallOverrides;
352}
353export interface FilterObject {
354 fromBlock?: number | string;
355 toBlock?: number | string;
356 blockHash?: string;
357 address?: string;
358 topics?: LogTopic[];
359}
360export declare type LogTopic = null | string | string[];
361export interface DecodedLogEntry<A> extends LogEntry {
362 event: string;
363 args: A;
364}
365export interface DecodedLogEntryEvent<A> extends DecodedLogEntry<A> {
366 removed: boolean;
367}
368export interface LogEntryEvent extends LogEntry {
369 removed: boolean;
370}
371export interface LogEntry {
372 logIndex: number | null;
373 transactionIndex: number | null;
374 transactionHash: string;
375 blockHash: string | null;
376 blockNumber: number | null;
377 address: string;
378 data: string;
379 topics: string[];
380}
381export declare type DecodedLogs = Array<LogWithDecodedArgs<DecodedLogArgs>>;
382export interface TxDataPayable extends TxData {
383 value?: BigNumber;
384}
385export declare type TransactionReceiptStatus = null | string | 0 | 1;
386export interface TransactionReceipt {
387 blockHash: string;
388 blockNumber: number;
389 transactionHash: string;
390 transactionIndex: number;
391 from: string;
392 to: string;
393 status: TransactionReceiptStatus;
394 cumulativeGasUsed: number;
395 gasUsed: number;
396 contractAddress: string | null;
397 logs: LogEntry[];
398}
399export declare enum AbiType {
400 Function = "function",
401 Constructor = "constructor",
402 Event = "event",
403 Fallback = "fallback"
404}
405export declare type ContractEventArg = any;
406export interface DecodedLogArgs {
407 [argName: string]: ContractEventArg;
408}
409export interface LogWithDecodedArgs<ArgsType extends DecodedLogArgs> extends DecodedLogEntry<ArgsType> {
410}
411export declare type RawLog = LogEntry;
412export declare enum BlockParamLiteral {
413 Earliest = "earliest",
414 Latest = "latest",
415 Pending = "pending"
416}
417export declare type BlockParam = BlockParamLiteral | number;
418export interface RawLogEntry {
419 logIndex: string | null;
420 transactionIndex: string | null;
421 transactionHash: string;
422 blockHash: string | null;
423 blockNumber: string | null;
424 address: string;
425 data: string;
426 topics: string[];
427}
428export declare enum SolidityTypes {
429 Address = "address",
430 Bool = "bool",
431 Bytes = "bytes",
432 Int = "int",
433 String = "string",
434 Tuple = "tuple",
435 Uint256 = "uint256",
436 Uint8 = "uint8",
437 Uint = "uint"
438}
439/**
440 * Contains the logs returned by a TransactionReceipt. We attempt to decode the
441 * logs using AbiDecoder. If we have the logs corresponding ABI, we decode it,
442 * otherwise we don't.
443 */
444export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt {
445 logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>;
446}
447export interface TraceParams {
448 disableMemory?: boolean;
449 disableStack?: boolean;
450 disableStorage?: boolean;
451 tracer?: string;
452 timeout?: string;
453}
454export declare type OutputField = '*' | 'ast' | 'legacyAST' | 'abi' | 'devdoc' | 'userdoc' | 'metadata' | 'ir' | 'evm.assembly' | 'evm.legacyAssembly' | 'evm.bytecode.object' | 'evm.bytecode.opcodes' | 'evm.bytecode.sourceMap' | 'evm.bytecode.linkReferences' | 'evm.deployedBytecode.object' | 'evm.deployedBytecode.opcodes' | 'evm.deployedBytecode.sourceMap' | 'evm.deployedBytecode.linkReferences' | 'evm.methodIdentifiers' | 'evm.gasEstimates' | 'ewasm.wast' | 'ewasm.wasm';
455export interface ContractChains {
456 [chainId: number]: ContractChainData;
457}
458export interface ContractChainData {
459 address: string;
460 links: {
461 [linkName: string]: string;
462 };
463 constructorArgs: string;
464}
465export declare type ParamDescription = string;
466export interface StandardContractOutput {
467 abi: ContractAbi;
468 evm: EvmOutput;
469 devdoc?: DevdocOutput;
470}
471export interface StandardOutput {
472 errors: SolcError[];
473 sources: {
474 [fileName: string]: {
475 id: number;
476 ast?: object;
477 legacyAST?: object;
478 };
479 };
480 contracts: {
481 [fileName: string]: {
482 [contractName: string]: StandardContractOutput;
483 };
484 };
485}
486export declare type ErrorType = 'JSONError' | 'IOError' | 'ParserError' | 'DocstringParsingError' | 'SyntaxError' | 'DeclarationError' | 'TypeError' | 'UnimplementedFeatureError' | 'InternalCompilerError' | 'Exception' | 'CompilerError' | 'FatalError' | 'Warning';
487export declare type ErrorSeverity = 'error' | 'warning';
488export interface SolcError {
489 sourceLocation?: SourceLocation;
490 type: ErrorType;
491 component: 'general' | 'ewasm';
492 severity: ErrorSeverity;
493 message: string;
494 formattedMessage?: string;
495}
496export interface SourceLocation {
497 file: string;
498 start: number;
499 end: number;
500}
501export interface EvmOutput {
502 bytecode: EvmBytecodeOutput;
503 deployedBytecode: EvmBytecodeOutput;
504}
505export interface EvmBytecodeOutput {
506 linkReferences?: EvmBytecodeOutputLinkReferences;
507 object: string;
508 sourceMap: string;
509}
510export interface EvmBytecodeOutputLinkReferences {
511 [sourceFile: string]: {
512 [libraryName: string]: Array<{
513 start: number;
514 length: number;
515 }>;
516 };
517}
518export interface DevdocOutput {
519 title?: string;
520 author?: string;
521 methods: {
522 [signature: string]: {
523 details?: string;
524 params?: {
525 [name: string]: ParamDescription;
526 };
527 return?: string;
528 };
529 };
530}
531export interface ContractVersionData {
532 compiler: CompilerOpts;
533 sources: {
534 [sourceName: string]: {
535 id: number;
536 };
537 };
538 sourceCodes: {
539 [sourceName: string]: string;
540 };
541 sourceTreeHashHex: string;
542 compilerOutput: StandardContractOutput;
543}
544export interface CompilerOpts {
545 name: 'solc';
546 version: string;
547 settings: CompilerSettings;
548}
549/**
550 * This type defines the schema of the artifact.json file generated by Sol-compiler
551 * schemaVersion: The version of the artifact schema
552 * contractName: The contract name it represents
553 * chains: Chain specific information by chain (address, id, constructor args, etc...)
554 * compilerOutput: The Solidity compiler output generated from the specified compiler input
555 * description (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description)
556 * compiler: The compiler settings used
557 * sourceCodes: The source code of the contract and all it's dependencies
558 * sources: A mapping from source filePath to sourceMap id
559 * sourceTreeHashHex: A unique hash generated from the contract source and that of it's dependencies.
560 * If any of the sources change, the hash would change notifying us that a re-compilation is necessary
561 */
562export interface ContractArtifact extends ContractVersionData {
563 schemaVersion: string;
564 contractName: string;
565 chains: ContractChains;
566}
567export interface GeneratedCompilerOptions {
568 name: 'solc';
569 version: string;
570 settings: CompilerSettings;
571}
572export interface CompilerSettings {
573 remappings?: string[];
574 optimizer?: OptimizerSettings;
575 evmVersion?: 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople';
576 metadata?: CompilerSettingsMetadata;
577 libraries?: {
578 [fileName: string]: {
579 [libName: string]: string;
580 };
581 };
582 outputSelection: {
583 [fileName: string]: {
584 [contractName: string]: OutputField[];
585 };
586 };
587}
588export interface CompilerSettingsMetadata {
589 useLiteralContent: true;
590}
591export interface OptimizerSettings {
592 enabled: boolean;
593 runs?: number;
594}
595export interface Source {
596 id: number;
597}
598/**
599 * Options you can specify (as flags or in a compiler.json file) when invoking sol-compiler
600 * contractsDir: Directory containing your project's Solidity contracts. Can contain nested directories.
601 * artifactsDir: Directory where you want the generated artifacts.json written to
602 * compilerSettings: Desired settings to pass to the Solidity compiler during compilation.
603 * (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description)
604 * contracts: List of contract names you wish to compile, or alternatively ['*'] to compile all contracts in the
605 * specified directory.
606 * useDockerisedSolc: If set to true - sol-compiler will try calling a dockerized installations of solc to achieve faster compilation times. Otherwise and by default - solcjs will be used. Defaults to false.
607 * isOfflineMode: If set to true - sol-compiler will not fetch the list of solc releases from github. It will use the hardcoded list. Defaults to false.
608 * solcVersion: If you don't want to compile each contract with the Solidity version specified in-file, you can force all
609 * contracts to compile with the the version specified here.
610 * shouldSaveStandardInput: Write the standard JSON input in ${contractsDir}/${contractName}.input.json
611 */
612export interface CompilerOptions {
613 contractsDir?: string;
614 artifactsDir?: string;
615 compilerSettings?: CompilerSettings;
616 contracts?: string[] | '*';
617 useDockerisedSolc?: boolean;
618 isOfflineMode?: boolean;
619 solcVersion?: string;
620 shouldSaveStandardInput?: boolean;
621 shouldCompileIndependently?: boolean;
622}
623export interface BlockRange {
624 fromBlock: BlockParam;
625 toBlock: BlockParam;
626}
627//# sourceMappingURL=index.d.ts.map
\No newline at end of file