[Blockchain Watcher] (EVM and SOLANA) Map fee value for evm and solana (#1518)

* Map fee value for evm and solana

* Resolve test

---------

Co-authored-by: julian merlo <julianmerlo@julians-MacBook-Pro-2.local>
This commit is contained in:
Julian 2024-06-27 12:57:13 -03:00 committed by GitHub
parent 5eec936372
commit f9ff45d278
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 42 additions and 4 deletions

View File

@ -65,12 +65,14 @@ export function populateTransaction(
populatedTransactions: EvmTransaction[] populatedTransactions: EvmTransaction[]
) { ) {
filterTransactions.forEach((transaction) => { filterTransactions.forEach((transaction) => {
transaction.status = transactionReceipts[transaction.hash].status; transaction.effectiveGasPrice = transactionReceipts[transaction.hash].effectiveGasPrice;
transaction.gasUsed = transactionReceipts[transaction.hash].gasUsed;
transaction.timestamp = evmBlocks[transaction.blockHash].timestamp; transaction.timestamp = evmBlocks[transaction.blockHash].timestamp;
transaction.status = transactionReceipts[transaction.hash].status;
transaction.logs = transactionReceipts[transaction.hash].logs;
transaction.environment = opts.environment; transaction.environment = opts.environment;
transaction.chainId = opts.chainId; transaction.chainId = opts.chainId;
transaction.chain = opts.chain; transaction.chain = opts.chain;
transaction.logs = transactionReceipts[transaction.hash].logs;
populatedTransactions.push(transaction); populatedTransactions.push(transaction);
}); });
} }

View File

@ -59,6 +59,9 @@ export class PollSolanaTransactions extends RunPollingJob {
); );
return []; return [];
} }
this.logger.info(
`[get][exec] Processing blocks [fromSlot: ${range.fromSlot} - toSlot: ${range.toSlot}]`
);
let fromBlock = await this.findValidBlock(range.fromSlot, (slot) => slot + 1); let fromBlock = await this.findValidBlock(range.fromSlot, (slot) => slot + 1);
let toBlock = await this.findValidBlock(range.toSlot, (slot) => slot - 1); let toBlock = await this.findValidBlock(range.toSlot, (slot) => slot - 1);

View File

@ -84,6 +84,8 @@ export type EvmTransactionFoundAttributes = TransactionFoundAttributes & {
v: string; v: string;
value: string; value: string;
protocol: string; protocol: string;
gasUsed: string;
effectiveGasPrice: string;
}; };
export type InstructionFound = { export type InstructionFound = {
@ -93,6 +95,7 @@ export type InstructionFound = {
emitterAddress: string; emitterAddress: string;
sequence: number; sequence: number;
protocol: string; protocol: string;
fee: number | undefined;
}; };
export enum TxStatus { export enum TxStatus {

View File

@ -44,6 +44,8 @@ export type EvmTransaction = {
environment: string; environment: string;
chain: string; chain: string;
logs: EvmTransactionLog[]; logs: EvmTransactionLog[];
gasUsed: string;
effectiveGasPrice: string;
}; };
export type EvmTransactionLog = { address: string; topics: string[]; data: string }; export type EvmTransactionLog = { address: string; topics: string[]; data: string };
@ -61,4 +63,6 @@ export type ReceiptTransaction = {
status: string; status: string;
transactionHash: string; transactionHash: string;
logs: EvmTransactionLog[]; logs: EvmTransactionLog[];
gasUsed: string;
effectiveGasPrice: string;
}; };

View File

@ -8,6 +8,7 @@ export type Transaction = {
}; };
meta?: { meta?: {
innerInstructions?: CompiledInnerInstruction[] | null; innerInstructions?: CompiledInnerInstruction[] | null;
fee: number;
err?: {} | string | null; err?: {} | string | null;
}; };
blockTime?: number | null; blockTime?: number | null;

View File

