Skip to content

feat: token creation event#325

Merged
andreabadesso merged 35 commits intomasterfrom
feat/token-creation-event
Jan 9, 2026
Merged

feat: token creation event#325
andreabadesso merged 35 commits intomasterfrom
feat/token-creation-event

Conversation

@andreabadesso
Copy link
Copy Markdown
Collaborator

@andreabadesso andreabadesso commented Nov 28, 2025

Motivation

The fullnode now emits TOKEN_CREATED events when tokens are created, either via traditional CREATE_TOKEN_TX or nano contract syscalls. The daemon needs to handle these events to properly track token creation and manage token lifecycle during reorgs and voids.

Acceptance Criteria

  • Handle TOKEN_CREATED events and store token info in token table
  • Track token-to-transaction mappings in new token_creation table (one tx can create multiple tokens)
  • Delete nano-created tokens when nc_execution changes from success to non-success
  • Delete ALL tokens (both types) when transaction that created it is voided
  • Hybrid transactions (CREATE_TOKEN_TX + nano): preserve CREATE_TOKEN_TX token during reorg, delete only nano-created tokens

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged
  • Make sure either the unit tests and/or the QA tests are capable of testing the new features
  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@andreabadesso andreabadesso force-pushed the feat/token-creation-event branch from fb0788c to df6b3b2 Compare November 28, 2025 11:42
@andreabadesso andreabadesso force-pushed the feat/token-creation-event branch from 027d3e0 to 1eac864 Compare November 28, 2025 14:42
@andreabadesso andreabadesso self-assigned this Nov 28, 2025
@andreabadesso andreabadesso added the enhancement New feature or request label Nov 28, 2025
@andreabadesso andreabadesso moved this to In Progress (WIP) in Hathor Network Nov 28, 2025
Comment on lines -287 to -293
if (version === hathorLib.constants.CREATE_TOKEN_TX_VERSION) {
if (!token_name || !token_symbol) {
throw new Error('Processed a token creation event but it did not come with token name and symbol');
}
await storeTokenInformation(mysql, hash, token_name, token_symbol);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now done in the TOKEN_CREATED event handling

await handleVertexAccepted(context as any, {} as any);

expect(storeTokenInformation).toHaveBeenCalledWith(mockDb, hash, tokenName, tokenSymbol);
expect(storeTokenInformation).not.toHaveBeenCalled();
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only insert to the token info table when the TOKEN_CREATED event is received

@andreabadesso andreabadesso moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Dec 9, 2025
@andreabadesso andreabadesso requested review from pedroferreira1 and r4mmer and removed request for pedroferreira1 December 9, 2025 21:15
@andreabadesso andreabadesso force-pushed the feat/token-creation-event branch 2 times, most recently from 9f6dcb0 to 2122958 Compare December 16, 2025 19:20
@andreabadesso andreabadesso force-pushed the feat/token-creation-event branch from 2122958 to 2a873a8 Compare December 16, 2025 19:47
@andreabadesso andreabadesso force-pushed the feat/token-creation-event branch from deb88f6 to 611f4d3 Compare December 17, 2025 11:48
export const REORG_SCENARIO_PORT = 8082;
// Same as the comment on the unvoided scenario last event
export const REORG_SCENARIO_LAST_EVENT = 19;
export const REORG_SCENARIO_LAST_EVENT = 18;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to this PR, but the simulator events changed for the reorg scenario

});
});

describe('Error handling', () => {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests come from #332, I cherry-picked the commit there

@andreabadesso andreabadesso force-pushed the feat/token-creation-event branch from 6240c55 to 764474d Compare December 17, 2025 13:36
@andreabadesso andreabadesso moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Jan 8, 2026
@github-project-automation github-project-automation Bot moved this from In Progress (Done) to In Review (WIP) in Hathor Network Jan 9, 2026
@andreabadesso andreabadesso merged commit b097ecc into master Jan 9, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Jan 9, 2026
@andreabadesso andreabadesso deleted the feat/token-creation-event branch January 9, 2026 15:42
@andreabadesso andreabadesso mentioned this pull request Jan 28, 2026
2 tasks
@andreabadesso andreabadesso moved this from Waiting to be deployed to Done in Hathor Network Jan 28, 2026
This was referenced Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants