Skip to content

Commit

Permalink
Use better Description typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jan 8, 2020
1 parent 13f50ab commit 2d5492c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/abstract-provider/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export interface FilterByBlockHash extends EventFilter {
export abstract class ForkEvent extends Description {
readonly expiry: number;

readonly _isForkEvent: boolean;
readonly _isForkEvent?: boolean;

static isForkEvent(value: any): value is ForkEvent {
return !!(value && value._isForkEvent);
Expand All @@ -142,6 +142,8 @@ export abstract class ForkEvent extends Description {
export class BlockForkEvent extends ForkEvent {
readonly blockhash: string;

readonly _isBlockForkEvent?: boolean;

constructor(blockhash: string, expiry?: number) {
if (!isHexString(blockhash, 32)) {
logger.throwArgumentError("invalid blockhash", "blockhash", blockhash);
Expand All @@ -159,6 +161,8 @@ export class BlockForkEvent extends ForkEvent {
export class TransactionForkEvent extends ForkEvent {
readonly hash: string;

readonly _isTransactionOrderForkEvent?: boolean;

constructor(hash: string, expiry?: number) {
if (!isHexString(hash, 32)) {
logger.throwArgumentError("invalid transaction hash", "hash", hash);
Expand Down
9 changes: 8 additions & 1 deletion packages/json-wallets/src.ts/crowdsale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ const logger = new Logger(version);

import { getPassword, looseArrayify, searchPath } from "./utils";

export class CrowdsaleAccount extends Description implements ExternallyOwnedAccount {
interface _CrowdsaleAccount {
address: string;
privateKey: string;

_isCrowdsaleAccount: boolean;
}

export class CrowdsaleAccount extends Description<_CrowdsaleAccount> implements ExternallyOwnedAccount {
readonly address: string;
readonly privateKey: string;
readonly mnemonic?: string;
Expand Down
13 changes: 11 additions & 2 deletions packages/json-wallets/src.ts/keystore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ import { getPassword, looseArrayify, searchPath, zpad } from "./utils";

// Exported Types

export class KeystoreAccount extends Description implements ExternallyOwnedAccount {
interface _KeystoreAccount {
address: string;
privateKey: string;
mnemonic?: string;
path?: string;

_isKeystoreAccount: boolean;
}

export class KeystoreAccount extends Description<_KeystoreAccount> implements ExternallyOwnedAccount {
readonly address: string;
readonly privateKey: string;
readonly mnemonic?: string;
Expand Down Expand Up @@ -94,7 +103,7 @@ export async function decrypt(json: string, password: Bytes | string, progressCa
}
}

const account: any = {
const account: _KeystoreAccount = {
_isKeystoreAccount: true,
address: address,
privateKey: hexlify(privateKey)
Expand Down

0 comments on commit 2d5492c

Please sign in to comment.