@ -68,6 +68,8 @@ export const evmRedeemedTransactionFoundMapper = (
gasPrice: transaction.gasPrice, gasPrice: transaction.gasPrice,
maxFeePerGas: transaction.maxFeePerGas, maxFeePerGas: transaction.maxFeePerGas,
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas, maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
gasUsed: transaction.gasUsed,
effectiveGasPrice: transaction.effectiveGasPrice,
nonce: transaction.nonce, nonce: transaction.nonce,
r: transaction.r, r: transaction.r,
s: transaction.s, s: transaction.s,

View File

@ -92,6 +92,7 @@ const processProgram = async (
emitterAddress: emitterAddress.toString("hex"), emitterAddress: emitterAddress.toString("hex"),
sequence: Number(sequence), sequence: Number(sequence),
protocol: protocolType, protocol: protocolType,
fee: transaction.meta?.fee,
}, },
}); });
} }

View File

@ -304,8 +304,10 @@ export class EvmJsonRPCBlockRepository implements EvmBlockRepository {
.map((response) => { .map((response) => {
if (response.result?.status && response.result?.transactionHash) { if (response.result?.status && response.result?.transactionHash) {
return { return {
status: response.result.status, effectiveGasPrice: response.result.effectiveGasPrice,
transactionHash: response.result.transactionHash, transactionHash: response.result.transactionHash,
gasUsed: response.result.gasUsed,
status: response.result.status,
logs: response.result.logs, logs: response.result.logs,
}; };
} }

View File

@ -315,8 +315,10 @@ const givenEvmBlockRepository = (
.flat() .flat()
.reduce((acc, tx) => { .reduce((acc, tx) => {
acc[tx.hash] = { acc[tx.hash] = {
status: "0x1", effectiveGasPrice: tx.effectiveGasPrice,
transactionHash: tx.hash, transactionHash: tx.hash,
gasUsed: tx.gasUsed,
status: "0x1",
logs: tx.logs, logs: tx.logs,
}; };
return acc; return acc;
@ -453,6 +455,8 @@ class TxBuilder {
data: "0x0", data: "0x0",
}, },
], ],
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}; };
} }
} }

View File

@ -131,6 +131,8 @@ const givenEvmBlockRepository = (height?: bigint, blocksAhead?: bigint) => {
receiptResponse[`0x0${index}`] = { receiptResponse[`0x0${index}`] = {
status: "0x1", status: "0x1",
transactionHash: `0x0${index}`, transactionHash: `0x0${index}`,
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
logs: [ logs: [
{ {
address: "0xf890982f9310df57d00f659cf4fd87e65aded8d7", address: "0xf890982f9310df57d00f659cf4fd87e65aded8d7",

View File

@ -64,6 +64,8 @@ describe("evmRedeemedTransactionFoundMapper", () => {
data: "0x", data: "0x",
}, },
], ],
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}, },
]); ]);
@ -110,6 +112,8 @@ describe("evmRedeemedTransactionFoundMapper", () => {
data: "0x", data: "0x",
}, },
], ],
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}, },
]); ]);
@ -185,6 +189,8 @@ describe("evmRedeemedTransactionFoundMapper", () => {
data: "0x00000000000000000000000000000000000000000000000000470de4df820000", data: "0x00000000000000000000000000000000000000000000000000470de4df820000",
}, },
], ],
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}, },
]); ]);
@ -266,6 +272,8 @@ describe("evmRedeemedTransactionFoundMapper", () => {
timestamp: Date.now(), timestamp: Date.now(),
environment: "testnet", environment: "testnet",
chain: "arbitrum-sepolia", chain: "arbitrum-sepolia",
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}, },
]); ]);
@ -320,6 +328,8 @@ describe("evmRedeemedTransactionFoundMapper", () => {
data: "0x", data: "0x",
}, },
], ],
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}, },
]); ]);
@ -365,6 +375,8 @@ describe("evmRedeemedTransactionFoundMapper", () => {
data: "0x00000000000000000000000000000000000000000000000000000004b2cb597d", data: "0x00000000000000000000000000000000000000000000000000000004b2cb597d",
}, },
], ],
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}, },
]); ]);
@ -448,6 +460,8 @@ describe("evmRedeemedTransactionFoundMapper", () => {
], ],
}, },
], ],
gasUsed: "0x6efa0",
effectiveGasPrice: "0x2fb1471cd",
}, },
]); ]);