Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Euphoria #359

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 67 additions & 67 deletions src/logic/safe/store/actions/fetchTransactionDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,57 @@ const updateTransactionDetails = createAction<TransactionDetailsPayload>(UPDATE_

export const fetchTransactionDetailsById =
({ transactionId, auraTxId }: { transactionId?: string; auraTxId?: string }) =>
async (dispatch: Dispatch, getState: () => AppReduxState): Promise<Transaction['txDetails']> => {
const transaction = getTransactionByAttribute(getState(), {
attributeValue: transactionId ? transactionId : auraTxId,
attributeName: transactionId ? 'id' : 'auraTxId',
})
const safeAddress = extractSafeAddress()
const chainId = currentChainId(getState())
const chainInfo = getChainInfo() as any
async (dispatch: Dispatch, getState: () => AppReduxState): Promise<Transaction['txDetails']> => {
const transaction = getTransactionByAttribute(getState(), {
attributeValue: transactionId ? transactionId : auraTxId,
attributeName: transactionId ? 'id' : 'auraTxId',
})
const safeAddress = extractSafeAddress()
const chainId = currentChainId(getState())
const chainInfo = getChainInfo() as any

if (transaction?.txDetails || !safeAddress) {
if (transaction?.txDetails || !safeAddress) {
return
}

try {
const { Data, ErrorCode } = await getTxDetailById(safeAddress, transactionId, auraTxId)
if (ErrorCode !== MESSAGES_CODE.SUCCESSFUL.ErrorCode) {
return
}
const extraDetails: any = {}
const listProposals = (await getProposals()).data?.[chainInfo.environment]?.proposal
const proposal = listProposals?.find((proposal) => proposal.proposal_id === Data?.Messages?.[0]?.proposalId)

try {
const { Data, ErrorCode } = await getTxDetailById(safeAddress, transactionId, auraTxId)
if (ErrorCode !== MESSAGES_CODE.SUCCESSFUL.ErrorCode) {
return
}
const extraDetails: any = {}
const listProposals = (await getProposals()).data?.[chainInfo.environment]?.proposal
const proposal = listProposals?.find((proposal) => proposal.proposal_id === Data?.Messages?.[0]?.proposalId)

if (proposal) {
const proposalDetail = {
id: proposal.proposal_id,
title: proposal.content[0].content.title,
status: proposal.status,
votingEnd: proposal.voting_end_time,
}
extraDetails.proposalDetail = proposalDetail
if (proposal) {
const proposalDetail = {
id: proposal.proposal_id,
title: proposal.title,
status: proposal.status,
votingEnd: proposal.voting_end_time,
}
extraDetails.proposalDetail = proposalDetail
}

const transactionDetails: any = {
txId: Data?.MultisigTxId?.toString() || null,
auraTxId: Data?.AuraTxId?.toString() || null,
executedAt: Data.Timestamp
? new Date(Data.Timestamp).getTime()
: Data.Executor
? new Date(Data.Executor.updatedAt).getTime()
: null,
createAt: Data.CreatedAt ? new Date(Data.CreatedAt).getTime() : null,
txStatus: (Data.Status == '0' ? TransactionStatus.SUCCESS : Data.Status) as TransactionStatus,
txMessage: Data?.Messages?.length ? Data?.Messages : [],
rawMessage: Data?.RawMessages,
deletedBy: Data?.Deleter,
fee: Data?.Fee?.toString() || 0,
gas: Data?.Gas?.toString() || 0,
txHash: Data?.TxHash || null,
confirmationsRequired: Data.ConfirmationsRequired,
confirmations: Data?.Confirmations?.map(
(cf) =>
const transactionDetails: any = {
txId: Data?.MultisigTxId?.toString() || null,
auraTxId: Data?.AuraTxId?.toString() || null,
executedAt: Data.Timestamp
? new Date(Data.Timestamp).getTime()
: Data.Executor
? new Date(Data.Executor.updatedAt).getTime()
: null,
createAt: Data.CreatedAt ? new Date(Data.CreatedAt).getTime() : null,
txStatus: (Data.Status == '0' ? TransactionStatus.SUCCESS : Data.Status) as TransactionStatus,
txMessage: Data?.Messages?.length ? Data?.Messages : [],
rawMessage: Data?.RawMessages,
deletedBy: Data?.Deleter,
fee: Data?.Fee?.toString() || 0,
gas: Data?.Gas?.toString() || 0,
txHash: Data?.TxHash || null,
confirmationsRequired: Data.ConfirmationsRequired,
confirmations: Data?.Confirmations?.map(
(cf) =>
({
signature: cf.signature,
signer: {
Expand All @@ -77,31 +77,31 @@ export const fetchTransactionDetailsById =
},
submittedAt: new Date(cf.createdAt).getTime(),
} as MultisigConfirmation),
),
executor: !Data?.Executor
? null
: {
),
executor: !Data?.Executor
? null
: {
logoUri: null,
name: null,
value: Data.Executor.ownerAddress,
},
rejectors: Data?.Rejectors?.map((re) => ({ logoUri: null, name: null, value: re.ownerAddress } as AddressEx)),
extraDetails,
autoClaimAmount: Data?.AutoClaimAmount,
sequence: Data?.Sequence,
logs: Data?.Logs,
txMemo: Data?.Memo,
}

dispatch(
updateTransactionDetails({
chainId,
transactionId: transactionDetails.txId,
safeAddress,
value: transactionDetails,
}),
)
} catch (error) {
console.error(`Failed to retrieve transaction details`, error.message)
rejectors: Data?.Rejectors?.map((re) => ({ logoUri: null, name: null, value: re.ownerAddress } as AddressEx)),
extraDetails,
autoClaimAmount: Data?.AutoClaimAmount,
sequence: Data?.Sequence,
logs: Data?.Logs,
txMemo: Data?.Memo,
}

dispatch(
updateTransactionDetails({
chainId,
transactionId: transactionDetails.txId,
safeAddress,
value: transactionDetails,
}),
)
} catch (error) {
console.error(`Failed to retrieve transaction details`, error.message)
}
}
2 changes: 1 addition & 1 deletion src/pages/Voting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function Voting(): ReactElement {
}
return {
id: proposal.proposal_id,
title: proposal.content.title,
title: proposal.title,
proposer: proposal.proposer_address,
status: proposal.status,
votingStart: proposal.voting_start_time,
Expand Down
21 changes: 19 additions & 2 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ export async function getNumberOfDelegator(validatorId: any): Promise<IResponse<
const { chainInfo } = await getGatewayUrl()
return axios
.get(
`${chainInfo.find((chain) => chain.chainId == currentChainInfo.chainId)?.rest
`${
chainInfo.find((chain) => chain.chainId == currentChainInfo.chainId)?.rest
}/cosmos/staking/v1beta1/validators/${validatorId}/delegations?pagination.count_total=true`,
)
.then((res) => res.data)
Expand All @@ -363,7 +364,23 @@ export const getProposals = async () => {

return axios
.post(chainInfo.indexerV2, {
query: `query GetProposals {\n ${chainInfo.environment} {\n proposal(order_by: {proposal_id: desc}, limit: 10) {\n proposer_address\n content\n tally\n proposal_id\n status\n submit_time\n deposit_end_time\n total_deposit\n voting_start_time\n voting_end_time\n }\n }\n }`,
query: `query GetProposals {${chainInfo.environment} {
proposal(order_by: {proposal_id: desc}, limit: 10)
{
proposer_address
content
tally
title
proposal_id
status
submit_time
deposit_end_time
total_deposit
voting_start_time
voting_end_time
}
}
}`,
variables: {},
operationName: 'GetProposals',
})
Expand Down
2 changes: 1 addition & 1 deletion src/types/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ export interface IProposal {
depositEndTime: Date
turnout: Turnout
requestAmount: Amount
}
}