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

Remove private logic in .hpp #16

Open
DenisCarriere opened this issue Feb 19, 2020 · 0 comments
Open

Remove private logic in .hpp #16

DenisCarriere opened this issue Feb 19, 2020 · 0 comments

Comments

@DenisCarriere
Copy link

Expect your header file to be imported by other smart contracts

I've created a simplified .hpp because your original header file had too much unnecessary overhead

Any logic that is used for private use case should be removed from the header files.

Would be useful to provide both an "advanced" & "basic" .hpp header files (basic wouldn't be used to compile contract, only for importing purposes)

Simple - delphioracle.hpp

#pragma once

#include <eosio/eosio.hpp>
#include <eosio/system.hpp>
#include <eosio/time.hpp>

#include <string>

using namespace eosio;
using namespace std;

class [[eosio::contract("delphioracle")]] delphioracle : public contract {
public:
    using contract::contract;

    [[eosio::action]]
    void set( const eosio::name scope, const uint64_t value );

    //Holds the last datapoints_count datapoints from qualified oracles
    struct [[eosio::table]] datapoints {
        uint64_t id;
        name owner;
        uint64_t value;
        uint64_t median;
        eosio::time_point timestamp;

        uint64_t primary_key() const {return id;}
        uint64_t by_timestamp() const {return timestamp.elapsed.to_seconds();}
        uint64_t by_value() const {return value;}
    };

    typedef eosio::multi_index<"datapoints"_n, datapoints,
        indexed_by<"value"_n, const_mem_fun<datapoints, uint64_t, &datapoints::by_value>>,
        indexed_by<"timestamp"_n, const_mem_fun<datapoints, uint64_t, &datapoints::by_timestamp>>> datapointstable;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant