@witnet/solidity 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/build/contracts/Bech32.json +1 -1
- package/build/contracts/Clonable.json +1 -1
- package/build/contracts/Context.json +1 -1
- package/build/contracts/Create3.json +1 -1
- package/build/contracts/ERC165.json +1 -1
- package/build/contracts/Escrowable.json +1 -1
- package/build/contracts/IChainlinkAggregatorV3.json +1 -1
- package/build/contracts/IERC165.json +1 -1
- package/build/contracts/IERC20.json +1 -1
- package/build/contracts/IERC2362.json +1 -1
- package/build/contracts/IPythChainlinkAggregatorV3.json +1 -1
- package/build/contracts/IWitAppliance.json +1 -1
- package/build/contracts/IWitOracle.json +1 -1
- package/build/contracts/IWitOracleAppliance.json +1 -1
- package/build/contracts/IWitOracleConsumer.json +1 -1
- package/build/contracts/IWitOracleConsumerLegacy.json +1 -1
- package/build/contracts/IWitOracleLegacy.json +1 -1
- package/build/contracts/IWitOracleQueriable.json +1 -1
- package/build/contracts/IWitOracleQueriableConsumer.json +1 -1
- package/build/contracts/IWitOracleQueriableEvents.json +1 -1
- package/build/contracts/IWitOracleQueriableExperimental.json +1 -1
- package/build/contracts/IWitOracleQueriableTrustableReporter.json +1 -1
- package/build/contracts/IWitOracleQueriableTrustlessReporter.json +1 -1
- package/build/contracts/IWitOracleRadonRegistry.json +1 -1
- package/build/contracts/IWitOracleRadonRegistryEvents.json +1 -1
- package/build/contracts/IWitOracleRadonRegistryLegacy.json +1 -1
- package/build/contracts/IWitOracleRadonRequestFactory.json +1 -1
- package/build/contracts/IWitOracleRadonRequestModal.json +1 -1
- package/build/contracts/IWitOracleRadonRequestTemplate.json +1 -1
- package/build/contracts/IWitOracleRequest.json +1 -1
- package/build/contracts/IWitOracleRequestFactory.json +1 -1
- package/build/contracts/IWitOracleRequestFactoryEvents.json +1 -1
- package/build/contracts/IWitOracleRequestTemplate.json +1 -1
- package/build/contracts/IWitOracleTrustableAdmin.json +1 -1
- package/build/contracts/IWitOracleTrustless.json +1 -1
- package/build/contracts/IWitPriceFeeds.json +1 -1
- package/build/contracts/IWitPriceFeedsAdmin.json +1 -1
- package/build/contracts/IWitPriceFeedsConsumer.json +1 -1
- package/build/contracts/IWitPriceFeedsEvents.json +1 -1
- package/build/contracts/IWitPriceFeedsLegacy.json +1 -1
- package/build/contracts/IWitPriceFeedsLegacyAdmin.json +1 -1
- package/build/contracts/IWitPriceFeedsLegacySolver.json +1 -1
- package/build/contracts/IWitPriceFeedsLegacySolverFactory.json +1 -1
- package/build/contracts/IWitPriceFeedsTypes.json +1 -1
- package/build/contracts/IWitPyth.json +1 -1
- package/build/contracts/IWitPythChainlinkAggregator.json +1 -1
- package/build/contracts/IWitPythErrors.json +1 -1
- package/build/contracts/IWitPythEvents.json +1 -1
- package/build/contracts/IWitPythReporter.json +1 -1
- package/build/contracts/IWitRandomness.json +1 -1
- package/build/contracts/IWitRandomnessAdmin.json +1 -1
- package/build/contracts/IWitRandomnessAdminV2.json +1 -1
- package/build/contracts/IWitRandomnessConsumer.json +1 -1
- package/build/contracts/IWitRandomnessEvents.json +1 -1
- package/build/contracts/IWitRandomnessLegacy.json +1 -1
- package/build/contracts/IWitRandomnessTypes.json +1 -1
- package/build/contracts/Initializable.json +1 -1
- package/build/contracts/OVM_GasPriceOracle.json +1 -1
- package/build/contracts/Ownable.json +1 -1
- package/build/contracts/Ownable2Step.json +1 -1
- package/build/contracts/Payable.json +1 -1
- package/build/contracts/Proxiable.json +1 -1
- package/build/contracts/ReentrancyGuard.json +1 -1
- package/build/contracts/Secp256k1.json +1 -1
- package/build/contracts/Slices.json +1 -1
- package/build/contracts/TestBech32.json +1 -1
- package/build/contracts/TestSecp256k1.json +1 -1
- package/build/contracts/Upgradeable.json +1 -1
- package/build/contracts/UsingWitOracle.json +1 -1
- package/build/contracts/UsingWitPriceFeeds.json +1 -1
- package/build/contracts/UsingWitRandomness.json +1 -1
- package/build/contracts/WitOracle.json +2 -13
- package/build/contracts/WitOracleBasePushOnly.json +1 -1
- package/build/contracts/WitOracleBasePushOnlyTrustable.json +1 -1
- package/build/contracts/WitOracleBasePushOnlyTrustless.json +1 -1
- package/build/contracts/WitOracleBasePushOnlyUpgradable.json +1 -1
- package/build/contracts/WitOracleBaseQueriable.json +1 -1
- package/build/contracts/WitOracleBaseQueriableTrustable.json +1 -1
- package/build/contracts/WitOracleBaseQueriableTrustless.json +1 -1
- package/build/contracts/WitOracleBaseQueriableUpgradable.json +1 -1
- package/build/contracts/WitOracleDataLib.json +2 -254
- package/build/contracts/WitOraclePushOnly.json +1 -1
- package/build/contracts/WitOracleRadonEncodingLib.json +2 -13
- package/build/contracts/WitOracleRadonRegistry.json +2 -13
- package/build/contracts/WitOracleRadonRegistryBase.json +1 -1
- package/build/contracts/WitOracleRadonRegistryBaseUpgradable.json +1 -1
- package/build/contracts/WitOracleRadonRegistryData.json +1 -1
- package/build/contracts/WitOracleRadonRegistryDefaultV21.json +1 -1
- package/build/contracts/WitOracleRadonRegistryUpgradableDefault.json +2 -17
- package/build/contracts/WitOracleRadonRegistryUpgradableNoSha256.json +1 -1
- package/build/contracts/WitOracleRadonRegistryUpgradableZkSync.json +1 -1
- package/build/contracts/WitOracleRadonRequestFactory.json +2 -13
- package/build/contracts/WitOracleRadonRequestFactoryBase.json +1 -1
- package/build/contracts/WitOracleRadonRequestFactoryBaseUpgradable.json +1 -1
- package/build/contracts/WitOracleRadonRequestFactoryModals.json +2 -13
- package/build/contracts/WitOracleRadonRequestFactoryModalsDefault.json +2 -13
- package/build/contracts/WitOracleRadonRequestFactoryTemplates.json +2 -13
- package/build/contracts/WitOracleRadonRequestFactoryTemplatesDefault.json +2 -13
- package/build/contracts/WitOracleRadonRequestFactoryUpgradableConfluxCore.json +1 -1
- package/build/contracts/WitOracleRadonRequestFactoryUpgradableDefault.json +2 -13
- package/build/contracts/WitOracleResultStatusLib.json +2 -14
- package/build/contracts/WitOracleTrustableDefault.json +2 -259
- package/build/contracts/WitOracleTrustableExperimental.json +1 -1
- package/build/contracts/WitOracleTrustableObscuro.json +1 -1
- package/build/contracts/WitOracleTrustableOvm2.json +1 -1
- package/build/contracts/WitOracleTrustablePushOnly.json +1 -1
- package/build/contracts/WitOracleTrustableReef.json +1 -1
- package/build/contracts/WitOracleTrustableZkSync.json +1 -1
- package/build/contracts/WitOracleTrustlessDataLib.json +1 -1
- package/build/contracts/WitOracleTrustlessDefaultV22.json +1 -1
- package/build/contracts/WitOracleTrustlessUpgradableDefault.json +1 -1
- package/build/contracts/WitPriceFeeds.json +2 -13
- package/build/contracts/WitPriceFeedsDataLib.json +2 -14
- package/build/contracts/WitPriceFeedsLegacy.json +2 -8
- package/build/contracts/WitPriceFeedsLegacyDataLib.json +2 -84
- package/build/contracts/WitPriceFeedsLegacyUpgradable.json +1 -1
- package/build/contracts/WitPriceFeedsLegacyUpgradableBypass.json +2 -80
- package/build/contracts/WitPriceFeedsSolverBase.json +1 -1
- package/build/contracts/WitPriceFeedsV3.json +1 -1
- package/build/contracts/WitPriceFeedsV3Upgradable.json +2 -17
- package/build/contracts/WitPythChainlinkAggregator.json +1 -1
- package/build/contracts/WitRandomness.json +2 -13
- package/build/contracts/WitRandomnessLegacy.json +1 -1
- package/build/contracts/WitRandomnessV3.json +2 -13
- package/build/contracts/WitRngConsumer.json +1 -1
- package/build/contracts/Witnet.json +1 -1
- package/build/contracts/WitnetBuffer.json +1 -1
- package/build/contracts/WitnetCBOR.json +1 -1
- package/build/contracts/WitnetDeployer.json +2 -13
- package/build/contracts/WitnetDeployerConfluxCore.json +1 -1
- package/build/contracts/WitnetDeployerDeferred.json +1 -1
- package/build/contracts/WitnetDeployerMeter.json +1 -1
- package/build/contracts/WitnetProxy.json +2 -9
- package/build/contracts/WitnetUpgradableBase.json +1 -1
- package/{migrations → dist/migrations}/addresses.json +1 -25
- package/{migrations → dist/migrations}/constructorArgs.json +1 -6
- package/dist/migrations/settings/artifacts.d.ts +95 -0
- package/dist/migrations/settings/artifacts.d.ts.map +1 -0
- package/dist/migrations/settings/artifacts.js +80 -0
- package/dist/migrations/settings/networks.d.ts +593 -0
- package/dist/migrations/settings/networks.d.ts.map +1 -0
- package/dist/migrations/settings/networks.js +593 -0
- package/dist/src/bin/helpers.cjs +350 -0
- package/dist/src/bin/helpers.d.cts +76 -0
- package/dist/src/bin/helpers.d.cts.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +33 -0
- package/dist/src/lib/types.d.ts +99 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/dist/src/lib/types.js +18 -0
- package/dist/src/lib/utils.d.ts +22 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/lib/utils.js +267 -0
- package/dist/src/lib/wrappers/ContractWrapper.d.ts +47 -0
- package/dist/src/lib/wrappers/ContractWrapper.d.ts.map +1 -0
- package/dist/src/lib/wrappers/ContractWrapper.js +81 -0
- package/dist/src/lib/wrappers/WitAppliance.d.ts +7 -0
- package/dist/src/lib/wrappers/WitAppliance.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitAppliance.js +17 -0
- package/dist/src/lib/wrappers/WitArtifact.d.ts +6 -0
- package/dist/src/lib/wrappers/WitArtifact.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitArtifact.js +16 -0
- package/dist/src/lib/wrappers/WitOracle.d.ts +105 -0
- package/dist/src/lib/wrappers/WitOracle.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitOracle.js +217 -0
- package/dist/src/lib/wrappers/WitOracleConsumer.d.ts +16 -0
- package/dist/src/lib/wrappers/WitOracleConsumer.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitOracleConsumer.js +30 -0
- package/dist/src/lib/wrappers/WitOracleRadonRegistry.d.ts +102 -0
- package/dist/src/lib/wrappers/WitOracleRadonRegistry.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitOracleRadonRegistry.js +140 -0
- package/dist/src/lib/wrappers/WitOracleRadonRequestFactory.d.ts +81 -0
- package/dist/src/lib/wrappers/WitOracleRadonRequestFactory.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitOracleRadonRequestFactory.js +257 -0
- package/dist/src/lib/wrappers/WitPriceFeeds.d.ts +91 -0
- package/dist/src/lib/wrappers/WitPriceFeeds.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitPriceFeeds.js +356 -0
- package/dist/src/lib/wrappers/WitPriceFeedsLegacy.d.ts +14 -0
- package/dist/src/lib/wrappers/WitPriceFeedsLegacy.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitPriceFeedsLegacy.js +64 -0
- package/dist/src/lib/wrappers/WitRandomness.d.ts +55 -0
- package/dist/src/lib/wrappers/WitRandomness.d.ts.map +1 -0
- package/dist/src/lib/wrappers/WitRandomness.js +165 -0
- package/dist/src/lib/wrappers.d.ts +8 -0
- package/dist/src/lib/wrappers.d.ts.map +1 -0
- package/dist/src/lib/wrappers.js +8 -0
- package/package.json +78 -54
- package/scripts/clean.cjs +21 -0
- package/scripts/eth-create2.cjs +38 -0
- package/scripts/eth-create3.cjs +45 -0
- package/scripts/postinstall.cjs +9 -0
- package/scripts/prepare.cjs +27 -0
- package/scripts/vanity2gen.cjs +121 -0
- package/scripts/vanity3gen.cjs +84 -0
- package/scripts/verify-proxies.cjs +50 -0
- package/scripts/verify-truffle.cjs +69 -0
- package/scripts/verify.js +95 -0
- package/scripts/wof-acls.js +17 -0
- package/src/bin/bots/bridge.cjs +0 -0
- package/src/bin/bots/randomizer.cjs +290 -0
- package/src/bin/bots/reporter.cjs +0 -0
- package/src/bin/cli/accounts.cjs +47 -0
- package/src/bin/cli/assets.cjs +466 -0
- package/src/bin/cli/framework.cjs +100 -0
- package/src/bin/cli/gateway.cjs +26 -0
- package/src/bin/cli/networks.cjs +63 -0
- package/src/bin/cli/priceFeeds.cjs +170 -0
- package/src/bin/cli/queries.cjs +217 -0
- package/src/bin/cli/randomness.cjs +367 -0
- package/src/bin/cli/reports.cjs +272 -0
- package/src/bin/cli/wizard.cjs +352 -0
- package/src/bin/helpers.cjs +388 -0
- package/src/bin/index.cjs +407 -0
- package/settings/artifacts.js +0 -71
- package/settings/index.js +0 -49
- package/settings/networks.js +0 -593
- package/settings/solidity.js +0 -11
- package/settings/specs.js +0 -102
- package/src/index.js +0 -96
- package/src/utils.js +0 -305
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const dotenv = require("dotenv")
|
|
4
|
+
dotenv.config({ quiet: true })
|
|
5
|
+
|
|
6
|
+
const { JsonRpcProvider } = require("ethers")
|
|
7
|
+
|
|
8
|
+
const helpers = require("./helpers.cjs")
|
|
9
|
+
const { DEFAULT_LIMIT, DEFAULT_SINCE } = helpers
|
|
10
|
+
const { green, yellow, lwhite } = helpers.colors
|
|
11
|
+
|
|
12
|
+
const { utils } = require("../../dist/src/index.js")
|
|
13
|
+
|
|
14
|
+
/// CONSTANTS AND GLOBALS =============================================================================================
|
|
15
|
+
|
|
16
|
+
const settings = {
|
|
17
|
+
flags: {
|
|
18
|
+
all: "List all available Radon assets, even if not yet deployed.",
|
|
19
|
+
apps: "Show addresses of Wit/Oracle appliances.",
|
|
20
|
+
await: "Hold down until next event is triggered.",
|
|
21
|
+
"check-result-status":
|
|
22
|
+
"Check result status for each oracle query (supersedes --trace-back).",
|
|
23
|
+
clone:
|
|
24
|
+
"Clone the WitRandomness contract to a new instance (curated by --signer)",
|
|
25
|
+
debug: "Outputs stack trace in case of error.",
|
|
26
|
+
decode: "Decode selected Radon assets, as currently deployed.",
|
|
27
|
+
deploy: "Deploy selected Radon assets, if not yet deployed.",
|
|
28
|
+
"dry-run":
|
|
29
|
+
"Dry-run selected Radon asset, as currently deployed (supersedes --decode).",
|
|
30
|
+
force: "Force operations without user intervention.",
|
|
31
|
+
help: "Describe how to use some command.",
|
|
32
|
+
legacy: "Filter to those declared in witnet/assets folder.",
|
|
33
|
+
parse: "Parse reported CBOR bytes",
|
|
34
|
+
mainnets: "List supported EVM mainnets.",
|
|
35
|
+
modals: "List deployed WitOracleRadonRequestModal contracts.",
|
|
36
|
+
randomize: "Pay for a new randomize request.",
|
|
37
|
+
requests: "Includes WitOracleRequest artifacts.",
|
|
38
|
+
templates: "List deployed WitOracleRadonRequestTemplate contracts.",
|
|
39
|
+
testnets: "List supported EVM testnets.",
|
|
40
|
+
"trace-back": "Trace matching witnessing acts on Witnet.",
|
|
41
|
+
verbose: "Outputs detailed information.",
|
|
42
|
+
version: "Print binary name and version as headline.",
|
|
43
|
+
voids: "Include deleted queries.",
|
|
44
|
+
},
|
|
45
|
+
options: {
|
|
46
|
+
confirmations: {
|
|
47
|
+
hint: "Number of block confirmations to wait for after an EVM transaction gets mined.",
|
|
48
|
+
param: "NUMBER",
|
|
49
|
+
},
|
|
50
|
+
contract: {
|
|
51
|
+
hint: "Path or name of the new mockup contract to be created",
|
|
52
|
+
param: "path/to/output",
|
|
53
|
+
},
|
|
54
|
+
"filter-consumer": {
|
|
55
|
+
hint: "Filter events triggered by given consumer.",
|
|
56
|
+
param: "EVM_ADDRESS",
|
|
57
|
+
},
|
|
58
|
+
"filter-requester": {
|
|
59
|
+
hint: "Filter events triggered by given requester.",
|
|
60
|
+
param: "EVM_ADDRESS",
|
|
61
|
+
},
|
|
62
|
+
"filter-radHash": {
|
|
63
|
+
hint: "Filter events referring the fragment of some RAD hash.",
|
|
64
|
+
param: "FRAGMENT",
|
|
65
|
+
},
|
|
66
|
+
gasPrice: {
|
|
67
|
+
hint: "EVM gas price to pay for.",
|
|
68
|
+
param: "GAS_PRICE",
|
|
69
|
+
},
|
|
70
|
+
gasLimit: {
|
|
71
|
+
hint: "Maximum EVM gas to spend per transaction.",
|
|
72
|
+
param: "GAS_LIMIT",
|
|
73
|
+
},
|
|
74
|
+
into: {
|
|
75
|
+
hint: "Address of some WitOracleConsumer contract where to report into.",
|
|
76
|
+
param: "EVM_ADDRESS",
|
|
77
|
+
},
|
|
78
|
+
limit: {
|
|
79
|
+
hint: `Limit number of listed records (default: ${DEFAULT_LIMIT}).`,
|
|
80
|
+
param: "LIMIT",
|
|
81
|
+
},
|
|
82
|
+
module: {
|
|
83
|
+
hint: "Package where to fetch Radon assets from (supersedes --legacy).",
|
|
84
|
+
param: "NPM_PACKAGE",
|
|
85
|
+
},
|
|
86
|
+
network: {
|
|
87
|
+
hint: "Bind mockup contract to immutable Wit/Oracle addresses on this EVM network.",
|
|
88
|
+
param: "NETWORK",
|
|
89
|
+
},
|
|
90
|
+
offset: {
|
|
91
|
+
hint: "Skip first records before listing (default: 0)",
|
|
92
|
+
param: "OFFSET",
|
|
93
|
+
},
|
|
94
|
+
port: {
|
|
95
|
+
hint: "Port on which the local ETH/RPC signing gateway is expected to be listening (default: 8545).",
|
|
96
|
+
param: "HTTP_PORT",
|
|
97
|
+
},
|
|
98
|
+
push: {
|
|
99
|
+
hint: "Retrieve the finalized result to the given Wit/Oracle query, and push it into some consumer contract (requires: --into).",
|
|
100
|
+
param: "WIT_DR_TX_HASH",
|
|
101
|
+
},
|
|
102
|
+
remote: {
|
|
103
|
+
hint: "Force the local gateway to rely on this remote ETH/RPC provider.",
|
|
104
|
+
param: "PROVIDER_URL",
|
|
105
|
+
},
|
|
106
|
+
signer: {
|
|
107
|
+
hint: "EVM signer address, other than gateway's default.",
|
|
108
|
+
param: "EVM_ADDRESS",
|
|
109
|
+
},
|
|
110
|
+
since: {
|
|
111
|
+
hint: `Process events since given EVM block number (default: ${DEFAULT_SINCE}).`,
|
|
112
|
+
param: "EVM_BLOCK",
|
|
113
|
+
},
|
|
114
|
+
target: {
|
|
115
|
+
hint: "Address of the contract to interact with.",
|
|
116
|
+
param: "EVM_ADDRESS",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
envars: {
|
|
120
|
+
ETHRPC_PRIVATE_KEYS:
|
|
121
|
+
"=> Private keys used by the ETH/RPC gateway for signing EVM transactions.",
|
|
122
|
+
ETHRPC_PROVIDER_URL:
|
|
123
|
+
"=> Remote ETH/RPC provider to rely on, if no otherwise specified.",
|
|
124
|
+
WITNET_KERMIT_PROVIDER_URL:
|
|
125
|
+
"=> Wit/Kermit API-REST provider to connect to, if no otherwise specified.",
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// MAIN WORKFLOW =====================================================================================================
|
|
130
|
+
|
|
131
|
+
main()
|
|
132
|
+
|
|
133
|
+
async function main() {
|
|
134
|
+
let ethRpcPort = 8545
|
|
135
|
+
if (process.argv.indexOf("--port") >= 0) {
|
|
136
|
+
ethRpcPort = parseInt(process.argv[process.argv.indexOf("--port") + 1], 10)
|
|
137
|
+
}
|
|
138
|
+
let ethRpcProvider, ethRpcNetwork
|
|
139
|
+
try {
|
|
140
|
+
ethRpcProvider = new JsonRpcProvider(`http://127.0.0.1:${ethRpcPort}`)
|
|
141
|
+
const network = await ethRpcProvider.getNetwork()
|
|
142
|
+
const chainId = Number(network.chainId)
|
|
143
|
+
ethRpcNetwork = utils.getEvmNetworkByChainId(chainId)
|
|
144
|
+
} catch (_err) {}
|
|
145
|
+
|
|
146
|
+
const router = {
|
|
147
|
+
...(ethRpcNetwork
|
|
148
|
+
? {
|
|
149
|
+
accounts: {
|
|
150
|
+
hint: `Show EVM gas currency balance for all available accounts on ${helpers.colors.mcyan(ethRpcNetwork.toUpperCase())}.`,
|
|
151
|
+
},
|
|
152
|
+
assets: {
|
|
153
|
+
hint: `Formally verify deployable Radon assets into ${helpers.colors.mcyan(ethRpcNetwork.toUpperCase())}.`,
|
|
154
|
+
params: "[RADON_ASSETS ...]",
|
|
155
|
+
flags: ["all", "decode", "deploy", "dry-run", "force", "legacy"],
|
|
156
|
+
options: ["module", "port", "signer"],
|
|
157
|
+
},
|
|
158
|
+
framework: {
|
|
159
|
+
hint: `List available Wit/Oracle Framework addresses in ${helpers.colors.mcyan(ethRpcNetwork.toUpperCase())}.`,
|
|
160
|
+
params: "[NAME_SUFFIX ...]",
|
|
161
|
+
flags: ["modals", "templates", "verbose"],
|
|
162
|
+
options: ["port"],
|
|
163
|
+
},
|
|
164
|
+
priceFeeds: {
|
|
165
|
+
hint: `Show latest Wit/PriceFeeds updates on ${helpers.colors.mcyan(ethRpcNetwork.toUpperCase())}.`,
|
|
166
|
+
params: "[EVM_ADDRESS]",
|
|
167
|
+
flags: ["trace-back"],
|
|
168
|
+
},
|
|
169
|
+
queries: {
|
|
170
|
+
hint: `Show latest Wit/Oracle queries pulled from smart contracts in ${helpers.colors.mcyan(ethRpcNetwork.toUpperCase())}.`,
|
|
171
|
+
params: "[IDS ...]",
|
|
172
|
+
flags: ["trace-back", "voids"],
|
|
173
|
+
options: [
|
|
174
|
+
"filter-radHash",
|
|
175
|
+
"filter-requester",
|
|
176
|
+
"limit",
|
|
177
|
+
"offset",
|
|
178
|
+
"since",
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
randomness: {
|
|
182
|
+
hint: `Show latest Wit/Randomness seeds randomized from ${helpers.colors.mcyan(ethRpcNetwork.toUpperCase())}.`,
|
|
183
|
+
params: "[EVM_ADDRESS]",
|
|
184
|
+
flags: ["clone", "randomize", "trace-back"],
|
|
185
|
+
options: ["limit", "offset", "since", "gasPrice", "signer"],
|
|
186
|
+
envars: [],
|
|
187
|
+
},
|
|
188
|
+
reports: {
|
|
189
|
+
hint: `Show latest Wit/Oracle data reports pushed into ${helpers.colors.mcyan(ethRpcNetwork.toUpperCase())}.`,
|
|
190
|
+
flags: ["parse", "trace-back"],
|
|
191
|
+
options: [
|
|
192
|
+
"filter-consumer",
|
|
193
|
+
"filter-radHash",
|
|
194
|
+
"limit",
|
|
195
|
+
"offset",
|
|
196
|
+
"since",
|
|
197
|
+
"push",
|
|
198
|
+
"into",
|
|
199
|
+
"gasPrice",
|
|
200
|
+
"gasLimit",
|
|
201
|
+
"signer",
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
}
|
|
205
|
+
: {}),
|
|
206
|
+
gateway: {
|
|
207
|
+
hint: "Launch a local ETH/RPC signing gateway connected to some specific EVM network.",
|
|
208
|
+
params: ["EVM_NETWORK"],
|
|
209
|
+
options: ["port", "remote"],
|
|
210
|
+
envars: ["ETHRPC_PRIVATE_KEYS", "ETHRPC_PROVIDER_URL"],
|
|
211
|
+
},
|
|
212
|
+
networks: {
|
|
213
|
+
hint: "List EVM networks currently bridged to the Witnet blockchain.",
|
|
214
|
+
params: "[EVM_ECOSYSTEM]",
|
|
215
|
+
flags: ["mainnets", "testnets"],
|
|
216
|
+
},
|
|
217
|
+
// wizard: {
|
|
218
|
+
// hint: "Generate Solidity mockup contracts adapted to your use case.",
|
|
219
|
+
// options: [
|
|
220
|
+
// "contract",
|
|
221
|
+
// "network",
|
|
222
|
+
// ],
|
|
223
|
+
// },
|
|
224
|
+
commands: {
|
|
225
|
+
accounts: require("./cli/accounts.cjs"),
|
|
226
|
+
assets: require("./cli/assets.cjs"),
|
|
227
|
+
framework: require("./cli/framework.cjs"),
|
|
228
|
+
gateway: require("./cli/gateway.cjs"),
|
|
229
|
+
networks: require("./cli/networks.cjs"),
|
|
230
|
+
priceFeeds: require("./cli/priceFeeds.cjs"),
|
|
231
|
+
queries: require("./cli/queries.cjs"),
|
|
232
|
+
randomness: require("./cli/randomness.cjs"),
|
|
233
|
+
reports: require("./cli/reports.cjs"),
|
|
234
|
+
// wizard: require("./cli/wizard.cjs"),
|
|
235
|
+
},
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let [args, flags] = helpers.extractFlagsFromArgs(
|
|
239
|
+
process.argv.slice(2),
|
|
240
|
+
Object.keys(settings.flags),
|
|
241
|
+
)
|
|
242
|
+
if (flags.version) {
|
|
243
|
+
showVersion()
|
|
244
|
+
}
|
|
245
|
+
let options
|
|
246
|
+
;[args, options] = helpers.extractOptionsFromArgs(
|
|
247
|
+
args,
|
|
248
|
+
Object.keys(settings.options),
|
|
249
|
+
)
|
|
250
|
+
if (args[0] && router.commands[args[0]] && router[args[0]]) {
|
|
251
|
+
const cmd = args[0]
|
|
252
|
+
if (flags.help) {
|
|
253
|
+
showCommandUsage(router, cmd, router[cmd])
|
|
254
|
+
} else {
|
|
255
|
+
try {
|
|
256
|
+
await router.commands[cmd](
|
|
257
|
+
{ ...settings, ...flags, ...options },
|
|
258
|
+
args.slice(1),
|
|
259
|
+
)
|
|
260
|
+
} catch (e) {
|
|
261
|
+
showUsageError(router, cmd, router[cmd], e, flags)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
showMainUsage(router)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function showMainUsage(router) {
|
|
270
|
+
showUsageHeadline(router)
|
|
271
|
+
showUsageFlags(["help", "debug", "version"])
|
|
272
|
+
showUsageOptions(["port"])
|
|
273
|
+
console.info("\nCOMMANDS:")
|
|
274
|
+
const maxLength = Object.keys(router.commands)
|
|
275
|
+
.map((key) => key.length)
|
|
276
|
+
.reduce((prev, curr) => (curr > prev ? curr : prev))
|
|
277
|
+
Object.keys(router.commands).forEach((cmd) => {
|
|
278
|
+
if (router[cmd])
|
|
279
|
+
console.info(
|
|
280
|
+
" ",
|
|
281
|
+
`${cmd}${" ".repeat(maxLength - cmd.length)}`,
|
|
282
|
+
" ",
|
|
283
|
+
router[cmd]?.hint,
|
|
284
|
+
)
|
|
285
|
+
})
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function showCommandUsage(router, cmd, specs) {
|
|
289
|
+
showUsageHeadline(router, cmd, specs)
|
|
290
|
+
showUsageFlags(specs?.flags || [])
|
|
291
|
+
showUsageOptions(specs?.options || [])
|
|
292
|
+
showUsageEnvars(specs?.envars || [])
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function showUsageEnvars(envars) {
|
|
296
|
+
if (envars.length > 0) {
|
|
297
|
+
console.info("\nENVARS:")
|
|
298
|
+
const maxWidth = envars
|
|
299
|
+
.map((envar) => envar.length)
|
|
300
|
+
.reduce((curr, prev) => (curr > prev ? curr : prev))
|
|
301
|
+
envars.forEach((envar) => {
|
|
302
|
+
if (envar.toUpperCase().indexOf("KEY") < 0 && process.env[envar]) {
|
|
303
|
+
console.info(
|
|
304
|
+
" ",
|
|
305
|
+
`${yellow(envar.toUpperCase())}${" ".repeat(maxWidth - envar.length)}`,
|
|
306
|
+
` => Settled to "${process.env[envar]}"`,
|
|
307
|
+
)
|
|
308
|
+
} else {
|
|
309
|
+
console.info(
|
|
310
|
+
" ",
|
|
311
|
+
`${yellow(envar.toUpperCase())}${" ".repeat(maxWidth - envar.length)}`,
|
|
312
|
+
` ${settings.envars[envar]}`,
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function showUsageError(router, cmd, specs, error, flags) {
|
|
320
|
+
showCommandUsage(router, cmd, specs)
|
|
321
|
+
if (error) {
|
|
322
|
+
console.info()
|
|
323
|
+
if (flags?.debug) {
|
|
324
|
+
console.error(error)
|
|
325
|
+
} else {
|
|
326
|
+
console.error(error?.stack?.split("\n")[0] || error)
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function showUsageFlags(flags) {
|
|
332
|
+
if (flags.length > 0) {
|
|
333
|
+
const maxWidth = flags
|
|
334
|
+
.map((flag) => flag.length)
|
|
335
|
+
.reduce((curr, prev) => (curr > prev ? curr : prev))
|
|
336
|
+
console.info("\nFLAGS:")
|
|
337
|
+
flags.forEach((flag) => {
|
|
338
|
+
if (settings.flags[flag]) {
|
|
339
|
+
console.info(
|
|
340
|
+
` --${flag}${" ".repeat(maxWidth - flag.length)} ${settings.flags[flag]}`,
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function showUsageHeadline(router, cmd, specs) {
|
|
348
|
+
console.info("USAGE:")
|
|
349
|
+
const flags =
|
|
350
|
+
cmd && (!specs?.flags || specs.flags.length === 0) ? "" : "[FLAGS] "
|
|
351
|
+
const options = specs?.options && specs.options.length > 0 ? "[OPTIONS] " : ""
|
|
352
|
+
if (cmd) {
|
|
353
|
+
let params
|
|
354
|
+
if (specs?.params) {
|
|
355
|
+
const optionalize = (str) =>
|
|
356
|
+
str.endsWith(" ...]")
|
|
357
|
+
? `[<${str.slice(1, -5)}> ...]`
|
|
358
|
+
: str[0] === "["
|
|
359
|
+
? `[<${str.slice(1, -1)}>]`
|
|
360
|
+
: `<${str}>`
|
|
361
|
+
if (Array.isArray(specs?.params)) {
|
|
362
|
+
params = `${specs.params.map((param) => optionalize(param)).join(" ")} `
|
|
363
|
+
} else {
|
|
364
|
+
params = `${optionalize(specs?.params)} `
|
|
365
|
+
}
|
|
366
|
+
console.info(
|
|
367
|
+
` ${lwhite(`npx witeth ${cmd}`)} ${params ? green(params) : ""}${flags}${options}`,
|
|
368
|
+
)
|
|
369
|
+
} else {
|
|
370
|
+
console.info(` ${lwhite(`npx witeth ${cmd}`)} ${flags}${options}`)
|
|
371
|
+
}
|
|
372
|
+
console.info("\nDESCRIPTION:")
|
|
373
|
+
console.info(` ${router[cmd].hint}`)
|
|
374
|
+
} else {
|
|
375
|
+
console.info(` ${lwhite("npx witeth")} <COMMAND> ${flags}${options}`)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function showUsageOptions(options) {
|
|
380
|
+
if (options.length > 0) {
|
|
381
|
+
console.info("\nOPTIONS:")
|
|
382
|
+
const maxLength = options
|
|
383
|
+
.map((option) =>
|
|
384
|
+
settings.options[option].param
|
|
385
|
+
? settings.options[option].param.length + option.length + 3
|
|
386
|
+
: option.length,
|
|
387
|
+
)
|
|
388
|
+
.reduce((prev, curr) => (curr > prev ? curr : prev))
|
|
389
|
+
options.forEach((option) => {
|
|
390
|
+
if (settings.options[option].hint) {
|
|
391
|
+
const str = `${option}${settings.options[option].param ? helpers.colors.gray(` <${settings.options[option].param}>`) : ""}`
|
|
392
|
+
console.info(
|
|
393
|
+
" ",
|
|
394
|
+
`--${str}${" ".repeat(maxLength - helpers.colorstrip(str).length)}`,
|
|
395
|
+
" ",
|
|
396
|
+
settings.options[option].hint,
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function showVersion() {
|
|
404
|
+
console.info(
|
|
405
|
+
`${lwhite(`Wit/Oracle Solidity CLI v${require("../../package.json").version}`)}`,
|
|
406
|
+
)
|
|
407
|
+
}
|
package/settings/artifacts.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
default: {
|
|
3
|
-
WitnetDeployer: "WitnetDeployer",
|
|
4
|
-
apps: {
|
|
5
|
-
WitPriceFeeds: "WitPriceFeedsV3Upgradable",
|
|
6
|
-
WitPriceFeedsLegacy: "WitPriceFeedsLegacyUpgradable",
|
|
7
|
-
WitRandomness: "WitRandomnessV3"
|
|
8
|
-
},
|
|
9
|
-
core: {
|
|
10
|
-
WitOracle: "WitOracleTrustableDefault",
|
|
11
|
-
WitOracleRadonRegistry: "WitOracleRadonRegistryUpgradableDefault",
|
|
12
|
-
WitOracleRadonRequestFactory: "WitOracleRadonRequestFactoryUpgradableDefault",
|
|
13
|
-
WitOracleRadonRequestFactoryModals: "WitOracleRadonRequestFactoryModalsDefault",
|
|
14
|
-
WitOracleRadonRequestFactoryTemplates: "WitOracleRadonRequestFactoryTemplatesDefault",
|
|
15
|
-
},
|
|
16
|
-
libs: {
|
|
17
|
-
WitOracleDataLib: "WitOracleDataLib",
|
|
18
|
-
WitOracleRadonEncodingLib: "WitOracleRadonEncodingLib",
|
|
19
|
-
WitOracleResultStatusLib: "WitOracleResultStatusLib",
|
|
20
|
-
WitPriceFeedsDataLib: "WitPriceFeedsDataLib",
|
|
21
|
-
WitPriceFeedsLegacyDataLib: "WitPriceFeedsLegacyDataLib",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
base: {
|
|
25
|
-
core: { WitOracle: "WitOracleTrustableOvm2" },
|
|
26
|
-
},
|
|
27
|
-
boba: {
|
|
28
|
-
core: { WitOracle: "WitOracleTrustableOvm2" },
|
|
29
|
-
},
|
|
30
|
-
"conflux:core": {
|
|
31
|
-
WitnetDeployer: "WitnetDeployerConfluxCore",
|
|
32
|
-
core: {
|
|
33
|
-
WitOracleRadonRequestFactory: "WitOracleRadonRequestFactoryUpgradableConfluxCore",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
"ethereum:sepolia": {
|
|
37
|
-
apps: {
|
|
38
|
-
WitPriceFeedsLegacy: "WitPriceFeedsLegacyUpgradableBypass",
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
mantle: {
|
|
42
|
-
core: { WitOracle: "WitOracleTrustableOvm2" },
|
|
43
|
-
},
|
|
44
|
-
meter: {
|
|
45
|
-
WitnetDeployer: "WitnetDeployerMeter",
|
|
46
|
-
core: { WitOracleRadonRequestFactory: "WitOracleRadonRequestFactoryUpgradableConfluxCore" },
|
|
47
|
-
},
|
|
48
|
-
optimism: {
|
|
49
|
-
core: { WitOracle: "WitOracleTrustableOvm2" },
|
|
50
|
-
},
|
|
51
|
-
"okx:x1": {
|
|
52
|
-
core: { WitOracleRadonRegistry: "WitOracleRadonRegistryUpgradableNoSha256" },
|
|
53
|
-
},
|
|
54
|
-
"polygon:zkevm": {
|
|
55
|
-
core: { WitOracleRadonRegistry: "WitOracleRadonRegistryUpgradableNoSha256" },
|
|
56
|
-
},
|
|
57
|
-
reef: {
|
|
58
|
-
WitnetDeployer: "WitnetDeployerDeferred",
|
|
59
|
-
core: { WitOracle: "WitOracleTrustableReef" },
|
|
60
|
-
},
|
|
61
|
-
scroll: {
|
|
62
|
-
core: { WitOracleRadonRegistry: "WitOracleRadonRegistryUpgradableNoSha256" },
|
|
63
|
-
},
|
|
64
|
-
"syscoin:rollux": {
|
|
65
|
-
core: { WitOracle: "WitOracleTrustableOvm2" },
|
|
66
|
-
},
|
|
67
|
-
ten: {
|
|
68
|
-
WitnetDeployer: "WitnetDeployerDeferred",
|
|
69
|
-
core: { WitOracle: "WitOracleTrustableObscuro" },
|
|
70
|
-
},
|
|
71
|
-
}
|
package/settings/index.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import merge from "lodash.merge"
|
|
2
|
-
|
|
3
|
-
import artifacts from "./artifacts.js"
|
|
4
|
-
import networks from "./networks.js"
|
|
5
|
-
import { default as specs } from "./specs.js"
|
|
6
|
-
import solidity from "./solidity.js"
|
|
7
|
-
import utils from "../src/utils.js"
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
getArtifacts: (network) => {
|
|
11
|
-
let res = artifacts.default
|
|
12
|
-
utils.getNetworkTagsFromString(network).forEach(net => {
|
|
13
|
-
res = merge(res, artifacts[net])
|
|
14
|
-
})
|
|
15
|
-
return res
|
|
16
|
-
},
|
|
17
|
-
getCompilers: (network) => {
|
|
18
|
-
let res = solidity.default
|
|
19
|
-
utils.getNetworkTagsFromString(network).forEach(net => {
|
|
20
|
-
res = merge(res, solidity[net])
|
|
21
|
-
})
|
|
22
|
-
return res
|
|
23
|
-
},
|
|
24
|
-
getNetworks: () => {
|
|
25
|
-
return Object.fromEntries(Object.entries(networks)
|
|
26
|
-
.filter(entry => entry[0].indexOf(":") > -1)
|
|
27
|
-
.map(entry => {
|
|
28
|
-
const [ecosystem, network] = utils.getRealmNetworkFromString(entry[0])
|
|
29
|
-
return [
|
|
30
|
-
network.toLowerCase(), merge(
|
|
31
|
-
{ ...networks.default },
|
|
32
|
-
networks[ecosystem],
|
|
33
|
-
networks[entry[0]]
|
|
34
|
-
),
|
|
35
|
-
]
|
|
36
|
-
})
|
|
37
|
-
)
|
|
38
|
-
},
|
|
39
|
-
getSpecs: (network) => {
|
|
40
|
-
let res = specs.default
|
|
41
|
-
utils.getNetworkTagsFromString(network).forEach(net => {
|
|
42
|
-
res = merge(res, specs[net])
|
|
43
|
-
})
|
|
44
|
-
return res
|
|
45
|
-
},
|
|
46
|
-
artifacts,
|
|
47
|
-
solidity,
|
|
48
|
-
specs,
|
|
49
|
-
}
|