Skip to content

Commit 8562f9f

Browse files
Merge branch 'master' into databricks-sql-warehouses
2 parents 1258a7c + 4636f3e commit 8562f9f

File tree

245 files changed

+6907
-1613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+6907
-1613
lines changed
Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
1+
import {
2+
Coinbase, Webhook,
3+
} from "@coinbase/coinbase-sdk";
4+
15
export default {
26
type: "app",
37
app: "coinbase_developer_platform",
4-
propDefinitions: {},
8+
propDefinitions: {
9+
walletAddress: {
10+
type: "string",
11+
label: "Address",
12+
description: "The address of the wallet to monitor. Example: `0x8fddcc0c5c993a1968b46787919cc34577d6dc5c`",
13+
},
14+
networkId: {
15+
type: "string",
16+
label: "Network ID",
17+
description: "The network ID of the wallet to monitor. Example: `base-mainnet`",
18+
async options() {
19+
const networks = Coinbase.networks;
20+
return Object.values(networks);
21+
},
22+
},
23+
},
524
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
25+
configure() {
26+
const apiKeyName = this.$auth.api_key_id;
27+
const privateKey = this.$auth.secret_key;
28+
Coinbase.configure({
29+
apiKeyName,
30+
privateKey,
31+
});
32+
},
33+
listWebhooks() {
34+
return Webhook.list();
35+
},
36+
createWebhook(opts) {
37+
return Webhook.create(opts);
38+
},
39+
deleteWebhook(webhook) {
40+
return webhook.delete();
941
},
1042
},
11-
};
43+
};

