Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b35ce46
Merge pull request #29 from API-market/dev
surabhil Jan 22, 2019
29ed8f6
Merge pull request #30 from API-market/staging
surabhil Jan 22, 2019
055c188
Merge pull request #7 from API-market/master
surabhil Jan 22, 2019
d9f651b
Update README.md
bas4r Apr 3, 2019
5843749
Update README.md
bas4r Apr 3, 2019
3dd6fc0
system.ore added
Aug 2, 2019
2f50819
test update
Aug 2, 2019
295f129
changeacctier applied
Sep 4, 2019
2595c3d
Merge pull request #40 from API-market/feature/ore-system
bas4r Nov 26, 2019
9df7bef
Merge pull request #42 from API-market/dev
bas4r Nov 26, 2019
7be631d
Merge pull request #43 from API-market/staging
bas4r Dec 2, 2019
8cde558
Version 1.6 syntax update
bas4r Jan 17, 2020
7bbbd1d
disable standard token tests
bas4r Jan 21, 2020
632a9d2
Misc changes
systemzax Mar 14, 2020
795ba0f
Remove build files
Mar 14, 2020
cea0b58
Add gitkeep to build folder
Mar 14, 2020
f05ccf3
Merge https://github.com/CryptoMechanics/aikon-ore-protocol into v2.0
bas4r Apr 24, 2020
c428fdd
getStaker & stakedAmount added
bas4r Jun 11, 2020
f62f2a2
system update
bas4r Jun 11, 2020
bc605bf
add checks for changeTier migration & fixs
bas4r Jun 11, 2020
82a525d
Merge pull request #44 from API-market/v2.0
bas4r Jun 11, 2020
0dade9d
Merge pull request #45 from API-market/v2.0
bas4r Jun 11, 2020
7b2a05e
Merge pull request #46 from API-market/dev
bas4r Jun 11, 2020
ab885b7
ore.apptoken added
bas4r Jun 25, 2020
acceb23
added tokenprice
bas4r Jul 1, 2020
54810c4
Merge pull request #47 from API-market/feature/apptoken-ore
bas4r Jul 16, 2020
cb3813e
Merge branch 'master' of github.com:API-market/ore-protocol into staging
bas4r Jul 23, 2020
722914e
apptoken.ore symbol delete patch
bas4r Jul 24, 2020
e7993cb
deltoken fix
bas4r Jul 24, 2020
e96bedf
deltoken deleted
bas4r Aug 11, 2020
5c3a8d5
pricecut added
bas4r Sep 28, 2020
b35f545
add tier table migration
bas4r Nov 28, 2020
464000d
comments added
bas4r Nov 30, 2020
7fa7a37
clean prints
bas4r Nov 30, 2020
b3a844a
add update test to circleci
bas4r Dec 8, 2020
5faaa4c
ci test walletname fix
bas4r Dec 8, 2020
021721d
Feature/circleci token update (#50)
bas4r Dec 9, 2020
900f298
Merge pull request #51 from API-market/feature/update-tier-table
bas4r Dec 9, 2020
05b4355
Merge branch 'dev' of github.com:API-market/ore-protocol into feature…
bas4r Dec 9, 2020
32ef029
update comments
bas4r Dec 9, 2020
5418b62
test refactoring
bas4r Dec 17, 2020
179258c
update docker image
bas4r Dec 17, 2020
d4cb733
update circleci.yml
bas4r Dec 17, 2020
58c7c83
fix circleci
bas4r Dec 18, 2020
1e38332
update readmes
bas4r Dec 18, 2020
2454443
update readmes
bas4r Dec 18, 2020
cb25f22
fix chgtier price name
bas4r Dec 29, 2020
51f6854
Merge pull request #53 from API-market/feature/docker-tests
bas4r Dec 30, 2020
5dd9bea
add expiry option
bas4r Dec 31, 2020
44af2d8
remove unnecessary upgrade step
bas4r Dec 31, 2020
c319dc2
Upgrade dir refactor
bas4r Jan 1, 2021
097028f
remove comments
bas4r Jan 1, 2021
8b00008
Readme update
bas4r Jan 1, 2021
f8fe4a8
update refactoring
bas4r Jan 2, 2021
b0f0d1f
keypress added
bas4r Jan 2, 2021
1d58cf2
fix migration check
bas4r Jan 2, 2021
f4c1860
update deployment scripts auths for setabi change
bas4r Jan 20, 2021
8ad961a
check setabi auth added
bas4r Jan 20, 2021
6d0f164
Merge pull request #9 from API-market/dev
bas4r Feb 1, 2021
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
9 changes: 3 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ jobs:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: bcelebci/ore-protocol
- image: openrightsexchange/ore-chain:v1.8.7
environment:
PIPENV_VENV_IN_PROJECT: true


steps:
- checkout
Expand All @@ -35,11 +36,7 @@ jobs:
- run:
name: run tests
command: |
tests/build_and_test.sh
python3 tests/standard_token.py
python3 tests/rights_registry.py
python3 tests/instrument.py
python3 tests/usage_log.py
./test.sh cleos

- store_artifacts:
path: test-reports
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*.out
*.app
build/*
contracts/build/*

#other
.DS_Store
Expand All @@ -42,3 +43,7 @@ scripts/scriptout/*
scripts/importkeys_prod.sh
scripts/importkeys_staging.sh
staging_keys

contracts/build/*

*/build/*
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

[![CircleCI](https://circleci.com/gh/API-market/ore-protocol/tree/master.svg?style=svg)](https://circleci.com/gh/API-market/ore-protocol/tree/master)
# ORE protocol

The ORE Protocol is a blockchain-hosted API that provides a developer-friendly way to define any digital asset (or any physical asset with an online digital representation) and to trade and control access to these protected resources.

### Token Economics Upgrade (2021-01-03)

The ORE Network designed to provide simpler approach for managing account resources (tiers) and to incentivize staking ORE tokens (via creating accounts, instruments etc..). Token Economics Upgrade enables these features, allowing stakers to claim rewards just like BPs (once a month). Click [here](./scripts/2020-12_TokenEconomicsUpgrade) to see upgrade details
### Rights Token (aka Instrument)
A non-fungible 'Rights Token' can enable access to one or more protected resources. It specifies which resources are available, how much each costs to access, and how to access them. These tokens can be stored in a blockchain 'wallet' and presented to the ORE Protocol to retrieve an endpoint and access token. Payment to access a resource (when required) is made as a real-time micropayment using the stable 'CPU' token.

Expand Down
45 changes: 45 additions & 0 deletions contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.5)
project(eosio_contracts VERSION 1.5.2)

set(EOSIO_CDT_VERSION_MIN "1.4")
set(EOSIO_CDT_VERSION_SOFT_MAX "1.6")
#set(EOSIO_CDT_VERSION_HARD_MAX "")

find_package(eosio.cdt)

### Check the version of eosio.cdt
set(VERSION_MATCH_ERROR_MSG "")
EOSIO_CHECK_VERSION(VERSION_OUTPUT "${EOSIO_CDT_VERSION}"
"${EOSIO_CDT_VERSION_MIN}"
"${EOSIO_CDT_VERSION_SOFT_MAX}"
"${EOSIO_CDT_VERSION_HARD_MAX}"
VERSION_MATCH_ERROR_MSG)
if(VERSION_OUTPUT STREQUAL "MATCH")
message(STATUS "Using eosio.cdt version ${EOSIO_CDT_VERSION}")
elseif(VERSION_OUTPUT STREQUAL "WARN")
message(WARNING "Using eosio.cdt version ${EOSIO_CDT_VERSION} even though it exceeds the maximum supported version of ${EOSIO_CDT_VERSION_SOFT_MAX}; continuing with configuration, however build may fail.\nIt is recommended to use eosio.cdt version ${EOSIO_CDT_VERSION_SOFT_MAX}.x")
else() # INVALID OR MISMATCH
message(FATAL_ERROR "Found eosio.cdt version ${EOSIO_CDT_VERSION} but it does not satisfy version requirements: ${VERSION_MATCH_ERROR_MSG}\nPlease use eosio.cdt version ${EOSIO_CDT_VERSION_SOFT_MAX}.x")
endif(VERSION_OUTPUT STREQUAL "MATCH")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(TEST_BUILD_TYPE "Debug")
set(CMAKE_BUILD_TYPE "Release")
else()
set(TEST_BUILD_TYPE ${CMAKE_BUILD_TYPE})
endif()

add_subdirectory(ore.apptoken)
add_subdirectory(ore.system)
#add_subdirectory(ore.standard_token)
add_subdirectory(ore.rights_registry)
add_subdirectory(ore.instrument)
add_subdirectory(ore.usage_log)


if (APPLE)
set(OPENSSL_ROOT "/usr/local/opt/openssl")
elseif (UNIX)
set(OPENSSL_ROOT "/usr/include/openssl")
endif()
set(SECP256K1_ROOT "/usr/local")
20 changes: 20 additions & 0 deletions contracts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/bash

printf "\t=========== Building eosio.contracts ===========\n\n"

CURDIRNAME=${PWD##*/}

