You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got errors when trying to compile the query script
witnet/EthPrice.js content:
import * as Witnet from "witnet-requests"
const binance = new Witnet.Source("https://api.binance.US/api/v3/trades?symbol=ETHUSD")
.parseJSONMap()
.getFloat("price")
.multiply(10 ** 6)
.round()
const coinbase = new Witnet.Source("https://api.coinbase.com/v2/exchange-rates?currency=ETH")
.parseJSONMap()
.getMap("data")
.getMap("rates")
.getFloat("USD")
.multiply(10 ** 6)
.round()
const kraken = new Witnet.Source("https://api.kraken.com/0/public/Ticker?pair=ETHUSD")
.parseJSONMap()
.getMap("result")
.getMap("XETHZUSD")
.getArray("a")
.getFloat(0)
.multiply(10 ** 6)
.round()
const aggregator = Witnet.Aggregator.deviationAndMean(1.5)
const tally = Witnet.Tally.deviationAndMean(2.5)
const query = new Witnet.Query()
.addSource(binance)
.addSource(coinbase)
.addSource(kraken)
.setAggregator(aggregator) // Set the aggregator function
.setTally(tally) // Set the tally function
.setQuorum(10, 51) // Set witness count and minimum consensus percentage
.setFees(5 * 10 ** 9, 10 ** 9) // Witnessing nodes will be rewarded 5 $WIT each
.setCollateral(50 * 10 ** 9) // Require each witness node to stake 50 $WIT
// Do not forget to export the query object
export { query as default }
Here is output
/Users/user/.nvm/versions/node/v18.20.0/bin/yarn run witnet:compile
yarn run v1.22.22
$ rad2sol --verbose --write-contracts
Compiling your Witnet queries...
=================================
> Compiling /Users/user/IdeaProjects/DWFG/contract/witnet/EthPrice.js
! WITNET REQUESTS COMPILATION ERRORS:
- Cannot read properties of undefined (reading 'dataPointType')
/Users/user/IdeaProjects/DWFG/contract/node_modules/witnet-requests/dist/lib/rad2sol/steps.js:127
console.log(" - The result type of the query is \x1B[36m".concat(Witnet.Types.typeFormat(query.dataPointType), "\x1B[0m"));
^
TypeError: Cannot read properties of undefined (reading 'dataPointType')
at execute (/Users/user/IdeaProjects/DWFG/contract/node_modules/witnet-requests/dist/lib/rad2sol/steps.js:127:101)
at /Users/user/IdeaProjects/DWFG/contract/node_modules/witnet-requests/dist/lib/rad2sol/scripts.js:30:31
at /Users/user/IdeaProjects/DWFG/contract/node_modules/witnet-requests/dist/bin/rad2sol.js:60:14
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 0)
Node.js v18.20.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Process finished with exit code 1
var query = vm.runInContext(code, context, __dirname);
console.log(" - The result type of the query is \x1B[36m".concat(Witnet.Types.typeFormat(query.dataPointType), "\x1B[0m"));
The text was updated successfully, but these errors were encountered:
I got errors when trying to compile the query script
witnet/EthPrice.js
content:Here is output
I try to debug and see
vm.runInContext(code, context, __dirname)
returns undefined insteps.js:126
https://github.com/witnet/witnet-requests-js/blob/0.9.12/src/lib/rad2sol/steps.js#L107-L108
The text was updated successfully, but these errors were encountered: