Skip to content

Commit

Permalink
fix: accounts transaction loading [web-archway] (forbole#1306)
Browse files Browse the repository at this point in the history
## Description

Closes: #XXXX

<!-- Add a description of the changes that this PR introduces and the
files that
are the most critical to review. -->

---

### Author Checklist

_All items are required. Please add a note to the item if the item is
not applicable and
please add links to any relevant follow up issues._

I have...

- [ ] ran linting via `yarn lint`
- [ ] wrote tests where necessary
- [ ] included the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] targeted the correct branch
- [ ] provided a link to the relevant issue or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed
- [ ] added a changeset via [`yarn && yarn
changeset`](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)

---------

Co-authored-by: Ignacio <[email protected]>
  • Loading branch information
MonikaCat and icfor authored Oct 6, 2023
1 parent dff3cd6 commit 61b3c8e
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-baboons-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'ui': patch
---

fix: accounts transaction loading
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
env:
PROJECT_NAME: ${{ matrix.project }}
NEXT_PUBLIC_CHAIN_TYPE: ${{ github.event.inputs.chain_type }}
- name: Insall Vercel CLI
- name: Install Vercel CLI
run: npm i -g vercel
- name: Generate vercel.json
run: |
Expand Down
34 changes: 20 additions & 14 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/web-emoney/src/screens/account_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AccountDetails = () => {
/>
<OtherTokens className={classes.otherTokens} otherTokens={state.otherTokens} />
<Staking className={classes.staking} rewards={state.rewards} />
<Transactions className={classes.transactions} />
<Transactions className={classes.transactions} loading={state.balanceLoading} />
</span>
</LoadAndExist>
</Layout>
Expand Down
2 changes: 1 addition & 1 deletion apps/web-evmos/src/screens/account_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AccountDetails = () => {
/>
<OtherTokens className={classes.otherTokens} otherTokens={state.otherTokens} />
<Staking className={classes.staking} rewards={state.rewards} />
<Transactions className={classes.transactions} />
<Transactions className={classes.transactions} loading={state.balanceLoading} />
</span>
</LoadAndExist>
</Layout>
Expand Down
6 changes: 4 additions & 2 deletions apps/web-osmosis/src/screens/account_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const defaultTokenUnit: TokenUnit = {

const initialState: AccountDetailState = {
loading: true,
balanceLoading: true,
exists: true,
desmosProfile: null,
overview: {
Expand Down Expand Up @@ -125,7 +126,7 @@ const formatBalance = (data?: Data) => {
// ==========================
const formatAllBalance = (data?: Data) => {
const stateChange: Partial<AccountDetailState> = {
loading: false,
balanceLoading: false,
};

stateChange.rewards = formatRewards(data);
Expand Down Expand Up @@ -177,7 +178,7 @@ const formatOtherTokens = (data?: Data) => {
const availableAmount = formatToken(availableRawAmount.amount, x);
const rewardsRawAmount = rewards.reduce((a, b) => {
if (!b) return a;
const coins = R.pathOr<NonNullable<typeof b['coins']>>([], ['coins'], b);
const coins = R.pathOr<NonNullable<(typeof b)['coins']>>([], ['coins'], b);
const denom = getDenom(coins, x);
return Big(a).plus(denom.amount).toPrecision();
}, '0');
Expand Down Expand Up @@ -263,6 +264,7 @@ export const useAccountDetails = () => {
useEffect(() => {
handleSetState((prevState) => ({
...prevState,
loading: false,
overview: {
address: address ?? '',
withdrawalAddress: withdrawalAddress.withdrawalAddress?.address ?? '',
Expand Down
2 changes: 1 addition & 1 deletion apps/web-osmosis/src/screens/account_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AccountDetails = () => {
/>
<OtherTokens className={classes.otherTokens} otherTokens={state.otherTokens} />
<Staking className={classes.staking} rewards={state.rewards} />
<Transactions className={classes.transactions} />
<Transactions className={classes.transactions} loading={state.balanceLoading} />
</span>
</LoadAndExist>
</Layout>
Expand Down
2 changes: 1 addition & 1 deletion apps/web-persistence/src/screens/account_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AccountDetails = () => {
/>
<OtherTokens className={classes.otherTokens} otherTokens={state.otherTokens} />
<Staking className={classes.staking} rewards={state.rewards} />
<Transactions className={classes.transactions} />
<Transactions className={classes.transactions} loading={state.balanceLoading} />
</span>
</LoadAndExist>
</Layout>
Expand Down
3 changes: 2 additions & 1 deletion apps/web-stride/src/screens/account_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const formatOtherTokens = (data: Data) => {
const availableRawAmount = getDenom(available, x);
const availableAmount = formatToken(availableRawAmount.amount, x);
const rewardsRawAmount = rewards.reduce((a, b) => {
const coins = R.pathOr<NonNullable<typeof b['coins']>>([], ['coins'], b);
const coins = R.pathOr<NonNullable<(typeof b)['coins']>>([], ['coins'], b);
const denom = getDenom(coins, x);
return Big(a).plus(denom.amount).toPrecision();
}, '0');
Expand Down Expand Up @@ -308,6 +308,7 @@ export const useAccountDetails = () => {
useEffect(() => {
handleSetState((prevState) => ({
...prevState,
loading: false,
overview: {
address: address ?? '',
withdrawalAddress: address ?? withdrawalAddress?.withdrawalAddress?.address ?? '',
Expand Down
Binary file removed bun.lockb
Binary file not shown.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
"eslint-plugin-turbo": "^1.9.3",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"next": "^13.4.1",
"prettier": "2.8.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"turbo": "^1.9.3",
"typescript": "^5.0.4"
},
"packageManager": "[email protected]",
"engines": {
"yarn": ">=1.22"
"yarn": ">=3.5",
"node": ">=18.17.1"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,mjs,cjs,css,md}": "npx prettier --write"
Expand Down
15 changes: 8 additions & 7 deletions packages/ui/src/screens/account_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const formatBalance = (data: Data): BalanceType => {
const rewardsAmount = formatToken(rewards, primaryTokenUnit);

const commission = getDenom(
R.pathOr<NonNullable<NonNullable<typeof data['commission']>['coins']>>(
R.pathOr<NonNullable<NonNullable<(typeof data)['commission']>['coins']>>(
[],
['commission', 'coins'],
data
Expand Down Expand Up @@ -170,7 +170,7 @@ const formatOtherTokens = (data: Data) => {
const availableRawAmount = getDenom(available, x);
const availableAmount = formatToken(availableRawAmount.amount, x);
const rewardsRawAmount = rewards.reduce((a, b) => {
const coins = R.pathOr<NonNullable<typeof b['coins']>>([], ['coins'], b);
const coins = R.pathOr<NonNullable<(typeof b)['coins']>>([], ['coins'], b);
const denom = getDenom(coins, x);
return Big(a).plus(denom.amount).toPrecision();
}, '0');
Expand Down Expand Up @@ -248,11 +248,11 @@ export const useAccountDetails = () => {

useEffect(() => {
const formattedRawData: {
commission?: typeof commission['commission'];
accountBalances?: typeof available['accountBalances'];
delegationBalance?: typeof delegation['delegationBalance'];
unbondingBalance?: typeof unbonding['unbondingBalance'];
delegationRewards?: typeof rewards['delegationRewards'];
commission?: (typeof commission)['commission'];
accountBalances?: (typeof available)['accountBalances'];
delegationBalance?: (typeof delegation)['delegationBalance'];
unbondingBalance?: (typeof unbonding)['unbondingBalance'];
delegationRewards?: (typeof rewards)['delegationRewards'];
} = {};
formattedRawData.commission = R.pathOr({ coins: [] }, ['commission'], commission);
formattedRawData.accountBalances = R.pathOr({ coins: [] }, ['accountBalances'], available);
Expand All @@ -270,6 +270,7 @@ export const useAccountDetails = () => {
useEffect(() => {
handleSetState((prevState) => ({
...prevState,
loading: false,
overview: {
address: address ?? '',
withdrawalAddress: withdrawalAddress.withdrawalAddress?.address ?? '',
Expand Down
3 changes: 3 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6275,7 +6275,10 @@ __metadata:
eslint-plugin-turbo: ^1.9.3
husky: ^8.0.3
lint-staged: ^13.2.2
next: ^13.4.1
prettier: 2.8.8
react: ^18.2.0
react-dom: ^18.2.0
turbo: ^1.9.3
typescript: ^5.0.4
languageName: unknown
Expand Down

0 comments on commit 61b3c8e

Please sign in to comment.