-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add getEventsByCreationNumber #37
Conversation
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
src/internal/event.ts
Outdated
const { aptosConfig, address, creationNumber } = args; | ||
const graphqlQuery = { | ||
query: GetEventsByCreationNumber, | ||
variables: { address, creationNumber }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variables: { address, creationNumber }, | |
variables: { Hex.fromHexInput({ hexInput: address }).toString(), creationNumber }, |
maybe add some input validation? oof I hate the object as params for this method....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@@ -0,0 +1,12 @@ | |||
query getEventsByCreationNumber($address: String, $creationNumber: bigint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are going to do getEventsByEventHandle and getEvents, so prob want to switch this to passing in a where condition - same comment @0xmaayan made in #15 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That make sense!
tests/e2e/api/event.test.ts
Outdated
test("it should get fund events by creation number and address", async () => { | ||
const config = new AptosConfig({ network: Network.TESTNET }); | ||
const aptos = new Aptos(config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to be consistent here and use LOCAL
40ccc2e
to
adab170
Compare
Update:
|
adab170
to
2a73e81
Compare
Update 2 Renamed from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the upstream branch to main and get this in?
Have we tested it out and it works?
@gregnazario Yep the whole stack is e2e tested and it works. Is there any concern if I merge this in as a stack? (Including the previous PR in the stack) |
export async function getEventsByCreationNumber(args: { | ||
aptosConfig: AptosConfig; | ||
address: HexInput; | ||
creationNumber: AnyNumber; | ||
}): Promise<GetEventsResponse> { | ||
const { aptosConfig, creationNumber } = args; | ||
const address = AccountAddress.fromHexInput({ input: args.address }).toString(); | ||
|
||
const whereCondition: any = { | ||
account_address: { _eq: address }, | ||
creation_number: { _eq: creationNumber }, | ||
}; | ||
|
||
const graphqlQuery = { | ||
query: GetEvents, | ||
variables: { where_condition: whereCondition }, | ||
}; | ||
|
||
const data = await queryIndexer<GetEventsQuery>({ | ||
aptosConfig, | ||
query: graphqlQuery, | ||
originMethod: "getEventsByCreationNumber", | ||
}); | ||
|
||
return data.events; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's follow up with Events V2 support next
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh is Events v2 part of Alpha?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm lets skip
6ccc28e
to
e17670e
Compare
3b6c325
to
360d0d5
Compare
360d0d5
to
55dd6e8
Compare
Description
Test Plan
pnpm fmt
Related Links