Skip to content
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

Add abi item in wasm contract and fix bugs #16

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading