diff --git a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx index c499c415..5d97f5da 100644 --- a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx +++ b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx @@ -1,5 +1,5 @@ import { Meta } from '@storybook/react'; -import { Transaction } from 'types'; +import { Transaction, TransactionStatus } from 'types'; import { TransactionListItemView } from './TransactionListItem.view'; export default { @@ -12,18 +12,30 @@ const transaction: Transaction = { txnType: 'invoke', chainId: '0x534e5f5345504f4c4941', senderAddress: - '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', + '0x5ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', - '0x0de0b6b3a7640000', - ], - timestamp: 1655705597, - status: 'Accepted on L1', - eventIds: ['245417_20_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.RECEIVED, failureReason: '', + timestamp: 1655869759, + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', + '0x0de0b6b3a7640000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }; export const FullWidth = () => ( diff --git a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.view.tsx b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.view.tsx index 7cafbdb1..ccaac53b 100644 --- a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.view.tsx +++ b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.view.tsx @@ -21,7 +21,6 @@ import { getTxnFailureReason, getTxnName, getTxnStatus, - getTxnToFromLabel, getTxnValues, } from './types'; import { getHumanReadableAmount, openExplorerTab } from 'utils/utils'; @@ -32,15 +31,17 @@ interface Props { export const TransactionListItemView = ({ transaction }: Props) => { const wallet = useAppSelector((state) => state.wallet); + const tokenAddress = wallet.erc20TokenBalanceSelected.address; const [currencySymbol, setCurrencySymbol] = useState('N/A'); const [txnValue, setTxnValue] = useState('0'); const [txnUsdValue, setTxnUsdValue] = useState('0.00'); useEffect(() => { const fetchData = async () => { + // Find the matching token const foundToken = wallet.erc20TokenBalances.find((token) => ethers.BigNumber.from(token.address).eq( - ethers.BigNumber.from(transaction.contractAddress), + ethers.BigNumber.from(tokenAddress), ), ); if (foundToken) { @@ -48,6 +49,7 @@ export const TransactionListItemView = ({ transaction }: Props) => { transaction, foundToken.decimals, foundToken.usdPrice, + tokenAddress, ); setTxnValue(getHumanReadableAmount(foundToken, txnValues.txnValue)); setTxnUsdValue(txnValues.txnUsdValue); @@ -58,10 +60,10 @@ export const TransactionListItemView = ({ transaction }: Props) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const txnName = getTxnName(transaction); + const txnName = getTxnName(transaction, tokenAddress); const txnDate = getTxnDate(transaction); const txnStatus = getTxnStatus(transaction); - const txnToFromLabel = getTxnToFromLabel(transaction); + const txnToFromLabel = ''; const txnFailureReason = getTxnFailureReason(transaction); return ( { @@ -17,23 +20,38 @@ export const getIcon = (transactionName: string): IconProp => { } }; -export const getTxnName = (transaction: Transaction): string => { - if (transaction.txnType.toLowerCase() === VoyagerTransactionType.INVOKE) { - if (transaction.contractFuncName.toLowerCase() === 'transfer') { - return 'Send'; - } else if (transaction.contractFuncName.toLowerCase() === 'upgrade') { - return 'Upgrade Account'; - } - } else if ( - transaction.txnType.toLowerCase() === VoyagerTransactionType.DEPLOY - ) { - return 'Deploy'; - } else if ( - transaction.txnType.toLowerCase() === VoyagerTransactionType.DEPLOY_ACCOUNT - ) { - return 'Deploy Account'; +export const getTxnName = ( + transaction: Transaction, + contractAddress: string, +): string => { + switch (transaction.txnType) { + case StarkscanTransactionType.INVOKE: + if ( + transaction.accountCalls && + transaction.accountCalls[contractAddress] + ) { + if ( + transaction.accountCalls[contractAddress].some( + (call) => call.contractFuncName === 'transfer', + ) + ) { + return 'Send'; + } else if ( + transaction.accountCalls[contractAddress].some( + (call) => call.contractFuncName === 'upgrade', + ) + ) { + return 'Upgrade Account'; + } + } + return 'Contract Interaction'; + case StarkscanTransactionType.DEPLOY: + return 'Depoly'; + case StarkscanTransactionType.DEPLOY_ACCOUNT: + return 'Deploy Account'; + default: + return 'Unknown'; } - return 'Unknown'; }; export const getTxnDate = (transaction: Transaction): string => { @@ -50,6 +68,9 @@ export const getTxnDate = (transaction: Transaction): string => { export const getTxnStatus = (transaction: Transaction): string => { let statusStr = []; + if (transaction.executionStatus) { + statusStr.push(formatStatus(transaction.executionStatus)); + } if (transaction.finalityStatus === transaction.executionStatus) { return transaction.finalityStatus ? formatStatus(transaction.finalityStatus) @@ -58,9 +79,6 @@ export const getTxnStatus = (transaction: Transaction): string => { if (transaction.finalityStatus) { statusStr.push(formatStatus(transaction.finalityStatus)); } - if (transaction.executionStatus) { - statusStr.push(formatStatus(transaction.executionStatus)); - } return statusStr.join(' / '); }; @@ -78,29 +96,6 @@ export const formatStatus = (status: string): string => { .join(' '); }; -export const getTxnToFromLabel = (transaction: Transaction): string => { - const txnName = getTxnName(transaction); - switch (txnName) { - case 'Send': - // TODO : This will not be needed after getTransactions revamp. - if (transaction.contractCallData.length === 3) { - return ( - 'To ' + shortenAddress(transaction.contractCallData[0].toString()) - ); - } else { - return ( - 'To ' + shortenAddress(transaction.contractCallData[4].toString()) - ); - } - case 'Receive': - return 'From ' + shortenAddress(transaction.senderAddress); - case 'Deploy': - return 'To ' + shortenAddress(transaction.contractAddress); - default: - return ''; - } -}; - export const getTxnFailureReason = (transaction: Transaction): string => { return transaction.executionStatus && transaction.executionStatus.toLowerCase() === @@ -114,24 +109,25 @@ export const getTxnValues = ( transaction: Transaction, decimals: number = 18, toUsdRate: number = 0, + tokenAddress: string, ) => { let txnValue = '0'; let txnUsdValue = '0'; + if (transaction.accountCalls && transaction.accountCalls[tokenAddress]) { + txnValue = ethers.utils.formatUnits( + transaction.accountCalls[tokenAddress] + .filter((call) => call.contractFuncName === 'transfer') // Filter for "transfer" calls + .reduce((acc, call) => { + // Extract the BigInt value from contractCallData + const value = BigInt( + call.contractCallData[call.contractCallData.length - 2].toString(), + ); + return acc + value; // Sum the BigInt values + }, BigInt(0)), + decimals, + ); // Start with BigInt(0) as the initial value - const txnName = getTxnName(transaction); - switch (txnName) { - case 'Send': - case 'Receive': - txnValue = ethers.utils.formatUnits( - transaction.contractCallData[ - transaction.contractCallData.length - 2 - ].toString(), - decimals, - ); - txnUsdValue = (parseFloat(txnValue) * toUsdRate).toFixed(2); - break; - default: - break; + txnUsdValue = (parseFloat(txnValue) * toUsdRate).toFixed(2); } return { txnValue, txnUsdValue }; diff --git a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx index e0efc285..263f296f 100644 --- a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx +++ b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx @@ -1,5 +1,5 @@ import { Meta } from '@storybook/react'; -import { Transaction } from 'types'; +import { Transaction, TransactionStatus } from 'types'; import { TransactionsListView } from './TransactionsList.view'; export default { @@ -17,16 +17,27 @@ const transactions: Transaction[] = [ '0x5ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', - '0x38d7ea4c68000', - '0x0', - ], - status: 'RECEIVED', + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.RECEIVED, failureReason: '', - eventIds: [], timestamp: 1655869759, + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', + '0x0de0b6b3a7640000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: @@ -37,15 +48,27 @@ const transactions: Transaction[] = [ '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', - '0x0de0b6b3a7640000', - ], timestamp: 1655705597, - status: 'Accepted on L2', - eventIds: ['245417_20_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.ACCEPTED_ON_L2, failureReason: '', + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', + '0x0de0b6b3a7640000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: @@ -56,17 +79,28 @@ const transactions: Transaction[] = [ '0x5ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', - '0xde0b6b3a7640000', - '0x0', - ], - status: 'REJECTED', + executionStatus: TransactionStatus.REJECTED, + finalityStatus: TransactionStatus.NOT_RECEIVED, failureReason: 'Actual fee exceeded max fee.\n13056675060932 > 9585012591398', - eventIds: [], timestamp: 1655695493, + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x6b686ebe2cbd70b37b54df1b9889cc3095b55f386110843912efcaed416ff3f', + '0x0de0b6b3a7640000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: @@ -77,15 +111,27 @@ const transactions: Transaction[] = [ '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x14361d05e560796ad3152e083b609f5205f3bd76039327326746ba7f769a666', - '0x0de0b6b3a7640000', - ], timestamp: 1654745214, - status: 'Accepted on L1', - eventIds: ['233927_16_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.ACCEPTED_ON_L1, failureReason: '', + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x14361d05e560796ad3152e083b609f5205f3bd76039327326746ba7f769a666', + '0x0de0b6b3a7640000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: @@ -96,15 +142,27 @@ const transactions: Transaction[] = [ '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x14361d05e560796ad3152e083b609f5205f3bd76039327326746ba7f769a666', - '0x0de0b6b3a7640000', - ], timestamp: 1654708040, - status: 'Accepted on L1', - eventIds: ['233510_7_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.ACCEPTED_ON_L1, failureReason: '', + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x14361d05e560796ad3152e083b609f5205f3bd76039327326746ba7f769a666', + '0x0de0b6b3a7640000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: @@ -115,15 +173,27 @@ const transactions: Transaction[] = [ '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x14361d05e560796ad3152e083b609f5205f3bd76039327326746ba7f769a666', - '0x1bc16d674ec80000', - ], timestamp: 1654701586, - status: 'Accepted on L1', - eventIds: ['233442_14_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.ACCEPTED_ON_L1, failureReason: '', + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x14361d05e560796ad3152e083b609f5205f3bd76039327326746ba7f769a666', + '0x1bc16d674ec80000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: '0x81fab4268648483028b9be3353d6551ca35041fb2a03c2f372b19f3ab109b1', @@ -133,15 +203,27 @@ const transactions: Transaction[] = [ '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', - '0x0de0b6b3a7640000', - ], timestamp: 1654678571, - status: 'Accepted on L1', - eventIds: ['233196_29_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.ACCEPTED_ON_L1, failureReason: '', + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', + '0x0de0b6b3a7640000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: @@ -152,15 +234,27 @@ const transactions: Transaction[] = [ '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: 'transfer', - contractCallData: [ - '0x256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', - '0x3782dace9d900000', - ], timestamp: 1654670913, - status: 'Accepted on L1', - eventIds: ['233116_23_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.ACCEPTED_ON_L1, failureReason: '', + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: 'transfer', + contractCallData: [ + '0x256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', + '0x3782dace9d900000', + ], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, { txnHash: @@ -171,12 +265,24 @@ const transactions: Transaction[] = [ '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - contractFuncName: '', - contractCallData: [], timestamp: 1654662459, - status: 'Accepted on L1', - eventIds: ['233027_3_0'], + executionStatus: TransactionStatus.SUCCEEDED, + finalityStatus: TransactionStatus.ACCEPTED_ON_L1, failureReason: '', + accountCalls: { + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': [ + { + contract: + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + contractFuncName: '', + contractCallData: [], + }, + ], + }, + maxFee: null, + actualFee: null, + version: 1, + dataVersion: '2', }, ]; diff --git a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.view.tsx b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.view.tsx index bbb68d0d..efa01a26 100644 --- a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.view.tsx +++ b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.view.tsx @@ -28,7 +28,6 @@ export const TransactionsListView = ({ transactions }: Props) => { address, wallet.erc20TokenBalanceSelected.address, 10, - 10, chain, false, true, @@ -50,7 +49,6 @@ export const TransactionsListView = ({ transactions }: Props) => { address, wallet.erc20TokenBalanceSelected.address, 10, - 10, chain, ); } diff --git a/packages/wallet-ui/src/components/ui/organism/Header/SendSummaryModal/SendSummaryModal.view.tsx b/packages/wallet-ui/src/components/ui/organism/Header/SendSummaryModal/SendSummaryModal.view.tsx index 8428a122..7423701e 100644 --- a/packages/wallet-ui/src/components/ui/organism/Header/SendSummaryModal/SendSummaryModal.view.tsx +++ b/packages/wallet-ui/src/components/ui/organism/Header/SendSummaryModal/SendSummaryModal.view.tsx @@ -197,7 +197,6 @@ export const SendSummaryModalView = ({ wallet.accounts[0] as unknown as string, wallet.erc20TokenBalanceSelected.address, 10, - 10, chainId, false, true, diff --git a/packages/wallet-ui/src/services/useStarkNetSnap.ts b/packages/wallet-ui/src/services/useStarkNetSnap.ts index 53c3405b..ef0a13a7 100644 --- a/packages/wallet-ui/src/services/useStarkNetSnap.ts +++ b/packages/wallet-ui/src/services/useStarkNetSnap.ts @@ -23,7 +23,7 @@ import { getTokenBalanceWithDetails, } from '../utils/utils'; import { setWalletConnection } from '../slices/walletSlice'; -import { Network, VoyagerTransactionType } from '../types'; +import { Network, StarkscanTransactionType } from '../types'; import { Account } from '../types'; import { Erc20TokenBalance, Erc20Token } from '../types'; import { disableLoading, enableLoadingWithMessage } from '../slices/UISlice'; @@ -539,7 +539,6 @@ export const useStarkNetSnap = () => { const getTransactions = async ( senderAddress: string, contractAddress: string, - pageSize: number, txnsInLastNumOfDays: number, chainId: string, showLoading: boolean = true, @@ -560,10 +559,7 @@ export const useStarkNetSnap = () => { ...defaultParam, senderAddress, contractAddress, - pageSize, txnsInLastNumOfDays, - onlyFromState, - withDeployTxn: true, chainId, }, }, @@ -590,8 +586,8 @@ export const useStarkNetSnap = () => { //Set the deploy transaction const deployTransaction = storedTxns.find( (txn: Transaction) => - txn.txnType.toLowerCase() === VoyagerTransactionType.DEPLOY || - txn.txnType.toLowerCase() === VoyagerTransactionType.DEPLOY_ACCOUNT, + txn.txnType.toLowerCase() === StarkscanTransactionType.DEPLOY || + txn.txnType.toLowerCase() === StarkscanTransactionType.DEPLOY_ACCOUNT, ); dispatch(setTransactionDeploy(deployTransaction)); diff --git a/packages/wallet-ui/src/types/index.ts b/packages/wallet-ui/src/types/index.ts index d6c064a8..937e05ad 100644 --- a/packages/wallet-ui/src/types/index.ts +++ b/packages/wallet-ui/src/types/index.ts @@ -1,19 +1,30 @@ import { BigNumber } from 'ethers'; +type AccountCall = { + contract: string; // HexStruct resolves to a string in this context + contractFuncName: string; + contractCallData: string[]; + recipient?: string; + amount?: string; +}; + +type AccountCalls = Record | null; + export type Transaction = { txnHash: string; // in hex txnType: string; chainId: string; // in hex senderAddress: string; // in hex contractAddress: string; // in hex - contractFuncName: string; - contractCallData: string[] | number[]; - status?: TransactionStatus | string; - executionStatus?: TransactionStatus | string; - finalityStatus?: TransactionStatus | string; + executionStatus: TransactionStatus | string; + finalityStatus: TransactionStatus | string; failureReason: string; - eventIds: string[]; + actualFee: string | null; + maxFee: string | null; timestamp: number; + accountCalls: AccountCalls; + version: number; + dataVersion: string; }; export type Account = { @@ -48,19 +59,20 @@ export type TransactionStatusOptions = | 'Rejected' | 'Not Received'; -export enum VoyagerTransactionType { // for retrieving txns from Voyager - DEPLOY = 'deploy', - DEPLOY_ACCOUNT = 'deploy_account', - INVOKE = 'invoke', +export enum StarkscanTransactionType { + DEPLOY = 'DEPLOY', + DEPLOY_ACCOUNT = 'DEPLOY_ACCOUNT', + INVOKE = 'INVOKE_FUNCTION', } export enum TransactionStatus { // for retrieving txn from Starknet feeder gateway + NOT_RECEIVED = 'NOT_RECEIVED', RECEIVED = 'RECEIVED', - PENDING = 'PENDING', ACCEPTED_ON_L2 = 'ACCEPTED_ON_L2', ACCEPTED_ON_L1 = 'ACCEPTED_ON_L1', - NOT_RECEIVED = 'NOT_RECEIVED', REJECTED = 'REJECTED', + REVERTED = 'REVERTED', + SUCCEEDED = 'SUCCEEDED', } export enum BalanceType { diff --git a/packages/wallet-ui/src/utils/constants.ts b/packages/wallet-ui/src/utils/constants.ts index 76d33c55..737fe69d 100644 --- a/packages/wallet-ui/src/utils/constants.ts +++ b/packages/wallet-ui/src/utils/constants.ts @@ -39,10 +39,10 @@ export const DECIMALS_DISPLAYED_MAX_LENGTH = 11; export const COINGECKO_API = 'https://api.coingecko.com/api/v3/'; -export const STARKNET_MAINNET_EXPLORER = 'https://voyager.online/'; +export const STARKNET_MAINNET_EXPLORER = 'https://starkscan.co/'; export const STARKNET_SEPOLIA_TESTNET_EXPLORER = - 'https://sepolia.voyager.online/'; + 'https://sepolia.starkscan.co/'; export const SNAPS_DOC_URL = 'https://docs.metamask.io/guide/snaps.html';