feat(transaction): default generation to unix millis, allow override#71
Merged
Conversation
Reverts the micros default from #65 and instead defaults to unix milliseconds (giving a ~5s deduplication window with the sequencer's 5000-generation window). Both `UnsignedTransaction::builder()` and `Transaction::builder()` now accept an optional `generation: u64` for callers that need a different value (e.g. micros, a counter, or a fixed value for tests). The WASM builder exposes the same via `.generation(bigint)`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="wasm/README.md">
<violation number="1" location="wasm/README.md:119">
P2: The example is missing `await` before the builder chain, so `tx` is a `Promise` instead of the resolved result from `send(client)`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| value — for example a microsecond timestamp for a ~5ms window: | ||
|
|
||
| ```typescript | ||
| const tx = Transaction.builder() |
Contributor
There was a problem hiding this comment.
P2: The example is missing await before the builder chain, so tx is a Promise instead of the resolved result from send(client).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wasm/README.md, line 119:
<comment>The example is missing `await` before the builder chain, so `tx` is a `Promise` instead of the resolved result from `send(client)`.</comment>
<file context>
@@ -111,6 +111,18 @@ const tx = Transaction.builder()
+value — for example a microsecond timestamp for a ~5ms window:
+
+```typescript
+const tx = Transaction.builder()
+ .callMessage(msg)
+ .generation(BigInt(Date.now()) * 1000n) // microseconds
</file context>
Suggested change
| const tx = Transaction.builder() | |
| const response = await Transaction.builder() |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
UnsignedTransaction::builder()andTransaction::builder()accept an optionalgeneration: u64— omit it for the millis default, or pass any value (micros, a counter, a fixed test value).generation(bigint)Rationale
With a 5000-generation window, microseconds gives a ~5ms deduplication window (too tight); milliseconds gives ~5s (practical). If the sequencer ever requires micros again, callers can pass
duration.as_micros() as u64/BigInt(Date.now()) * 1000nexplicitly.Test plan
just check/just lint/just test(72/72 pass)🤖 Generated with Claude Code
Summary by cubic
Default uniqueness generation now uses unix milliseconds, giving a ~5s deduplication window with the sequencer’s 5000-generation window. Added an optional override so callers can supply any generation value when needed.
UnsignedTransaction::builder()andTransaction::builder()acceptgeneration: u64(optional). Omit to use current unix ms..generation(bigint)to override the default. README updated with an example.Written for commit 5cedebd. Summary will update on new commits.