Skip to content

Commit

Permalink
Merge branch 'feature/fallback-emoji'
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovNikita committed Aug 2, 2024
2 parents fb6e630 + c44b328 commit f253c3a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions packages/core/src/entries/account.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line max-classes-per-file
import { AuthKeychain, AuthPassword, AuthSigner, AuthSignerDeepLink } from './password';
import { KeystonePathInfo } from '../service/keystone/types';
import { AuthKeychain, AuthPassword, AuthSigner, AuthSignerDeepLink } from './password';
import { DerivationItem, TonWalletStandard, WalletId } from './wallet';

/**
Expand Down Expand Up @@ -29,15 +29,24 @@ export interface IAccount {
setActiveTonWallet(walletId: WalletId): void;
}

export class Clonable {
export abstract class Clonable {
clone() {
const cloned = structuredClone(this);
Object.setPrototypeOf(cloned, Object.getPrototypeOf(this));
return cloned as this;
}
}

export class AccountTonMnemonic extends Clonable implements IAccount {
export abstract class FallbackEmoji extends Clonable {
constructor(public emoji: string) {
super();
if (!this.emoji) {
this.emoji = '😀';
}
}
}

export class AccountTonMnemonic extends FallbackEmoji implements IAccount {
public readonly type = 'mnemonic';

get allTonWallets() {
Expand All @@ -63,7 +72,7 @@ export class AccountTonMnemonic extends Clonable implements IAccount {
public activeTonWalletId: WalletId,
public tonWallets: TonWalletStandard[]
) {
super();
super(emoji);
}

getTonWallet(id: WalletId) {
Expand Down Expand Up @@ -106,7 +115,7 @@ export class AccountTonMnemonic extends Clonable implements IAccount {
}
}

export class AccountLedger extends Clonable implements IAccount {
export class AccountLedger extends FallbackEmoji implements IAccount {
public readonly type = 'ledger';

get allTonWallets() {
Expand Down Expand Up @@ -145,7 +154,7 @@ export class AccountLedger extends Clonable implements IAccount {
public addedDerivationsIndexes: number[],
public readonly allAvailableDerivations: DerivationItem[]
) {
super();
super(emoji);

if (
addedDerivationsIndexes.some(index =>
Expand Down Expand Up @@ -239,7 +248,7 @@ export class AccountLedger extends Clonable implements IAccount {
}
}

export class AccountKeystone extends Clonable implements IAccount {
export class AccountKeystone extends FallbackEmoji implements IAccount {
public readonly type = 'keystone';

get allTonWallets() {
Expand All @@ -264,7 +273,7 @@ export class AccountKeystone extends Clonable implements IAccount {
public readonly pathInfo: KeystonePathInfo | undefined,
public tonWallet: TonWalletStandard
) {
super();
super(emoji);
}

getTonWallet(id: WalletId) {
Expand All @@ -290,7 +299,7 @@ export class AccountKeystone extends Clonable implements IAccount {
}
}

export class AccountTonOnly extends Clonable implements IAccount {
export class AccountTonOnly extends FallbackEmoji implements IAccount {
public readonly type = 'ton-only';

get allTonWallets() {
Expand All @@ -316,7 +325,7 @@ export class AccountTonOnly extends Clonable implements IAccount {
public activeTonWalletId: WalletId,
public tonWallets: TonWalletStandard[]
) {
super();
super(emoji);
}

getTonWallet(id: WalletId) {
Expand Down

0 comments on commit f253c3a

Please sign in to comment.