if [ $CURDIRNAME != 'contracts' ]
then
cd contracts
fi

RED='\033[0;31m'
NC='\033[0m'

CORES=`getconf _NPROCESSORS_ONLN`
mkdir -p build
pushd build &> /dev/null
cmake ../
make -j${CORES}
popd &> /dev/null
9 changes: 9 additions & 0 deletions contracts/ore.apptoken/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_contract(ore.apptoken ore.apptoken ${CMAKE_CURRENT_SOURCE_DIR}/src/ore.apptoken.cpp)

target_include_directories(ore.apptoken.wasm
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include)

set_target_properties(ore.apptoken.wasm
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
88 changes: 88 additions & 0 deletions contracts/ore.apptoken/include/ore.apptoken.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#pragma once

#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>

#include <string>

using namespace eosio;
using namespace std;

using std::string;

/**
* eosio.token contract defines the structures and actions that allow users to create, issue, and manage
* tokens on EOSIO based blockchains.
*/
class [[eosio::contract("ore.apptoken")]] apptoken : public eosio::contract
{
public:
apptoken( name receiver, name code, datastream<const char*> ds): contract(receiver, code, ds) {}

/**
* Allows `issuer` account to create a token in supply of `maximum_supply`. If validation is successful a new entry in statstable for token symbol scope gets created.
*
* @param issuer - the account that creates the token,
* @param maximum_supply - the maximum supply set for the token created.
*
* @pre Token symbol has to be valid,
* @pre Token symbol must not be already created,
* @pre maximum_supply has to be smaller than the maximum supply allowed by the system: 1^62 - 1.
* @pre Maximum supply must be positive;
*/
ACTION create(const name &issuer,
const asset &maximum_supply);
ACTION issue(const name &to, const asset &quantity, const string &memo);
ACTION retire(const asset &quantity, const string &memo);
ACTION transfer(const name &from,
const name &to,
const asset &quantity,
const string &memo);
ACTION open(const name &owner, const symbol &symbol, const name &ram_payer);

ACTION close(const name &owner, const symbol &symbol);

static asset get_supply(const name &token_contract_account, const symbol_code &sym_code)
{
stats statstable(token_contract_account, sym_code.raw());
const auto &st = statstable.get(sym_code.raw());
return st.supply;
}

static asset get_balance(const name &token_contract_account, const name &owner, const symbol_code &sym_code)
{
accounts accountstable(token_contract_account, owner.value);
const auto &ac = accountstable.get(sym_code.raw());
return ac.balance;
}

using create_action = eosio::action_wrapper<"create"_n, &apptoken::create>;
using issue_action = eosio::action_wrapper<"issue"_n, &apptoken::issue>;
using retire_action = eosio::action_wrapper<"retire"_n, &apptoken::retire>;
using transfer_action = eosio::action_wrapper<"transfer"_n, &apptoken::transfer>;
using open_action = eosio::action_wrapper<"open"_n, &apptoken::open>;
using close_action = eosio::action_wrapper<"close"_n, &apptoken::close>;

private:
struct [[eosio::table]] account
{
asset balance;

uint64_t primary_key() const { return balance.symbol.code().raw(); }
};

struct [[eosio::table]] currency_stats
{
asset supply;
asset max_supply;
name issuer;

uint64_t primary_key() const { return supply.symbol.code().raw(); }
};

typedef eosio::multi_index<"accounts"_n, account> accounts;
typedef eosio::multi_index<"stat"_n, currency_stats> stats;

void sub_balance(const name &owner, const asset &value);
void add_balance(const name &owner, const asset &value, const name &ram_payer);
};
159 changes: 159 additions & 0 deletions contracts/ore.apptoken/src/ore.apptoken.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#include "../include/ore.apptoken.hpp"

using namespace eosio;

ACTION apptoken::create( const name& issuer,
const asset& maximum_supply )
{
require_auth( name("system.ore"));

auto sym = maximum_supply.symbol;
check( sym.is_valid(), "invalid symbol name [apptoken.create]" );
check( maximum_supply.is_valid(), "invalid supply [apptoken.create]");
check( maximum_supply.amount > 0, "max-supply must be positive [apptoken.create]");

stats statstable( get_self(), sym.code().raw() );
auto existing = statstable.find( sym.code().raw() );
check( existing == statstable.end(), "token with symbol already exists [apptoken.create]" );

statstable.emplace( get_self(), [&]( auto& s ) {
s.supply.symbol = maximum_supply.symbol;
s.max_supply = maximum_supply;
s.issuer = issuer;
});
}

ACTION apptoken::issue( const name& to, const asset& quantity, const string& memo )
{
auto sym = quantity.symbol;
check( sym.is_valid(), "invalid symbol name [apptoken.issue]" );
check( memo.size() <= 256, "memo has more than 256 bytes [apptoken.issue]" );

stats statstable( get_self(), sym.code().raw() );
auto existing = statstable.find( sym.code().raw() );
check( existing != statstable.end(), "token with symbol does not exist, create token before issue [apptoken.issue]" );
const auto& st = *existing;
check( to == st.issuer, "tokens can only be issued to issuer account [apptoken.issue]" );

require_auth( st.issuer );
check( quantity.is_valid(), "invalid quantity [apptoken.issue]" );
check( quantity.amount > 0, "must issue positive quantity [apptoken.issue]" );

check( quantity.symbol == st.supply.symbol, "symbol precision mismatch [apptoken.issue]" );
check( quantity.amount <= st.max_supply.amount - st.supply.amount, "quantity exceeds available supply [apptoken.issue]");

statstable.modify( st, same_payer, [&]( auto& s ) {
s.supply += quantity;
});

add_balance( st.issuer, quantity, st.issuer );
}

ACTION apptoken::retire( const asset& quantity, const string& memo )
{
auto sym = quantity.symbol;
check( sym.is_valid(), "invalid symbol name [apptoken.retire]" );
check( memo.size() <= 256, "memo has more than 256 bytes [apptoken.retire]" );

stats statstable( get_self(), sym.code().raw() );
auto existing = statstable.find( sym.code().raw() );
check( existing != statstable.end(), "token with symbol does not exist [apptoken.retire]" );
const auto& st = *existing;

require_auth( st.issuer );
check( quantity.is_valid(), "invalid quantity [apptoken.retire]" );
check( quantity.amount > 0, "must retire positive quantity [apptoken.retire]" );

check( quantity.symbol == st.supply.symbol, "symbol precision mismatch [apptoken.retire]" );

statstable.modify( st, same_payer, [&]( auto& s ) {
s.supply -= quantity;
});

sub_balance( st.issuer, quantity );
}

ACTION apptoken::transfer( const name& from,
const name& to,
const asset& quantity,
const string& memo )
{
check( from != to, "cannot transfer to self [apptoken.transfer]" );
require_auth( from );
check( is_account( to ), "to account does not exist [apptoken.transfer]");
auto sym = quantity.symbol.code();
stats statstable( get_self(), sym.raw() );
const auto& st = statstable.get( sym.raw() );

require_recipient( from );
require_recipient( to );

check( quantity.is_valid(), "invalid quantity [apptoken.transfer]" );
check( quantity.amount > 0, "must transfer positive quantity [apptoken.transfer]" );
check( quantity.symbol == st.supply.symbol, "symbol precision mismatch [apptoken.transfer]" );
check( memo.size() <= 256, "memo has more than 256 bytes [apptoken.transfer]" );

auto payer = has_auth( to ) ? to : from;

sub_balance( from, quantity );
add_balance( to, quantity, payer );
}

void apptoken::sub_balance( const name& owner, const asset& value ) {
accounts from_acnts( get_self(), owner.value );

const auto& from = from_acnts.get( value.symbol.code().raw(), "no balance object found [apptoken.sub_balance]" );
check( from.balance.amount >= value.amount, "overdrawn balance [apptoken.sub_balance]" );

from_acnts.modify( from, owner, [&]( auto& a ) {
a.balance -= value;
});
}

void apptoken::add_balance( const name& owner, const asset& value, const name& ram_payer )
{
accounts to_acnts( get_self(), owner.value );
auto to = to_acnts.find( value.symbol.code().raw() );
if( to == to_acnts.end() ) {
to_acnts.emplace( ram_payer, [&]( auto& a ){
a.balance = value;
});
} else {
to_acnts.modify( to, same_payer, [&]( auto& a ) {
a.balance += value;
});
}
}

ACTION apptoken::open( const name& owner, const symbol& symbol, const name& ram_payer )
{
require_auth( ram_payer );

check( is_account( owner ), "owner account does not exist [apptoken.open]" );

auto sym_code_raw = symbol.code().raw();
stats statstable( get_self(), sym_code_raw );
const auto& st = statstable.get( sym_code_raw, "symbol does not exist [apptoken.open]" );
check( st.supply.symbol == symbol, "symbol precision mismatch [apptoken.open]" );

accounts acnts( get_self(), owner.value );
auto it = acnts.find( sym_code_raw );
if( it == acnts.end() ) {
acnts.emplace( ram_payer, [&]( auto& a ){
a.balance = asset{0, symbol};
});
}
}

ACTION apptoken::close( const name& owner, const symbol& symbol )
{
require_auth( owner );
accounts acnts( get_self(), owner.value );
auto it = acnts.find( symbol.code().raw() );
check( it != acnts.end(), "Balance row already deleted or never existed. Action won't have any effect. [apptoken.close]" );
check( it->balance.amount == 0, "Cannot close because the balance is not zero. [apptoken.close]" );
acnts.erase( it );
}


EOSIO_DISPATCH(apptoken, (create)(issue)(transfer)(open)(close)(retire))
8 changes: 8 additions & 0 deletions contracts/ore.instrument/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_contract(ore.instrument ore.instrument ${CMAKE_CURRENT_SOURCE_DIR}/src/ore.instrument.cpp)
target_include_directories(ore.instrument.wasm
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include)

set_target_properties(ore.instrument.wasm
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
Loading