Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
luu-alex committed Oct 11, 2023
1 parent 085accc commit 5f23704
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/web3-eth-contract/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,15 @@ export class Contract<Abi extends ContractAbi>
options ?? {},
);
const logs = await getLogs(this, { fromBlock, toBlock, topics, address }, returnFormat);
// eslint-disable-next-line
console.log(logs)
const decodedLogs = logs.map(log =>
typeof log === 'string'
? log
: decodeEventABI(abi, log as LogsInput, this._jsonInterface, returnFormat),
);
// eslint-disable-next-line
console.log(decodedLogs)

const filter = options?.filter ?? {};
const filterKeys = Object.keys(filter);
Expand Down
2 changes: 2 additions & 0 deletions packages/web3-eth/src/utils/decoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const decodeEventABI = (
const result = format(logSchema, data, returnFormat);
// eslint-disable-next-line
console.log(result)
// eslint-disable-next-line
console.log(event)
// if allEvents get the right event
if ([ALL_EVENTS, 'allEvents'].includes(modifiedEvent.name)) {
const matchedEvent = jsonInterface.find(j => j.signature === data.topics[0]);
Expand Down
62 changes: 62 additions & 0 deletions packages/web3-eth/test/unit/decoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,67 @@ describe('decoding functions', () => {
},
);
});
// describe.only('decodeEventABI test', () => {
// const inputs :LogsInput = {

// address: '0x96944673f4314c7c6dfb719ecf86d68cce9dc393',

// topics: [

// '0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31',

// '0x000000000000000000000000af853ff16d40f011a9b153a664ac5cea2f3f1a93',

// '0x0000000000000000000000006855e2abfb524687cb19e3cf2f33b25bf38223cc'

// ],

// data: '0x0000000000000000000000000000000000000000000000000000000000000000',

// blockNumber: "229",

// transactionHash: '0x1e53f2432335b7ae65b9b194ffc04531dbd82a400000ce11be59dd6116a110af',

// transactionIndex: "0",

// blockHash: '0xc543b8156a1fcbc2f7e3049903ef4f19785bf81b3ca299a4f5a10a660d93499b',

// logIndex: "0"

// };
// const event = {
// anonymous: false,
// inputs: [
// {
// indexed: true,
// internalType: 'address',
// name: 'from',
// type: 'address'
// },
// {
// indexed: true,
// internalType: 'address',
// name: 'to',
// type: 'address'
// },
// {
// indexed: true,
// internalType: 'uint256',
// name: 'tokenId',
// type: 'uint256'
// }
// ],
// name: 'Transfer',
// type: 'event',
// signature: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
// };

// console.log(decodeEventABI(event, inputs, [
// { signature: event.signature } as unknown as AbiEventFragment & {
// signature: string;
// },
// ])
// )
// });
});
});

0 comments on commit 5f23704

Please sign in to comment.