Skip to content

Token-locker: comments and review#174

Draft
olga24912 wants to merge 10 commits intomasterfrom
token-locker-review
Draft

Token-locker: comments and review#174
olga24912 wants to merge 10 commits intomasterfrom
token-locker-review

Conversation

@olga24912
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread token-locker/src/lib.rs
#[serializer(borsh)]
verification_success: bool,
/// Account Id of the token on NEAR
#[serializer(borsh)] token: String,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why token is String not an AccountId?

Comment thread token-locker/src/lib.rs
/// Account Id of the token on NEAR
#[serializer(borsh)] token: String,
/// Account Id of the token recipient on NEAR
#[serializer(borsh)] new_owner_id: String,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why new_owner_id is a String, not an AccountId? Also, recipient maybe a better name to be consistent with other functions.

Comment thread token-locker/src/lib.rs
/// The proof of the Ethereum `burn` event.
#[serializer(borsh)] proof: Proof,
/// The NEAR account id of the token
#[serializer(borsh)] token: String,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why String not AccountId? It is not clear it is NEAR account ID, or token name, or symbols or maybe Eth address...

Comment thread token-locker/src/lib.rs
&mut self,
receiver_id: AccountId,
amount: U128,
memo: Option<String>,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get what memo mean in this context. But I think it is something standard, and we always use None for that field. So I think it doesn't matter.

Comment thread token-locker/src/lib.rs
fn ft_transfer(
&mut self,
receiver_id: AccountId,
amount: U128,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Balance I think is more logical here as a type, but maybe it is standard and can not be changed. Not sure about that.

Comment thread token-locker/src/lib.rs
/// Update Ethereum Address of the Bridge Token Factory
#[private]
pub fn update_factory_address(&mut self, factory_address: String) {
self.eth_factory_address = validate_eth_address(factory_address);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think validate_eth_address is not a clear name, it is more like a constructor for EthAddress from String. I think the name eth_address_from_string is more clear. I think it is Ok to do some checks in the constructor. I expect that the function validate_eth_address return is this address is valid or not.

Comment thread token-locker/src/lib.rs
@@ -68,54 +73,80 @@ pub struct Contract {
pub is_whitelist_mode_enabled: bool,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ethereum Factory also have a whitelist. Are these whitelists consistent with each other? If yes, how is this achieved?

Comment thread token-locker/src/lib.rs

/// Checks whether the provided proof is already used.
/// Checks whether the provided proof of Ethereum `burn` event is already used for unlocking tokens
pub fn is_used_proof(&self, #[serializer(borsh)] proof: Proof) -> bool {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where this function is used? Is it just a part of public API?

Comment thread token-locker/src/lib.rs
// The deposit required to cover the cost
// of additional storage of used proof
let required_deposit = self.record_proof(&proof);
assert!(env::attached_deposit() >= required_deposit);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also should be an extra 2 YOCTO which we used for ft_transfer_call. And maybe we want to return extra money back if the deposit is bigger than required.

Comment thread token-locker/src/lib.rs

// The deposit required to cover the cost
// of additional storage of used proof
let required_deposit = self.record_proof(&proof);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we get an error during ft_transfer_call? In that case, we will record that proof is already used, but we don't unlock tokens.

@@ -81,17 +81,17 @@ contract ProofConsumer is Ownable, IProofConsumer {
.outcome
.executor_id
) == keccak256(nearTokenLocker),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is better to do all these checks at the begging of the function. I think we shouldn't store it in the usedProofs incorrect proofs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant