From 60944eef0b2b87fd21034465303a3afeb196fb47 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Sun, 6 Oct 2024 14:16:52 +0000 Subject: [PATCH 01/16] overledger new actions added - read from smart contract and sign a transaction --- .../read-from-smart-contract.mjs | 69 +++++++++++++++++++ .../sign-a-transaction/sign-a-transaction.mjs | 44 ++++++++++++ components/overledger/overledger.app.mjs | 24 ++++++- 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs create mode 100644 components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs new file mode 100644 index 0000000000000..6944072fe34de --- /dev/null +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs @@ -0,0 +1,69 @@ +import { + NETWORK_OPTIONS, TECHNOLOGY_OPTIONS, +} from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.mjs"; +import overledger from "../../overledger.app.mjs"; + +export default { + key: "overledger-read-from-smart-contract", + name: "Read from Smart Contract", + description: "Reads data from a specified smart contract on the Overledger network.", + version: "0.0.1", + type: "action", + props: { + overledger, + locationTechnology: { + type: "string", + label: "Location Technology", + description: "The technology of the blockchain that the transaction will be submitted to", + options: TECHNOLOGY_OPTIONS, + reloadProps: true, + }, + functionName: { + type: "string", + label: "Function Name", + description: "The name of the function to call on the smart contract.", + }, + inptParameters: { + type: "string[]", + label: "Input Parameters", + description: "The input parameters for the smart contract function, in JSON format.", + optional: true, + }, + smartContractId: { + propDefinition: [ + overledger, + "smartContractId", + ], + }, + }, + async additionalProps() { + const props = {}; + if (this.locationTechnology) { + props.locationNetwork = { + type: "string", + label: "Location Network", + description: "The blockchain network the transaction will be submitted to.", + options: NETWORK_OPTIONS[this.locationTechnology], + }; + } + return props; + }, + async run({ $ }) { + const response = await this.overledger.readFromSmartContract({ + $, + data: { + location: { + technology: this.locationTechnology, + network: this.locationNetwork, + }, + functionName: this.functionName, + smartContractId: this.smartContractId, + inputParameters: this.inputParameters && parseObject(this.inputParameters), + }, + }); + + $.export("$summary", `Successfully read from contract: ${this.contractAddress}`); + return response; + }, +}; diff --git a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs new file mode 100644 index 0000000000000..ec3125dc85123 --- /dev/null +++ b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs @@ -0,0 +1,44 @@ +import overledger from "../../overledger.app.mjs"; + +export default { + key: "overledger-sign-smart-contract-transaction", + name: "Sign Smart Contract Transaction", + description: "Sign and send a transaction to a smart contract using Overledger", + version: "0.0.1", + type: "action", + props: { + overledger, + keyId: { + type: "string", + label: "Signing Account ID", + description: "The blockchain account that will sign the transaction.", + }, + requestId: { + type: "string", + label: "requestId", + description: "The Overledger identifier assigned to the related transaction preparation request. This should be set to the requestId parameter found in the response object of the 'Prepare a Smart Contract Transaction' Overledger action.", + }, + transactionSigningResponderName: { + type: "string", + label: "Transaction Signing Responder", + description: "The name of the Transaction Signing Responder you would like to use. The CTA Transaction Signing Responder is the Quant-provided signer for testnet accounts.", + }, + nativeData: { + type: "object", + label: "the transaction data required to be signed", + description: "A JSON object representing the transaction required to be signed.", + }, + }, + async run({ $ }) { + // Sign the transaction + const response = await this.overledger.signTransaction({ + $, + data: { + requestId: this.requestId, + nativeData: this.nativeData, + }, + }); + $.export("$summary", "Transaction signed successfully"); + return response; + }, +}; diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 202f732ae0519..3c0174e30acaa 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -22,24 +22,42 @@ export default { }; }, _makeRequest({ - $ = this, path, ...otherOpts + $ = this, baseUrl, path, ...otherOpts }) { return axios($, { ...otherOpts, - url: this._baseUrl() + path, + url: baseUrl + path, headers: this._headers(), }); }, prepareSmartContractTransaction(opts = {}) { return this._makeRequest({ method: "POST", + baseUrl: this._baseUrl(), path: "/api/preparations/transactions/smart-contracts/write", ...opts, }); }, + readFromSmartContract(opts = {}) { + return this._makeRequest({ + method: "POST", + baseUrl: this._baseUrl(), + path: "/api/smart-contracts/read", + ...opts, + }); + }, + signTransaction(opts = {}) { + return this._makeRequest({ + method: "POST", + baseUrl: "https://api.sandbox.overledger.io", + path: "/api/transaction-signing-sandbox", + ...opts, + }); + }, executeSignedTransaction(opts = {}) { return this._makeRequest({ method: "POST", + baseUrl: this._baseUrl(), path: "/api/executions/transactions", ...opts, }); @@ -49,6 +67,7 @@ export default { }) { return this._makeRequest({ method: "POST", + baseUrl: this._baseUrl(), path: `/api/webhooks/${path}`, ...opts, }); @@ -58,6 +77,7 @@ export default { }) { return this._makeRequest({ method: "DELETE", + baseUrl: this._baseUrl(), path: `/api/webhooks/${path}/${webhookId}`, }); }, From 9bf2acaf2df2ee06d010c0b3b5380952c5261024 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Mon, 7 Oct 2024 10:40:15 +0100 Subject: [PATCH 02/16] Update components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs Success message alteration to align with current context Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../read-from-a-smart-contract/read-from-smart-contract.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs index 6944072fe34de..b399539e18719 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs @@ -63,7 +63,7 @@ export default { }, }); - $.export("$summary", `Successfully read from contract: ${this.contractAddress}`); + $.export("$summary", `Successfully read from contract: ${this.smartContractId}`); return response; }, }; From d192f177fface3f8a4075d867c6819b5f29c424d Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Mon, 7 Oct 2024 10:51:16 +0100 Subject: [PATCH 03/16] Update components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs inputParameters is an array of Objects so no need to parseObject Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../read-from-a-smart-contract/read-from-smart-contract.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs index b399539e18719..e1211b56c983e 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs @@ -59,7 +59,7 @@ export default { }, functionName: this.functionName, smartContractId: this.smartContractId, - inputParameters: this.inputParameters && parseObject(this.inputParameters), + inputParameters: this.inputParameters, }, }); From 29d88f509f20b56da24519b721184465b09c4be7 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Mon, 7 Oct 2024 19:07:39 +0000 Subject: [PATCH 04/16] modified read from smart contract parameters --- .../prepare-smart-contract-transaction.mjs | 8 +-- .../read-from-smart-contract.mjs | 52 ++++++++++++------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs index 8a07e23324403..64150ac1c45b3 100644 --- a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs +++ b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs @@ -30,10 +30,10 @@ export default { description: "The name of the function to call on the smart contract.", }, smartContractId: { - propDefinition: [ - overledger, - "smartContractId", - ], + type: "string", + label: "Smart Contract ID", + description: "The ID/address of the smart contract to interact with.", + }, inputParameters: { type: "string[]", diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs index e1211b56c983e..0a758b8c29fa9 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs @@ -24,17 +24,21 @@ export default { label: "Function Name", description: "The name of the function to call on the smart contract.", }, - inptParameters: { + inputParameters: { type: "string[]", - label: "Input Parameters", - description: "The input parameters for the smart contract function, in JSON format.", + label: "Input Parameters - Stringified Objects", + description: "The input parameters for the smart contract function, in JSON string format. Example: `['{\"type\":\"string\",\"value\":\"param1\"}', '{\"type\":\"uint256\",\"value\":\"param2\"}']`", optional: true, }, smartContractId: { - propDefinition: [ - overledger, - "smartContractId", - ], + type: "string", + label: "Smart Contract ID", + description: "The ID/address of the smart contract to interact with.", + }, + outputParameters: { + type: "string[]", + label: "Output Parameters", + description: "The type of output parameter required e.g., address, string", }, }, async additionalProps() { @@ -50,20 +54,28 @@ export default { return props; }, async run({ $ }) { - const response = await this.overledger.readFromSmartContract({ - $, - data: { - location: { - technology: this.locationTechnology, - network: this.locationNetwork, - }, - functionName: this.functionName, - smartContractId: this.smartContractId, - inputParameters: this.inputParameters, + + const requestBody = { + location: { + technology: this.locationTechnology, + network: this.locationNetwork, }, - }); + functionName: this.functionName, + inputParameters: parseObject(this.inputParameters), + smartContractId: this.smartContractId, + outputParameters: parseObject(this.outputParameters), + }; - $.export("$summary", `Successfully read from contract: ${this.smartContractId}`); - return response; + try { + // Make the API call to Overledger + const response = await this.overledger.readFromSmartContract({ + $, + data: requestBody, + }); + $.export("$summary", `Successfully read from contract: ${this.smartContractId}`); + return response; + } catch (error) { + throw new Error(`Failed to read from smart contract: ${error.message}`); + } }, }; From 4ff37949c85fe918ae0a4b6e63fc110aaf1d7df6 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 8 Oct 2024 10:47:42 +0000 Subject: [PATCH 05/16] modified readfromsmart contract transaction, prepare-sign-execute transaction actions --- .../execute-signed-transaction.mjs | 4 +-- .../prepare-smart-contract-transaction.mjs | 36 ++++++++++--------- .../read-from-smart-contract.mjs | 5 --- .../sign-a-transaction/sign-a-transaction.mjs | 36 +++++++++++++++---- components/overledger/common/constants.mjs | 8 +++++ components/overledger/overledger.app.mjs | 9 +++-- 6 files changed, 65 insertions(+), 33 deletions(-) diff --git a/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs b/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs index 66b9082f38218..068811773e505 100644 --- a/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs +++ b/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs @@ -11,12 +11,12 @@ export default { requestId: { type: "string", label: "Request ID", - description: "The ID of the request for executing a signed transaction.", + description: "The Overledger identifier assigned to the related transaction preparation request. This should be set to the requestId parameter found in the response object of the 'Prepare a Smart Contract Transaction' Overledger action.", }, signedTransaction: { type: "string", label: "Signed Transaction", - description: "The signed transaction data.", + description: "The raw transaction bytecode after signing. This should be set to the signed parameter found in the response object of the 'Sign a Transaction' Overledger action.", optional: true, }, }, diff --git a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs index 64150ac1c45b3..a8d735008f6f1 100644 --- a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs +++ b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs @@ -1,5 +1,5 @@ import { - NETWORK_OPTIONS, TECHNOLOGY_OPTIONS, + NETWORK_OPTIONS, TECHNOLOGY_OPTIONS } from "../../common/constants.mjs"; import { parseObject } from "../../common/utils.mjs"; import overledger from "../../overledger.app.mjs"; @@ -22,12 +22,7 @@ export default { signingAccountId: { type: "string", label: "Signing Account ID", - description: "The blockchain account that will sign the transaction.", - }, - functionName: { - type: "string", - label: "Function Name", - description: "The name of the function to call on the smart contract.", + description: "The blockchain account (address) that you will be sending this transaction", }, smartContractId: { type: "string", @@ -35,6 +30,11 @@ export default { description: "The ID/address of the smart contract to interact with.", }, + functionName: { + type: "string", + label: "Function Name", + description: "The name of the function to call on the smart contract.", + }, inputParameters: { type: "string[]", label: "Input Parameters", @@ -55,18 +55,20 @@ export default { return props; }, async run({ $ }) { + const requestBody = { + location: { + technology: this.locationTechnology, + network: this.locationNetwork, + }, + signingAccountId: this.signingAccountId, + functionName: this.functionName, + smartContractId: this.smartContractId, + inputParameters: parseObject(this.inputParameters), + } + const response = await this.overledger.prepareSmartContractTransaction({ $, - data: { - location: { - technology: this.locationTechnology, - network: this.locationNetwork, - }, - signingAccountId: this.signingAccountId, - functionName: this.functionName, - smartContractId: this.smartContractId, - inputParameters: this.inputParameters && parseObject(this.inputParameters), - }, + data: requestBody, }); $.export("$summary", "Smart contract transaction prepared successfully"); return response; diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs index 0a758b8c29fa9..8cb29619cb17a 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs @@ -65,8 +65,6 @@ export default { smartContractId: this.smartContractId, outputParameters: parseObject(this.outputParameters), }; - - try { // Make the API call to Overledger const response = await this.overledger.readFromSmartContract({ $, @@ -74,8 +72,5 @@ export default { }); $.export("$summary", `Successfully read from contract: ${this.smartContractId}`); return response; - } catch (error) { - throw new Error(`Failed to read from smart contract: ${error.message}`); - } }, }; diff --git a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs index ec3125dc85123..e0b95a1d5b7cc 100644 --- a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs +++ b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs @@ -1,4 +1,5 @@ import overledger from "../../overledger.app.mjs"; +import { UNIT_OPTIONS } from "../../common/constants.mjs"; export default { key: "overledger-sign-smart-contract-transaction", @@ -16,11 +17,11 @@ export default { requestId: { type: "string", label: "requestId", - description: "The Overledger identifier assigned to the related transaction preparation request. This should be set to the requestId parameter found in the response object of the 'Prepare a Smart Contract Transaction' Overledger action.", + description: "The ID assigned to a preparation request in Overledger. This should be set to the requestId parameter found in the response object of the 'Prepare Smart Contract Transaction' Overledger action.", }, transactionSigningResponderName: { type: "string", - label: "Transaction Signing Responder", + label: "Transaction Signing Responder Name", description: "The name of the Transaction Signing Responder you would like to use. The CTA Transaction Signing Responder is the Quant-provided signer for testnet accounts.", }, nativeData: { @@ -28,15 +29,38 @@ export default { label: "the transaction data required to be signed", description: "A JSON object representing the transaction required to be signed.", }, + locationTechnology: { + type: "string", + label: "Location Technology", + description: "The blockchain technology used for this transaction, e.g., ethereum, substrate.", + optional: true, + // Reference the output of the previous step + default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology, + }, }, async run({ $ }) { + const gatewayFee = { + amount: "100", + unit: "QNT", + }; + // Define DLT Fee and dynamically set the 'unit' from UNIT_OPTIONS + const dltFee = { + amount: "0.000019897764079968", + unit: UNIT_OPTIONS[this.locationTechnology] || "ETH" // Use default if not found + }; // Sign the transaction + const requestBody = { + keyId: this.keyId, + gatewayFee: gatewayFee, + requestId: this.requestId, + dltFee: dltFee, + nativeData: this.nativeData, + transactionSigningResponderName: this.transactionSigningResponderName, + } + const response = await this.overledger.signTransaction({ $, - data: { - requestId: this.requestId, - nativeData: this.nativeData, - }, + data: requestBody, }); $.export("$summary", "Transaction signed successfully"); return response; diff --git a/components/overledger/common/constants.mjs b/components/overledger/common/constants.mjs index 95edbcbf63ac1..0ad06d73844be 100644 --- a/components/overledger/common/constants.mjs +++ b/components/overledger/common/constants.mjs @@ -50,3 +50,11 @@ export const NETWORK_OPTIONS = { "Sandbox", ], }; + +export const UNIT_OPTIONS = { + "ethereum": "ETH", // Ethereum's token symbol is ETH + "substrate": "DOT", // Polkadot's token symbol is DOT + "xrp ledger": "XRP", // XRP Ledger's token symbol is XRP + "bitcoin": "BTC", // Bitcoin's token symbol is BTC + "hyperledger fabric": "FAB", // Placeholder for Hyperledger Fabric's token symbol +}; \ No newline at end of file diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 3c0174e30acaa..8b0424eb0dc42 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -14,6 +14,9 @@ export default { _baseUrl() { return "https://api.overledger.io"; }, + _sanboxBaseUrl(){ + return "https://api.sandbox.overledger.io"; + }, _headers() { return { "Authorization": `Bearer ${this.$auth.oauth_access_token}`, @@ -33,7 +36,7 @@ export default { prepareSmartContractTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._baseUrl(), + baseUrl: this._sanboxBaseUrl(), path: "/api/preparations/transactions/smart-contracts/write", ...opts, }); @@ -41,7 +44,7 @@ export default { readFromSmartContract(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._baseUrl(), + baseUrl: this._sanboxBaseUrl(), path: "/api/smart-contracts/read", ...opts, }); @@ -49,7 +52,7 @@ export default { signTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: "https://api.sandbox.overledger.io", + baseUrl: this._sanboxBaseUrl(), path: "/api/transaction-signing-sandbox", ...opts, }); From 2b4a1a8cd1ab6f7a26db57adf918314354d2f78d Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 8 Oct 2024 10:55:36 +0000 Subject: [PATCH 06/16] modified readfromsmart contract transaction, prepare-sign-execute transaction actions --- .../prepare-smart-contract-transaction.mjs | 4 +-- .../read-from-smart-contract.mjs | 12 ++++----- .../sign-a-transaction/sign-a-transaction.mjs | 26 +++++++++++-------- components/overledger/common/constants.mjs | 2 +- components/overledger/overledger.app.mjs | 3 ++- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs index a8d735008f6f1..a97d246dcb4b1 100644 --- a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs +++ b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs @@ -1,5 +1,5 @@ import { - NETWORK_OPTIONS, TECHNOLOGY_OPTIONS + NETWORK_OPTIONS, TECHNOLOGY_OPTIONS, } from "../../common/constants.mjs"; import { parseObject } from "../../common/utils.mjs"; import overledger from "../../overledger.app.mjs"; @@ -64,7 +64,7 @@ export default { functionName: this.functionName, smartContractId: this.smartContractId, inputParameters: parseObject(this.inputParameters), - } + }; const response = await this.overledger.prepareSmartContractTransaction({ $, diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs index 8cb29619cb17a..6cc27eb097ca3 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs @@ -66,11 +66,11 @@ export default { outputParameters: parseObject(this.outputParameters), }; // Make the API call to Overledger - const response = await this.overledger.readFromSmartContract({ - $, - data: requestBody, - }); - $.export("$summary", `Successfully read from contract: ${this.smartContractId}`); - return response; + const response = await this.overledger.readFromSmartContract({ + $, + data: requestBody, + }); + $.export("$summary", `Successfully read from contract: ${this.smartContractId}`); + return response; }, }; diff --git a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs index e0b95a1d5b7cc..efd6837d1a1e6 100644 --- a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs +++ b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs @@ -26,27 +26,31 @@ export default { }, nativeData: { type: "object", - label: "the transaction data required to be signed", + label: "Native Data", description: "A JSON object representing the transaction required to be signed.", - }, - locationTechnology: { - type: "string", - label: "Location Technology", - description: "The blockchain technology used for this transaction, e.g., ethereum, substrate.", optional: true, // Reference the output of the previous step - default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology, + default: ({ steps }) => steps.prepare_smart_contract_transaction?.nativeData, }, }, + locationTechnology: { + type: "string", + label: "Location Technology", + description: "The blockchain technology used for this transaction, e.g., ethereum, substrate.", + optional: true, + // Reference the output of the previous step + default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology, + }, async run({ $ }) { + //default values of gatewayFee and dltfee hard coded into params. const gatewayFee = { - amount: "100", + amount: "0", unit: "QNT", }; - // Define DLT Fee and dynamically set the 'unit' from UNIT_OPTIONS + // Define DLT Fee and dynamically set the 'unit/symbol' from UNIT_OPTIONS const dltFee = { amount: "0.000019897764079968", - unit: UNIT_OPTIONS[this.locationTechnology] || "ETH" // Use default if not found + unit: UNIT_OPTIONS[this.locationTechnology] || "ETH", // Use default if not found }; // Sign the transaction const requestBody = { @@ -56,7 +60,7 @@ export default { dltFee: dltFee, nativeData: this.nativeData, transactionSigningResponderName: this.transactionSigningResponderName, - } + }; const response = await this.overledger.signTransaction({ $, diff --git a/components/overledger/common/constants.mjs b/components/overledger/common/constants.mjs index 0ad06d73844be..c435539a31d1f 100644 --- a/components/overledger/common/constants.mjs +++ b/components/overledger/common/constants.mjs @@ -57,4 +57,4 @@ export const UNIT_OPTIONS = { "xrp ledger": "XRP", // XRP Ledger's token symbol is XRP "bitcoin": "BTC", // Bitcoin's token symbol is BTC "hyperledger fabric": "FAB", // Placeholder for Hyperledger Fabric's token symbol -}; \ No newline at end of file +}; diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 8b0424eb0dc42..5e92204cece43 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -14,7 +14,8 @@ export default { _baseUrl() { return "https://api.overledger.io"; }, - _sanboxBaseUrl(){ + //Sanbox base URL + _sanboxBaseUrl() { return "https://api.sandbox.overledger.io"; }, _headers() { From ee22f4049e9491766845049bc8b724d850feb090 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 8 Oct 2024 11:03:20 +0000 Subject: [PATCH 07/16] modified readfromsmart contract transaction, prepare-sign-execute transaction actions --- components/overledger/common/constants.mjs | 2 +- components/overledger/overledger.app.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/overledger/common/constants.mjs b/components/overledger/common/constants.mjs index c435539a31d1f..93b70bbab5fee 100644 --- a/components/overledger/common/constants.mjs +++ b/components/overledger/common/constants.mjs @@ -50,7 +50,7 @@ export const NETWORK_OPTIONS = { "Sandbox", ], }; - +///unit options to allow for the correct selection based on the location network export const UNIT_OPTIONS = { "ethereum": "ETH", // Ethereum's token symbol is ETH "substrate": "DOT", // Polkadot's token symbol is DOT diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 5e92204cece43..579236e8ef53d 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -14,7 +14,7 @@ export default { _baseUrl() { return "https://api.overledger.io"; }, - //Sanbox base URL + //Sanbox base URL signing - allows for use on non _sanboxBaseUrl() { return "https://api.sandbox.overledger.io"; }, From 281f0d6f2d9192ce554ec08338067df00cd7d495 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 8 Oct 2024 11:29:05 +0000 Subject: [PATCH 08/16] modified readfromsmart contract transaction, prepare-sign-execute transaction actions --- components/overledger/overledger.app.mjs | 10 +++++----- .../watch-new-account-event-instant.mjs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 579236e8ef53d..b555de4edaa5d 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -14,8 +14,8 @@ export default { _baseUrl() { return "https://api.overledger.io"; }, - //Sanbox base URL signing - allows for use on non - _sanboxBaseUrl() { + //Sandbox base URL - allows for use on Sandbox environments + _sandboxBaseUrl() { return "https://api.sandbox.overledger.io"; }, _headers() { @@ -37,7 +37,7 @@ export default { prepareSmartContractTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._sanboxBaseUrl(), + baseUrl: this._sandboxBaseUrl(), path: "/api/preparations/transactions/smart-contracts/write", ...opts, }); @@ -53,7 +53,7 @@ export default { signTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._sanboxBaseUrl(), + baseUrl: this._sandboxBaseUrl(), path: "/api/transaction-signing-sandbox", ...opts, }); @@ -61,7 +61,7 @@ export default { executeSignedTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._baseUrl(), + baseUrl: this._sandboxBaseUrl(), path: "/api/executions/transactions", ...opts, }); diff --git a/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs b/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs index 0819fc7e8641c..f8e866d73bb46 100644 --- a/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs +++ b/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs @@ -27,7 +27,7 @@ export default { }; }, getSummary(body) { - return `New asccount event with transaction Id: ${body.transactionId}`; + return `New account event with transaction Id: ${body.transactionId}`; }, }, sampleEmit, From 9dff0186f3e45545c9b1184daead979da22dcd33 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 8 Oct 2024 15:58:00 +0000 Subject: [PATCH 09/16] modified Overledger.app to add instance selection between Sandbox and Live Overledger --- components/overledger/overledger.app.mjs | 38 +++++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index b555de4edaa5d..81057a79100c0 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -3,6 +3,24 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "overledger", + props: { //Options to allow for instance selection of Overledger environment - Sanbox or Live Overledger ro determine BaseURL + environment: { + type: "string", + label: "Overledger Instance", + description: "Select the Overledger environment.", + options: [ + { + label: "Sandbox", + value: "sandbox", + }, + { + label: "Overledger", + value: "overledger", + }, + ], + optional: false, + }, + }, propDefinitions: { smartContractId: { type: "string", @@ -11,13 +29,6 @@ export default { }, }, methods: { - _baseUrl() { - return "https://api.overledger.io"; - }, - //Sandbox base URL - allows for use on Sandbox environments - _sandboxBaseUrl() { - return "https://api.sandbox.overledger.io"; - }, _headers() { return { "Authorization": `Bearer ${this.$auth.oauth_access_token}`, @@ -25,6 +36,11 @@ export default { "API-Version": "3.0.0", }; }, + _getBaseUrl() { //conditional to for environment selection. + return this.environment === "sandbox" + ? "https://api.sandbox.overledger.io" + : "https://api.overledger.io"; + }, _makeRequest({ $ = this, baseUrl, path, ...otherOpts }) { @@ -37,7 +53,7 @@ export default { prepareSmartContractTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._sandboxBaseUrl(), + baseUrl: this._getBaseUrl(), path: "/api/preparations/transactions/smart-contracts/write", ...opts, }); @@ -45,7 +61,7 @@ export default { readFromSmartContract(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._sanboxBaseUrl(), + baseUrl: this._getBaseUrl(), path: "/api/smart-contracts/read", ...opts, }); @@ -53,7 +69,7 @@ export default { signTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._sandboxBaseUrl(), + baseUrl: this._getBaseUrl(), path: "/api/transaction-signing-sandbox", ...opts, }); @@ -61,7 +77,7 @@ export default { executeSignedTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._sandboxBaseUrl(), + baseUrl: this._getBaseUrl(), path: "/api/executions/transactions", ...opts, }); From 08bc1aea94eb32408b29c7db36bb761e858740c0 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 8 Oct 2024 16:53:17 +0000 Subject: [PATCH 10/16] modified Overledger.app to add instance selection between Sandbox and Live Overledger - altered basURL in hook methods create and delete --- components/overledger/overledger.app.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 81057a79100c0..1d131a7a93f23 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -87,7 +87,7 @@ export default { }) { return this._makeRequest({ method: "POST", - baseUrl: this._baseUrl(), + baseUrl: this._getBaseUrl(), path: `/api/webhooks/${path}`, ...opts, }); @@ -97,7 +97,7 @@ export default { }) { return this._makeRequest({ method: "DELETE", - baseUrl: this._baseUrl(), + baseUrl: this._getBaseUrl(), path: `/api/webhooks/${path}/${webhookId}`, }); }, From 6193c92540b0f49a314e030c61a3b562d2975388 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 8 Oct 2024 17:28:06 +0000 Subject: [PATCH 11/16] comments added to explain actions modifications --- .../prepare-smart-contract-transaction.mjs | 2 +- .../read-from-a-smart-contract/read-from-smart-contract.mjs | 2 +- components/overledger/overledger.app.mjs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs index a97d246dcb4b1..c43be05bbd25f 100644 --- a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs +++ b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs @@ -63,7 +63,7 @@ export default { signingAccountId: this.signingAccountId, functionName: this.functionName, smartContractId: this.smartContractId, - inputParameters: parseObject(this.inputParameters), + inputParameters: parseObject(this.inputParameters), //parse these values using the parseObject function at this shouls turn the JSON string into JSON objects to used in the request body. }; const response = await this.overledger.prepareSmartContractTransaction({ diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs index 6cc27eb097ca3..729b4e3059c16 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs @@ -61,7 +61,7 @@ export default { network: this.locationNetwork, }, functionName: this.functionName, - inputParameters: parseObject(this.inputParameters), + inputParameters: parseObject(this.inputParameters), //parse these values using the parseObject function at this shouls turn the JSON string into JSON objects to used in the request body. smartContractId: this.smartContractId, outputParameters: parseObject(this.outputParameters), }; diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 1d131a7a93f23..dae98cd559e7b 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -3,7 +3,7 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "overledger", - props: { //Options to allow for instance selection of Overledger environment - Sanbox or Live Overledger ro determine BaseURL + props: { //Options to allow for instance selection of Overledger environment - Sandbox or Live Overledger to determine BaseURL environment: { type: "string", label: "Overledger Instance", @@ -36,7 +36,7 @@ export default { "API-Version": "3.0.0", }; }, - _getBaseUrl() { //conditional to for environment selection. + _getBaseUrl() { //conditional for environment url selection. return this.environment === "sandbox" ? "https://api.sandbox.overledger.io" : "https://api.overledger.io"; From a2ec749fa69d07b0c7d653032e65d19581f4f028 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Wed, 9 Oct 2024 09:46:40 +0000 Subject: [PATCH 12/16] added versioning updates to actions and overledger pckage.json. as well as component key adjustments to alin with pipedream requirements --- .../execute-signed-transaction.mjs | 2 +- .../prepare-smart-contract-transaction.mjs | 2 +- ...om-smart-contract.mjs => read-from-a-smart-contract.mjs} | 4 ++-- .../actions/sign-a-transaction/sign-a-transaction.mjs | 6 +++--- components/overledger/package.json | 2 +- .../new-contract-event-instant.mjs | 2 +- .../watch-new-account-event-instant.mjs | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) rename components/overledger/actions/read-from-a-smart-contract/{read-from-smart-contract.mjs => read-from-a-smart-contract.mjs} (96%) diff --git a/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs b/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs index 068811773e505..9d6e7b1af276f 100644 --- a/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs +++ b/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs @@ -4,7 +4,7 @@ export default { key: "overledger-execute-signed-transaction", name: "Execute Signed Transaction", description: "Executes a signed transaction by sending it to a blockchain node via Overledger. [See the documentation](https://developers.quant.network/reference/executesignedrequest)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { overledger, diff --git a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs index c43be05bbd25f..3b59535c9f3f2 100644 --- a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs +++ b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs @@ -8,7 +8,7 @@ export default { key: "overledger-prepare-smart-contract-transaction", name: "Prepare Smart Contract Transaction", description: "Prepares a smart contract transaction for signing on the Overledger platform. [See the documentation](https://developers.quant.network/reference/preparesmartcontractwrite)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { overledger, diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs similarity index 96% rename from components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs rename to components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs index 729b4e3059c16..b8f72cc70418c 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs @@ -5,8 +5,8 @@ import { parseObject } from "../../common/utils.mjs"; import overledger from "../../overledger.app.mjs"; export default { - key: "overledger-read-from-smart-contract", - name: "Read from Smart Contract", + key: "overledger-read-from-a-smart-contract", + name: "Read from a smart contract", description: "Reads data from a specified smart contract on the Overledger network.", version: "0.0.1", type: "action", diff --git a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs index efd6837d1a1e6..2909022e4efbc 100644 --- a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs +++ b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs @@ -2,9 +2,9 @@ import overledger from "../../overledger.app.mjs"; import { UNIT_OPTIONS } from "../../common/constants.mjs"; export default { - key: "overledger-sign-smart-contract-transaction", - name: "Sign Smart Contract Transaction", - description: "Sign and send a transaction to a smart contract using Overledger", + key: "overledger-sign-a-transaction", + name: "Sign a transaction", + description: "Sign a transaction using Overledger", version: "0.0.1", type: "action", props: { diff --git a/components/overledger/package.json b/components/overledger/package.json index 8b691556dba80..7cb7ad307a8bb 100644 --- a/components/overledger/package.json +++ b/components/overledger/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/overledger", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Overledger Components", "main": "overledger.app.mjs", "keywords": [ diff --git a/components/overledger/sources/new-contract-event-instant/new-contract-event-instant.mjs b/components/overledger/sources/new-contract-event-instant/new-contract-event-instant.mjs index 3ca4b30a53e33..1ea476ebfe6c8 100644 --- a/components/overledger/sources/new-contract-event-instant/new-contract-event-instant.mjs +++ b/components/overledger/sources/new-contract-event-instant/new-contract-event-instant.mjs @@ -6,7 +6,7 @@ export default { key: "overledger-new-contract-event-instant", name: "New Smart Contract Event (Instant)", description: "Emit new event when a smart contract releases a new event.", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { diff --git a/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs b/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs index f8e866d73bb46..f0c29481e1883 100644 --- a/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs +++ b/components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs @@ -6,7 +6,7 @@ export default { key: "overledger-watch-new-account-event-instant", name: "New Account Event (Instant)", description: "Emit new event for transactions to/from a specific account.", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { From f7a15bae3cd3bb2fda413b98d826aee1319fbc2d Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Thu, 10 Oct 2024 10:45:35 +0000 Subject: [PATCH 13/16] code revisions made based on pull request review --- .../execute-signed-transaction.mjs | 18 +++++++-- .../prepare-smart-contract-transaction.mjs | 7 ++++ .../read-from-a-smart-contract.mjs | 7 ++++ .../sign-a-transaction/sign-a-transaction.mjs | 7 ++++ components/overledger/common/constants.mjs | 11 ++++++ components/overledger/overledger.app.mjs | 39 ++++++------------- 6 files changed, 57 insertions(+), 32 deletions(-) diff --git a/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs b/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs index 9d6e7b1af276f..6dde413c438be 100644 --- a/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs +++ b/components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs @@ -8,6 +8,12 @@ export default { type: "action", props: { overledger, + environment: { + propDefinition: [ + overledger, + "environment", + ], + }, requestId: { type: "string", label: "Request ID", @@ -21,12 +27,16 @@ export default { }, }, async run({ $ }) { + + const requestBody = { + requestId: this.requestId, + signedTransaction: this.signedTransaction, + }; + const response = await this.overledger.executeSignedTransaction({ $, - data: { - requestId: this.requestId, - signedTransaction: this.signedTransaction, - }, + environment: this.environment, + data: requestBody, }); $.export("$summary", `Successfully executed signed transaction with Request ID ${this.requestId}`); diff --git a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs index 3b59535c9f3f2..deb49aa89a537 100644 --- a/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs +++ b/components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs @@ -12,6 +12,12 @@ export default { type: "action", props: { overledger, + environment: { + propDefinition: [ + overledger, + "environment", + ], + }, locationTechnology: { type: "string", label: "Location Technology", @@ -68,6 +74,7 @@ export default { const response = await this.overledger.prepareSmartContractTransaction({ $, + environment: this.environment, data: requestBody, }); $.export("$summary", "Smart contract transaction prepared successfully"); diff --git a/components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs b/components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs index b8f72cc70418c..7898ad5c8b216 100644 --- a/components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs +++ b/components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs @@ -12,6 +12,12 @@ export default { type: "action", props: { overledger, + environment: { + propDefinition: [ + overledger, + "environment", + ], + }, locationTechnology: { type: "string", label: "Location Technology", @@ -68,6 +74,7 @@ export default { // Make the API call to Overledger const response = await this.overledger.readFromSmartContract({ $, + environment: this.environment, data: requestBody, }); $.export("$summary", `Successfully read from contract: ${this.smartContractId}`); diff --git a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs index 2909022e4efbc..b0cc190c32433 100644 --- a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs +++ b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs @@ -9,6 +9,12 @@ export default { type: "action", props: { overledger, + environment: { + propDefinition: [ + overledger, + "environment", + ], + }, keyId: { type: "string", label: "Signing Account ID", @@ -64,6 +70,7 @@ export default { const response = await this.overledger.signTransaction({ $, + environment: this.environment, data: requestBody, }); $.export("$summary", "Transaction signed successfully"); diff --git a/components/overledger/common/constants.mjs b/components/overledger/common/constants.mjs index 93b70bbab5fee..e9e8dd4a77959 100644 --- a/components/overledger/common/constants.mjs +++ b/components/overledger/common/constants.mjs @@ -50,6 +50,17 @@ export const NETWORK_OPTIONS = { "Sandbox", ], }; +//Overledger environment to be used - Test or Live +export const OVERLEDGER_INSTANCE = [ + { + label: "Sandbox", + value: "sandbox", + }, + { + label: "Overledger", + value: "overledger", + }, +]; ///unit options to allow for the correct selection based on the location network export const UNIT_OPTIONS = { "ethereum": "ETH", // Ethereum's token symbol is ETH diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index dae98cd559e7b..0f1075aaa4603 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -1,32 +1,21 @@ import { axios } from "@pipedream/platform"; +import { OVERLEDGER_INSTANCE } from "./common/constants.mjs"; export default { type: "app", app: "overledger", - props: { //Options to allow for instance selection of Overledger environment - Sandbox or Live Overledger to determine BaseURL - environment: { - type: "string", - label: "Overledger Instance", - description: "Select the Overledger environment.", - options: [ - { - label: "Sandbox", - value: "sandbox", - }, - { - label: "Overledger", - value: "overledger", - }, - ], - optional: false, - }, - }, propDefinitions: { smartContractId: { type: "string", label: "Smart Contract ID", description: "The ID of the smart contract to interact with.", }, + environment: { + type: "string", + label: "Overledger Instance", + description: "Select the Overledger instance to be used", + options: OVERLEDGER_INSTANCE, + }, }, methods: { _headers() { @@ -36,24 +25,23 @@ export default { "API-Version": "3.0.0", }; }, - _getBaseUrl() { //conditional for environment url selection. - return this.environment === "sandbox" + _getBaseUrl(environment) { //conditional for environment url selection. + return environment === "sandbox" ? "https://api.sandbox.overledger.io" : "https://api.overledger.io"; }, _makeRequest({ - $ = this, baseUrl, path, ...otherOpts + $ = this, environment, path, ...otherOpts }) { return axios($, { ...otherOpts, - url: baseUrl + path, + url: this._getBaseUrl(environment) + path, headers: this._headers(), }); }, prepareSmartContractTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._getBaseUrl(), path: "/api/preparations/transactions/smart-contracts/write", ...opts, }); @@ -61,7 +49,6 @@ export default { readFromSmartContract(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._getBaseUrl(), path: "/api/smart-contracts/read", ...opts, }); @@ -69,7 +56,6 @@ export default { signTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._getBaseUrl(), path: "/api/transaction-signing-sandbox", ...opts, }); @@ -77,7 +63,6 @@ export default { executeSignedTransaction(opts = {}) { return this._makeRequest({ method: "POST", - baseUrl: this._getBaseUrl(), path: "/api/executions/transactions", ...opts, }); @@ -87,7 +72,6 @@ export default { }) { return this._makeRequest({ method: "POST", - baseUrl: this._getBaseUrl(), path: `/api/webhooks/${path}`, ...opts, }); @@ -97,7 +81,6 @@ export default { }) { return this._makeRequest({ method: "DELETE", - baseUrl: this._getBaseUrl(), path: `/api/webhooks/${path}/${webhookId}`, }); }, From 271233d06b5689ac4c0e7580a04a2a424e70c7a1 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Fri, 11 Oct 2024 12:20:25 +0000 Subject: [PATCH 14/16] added enironment prop to commmon sources file (base.mjs) and updated delete and creathooks to take in this param --- components/overledger/overledger.app.mjs | 3 ++- components/overledger/sources/common/base.mjs | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/overledger/overledger.app.mjs b/components/overledger/overledger.app.mjs index 0f1075aaa4603..d7f4e561f6569 100644 --- a/components/overledger/overledger.app.mjs +++ b/components/overledger/overledger.app.mjs @@ -77,11 +77,12 @@ export default { }); }, deleteHook({ - path, webhookId, + path, webhookId, ...opts }) { return this._makeRequest({ method: "DELETE", path: `/api/webhooks/${path}/${webhookId}`, + ...opts, }); }, }, diff --git a/components/overledger/sources/common/base.mjs b/components/overledger/sources/common/base.mjs index ffce0a02e37f3..c6a6ae816976f 100644 --- a/components/overledger/sources/common/base.mjs +++ b/components/overledger/sources/common/base.mjs @@ -6,6 +6,12 @@ import overledger from "../../overledger.app.mjs"; export default { props: { overledger, + environment: { + propDefinition: [ + overledger, + "environment", + ], + }, db: "$.service.db", http: { type: "$.interface.http", @@ -35,6 +41,7 @@ export default { async activate() { const response = await this.overledger.createHook({ path: this.getPath(), + environment: this.environment, data: { location: { technology: this.locationTechnology, @@ -51,6 +58,7 @@ export default { await this.overledger.deleteHook({ path: this.getPath(), webhookId, + environment: this.environment, }); }, }, From 7e639e01756a0ed304ebef9cedeb40fc6e123f72 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Tue, 15 Oct 2024 09:22:52 +0000 Subject: [PATCH 15/16] fixed issue with sign-a-transaction default nativeData being undefined now is object --- .../sign-a-transaction/sign-a-transaction.mjs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs index b0cc190c32433..9e5a140ad2fe5 100644 --- a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs +++ b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs @@ -15,6 +15,13 @@ export default { "environment", ], }, + locationTechnology: { + type: "string", + label: "Location Technology", + description: "The blockchain technology used for this transaction, e.g., ethereum, substrate - required in order to set the dltfee", + //previous prep step output - reuired in this step in order to set the dltfee unit + default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology || "ethereum", + }, keyId: { type: "string", label: "Signing Account ID", @@ -34,19 +41,10 @@ export default { type: "object", label: "Native Data", description: "A JSON object representing the transaction required to be signed.", - optional: true, // Reference the output of the previous step - default: ({ steps }) => steps.prepare_smart_contract_transaction?.nativeData, + default: ({ steps }) => steps.prepare_smart_contract_transaction?.nativeData || {}, }, }, - locationTechnology: { - type: "string", - label: "Location Technology", - description: "The blockchain technology used for this transaction, e.g., ethereum, substrate.", - optional: true, - // Reference the output of the previous step - default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology, - }, async run({ $ }) { //default values of gatewayFee and dltfee hard coded into params. const gatewayFee = { From 1ae32d056c405559ed3421edff2ba173de639ba5 Mon Sep 17 00:00:00 2001 From: Phil Buuza Date: Sun, 20 Oct 2024 22:46:21 +0000 Subject: [PATCH 16/16] removal of default actions prop values on sign-transaction - stop error flag --- .../actions/sign-a-transaction/sign-a-transaction.mjs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs index 9e5a140ad2fe5..af30ce4067766 100644 --- a/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs +++ b/components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs @@ -19,8 +19,6 @@ export default { type: "string", label: "Location Technology", description: "The blockchain technology used for this transaction, e.g., ethereum, substrate - required in order to set the dltfee", - //previous prep step output - reuired in this step in order to set the dltfee unit - default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology || "ethereum", }, keyId: { type: "string", @@ -41,8 +39,6 @@ export default { type: "object", label: "Native Data", description: "A JSON object representing the transaction required to be signed.", - // Reference the output of the previous step - default: ({ steps }) => steps.prepare_smart_contract_transaction?.nativeData || {}, }, }, async run({ $ }) {