Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Accounts typings #2417

Merged
merged 4 commits into from
Feb 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions packages/web3-eth-accounts/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import {AbstractWeb3Module, Transaction, Web3ModuleOptions} from 'web3-core';
import {provider} from 'web3-providers';

export class Accounts extends AbstractWeb3Module {
constructor(
provider: provider,
options?: Web3ModuleOptions
);
constructor(provider: provider, options?: Web3ModuleOptions);

create(entropy?: string): Account;

Expand All @@ -36,7 +33,7 @@ export class Accounts extends AbstractWeb3Module {

hashMessage(message: string): string;

sign(data: string, privateKey: string): string | Sign;
sign(data: string, privateKey: string): Sign;

recover(message: SignedTransaction): string;
recover(message: string | SignedTransaction, signature: string, preFixed?: boolean): string;
Expand All @@ -54,7 +51,7 @@ export class Wallet {

create(numberOfAccounts: number, entropy?: string): Wallet;

add(account: string | Account): AddedAccount;
add(account: string | AddAccount): AddedAccount;

remove(account: string | number): boolean;

Expand All @@ -69,12 +66,20 @@ export class Wallet {
load(password: string, keyName?: string): Wallet;
}

export interface AddAccount {
address: string;
privateKey: string;
}

export interface Account {
address: string;
privateKey: string;
signTransaction?: (tx: Transaction) => {};
sign?: (data: string) => {};
encrypt?: (password: string) => {};
signTransaction: (
tx: Transaction,
callback?: (signTransaction: SignedTransaction) => void
) => Promise<SignedTransaction>;
sign: (data: string) => Sign;
encrypt: (password: string) => EncryptedKeystoreV3Json;
}

export interface AddedAccount extends Account {
Expand All @@ -83,22 +88,22 @@ export interface AddedAccount extends Account {

export interface EncryptedKeystoreV3Json {
version: number;
id: string,
address: string,
id: string;
address: string;
crypto: {
ciphertext: string,
cipherparams: {iv: string},
cipher: string,
kdf: string,
ciphertext: string;
cipherparams: {iv: string};
cipher: string;
kdf: string;
kdfparams: {
dklen: number,
salt: string,
n: number,
r: number,
p: number
},
dklen: number;
salt: string;
n: number;
r: number;
p: number;
};
mac: string;
}
};
}

export interface SignedTransaction {
Expand Down