From 74be68de8a035374add8d55ccc5ed55592c65aa9 Mon Sep 17 00:00:00 2001 From: ltminhthu Date: Tue, 21 May 2024 13:40:52 +0700 Subject: [PATCH 01/35] sync --- apps/wallet/src/engine/runners/tezos/index.ts | 46 +++++++++++++++++-- apps/wallet/src/engine/runners/tezos/token.ts | 5 ++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 apps/wallet/src/engine/runners/tezos/token.ts diff --git a/apps/wallet/src/engine/runners/tezos/index.ts b/apps/wallet/src/engine/runners/tezos/index.ts index ba66f6892..8beca0fea 100644 --- a/apps/wallet/src/engine/runners/tezos/index.ts +++ b/apps/wallet/src/engine/runners/tezos/index.ts @@ -1,13 +1,53 @@ +import { TezosToolkit } from '@taquito/taquito'; +import {} from '@taquito/tzip16'; +import { Networks } from '@walless/core'; +import type { PublicKeyDocument } from '@walless/store'; +import { selectors } from '@walless/store'; +import { storage } from 'utils/storage'; + import type { EngineConfig, Runner } from '../../types'; export type TezosContext = { - connection: unknown; + connection: TezosToolkit; }; +const MAIN_NET = 'https://api.tez.ie/rpc/mainnet'; +const GHOST_NET = 'https://ghostnet.ecadinfra.com'; + // eslint-disable-next-line @typescript-eslint/no-unused-vars -export const createTezosRunner = (config: EngineConfig): Runner => { +export const createTezosRunner = async ( + config: EngineConfig, +): Promise => { + const { networkClusters } = config; + const cluster = networkClusters[Networks.tezos]; + const rpc = cluster === 'mainnet' ? MAIN_NET : GHOST_NET; + const ghost = GHOST_NET; + + const keysResult = await storage.find(selectors.tezosKeys); + const keys = keysResult.docs; + return { - start() {}, + async start() { + const tokensPromises = keys.map(async (key) => { + const owner = key._id; + const connection = new TezosToolkit(rpc); + const tzBalance = await connection.tz.getBalance(owner); + const tokens = await fetch('https://api.tzkt.io/v1/tokens'); + const balances = await fetch( + 'https://stage.tzpro.io/v1/wallets/{address}/balances', + ); + const tokensJson = await tokens.json(); + const balancesJson = await balances.json(); + console.log(balancesJson); + console.log(tokensJson); + console.log(tzBalance); + + return tzBalance; + }); + await Promise.all(tokensPromises).catch((e) => { + console.error(e); + }); + }, stop() {}, getContext: (): TezosContext => { return {} as TezosContext; diff --git a/apps/wallet/src/engine/runners/tezos/token.ts b/apps/wallet/src/engine/runners/tezos/token.ts new file mode 100644 index 000000000..b94901ec1 --- /dev/null +++ b/apps/wallet/src/engine/runners/tezos/token.ts @@ -0,0 +1,5 @@ +const constructTezosTokenDocument = async ( + token: Token, + network: Network, + tokenMetadata: TokenMetadata, +) => {}; From 9a2f579b9e6a7ea1edbabb662c5d509022ff11eb Mon Sep 17 00:00:00 2001 From: ltminhthu Date: Sat, 25 May 2024 16:33:30 +0700 Subject: [PATCH 02/35] query fungible token on tezos --- apps/wallet/src/engine/runners/tezos/index.ts | 69 ++++++++++++++++--- apps/wallet/src/engine/runners/tezos/token.ts | 56 +++++++++++++-- apps/wallet/src/engine/runners/tezos/utils.ts | 7 ++ packages/core/utils/assets.ts | 18 +++++ 4 files changed, 134 insertions(+), 16 deletions(-) create mode 100644 apps/wallet/src/engine/runners/tezos/utils.ts diff --git a/apps/wallet/src/engine/runners/tezos/index.ts b/apps/wallet/src/engine/runners/tezos/index.ts index 8beca0fea..113c7e50b 100644 --- a/apps/wallet/src/engine/runners/tezos/index.ts +++ b/apps/wallet/src/engine/runners/tezos/index.ts @@ -1,12 +1,17 @@ import { TezosToolkit } from '@taquito/taquito'; import {} from '@taquito/tzip16'; +import type { TezosToken } from '@walless/core'; import { Networks } from '@walless/core'; -import type { PublicKeyDocument } from '@walless/store'; +import type { PublicKeyDocument, TokenDocument } from '@walless/store'; import { selectors } from '@walless/store'; -import { storage } from 'utils/storage'; +import { getTokenQuote } from 'utils/api'; +import { addTokenToStorage, storage } from 'utils/storage'; import type { EngineConfig, Runner } from '../../types'; +import { constructTezosTokenDocument, XTZ } from './token'; +import { convertTezosImageUriToUrl } from './utils'; + export type TezosContext = { connection: TezosToolkit; }; @@ -14,6 +19,9 @@ export type TezosContext = { const MAIN_NET = 'https://api.tez.ie/rpc/mainnet'; const GHOST_NET = 'https://ghostnet.ecadinfra.com'; +const TZKT_API_MAINNET = 'https://api.tzkt.io/v1'; +const TZKT_API_GHOSTNET = 'https://api.ghostnet.tzkt.io/v1'; + // eslint-disable-next-line @typescript-eslint/no-unused-vars export const createTezosRunner = async ( config: EngineConfig, @@ -21,7 +29,7 @@ export const createTezosRunner = async ( const { networkClusters } = config; const cluster = networkClusters[Networks.tezos]; const rpc = cluster === 'mainnet' ? MAIN_NET : GHOST_NET; - const ghost = GHOST_NET; + const tzktAPI = cluster === 'mainnet' ? TZKT_API_MAINNET : TZKT_API_GHOSTNET; const keysResult = await storage.find(selectors.tezosKeys); const keys = keysResult.docs; @@ -32,15 +40,54 @@ export const createTezosRunner = async ( const owner = key._id; const connection = new TezosToolkit(rpc); const tzBalance = await connection.tz.getBalance(owner); - const tokens = await fetch('https://api.tzkt.io/v1/tokens'); - const balances = await fetch( - 'https://stage.tzpro.io/v1/wallets/{address}/balances', + + const tokenBalances = await fetch( + `${tzktAPI}/tokens/balances?account=${owner}`, ); - const tokensJson = await tokens.json(); - const balancesJson = await balances.json(); - console.log(balancesJson); - console.log(tokensJson); - console.log(tzBalance); + const tokenBalancesJson = await tokenBalances.json(); + + const tzDocument = constructTezosTokenDocument({ + ...XTZ, + owner: key._id, + cluster, + amount: tzBalance.toString(), + balance: parseFloat(tzBalance.toString()) / 10 ** XTZ.decimals, + } as TezosToken); + + const tokenDocuments: TokenDocument[] = [tzDocument]; + + tokenBalancesJson.forEach((tokenBalance) => { + const tokenDocument = constructTezosTokenDocument({ + owner: key._id, + network: Networks.tezos, + cluster, + tokenId: tokenBalance.token.tokenId, + contract: tokenBalance.token.contract, + tokenType: tokenBalance.token.standard, + decimals: tokenBalance.token.metadata.decimals, + symbol: tokenBalance.token.metadata.symbol, + name: tokenBalance.token.metadata.name, + amount: tokenBalance.balance, + balance: + parseFloat(tokenBalance.balance) / + 10 ** tokenBalance.token.metadata.decimals, + image: convertTezosImageUriToUrl( + tokenBalance.token.metadata.thumbnailUri, + ), + } as TezosToken); + + tokenDocuments.push(tokenDocument); + }); + + for (const tokenDocument of tokenDocuments) { + const responseQuotes = await getTokenQuote({ + address: `${tokenDocument.contract?.address}`, + network: tokenDocument.network, + }); + tokenDocument.quotes = responseQuotes?.quotes; + + await addTokenToStorage>(tokenDocument); + } return tzBalance; }); diff --git a/apps/wallet/src/engine/runners/tezos/token.ts b/apps/wallet/src/engine/runners/tezos/token.ts index b94901ec1..819f7d8be 100644 --- a/apps/wallet/src/engine/runners/tezos/token.ts +++ b/apps/wallet/src/engine/runners/tezos/token.ts @@ -1,5 +1,51 @@ -const constructTezosTokenDocument = async ( - token: Token, - network: Network, - tokenMetadata: TokenMetadata, -) => {}; +import type { TezosToken } from '@walless/core'; +import { NetworkClusters, Networks, TezosTokenTypes } from '@walless/core'; +import type { TokenDocument } from '@walless/store'; + +import { convertTezosImageUriToUrl } from './utils'; + +export const constructTezosTokenDocument = ( + token: TezosToken, +): TokenDocument => { + let image = convertTezosImageUriToUrl(token.image); + if (token.symbol === 'tzBTC') { + image = 'https://tzbtc.io/wp-content/uploads/2020/03/tzbtc_logo_single.svg'; + } + + const tokenDocument = { + _id: `${token.owner}/token/${token.contract.address}/${token.tokenId}`, + type: 'Token', + network: Networks.tezos, + cluster: token.cluster, + owner: token.owner, + balance: token.balance, + amount: token.amount, + decimals: token.decimals, + symbol: token.symbol, + name: token.name, + image: image, + contract: token.contract, + tokenType: token.tokenType, + tokenId: token.tokenId, + } as TokenDocument; + + return tokenDocument; +}; + +export const XTZ = { + tokenId: '0', + network: Networks.tezos, + owner: '', + cluster: NetworkClusters.mainnet, + balance: 0, + amount: '0', + decimals: 6, + symbol: 'XTZ', + name: 'XTZ', + image: 'https://s2.coinmarketcap.com/static/img/coins/200x200/2011.png', + contract: { + address: 'KT1VYsVfmobT7rsMVivvZ4J8i3bPiqz12NaH', + alias: 'XTZ', + }, + tokenType: TezosTokenTypes.FA12, +}; diff --git a/apps/wallet/src/engine/runners/tezos/utils.ts b/apps/wallet/src/engine/runners/tezos/utils.ts new file mode 100644 index 000000000..59ab3c586 --- /dev/null +++ b/apps/wallet/src/engine/runners/tezos/utils.ts @@ -0,0 +1,7 @@ +export const convertTezosImageUriToUrl = (uri: string) => { + if (!uri) return ''; + if (!uri.startsWith('ipfs://')) return uri; + const path = uri.replaceAll('ipfs://', ''); + + return `https://ipfs.io/ipfs/${path}`; +}; diff --git a/packages/core/utils/assets.ts b/packages/core/utils/assets.ts index 3a93563bf..0c1de26f0 100644 --- a/packages/core/utils/assets.ts +++ b/packages/core/utils/assets.ts @@ -80,3 +80,21 @@ export type SuiToken = Token & { previousTransaction: string; decimals: number; }; + +export enum TezosTokenTypes { + FA12 = 'FA1.2', + FA2 = 'FA2', +} + +export type TezosContract = { + address: string; + alias?: string; +}; + +export type TezosToken = Token & { + tokenId: string; + tokenType: TezosTokenTypes; + contract: TezosContract; + decimals: number; + amount: string; +}; From 43ed3a815f8afd3156fe2cb56fdf513f3e383e8e Mon Sep 17 00:00:00 2001 From: ltminhthu Date: Mon, 3 Jun 2024 10:51:30 +0700 Subject: [PATCH 03/35] update small details of utils in fetching on tezos --- apps/wallet/src/engine/runners/tezos/index.ts | 21 +++++++------------ apps/wallet/src/engine/runners/tezos/utils.ts | 20 ++++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/apps/wallet/src/engine/runners/tezos/index.ts b/apps/wallet/src/engine/runners/tezos/index.ts index 113c7e50b..cd8cb7676 100644 --- a/apps/wallet/src/engine/runners/tezos/index.ts +++ b/apps/wallet/src/engine/runners/tezos/index.ts @@ -1,4 +1,4 @@ -import { TezosToolkit } from '@taquito/taquito'; +import type { TezosToolkit } from '@taquito/taquito'; import {} from '@taquito/tzip16'; import type { TezosToken } from '@walless/core'; import { Networks } from '@walless/core'; @@ -10,26 +10,20 @@ import { addTokenToStorage, storage } from 'utils/storage'; import type { EngineConfig, Runner } from '../../types'; import { constructTezosTokenDocument, XTZ } from './token'; -import { convertTezosImageUriToUrl } from './utils'; +import { convertTezosImageUriToUrl, getTezosContext } from './utils'; export type TezosContext = { connection: TezosToolkit; + tzktApi: string; }; -const MAIN_NET = 'https://api.tez.ie/rpc/mainnet'; -const GHOST_NET = 'https://ghostnet.ecadinfra.com'; - -const TZKT_API_MAINNET = 'https://api.tzkt.io/v1'; -const TZKT_API_GHOSTNET = 'https://api.ghostnet.tzkt.io/v1'; - // eslint-disable-next-line @typescript-eslint/no-unused-vars export const createTezosRunner = async ( config: EngineConfig, ): Promise => { const { networkClusters } = config; const cluster = networkClusters[Networks.tezos]; - const rpc = cluster === 'mainnet' ? MAIN_NET : GHOST_NET; - const tzktAPI = cluster === 'mainnet' ? TZKT_API_MAINNET : TZKT_API_GHOSTNET; + const { connection, tzktApi } = getTezosContext(config); const keysResult = await storage.find(selectors.tezosKeys); const keys = keysResult.docs; @@ -38,11 +32,10 @@ export const createTezosRunner = async ( async start() { const tokensPromises = keys.map(async (key) => { const owner = key._id; - const connection = new TezosToolkit(rpc); const tzBalance = await connection.tz.getBalance(owner); const tokenBalances = await fetch( - `${tzktAPI}/tokens/balances?account=${owner}`, + `${tzktApi}/tokens/balances?account=${owner}`, ); const tokenBalancesJson = await tokenBalances.json(); @@ -76,6 +69,8 @@ export const createTezosRunner = async ( ), } as TezosToken); + console.log(tokenDocument); + tokenDocuments.push(tokenDocument); }); @@ -97,7 +92,7 @@ export const createTezosRunner = async ( }, stop() {}, getContext: (): TezosContext => { - return {} as TezosContext; + return { connection, tzktApi } as TezosContext; }, restart: () => {}, }; diff --git a/apps/wallet/src/engine/runners/tezos/utils.ts b/apps/wallet/src/engine/runners/tezos/utils.ts index 59ab3c586..ca8ca837e 100644 --- a/apps/wallet/src/engine/runners/tezos/utils.ts +++ b/apps/wallet/src/engine/runners/tezos/utils.ts @@ -1,3 +1,23 @@ +import { TezosToolkit } from '@taquito/taquito'; +import { Networks } from '@walless/core'; +import type { EngineConfig } from 'engine/types'; + +const MAIN_NET = 'https://api.tez.ie/rpc/mainnet'; +const GHOST_NET = 'https://ghostnet.ecadinfra.com'; + +const TZKT_API_MAINNET = 'https://api.tzkt.io/v1'; +const TZKT_API_GHOSTNET = 'https://api.ghostnet.tzkt.io/v1'; + +export const getTezosContext = (config: EngineConfig) => { + const { networkClusters } = config; + const cluster = networkClusters[Networks.tezos]; + const rpc = cluster === 'mainnet' ? MAIN_NET : GHOST_NET; + + const connection = new TezosToolkit(rpc); + const tzktApi = cluster === 'mainnet' ? TZKT_API_MAINNET : TZKT_API_GHOSTNET; + return { connection, tzktApi }; +}; + export const convertTezosImageUriToUrl = (uri: string) => { if (!uri) return ''; if (!uri.startsWith('ipfs://')) return uri; From 628d9c9225adf21efdb1dad2d7db3866c5f27dc0 Mon Sep 17 00:00:00 2001 From: ltminhthu Date: Mon, 3 Jun 2024 11:55:40 +0700 Subject: [PATCH 04/35] chore: edit function name, add comments, etc. --- apps/wallet/src/engine/runners/tezos/index.ts | 20 +++++++++---------- apps/wallet/src/engine/runners/tezos/utils.ts | 2 +- packages/core/utils/assets.ts | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/wallet/src/engine/runners/tezos/index.ts b/apps/wallet/src/engine/runners/tezos/index.ts index cd8cb7676..5ef94daf3 100644 --- a/apps/wallet/src/engine/runners/tezos/index.ts +++ b/apps/wallet/src/engine/runners/tezos/index.ts @@ -10,7 +10,7 @@ import { addTokenToStorage, storage } from 'utils/storage'; import type { EngineConfig, Runner } from '../../types'; import { constructTezosTokenDocument, XTZ } from './token'; -import { convertTezosImageUriToUrl, getTezosContext } from './utils'; +import { convertTezosImageUriToUrl, createContext } from './utils'; export type TezosContext = { connection: TezosToolkit; @@ -23,7 +23,7 @@ export const createTezosRunner = async ( ): Promise => { const { networkClusters } = config; const cluster = networkClusters[Networks.tezos]; - const { connection, tzktApi } = getTezosContext(config); + const { connection, tzktApi } = createContext(config); const keysResult = await storage.find(selectors.tezosKeys); const keys = keysResult.docs; @@ -47,9 +47,15 @@ export const createTezosRunner = async ( balance: parseFloat(tzBalance.toString()) / 10 ** XTZ.decimals, } as TezosToken); - const tokenDocuments: TokenDocument[] = [tzDocument]; + const responseQuotes = await getTokenQuote({ + address: `${tzDocument.contract?.address}`, + network: tzDocument.network, + }); + tzDocument.quotes = responseQuotes?.quotes; + + await addTokenToStorage>(tzDocument); - tokenBalancesJson.forEach((tokenBalance) => { + for (const tokenBalance of tokenBalancesJson) { const tokenDocument = constructTezosTokenDocument({ owner: key._id, network: Networks.tezos, @@ -69,12 +75,6 @@ export const createTezosRunner = async ( ), } as TezosToken); - console.log(tokenDocument); - - tokenDocuments.push(tokenDocument); - }); - - for (const tokenDocument of tokenDocuments) { const responseQuotes = await getTokenQuote({ address: `${tokenDocument.contract?.address}`, network: tokenDocument.network, diff --git a/apps/wallet/src/engine/runners/tezos/utils.ts b/apps/wallet/src/engine/runners/tezos/utils.ts index ca8ca837e..e26621ead 100644 --- a/apps/wallet/src/engine/runners/tezos/utils.ts +++ b/apps/wallet/src/engine/runners/tezos/utils.ts @@ -8,7 +8,7 @@ const GHOST_NET = 'https://ghostnet.ecadinfra.com'; const TZKT_API_MAINNET = 'https://api.tzkt.io/v1'; const TZKT_API_GHOSTNET = 'https://api.ghostnet.tzkt.io/v1'; -export const getTezosContext = (config: EngineConfig) => { +export const createContext = (config: EngineConfig) => { const { networkClusters } = config; const cluster = networkClusters[Networks.tezos]; const rpc = cluster === 'mainnet' ? MAIN_NET : GHOST_NET; diff --git a/packages/core/utils/assets.ts b/packages/core/utils/assets.ts index 0c1de26f0..4f6f14c8e 100644 --- a/packages/core/utils/assets.ts +++ b/packages/core/utils/assets.ts @@ -81,6 +81,7 @@ export type SuiToken = Token & { decimals: number; }; +// There are 2 standards of tokens in Tezos, they are FA1.2 and FA2 export enum TezosTokenTypes { FA12 = 'FA1.2', FA2 = 'FA2', From 3f472ba0cf3d675cbc6bec4cc75133e0012781aa Mon Sep 17 00:00:00 2001 From: ltminhthu Date: Wed, 5 Jun 2024 08:43:27 +0700 Subject: [PATCH 05/35] chore: adjust code syntax --- apps/wallet/src/engine/runners/tezos/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/wallet/src/engine/runners/tezos/index.ts b/apps/wallet/src/engine/runners/tezos/index.ts index 5ef94daf3..aa59e5106 100644 --- a/apps/wallet/src/engine/runners/tezos/index.ts +++ b/apps/wallet/src/engine/runners/tezos/index.ts @@ -86,9 +86,7 @@ export const createTezosRunner = async ( return tzBalance; }); - await Promise.all(tokensPromises).catch((e) => { - console.error(e); - }); + await Promise.all(tokensPromises).catch(console.error); }, stop() {}, getContext: (): TezosContext => { From 738ecec4b62238b1af95b1f60ce4595cfc647d26 Mon Sep 17 00:00:00 2001 From: ltminhthu Date: Tue, 11 Jun 2024 16:25:10 +0700 Subject: [PATCH 06/35] fix: navigation for new explorer screen --- apps/wallet/src/features/Explorer/Header.tsx | 2 +- apps/wallet/src/features/Loyalty/internal.tsx | 6 ++++-- apps/wallet/src/stacks/Explorer/index.tsx | 8 +++++++- apps/wallet/src/utils/navigation/index.ts | 8 +++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/wallet/src/features/Explorer/Header.tsx b/apps/wallet/src/features/Explorer/Header.tsx index bc8dce078..f2dec292e 100644 --- a/apps/wallet/src/features/Explorer/Header.tsx +++ b/apps/wallet/src/features/Explorer/Header.tsx @@ -27,7 +27,7 @@ const Header = () => { return ( - Hi👋, your balance today: + Hi 👋, your balance today: { diff --git a/apps/wallet/src/features/Loyalty/internal.tsx b/apps/wallet/src/features/Loyalty/internal.tsx index f954718f8..a054f8ef1 100644 --- a/apps/wallet/src/features/Loyalty/internal.tsx +++ b/apps/wallet/src/features/Loyalty/internal.tsx @@ -141,7 +141,8 @@ export const navigateInternalByCta = (cta: string) => { params: { screen: 'Widget', params: { - id: 'pixeverse', + screen: 'Default', + params: { id: 'pixeverse' }, }, }, }); @@ -160,7 +161,8 @@ export const navigateInternalByCta = (cta: string) => { params: { screen: 'Widget', params: { - id: 'solana', + screen: 'Default', + params: { id: 'solana' }, }, }, }); diff --git a/apps/wallet/src/stacks/Explorer/index.tsx b/apps/wallet/src/stacks/Explorer/index.tsx index fe45af5c6..64f8f90ff 100644 --- a/apps/wallet/src/stacks/Explorer/index.tsx +++ b/apps/wallet/src/stacks/Explorer/index.tsx @@ -39,7 +39,13 @@ export const ExplorerStack = () => { goBack: () => navigate('Dashboard', { screen: 'Explore', - params: { screen: 'Widget', params: {} }, + params: { + screen: 'Widget', + params: { + screen: 'Default', + params: { id: 'explorer' }, + }, + }, }), }), [], diff --git a/apps/wallet/src/utils/navigation/index.ts b/apps/wallet/src/utils/navigation/index.ts index fe3e399c2..8a1a13c7c 100644 --- a/apps/wallet/src/utils/navigation/index.ts +++ b/apps/wallet/src/utils/navigation/index.ts @@ -51,7 +51,13 @@ export const linking: LinkingOptions = { Explore: { path: '/explore', screens: { - Widget: '/widget/:id', + Widget: { + path: '/widget', + screens: { + Default: '/:id', + Setting: '/setting', + }, + }, Collection: { path: '/collection', screens: { From 91e8cddd3b3744660eb8086c124367c992dec674 Mon Sep 17 00:00:00 2001 From: Tan Le Date: Wed, 12 Jun 2024 11:22:36 +0700 Subject: [PATCH 07/35] feat: transparent status bar on android --- apps/wallet/src/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/wallet/src/index.tsx b/apps/wallet/src/index.tsx index 949f05986..c180eca9b 100644 --- a/apps/wallet/src/index.tsx +++ b/apps/wallet/src/index.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef } from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; -import { StyleSheet, View } from 'react-native'; +import { Platform, StatusBar, StyleSheet, View } from 'react-native'; import { SafeAreaProvider } from 'react-native-safe-area-context'; import { NavigationContainer } from '@react-navigation/native'; import { modalActions, ModalManager, themeState } from '@walless/gui'; @@ -31,6 +31,12 @@ export const AppStack = () => { useNotifications(); useEffect(() => modalActions.setContainerRef(modalContainerRef), []); + useEffect(() => { + if (Platform.OS === 'android') { + StatusBar.setTranslucent(true); + StatusBar.setBackgroundColor('transparent'); + } + }, []); return ( From 9d5f3a1803607bb399d201a3cc24bcbc565f66fd Mon Sep 17 00:00:00 2001 From: Tan Le Date: Wed, 12 Jun 2024 12:37:39 +0700 Subject: [PATCH 08/35] chore: use svg logo --- apps/wallet/src/components/Logo.tsx | 92 +++++++++++++++++++ .../Invitation/InvitationHeader.tsx | 19 ++-- .../Authentication/Invitation/index.tsx | 7 +- .../Authentication/Login/SignInHeader.tsx | 14 +-- .../Authentication/Login/SignInInner.tsx | 7 +- .../screens/Authentication/Login/index.tsx | 3 +- .../src/screens/Authentication/Recovery.tsx | 15 +-- 7 files changed, 123 insertions(+), 34 deletions(-) create mode 100644 apps/wallet/src/components/Logo.tsx diff --git a/apps/wallet/src/components/Logo.tsx b/apps/wallet/src/components/Logo.tsx new file mode 100644 index 000000000..7b25922ff --- /dev/null +++ b/apps/wallet/src/components/Logo.tsx @@ -0,0 +1,92 @@ +import type { FC } from 'react'; +import { + ClipPath, + Defs, + G, + LinearGradient, + Path, + Rect, + Stop, + Svg, +} from 'react-native-svg'; + +type Props = { + size?: number; +}; + +export const Logo: FC = ({ size = 118 }) => { + const width = size; + const height = (width * 62) / 118; + + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default Logo; diff --git a/apps/wallet/src/screens/Authentication/Invitation/InvitationHeader.tsx b/apps/wallet/src/screens/Authentication/Invitation/InvitationHeader.tsx index 6ce36de6c..ee3380f8b 100644 --- a/apps/wallet/src/screens/Authentication/Invitation/InvitationHeader.tsx +++ b/apps/wallet/src/screens/Authentication/Invitation/InvitationHeader.tsx @@ -1,22 +1,20 @@ import type { FC } from 'react'; -import type { ImageSourcePropType, ViewStyle } from 'react-native'; -import { Image, StyleSheet } from 'react-native'; +import type { ViewStyle } from 'react-native'; +import { StyleSheet } from 'react-native'; import { Text, View } from '@walless/gui'; +import Logo from 'components/Logo'; interface Props { - logoSrc: ImageSourcePropType; logoSize: number; style?: ViewStyle; } -const InvitationHeader: FC = ({ logoSrc, logoSize, style }) => { - const logoStyle = { - width: logoSize, - height: logoSize, - }; +const InvitationHeader: FC = ({ logoSize, style }) => { return ( - + + + Welcome to Walless You’ll need to enter invitation code to access{'\n'}Private Beta. @@ -31,6 +29,9 @@ const styles = StyleSheet.create({ container: { alignItems: 'center', }, + logoContainer: { + marginVertical: 14, + }, greetingText: { fontSize: 20, fontWeight: '600', diff --git a/apps/wallet/src/screens/Authentication/Invitation/index.tsx b/apps/wallet/src/screens/Authentication/Invitation/index.tsx index 01330e5bd..d7f6128e3 100644 --- a/apps/wallet/src/screens/Authentication/Invitation/index.tsx +++ b/apps/wallet/src/screens/Authentication/Invitation/index.tsx @@ -14,7 +14,6 @@ import { import { Anchor, Button, Input, Text, View } from '@walless/gui'; import { showError } from 'modals/Error'; import { appState } from 'state/app'; -import assets from 'utils/assets'; import { validateInvitationCode } from 'utils/auth'; import { useSafeAreaInsets, useSnapshot } from 'utils/hooks'; import { navigate } from 'utils/navigation'; @@ -86,11 +85,7 @@ export const InvitationScreen: FC = () => { - + = ({ logoSrc, logoSize }) => { - const logoStyle = { - width: logoSize, - height: logoSize, - }; +const SignInHeader: FC = ({ logoSize }) => { return ( - + Sign in to continue ); @@ -27,6 +22,7 @@ const styles = StyleSheet.create({ alignItems: 'center', justifyContent: 'center', paddingTop: 48, + gap: 10, }, title: { fontSize: 20, diff --git a/apps/wallet/src/screens/Authentication/Login/SignInInner.tsx b/apps/wallet/src/screens/Authentication/Login/SignInInner.tsx index 398eb7d8b..f995479e9 100644 --- a/apps/wallet/src/screens/Authentication/Login/SignInInner.tsx +++ b/apps/wallet/src/screens/Authentication/Login/SignInInner.tsx @@ -14,7 +14,9 @@ const SignInInner: FC = ({ onGoogleSignIn, loading }) => { {loading ? ( - + + + ) : (