From 0fab108e33b46018c91242d72487ac3adc3c0f20 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 22 Aug 2023 08:01:13 -0700 Subject: [PATCH] Update for PR feedback. Update documentation. Remove a few extra imports from python files. Signed-off-by: Mic Bowman --- client/docs/plugin_model.md | 28 +++++++++++++------ .../plugins/attestation-test.py | 1 - contracts/wawaka/kv-test/plugins/kv-test.py | 2 -- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/client/docs/plugin_model.md b/client/docs/plugin_model.md index 1828aa98..f087c626 100644 --- a/client/docs/plugin_model.md +++ b/client/docs/plugin_model.md @@ -14,14 +14,19 @@ bash script. Similarly, the `mint_tokens` command may invoke a series of operations across multiple contract objects in order to mint new NFT tokens. -There are three general styles of plugins: *contract operations*, -*contract commands* and *scripts*. Loosely, a contract operation wraps +There are three general styles of plugins: + +* *contract operations* : Loosely, a contract operation wraps the invocation of a single method on a contract object. Contract operations are parameterized to interact with a specific contract object with defaults for enclave service and ledger -connections. Contract commands provide a logical operation that spans +connections. + +* *contract commands* : Contract commands provide a logical operation that spans multiple invocations (possibly across multiple contract -objects). Scripts simply provide a useful local function (such as +objects). + +* *scripts* : Scripts simply provide a useful local function (such as updating the current configuration). The PDO client library includes a basic set of scripts that should be sufficient for most uses. @@ -51,7 +56,7 @@ that sets up the invocation of the method on `kv-test` contract objects. The contract command portion of the plugin defines a set of commands -that span multiple operations, dervied from the +that span multiple operations, derived from the `contract_command_base` class. For example, provisioning a `token_issuer` contract object requires two operations to be performed (`add_endpoint` and `provision_token_issuer`). The `provision` command @@ -84,7 +89,7 @@ the configuration of a contract object and its relationship to other contract objects. Scripts, take no additional parameters beyond the `State`. -Functionality defined in the pluging can be mapped to a `pdo-shell` +Functionality defined in the plugin can be mapped to a `pdo-shell` command by defining an entry point and binding it to a command attribute in the shell class. Each type of operation (contract operations, contract commands and scripts) has a class-specific @@ -94,6 +99,10 @@ generator that creates a function for the shell, ## Base Classes ## +The base classes are primarily used to define consistent interfaces +across the different types of objects. The base classes also provide +a common set of display functions. + ### State ### Implements the client and contract configuration as a multi-tiered @@ -138,9 +147,10 @@ configuration file. ### SessionParameters ### -Captures the parameters for interacting with a specific contract. This -includes information about the contract (the contract save file) and -the preferred eservice for interacting with the contract. +Captures the parameters for interacting with a specific contract +instance. This includes information about the contract (the contract +save file) and the preferred eservice for interacting with the +contract. Properties include: * `eservice_url` -- Enclave service to use for all operations diff --git a/contracts/wawaka/attestation-test/plugins/attestation-test.py b/contracts/wawaka/attestation-test/plugins/attestation-test.py index d6dc687c..779f0da5 100644 --- a/contracts/wawaka/attestation-test/plugins/attestation-test.py +++ b/contracts/wawaka/attestation-test/plugins/attestation-test.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import ast import argparse import json import logging diff --git a/contracts/wawaka/kv-test/plugins/kv-test.py b/contracts/wawaka/kv-test/plugins/kv-test.py index 31d2d23b..48afde56 100644 --- a/contracts/wawaka/kv-test/plugins/kv-test.py +++ b/contracts/wawaka/kv-test/plugins/kv-test.py @@ -15,14 +15,12 @@ import argparse import json import logging -import random logger = logging.getLogger(__name__) import pdo.client.builder.shell as pshell import pdo.client.builder.contract as pcontract -from pdo.service_client.enclave import EnclaveServiceClient from pdo.client.commands.contract import send_to_contract from pdo.client.commands.eservice import get_eservice_from_contract from pdo.contract import invocation_request