Skip to content

Commit

Permalink
fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
taokayan committed Sep 4, 2023
1 parent 736b460 commit f5b8838
Show file tree
Hide file tree
Showing 7 changed files with 438 additions and 14 deletions.
328 changes: 328 additions & 0 deletions antelope_contracts/contracts/eosio.boot/eosio.boot.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "activate",
"base": "",
"fields": [
{
"name": "feature_digest",
"type": "checksum256"
}
]
},
{
"name": "authority",
"base": "",
"fields": [
{
"name": "threshold",
"type": "uint32"
},
{
"name": "keys",
"type": "key_weight[]"
},
{
"name": "accounts",
"type": "permission_level_weight[]"
},
{
"name": "waits",
"type": "wait_weight[]"
}
]
},
{
"name": "canceldelay",
"base": "",
"fields": [
{
"name": "canceling_auth",
"type": "permission_level"
},
{
"name": "trx_id",
"type": "checksum256"
}
]
},
{
"name": "deleteauth",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "permission",
"type": "name"
}
]
},
{
"name": "key_weight",
"base": "",
"fields": [
{
"name": "key",
"type": "public_key"
},
{
"name": "weight",
"type": "uint16"
}
]
},
{
"name": "linkauth",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "code",
"type": "name"
},
{
"name": "type",
"type": "name"
},
{
"name": "requirement",
"type": "name"
}
]
},
{
"name": "newaccount",
"base": "",
"fields": [
{
"name": "creator",
"type": "name"
},
{
"name": "name",
"type": "name"
},
{
"name": "owner",
"type": "authority"
},
{
"name": "active",
"type": "authority"
}
]
},
{
"name": "onerror",
"base": "",
"fields": [
{
"name": "sender_id",
"type": "uint128"
},
{
"name": "sent_trx",
"type": "bytes"
}
]
},
{
"name": "permission_level",
"base": "",
"fields": [
{
"name": "actor",
"type": "name"
},
{
"name": "permission",
"type": "name"
}
]
},
{
"name": "permission_level_weight",
"base": "",
"fields": [
{
"name": "permission",
"type": "permission_level"
},
{
"name": "weight",
"type": "uint16"
}
]
},
{
"name": "reqactivated",
"base": "",
"fields": [
{
"name": "feature_digest",
"type": "checksum256"
}
]
},
{
"name": "setabi",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "abi",
"type": "bytes"
}
]
},
{
"name": "setcode",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "vmtype",
"type": "uint8"
},
{
"name": "vmversion",
"type": "uint8"
},
{
"name": "code",
"type": "bytes"
}
]
},
{
"name": "unlinkauth",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "code",
"type": "name"
},
{
"name": "type",
"type": "name"
}
]
},
{
"name": "updateauth",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "permission",
"type": "name"
},
{
"name": "parent",
"type": "name"
},
{
"name": "auth",
"type": "authority"
}
]
},
{
"name": "wait_weight",
"base": "",
"fields": [
{
"name": "wait_sec",
"type": "uint32"
},
{
"name": "weight",
"type": "uint16"
}
]
}
],
"actions": [
{
"name": "activate",
"type": "activate",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Activate Protocol Feature\nsummary: 'Activate protocol feature {{nowrap feature_digest}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/admin.png#9bf1cec664863bd6aaac0f814b235f8799fb02c850e9aa5da34e8a004bd6518e\n---\n\n{{$action.account}} activates the protocol feature with a digest of {{feature_digest}}."
},
{
"name": "canceldelay",
"type": "canceldelay",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Cancel Delayed Transaction\nsummary: '{{nowrap canceling_auth.actor}} cancels a delayed transaction'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\n{{canceling_auth.actor}} cancels the delayed transaction with id {{trx_id}}."
},
{
"name": "deleteauth",
"type": "deleteauth",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Delete Account Permission\nsummary: 'Delete the {{nowrap permission}} permission of {{nowrap account}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\nDelete the {{permission}} permission of {{account}}."
},
{
"name": "linkauth",
"type": "linkauth",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Link Action to Permission\nsummary: '{{nowrap account}} sets the minimum required permission for the {{#if type}}{{nowrap type}} action of the{{/if}} {{nowrap code}} contract to {{nowrap requirement}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\n{{account}} sets the minimum required permission for the {{#if type}}{{type}} action of the{{/if}} {{code}} contract to {{requirement}}.\n\n{{#if type}}{{else}}Any links explicitly associated to specific actions of {{code}} will take precedence.{{/if}}"
},
{
"name": "newaccount",
"type": "newaccount",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Create New Account\nsummary: '{{nowrap creator}} creates a new account with the name {{nowrap name}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\n{{creator}} creates a new account with the name {{name}} and the following permissions:\n\nowner permission with authority:\n{{to_json owner}}\n\nactive permission with authority:\n{{to_json active}}"
},
{
"name": "onerror",
"type": "onerror",
"ricardian_contract": ""
},
{
"name": "reqactivated",
"type": "reqactivated",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Assert Protocol Feature Activation\nsummary: 'Assert that protocol feature {{nowrap feature_digest}} has been activated'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/admin.png#9bf1cec664863bd6aaac0f814b235f8799fb02c850e9aa5da34e8a004bd6518e\n---\n\nAssert that the protocol feature with a digest of {{feature_digest}} has been activated."
},
{
"name": "setabi",
"type": "setabi",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Deploy Contract ABI\nsummary: 'Deploy contract ABI on account {{nowrap account}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\nDeploy the ABI file associated with the contract on account {{account}}."
},
{
"name": "setcode",
"type": "setcode",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Deploy Contract Code\nsummary: 'Deploy contract code on account {{nowrap account}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\nDeploy compiled contract code to the account {{account}}."
},
{
"name": "unlinkauth",
"type": "unlinkauth",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Unlink Action from Permission\nsummary: '{{nowrap account}} unsets the minimum required permission for the {{#if type}}{{nowrap type}} action of the{{/if}} {{nowrap code}} contract'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\n{{account}} removes the association between the {{#if type}}{{type}} action of the{{/if}} {{code}} contract and its minimum required permission.\n\n{{#if type}}{{else}}This will not remove any links explicitly associated to specific actions of {{code}}.{{/if}}"
},
{
"name": "updateauth",
"type": "updateauth",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Modify Account Permission\nsummary: 'Add or update the {{nowrap permission}} permission of {{nowrap account}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/account.png#3d55a2fc3a5c20b456f5657faf666bc25ffd06f4836c5e8256f741149b0b294f\n---\n\nModify, and create if necessary, the {{permission}} permission of {{account}} to have a parent permission of {{parent}} and the following authority:\n{{to_json auth}}"
}
],
"tables": [],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
Binary file not shown.
21 changes: 17 additions & 4 deletions antelope_contracts/contracts/stubs/stub_evm_runtime.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <variant>
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>

Expand All @@ -7,24 +8,36 @@ namespace stub {

typedef std::vector<char> bytes;

struct bridge_message_v0 {
eosio::name receiver;
bytes sender;
eosio::time_point timestamp;
bytes value;
bytes data;

EOSLIB_SERIALIZE(bridge_message_v0, (receiver)(sender)(timestamp)(value)(data));
};

using bridge_message_t = std::variant<bridge_message_v0>;

class [[eosio::contract]] stub_evm_runtime : public contract {
using contract::contract;

public:
[[eosio::action]] void call(eosio::name from, const bytes& to, uint128_t value, const bytes& data, uint64_t gas_limit);
[[eosio::action]] void sendbridgemsg(eosio::name receiver, const bytes& sender, const eosio::time_point& timestamp, const bytes& value, const bytes& data);
[[eosio::action]] void sendbridgemsg(const bridge_message_t &message);

private:
void onbridgemsg(name receiver, const bytes& sender, const time_point& timestamp, const bytes& value, const bytes& data);
void onbridgemsg(const bridge_message_t &message);
using onbridgemsg_action = action_wrapper<"onbridgemsg"_n, &stub_evm_runtime::onbridgemsg>;
};

void stub_evm_runtime::call(eosio::name from, const bytes& to, uint128_t value, const bytes& data, uint64_t gas_limit) {
}

void stub_evm_runtime::sendbridgemsg(eosio::name receiver, const bytes& sender, const eosio::time_point& timestamp, const bytes& value, const bytes& data) {
void stub_evm_runtime::sendbridgemsg(const bridge_message_t &message) {
onbridgemsg_action onbridgemsg_act(eosio::name("eosio.erc2o"), {{get_self(), "active"_n}});
onbridgemsg_act.send(receiver, sender, timestamp, value, data);
onbridgemsg_act.send(message);
}

} // namespace stub
4 changes: 4 additions & 0 deletions antelope_contracts/tests/erc20/contracts.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ namespace eosio {
namespace testing {

struct contracts {

static std::vector<uint8_t> eosio_boot_wasm() { return read_wasm("${ANTELOPE_CONTRACTS_SOURCE_DIR}/eosio.boot/eosio.boot.wasm"); }
static std::vector<char> eosio_boot_abi() { return read_abi("${ANTELOPE_CONTRACTS_SOURCE_DIR}/eosio.boot/eosio.boot.abi"); }

static std::vector<uint8_t> eosio_token_wasm() { return read_wasm("${ANTELOPE_CONTRACTS_SOURCE_DIR}/eosio.token/eosio.token.wasm"); }
static std::vector<char> eosio_token_abi() { return read_abi("${ANTELOPE_CONTRACTS_SOURCE_DIR}/eosio.token/eosio.token.abi"); }

Expand Down
Loading

0 comments on commit f5b8838

Please sign in to comment.