Skip to content

Commit

Permalink
Merge pull request #310 from aura-nw/euphoria
Browse files Browse the repository at this point in the history
Euphoria
  • Loading branch information
harisato authored Aug 24, 2023
2 parents a869781 + 6327705 commit c49ba90
Show file tree
Hide file tree
Showing 23 changed files with 895 additions and 565 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pyxis-safe",
"version": "0.4.8",
"version": "0.6.0",
"description": "The multi-signature safe of the Interchain",
"website": "https://github.com/aura-nw/aura-safe#aura-safe",
"bugs": {
Expand Down Expand Up @@ -298,4 +298,4 @@
"typescript": "^4.3.5",
"wait-on": "^6.0.0"
}
}
}
6 changes: 1 addition & 5 deletions src/config/cache/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,29 @@ let chains: ChainInfo[] = []
export const getChains = (): ChainInfo[] => chains

export const loadChains = async () => {
const networkList: ChainInfo[] = await getMChainsConfig();
const networkList: ChainInfo[] = await getMChainsConfig()
chains = networkList.map((chain) => {
if (chain.chainId.includes('euphoria')) {
return {
...chain,
indexerUrl: 'https://indexer-v2.dev.aurascan.io/api/v1/graphiql',
environment: 'euphoria',
}
}
if (chain.chainId.includes('serenity')) {
return {
...chain,
indexerUrl: 'https://indexer-v2.dev.aurascan.io/api/v1/graphiql',
environment: 'serenity',
}
}
if (chain.chainId.includes('aura-testnet')) {
return {
...chain,
indexerUrl: 'https://indexer-v2.dev.aurascan.io/api/v1/graphiql',
environment: 'auratestnet',
}
}
if (chain.chainId.includes('xstaxy')) {
return {
...chain,
indexerUrl: 'https://indexer-v2.dev.aurascan.io/api/v1/graphiql',
environment: 'xstaxy',
}
}
Expand Down
1 change: 0 additions & 1 deletion src/logic/config/store/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { clearSafeList } from 'src/logic/safe/store/actions/clearSafeList'
import loadSafesFromStorage from 'src/logic/safe/store/actions/loadSafesFromStorage'
import { Dispatch } from 'src/logic/safe/store/actions/types'
import { CONFIG_ACTIONS } from '../actions'
import { fetchAllValidator } from 'src/logic/validator/store/actions'

export const configMiddleware =
({ dispatch }) =>
Expand Down
40 changes: 26 additions & 14 deletions src/logic/delegation/store/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
import { Action, createAction } from 'redux-actions'
import { ThunkDispatch } from 'redux-thunk'
import { getInternalChainId } from 'src/config'
import { extractSafeAddress } from 'src/routes/routes'
import { getAllDelegateOfUser } from 'src/services'
import { getChainInfo } from 'src/config'
import { AppReduxState } from 'src/logic/safe/store'
import { extractSafeAddress } from 'src/routes/routes'
import { getAllDelegations, getAllReward } from 'src/services'
import { DelegationType } from '../reducer'

export const FETCH_ALL_DELEGATIONS = 'FETCH_ALL_DELEGATIONS'

export const fetchAllDelegations =
() =>
async (dispatch: ThunkDispatch<AppReduxState, undefined, Action<DelegationType[]>>): Promise<void> => {
try {
const safeAddress = extractSafeAddress()
const internalChainId = getInternalChainId()
const allDelegation = (await getAllDelegateOfUser(internalChainId, safeAddress)) as any
if (allDelegation.Data.delegations) {
const formatedData: DelegationType[] = allDelegation.Data.delegations.map(
async (dispatch: ThunkDispatch<AppReduxState, undefined, Action<DelegationType[]>>): Promise<void> => {
try {
const safeAddress = extractSafeAddress()
const currentChainInfo = getChainInfo() as any
const allDelegation = await getAllDelegations(currentChainInfo.lcd, safeAddress)
const allReward = await getAllReward(currentChainInfo.lcd, safeAddress)

const formatDataDelegations = allDelegation?.delegation_responses
?.map((delegation: any) => {
const reward = allReward?.rewards?.find(
(rw: any) => rw.validator_address === delegation.delegation.validator_address,
) as any
return {
balance: delegation.balance,
operatorAddress: delegation.delegation.validator_address,
reward: reward?.reward ?? [],
}
}) ?? []

const formatedData: DelegationType[] = formatDataDelegations.map(
(delegation: any): DelegationType => ({
operatorAddress: delegation.operatorAddress,
reward: delegation.reward[0]?.amount,
staked: delegation.balance?.amount,
}),
)
dispatch(setAllDelegation(formatedData))
} catch (err) {
console.error('fetch delegation error', err)
}
} catch (err) {
console.error('fetch delegation error', err)
return Promise.resolve()
}
return Promise.resolve()
}
const setAllDelegation = createAction<DelegationType[]>(FETCH_ALL_DELEGATIONS)
Loading

0 comments on commit c49ba90

Please sign in to comment.