Add metacoin example project

This commit is contained in:
Leonid Logvinov
2018-03-28 11:05:36 +02:00
parent bc49dde4d5
commit 4d9029bb0e
82 changed files with 1209 additions and 732 deletions

View File

@@ -0,0 +1,57 @@
declare module 'bn.js' {
import { Buffer } from 'buffer';
type Endianness = 'le' | 'be';
class BN {
constructor(num: number | string | number[] | Buffer, base?: number, endian?: Endianness);
public clone(): BN;
public toString(base?: number, length?: number): string;
public toNumber(): number;
public toJSON(): string;
public toArray(endian?: Endianness, length?: number): number[];
public toBuffer(endian?: Endianness, length?: number): Buffer;
public bitLength(): number;
public zeroBits(): number;
public byteLength(): number;
public isNeg(): boolean;
public isEven(): boolean;
public isOdd(): boolean;
public isZero(): boolean;
public cmp(b: any): number;
public lt(b: any): boolean;
public lte(b: any): boolean;
public gt(b: any): boolean;
public gte(b: any): boolean;
public eq(b: any): boolean;
public isBN(b: any): boolean;
public neg(): BN;
public abs(): BN;
public add(b: BN): BN;
public sub(b: BN): BN;
public mul(b: BN): BN;
public sqr(): BN;
public pow(b: BN): BN;
public div(b: BN): BN;
public mod(b: BN): BN;
public divRound(b: BN): BN;
public or(b: BN): BN;
public and(b: BN): BN;
public xor(b: BN): BN;
public setn(b: number): BN;
public shln(b: number): BN;
public shrn(b: number): BN;
public testn(b: number): boolean;
public maskn(b: number): BN;
public bincn(b: number): BN;
public notn(w: number): BN;
public gcd(b: BN): BN;
public egcd(b: BN): { a: BN; b: BN; gcd: BN };
public invm(b: BN): BN;
}
export = BN;
}

View File

@@ -0,0 +1 @@
declare module 'chai-bignumber';

View File