components/coinbase_developer_platform/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/coinbase_developer_platform",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Coinbase Developer Platform Components",
55
"main": "coinbase_developer_platform.app.mjs",
66
"keywords": [
@@ -11,5 +11,9 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@coinbase/coinbase-sdk": "^0.25.0",
17+
"@pipedream/platform": "^3.1.0"
1418
}
15-
}
19+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import coinbase from "../../coinbase_developer_platform.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
props: {
6+
coinbase,
7+
db: "$.service.db",
8+
http: "$.interface.http",
9+
},
10+
methods: {
11+
_getWebhookId() {
12+
return this.db.get("webhookId");
13+
},
14+
_setWebhookId(webhookId) {
15+
this.db.set("webhookId", webhookId);
16+
},
17+
generateMeta() {
18+
throw new ConfigurationError("generateMeta is not implemented");
19+
},
20+
},
21+
async run(event) {
22+
const { body } = event;
23+
if (!body) {
24+
return;
25+
}
26+
const meta = this.generateMeta(body);
27+
this.$emit(body, meta);
28+
},
29+
};
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import common from "../common/base.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
import sampleEmit from "./test-event.mjs";
4+
5+
export default {
6+
...common,
7+
name: "New Wallet Event (Instant)",
8+
key: "coinbase_developer_platform-new-wallet-event",
9+
description: "Emit new event for each new wallet event. [See the documentation](https://docs.cdp.coinbase.com/webhooks/cdp-sdk#external-address-webhook)",
10+
version: "0.0.1",
11+
type: "source",
12+
dedupe: "unique",
13+
props: {
14+
...common.props,
15+
walletAddress: {
16+
propDefinition: [
17+
common.props.coinbase,
18+
"walletAddress",
19+
],
20+
},
21+
networkId: {
22+
propDefinition: [
23+
common.props.coinbase,
24+
"networkId",
25+
],
26+
},
27+
},
28+
hooks: {
29+
async activate() {
30+
this.coinbase.configure();
31+
const webhook = await this.coinbase.createWebhook({
32+
notificationUri: this.http.endpoint,
33+
eventType: "wallet_activity",
34+
networkId: this.networkId,
35+
eventTypeFilter: {
36+
addresses: [
37+
this.walletAddress,
38+
],
39+
wallet_id: "",
40+
},
41+
});
42+
43+
if (!webhook?.model?.id) {
44+
throw new ConfigurationError("Failed to create webhook");
45+
}
46+
47+
this._setWebhookId(webhook.model.id);
48+
},
49+
async deactivate() {
50+
this.coinbase.configure();
51+
const webhookId = this._getWebhookId();
52+
if (webhookId) {
53+
const { data: webhooks } = await this.coinbase.listWebhooks();
54+
const webhook = webhooks.find((webhook) => webhook.model.id === webhookId);
55+
await this.coinbase.deleteWebhook(webhook);
56+
}
57+
},
58+
},
59+
methods: {
60+
...common.methods,
61+
generateMeta(body) {
62+
return {
63+
id: body.transactionHash,
64+
summary: `New ${body.eventType} event`,
65+
ts: Date.parse(body.blockTime),
66+
};
67+
},
68+
},
69+
sampleEmit,
70+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default {
2+
"blockHash": "0x351bd04dfe350fca186cd47080220283a75d07018ed251748a4ad19e7f327caf",
3+
"blockNumber": 20305354,
4+
"blockTime": "2024-09-27T21:16:40.000Z",
5+
"contractAddress": "0xab39a8b6801b0b6aa20e9a1953c861ec0a57d175",
6+
"eventType": "erc20_transfer",
7+
"from": "0x10db590ffa5b7bc46cffbd436180e01b6c5c0af6",
8+
"logIndex": "121",
9+
"network": "base-sepolia",
10+
"to": "0x4a9ab171e31daff484c70921f2f5e89a8fe12f59",
11+
"transactionHash": "0x940db3006449456b386397ab42114134d745d2876196226444601670f3e99db8",
12+
"transactionIndex": "19",
13+
"value": "1000000",
14+
"webhookId": "66bd79d0b9c200eae1a43165"
15+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import app from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-cancel-all-runs",
5+
name: "Cancel All Runs",
6+
description: "Cancel all active runs for a job. The runs are canceled asynchronously, so it doesn't prevent new runs from being started. [See the documentation](https://docs.databricks.com/api/workspace/jobs/cancelallruns)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
// eslint-disable-next-line pipedream/props-label, pipedream/props-description
12+
info: {
13+
type: "alert",
14+
alertType: "info",
15+
content: "Either a **Job** or **All Queued Runs** must be provided.",
16+
},
17+
jobId: {
18+
optional: true,
19+
propDefinition: [
20+
app,
21+
"jobId",
22+
],
23+
},
24+
allQueuedRuns: {
25+
type: "boolean",
26+
label: "All Queued Runs",
27+
description: "Optional boolean parameter to cancel all queued runs. If no **Job ID** is provided, all queued runs in the workspace are canceled.",
28+
optional: true,
29+
},
30+
},
31+
async run({ $ }) {
32+
const {
33+
app,
34+
jobId,
35+
allQueuedRuns,
36+
} = this;
37+
38+
await app.cancelAllRuns({
39+
$,
40+
data: {
41+
job_id: jobId,
42+
all_queued_runs: allQueuedRuns,
43+
},
44+
});
45+
46+
$.export("$summary", "Successfully initiated cancellation of all runs");
47+
48+
return {
49+
success: true,
50+
};
51+
},
52+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-cancel-run",
5+
name: "Cancel Run",
6+
description: "Cancel a job run. The run is canceled asynchronously, so it may still be running when this request completes. [See the documentation](https://docs.databricks.com/api/workspace/jobs/cancelrun)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
runId: {
12+
propDefinition: [
13+
app,
14+
"runId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const {
20+
app,
21+
runId,
22+
} = this;
23+
24+
await app.cancelRun({
25+
$,
26+
data: {
27+
run_id: runId,
28+
},
29+
});
30+
31+
$.export("$summary", `Successfully initiated cancellation of run with ID \`${runId}\`.`);
32+
33+
return {
34+
success: true,
35+
};
36+
},
37+
};

0 commit comments

Comments
 (0)