-
Notifications
You must be signed in to change notification settings - Fork 47
Add Docs for Ralph Danube Features #492
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
Conversation
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.
LGTM 👍
docs/ralph/danube-features.md
Outdated
|
||
There are a few things worth emphasizing here: | ||
|
||
- TxScript can only chain the asset outputs from the contract call, contract output cannot be chained |
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.
TxScript can only chain the asset outputs of the callers. If the asset outputs are for non-callers, then they can't be chained either.
def chainCallerOutputs(frameBalanceState: MutBalanceState): ExeResult[Unit] = {
EitherF.foreachTry(allInputAddresses.toIterable) { caller =>
docs/ralph/danube-features.md
Outdated
|
||
The Danube upgrade introduces the `@preserveCaller` function annotation. When a function is annotated with `@preserveCaller`, the caller information is preserved for the next function call in the chain. | ||
|
||
More specifically, if a `@preserveCaller` annotated function calls another function, the `callerAddress!()` in the called function will return the caller address of the annotated function rather than the annotated function itself. This feature is particularly valuable for implementing routing patterns in smart contracts, where maintaining the identity of the original caller is essential for proper access control and authorization. |
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.
Let's note that the same mechanism works for externalCallerAddress!()
docs/ralph/danube-features.md
Outdated
Here's an example of how `@preserveCaller` works: | ||
|
||
```rust | ||
Contract PreserveCaller(internal: PreserveCallerInternal) { |
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.
How about naming it Rounter
since it's the most common use case?
docs/ralph/danube-features.md
Outdated
pub fn ifStmts(x: U256, y: U256) -> U256 { | ||
let num1 = if (x > y) 1 else 0 | ||
let num2 = if x > y 1 else 0 | ||
let num3 = if x > y { log(x) 1 } else { log(x) 0 } |
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.
This isn't recommended. Better do this. We will introduce fmt for such cases.
let num3 = if x > y {
log(x)
1
} else {
log(x)
0
}
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.
Let's also add this change: alephium/alephium#1255 (comment)
No description provided.