Skip to content

Commit f7a15ba

Browse files
committed
code revisions made based on pull request review
1 parent a2ec749 commit f7a15ba

File tree

6 files changed

+57
-32
lines changed

6 files changed

+57
-32
lines changed

components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ export default {
88
type: "action",
99
props: {
1010
overledger,
11+
environment: {
12+
propDefinition: [
13+
overledger,
14+
"environment",
15+
],
16+
},
1117
requestId: {
1218
type: "string",
1319
label: "Request ID",
@@ -21,12 +27,16 @@ export default {
2127
},
2228
},
2329
async run({ $ }) {
30+
31+
const requestBody = {
32+
requestId: this.requestId,
33+
signedTransaction: this.signedTransaction,
34+
};
35+
2436
const response = await this.overledger.executeSignedTransaction({
2537
$,
26-
data: {
27-
requestId: this.requestId,
28-
signedTransaction: this.signedTransaction,
29-
},
38+
environment: this.environment,
39+
data: requestBody,
3040
});
3141

3242
$.export("$summary", `Successfully executed signed transaction with Request ID ${this.requestId}`);

components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export default {
1212
type: "action",
1313
props: {
1414
overledger,
15+
environment: {
16+
propDefinition: [
17+
overledger,
18+
"environment",
19+
],
20+
},
1521
locationTechnology: {
1622
type: "string",
1723
label: "Location Technology",
@@ -68,6 +74,7 @@ export default {
6874

6975
const response = await this.overledger.prepareSmartContractTransaction({
7076
$,
77+
environment: this.environment,
7178
data: requestBody,
7279
});
7380
$.export("$summary", "Smart contract transaction prepared successfully");

components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export default {
1212
type: "action",
1313
props: {
1414
overledger,
15+
environment: {
16+
propDefinition: [
17+
overledger,
18+
"environment",
19+
],
20+
},
1521
locationTechnology: {
1622
type: "string",
1723
label: "Location Technology",
@@ -68,6 +74,7 @@ export default {
6874
// Make the API call to Overledger
6975
const response = await this.overledger.readFromSmartContract({
7076
$,
77+
environment: this.environment,
7178
data: requestBody,
7279
});
7380
$.export("$summary", `Successfully read from contract: ${this.smartContractId}`);

components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ export default {
99
type: "action",
1010
props: {
1111
overledger,
12+
environment: {
13+
propDefinition: [
14+
overledger,
15+
"environment",
16+
],
17+
},
1218
keyId: {
1319
type: "string",
1420
label: "Signing Account ID",
@@ -64,6 +70,7 @@ export default {
6470

6571
const response = await this.overledger.signTransaction({
6672
$,
73+
environment: this.environment,
6774
data: requestBody,
6875
});
6976
$.export("$summary", "Transaction signed successfully");

components/overledger/common/constants.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ export const NETWORK_OPTIONS = {
5050
"Sandbox",
5151
],
5252
};
53+
//Overledger environment to be used - Test or Live
54+
export const OVERLEDGER_INSTANCE = [
55+
{
56+
label: "Sandbox",
57+
value: "sandbox",
58+
},
59+
{
60+
label: "Overledger",
61+
value: "overledger",
62+
},
63+
];
5364
///unit options to allow for the correct selection based on the location network
5465
export const UNIT_OPTIONS = {
5566
"ethereum": "ETH", // Ethereum's token symbol is ETH

components/overledger/overledger.app.mjs

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,21 @@
11
import { axios } from "@pipedream/platform";
2+
import { OVERLEDGER_INSTANCE } from "./common/constants.mjs";
23

34
export default {
45
type: "app",
56
app: "overledger",
6-
props: { //Options to allow for instance selection of Overledger environment - Sandbox or Live Overledger to determine BaseURL
7-
environment: {
8-
type: "string",
9-
label: "Overledger Instance",
10-
description: "Select the Overledger environment.",
11-
options: [
12-
{
13-
label: "Sandbox",
14-
value: "sandbox",
15-
},
16-
{
17-
label: "Overledger",
18-
value: "overledger",
19-
},
20-
],
21-
optional: false,
22-
},
23-
},
247
propDefinitions: {
258
smartContractId: {
269
type: "string",
2710
label: "Smart Contract ID",
2811
description: "The ID of the smart contract to interact with.",
2912
},
13+
environment: {
14+
type: "string",
15+
label: "Overledger Instance",
16+
description: "Select the Overledger instance to be used",
17+
options: OVERLEDGER_INSTANCE,
18+
},
3019
},
3120
methods: {
3221
_headers() {
@@ -36,48 +25,44 @@ export default {
3625
"API-Version": "3.0.0",
3726
};
3827
},
39-
_getBaseUrl() { //conditional for environment url selection.
40-
return this.environment === "sandbox"
28+
_getBaseUrl(environment) { //conditional for environment url selection.
29+
return environment === "sandbox"
4130
? "https://api.sandbox.overledger.io"
4231
: "https://api.overledger.io";
4332
},
4433
_makeRequest({
45-
$ = this, baseUrl, path, ...otherOpts
34+
$ = this, environment, path, ...otherOpts
4635
}) {
4736
return axios($, {
4837
...otherOpts,
49-
url: baseUrl + path,
38+
url: this._getBaseUrl(environment) + path,
5039
headers: this._headers(),
5140
});
5241
},
5342
prepareSmartContractTransaction(opts = {}) {
5443
return this._makeRequest({
5544
method: "POST",
56-
baseUrl: this._getBaseUrl(),
5745
path: "/api/preparations/transactions/smart-contracts/write",
5846
...opts,
5947
});
6048
},
6149
readFromSmartContract(opts = {}) {
6250
return this._makeRequest({
6351
method: "POST",
64-
baseUrl: this._getBaseUrl(),
6552
path: "/api/smart-contracts/read",
6653
...opts,
6754
});
6855
},
6956
signTransaction(opts = {}) {
7057
return this._makeRequest({
7158
method: "POST",
72-
baseUrl: this._getBaseUrl(),
7359
path: "/api/transaction-signing-sandbox",
7460
...opts,
7561
});
7662
},
7763
executeSignedTransaction(opts = {}) {
7864
return this._makeRequest({
7965
method: "POST",
80-
baseUrl: this._getBaseUrl(),
8166
path: "/api/executions/transactions",
8267
...opts,
8368
});
@@ -87,7 +72,6 @@ export default {
8772
}) {
8873
return this._makeRequest({
8974
method: "POST",
90-
baseUrl: this._getBaseUrl(),
9175
path: `/api/webhooks/${path}`,
9276
...opts,
9377
});
@@ -97,7 +81,6 @@ export default {
9781
}) {
9882
return this._makeRequest({
9983
method: "DELETE",
100-
baseUrl: this._getBaseUrl(),
10184
path: `/api/webhooks/${path}/${webhookId}`,
10285
});
10386
},

0 commit comments

Comments
 (0)