-
Notifications
You must be signed in to change notification settings - Fork 2
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
Wegld fee #65
Wegld fee #65
Conversation
andreiblt1304
commented
Jun 28, 2024
•
edited
Loading
edited
- Created a separate endpoint to register tokens
- Added registered tokens mapper
- Modified init endpoint with optional values for WEGLD and Sovereign Token Prefix Identifiers
Now the verification consists only if the tokens has the current's sovereign prefix and if they are registered. The WEGLD fee has to be paid before execution.
common/utils/src/lib.rs
Outdated
return false; | ||
} | ||
|
||
let dash = b'-'; |
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.
Have this as a const instead.
common/utils/src/lib.rs
Outdated
|
||
let dash = b'-'; | ||
let buffer = token_id.as_managed_buffer(); | ||
let mut array_buffer = [0u8; 32]; |
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.
"32" can also be a const, like "MAX_TOKEN_ID_LEN"
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.
Should also do the same in the above function btw.
); | ||
|
||
for token_id in tokens { | ||
self.register_token(token_id); |
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 this makes token issue, it won't work. You can only make one legacy async call per call, which is what the token issue framework uses.
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.
register_token
just saves the TokenIdentifier
to the paid_issued_tokens
mapper
enshrine-esdt-safe/src/lib.rs
Outdated
if !is_sovereign_chain { | ||
match wegld_identifier { | ||
Some(identifier) => { | ||
require!( | ||
identifier.is_valid_esdt_identifier(), | ||
"Sent Identifier is not valid" | ||
); | ||
|
||
self.wegld_identifier().set(identifier); | ||
} | ||
|
||
None => sc_panic!("WEGLG identifier must be set in Mainchain"), | ||
} | ||
|
||
match sov_token_prefix { | ||
Some(prefix) => self.sovereign_tokens_prefix().set(prefix), | ||
None => sc_panic!("Sovereign Token Prefix must be set in Mainchain"), | ||
} | ||
} |
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.
Can revert condition here to do some de-nesting, i.e.
if is_sovereign_chain {
return;
}
// code that was inside if
Also, since you need "Some" for both Option, why not take "TokenIdentifier" and "ManagedBuffer" directly in the init call?
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.
i agree with the de-nesting but I don't quite understand what you mean by taking those directly in the init call