-
Notifications
You must be signed in to change notification settings - Fork 78
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: mirroring erc-20 contracts #845
Conversation
|
||
Ok(result) | ||
}) | ||
} | ||
|
||
pub fn get_erc20_metadata<I: IO + Copy, E: Env>(mut io: I, env: &E) -> Result<(), ContractError> { | ||
let erc20_address = io.read_input_arr20().map(Address::from_array)?; | ||
let erc20_identifier = |
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.
Technically it is a breaking change, but I think it's okay because we haven't deployed this function yet.
@aleksuss Could you please add the details about the added public methods/api with its arguments (json/borsh) in the PR description? |
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.
Nice work!
engine-test-doubles/src/promise.rs
Outdated
unsafe fn promise_create_and_combine(&mut self, args: &[PromiseCreateArgs]) -> PromiseId { | ||
args.iter() | ||
.map(|arg| self.promise_create_call(arg)) | ||
.last() |
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.
The current implementation does not have the right semantics. I think the correct implementation would look something like
let id = self.take_id();
self.scheduled_promises.insert(
id,
PromiseArgs::Recursive(
NearPromise::And(
args.iter().map(|p| NearPromise::Simple(SimpleNearPromise::Create(p.clone()))).collect()
)
)
);
PromiseId::new(id)
.try_to_vec() | ||
.map_err(|_| crate::errors::ERR_SERIALIZE)?, | ||
attached_balance: Yocto::new(0), | ||
attached_gas: NearGas::new(5_000_000_000_000), |
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.
Probably makes sense to factor out the gas values as named constants (here and in the other promise).
attached_balance: Yocto::new(0), | ||
attached_gas: NearGas::new(5_000_000_000_000), | ||
}; | ||
let promise_id = unsafe { |
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.
Please put a short comment here about the safety of this call. Something along the lines of "these promises are read-only calls to the main engine and this code is only reachable if the transaction is executed by a privileged account".
Description
The PR adds a possibility to mirror previously deployed ERC-20 contracts on the main Aurora contract. The transaction
mirror_erc20_token
is allowed in the Silo mode only.mirror_erc20_token
accepts parameters serialised with borsh.get(set)_erc20_metadata
accepts parameters serialised with JSON.Performance / NEAR gas cost considerations
There are no changes in the performance/gas consumption.
Testing
The corresponding test has been added.