Skip to content

Commit

Permalink
decode evm tx for approval
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrunk committed Jul 10, 2024
1 parent 924dc46 commit 0a23a08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/components/TransactionRequest/TransactionRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const TransactionRequest = (props: {
const [sendingAmount, setSendingAmount] = useState('');
const [receiverAddress, setReceiverAddress] = useState('');
const [senderAddress, setSenderAddress] = useState('');
const [token, setToken] = useState('');
const [fee, setFee] = useState('');
const [authenticationOpen, setAuthenticationOpen] = useState(false);
const blockchainConfig = blockchains[props.chain];
Expand Down Expand Up @@ -67,6 +68,7 @@ const TransactionRequest = (props: {
setSendingAmount(txInfo.amount);
setReceiverAddress(txInfo.receiver);
setSenderAddress(txInfo.sender);
setToken(txInfo.token || '');
if (props.utxos && props.utxos.length) {
setFee(txInfo.fee);
}
Expand Down Expand Up @@ -117,7 +119,16 @@ const TransactionRequest = (props: {
{t('home:sending')}
</Text>
<Text style={[Fonts.textSmall, Fonts.textBold, Fonts.textCenter]}>
{' ' + sendingAmount + ' ' + blockchainConfig.symbol + ' '}
{' ' +
sendingAmount +
' ' +
(token
? blockchainConfig.tokens.find(
(ttt) =>
ttt.contract.toLocaleLowerCase() === token.toLowerCase(),
)
: blockchainConfig.symbol) +
' '}
</Text>
<Text style={[Fonts.textSmall, Fonts.textCenter]}>
{t('home:to')}
Expand Down
10 changes: 9 additions & 1 deletion src/lib/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ interface output {
value: number;
}

interface tokenInfo {
sender: string;
receiver: string;
amount: string;
fee: string;
token?: string;
}

export function decodeTransactionForApproval(
rawTx: string,
chain: keyof cryptos,
utxos: utxo[],
) {
): tokenInfo {
try {
if (blockchains[chain].chainType === 'evm') {
return decodeEVMTransactionForApproval(rawTx, chain);
Expand Down

0 comments on commit 0a23a08

Please sign in to comment.