-
Notifications
You must be signed in to change notification settings - Fork 0
feat(sui-indexer): add Ika coordinator event polling for signature completion tracking #301
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f846e0c
feat(sui-indexer): add Ika coordinator event polling for signature co…
Rcc999 4e58f58
Migration file to add coordinator_pckg column
Rcc999 9bdcf49
Resolved comments
Rcc999 5cb0abc
Merge branch 'master' into rayane/ika-event-in-gql-query
Rcc999 76009bb
Resolved comments
Rcc999 445a82b
Merge branch 'master' into rayane/ika-event-in-gql-query
Rcc999 1fde767
Merge branch 'master' into rayane/ika-event-in-gql-query
Rcc999 83f43e5
Merge branch 'master' into rayane/ika-event-in-gql-query
Rcc999 7ba4c93
Merge branch 'master' into rayane/ika-event-in-gql-query
Rcc999 172e290
Merge branch 'master' into rayane/ika-event-in-gql-query
Rcc999 26c1d19
Merge branch 'master' into rayane/ika-event-in-gql-query
Rcc999 0a887a4
Resolved comments
Rcc999 7729b1c
Resolved prettier issue
Rcc999 4d55376
Resolved prettier issue
Rcc999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,11 @@ import { | |
| type SolvedEventRaw, | ||
| type SignatureRecordedEventRaw, | ||
| type SuiEventNode, | ||
| type IkaCompletedSignEventRaw, | ||
| type IkaRejectedSignEventRaw, | ||
| UtxoStatus, | ||
| } from "./models"; | ||
| import { logger } from "@gonative-cc/lib/logger"; | ||
| import { logError, logger } from "@gonative-cc/lib/logger"; | ||
| import { fromBase64 } from "@mysten/sui/utils"; | ||
|
|
||
| export class SuiEventHandler { | ||
|
|
@@ -105,4 +107,61 @@ export class SuiEventHandler { | |
| utxoId: e.utxo_id, | ||
| }); | ||
| } | ||
|
|
||
| public async handleIkaEvents(events: SuiEventNode[]) { | ||
| const results = await Promise.allSettled( | ||
| events.map((e) => { | ||
| if (e.type.includes("::coordinator_inner::CompletedSignEvent")) { | ||
| return this.handleCompletedSign(e); | ||
| } else if (e.type.includes("::coordinator_inner::RejectedSignEvent")) { | ||
| return this.handleRejectedSign(e); | ||
| } | ||
| return Promise.resolve(); | ||
| }), | ||
| ); | ||
|
|
||
| results.forEach((result, i) => { | ||
| if (result.status === "rejected") { | ||
| const e = events[i]; | ||
| logError( | ||
| { | ||
| msg: "Failed to handle Ika event", | ||
| method: "handleIkaEvents", | ||
| eventType: e?.type, | ||
| txDigest: e?.txDigest, | ||
| }, | ||
| result.reason, | ||
| ); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| private async handleCompletedSign(e: SuiEventNode) { | ||
| const data = e.json as IkaCompletedSignEventRaw; | ||
|
|
||
| logger.info({ | ||
| msg: "Ika signature completed", | ||
| sign_id: data.sign_id, | ||
| is_future_sign: data.is_future_sign, | ||
| signature_length: data.signature.length, | ||
| txDigest: e.txDigest, | ||
| setupId: this.setupId, | ||
| }); | ||
|
|
||
| // TODO: Call redeem_solver service binding to record signature | ||
| } | ||
|
|
||
| private async handleRejectedSign(e: SuiEventNode) { | ||
| const data = e.json as IkaRejectedSignEventRaw; | ||
|
|
||
| logger.warn({ | ||
| msg: "Ika signature rejected", | ||
| sign_id: data.sign_id, | ||
| is_future_sign: data.is_future_sign, | ||
| txDigest: e.txDigest, | ||
| setupId: this.setupId, | ||
| }); | ||
|
|
||
| // TODO: Call redeem_solver service binding to mark signature as rejected | ||
Rcc999 marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
lets add it here
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.
#313