feat: deploy and configure streams to allow 0 value#190
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request introduces explicit per-stream Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 36 minutes and 1 second.Comment |
Time Submission Status
You can submit time with the command. Example: See available commands to help comply with our Guidelines. |
|
@holdex pr submit-time 4h |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
core/contractsapi/allow_zeros_guard_test.go (1)
69-78: ⚡ Quick win
TestInsertMetadata_AllowsOtherKeysis currently vacuous.This only asserts constants differ, so it will still pass even if
insertMetadatastarts rejecting non-reserved keys. Please exercise the helper path and assert the failure (if any) is notErrReservedMetadataKey.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/contractsapi/allow_zeros_guard_test.go` around lines 69 - 78, Update TestInsertMetadata_AllowsOtherKeys to exercise the actual validation path instead of only comparing constants: for each key (types.ReadVisibilityKey, types.ComposeVisibilityKey, types.AllowReadWalletKey) call the same insertion/validation function used by production (e.g., insertMetadata or the test helper used elsewhere in this package) and assert that the returned error is either nil or, if non-nil, is not errors.Is(err, ErrReservedMetadataKey); keep the existing t.Run(name) structure and retain the require.NotEqual check if desired, but replace the vacuous assertion with the actual call and the error check against ErrReservedMetadataKey.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@core/contractsapi/batch_deploy_streams.go`:
- Around line 57-60: The code currently sets args = [][]any{{streamIds,
streamTypes, nil}} which still sends a third parameter (nil) and breaks callers
expecting a 2-arg signature; change the construction of args so when you want
the legacy 2-arg call you create a two-element inner slice (e.g.,
[]any{streamIds, streamTypes}) instead of including nil. Locate the
batch_deploy_streams.go logic that builds args (the variable named args and the
values streamIds and streamTypes) and branch so that you only append the third
element when metadata is present; otherwise build args entries with exactly two
elements to preserve compatibility with create_streams' 2-arg signature.
In `@core/contractsapi/deploy_stream.go`:
- Around line 25-29: The current call to input.KwilClient.Execute always passes
a third argument value for "create_stream", breaking legacy 2-argument behavior;
change the call in deploy_stream.go to conditionally build the args slice: if
input.AllowZeros is false, call input.KwilClient.Execute with args containing
only input.StreamId.String() and input.StreamType.String(); if input.AllowZeros
is true, include the third boolean value in the args. Modify the single
invocation of input.KwilClient.Execute to use a small conditional that
constructs [][]any with either two elements ({input.StreamId.String(),
input.StreamType.String()}) or three elements ({input.StreamId.String(),
input.StreamType.String(), input.AllowZeros}) so the 2-argument wire shape is
preserved when AllowZeros is false.
---
Nitpick comments:
In `@core/contractsapi/allow_zeros_guard_test.go`:
- Around line 69-78: Update TestInsertMetadata_AllowsOtherKeys to exercise the
actual validation path instead of only comparing constants: for each key
(types.ReadVisibilityKey, types.ComposeVisibilityKey, types.AllowReadWalletKey)
call the same insertion/validation function used by production (e.g.,
insertMetadata or the test helper used elsewhere in this package) and assert
that the returned error is either nil or, if non-nil, is not errors.Is(err,
ErrReservedMetadataKey); keep the existing t.Run(name) structure and retain the
require.NotEqual check if desired, but replace the vacuous assertion with the
actual call and the error check against ErrReservedMetadataKey.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 88fd4e35-57aa-4bb9-8c02-678e94f4f1c1
📒 Files selected for processing (12)
core/contractsapi/abstract_api.gocore/contractsapi/allow_zeros_guard_test.gocore/contractsapi/batch_deploy_streams.gocore/contractsapi/deploy_stream.gocore/contractsapi/stream_procedures.gocore/tnclient/actions_transport.gocore/tnclient/client.gocore/types/allow_zeros_test.gocore/types/contract_values.gocore/types/stream.gocore/types/stream_types.godocs/api-reference.md
resolves: https://github.com/truflation/website/issues/3757
Summary by CodeRabbit
New Features
allow_zerossetting to control zero-value persistence during inserts.SetAllowZerosandGetAllowZerosactions to manage the setting after stream creation.DeployStreamWithOptionsto configureallow_zerosat creation.Documentation
Tests