Skip to content

Commit

Permalink
chore(wallet-mobile): more helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed May 4, 2024
1 parent 9cd45d5 commit 7afdc86
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,14 @@ export class ByronWallet implements YoroiWallet {
return this.balanceManager.getPrimaryBreakdown()
}

get hasOnlyPrimary() {
return this.balanceManager.getHasOnlyPrimary()
}

get isEmpty() {
return this.balanceManager.getIsEmpty()
}

get receiveAddresses(): Addresses {
return this.externalAddresses.slice(0, this.numReceiveAddresses)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ export const makeShelleyWallet = (constants: typeof MAINNET | typeof TESTNET | t
get primaryBreakdown() {
return this.balanceManager.getPrimaryBreakdown()
}

get hasOnlyPrimary() {
return this.balanceManager.getHasOnlyPrimary()
}

get isEmpty() {
return this.balanceManager.getIsEmpty()
}
// end of portfolio

get receiveAddresses(): Addresses {
Expand Down
25 changes: 16 additions & 9 deletions apps/wallet-mobile/src/yoroi-wallets/cardano/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,24 @@ export type YoroiWallet = {
readonly portfolioPrimaryTokenInfo: Portfolio.Token.Info
readonly balanceManager: Readonly<Portfolio.Manager.Balance>

// ---------------------------------------------------------------------------------------
// ########## Interface - V2 ##########
get isMainnet(): boolean

// Portfolio
balance$: Portfolio.Manager.Balance['observable$']
get balances(): ReturnType<Portfolio.Manager.Balance['getBalances']>
get primaryBalance(): ReturnType<Portfolio.Manager.Balance['getPrimaryBalance']>
get primaryBreakdown(): ReturnType<Portfolio.Manager.Balance['getPrimaryBreakdown']>
get isEmpty(): boolean
get hasOnlyPrimary(): boolean

// sync
resync(): Promise<void>
clear(): Promise<void>
sync(params: {isForced?: boolean}): Promise<void>
// ---------------------------------------------------------------------------------------

// API
api: App.Api

Expand Down Expand Up @@ -161,10 +177,7 @@ export type YoroiWallet = {
fetchNftModerationStatus(fingerprint: string): Promise<YoroiNftModerationStatus>

// Sync, Save
resync(): Promise<void>
clear(): Promise<void>
save(): Promise<void>
sync(params: {isForced?: boolean}): Promise<void>
saveMemo(txId: string, memo: string): Promise<void>

// Balances, TxDetails
Expand All @@ -184,12 +197,6 @@ export type YoroiWallet = {
}
setCollateralId(collateralId: RawUtxo['utxo_id']): Promise<void>

// Portfolio
balance$: Portfolio.Manager.Balance['observable$']
get balances(): ReturnType<Portfolio.Manager.Balance['getBalances']>
get primaryBalance(): ReturnType<Portfolio.Manager.Balance['getPrimaryBalance']>
get primaryBreakdown(): ReturnType<Portfolio.Manager.Balance['getPrimaryBreakdown']>

// Fiat
fetchCurrentPrice(symbol: CurrencySymbol): Promise<number>

Expand Down

0 comments on commit 7afdc86

Please sign in to comment.