-
Notifications
You must be signed in to change notification settings - Fork 9
feat!: use OZ FT contract #37
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
741ef02 to
a7e3526
Compare
b9805cd to
495edac
Compare
d68ca62 to
88ba1cd
Compare
| let owner: Address = e.storage().instance().get(&OWNER).expect("owner should be set"); | ||
| if owner != caller { | ||
| panic_with_error!(e, ExampleContractError::Unauthorized); | ||
| } | ||
|
|
||
| pausable::pause(e, &caller); | ||
| } | ||
|
|
||
| fn unpause(e: &Env, caller: Address) { | ||
| // When `ownable` module is available, | ||
| // the following checks should be equivalent to: | ||
| // `ownable::only_owner(&e);` | ||
| let owner: Address = e.storage().instance().get(&OWNER).expect("owner should be set"); |
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 owner: Address = e.storage().instance().get(&OWNER).expect("owner should be set"); | |
| if owner != caller { | |
| panic_with_error!(e, ExampleContractError::Unauthorized); | |
| } | |
| pausable::pause(e, &caller); | |
| } | |
| fn unpause(e: &Env, caller: Address) { | |
| // When `ownable` module is available, | |
| // the following checks should be equivalent to: | |
| // `ownable::only_owner(&e);` | |
| let owner: Address = e.storage().instance().get(&OWNER).expect("owner should be set"); | |
| let owner: Address = e.storage().instance().get(&OWNER).unwrap_optimized(); | |
| if owner != caller { | |
| panic_with_error!(e, ExampleContractError::Unauthorized); | |
| } | |
| pausable::pause(e, &caller); | |
| } | |
| fn unpause(e: &Env, caller: Address) { | |
| // When `ownable` module is available, | |
| // the following checks should be equivalent to: | |
| // `ownable::only_owner(&e);` | |
| let owner: Address = e.storage().instance().get(&OWNER)..unwrap_optimized(); |
Since the contract can't be deployed with setting the owner it's probably better to use this version of unwrap as it's provided by the soroban-sdk and is well, optimized.
I'm also confused why we need to pass the caller. Couldn't we just do owner.require_auth()? It seems like an extra unneeded check here.
This is something not worth slowing things down here but I think that it is probably because the authors assumed you needed to pass the account.
The CLI currently has a bug for auth where it only considers accounts that were passed in rather than any account referenced in the auth entries provided by simulation. So perhaps they were using the CLI and found that they needed to pass the account to have auth work correctly.
I'll open an issue there about it and with OZ.
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 contract is copied directly over from their examples. Can you send them a PR or some comments upstream?
Fixes #39
Requires upstream Stellar CLI changes: