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

Chore: Prepare branch bound to WSB 2.1.x #30

Open
wants to merge 11 commits into
base: 2.1.x
Choose a base branch
from
Open
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "witnet-solidity",
"version": "2.0.3",
"version": "2.1.0-beta.0",
"description": "Witnet CLI import module for Solidity projects",
"author": "Witnet Foundation",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/witnet/witnet-solidity/tree/2.0"
"url": "https://github.com/witnet/witnet-solidity/"
},
"private": false,
"type": "commonjs",
Expand Down Expand Up @@ -46,8 +46,8 @@
"dotenv": "^16.4.1",
"inquirer": "^8.0.0",
"truffle": "^5.11.5",
"witnet-solidity-bridge": "../witnet-solidity-bridge",
"witnet-toolkit": "../witnet-toolkit"
"witnet-solidity-bridge": "2.1.0-beta.0",
"witnet-toolkit": "^2.0.9"
},
"devDependencies": {
"cbor": "^9.0.2",
Expand Down
50 changes: 25 additions & 25 deletions src/bin/witnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function showMainUsage () {
console.info(" ", "deploy", "\t\t=>", "Deploy Witnet requests and templates defined within the witnet/assets/ folder.")
console.info(" ", "ethrpc", "\t\t=>", "Run a local ETH/RPC gateway to the specified chain.")
console.info(" ", "test", "\t\t=>", "Dry-run requests and templates defined within the witnet/assets/ folder.")
console.info(" ", "wizard", "\t\t=>", "Helps you to integrate the Witnet Oracle within your smart contracts.")
console.info(" ", "wizard", "\t\t=>", "Helps you to integrate the Wit/Oracle blockchain within your smart contracts.")
}

function showAvailUsage () {
Expand Down Expand Up @@ -480,7 +480,7 @@ async function wizard () {
...await inquirer.prompt({
type: "list",
name: "callbacks",
message: "How would you like your contract to read data from the Witnet Oracle?",
message: "How would you like your contract to read data from the Wit/Oracle blockchain?",
choices: [
"Asynchronously => my contract will eventually read the result from Witnet, when available.",
"Synchronously => my contract is to be called as soon as data is reported from Witnet.",
Expand Down Expand Up @@ -539,11 +539,11 @@ async function wizard () {
...answers,
}
const artifact = (appKind === "Price"
? "WitnetPriceFeeds"
? "WitPriceFeeds"
: answers?.randomness?.split(" ")[0] === "Yes"
? "WitnetRandomnessV2"
: (
"WitnetOracle"
"WitOracle"
)
)
const findings = []
Expand All @@ -564,7 +564,7 @@ async function wizard () {
throw Error(`Sorry, required ${artifact} contract is not available on selected ecosystems: ${answers?.ecosystems}`)
}
} else {
importWitnetMocks = "\nimport \"witnet-solidity-bridge/contracts/mocks/WitnetMockedOracle.sol\";"
importWitnetMocks = "\nimport \"witnet-solidity-bridge/contracts/mocks/WitMockedOracle.sol\";"
}
}

Expand Down Expand Up @@ -604,46 +604,46 @@ async function wizard () {
templateFile += "_UsingRandomness.tsol"
} else {
if (!answers?.witnetAddress) {
constructorParams = "WitnetOracle _witnetOracle"
witnetAddress = "_witnetOracle"
constructorParams = "WitOracle _witOracle"
witnetAddress = "_witOracle"
} else {
witnetAddress = `WitnetOracle(${answers.witnetAddress})`
witnetAddress = `WitOracle(${answers.witnetAddress})`
}
templateFile += "_RandomnessRequestConsumer.tsol"
}
break
}
case "Price": {
if (!answers?.witnetAddress) {
constructorParams = "WitnetPriceFeeds _witnetPriceFeeds"
constructorParams = "WitPriceFeeds _witnetPriceFeeds"
witnetAddress = "_witnetPriceFeeds"
} else {
witnetAddress = `WitnetPriceFeeds(${answers.witnetAddress})`
witnetAddress = `WitPriceFeeds(${answers.witnetAddress})`
}
templateFile += "_UsingPriceFeeds.tsol"
break
}
case "Public": {
if (answers?.dynamic.split(" ")[0] === "Yes") {
if (answers.parameterized.split(" ")[0] === "Yes") {
constructorParams = "WitnetRequestTemplate _witnetRequestTemplate"
witnetAddress = "_witnetRequestTemplate"
constructorParams = "WitOracleRequestTemplate _witOracleRequestTemplate"
witnetAddress = "_witOracleRequestTemplate"
templateFile += (answers?.callbacks.split(" ")[0] === "Synchronously"
? "_RequestTemplateConsumer.tsol"
: "_UsingRequestTemplate.tsol"
)
} else {
if (!answers?.witnetAddress) {
constructorParams = "WitnetOracle _witnetOracle"
witnetAddress = "_witnetOracle"
constructorParams = "WitOracle _witOracle"
witnetAddress = "_witOracle"
} else {
witnetAddress = `WitnetOracle(${answers.witnetAddress})`
witnetAddress = `WitOracle(${answers.witnetAddress})`
}
templateFile += "_Consumer.tsol"
}
} else {
constructorParams = "WitnetRequest _witnetRequest"
witnetAddress = "_witnetRequest"
constructorParams = "WitOracleRequest _witOracleRequest"
witnetAddress = "_witOracleRequest"
templateFile += (answers?.callbacks.split(" ")[0] === "Synchronously"
? "_RequestConsumer.tsol"
: "_UsingRequest.tsol"
Expand Down Expand Up @@ -757,17 +757,17 @@ function _traceWitnetArtifact (artifact) {
if (specs.retrieve[0]?.argsCount) {
if (!args || args.length === 0) {
console.info(" ", `[1] RETRIEVE:\t\x1b[1;32m${
utils.getWitnetRequestMethodString(specs.retrieve[0].method)
utils.getWitOracleRequestMethodString(specs.retrieve[0].method)
}(\x1b[0;32m<${
specs.retrieve[0].argsCount
} args>\x1b[1;32m)\x1b[0m`
)
} else {
// eslint-disable-next-line
console.info(" ", `[1] RETRIEVE:\t\x1b[1;32m${utils.getWitnetRequestMethodString(specs.retrieve[0].method)}(\x1b[0;32m${JSON.stringify(args[0])}\x1b[1;32m\x1b[0m`)
console.info(" ", `[1] RETRIEVE:\t\x1b[1;32m${utils.getWitOracleRequestMethodString(specs.retrieve[0].method)}(\x1b[0;32m${JSON.stringify(args[0])}\x1b[1;32m\x1b[0m`)
}
} else {
console.info(" ", `[1] RETRIEVE:\t\x1b[1;32m${utils.getWitnetRequestMethodString(specs.retrieve[0].method)}()\x1b[0m`)
console.info(" ", `[1] RETRIEVE:\t\x1b[1;32m${utils.getWitOracleRequestMethodString(specs.retrieve[0].method)}()\x1b[0m`)
}
} else {
console.info(" ", "[1] RETRIEVE:")
Expand All @@ -777,14 +777,14 @@ function _traceWitnetArtifact (artifact) {
if (value?.argsCount) {
if (!args[index] || args[index].length === 0) {
// eslint-disable-next-line
console.info(" ", ` [#${index}]\t\t\x1b[1;32m${utils.getWitnetRequestMethodString(value.method)}(\x1b[0;32m<${value.argsCount} args>\x1b[1;32m)\x1b[0m`)
console.info(" ", ` [#${index}]\t\t\x1b[1;32m${utils.getWitOracleRequestMethodString(value.method)}(\x1b[0;32m<${value.argsCount} args>\x1b[1;32m)\x1b[0m`)
} else {
// eslint-disable-next-line
console.info(" ", ` [#${index}]\t\t\x1b[1;32m${utils.getWitnetRequestMethodString(value.method)}(\x1b[0;32m${JSON.stringify(args[index])}\x1b[1;32m)\x1b[0m`)
console.info(" ", ` [#${index}]\t\t\x1b[1;32m${utils.getWitOracleRequestMethodString(value.method)}(\x1b[0;32m${JSON.stringify(args[index])}\x1b[1;32m)\x1b[0m`)
}
} else {
// eslint-disable-next-line
console.info(" ", ` [#${index}]\t\t\x1b[1;32m${utils.getWitnetRequestMethodString(value.method)}()\x1b[0m`)
console.info(" ", ` [#${index}]\t\t\x1b[1;32m${utils.getWitOracleRequestMethodString(value.method)}()\x1b[0m`)
}
}
_traceWitnetArtifactSource(value)
Expand Down Expand Up @@ -862,9 +862,9 @@ function _traceWitnetSource (value) {
if (value?.method) {
if (value?.argsCount) {
// eslint-disable-next-line
console.info(" ", `> Method: \x1b[1;32m${utils.getWitnetRequestMethodString(value.method)}(\x1b[0;32m<${value.argsCount} args>\x1b[1;32m)\x1b[0m`)
console.info(" ", `> Method: \x1b[1;32m${utils.getWitOracleRequestMethodString(value.method)}(\x1b[0;32m<${value.argsCount} args>\x1b[1;32m)\x1b[0m`)
} else {
console.info(" ", `> Method: \x1b[1;32m${utils.getWitnetRequestMethodString(value.method)}()\x1b[0m`)
console.info(" ", `> Method: \x1b[1;32m${utils.getWitOracleRequestMethodString(value.method)}()\x1b[0m`)
}
if (value?.url) {
console.info(" ", `> URL: \x1b[32m${value.url}\x1b[0m`)
Expand Down
8 changes: 4 additions & 4 deletions witnet/assets/_requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ const templates = Witnet.Dictionary(
module.exports = {
/// //// STATIC REQUESTS /////////////////////////////////////////////////////////
// path: { ... path: {
// WitnetRequestXXX: Witnet.StaticRequest({
// WitOracleRequestXXX: Witnet.StaticRequest({
// retrieve: [ Witnet.Sources.., ..., sources['source-name-x'], ... ],
// aggregate?: Witnet.Reducers..,
// tally?: Witnet.Reducers..,
// }),
/// /// REQUESTS FROM TEMPLATE ///////////////////////////////////////////////////
// WitnetRequestYYY: Witnet.RequestFromTemplate(
// templates['WitnetRequestTemplateUniqueNameX'],
// WitOracleRequestYYY: Witnet.RequestFromTemplate(
// templates['WitOracleRequestTemplateUniqueNameX'],
// [ [ .. ], .. ], // args: string[][]
// ),
/// /// REQUESTS FROM RETRIEVALS DICTIONARY //////////////////////////////////////
// WitnetRequestZZZ: Witnet.RequestFromDictionary({
// WitOracleRequestZZZ: Witnet.RequestFromDictionary({
// retrieve: {
// dict: sources,
// tags: {
Expand Down
2 changes: 1 addition & 1 deletion witnet/assets/_templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const sources = Witnet.Dictionary(
module.exports = {
/// //// REQUEST TEMPLATES ///////////////////////////////////////////////////////
// path: { ... path: {
// WitnetRequestTemplateXXX: Witnet.RequestTemplate({
// WitOracleRequestTemplateXXX: Witnet.RequestTemplate({
// retrieve: [ sources['source-name-x'], ... ],
// aggregate?: Witnet.Reducers..,
// tally?: Witnet.Reducers..,
Expand Down
4 changes: 2 additions & 2 deletions witnet/assets/requests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Witnet = require("witnet-toolkit")

module.exports = {
legacy: {
WitnetRequestPriceUsdtWit9: Witnet.StaticRequest({
WitOracleRequestPriceUsdtWit9: Witnet.StaticRequest({
retrieve: [
Witnet.Sources.HttpGet({
url: "https://api-cloud.bitmart.com/spot/v1/ticker?symbol=WIT_USDT",
Expand Down Expand Up @@ -40,7 +40,7 @@ module.exports = {
aggregate: Witnet.Reducers.Median(Witnet.Filters.Stdev(1.4)),
tally: Witnet.Reducers.PriceTally(),
}),
WitnetRequestRandomness: Witnet.StaticRequest({
WitOracleRequestRandomness: Witnet.StaticRequest({
retrieve: [Witnet.Sources.RNG()],
tally: Witnet.Reducers.ConcatHash(),
}),
Expand Down
27 changes: 13 additions & 14 deletions witnet/assets/templates/ccdr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,45 @@ const sources = Witnet.Dictionary(
)

module.exports = {
WitnetRequestTemplateEthBlockNumber: Witnet.RequestTemplate({
WitOracleRequestTemplateEthBlockNumber: Witnet.RequestTemplate({
retrieve: sources["eth-block-number"],
tests: {
"get block number from sepolia works": [
"https://provider-url",
"https://worldchain-mainnet.g.alchemy.com/public",
],
},
}),
WitnetRequestTemplateEthGasPrice: Witnet.RequestTemplate({
WitOracleRequestTemplateEthGasPrice: Witnet.RequestTemplate({
retrieve: sources["eth-gas-price"],
tests: {
"get balance from sepolia works": [
"https://provider-url",
"https://worldchain-mainnet.g.alchemy.com/public",
],
},
}),
WitnetRequestTemplateEthTransactionByHash: Witnet.RequestTemplate({
WitOracleRequestTemplateEthTransactionByHash: Witnet.RequestTemplate({
retrieve: sources["eth-get-transaction-by-hash"],
tests: {
"get transaction by hash from sepolia works": [
"https://provider-url",
"transaction-hash",
"https://worldchain-mainnet.g.alchemy.com/public",
"0xee0a762f4d76f824cd5e7d10fe86ff6c57e8bebf1aab6047be99ac27fe38bfd9",
],
},
}),
WitnetRequestTemplateWitSupplyInfo: Witnet.RequestTemplate({
WitOracleRequestTemplateWitSupplyInfo: Witnet.RequestTemplate({
retrieve: sources["wit-supply-info"],
tests: {
"get Witnet supply info": [
"https://provider-url",
"transaction-hash",
"get witnet supply info": [
"http://3.133.4.38:21339",
],
},
}),
WitnetRequestTemplateWitTransactionByHash: Witnet.RequestTemplate({
WitOracleRequestTemplateWitTransactionByHash: Witnet.RequestTemplate({
retrieve: sources["wit-get-transaction-by-hash"],
tests: {
"get transaction by hash from witnet works": [
"https://provider-url",
"transaction-hash",
"http://3.133.4.38:21339",
"c40ecb835212dfe64feeebb5493fc49066d5207f28372672b219ca43fda08e7d",
],
},
}),
Expand Down
8 changes: 4 additions & 4 deletions witnet/contracts/Witnet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity ^0.8.0;

// Witnet Requests deployment dependencies:
import "witnet-solidity-bridge/contracts/apps/UsingWitnet.sol";
import "witnet-solidity-bridge/contracts/WitnetPriceFeeds.sol";
import "witnet-solidity-bridge/contracts/mockups/UsingWitOracle.sol";
import "witnet-solidity-bridge/contracts/WitPriceFeeds.sol";

// Witnet mocking contracts (only for local/unitary testing):
import "witnet-solidity-bridge/contracts/mocks/WitnetMockedOracle.sol";
import "witnet-solidity-bridge/contracts/mocks/WitnetMockedPriceFeeds.sol";
import "witnet-solidity-bridge/mockups/tests/WitMockedOracle.sol";
import "witnet-solidity-bridge/mockups/tests/WitMockedPriceFeeds.sol";
Loading