Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions components/beaconchain/actions/get-epoch/get-epoch.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import app from "../../beaconchain.app.mjs";

export default {
key: "beaconchain-get-epoch",
name: "Get Epoch",
description: "Returns information for a specified epoch by the epoch number or an epoch tag (can be latest or finalized). [See the documentation](https://beaconcha.in/api/v1/docs/index.html#/Epoch/get_api_v1_epoch__epoch_)",
version: "0.0.1",
type: "action",
props: {
app,
epoch: {
propDefinition: [
app,
"epoch",
],
},
},
methods: {
getEpoch({
epoch, ...args
} = {}) {
return this.app._makeRequest({
path: `/epoch/${epoch}`,
...args,
});
},
},
async run({ $ }) {
const {
getEpoch,
epoch,
} = this;

const response = await getEpoch({
$,
epoch,
});

$.export("$summary", `Successfully retrieved epoch \`${response.data.epoch}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import app from "../../beaconchain.app.mjs";

export default {
key: "beaconchain-get-execution-blocks",
name: "Get Execution Blocks",
description: "Retrieve execution blocks by execution block number. [See the documentation](https://beaconcha.in/api/v1/docs/index.html#/Execution/get_api_v1_execution_block__blockNumber_)",
version: "0.0.1",
type: "action",
props: {
app,
blockNumbers: {
type: "string[]",
label: "Block Number",
description: "Enter one or more execution block numbers, up to a maximum of 100.",
},
},
methods: {
getExecutionBlocks({
blockNumber, ...args
} = {}) {
return this.app._makeRequest({
path: `/execution/block/${blockNumber}`,
...args,
});
},
},
async run({ $ }) {
const {
getExecutionBlocks,
blockNumbers,
} = this;

const response = await getExecutionBlocks({
$,
blockNumber: Array.isArray(blockNumbers)
? blockNumbers.map((value) => value.trim()).join(",")
: blockNumbers,
});

$.export("$summary", "Successfully retrieved execution blocks.");
return response;
},
};
43 changes: 43 additions & 0 deletions components/beaconchain/actions/get-slots/get-slots.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import app from "../../beaconchain.app.mjs";

export default {
key: "beaconchain-get-slots",
name: "Get Slots",
description: "Returns all slots for a specified epoch. [See the documentation](https://beaconcha.in/api/v1/docs/index.html#/Epoch/get_api_v1_epoch__epoch__slots)",
version: "0.0.1",
type: "action",
props: {
app,
epoch: {
description: "Returns all slots for a specified epoch.",
propDefinition: [
app,
"epoch",
],
},
},
methods: {
getEpochSlots({
epoch, ...args
} = {}) {
return this.app._makeRequest({
path: `/epoch/${epoch}/slots`,
...args,
});
},
},
async run({ $ }) {
const {
getEpochSlots,
epoch,
} = this;

const response = await getEpochSlots({
$,
epoch,
});

$.export("$summary", `Successfully retrieved \`${response.data.length}\` slot(s).`);
return response;
},
};
43 changes: 43 additions & 0 deletions components/beaconchain/actions/get-validators/get-validators.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import app from "../../beaconchain.app.mjs";

export default {
key: "beaconchain-get-validators",
name: "Get Validators",
description: "Returns information for all validators up to 100 by index or public key. [See the documentation](https://beaconcha.in/api/v1/docs/index.html#/Validator/get_api_v1_validator__indexOrPubkey_).",
version: "0.0.1",
type: "action",
props: {
app,
indexesOrPubkeys: {
type: "string[]",
label: "Validator Indexes Or Public Keys",
description: "Enter up to 100 validator indices or public keys.",
},
},
methods: {
getValidators({
indexOrPubkey, ...args
} = {}) {
return this.app._makeRequest({
path: `/validator/${indexOrPubkey}`,
...args,
});
},
},
async run({ $ }) {
const {
getValidators,
indexesOrPubkeys,
} = this;

const response = await getValidators({
$,
indexOrPubkey: Array.isArray(indexesOrPubkeys)
? indexesOrPubkeys.map((value) => value.trim()).join(",")
: indexesOrPubkeys,
});

$.export("$summary", "Successfully retrieved validators.");
return response;
},
};
39 changes: 34 additions & 5 deletions components/beaconchain/beaconchain.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "beaconchain",
propDefinitions: {},
propDefinitions: {
epoch: {
type: "string",
label: "Epoch",
description: "Epoch number, the string `latest` or the string `finalized`.",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`;
},
getHeaders(headers) {
return {
...headers,
"apikey": `${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, headers, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
},
};
};
7 changes: 7 additions & 0 deletions components/beaconchain/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const BASE_URL = "https://beaconcha.in";
const VERSION_PATH = "/api/v1";

export default {
BASE_URL,
VERSION_PATH,
};
7 changes: 5 additions & 2 deletions components/beaconchain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/beaconchain",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Beaconchain Components",
"main": "beaconchain.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.3"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading