From 13b6fe0e4208a91e0b0b095fca75d05de160cf36 Mon Sep 17 00:00:00 2001 From: bl05b3e <naMATy-$pRBE2hbMh{x9'Tx@j?> Date: Wed, 7 Dec 2022 20:48:08 +0100 Subject: [PATCH] [enh] Add official G1 SS58 prefix --- src/app/home/home.page.ts | 2 +- src/app/network/currency.model.ts | 5 +++-- src/app/network/network.service.ts | 20 +++++++++++--------- src/app/register/register.form.html | 2 +- src/app/wallet/account.service.ts | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 9a37e0b..e5ed9c2 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -74,7 +74,7 @@ export class HomePage extends BasePage<Settings> implements OnInit { await this.settings.ready(); await this.networkService.ready(); - this.currency = this.networkService.currency.name; + this.currency = this.networkService.currency.displayName; // Load account await this.accountService.ready(); diff --git a/src/app/network/currency.model.ts b/src/app/network/currency.model.ts index 4f4f1d1..40a888d 100644 --- a/src/app/network/currency.model.ts +++ b/src/app/network/currency.model.ts @@ -1,7 +1,8 @@ export interface Currency { - name: string; + network: string; + displayName: string; symbol: string; - ss58Format: number; + prefix: number; genesys: string; fees: { identity: number; diff --git a/src/app/network/network.service.ts b/src/app/network/network.service.ts index f46bd80..a7a6c41 100644 --- a/src/app/network/network.service.ts +++ b/src/app/network/network.service.ts @@ -9,9 +9,10 @@ import {Currency} from "@app/network/currency.model"; const WELL_KNOWN_CURRENCIES = Object.freeze({ 'Ğdev': <Partial<Currency>>{ - name: 'Ğdev', - symbol: 'ĞD', - ss58Format: 42, + network: "gdev", + displayName: 'Ğdev', + symbol: 'GD', + prefix: 42, genesys: '0x9f956a87b5568f12c757bb3426897bba6123a1ef311fcd0945bd669fd0e612f8', fees: { identity: 300, // = 3 Gdev @@ -20,9 +21,10 @@ const WELL_KNOWN_CURRENCIES = Object.freeze({ decimals: 2 }, 'Ğ1': <Partial<Currency>>{ - name: 'Ğ1', - symbol: 'Ğ1', - ss58Format: 42, + network: "g1", + displayName: 'Ğ1', + symbol: 'G1', + prefix: 4450, genesys: '0x___TODO___', fees: { identity: 300, // = 3G1 - FIXME @@ -36,7 +38,7 @@ const WELL_KNOWN_CURRENCIES = Object.freeze({ export class NetworkService extends StartableService<ApiPromise> { currency = <Currency>{ - name: null, + displayName: null, symbol: null, genesys: null } @@ -99,8 +101,8 @@ export class NetworkService extends StartableService<ApiPromise> { this.currency = WELL_KNOWN_CURRENCIES[chain]; } } - this.currency.name = this.currency.name || chain; - this.currency.symbol = this.currency.symbol || chainInfo.tokenSymbol.value?.[0].toHuman() || abbreviate(this.currency.name); + this.currency.displayName = this.currency.displayName || chain; + this.currency.symbol = this.currency.symbol || chainInfo.tokenSymbol.value?.[0].toHuman() || abbreviate(this.currency.displayName); this.currency.decimals = this.currency.decimals || +(chainInfo.tokenDecimals.value?.[0].toHuman()) || 0; // Read the genesys block hash diff --git a/src/app/register/register.form.html b/src/app/register/register.form.html index 803b832..8f4ea0b 100644 --- a/src/app/register/register.form.html +++ b/src/app/register/register.form.html @@ -45,7 +45,7 @@ <!-- explanation 3 --> <ion-slide class="ion-padding"> - <p [innerHTML]="'ACCOUNT.NEW.STEP_3_HELP'|translate: {currency: currency?.name}"></p> + <p [innerHTML]="'ACCOUNT.NEW.STEP_3_HELP'|translate: {currency: currency?.displayName}"></p> </ion-slide> <!-- explanation 4 --> diff --git a/src/app/wallet/account.service.ts b/src/app/wallet/account.service.ts index 19fa4f1..90a4433 100644 --- a/src/app/wallet/account.service.ts +++ b/src/app/wallet/account.service.ts @@ -122,7 +122,7 @@ export class AccountService extends StartableService { // Configure keyring keyring.setDevMode(this._isDevelopment); - keyring.setSS58Format(currency.ss58Format || 42 /* = dev format */); + keyring.setSS58Format(currency.prefix || 42 /* = dev format */); // Restoring accounts await this.restoreAccounts(currency); @@ -145,7 +145,7 @@ export class AccountService extends StartableService { keyring.loadAll({ store: this._store, - ss58Format: currency?.ss58Format, + ss58Format: currency?.prefix, genesisHash: currency?.genesys, isDevelopment: this._isDevelopment }); -- GitLab