Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrunk committed Nov 15, 2024
1 parent 35988fb commit af870d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/services/blockchains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ const sepolia = {
symbol: 'TEST-ETH',
decimals: 18,
},
{
contract: '0x690cc0235aBEA2cF89213E30D0F0Ea0fC054B909',
name: 'Fake Flux',
symbol: 'TEST-FLUX',
decimals: 8,
},
// {
// contract: '0x690cc0235aBEA2cF89213E30D0F0Ea0fC054B909',
// name: 'Fake Flux',
// symbol: 'TEST-FLUX',
// decimals: 8,
// },
],
};

Expand Down
3 changes: 2 additions & 1 deletion src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ admin.initializeApp({
interface decodedTx {
amount: string;
receiver: string;
tokenSymbol?: string;
token?: string;
sender?: string;
fee?: string;
Expand All @@ -33,7 +34,7 @@ async function sendNotificationKey(wkIdentity, data) {
data.payload,
data.chain,
);
body = `A transaction of ${decodedTransaction.amount} ${decodedTransaction.token ? blockchains[data.chain].tokens.find((ttt) => ttt.contract.toLowerCase() === decodedTransaction.token.toLowerCase()).symbol : blockchains[data.chain].symbol} to ${decodedTransaction.receiver} has been initiated on your wallet.`;
body = `A transaction of ${decodedTransaction.amount} ${decodedTransaction.token ? decodedTransaction.tokenSymbol : blockchains[data.chain].symbol} to ${decodedTransaction.receiver} has been initiated on your wallet.`;
}
} catch (error) {
log.error(error);
Expand Down
7 changes: 7 additions & 0 deletions src/services/transactionDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ async function decodeEVMTransactionForApproval(rawTx, chain = 'eth') {
amount,
fee: totalFeeWei.toFixed(),
token: '',
tokenSymbol: '',
};

if (amount === '0') {
Expand All @@ -92,6 +93,7 @@ async function decodeEVMTransactionForApproval(rawTx, chain = 'eth') {

if (token) {
decimals = token.decimals;
txInfo.tokenSymbol = token.symbol;
}
const contractData = decodedData.args[2];
// most likely we are dealing with a contract call, sending some erc20 token
Expand All @@ -112,6 +114,8 @@ async function decodeEVMTransactionForApproval(rawTx, chain = 'eth') {
.dividedBy(new BigNumber(10 ** decimals))
.toFixed();
}
} else {
txInfo.tokenSymbol = blockchains[chain].symbol;
}

return txInfo;
Expand All @@ -123,6 +127,7 @@ async function decodeEVMTransactionForApproval(rawTx, chain = 'eth') {
amount: 'decodingError',
fee: 'decodingError',
token: 'decodingError',
tokenSymbol: 'decodingError',
};
return txInfo;
}
Expand Down Expand Up @@ -202,13 +207,15 @@ async function decodeTransactionForApproval(rawTx, chain = 'btc') {
const txInfo = {
receiver: txReceiver,
amount,
tokenSymbol: blockchains[chain].symbol,
};
return txInfo;
} catch (error) {
log.error(error);
return {
receiver: 'decodingError',
amount: 'decodingError',
tokenSymbol: 'decodingError',
};
}
}
Expand Down

0 comments on commit af870d6

Please sign in to comment.