feat(sharding): put in agreement with styleguide and port code samples to Tolk#2131
feat(sharding): put in agreement with styleguide and port code samples to Tolk#2131
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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. Comment |
This comment has been minimized.
This comment has been minimized.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
| seqno: uint64, | ||
| todoChildCode: cell, | ||
| ): AutoDeployAddress { | ||
| val childStorage: TodoChildStorage = { |
There was a problem hiding this comment.
I guess the child StateInit only includes seqno, so two parents using the same child code and sequence number can derive the same child address. it also contradicts the caution above, because the child has no stored parent address to verify
to fix it is to include the parent address in the child's initial storage, pass it into address derivation, and verify it in the child handler
| self.numChildren = 0; | ||
| } | ||
| fun onInternalMessage(in: InMessage) { | ||
| val msg = lazy TodoChildMessage.fromSlice(in.body); |
There was a problem hiding this comment.
I'm not sure, but I think the else branch in the match below may not be reachable as written. Since TodoChildMessage = Identify is a single-variant union, lazy TodoChildMessage.fromSlice(in.body) should throw on any body that doesn't parse as Identify - including an empty body, since the opcode parse fails first
If the intent is to ignore empty top-up messages, the empty-body check probably needs to happen before the lazy fromSlice call for instance
fun onInternalMessage(in: InMessage) {
+ if (in.body.isEmpty()) {
+ return;
+ }
val msg = lazy TodoChildMessage.fromSlice(in.body);it definitely worths double-checking against actual Tolk semantics
This comment has been minimized.
This comment has been minimized.
|
|
||
| Consider NFTs: the collection acts as the parent contract, and each NFT item is a child contract. The key in this case is the item index, and only the collection can set the initial owner. | ||
|
|
||
| For jettons, the parent contract is the minter, and the child contracts are user wallets. The key is the user's smart contract address, and the value is the user's token balance. |
There was a problem hiding this comment.
| For jettons, the parent contract is the minter, and the child contracts are user wallets. The key is the user's smart contract address, and the value is the user's token balance. | |
| For jettons, the parent contract is the minter, and the child contracts are user wallets. The key is the user's smart contract address. |
|
|
||
| For jettons, the parent contract is the minter, and the child contracts are user wallets. The key is the user's smart contract address, and the value is the user's token balance. | ||
|
|
||
| Both patterns follow the same principle: each key maps to a separate contract. In jetton protocols, there is a unique contract per user, while in NFT collections, there is one contract per item (by index) that is shared across all users. |
There was a problem hiding this comment.
that is shared across all users.
This wording sounds a bit strange.
|
|
||
| ```tact Tact | ||
| import "@stdlib/deploy"; | ||
| fun TodoChildStorage.save(self) { |
There was a problem hiding this comment.
we should add parentAddress: address here
| struct (0x5b6f1392) DeployAnother {} | ||
|
|
||
| // Build StateInit for a TodoChild instance with the given seqno. | ||
| fun calcDeployedTodoChild( |
There was a problem hiding this comment.
maybe we should move it to parent.tolk (I am not sure)
closes #500