Add several declaration files, change a few typings.

This commit is contained in:
aitrean 2018-02-12 21:35:39 -05:00
parent a371d6449a
commit e5e9008ed2
7 changed files with 94 additions and 5 deletions

View File

@ -14,7 +14,7 @@ export interface Token {
error?: string | null;
}
export interface Tokens {
[key: string]: Token;
[key: string]: Token[];
}
const TokenTypes: Tokens = {

View File

@ -16,8 +16,6 @@ export class LedgerWallet extends DeterministicWallet implements IFullWallet {
});
}
// modeled after
// https://github.com/kvhnuke/etherwallet/blob/3f7ff809e5d02d7ea47db559adaca1c930025e24/app/scripts/uiFuncs.js#L58
public signRawTransaction(t: EthTx): Promise<Buffer> {
t.v = Buffer.from([t._chainId]);
t.r = toBuffer(0);

10
common/typescript/idna-uts46.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
declare module 'idna-uts46' {
export interface Options {
transitional?: boolean;
useStd3ASCII?: boolean;
verifyDnsLength?: boolean;
}
export function toAscii(domain: string, options: Options): string;
export function toUnicode(domain: string, args: Options): string;
}

37
common/typescript/ledgerco.d.ts vendored Normal file
View File

@ -0,0 +1,37 @@
declare module 'ledgerco' {
export class eth {
constructor(transport: any);
getAddress_async(
path: string,
boolDisplay?: boolean,
boolChaincode?: boolean
): Promise<{
publicKey: string;
address: string;
chainCode?: string;
}>;
signTransaction_async(
path: string,
rawTxHex: string
): Promise<{
s: string;
v: string;
r: string;
}>;
getAppConfiguration_async(): Promise<{
arbitraryDataEnabled: number;
version: string;
}>;
signPersonalMessage_async(
path: string,
messageHex: string
): Promise<{
v: number;
s: string;
r: string;
}>;
}
}

View File

@ -0,0 +1,38 @@
interface PropTypes {
activeStep: number;
steps: any[];
activeColor: string;
completeColor: string;
defaultColor: string;
activeTitleColor: string;
completeTitleColor: string;
defaultTitleColor: string;
circleFontColor: string;
size: number;
circleFontSize: number;
titleFontSize: number;
circleTop: number;
titleTop: number;
defaultOpacity: string;
completeOpacity: string;
activeOpacity: string;
defaultTitleOpacity: string;
completeTitleOpacity: string;
activeTitleOpacity: string;
barStyle: string;
defaultBarColor: string;
completeBarColor: string;
defaultBorderColor: string;
completeBorderColor: string;
activeBorderColor: string;
defaultBorderStyle: string;
completeBorderStyle: string;
activeBorderStyle: string;
}
declare module 'react-stepper-horizontal' {
export class Stepper extends React.Component<PropTypes> {
constructor();
render(): any;
}
}

View File

@ -0,0 +1,6 @@
declare module 'redux-test-utils' {
import { Store } from 'react-redux';
export function createMockStore(testState: any): Store<any>;
export function createMockDispatch(testAction: any): any;
}

View File

@ -1,4 +1,4 @@
import TOKENS from 'config/tokens';
import TOKENS, { Token } from 'config/tokens';
import { isValidETHAddress } from 'libs/validators';
describe('Tokens JSON', () => {
@ -8,7 +8,7 @@ describe('Tokens JSON', () => {
const addressCollisionMap: any = {};
const symbolCollisionMap: any = {};
tokens.forEach(token => {
tokens.forEach((token: Token) => {
if (!isValidETHAddress(token.address)) {
throw Error(`Token ${token.symbol} has invalid contract address '${token.address}'`);
}