Skip to content

Commit 07f4dd5

Browse files
authored
Added actions (#13607)
1 parent edaa38c commit 07f4dd5

File tree

6 files changed

+222
-7
lines changed

6 files changed

+222
-7
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import app from "../../owl_protocol.app.mjs";
2+
3+
export default {
4+
key: "owl_protocol-deploy-collection",
5+
name: "Deploy Collection",
6+
description: "Deploy digital asset collection. [See the documentation](https://docs-api.owlprotocol.xyz/reference/collection-deploy)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chainId: {
12+
propDefinition: [
13+
app,
14+
"chainId",
15+
],
16+
},
17+
collectionName: {
18+
propDefinition: [
19+
app,
20+
"collectionName",
21+
],
22+
},
23+
symbol: {
24+
propDefinition: [
25+
app,
26+
"symbol",
27+
],
28+
},
29+
description: {
30+
propDefinition: [
31+
app,
32+
"description",
33+
],
34+
},
35+
36+
},
37+
async run({ $ }) {
38+
const response = await this.app.deployCollection({
39+
$,
40+
data: {
41+
chainId: this.chainId,
42+
name: this.collectionName,
43+
symbol: this.symbol,
44+
description: this.description,
45+
},
46+
});
47+
48+
$.export("$summary", `Successfully deployed the collection '${this.collectionName}' with the contract Address: '${response.contractAddress}'`);
49+
50+
return response;
51+
},
52+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import app from "../../owl_protocol.app.mjs";
2+
3+
export default {
4+
key: "owl_protocol-get-network",
5+
name: "Get Network",
6+
description: "Get network details by the ID. [See the documentation](https://docs-api.owlprotocol.xyz/reference/network-get)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chainId: {
12+
propDefinition: [
13+
app,
14+
"chainId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.getNetwork({
20+
$,
21+
chainId: this.chainId,
22+
});
23+
24+
$.export("$summary", `Successfully retrieved data of Network: '${response.name}'`);
25+
26+
return response;
27+
},
28+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import app from "../../owl_protocol.app.mjs";
2+
3+
export default {
4+
key: "owl_protocol-mint-asset",
5+
name: "Mint Asset",
6+
description: "Mint digital assets for collection. [See the documentation](https://docs-api.owlprotocol.xyz/reference/collection-erc721autoid-mint)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chainId: {
12+
propDefinition: [
13+
app,
14+
"chainId",
15+
],
16+
},
17+
address: {
18+
propDefinition: [
19+
app,
20+
"address",
21+
],
22+
},
23+
mintTo: {
24+
propDefinition: [
25+
app,
26+
"mintTo",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.app.mintAsset({
32+
$,
33+
chainId: this.chainId,
34+
address: this.address,
35+
data: {
36+
to: this.mintTo,
37+
},
38+
});
39+
40+
$.export("$summary", `Successfully minted asset to '${this.mintTo}'`);
41+
42+
return response;
43+
},
44+
};
Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,96 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "owl_protocol",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
chainId: {
8+
type: "integer",
9+
label: "Chain ID",
10+
description: "Network Chain ID",
11+
async options() {
12+
const networksIds = await this.listNetworks();
13+
return networksIds.map(({
14+
chainId, name,
15+
}) => ({
16+
value: chainId,
17+
label: name,
18+
}));
19+
},
20+
},
21+
collectionName: {
22+
type: "string",
23+
label: "Collection Name",
24+
description: "Name of the collection",
25+
},
26+
symbol: {
27+
type: "string",
28+
label: "Collection Symbol",
29+
description: "Ticker symbol of collection, Must be 3-4 characters long",
30+
},
31+
description: {
32+
type: "string",
33+
label: "Collection Description",
34+
description: "Description of the collection",
35+
},
36+
address: {
37+
type: "string",
38+
label: "Address",
39+
description: "An ethereum address",
40+
},
41+
mintTo: {
42+
type: "string",
43+
label: "Mint To",
44+
description: "Email, userId or address to mint to",
45+
},
46+
},
547
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
48+
async _makeRequest(opts = {}) {
49+
const {
50+
$ = this,
51+
path,
52+
headers,
53+
...otherOpts
54+
} = opts;
55+
return axios($, {
56+
...otherOpts,
57+
url: this.$auth.api_url + path,
58+
headers: {
59+
...headers,
60+
"accept": "application/json",
61+
"x-api-key": `${this.$auth.api_key}`,
62+
},
63+
});
64+
},
65+
async getNetwork({
66+
chainId, ...args
67+
}) {
68+
return this._makeRequest({
69+
path: `/network/${chainId}`,
70+
...args,
71+
});
72+
},
73+
async mintAsset({
74+
chainId, address, ...args
75+
}) {
76+
return this._makeRequest({
77+
method: "post",
78+
path: `/project/collection/${chainId}/${address}/mint/erc721AutoId`,
79+
...args,
80+
});
81+
},
82+
async deployCollection(args = {}) {
83+
return this._makeRequest({
84+
method: "post",
85+
path: "/project/collection/deploy",
86+
...args,
87+
});
88+
},
89+
async listNetworks(args = {}) {
90+
return this._makeRequest({
91+
path: "/networks",
92+
...args,
93+
});
994
},
1095
},
1196
};

components/owl_protocol/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/owl_protocol",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Owl Protocol Components",
55
"main": "owl_protocol.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.0.0"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)