aurora-is-near / aurora-engine

⚙️ Aurora Engine implements an Ethereum Virtual Machine (EVM) on the NEAR Protocol.
https://doc.aurora.dev/develop/compat/evm
330 stars 82 forks source link

Add set_owner method for Aurora DAO #690

Closed hskang9 closed 1 year ago

hskang9 commented 1 year ago

Description

Aurora DAO requires an owner shift from the contract creator to Aurora DAO contract to execute its admin functions in the future. To achieve this, previous owner have to set the owner address from before to a new address that the previous owner sets.

set_owner method checks whether the sender is marked as the owner of the engine contract's state.

Then converts string input into AccountId.

Performance / NEAR gas cost considerations

It changes owner property in Aurora engine's contract state.

Testing

Tests were done in https://github.com/hskang9/aurora-silo-tests/blob/main/src/test.rs#L156.

How should this be reviewed

I am concerned if converting a random string into NEAR account id is still safe.

Additional information

hskang9 commented 1 year ago

I tried to remove unwrap() as far as possible by aggregating both postres::Error and TryFromIntError, but they happen to collide on RowIter type's map function.

hskang9 commented 1 year ago

So I was told by @joshuajbouw to overhaul the json encode/decode after adding this method as borsh, because it is inconsistent for admin methods to have it while all other methods use borsh encode/decode for now.

hskang9 commented 1 year ago

@joshuajbouw it is now used with borsh.

aleksuss commented 1 year ago

Resolve the conflicts.