-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: added migration & ownable #166
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for gnochess-signup-form canceled.
|
✅ Deploy Preview for gnochess canceled.
|
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.
Left a few minor comments
Please add some unit tests for the migration functionality 🙏
package chess | ||
|
||
func checkMigrated() { | ||
if migrated { |
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.
if !migrated {return}
...
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.
Do you intend to handle the situation where the realm has not migrated yet? If that is the case, since migrated
is a bool, the only stateful change that will happen is if it is true
. Why check otherwise?
realm/migrate.gno
Outdated
} | ||
|
||
func Migrate(newRealmPath string) string { | ||
// TODO add check for path validity |
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.
Leftover TODO?
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.
Not sure how to check for path validity at this point. The check should be able to see whether or not there is a ream deployed at newRealmPath
.
Edit: added an empty string check for now.
return true | ||
} | ||
|
||
func GetOwner() std.Address { |
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.
Why is this exported?
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.
So that it can be called by gnokey
, as to check who is the owner of realm
realm/migrate.gno
Outdated
return migratedTo | ||
} | ||
|
||
// testing commands, todo remove |
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.
Leftover?
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.
Left it in so its easier for anyone to test currently, will remove before merging
Removed.
Description
This PR introduces ownership & realm migration functionality to the
chess
package, and addresses issue #56.This PR also introduces an
init
function to the Chess realm, setting the realm owner to its deployer keypair upon deployment. The following functionality is added:Ownership functionality:
owner
variable is added to realm state,isOwner()
will check if the caller is owner and will panic if the caller is not the owner,Migration functionality:
migrateTo
variable added to represent the path of new deployment of realmmigrated
bool added to indicate if a migration has happened beforeMigrate
function to allow migrating, only callable by current owner of realmcheckMigrated