@@ -114,6 +114,9 @@ declare namespace Chai {
extensible: Assertion;
sealed: Assertion;
frozen: Assertion;
bignumber: Assertion;
// HACK: In order to comply with chai-as-promised we make eventually a `PromisedAssertion` not an `Assertion`
eventually: PromisedAssertion;
oneOf(list: any[], message?: string): Assertion;
}
@@ -148,7 +151,7 @@ declare namespace Chai {
}
interface NumberComparer {
(value: number, message?: string): Assertion;
(value: number | object, message?: string): Assertion;
}
interface TypeComparison {

View File

@@ -0,0 +1 @@
declare module 'dirty-chai';

View File

@@ -0,0 +1,5 @@
declare module 'ethereumjs-abi' {
const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
const soliditySHA256: (argTypes: string[], args: any[]) => Buffer;
const methodID: (name: string, types: string[]) => Buffer;
}

View File

@@ -0,0 +1,14 @@
declare module 'ethereumjs-tx' {
class EthereumTx {
public raw: Buffer[];
public r: Buffer;
public s: Buffer;
public v: Buffer;
public nonce: Buffer;
public serialize(): Buffer;
public sign(buffer: Buffer): void;
public getSenderAddress(): Buffer;
constructor(txParams: any);
}
export = EthereumTx;
}

View File

@@ -0,0 +1,101 @@
declare module 'ethereumjs-util' {
import { Buffer } from 'buffer';
import BN = require('bn.js');
interface Signature {
v: number;
r: Buffer;
s: Buffer;
}
export const MAX_INTEGER: BN;
export const TWO_POW256: BN;
export const SHA3_NULL_S: string;
export const SHA3_NULL: Buffer;
export const SHA3_RLP_ARRAY_S: string;
export const SHA3_RLP_ARRAY: Buffer;
export const SHA3_RLP_S: string;
export const SHA3_RLP: Buffer;
export function zeros(bytes: number): Buffer;
export function setLength(msg: Buffer, length: number, right: boolean): Buffer;
export function setLength(msg: number[], length: number, right: boolean): number[];
export function setLengthLeft(msg: Buffer, length: number, right?: boolean): Buffer;
export function setLengthLeft(msg: number[], length: number, right?: boolean): number[];
export function setLengthRight(msg: Buffer, length: number): Buffer;
export function setLengthRight(msg: number[], length: number): number[];
export function unpad(a: Buffer): Buffer;
export function unpad(a: number[]): number[];
export function unpad(a: string): string;
export function toBuffer(v: any): Buffer;
export function bufferToInt(buf: Buffer): number;
export function bufferToHex(buf: Buffer): string;
export function fromSigned(num: Buffer): BN;
export function toUnsigned(num: BN): Buffer;
export function sha3(a: Buffer | string | number | number[], bits?: number): Buffer;
export function sha256(a: Buffer | string | number | number[]): Buffer;
export function ripemd160(a: Buffer | string | number | number[], padded?: boolean): Buffer;
export function rlphash(a: Buffer | string | number | number[]): Buffer;
export function isValidPrivate(privateKey: Buffer): boolean;
export function isValidPublic(publicKey: Buffer, sanitize?: boolean): boolean;
export function pubToAddress(publicKey: Buffer, sanitize?: boolean): Buffer;
export function publicToAddress(publicKey: Buffer, sanitize?: boolean): Buffer;
export function privateToPublic(privateKey: Buffer): Buffer;
export function importPublic(publicKey: Buffer): Buffer;
export function ecsign(message: Buffer, privateKey: Buffer): Signature;
export function hashPersonalMessage(message: Buffer | string): Buffer;
export function ecrecover(msgHash: Buffer, v: number, r: Buffer, s: Buffer): Buffer;
export function toRpcSig(v: number, r: Buffer, s: Buffer): string;
export function fromRpcSig(sig: string): Signature;
export function privateToAddress(privateKey: Buffer): Buffer;
export function isValidAddress(address: string): boolean;
export function toChecksumAddress(address: string): string;
export function isValidChecksumAddress(address: string): boolean;
export function generateAddress(from: Buffer | string, nonce: number | string | number[] | Buffer): Buffer;
export function isPrecompiled(address: Buffer | string): boolean;
export function addHexPrefix(str: string): string;
export function stripHexPrefix(str: string): string;
export function isValidSignature(v: number, r: Buffer | string, s: Buffer | string, homestead?: boolean): boolean;
export function baToJSON(ba: Buffer): string;
export function baToJSON(ba: any[]): string[];
}

View File

@@ -0,0 +1,38 @@
declare module 'solc' {
export interface ContractCompilationResult {
srcmap: string;
srcmapRuntime: string;
bytecode: string;
runtimeBytecode: string;
interface: string;
}
export interface CompilationResult {
errors: string[];
contracts: {
[contractIdentifier: string]: ContractCompilationResult;
};
sources: {
[sourceName: string]: {
AST: any;
};
};
sourceList: string[];
}
export interface ImportContents {
contents: string;
}
export interface InputSources {
sources: {
[fileName: string]: string;
};
}
export interface SolcInstance {
compile(
sources: InputSources,
optimizerEnabled: number,
findImports: (importPath: string) => ImportContents,
): CompilationResult;
}
export function loadRemoteVersion(versionName: string, cb: (err: Error | null, res?: SolcInstance) => void): void;
export function setupMethods(solcBin: any): SolcInstance;
}

View File

@@ -0,0 +1,12 @@
declare module 'truffle-hdwallet-provider' {
import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types';
import * as Web3 from 'web3';
class HDWalletProvider implements Web3.Provider {
constructor(mnemonic: string, rpcUrl: string);
public sendAsync(
payload: JSONRPCRequestPayload,
callback: (err: Error, result: JSONRPCResponsePayload) => void,
): void;
}
export = HDWalletProvider;
}

View File

@@ -0,0 +1,3 @@
declare module 'web3-eth-abi' {
export function encodeParameters(typesArray: string[], parameters: any[]): string;
}

View File

@@ -0,0 +1,11 @@
declare module 'web3-provider-engine' {
class Web3ProviderEngine {
public on(event: string, handler: () => void): void;
public send(payload: any): void;
public sendAsync(payload: any, callback: (error: any, response: any) => void): void;
public addProvider(provider: any): void;
public start(): void;
public stop(): void;
}
export = Web3ProviderEngine;
}