Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
feat: implement `WalletData#isDelegate/isKnown/isMultiSignature/isSec…
Browse files Browse the repository at this point in the history
…ondSignature` (#477)
  • Loading branch information
faustbrian committed Jun 23, 2020
1 parent 9788bc7 commit 4dcd4aa
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 10 deletions.
16 changes: 16 additions & 0 deletions packages/platform-sdk-ark/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
return BigNumber.make(this.data.votes);
}

public isDelegate(): boolean {
return !!this.data.username;
}

public isKnown(): boolean {
return false;
}

public isMultiSignature(): boolean {
return !!this.data.multiSignature;
}

public isSecondSignature(): boolean {
return !!this.data.secondPublicKey;
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-atom/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-btc/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-eos/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-eth/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-lsk/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
return BigNumber.make(this.data.votes);
}

public isDelegate(): boolean {
return !!this.data.delegate;
}

public isKnown(): boolean {
return false;
}

public isMultiSignature(): boolean {
return false;
}

public isSecondSignature(): boolean {
return !!this.data.secondPublicKey;
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-neo/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 6 additions & 10 deletions packages/platform-sdk-profiles/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,28 +174,24 @@ export class Wallet {
*/

public isDelegate(): boolean {
// TODO: automatically determine this
return this.data().has(WalletFlag.SecondSig);
return this.#wallet.isDelegate();
}

public isKnown(): boolean {
// TODO: automatically determine this
return this.data().has(WalletFlag.Known);
return this.#wallet.isKnown();
}

public isLedger(): boolean {
// TODO: automatically determine this
return this.data().has(WalletFlag.Ledger);
}

public isMultiSig(): boolean {
// TODO: automatically determine this
return this.data().has(WalletFlag.MultiSig);
public isMultiSignature(): boolean {
return this.#wallet.isMultiSignature();
}

public isSecondSig(): boolean {
// TODO: automatically determine this
return this.data().has(WalletFlag.SecondSig);
public isSecondSignature(): boolean {
return this.#wallet.isSecondSignature();
}

public isStarred(): boolean {
Expand Down
16 changes: 16 additions & 0 deletions packages/platform-sdk-trx/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-xlm/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-xmr/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
16 changes: 16 additions & 0 deletions packages/platform-sdk-xrp/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export class WalletData extends DTO.AbstractWalletData implements Contracts.Wall
public votes(): BigNumber | undefined {
throw new Exceptions.NotImplemented(this.constructor.name, "votes");
}

public isDelegate(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isDelegate");
}

public isKnown(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isKnown");
}

public isMultiSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isMultiSignature");
}

public isSecondSignature(): boolean {
throw new Exceptions.NotImplemented(this.constructor.name, "isSecondSignature");
}
}
9 changes: 9 additions & 0 deletions packages/platform-sdk/src/contracts/coins/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export interface WalletData {

votes(): BigNumber | undefined;

// Flags
isDelegate(): boolean;

isKnown(): boolean;

isMultiSignature(): boolean;

isSecondSignature(): boolean;

toObject(): KeyValuePair;
}

Expand Down
9 changes: 9 additions & 0 deletions packages/platform-sdk/src/dto/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export abstract class AbstractWalletData {

abstract votes(): BigNumber | undefined;

// Flags
abstract isDelegate(): boolean;

abstract isKnown(): boolean;

abstract isMultiSignature(): boolean;

abstract isSecondSignature(): boolean;

public toObject(): KeyValuePair {
return {
address: this.address(),
Expand Down

0 comments on commit 4dcd4aa

Please sign in to comment.