Skip to content

Commit fbb6301

Browse files
lcaresiaGTFalcao
andauthored
[Components] blocknative #10918 (#19023)
* Added actions * Added actions * Update components/blocknative/blocknative.app.mjs --------- Co-authored-by: Guilherme Falcão <48412907+GTFalcao@users.noreply.github.com>
1 parent 785cc4a commit fbb6301

File tree

17 files changed

+178
-34
lines changed

17 files changed

+178
-34
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../blocknative.app.mjs";
2+
3+
export default {
4+
key: "blocknative-get-chains",
5+
name: "Get Chains",
6+
description: "Get a list of supported chains. [See the documentation](https://docs.blocknative.com/gas-prediction/gas-platform-1)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.getChains({
19+
$,
20+
});
21+
$.export("$summary", "Successfully retrieved " + response.length + " chains");
22+
return response;
23+
},
24+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import app from "../../blocknative.app.mjs";
2+
3+
export default {
4+
key: "blocknative-get-gas-prices",
5+
name: "Get Gas Prices",
6+
description: "Get gas price estimations with confidence levels. [See the documentation](https://docs.blocknative.com/gas-prediction/gas-platform)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
confidenceLevels: {
17+
propDefinition: [
18+
app,
19+
"confidenceLevels",
20+
],
21+
},
22+
chainid: {
23+
propDefinition: [
24+
app,
25+
"chainid",
26+
],
27+
},
28+
},
29+
async run({ $ }) {
30+
const response = await this.app.getBlockprices({
31+
$,
32+
params: {
33+
confidenceLevels: this.confidenceLevels.join(","),
34+
chainid: this.chainid,
35+
},
36+
});
37+
$.export("$summary", "Successfully retrieved " + response.blockPrices[0].estimatedPrices.length + " estimated prices");
38+
return response;
39+
},
40+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../blocknative.app.mjs";
2+
3+
export default {
4+
key: "blocknative-get-oracles",
5+
name: "Get Oracles",
6+
description: "Get a list of supported oracles. [See the documentation](https://docs.blocknative.com/gas-prediction/gas-platform-2)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.getOracles({
19+
$,
20+
});
21+
$.export("$summary", "Successfully retrieved " + response.length + " results");
22+
return response;
23+
},
24+
};
Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,67 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "blocknative",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
confidenceLevels: {
8+
type: "integer[]",
9+
label: "confidenceLevels",
10+
description: "Confidence levels to include in the gas price estimation",
11+
},
12+
chainid: {
13+
type: "string",
14+
label: "chainid",
15+
description: "Blockchain network identifier to query gas prices for",
16+
async options() {
17+
const response = await this.getChains();
18+
return response.map(({
19+
label, chainId,
20+
}) => ({
21+
value: chainId,
22+
label,
23+
}));
24+
},
25+
},
26+
},
527
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
28+
_baseUrl() {
29+
return "https://api.blocknative.com";
30+
},
31+
async _makeRequest(opts = {}) {
32+
const {
33+
$ = this,
34+
path,
35+
headers,
36+
...otherOpts
37+
} = opts;
38+
return axios($, {
39+
...otherOpts,
40+
url: this._baseUrl() + path,
41+
headers: {
42+
"Authorization": `${this.$auth.api_key}`,
43+
...headers,
44+
},
45+
});
46+
},
47+
48+
async getBlockprices(args = {}) {
49+
return this._makeRequest({
50+
path: "/gasprices/blockprices",
51+
...args,
52+
});
53+
},
54+
async getChains(args = {}) {
55+
return this._makeRequest({
56+
path: "/chains",
57+
...args,
58+
});
59+
},
60+
async getOracles(args = {}) {
61+
return this._makeRequest({
62+
path: "/oracles",
63+
...args,
64+
});
965
},
1066
},
11-
};
67+
};

components/blocknative/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/blocknative",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Blocknative Components",
55
"main": "blocknative.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.1"
1417
}
1518
}

components/browseract/browseract.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/camino_ai/camino_ai.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/clappia/clappia.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/digitalocean_gradient_ai_serverless_inference/digitalocean_gradient_ai_serverless_inference.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/elastic_security/elastic_security.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

0 commit comments

Comments
 (0)