diff --git a/src/app/components/Toolbar/Features/Account/__tests__/Account.test.tsx b/src/app/components/Toolbar/Features/Account/__tests__/Account.test.tsx
index d7d2e955aa..5af4e9ee45 100644
--- a/src/app/components/Toolbar/Features/Account/__tests__/Account.test.tsx
+++ b/src/app/components/Toolbar/Features/Account/__tests__/Account.test.tsx
@@ -7,7 +7,7 @@ import { Account, AccountProps } from '../Account'
const props = {
address: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
- balance: { available: '200', debonding: '0', delegations: '800', total: '1000' },
+ balance: { available: '200', debonding: '0', delegations: '800', total: '1000', nonce: '0' },
onClick: () => {},
isActive: false,
displayBalance: true,
diff --git a/src/app/components/Toolbar/Features/AccountSelector/__tests__/index.test.tsx b/src/app/components/Toolbar/Features/AccountSelector/__tests__/index.test.tsx
index 165eaf5667..f0830caf73 100644
--- a/src/app/components/Toolbar/Features/AccountSelector/__tests__/index.test.tsx
+++ b/src/app/components/Toolbar/Features/AccountSelector/__tests__/index.test.tsx
@@ -28,7 +28,7 @@ describe('', () => {
wallets: {
oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe: {
address: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
- balance: { available: '100', debonding: '0', delegations: '0', total: '100' },
+ balance: { available: '100', debonding: '0', delegations: '0', total: '100', nonce: '0' },
publicKey: '00',
type: WalletType.UsbLedger,
},
diff --git a/src/app/lib/getAccountBalanceWithFallback.ts b/src/app/lib/getAccountBalanceWithFallback.ts
index c6f70df719..a9144e308e 100644
--- a/src/app/lib/getAccountBalanceWithFallback.ts
+++ b/src/app/lib/getAccountBalanceWithFallback.ts
@@ -3,7 +3,7 @@ import { call } from 'typed-redux-saga'
import { getExplorerAPIs, getOasisNic } from '../state/network/saga'
import { Account } from '../state/account/types'
-function* getBalanceGRPC(address: string, { includeNonce = true } = {}) {
+function* getBalanceGRPC(address: string) {
const nic = yield* call(getOasisNic)
const publicKey = yield* call(addressToPublicKey, address)
const account = yield* call([nic, nic.stakingAccount], { owner: publicKey, height: 0 })
@@ -14,19 +14,19 @@ function* getBalanceGRPC(address: string, { includeNonce = true } = {}) {
delegations: null,
debonding: null,
total: null,
- ...(includeNonce ? { nonce: account.general?.nonce?.toString() ?? '0' } : {}),
+ nonce: account.general?.nonce?.toString() ?? '0',
}
}
-export function* getAccountBalanceWithFallback(address: string, { includeNonce = true } = {}) {
+export function* getAccountBalanceWithFallback(address: string) {
const { getAccount } = yield* call(getExplorerAPIs)
try {
- const account: Account = yield* call(getAccount, address, { includeNonce })
+ const account: Account = yield* call(getAccount, address)
return account
} catch (apiError: any) {
console.error('get account failed, continuing to RPC fallback.', apiError)
try {
- const account: Account = yield* call(getBalanceGRPC, address, { includeNonce })
+ const account: Account = yield* call(getBalanceGRPC, address)
return account
} catch (rpcError) {
console.error('get account with RPC failed, continuing without updated account.', rpcError)
diff --git a/src/app/pages/AccountPage/index.tsx b/src/app/pages/AccountPage/index.tsx
index ad5358dd30..c03ca14290 100644
--- a/src/app/pages/AccountPage/index.tsx
+++ b/src/app/pages/AccountPage/index.tsx
@@ -91,6 +91,7 @@ export function AccountPage() {
account.available == null || balanceDelegations == null || balanceDebondingDelegations == null
? null
: (BigInt(account.available) + balanceDelegations + balanceDebondingDelegations).toString(),
+ nonce: account.nonce,
}
// Restart fetching account balances if address or network changes
diff --git a/src/app/pages/OpenWalletPage/Features/ImportAccountsSelectionModal/__tests__/index.test.tsx b/src/app/pages/OpenWalletPage/Features/ImportAccountsSelectionModal/__tests__/index.test.tsx
index 10269e5291..44cb2ae264 100644
--- a/src/app/pages/OpenWalletPage/Features/ImportAccountsSelectionModal/__tests__/index.test.tsx
+++ b/src/app/pages/OpenWalletPage/Features/ImportAccountsSelectionModal/__tests__/index.test.tsx
@@ -52,7 +52,7 @@ describe('', () => {
importAccountsActions.accountsListed([
{
address: 'oasis1qzyqaxestzlum26e2vdgvkerm6d9qgdp7gh2pxqe',
- balance: { available: '0', debonding: '0', delegations: '0', total: '0' },
+ balance: { available: '0', debonding: '0', delegations: '0', total: '0', nonce: '0' },
path: [44, 474, 0],
pathDisplay: `m/44'/474'/0'`,
publicKey: '00',
@@ -77,7 +77,7 @@ describe('', () => {
importAccountsActions.accountsListed([
{
address: 'oasis1qzyqaxestzlum26e2vdgvkerm6d9qgdp7gh2pxqe',
- balance: { available: '0', debonding: '0', delegations: '0', total: '0' },
+ balance: { available: '0', debonding: '0', delegations: '0', total: '0', nonce: '0' },
path: [44, 474, 0],
pathDisplay: `m/44'/474'/0'`,
publicKey: '00',
@@ -86,7 +86,7 @@ describe('', () => {
},
{
address: 'oasis1qqv25adrld8jjquzxzg769689lgf9jxvwgjs8tha',
- balance: { available: '0', debonding: '0', delegations: '0', total: '0' },
+ balance: { available: '0', debonding: '0', delegations: '0', total: '0', nonce: '0' },
path: [44, 474, 1],
pathDisplay: `m/44'/474'/1'`,
publicKey: '00',
diff --git a/src/app/state/account/types.ts b/src/app/state/account/types.ts
index cd3a7b5011..46f0554fbc 100644
--- a/src/app/state/account/types.ts
+++ b/src/app/state/account/types.ts
@@ -11,7 +11,7 @@ export interface BalanceDetails {
delegations: StringifiedBigInt | null
/** This is delayed in getAccount by 20 seconds on oasisscan and 5 seconds on oasismonitor. */
total: StringifiedBigInt | null
- nonce?: StringifiedBigInt | null
+ nonce: StringifiedBigInt
}
export interface Allowance {
@@ -22,7 +22,6 @@ export interface Allowance {
export interface Account extends BalanceDetails {
address: string
allowances?: Allowance[]
- nonce?: StringifiedBigInt
}
/* --- STATE --- */
diff --git a/src/app/state/wallet/saga.ts b/src/app/state/wallet/saga.ts
index 76f7a0afa2..7f82b19c69 100644
--- a/src/app/state/wallet/saga.ts
+++ b/src/app/state/wallet/saga.ts
@@ -48,13 +48,11 @@ export function* openWalletsFromLedger({ payload }: PayloadAction {
+ async function getAccount(address: string): Promise {
const account = await accounts.getAccount({ accountId: address })
if (!account || account.code !== 0) throw new Error('Wrong response code') // TODO
- return parseAccount(account.data, { includeNonce })
+ return parseAccount(account.data)
}
async function getAllValidators(): Promise {
@@ -103,7 +103,7 @@ export function getOasisscanAPIs(url: string | 'https://api.oasisscan.com/mainne
}
}
-export function parseAccount(account: AccountsRow, { includeNonce = true } = {}): Account {
+export function parseAccount(account: AccountsRow): Account {
return {
address: account.address,
allowances: account.allowances.map(allowance => ({
@@ -114,7 +114,7 @@ export function parseAccount(account: AccountsRow, { includeNonce = true } = {})
delegations: parseRoseStringToBaseUnitString(account.escrow),
debonding: parseRoseStringToBaseUnitString(account.debonding),
total: parseRoseStringToBaseUnitString(account.total),
- ...(includeNonce ? { nonce: BigInt(account.nonce ?? 0).toString() } : {}),
+ nonce: BigInt(account.nonce ?? 0).toString(),
}
}