Skip to content

Commit

Permalink
Update the client shell to fix bugs and improve invocations
Browse files Browse the repository at this point in the history
Signed-off-by: Mic Bowman <[email protected]>
  • Loading branch information
cmickeyb authored and prakashngit committed Feb 19, 2020
1 parent e02f76e commit ed4cbad
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
20 changes: 14 additions & 6 deletions client/bin/pdo-invoke.psh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
##
## Required:
## pdo_file -- save file for the contract
## expr -- expression to be evaluated
## method -- method to be evaluated
## params -- JSON-encoded list of positional parameters
## identity -- the identity of the contract creator
##
## $ ./pdo-invoke.psh -m contract <contract> -expr <expression> -m identity <identity>

set -q --conditional -s data -v .
set -q --conditional -s params -v ""
set -q --conditional -s method -v ""

script -f ${home}/etc/site.psh

if -e ${identity} '__unknown__'
Expand All @@ -40,12 +43,17 @@ if -n ${pdo_file}
exit
fi

if -n ${expr}
echo missing required parameter, expr
identity -n ${identity}

if -n ${method}
echo missing method to invoke
exit
fi

identity -n ${identity}
send -f ${pdo_file} ${expr}
if -n ${params}
send -f ${pdo_file} ${method}
else
send -f ${pdo_file} -p ${params} ${method}
fi

exit
4 changes: 3 additions & 1 deletion client/pdo/client/controller/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import argparse
import logging
import random
Expand Down Expand Up @@ -109,10 +110,11 @@ def __create_contract(ledger_config, client_keys, preferred_eservice_client, ese
def command_create(state, bindings, pargs) :
"""controller command to create a contract
"""
interp = os.environ.get("PDO_INTERPRETER", "gipsy")

parser = argparse.ArgumentParser(prog='create')
parser.add_argument('-c', '--contract-class', help='Name of the contract class', required = True, type=str)
parser.add_argument('-i', '--interpreter', help='Name of the interpreter used to evaluate the contract', default='gipsy')
parser.add_argument('-i', '--interpreter', help='Name of the interpreter used to evaluate the contract', default=interp)
parser.add_argument('-s', '--contract-source', help='File that contains contract source code', required=True, type=str)
parser.add_argument('-p', '--pservice-group', help='Name of the provisioning service group to use', default="default")
parser.add_argument('-e', '--eservice-group', help='Name of the enclave service group to use', default="default")
Expand Down
10 changes: 9 additions & 1 deletion client/pdo/client/controller/commands/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def command_send(state, bindings, pargs) :
parser = argparse.ArgumentParser(prog='send')
parser.add_argument('-e', '--enclave', help='URL of the enclave service to use', type=str)
parser.add_argument('-f', '--save-file', help='File where contract data is stored', type=str)
parser.add_argument('-p', '--positional', help='JSON encoded list of positional parameters', type=invocation_parameter)
parser.add_argument('-s', '--symbol', help='Save the result in a symbol for later use', type=str)
parser.add_argument('-q', '--quiet', help='Do not print the result', action='store_true')
parser.add_argument('--wait', help='Wait for the transaction to commit', action = 'store_true')
Expand All @@ -156,9 +157,16 @@ def command_send(state, bindings, pargs) :

options = parser.parse_args(pargs)
waitflag = options.wait

method = options.method

pparams = options.positional_params or []
pparams = []
if options.positional :
assert type(options.positional) is list
pparams.extend(options.positional)

if options.positional_params :
pparams.extend(options.positional_params)

kparams = dict()
if options.kwarg :
Expand Down
5 changes: 4 additions & 1 deletion client/pdo/client/controller/contract_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def do_if(self, args) :
pargs = self.__arg_parse__(args)

parser = argparse.ArgumentParser(prog='if')
parser.add_argument('--not', help='inverts the result of the query', action='store_true')
parser.add_argument('--not', help='inverts the result of the query', dest='invert', action='store_true')

eparser = parser.add_mutually_exclusive_group(required=True)
eparser.add_argument('-z', '--zero', help="true if the argument is 0", type=int)
Expand All @@ -332,6 +332,9 @@ def do_if(self, args) :
else :
condition = False

if options.invert :
condition = not condition

if not condition :
self.deferred += 1

Expand Down

0 comments on commit ed4cbad

Please sign in to comment.