Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
100 changes: 58 additions & 42 deletions src/app/pages/add/create-wallet/create-wallet.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,48 +164,64 @@
</mat-form-field>

<ion-item class="option-container" [ngClass]="{'set-padding-top': !isEnvDev}"
*ngIf="!isShared && (this.coin === 'xpi' || this.coin === 'xec')">
<div class="option-line">
<ion-label translate>
eToken Path
</ion-label>
<ion-toggle [checked]="isSlpToken" (ionChange)="changeSlpPath($event)"></ion-toggle>
</div>
<div class="option-line-info" *ngIf="isSlpToken">
<span translate>Only select path m'/44'/1899'/0 for #Saving4Lotus or #Hold2Earn programs</span>
</div>
</ion-item>

<!-- TODO: Hide support path 145 -->
<!-- <ion-item class="option-container" [ngClass]="{'set-padding-top': !isEnvDev}"
*ngIf="!isShared && (this.coin === 'xpi' || this.coin === 'xec')">
<div class="option-line">
<ion-label translate>
Wallet Path 145
</ion-label>
<ion-toggle [checked]="isFromRaipay" (ionChange)="changeRaipayPath($event)"></ion-toggle>
</div>
<div class="option-line-info" *ngIf="isFromRaipay">
<span translate>
Only select path m'/44'/145'/0 to import seed of wallet supports path 145
</span>
</div>
</ion-item> -->

<ion-item lines="none" class="option-container" *ngIf="!isSingleAddress()"
[ngClass]="{'with-label': createForm.value.singleAddress}">
<div class="option-line">
<p>{{ 'Single Address' | translate }}</p>
<ion-toggle [checked]="isSlpToken || isFromRaipay"
formControlName="singleAddress"></ion-toggle>
</div>
<div class="option-line-info" *ngIf="createForm.value.singleAddress">
<span translate>The single address feature will force the account to only use one address rather than
generating new addresses.</span>
<br>
<a class="label-tip-link" (click)="openSupportSingleAddress()" translate>Learn More</a>
</div>
</ion-item>
*ngIf="!isShared && (this.coin === 'xpi' || this.coin === 'xec')">
<div class="option-line">
<ion-label translate>
eToken Account
</ion-label>
<ion-toggle [checked]="isSlpToken" (ionChange)="changeSlpPath($event)"></ion-toggle>
</div>
</ion-item>

<ion-item *ngIf="isSlpToken && coin === 'xec'" class="choose-path-section">
<ion-list lines="none" class="bp-list choose-path-list" *ngIf="coin == 'xec'">
<ion-radio-group [value]="eTokenPathOpts[0].id">
<ion-item *ngFor="let opt of eTokenPathOpts">
<ion-label translate>
{{ opt.label }}
</ion-label>
<ion-radio slot="start"
(click)="eTokenPathOptionsChange(opt.id)"
[value]="opt.id"
></ion-radio>
</ion-item>
</ion-radio-group>
<!-- <div class="option-line-info" *ngIf="isSlpToken">
<span translate>Only select path m'/44'/1899' for #Saving4Lotus or #Hold2Earn programs</span>
</div> -->
</ion-list>
</ion-item>

<!-- TODO: Hide support path 145 -->
<!-- <ion-item class="option-container" [ngClass]="{'set-padding-top': !isEnvDev}"
*ngIf="!isShared && (this.coin === 'xpi' || this.coin === 'xec')">
<div class="option-line">
<ion-label translate>
Wallet Path 145
</ion-label>
<ion-toggle [checked]="isFromRaipay" (ionChange)="changeRaipayPath($event)"></ion-toggle>
</div>
<div class="option-line-info" *ngIf="isFromRaipay">
<span translate>
Only select path m'/44'/145'/0 to import seed of wallet supports path 145
</span>
</div>
</ion-item> -->

<ion-item lines="none" class="option-container" *ngIf="!isSingleAddress()"
[ngClass]="{'with-label': createForm.value.singleAddress}">
<div class="option-line">
<p>{{ 'Single Address' | translate }}</p>
<ion-toggle [checked]="isSlpToken || isFromRaipay"
formControlName="singleAddress"></ion-toggle>
</div>
<div class="option-line-info" *ngIf="createForm.value.singleAddress">
<span translate>The single address feature will force the account to only use one address rather than
generating new addresses.</span>
<br>
<a class="label-tip-link" (click)="openSupportSingleAddress()" translate>Learn More</a>
</div>
</ion-item>
</div>
</form>
</ion-content>
Expand Down
32 changes: 32 additions & 0 deletions src/app/pages/add/create-wallet/create-wallet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,36 @@ page-create-wallet {
.wide-header__title {
--min-height: 72px;
}

.choose-path-section {
--inner-padding-end: 0;
--inner-padding-bottom: 0 !important;
.choose-path-list {
width: 100%;
background: transparent;
ion-radio-group {
ion-item {
margin: 0 1rem !important;
box-shadow: none !important;
ion-label {
font-size: 14px !important;
}
&:last-child {
--inner-border-width: 0 !important;
}
}
}
.option-line-info {
padding: 0 0 1rem 1rem;
font-size: 13px;
font-weight: 400;
color: rgba(0, 30, 46, 0.6);
a {
padding-top: 13px;
font-size: 14px;
color: #00658d;
}
}
}
}
}
35 changes: 28 additions & 7 deletions src/app/pages/add/create-wallet/create-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ export class CreateWalletPage implements OnInit {
public cancelText: string;
public createForm: FormGroup;
public currentTheme: string;
public eTokenPathOpts = [
{
id: '1899',
label: this.translate.instant(`m'/44'/1899'`),
},
{
id: '899',
label: this.translate.instant(`m'/44'/899'`),
}
];

public multisigAddresses: string[];
public invalidAddress: boolean;
Expand Down Expand Up @@ -146,11 +156,12 @@ export class CreateWalletPage implements OnInit {
derivationPath: [this.derivationPathByDefault],
testnetEnabled: [false],
useNativeSegwit: [false],
singleAddress: [false],
singleAddress: [this.coin === 'xec' ? true : false],
eTokenPath: [this.coin === 'xec' ? this.eTokenPathOpts[0].id : null],
coin: [null, Validators.required]
});
this.createForm.controls['coin'].setValue(this.coin);

