Skip to content

Commit

Permalink
fix: wpf bypass 0.7 -> 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Dec 4, 2024
1 parent 5e6128a commit c07e1ff
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
18 changes: 16 additions & 2 deletions contracts/impls/apps/WitnetPriceFeedsBypassV20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ contract WitnetPriceFeedsBypassV20
WitnetUpgradableBase
{
using Witnet for bytes4;
using WitnetV2 for WitnetV2.RadonSLA;

WitnetPriceFeedsV20 immutable public surrogate;

constructor (
Expand Down Expand Up @@ -143,10 +145,22 @@ contract WitnetPriceFeedsBypassV20
// ================================================================================================================
// --- Partial interception of 'IWitnetFeeds' ---------------------------------------------------------------------

function defaultRadonSLA()
public view
returns (Witnet.RadonSLA memory)
{
return abi.decode(
_staticcall(abi.encodeWithSignature(
"defaulRadonSLA()"
)),
(WitnetV2.RadonSLA)
).toV1();
}

function estimateUpdateBaseFee(bytes4, uint256 _gasPrice, uint256) public view returns (uint256) {
return abi.decode(
_staticcall(abi.encodeWithSignature(
"estimateUpdateBaseFee(uint256)",
"estimateUpdateUpdateRequestFee(uint256)",
_gasPrice
)),
(uint256)
Expand All @@ -156,7 +170,7 @@ contract WitnetPriceFeedsBypassV20
function estimateUpdateBaseFee(bytes4, uint256 _gasPrice, uint256, bytes32) external view returns (uint256) {
return abi.decode(
_staticcall(abi.encodeWithSignature(
"estimateUpdateBaseFee(uint256)",
"estimateUpdateUpdateRequestFee(uint256)",
_gasPrice
)),
(uint256)
Expand Down
36 changes: 36 additions & 0 deletions migrations/ops/drs/err/1_ops_drs_err.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const addresses = require("../../../witnet.addresses")
const utils = require("../../../../scripts/utils")

const WitnetRequestBoard = artifacts.require("WitnetRequestBoard")

module.exports = async function (_deployer, network, [,, reporter]) {
const [realm, chain] = utils.getRealmNetworkFromString(network.split("-")[0])

const wrb = await WitnetRequestBoard.at(addresses[realm][chain].WitnetRequestBoard)
console.log("> WitnetRequestBoard address:", wrb.address)

let queryId = parseInt(await wrb.getNextQueryId()) - 1
process.argv.forEach((argv, index, args) => {
if (argv === "--query") {
queryId = args[index + 1]
}
})

const query = await wrb.getQueryData(queryId)
console.log(`Query #${queryId}:\n${query}`)
if (
query?.response.drTxHash === "0x0000000000000000000000000000000000000000000000000000000000000000"
) {
console.log(`\n> Reporting failure onto query #${queryId}...`)
const tx = await wrb.methods["reportResult(uint256,bytes32,bytes)"](
queryId,
"0x" + utils.padLeft("deadbeaf", "0, 64"),
"0xd8278118E1",
{ from: reporter }
)
console.log(tx)
} else {
console.log(`\n> Query #${query} already reported:`)
console.log(query)
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"fmt": "npm run fmt:js && npm run fmt:sol",
"migrate": "node ./scripts/migrate.js 2>&1",
"networks": "node ./scripts/networks.js 2>&1",
"ops:drs:err": "truffle migrate --compile-none --migrations_directory ./migrations/ops/drs/err --network",
"ops:rng:sla": "truffle migrate --migrations_directory ./migrations/ops/rng/sla --network",
"test": "npm run clean && truffle test"
},
Expand Down Expand Up @@ -63,6 +64,6 @@
"truffle": "~5.11.5",
"truffle-assertions": "0.9.2",
"truffle-flattener": "~1.6.0",
"truffle-plugin-verify": "~0.6.2"
"truffle-plugin-verify": "^0.6.7"
}
}

0 comments on commit c07e1ff

Please sign in to comment.