delphioracle's People
Forkers
deckb maxjarvie threadshare itsn1x vlbos dkimotho vigorstablecoin mmitech greeneosio alohaeos ignatiuszy ekkis dev-resources telosnetwork zhaoyilun ankh2054 eoscodes mewmix sugarfinance manh-vv we-can-dev igorjrmedeiros tlacloc 50shades0fshay minabebawy codingonmycouch eosiogo slumericanafi the-delta-slumerican-organization pinkdiamond1delphioracle's Issues
Unable to write a price
due to the other issue I opened: #10 I commented out the check to try to force a write. now I get another error
cleos push action delphioracle write '{"owner":"dextersysdao", "quotes": [{"value":58500,"pair":"eosusd"}]}' -p dextersysdao@active
Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: pair not allowed
pending console output: length 1quote 0 58500 eosusd
Missing instructions
I need to compile this contract locally for testing purposes. when I call the 'write' method as per the instructions I get the error:
Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: account is not a qualified oracle
pending console output: length 1
but don't find guidance in the README as to how to make me a qualified oracle. help?
- Edit I -
also, in looking through the code I find no references to the producers_table where a write occurs, only when checking for validity (which issues the above error message). so I can't see how a valid producer record is produced. how does this work?
include public static methods
Would be useful to have a public static methods exposed to make it easier to grab the datapoints
get_median
get_value
basic
static uint64_t get_median( const name scope )
{
delphioracle::datapointstable _datapoints( "delphioracle"_n, scope.value );
auto datapoints_itr = _datapoints.begin();
check( datapoints_itr != _datapoints.end(), "cannot iterate over delphioracle");
return datapoints_itr->median;
}
advanced (return asset)
static asset get_median( const name scope, const symbol sym )
{
delphioracle::datapointstable _datapoints( "delphioracle"_n, scope.value );
auto datapoints_itr = _datapoints.begin();
check( datapoints_itr != _datapoints.end(), "cannot iterate over delphioracle");
return asset{ static_cast<int64_t>(datapoints_itr->median), sym };
}
note: the examples were used in .cpp
files, you might need to check if they are valid as public static methods.
How to use externally
Other smart contracts would then be able to pull those methods like so:
#include <delphioracle/delphioracle.hpp>
const uint64_t median = delphioracle::get_median("eosusd"_n);
// or advanced (return asset)
const asset median = delphioracle::get_median("eosusd"_n, symbol{"USD", 4});
improve code
old code <function: update_eosusd_oracle>
//skip first 6 values
auto itr = value_sorted.begin();
itr++;
itr++;
itr++;
itr++;
itr++;
//get next 9 values
for (int i = 0; i<9;i++){
itr++;
avg+=itr->value;
}
I think it's better by this way.
new code
auto itr = value_sorted.begin();
//skip first 6 values
//get next 9 values
for (int i = 0; i<9;i++){
itr++;
if (i>5) {
// skip first 6 values
avg+=itr->value;
}
}
Remove private logic in .hpp
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;
};
EOS_CHAIN?
I've done the install in scripts/
but in looking at the .env
I need to replace some values. what do I use for EOS_CHAIN when I'm running against localhost?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.