this.isSlpToken = true ? this.coin === 'xec' : false;
if (this.coin === 'btc' || this.coin === 'ltc')
this.createForm.controls['useNativeSegwit'].setValue(true);

Expand Down Expand Up @@ -231,6 +242,11 @@ export class CreateWalletPage implements OnInit {
this.createForm.controls['recoveryPhrase'].setValue(null);
}

public eTokenPathOptionsChange(eTokenId): void {
this.createForm.controls['eTokenPath'].setValue(eTokenId);
this.changeSlpPath(null, true);
}

public setDerivationPath(): void {
const path: string = this.createForm.value.testnet
? this.derivationPathForTestnet
Expand Down Expand Up @@ -258,7 +274,10 @@ export class CreateWalletPage implements OnInit {
: this.createForm.value.singleAddress,
coin: this.createForm.value.coin
};


// Support eToken for path 899
const isPath899 = this.createForm.value.eTokenPath === '899';
if (isPath899 && this.isSlpToken) opts['isPath899'] = isPath899;
const setSeed = this.createForm.value.selectedSeed == 'set';
opts['setSeed'] = setSeed;
if (setSeed) {
Expand Down Expand Up @@ -561,11 +580,13 @@ export class CreateWalletPage implements OnInit {
}
}

changeSlpPath(event) {
this.isSlpToken = event.detail.checked;
if (event.detail.checked) {
changeSlpPath(event, isChange?: boolean) {
const isPath899 = this.createForm.controls['eTokenPath'].value === '899';
this.isSlpToken = event?.detail?.checked || isChange;
if (event?.detail?.checked || isChange) {
this.createForm.controls['walletName'].setValue(this.createForm.controls['walletName'].value.replace(" - 145", ""));
this.createForm.controls['walletName'].setValue(this.createForm.controls['walletName'].value + " - 1899");
this.createForm.controls['walletName'].setValue(this.createForm.controls['walletName'].value.replace(" - 1899", ""));
if (!isPath899 || this.coin === 'xpi') this.createForm.controls['walletName'].setValue(this.createForm.controls['walletName'].value + " - 1899");
this.createForm.controls['singleAddress'].setValue(true);
this.isFromRaipay = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/add/import-wallet/import-wallet.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</ion-item>
<ion-item class="token-path-item" *ngIf="isShoweTokenPath">
<ion-label translate>
eToken Path
eToken Account
</ion-label>
<ion-toggle (ionChange)="setDerivationPathForXpiSlpToken($event)"></ion-toggle>
</ion-item>
Expand Down
4 changes: 4 additions & 0 deletions src/app/pages/settings/wallet-settings/wallet-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<ion-label>{{'Hide Account' | translate }}</ion-label>
<ion-toggle checked="{{wallet?.hidden}}" (ionChange)="hiddenWalletChange(wallet.id)"></ion-toggle>
</ion-item>
<ion-item *ngIf="wallet?.credentials?.isSlpToken && wallet.coin === 'xec'" class="item-end" detail="false">
<ion-label>{{'Hide eToken Account' | translate }}</ion-label>
<ion-toggle checked="{{!wallet?.isSlpToken}}" (ionChange)="hiddenETokenWalletChange(wallet.id)"></ion-toggle>
</ion-item>
<label-tip class="info" type="info" header="no-header">
<div label-tip-body translate>
The account won't be removed from this device. You can hide it whenever you need it.
Expand Down
6 changes: 6 additions & 0 deletions src/app/pages/settings/wallet-settings/wallet-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ export class WalletSettingsPage {
this.events.publish('Local/GetData', true);
}

public hiddenETokenWalletChange(walletId: string): void {
if (!walletId) return;
this.profileProvider.toggleHideETokenWalletFlag(walletId);
this.events.publish('Local/GetData', true);
}

public openWalletGroupDelete(): void {
this.router.navigate(['/wallet-delete'], {
state: {
Expand Down
9 changes: 9 additions & 0 deletions src/app/providers/persistence/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const Keys = {
HIDE_BALANCE: walletId => 'hideBalance-' + walletId,
TOTAL_BALANCE: 'totalBalance',
HIDE_WALLET: walletId => 'hideWallet-' + walletId,
HIDE_ETOKEN_WALLET: walletId => 'hideETokenWallet-' + walletId,
KEY_ONBOARDING: 'keyOnboarding',
KEYS: 'keys',
LAST_ADDRESS: walletId => 'lastAddress-' + walletId,
Expand Down Expand Up @@ -353,10 +354,18 @@ export class PersistenceProvider {
return this.storage.set(Keys.HIDE_WALLET(walletId), val);
}

setHideETokenWalletFlag(walletId: string, val) {
return this.storage.set(Keys.HIDE_ETOKEN_WALLET(walletId), val);
}

getHideWalletFlag(walletId: string) {
return this.storage.get(Keys.HIDE_WALLET(walletId));
}

getHideETokenWalletFlag(walletId: string) {
return this.storage.get(Keys.HIDE_ETOKEN_WALLET(walletId));
}

setDisclaimerAccepted() {
return this.storage.set(Keys.AGREE_DISCLAIMER, true);
}
Expand Down
Loading