Skip to content

Instantly share code, notes, and snippets.

@veox
Last active October 16, 2018 16:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veox/e70364eca986fa56fff0afd5c946b8f7 to your computer and use it in GitHub Desktop.
Save veox/e70364eca986fa56fff0afd5c946b8f7 to your computer and use it in GitHub Desktop.
Get basic info on specific Augur fee/dispute window, based on time[stamp]
// get fee window info based on timestamp
// date (EDIT to change)
var dat = 'Wed, 05 Sep 2018 13:37:00 UTC';
// universe (EDIT to change)
var uni = "0xe991247b78f937d7b69cfc00f1a487a293557677";
var Augur = require("augur.js");
var augur = new Augur();
// https://coderwall.com/p/rbfl6g/how-to-get-the-correct-unix-timestamp-from-any-date-in-javascript
Date.prototype.getUnixTime = function() { return this.getTime()/1000|0 };
if(!Date.now) Date.now = function() { return new Date(); }
Date.time = function() { return Date.now().getUnixTime(); }
// date/time within a fee/dispute window
var parsedUnixTime = new Date(dat).getUnixTime();
var ts = augur.utils.convertBigNumberToHexString(parsedUnixTime);
var ethereumNode = { http: "http://127.0.0.1:8545", ws: "ws://127.0.0.1:8546" };
var augurNode = "ws://127.0.0.1:9001";
augur.connect({ ethereumNode, augurNode }, (err, connectionInfo) => {
augur.api.Universe.getFeeWindowByTimestamp({
_timestamp: ts,
tx: { to: uni },
}, function (error, result) {
augur.augurNode.submitRequest(
"getFeeWindow",
{
universe: uni,
feeWindow: result,
},
function(error, result) {
console.log(result);
}
);
});
});
augur-experiments% node ./fee-window.js
connecting to augur-node: ws://127.0.0.1:9001
connecting to ethereum-node: {"http":"http://127.0.0.1:8545","ws":"ws://127.0.0.1:8546"}
websocket ws://127.0.0.1:9001 opened
connected to augur
websocket ws://127.0.0.1:8546 opened
connected to ethereum
[ethrpc] eth_subscribe request failed, fall back to polling for blocks: Couldn't parse parameters: newHeads
{ feeWindowEthFees: '121990051869599',
feeWindowRepStaked: '411153987339564732435',
endTime: 1536192000,
feeWindow: '0x3c3d83f340eed2e41687da063d4ec21fa1fae687',
feeWindowId: 2539,
startTime: 1535587200,
universe: '0xe991247b78f937d7b69cfc00f1a487a293557677',
feeToken: '0x7d5f95ae3bf9470d154c3cbde22c55b1df295173' }
^C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment