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
3 changes: 0 additions & 3 deletions components/alchemy/.gitignore

This file was deleted.

58 changes: 58 additions & 0 deletions components/alchemy/alchemy.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "alchemy",
propDefinitions: {
network: {
type: "string",
label: "Network",
description: "Network of the webhook",
options: constants.NETWORKS,
},
query: {
type: "string",
label: "GraphQL Query",
description: "Create a custom GraphQL query or select `Full Block Receipts` to get all log events for every new block",
options: [
{
label: "Full Block Receipts",
value: constants.FULL_BLOCK_RECEIPTS,
},
],
},
},
methods: {
_baseUrl() {
return "https://dashboard.alchemy.com/api";
},
_makeRequest({
$ = this,
path,
...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
"X-Alchemy-Token": this.$auth.auth_token,
},
...opts,
});
},
createWebhook(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/create-webhook",
...opts,
});
},
deleteWebhook(opts = {}) {
return this._makeRequest({
method: "DELETE",
path: "/delete-webhook",
...opts,
});
},
},
};
13 changes: 0 additions & 13 deletions components/alchemy/app/alchemy.app.ts

This file was deleted.

82 changes: 82 additions & 0 deletions components/alchemy/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const NETWORKS = [
"ETH_MAINNET",
"ETH_SEPOLIA",
"ETH_HOLESKY",
"ARBMAINNET",
"ARBSEPOLIA",
"ARBNOVA_MAINNET",
"MATICMAINNET",
"MATICMUMBAI",
"OPTMAINNET",
"OPTGOERLI",
"BASE_MAINNET",
"BASE_SEPOLIA",
"ZKSYNC_MAINNET",
"ZKSYNC_SEPOLIA",
"LINEA_MAINNET",
"LINEA_SEPOLIA",
"GNOSIS_MAINNET",
"GNOSIS_CHIADO",
"FANTOM_MAINNET",
"FANTOM_TESTNET",
"METIS_MAINNET",
"BLAST_MAINNET",
"BLAST_SEPOLIA",
"SHAPE_SEPOLIA",
"ZETACHAIN_MAINNET",
"ZETACHAIN_TESTNET",
"WORLDCHAIN_MAINNET",
"WORLDCHAIN_SEPOLIA",
"BNB_MAINNET",
"BNB_TESTNET",
"AVAX_MAINNET",
"AVAX_FUJI",
"SONEIUM_MINATO",
"GEIST_POLTER",
];

const FULL_BLOCK_RECEIPTS = `
{
block {
hash,
number,
timestamp,
logs(filter: {addresses: [], topics: []}) {
data,
topics,
index,
account {
address
},
transaction {
hash,
nonce,
index,
from {
address
},
to {
address
},
value,
gasPrice,
maxFeePerGas,
maxPriorityFeePerGas,
gas,
status,
gasUsed,
cumulativeGasUsed,
effectiveGasPrice,
createdContract {
address
}
}
}
}
}
`;

export default {
NETWORKS,
FULL_BLOCK_RECEIPTS,
};
10 changes: 5 additions & 5 deletions components/alchemy/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@pipedream/alchemy",
"version": "0.0.3",
"version": "0.1.0",
"description": "Pipedream Alchemy Components",
"main": "dist/app/alchemy.app.mjs",
"main": "alchemy.app.mjs",
"keywords": [
"pipedream",
"alchemy"
],
"files": [
"dist"
],
"homepage": "https://pipedream.com/apps/alchemy",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import alchemy from "../../alchemy.app.mjs";

export default {
key: "alchemy-new-graphql-query-instant",
name: "New GraphQL Query (Instant)",
description: "Emit new event when a new GraphQL query is uploaded to Alchemy's Custom Webhook service. [See the documentation](https://docs.alchemy.com/reference/create-webhook)",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
alchemy,
db: "$.service.db",
http: {
type: "$.interface.http",
customResponse: true,
},
network: {
propDefinition: [
alchemy,
"network",
],
},
query: {
propDefinition: [
alchemy,
"query",
],
},
},
hooks: {
async activate() {
const { data: { id } } = await this.alchemy.createWebhook({
data: {
network: this.network,
webhook_type: "GRAPHQL",
webhook_url: this.http.endpoint,
graphql_query: this.query,
},
});
this._setHookId(id);
},
async deactivate() {
const hookId = this._getHookId();
if (hookId) {
await this.alchemy.deleteWebhook({
params: {
webhook_id: hookId,
},
});
}
},
},
methods: {
_getHookId() {
return this.db.get("hookId");
},
_setHookId(hookId) {
this.db.set("hookId", hookId);
},
generateMeta(body) {
return {
id: body.id,
summary: `New Event ID: ${body.id}`,
ts: Date.parse(body.createdAt),
};
},
},
async run(event) {
this.http.respond({
status: 200,
});

const { body } = event;
const meta = this.generateMeta(body);
this.$emit(body, meta);
},
};
Loading
Loading