Giter Site home page Giter Site logo

odra's People

Contributors

kpob avatar kubaplas avatar zie1ony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

odra's Issues

Add `odra-modules`.

Add odra-modules crate to the repo and reexport it in odra.
odra-modules should contain:

  • ERC20 token.
  • Wrapped CSPR based on ERC20 token.

Module with multiple #[odra::module] impl block does not compile

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.

Test U256 overflow.

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.

Detect bad argument name in `odra::external_contract`.

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);
    }
}

Featues check.

Check if only one feature is enabled. Fail the compilation if two or more featues are on.

execution_error macro causes clippy warning

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

Reuse `cargo-purse` in Casper

Currently every time CSPR is passed to the contract new purse is created. It should be just one both for users and contracts.

Modules in Mapping.

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>>
}

Add `List` collection.

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.

Odra 0.1.0 Milestone

Repos:

  • odra
  • odra-casper
  • cargo-odra
  • odra-template
  • odra-examples

[KUBA] Cargo Odra

  • cargo odra build without params should be the same as cargo odra build -h.
  • remove "near"
  • cargo odra clean
  • inform where wasm files were copied
  • cargo fmt on *wasm.rs
  • read how to cargo install cargo-odra
  • detect missing wasm-strip
  • detect missing target wasm32-unknown-unknown
  • Github Actions
  • Developer mode
  • setup repo:
    • master restructed
    • develop restricted
    • feature
  • README.md
  • CHANGELOG.md
  • Docsy for every public element.
  • add MIT LICENCE
  • Allow for odra and backend at a spec directory in developer mode.
  • [MACIEJ] refactor cargo odra generate.

[MACIEJ] Odra Casper

  • rename is_named_arg_exist,
  • TODO: Optimalize get_key and set_key
  • Remove OdraAddressWrapper and impl CasperAddress::from_odra_address(), casper_address.to_odra_address().
  • Fix WrappedType
  • add MIT LICENCE
  • CHANGELOG.md
  • setup repo:
    • master restructed
    • develop restricted
    • feature
  • remove features
  • Enable Github Actions
  • Tests for codegen.
  • Docs for public elements.
  • OdraError to OdraExecutionError when is implemented.

[KUBA] Odra Template

  • make sure it works.
  • CHANGELOG.md
  • Docsy for every public element.
  • add MIT LICENCE
  • setup repo:
    • master restructed
    • develop restricted
    • feature

[KUBA] Owned Token

  • Prepare reposiotry for publishing
  • Rename to odra-examples
  • README
  • CHANGELOG.md
  • add MIT LICENCE
  • setup repo:
    • master restructed
    • develop restricted
    • feature
  • Enable Casper tests when cargo odra test -p casper compiles getter_proxy.
  • Use Error macro when available.

[KRZYSIEK] Odra

  • Introduce unwrap_or_revert(err: Into)
  • unify event_absolute_position and index_to_usize, use odra-utils
  • try &str instead of &[u8] in core/contract_env
  • Fix TODO: odra/lang/ir/src/module_item/module_impl.rs.
  • Fix TODO in variable and mapping
  • add MIT LICENCE
  • remove mock_vm/src/test_utils.rs
  • setup repo:
    • master restructed
    • develop restricted
    • feature
  • Enable Github Actions
  • Add ContractEnv::self_address() to both MockVM and external_api::ContractEnv.
  • [MACIEJ] modify assert_event to work backwards
  • Docsy for every public element.
  • Macro for errors.
  • CHANGELOG.md
  • [MACIEJ] README.md per directory if needed
  • [MACIEJ] Main README.md

Code publishing process.

Odra
  • publish odra 0.0.1
  • make remaining changes (README and changlog) and change to 0.1.0.
  • make new tag, observe release.
Odra Casper
  • change to use odra 0.0.1
  • publish odra-casper 0.0.1
  • make remaining changes (changlog, docs) and change to 0.1.0.
  • make new tag, observe release.
Odra Template
  • change to use odra 0.0.1
  • point at odra 0.1.0
Cargo Odra
  • change to use odra 0.0.1
  • publish 0.0.1
  • make remaining changes (changlog) and change to 0.1.0.
  • make new tag, observe release.
Odra Examples
  • point at odra 0.0.1
  • enable casper tests
  • point at odra 0.1.0

Publishing

  • Set all version to 0.0.1.
  • Test publish with 0.0.1 to 0.0.2
  • merge all develops to master
  • publishing GH Actions
  • Video
  • DxD Portal Milestone submit
  • Make sure CRDAO is on it.
  • Update odra.dev
  • Add "Proudly by odra.dev (R) and logo and link"
  • Open discord.
  • Write release blog post at odra.dev/blog

Cargo.toml example

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"]

Catch calling constructors in MockVM

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);
    });
}

Native token interface.

Handle native token:

  • standard transfers,
  • passing tokens with contract calls when calling contract from the outside,
  • passing tokens with contract to contract call.
  • proper gas metering in tests that allows testing token transfers. The best would be zero-cost gas table.
  • #[odra(payable)] to mark entrypoint that accept tokens. (also in #[odra::external_contract]?).
  • TestEnv check of token.
  • Handle potential different types of integers for native tokens in backends (Casper has 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();
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.