@witnet/sdk 1.2.4 → 1.2.6
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/dist/package.json +3 -3
- package/package.json +3 -3
- package/witnet/assets/_index.cjs +5 -0
- package/witnet/assets/_requests.cjs +25 -0
- package/witnet/assets/_sources.cjs +36 -0
- package/witnet/assets/_templates.cjs +36 -0
- package/witnet/assets/index.cjs +4 -0
- package/witnet/assets/modals/index.cjs +7 -0
- package/witnet/assets/modals/web3/btc.cjs +0 -0
- package/witnet/assets/modals/web3/eth.cjs +27 -0
- package/witnet/assets/modals/web3/ipfs.cjs +22 -0
- package/witnet/assets/modals/web3/sol.cjs +0 -0
- package/witnet/assets/modals/web3/wit.cjs +28 -0
- package/witnet/assets/requests.cjs +49 -0
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witnet/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Typescript library and CLI tooling for Web3 buidlers willing to interact with the Witnet blockchain.",
|
|
5
5
|
"author": "Witnet Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
26
|
"scripts/",
|
|
27
|
-
"src/assets",
|
|
28
27
|
"src/bin",
|
|
28
|
+
"witnet/assets",
|
|
29
29
|
".env_witnet"
|
|
30
30
|
],
|
|
31
31
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "pbjs --target json witnet/witnet.proto -o witnet/witnet.proto.json && npm run clean && tsc -p tsconfig.json",
|
|
51
51
|
"clean": "node ./scripts/clean.cjs dist",
|
|
52
|
-
"fmt": "npx biome check ./src ./scripts",
|
|
52
|
+
"fmt": "npx biome check --unsafe ./src ./scripts",
|
|
53
53
|
"fmt!": "npx biome check --write --unsafe ./src ./scripts",
|
|
54
54
|
"postinstall": "node scripts/postinstall.cjs",
|
|
55
55
|
"prepare": "pnpm run build",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witnet/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Typescript library and CLI tooling for Web3 buidlers willing to interact with the Witnet blockchain.",
|
|
5
5
|
"author": "Witnet Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
26
|
"scripts/",
|
|
27
|
-
"src/assets",
|
|
28
27
|
"src/bin",
|
|
28
|
+
"witnet/assets",
|
|
29
29
|
".env_witnet"
|
|
30
30
|
],
|
|
31
31
|
"exports": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "pbjs --target json witnet/witnet.proto -o witnet/witnet.proto.json && npm run clean && tsc -p tsconfig.json",
|
|
83
83
|
"clean": "node ./scripts/clean.cjs dist",
|
|
84
|
-
"fmt": "npx biome check ./src ./scripts",
|
|
84
|
+
"fmt": "npx biome check --unsafe ./src ./scripts",
|
|
85
85
|
"fmt!": "npx biome check --write --unsafe ./src ./scripts",
|
|
86
86
|
"postinstall": "node scripts/postinstall.cjs",
|
|
87
87
|
"watcher": "node ./src/bin/bots/watcher.cjs",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { assets, Witnet } = require("@witnet/sdk");
|
|
2
|
+
const { RadonRequest, RadonScript } = Witnet.Radon;
|
|
3
|
+
const { filters, reducers, retrievals, types } = Witnet.Radon;
|
|
4
|
+
|
|
5
|
+
const _sources = require("./sources.cjs");
|
|
6
|
+
const _templates = require("./templates.cjs");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
/// //// REQUESTS FROM RETRIEVALS /////////////////////////////////////////////////
|
|
10
|
+
// path: { ... path: {
|
|
11
|
+
// WitOracleRequestXXX: new RadonRequest({
|
|
12
|
+
// sources: [
|
|
13
|
+
// sources...RadonRetrieval1,
|
|
14
|
+
// sources...RadonRetrieval2.foldArgs("value21"),
|
|
15
|
+
// sources...RadonRetrieval3.foldArgs("value31", "value32"),
|
|
16
|
+
// retrievals..HttpXXX({ ... })
|
|
17
|
+
// ...
|
|
18
|
+
// ],
|
|
19
|
+
// sourcesReducer?: reducers..,
|
|
20
|
+
// witnessReducer?: reducers..,
|
|
21
|
+
// }),
|
|
22
|
+
/// /// REQUESTS FROM TEMPLATE ///////////////////////////////////////////////////
|
|
23
|
+
// WitOracleRequestYYY: templates...RadonTemplate1.buildRequest([["arg11", "arg12", ..], ..])
|
|
24
|
+
// }, ... },
|
|
25
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { assets, utils, Witnet } = require("@witnet/sdk");
|
|
2
|
+
const { RadonScript, retrievals, types } = Witnet.Radon;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
// path: { ... path: {
|
|
6
|
+
/// //// HTTP-GET RETRIEVALS /////////////////////////////////////////////////////
|
|
7
|
+
// RadonRetrievalXX1: retrievals.HttpGet(
|
|
8
|
+
// url: "http-or-https://authority/path?query",
|
|
9
|
+
// headers?: {
|
|
10
|
+
// "http-header-tag": "http-header-value",
|
|
11
|
+
// ...,
|
|
12
|
+
// },
|
|
13
|
+
// script?: Witnet.Radon.Script()..,
|
|
14
|
+
// }),
|
|
15
|
+
/// //// HTTP-POST RETRIEVALS ////////////////////////////////////////////////////
|
|
16
|
+
// RadonRetrievalXX2: retrievals.HttpPost(
|
|
17
|
+
// url: "http-or-https://authority/path?query",
|
|
18
|
+
// body?: "...",
|
|
19
|
+
// headers?: {
|
|
20
|
+
// "http-header-tag": "http-header-value",
|
|
21
|
+
// ...,
|
|
22
|
+
// },
|
|
23
|
+
// script?: Witnet.Radon.Script()..,
|
|
24
|
+
// }),
|
|
25
|
+
/// //// GRAPH-QL QUERIES ////////////////////////////////////////////////////////
|
|
26
|
+
// RadonRetrievalXX3: retrievals.GraphQLQuery(
|
|
27
|
+
// url: "http-or-https://authority/path?query",
|
|
28
|
+
// query: "...",
|
|
29
|
+
// headers?: {
|
|
30
|
+
// "http-header-tag": "http-header-value",
|
|
31
|
+
// ...,
|
|
32
|
+
// },
|
|
33
|
+
// script?: Witnet.Radon.Script()..,
|
|
34
|
+
// }),
|
|
35
|
+
// }, ... },
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { assets, Witnet } = require("@witnet/sdk");
|
|
2
|
+
const { RadonModal, RadonScript, RadonTemplate } = Witnet.Radon;
|
|
3
|
+
const { filters, reducers, retrievals, types } = Witnet.Radon;
|
|
4
|
+
|
|
5
|
+
const _sources = require("./sources.cjs");
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
/// //// REQUEST TEMPLATES ///////////////////////////////////////////////////////
|
|
9
|
+
// path: { ... path: {
|
|
10
|
+
// WitOracleRequestTemplateXXX: new RadonTemplate({
|
|
11
|
+
// sources: [
|
|
12
|
+
// sources..XX1,
|
|
13
|
+
// // ...
|
|
14
|
+
// sources..XX2.foldArgs(...args: string[]),
|
|
15
|
+
// // ...
|
|
16
|
+
// retrievals..({ ..
|
|
17
|
+
// // ...
|
|
18
|
+
// ],
|
|
19
|
+
// sourcesReducer?: Witnet.Radon.Reducers..,
|
|
20
|
+
// witnessReducer?: Witnet.Radon.Reducers..,
|
|
21
|
+
// samples?: {
|
|
22
|
+
// "test-description-1": [
|
|
23
|
+
// [ "..", ... ], // source #0 args (string[])
|
|
24
|
+
// ...
|
|
25
|
+
// ],
|
|
26
|
+
// ...
|
|
27
|
+
// }
|
|
28
|
+
// }),
|
|
29
|
+
// WitOracleRequestTemplateYYY: new RadonTemplate({
|
|
30
|
+
// sources: sources..YY1.spawnRetrievals(argIndex = 0, ...values: string[])
|
|
31
|
+
// sourcesReducer?: reducers..,
|
|
32
|
+
// witnessReducer?: reducers..,
|
|
33
|
+
// }),
|
|
34
|
+
// ...
|
|
35
|
+
// }, ... },
|
|
36
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const {
|
|
2
|
+
RadonModal,
|
|
3
|
+
RadonScript,
|
|
4
|
+
retrievals,
|
|
5
|
+
types,
|
|
6
|
+
} = require("../../../../dist/src/lib/radon/index.js");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
WitOracleEthBlockNumber: new RadonModal({
|
|
10
|
+
retrieval: retrievals.JsonRPC({
|
|
11
|
+
rpc: retrievals.rpc.eth.blockNumber(),
|
|
12
|
+
script: RadonScript(types.RadonString).asFloat().floor(),
|
|
13
|
+
}),
|
|
14
|
+
}),
|
|
15
|
+
WitOracleEthGetBalance: new RadonModal({
|
|
16
|
+
retrieval: retrievals.JsonRPC({
|
|
17
|
+
rpc: retrievals.rpc.eth.getBalance("\\0\\"),
|
|
18
|
+
script: RadonScript(types.RadonString).asFloat().floor(),
|
|
19
|
+
}),
|
|
20
|
+
}),
|
|
21
|
+
WitOracleEthGetTransactionReceipt: new RadonModal({
|
|
22
|
+
retrieval: retrievals.JsonRPC({
|
|
23
|
+
rpc: retrievals.rpc.eth.getTransactionByHash("\\0\\"),
|
|
24
|
+
script: RadonScript(types.RadonString).parseJSONMap(),
|
|
25
|
+
}),
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const {
|
|
2
|
+
RadonModal,
|
|
3
|
+
RadonScript,
|
|
4
|
+
retrievals,
|
|
5
|
+
types,
|
|
6
|
+
} = require("../../../../dist/src/lib/radon/index.js");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
WitOracleIpfsFileExists: new RadonModal({
|
|
10
|
+
retrieval: retrievals.HttpHead({
|
|
11
|
+
script: RadonScript(types.RadonMap)
|
|
12
|
+
.getString("etag")
|
|
13
|
+
.slice(1, -1)
|
|
14
|
+
.match(types.RadonBoolean, { "\\0\\": true }, false),
|
|
15
|
+
}),
|
|
16
|
+
}),
|
|
17
|
+
WitOracleIpfsFileSha256: new RadonModal({
|
|
18
|
+
retrieval: retrievals.HttpGet({
|
|
19
|
+
script: RadonScript(types.RadonBytes).hash(),
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const {
|
|
2
|
+
RadonModal,
|
|
3
|
+
RadonScript,
|
|
4
|
+
retrievals,
|
|
5
|
+
types,
|
|
6
|
+
} = require("../../../../dist/src/lib/radon/index.js");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
WitOracleWitGetBalance: new RadonModal({
|
|
10
|
+
retrieval: retrievals.JsonRPC({
|
|
11
|
+
rpc: retrievals.rpc.wit.getBalance("\\0\\"),
|
|
12
|
+
script: RadonScript(types.RadonString)
|
|
13
|
+
.parseJSONMap()
|
|
14
|
+
.getMap("result")
|
|
15
|
+
.values(),
|
|
16
|
+
}),
|
|
17
|
+
}),
|
|
18
|
+
WitOracleWitGetValueTransfer: new RadonModal({
|
|
19
|
+
retrieval: retrievals.JsonRPC({
|
|
20
|
+
rpc: retrievals.rpc.wit.getValueTransfer("\\0\\", "\\1\\"),
|
|
21
|
+
script: RadonScript(types.RadonString)
|
|
22
|
+
.parseJSONMap()
|
|
23
|
+
.getMap("result")
|
|
24
|
+
.getMap("\\1\\")
|
|
25
|
+
.values(),
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const {
|
|
2
|
+
RadonRequest,
|
|
3
|
+
RadonScript,
|
|
4
|
+
filters,
|
|
5
|
+
reducers,
|
|
6
|
+
retrievals,
|
|
7
|
+
types,
|
|
8
|
+
} = require("../../dist/src/lib/radon/index.js");
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
defi: {
|
|
12
|
+
tickers: {
|
|
13
|
+
crypto: {
|
|
14
|
+
WitOracleRequestPriceCryptoWitUsdt6: new RadonRequest({
|
|
15
|
+
sources: [
|
|
16
|
+
retrievals.HttpGet({
|
|
17
|
+
url: "https://api.mexc.com/api/v3/ticker/price?symbol=WITUSDT",
|
|
18
|
+
script: RadonScript(types.RadonString)
|
|
19
|
+
.parseJSONMap()
|
|
20
|
+
.getFloat("price")
|
|
21
|
+
.multiply(1e6)
|
|
22
|
+
.round(),
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
sourcesReducer: reducers.Median(filters.Stdev(1.4)),
|
|
26
|
+
witnessReducer: reducers.PriceTally(),
|
|
27
|
+
}),
|
|
28
|
+
WitOracleRequestPriceCryptoUsdtWit9: new RadonRequest({
|
|
29
|
+
sources: [
|
|
30
|
+
retrievals.HttpGet({
|
|
31
|
+
url: "https://api.mexc.com/api/v3/ticker/price?symbol=WITUSDT",
|
|
32
|
+
script: RadonScript(types.RadonString)
|
|
33
|
+
.parseJSONMap()
|
|
34
|
+
.getFloat("price")
|
|
35
|
+
.multiply(1e6)
|
|
36
|
+
.round(),
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
sourcesReducer: reducers.Median(filters.Stdev(1.4)),
|
|
40
|
+
witnessReducer: reducers.PriceTally(),
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
WitOracleRequestRandomness: new RadonRequest({
|
|
46
|
+
sources: retrievals.RNG(),
|
|
47
|
+
witnessReducer: reducers.ConcatHash(),
|
|
48
|
+
}),
|
|
49
|
+
};
|