Skip to content

Commit

Permalink
Merge pull request #20 from eosnetworkfoundation/kayan_upgradeto
Browse files Browse the repository at this point in the history
Kayan upgradeto
  • Loading branch information
arhag authored Sep 8, 2023
2 parents c1fe928 + c4a8b39 commit 8611744
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions antelope_contracts/contracts/erc20/include/erc20/erc20.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class [[eosio::contract]] erc20 : public contract {
// evm runtime will call this to notify erc20 about the message from 'from' with 'data'.
[[eosio::action]] void onbridgemsg(const bridge_message_t &message);
[[eosio::action]] void upgrade();
[[eosio::action]] void upgradeto(std::string impl_address);

[[eosio::action]] void regtoken(eosio::name eos_contract_name,
std::string evm_token_name, std::string evm_token_symbol,
Expand Down
16 changes: 16 additions & 0 deletions antelope_contracts/contracts/erc20/src/erc20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ void erc20::upgrade() {
});
}

void erc20::upgradeto(std::string impl_address) {
require_auth(get_self());
auto address_bytes = from_hex(impl_address);
eosio::check(!!address_bytes, "implementation address must be valid 0x EVM address");
eosio::check(address_bytes->size() == kAddressLength, "invalid length of implementation address");

uint64_t id = 0;
impl_contract_table_t contract_table(_self, _self.value);

contract_table.emplace(_self, [&](auto &v) {
v.id = id;
v.address.resize(kAddressLength);
memcpy(&(v.address[0]), address_bytes->data(), kAddressLength);
});
}

[[eosio::action]] void erc20::regtoken(eosio::name token_contract, std::string evm_token_name, std::string evm_token_symbol, const eosio::asset& ingress_fee, const eosio::asset &egress_fee, uint8_t erc20_precision) {
require_auth(get_self());

Expand Down

0 comments on commit 8611744

Please sign in to comment.