From 8496bc8709b90322199bc9dfbc49da4587f7b206 Mon Sep 17 00:00:00 2001 From: Greg Nazario Date: Mon, 4 Nov 2024 13:18:22 -0500 Subject: [PATCH] [transactions] Add source contract for multisig transactions that apply (#893) --- src/pages/Transaction/utils.tsx | 60 +++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/pages/Transaction/utils.tsx b/src/pages/Transaction/utils.tsx index ae9e65d9..41e71f56 100644 --- a/src/pages/Transaction/utils.tsx +++ b/src/pages/Transaction/utils.tsx @@ -23,7 +23,20 @@ export function getTransactionCounterparty( return undefined; } - if (transaction.payload.type !== "entry_function_payload") { + let payload: Types.TransactionPayload_EntryFunctionPayload; + if (transaction.payload.type === "entry_function_payload") { + payload = + transaction.payload as Types.TransactionPayload_EntryFunctionPayload; + } else if ( + transaction.payload.type === "multisig_payload" && + "transaction_payload" in transaction.payload && + transaction.payload.transaction_payload && + "type" in transaction.payload.transaction_payload && + transaction.payload.transaction_payload.type === "entry_function_payload" + ) { + payload = transaction.payload + .transaction_payload as Types.TransactionPayload_EntryFunctionPayload; + } else { return undefined; } @@ -34,9 +47,6 @@ export function getTransactionCounterparty( // payload function is "0x1::aptos_account::transfer" or "0x1::aptos_account::transfer_coins" // In both scenarios, the first item in arguments is the receiver's address, and the second item is the amount. - const payload = - transaction.payload as Types.TransactionPayload_EntryFunctionPayload; - const isCoinTransfer = payload.function === "0x1::coin::transfer" || payload.function === "0x1::aptos_account::transfer_coins" || @@ -236,28 +246,28 @@ export interface FungibleAssetActivity { export function useTransactionBalanceChanges(txn_version: string) { const {loading, error, data} = useGraphqlQuery( gql` - query TransactionQuery($txn_version: String) { - fungible_asset_activities( - where: {transaction_version: {_eq: ${txn_version}}} - ) { - amount - entry_function_id_str - gas_fee_payer_address - is_frozen - asset_type - event_index - owner_address - transaction_timestamp - transaction_version - type - storage_refund_amount - metadata { - asset_type - decimals - symbol - } + query TransactionQuery($txn_version: String) { + fungible_asset_activities( + where: {transaction_version: {_eq: ${txn_version}}} + ) { + amount + entry_function_id_str + gas_fee_payer_address + is_frozen + asset_type + event_index + owner_address + transaction_timestamp + transaction_version + type + storage_refund_amount + metadata { + asset_type + decimals + symbol + } + } } - } `, {variables: {txn_version}}, );