Skip to content

Commit

Permalink
feat: use witnet-requests package for composing requests
Browse files Browse the repository at this point in the history
fix #4
  • Loading branch information
aesedepece committed Aug 26, 2019
1 parent 217bb27 commit d97fd4e
Show file tree
Hide file tree
Showing 8 changed files with 3,893 additions and 528 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@
"dependencies": {
"cbor": "^4.1.5",
"openzeppelin-solidity": "^2.3.0",
"witnet-ethereum-bridge": "https://github.com/aesedepece/witnet-ethereum-bridge#request-result"
"witnet-ethereum-bridge": "https://github.com/aesedepece/witnet-ethereum-bridge#request-result",
"witnet-requests": "https://github.com/witnet/witnet-requests-js#master"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
"@babel/register": "^7.5.5",
"babel-plugin-inline-script-import": "^0.0.4",
"babel-register": "^6.26.0",
"babel-traverse": "^6.26.0",
"babylon": "^6.18.0",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
Expand Down
39 changes: 14 additions & 25 deletions requests/BitcoinPrice.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import { FILTERS, REDUCERS, Aggregator, Request, Source, Tally } from "rad.js"
import { Aggregator, Request, Source, Tally, Types } from "witnet-requests"
const { FILTERS, REDUCERS } = Types

const coindesk = new Source("https://api.coindesk.com/v1/bpi/currentprice.json")
.asString()
.parseJSON()
.asMap()
.get("bpi")
.asMap()
.get("USD")
.asMap()
.get("rate_float")
.asFloat()
const coindesk = new Source("https://api.coindesk.com/v1/bpi/currentprice.json").asString()
.parseJSON().asMap()
.get("bpi").asMap()
.get("USD").asMap()
.get("rate_float").asFloat()

const blockchain = new Source("https://blockchain.info/ticker")
.asString()
.parseJSON()
.asMap()
.get("USD")
.asMap()
.get("15m")
.asFloat()
const blockchain = new Source("https://blockchain.info/ticker").asString()
.parseJSON().asMap()
.get("USD").asMap()
.get("15m").asFloat()

const bitstamp = new Source("https://www.bitstamp.net/api/ticker/")
.asString()
.parseJSON()
.asMap()
.get("last")
.asFloat()
const bitstamp = new Source("https://www.bitstamp.net/api/ticker/").asString()
.parseJSON().asMap()
.get("last").asFloat()

const aggregator = new Aggregator([coindesk, blockchain, bitstamp])
.flatten()
Expand Down
2 changes: 1 addition & 1 deletion requests/RandomNumber.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request, Source, Tally } from "rad.js"
import { Request, Source, Tally } from "witnet-requests"

const source = new Source("http://qrng.anu.edu.au/API/jsonI.php?length=1&type=uint8")
.asString()
Expand Down
3 changes: 2 additions & 1 deletion requests/Weather.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FILTERS, REDUCERS, TYPES, Request, Script, Source } from "rad.js"
import { Request, Script, Source, Types } from "witnet-requests"
const { FILTERS, REDUCERS, TYPES } = Types

const request = new Request()
.addSource(
Expand Down
3 changes: 3 additions & 0 deletions requests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
281 changes: 0 additions & 281 deletions witnet/lib/rad.js

This file was deleted.

Loading

0 comments on commit d97fd4e

Please sign in to comment.