-
Notifications
You must be signed in to change notification settings - Fork 116
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
Replace this.token
with methods on TokenContract
#1446
Conversation
static randomKeypair() { | ||
let privateKey = PrivateKey.random(); | ||
return { privateKey, publicKey: privateKey.toPublicKey() }; | ||
} |
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.
quality of life improvement, it's annoying to always need two commands to create a keypair
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 example was meant as a reproduction at a time where the missing 'access' permission caused a security hole for token contracts, and is long obsolete
this.token
with methods on TokenContract
@@ -71,7 +79,7 @@ class Dex extends SmartContract { | |||
} | |||
|
|||
@method createAccount() { | |||
this.token.mint({ address: this.sender, amount: UInt64.from(0) }); | |||
this.internal.mint({ address: this.sender, amount: UInt64.from(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.internal
is a great way to communicate usage within smart contract methods, awesome!
closes #1439
Removes
this.token
fromSmartContract
andAccountUpdate
, for two reasons:Instead, we reintroduce
mint()
,burn()
andsend()
as helper methods underTokenContract.internal
. The intention of this name is to make it clearer that these methods are for use within token contract methods, not from the outside (because they wouldn't be authorized when used from outside)this.token.id
is reintroduced asthis.deriveTokenId()
on token contracts. The reason to change the API from a property access to a function is that it's actually a function, which computes a hash in the circuit, and it's weird if a property access secretly adds constraints.