Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import { Api } from '../../api/api'; import { Dispatch, GetState } from '../index'; import { selectActiveNodeApi } from '../stacks-node/stacks-node.reducer'; import { createAction } from '@reduxjs/toolkit'; import { AddressStxBalanceResponse } from '@stacks/stacks-blockchain-api-types'; import { safeAwait } from '@stacks/ui'; export const fetchAddress = createAction('address/fetch-address'); export const fetchAddressDone = createAction<AddressStxBalanceResponse>( 'address/fetch-address-done' ); export const fetchAddressFail = createAction('address/fetch-address-fail'); export function getAddressDetails(address: string) { return async (dispatch: Dispatch, getState: GetState) => { dispatch(fetchAddress()); const activeNode = selectActiveNodeApi(getState()); const [error, response] = await safeAwait( new Api(activeNode.url).accountsApi.getAccountStxBalance({ principal: address }) ); Iif (error) { dispatch(fetchAddressFail()); return; } Iif (response) { dispatch(fetchAddressDone(response as AddressStxBalanceResponse)); } }; } export const updateAddressBalance = createAction<{ address: string; balance: string }>('address/update-balance'); |