odradev / odra Goto Github PK
View Code? Open in Web Editor NEWOdra framework
License: MIT License
Odra framework
License: MIT License
Add odra-modules
crate to the repo and reexport it in odra
.
odra-modules
should contain:
ERC20
token.Wrapped CSPR
based on ERC20
token.When the #[deploy(init)]
method is specified don't generate Module::deploy()
method. It's like this here: https://github.com/odradev/odra-template/blob/3259626c1a123a295ea56f5d6070b59bc3662917/src/flipper.rs#L47
Fix odradev/odra-template
afterwards.
By now the only correct implementation of a module is having a struct and a single implementation block. If for some reason, a developer would like to have a module with more than one implementation block marked as odra::module
, compilation will fail.
We need to come up with a solution that gently informs a user that he should put all the entry points in a single impl block or allow having multiple blocks.
Inside an implementation block, only public functions should be converted to entry points.
Currently, a module with a private function does not compile to a wasm.
If conversion U512
-> U256
is required, the value may exceed the max value of U256. This scenario should be gently handled (e.g, the state should be reverted) and tested.
Consider this implementation of getter max of U256 as U512:
U512::from(<casper_types::U256 as AsPrimitive<casper_types::U512>>::as_(U256::MAX))
in
odra/odra-casper/types/src/uints.rs
Line 175 in 74bbf2c
Build getter_proxy.wasm
in build.rs
. Now it is included in the repo.
By default compile contracts as no_std
. Allow contracts to use std
if needed.
When the external_contract
is wrongly defined, MockVM
should throw an error like missing argument: "b"
:
use odra::types::Address;
#[odra::module]
pub struct Contract {}
#[odra::module]
impl Contract {
pub fn add(&self, a: u32, b: u32) -> u32 {
a + b
}
}
#[odra::external_contract]
trait WrongInterface {
fn add(&self, a: u32, wrong_name: u32) -> u32;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add() {
let contract = Contract::deploy();
let reference = WrongInterfaceRef::at(contract.address());
let _ = reference.add(1, 2);
}
}
Check if only one feature is enabled. Fail the compilation if two or more featues are on.
Sample logs:
execution_error! {
| ^^^^^^^^^^^^^^^^
= note: `-D clippy::from-over-into` implied by `-D warnings`
= help: consider to implement `From<erc20::Error>` instead
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into
= note: this error originates in the attribute macro `odra::odra_error` (in Nightly builds, run with -Z macro-backtrace for more
It's required so I can use the contract defined in one file in tests in another file.
Currently every time CSPR is passed to the contract new purse is created. It should be just one both for users and contracts.
It should be possible to use a module or another mapping as a mapping's value.
Example:
use odra::modules::tokens::ERC20;
#[odra::module]
struct Contract {
tokens: Mapping<String, ERC20>,
nested: Mapping<String, Mapping<u32, u64>>
}
Implement AddAssign, SubAssign, MulAssign, DivAssign in casper-types
uints.
Then remove -A clippy::assign-op-pattern
from justfile
.
Developer should be able to advance a block time in tests.
Running getter functions should not deduct gas, so in Casper all getters should be run as a special system account.
Add tests for Mapping and Variable that runs against MockVM.
Allow for:
use odra::List;
#[odra::module]
pub struct Contract {
list: List<u8>
}
#[odra::module]
impl Contract {
pub fn add(&self, value: u8) {
self.list.append(value);
}
pub fn get(&self, index: u32) -> Option<u32> {
self.list.get(index)
}
}
It should be implemented using Mapping and indexed from 0.
cargo odra build
without params should be the same as cargo odra build -h
.cargo odra test -p casper
compiles getter_proxy
.authors = ["Jakub Płaskonka [email protected]", "Krzysztof Pobiarżyn [email protected]", "Maciej Zieliński [email protected]"]
license = "MIT"
repository = "https://github.com/odradev/odra" // set to proper
description = "High-level smart contract framework for Rust" // different for each. This one is for core.
keywords = ["wasm", "webassembly", "blockchain"]
categories = ["wasm", "smart contracts"]
When calling a constructor, MockVM should return VmError(InvalidContext)
instead of VmError(NoSuchMethod(constructor_name))
.
Example test:
#[test]
fn second_initialization_fails() {
let (owner, ownable) = setup();
TestEnv::assert_exception(OdraError::VmError(VmError::InvalidContext), || {
ownable.init(owner);
});
}
Handle native token:
#[odra(payable)]
to mark entrypoint that accept tokens. (also in #[odra::external_contract]
?).u512
, Ethereum u256
).In test script.
let one = TestEnv::one_token();
TestEnv::with_tokens(1000 * one);
TestEnv::set_caller(user1);
contract.deposit();
assert_eq!(
TestEnv::token_balance(user1),
TestEnv::token_balance(contract.address())
)
In contract.
#[odra(init)]
#[odra(payable)]
pub fn start() {
let caller = ContracEnv::caller();
let contract_balance = ContracEnv::self_balance();
let transfered_amount = ContracEnv::attached_value();
let threshold = ContractEnv::one_token() * 100;
if contract_balance > threshold {
ContractEnv::transfer_tokens(caller, transfered_amount);
} else {
ContracEnv::with_tokens(contract_balance);
AnotherContract::at(caller).do_something();
}
}
Missmatch of types in call_contract
method in Odra and Odra Casper. #[no_mangle] call_contract
in Odra Casper returns Bytes
instead of Option<Bytes>
.
In odra/src/lib.rs
remove all *
in exports.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.