Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Implement Starknet event parsers #54 #57

Open
Cevedale opened this issue Jan 8, 2024 · 5 comments
Open

FEAT: Implement Starknet event parsers #54 #57

Cevedale opened this issue Jan 8, 2024 · 5 comments

Comments

@Cevedale
Copy link

Cevedale commented Jan 8, 2024

Hey!
You may need to adapt it based on your specific needs and the details of the Starknet API:

// src/starknet/parser.ts

class Contract {
private address: string;
private abi: any; // replace 'any' with the actual type of ABI

constructor({ address, abi }: { address: string, abi: any }) {
this.address = address;
this.abi = abi;
}

eventFilter(eventName: string): any {
// Implement your logic to generate the DNA filter based on the event name
// This is just a placeholder, replace it with the actual logic
const filter = {
fromAddress: "...",
// ... other filter properties
};
return filter;
}

eventParser(eventData: any): any {
// Implement your logic to parse the event data into TypeScript objects
// This is just a placeholder, replace it with the actual logic
const parsedData = {
// ... parsed data properties
};
return parsedData;
}
}

export default Contract;

test file:
// packages/indexer/test/parser.test.ts

import Contract from '../src/starknet/parser';

describe('eventFilter', () => {
it('returns the DNA filter', () => {
const contract = new Contract({ address: 'your_contract_address', abi: {} /* your ABI here */ });
const filter = contract.eventFilter('Transfer');
expect(filter).toMatchInlineSnapshot({ fromAddress: "...", ... });
});
});

describe('eventParser', () => {
it('parses event data into TypeScript objects', () => {
const contract = new Contract({ address: 'your_contract_address', abi: {} /* your ABI here / });
const parsedData = contract.eventParser({/ your sample event data here /});
expect(parsedData).toMatchInlineSnapshot({ /
expected parsed data structure */ });
});
});

Replace 'your_contract_address', {} /* your ABI here */, and other placeholders with the actual values and data structures based on your Starknet contract and ABI.

This is a basic starting point, and you may need to adjust it based on the actual structure of Starknet events and contracts.

@EjembiEmmanuel
Copy link

@Cevedale is this still open for contribution?

@Sravya-212
Copy link

@Cevedale I would like to work on this

@fracek
Copy link
Contributor

fracek commented Sep 11, 2024

Yes this one is available! Can you join the Apibara @ OD Hack telegram group to discuss it?

@Sravya-212
Copy link

@fracek I am already in the @od hackers community

@fracek
Copy link
Contributor

fracek commented Sep 11, 2024

Cool, feel free to dm me there and I'll get you up to speed on the task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants