Skip to content

Commit

Permalink
Merge pull request #16 from BolarityNetwork/features/EvmABIx1
Browse files Browse the repository at this point in the history
Add abi item in wasm contract and fix bugs
  • Loading branch information
Acaishiba authored Aug 26, 2024
2 parents b465314 + 176eed8 commit 88807b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions external/contract/src/erc20wasm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ mod erc20 {
evm_abi.push(("approve(address,uint256)returns(bool)".to_string(), "approve_abi".to_string(), None));
evm_abi.push(("transferFrom(address,address,uint256)returns(bool)".to_string(), "transfer_from_abi".to_string(), None));

evm_abi.push(("wasmCallEvm(string,string,uint128)returns(string)".to_string(), "wasmCallEvm".to_string(), None));
evm_abi.push(("wasmCallEvmBalance(string,string)returns(uint128)".to_string(), "wasmCallEvmBalance".to_string(), None));
evm_abi.push(("wasmCallEvmProxy(string)returns(string)".to_string(), "wasmCallEvmProxy".to_string(), None));

evm_abi
}

Expand Down
17 changes: 12 additions & 5 deletions frame/hybrid-vm-port/src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,16 @@ impl<T: Config> Pallet<T> {
return Err(err);
}

let input_type: Vec<&str> = abi_fun[index_s1 + 1..index_e1].split(',').collect();
let output_type: Vec<&str> = abi_fun[index_s2 + 1..index_e2].split(',').collect();
let input_type: Vec<&str> = if index_s1 + 1 < index_e1 {
abi_fun[index_s1 + 1..index_e1].split(',').collect()
} else {
vec![]
};
let output_type: Vec<&str> = if index_s2 + 1 < index_e2 {
abi_fun[index_s2 + 1..index_e2].split(',').collect()
} else {
vec![]
};

// wasm type: AccountId,bool,Vec<u8>,H256,String,u8,u16,u32,u64,u128,U256,Vec<T>
let data_type = "address,bool,bytes,bytes32,string,uint8,uint16,uint32,uint64,uint128,uint256,address[],bool[],bytes32[],uint8[],uint16[],uint32[],uint64[],uint128[],uint256[]";
Expand Down Expand Up @@ -340,7 +348,7 @@ impl<T: Config> Pallet<T> {
};

let info = pallet_contracts::Pallet::<T>::bare_call(
origin,
origin.clone(),
t.into(),
balance,
weight_limit,
Expand All @@ -354,8 +362,7 @@ impl<T: Config> Pallet<T> {
match info.result {
Ok(return_value) => {
if !return_value.did_revert() {
// because return_value.data = MessageResult<T, E>, so, the
// first byte is zhe Ok() Code, be removed
frame_system::Pallet::<T>::inc_account_nonce(&origin);
let err_data = DispatchErrorWithPostInfo {
post_info: PostDispatchInfo {
actual_weight: Some(info.gas_consumed),
Expand Down
Binary file modified frame/hybrid-vm/fixtures/erc20.wasm
Binary file not shown.

0 comments on commit 88807b9

Please sign in to comment.