Skip to content

Commit

Permalink
Update old ScalarDL cli commands with new subcommands for v3.9.0 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkey-mas authored Feb 13, 2024
1 parent 0017068 commit 1c8de1f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
32 changes: 16 additions & 16 deletions docs/applications/escrow-payment/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ register-all: register-cert register-contracts

register-cert:
@echo "Registering certificate ..."
@client/bin/register-cert --properties client.properties
@client/bin/scalardl register-cert --properties client.properties

assemble: clear
@echo "Building contracts ..."
@./gradlew assemble

register-contracts: assemble
@echo "Registering contracts ..."
@client/bin/register-contract --properties client.properties --contract-id AddAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.AddAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/AddAccount.class
@client/bin/register-contract --properties client.properties --contract-id AddItem_foo --contract-binary-name com.ypeckstadt.escrow.contract.item.AddItem --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/item/AddItem.class
@client/bin/register-contract --properties client.properties --contract-id AddOrder_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.AddOrder --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/AddOrder.class
@client/bin/register-contract --properties client.properties --contract-id CancelOrder_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.CancelOrder --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/CancelOrder.class
@client/bin/register-contract --properties client.properties --contract-id ChargeAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.ChargeAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/ChargeAccount.class
@client/bin/register-contract --properties client.properties --contract-id SetOrderToReceivedStatus_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.SetOrderToReceivedStatus --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/SetOrderToReceivedStatus.class
@client/bin/register-contract --properties client.properties --contract-id SetOrderToShippedStatus_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.SetOrderToShippedStatus --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/SetOrderToShippedStatus.class
@client/bin/register-contract --properties client.properties --contract-id ViewAccountHistory_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.ViewAccountHistory --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/ViewAccountHistory.class
@client/bin/register-contract --properties client.properties --contract-id ViewItem_foo --contract-binary-name com.ypeckstadt.escrow.contract.item.ViewItem --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/item/ViewItem.class
@client/bin/register-contract --properties client.properties --contract-id DebitEscrowAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.DebitEscrowAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/DebitEscrowAccount.class
@client/bin/register-contract --properties client.properties --contract-id CreditEscrowAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.CreditEscrowAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/CreditEscrowAccount.class
@client/bin/register-contract --properties client.properties --contract-id CreditAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.CreditAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/CreditAccount.class
@client/bin/register-contract --properties client.properties --contract-id DebitAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.DebitAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/DebitAccount.class
@client/bin/register-contract --properties client.properties --contract-id ViewOrderHistory_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.ViewOrderHistory --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/ViewOrderHistory.class
@client/bin/register-contract --properties client.properties --contract-id ViewEscrowAccountHistory_foo --contract-binary-name com.ypeckstadt.escrow.contract.escrowAccount.ViewEscrowAccountHistory --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/escrowAccount/ViewEscrowAccountHistory.class
@client/bin/scalardl register-contract --properties client.properties --contract-id AddAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.AddAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/AddAccount.class
@client/bin/scalardl register-contract --properties client.properties --contract-id AddItem_foo --contract-binary-name com.ypeckstadt.escrow.contract.item.AddItem --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/item/AddItem.class
@client/bin/scalardl register-contract --properties client.properties --contract-id AddOrder_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.AddOrder --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/AddOrder.class
@client/bin/scalardl register-contract --properties client.properties --contract-id CancelOrder_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.CancelOrder --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/CancelOrder.class
@client/bin/scalardl register-contract --properties client.properties --contract-id ChargeAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.ChargeAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/ChargeAccount.class
@client/bin/scalardl register-contract --properties client.properties --contract-id SetOrderToReceivedStatus_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.SetOrderToReceivedStatus --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/SetOrderToReceivedStatus.class
@client/bin/scalardl register-contract --properties client.properties --contract-id SetOrderToShippedStatus_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.SetOrderToShippedStatus --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/SetOrderToShippedStatus.class
@client/bin/scalardl register-contract --properties client.properties --contract-id ViewAccountHistory_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.ViewAccountHistory --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/ViewAccountHistory.class
@client/bin/scalardl register-contract --properties client.properties --contract-id ViewItem_foo --contract-binary-name com.ypeckstadt.escrow.contract.item.ViewItem --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/item/ViewItem.class
@client/bin/scalardl register-contract --properties client.properties --contract-id DebitEscrowAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.DebitEscrowAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/DebitEscrowAccount.class
@client/bin/scalardl register-contract --properties client.properties --contract-id CreditEscrowAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.CreditEscrowAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/CreditEscrowAccount.class
@client/bin/scalardl register-contract --properties client.properties --contract-id CreditAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.CreditAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/CreditAccount.class
@client/bin/scalardl register-contract --properties client.properties --contract-id DebitAccount_foo --contract-binary-name com.ypeckstadt.escrow.contract.account.DebitAccount --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/account/DebitAccount.class
@client/bin/scalardl register-contract --properties client.properties --contract-id ViewOrderHistory_foo --contract-binary-name com.ypeckstadt.escrow.contract.order.ViewOrderHistory --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/order/ViewOrderHistory.class
@client/bin/scalardl register-contract --properties client.properties --contract-id ViewEscrowAccountHistory_foo --contract-binary-name com.ypeckstadt.escrow.contract.escrowAccount.ViewEscrowAccountHistory --contract-class-file build/classes/java/main/com/ypeckstadt/escrow/contract/escrowAccount/ViewEscrowAccountHistory.class

clear:
@rm -rf build
Expand Down
12 changes: 6 additions & 6 deletions docs/applications/simple-bank-account/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ scalar.dl.client.private_key_path=conf/client-key.pem
If everything is set up properly you should be able to register your certificate on the ScalarDL network as

```bash
$ ${SCALAR_SDK_HOME}/client/bin/register-cert --properties ./conf/client.properties
$ ${SCALAR_SDK_HOME}/client/bin/scalardl register-cert --properties ./conf/client.properties
```

You should receive status code 200 if successful.
Expand Down Expand Up @@ -157,7 +157,7 @@ In this example we will register three contracts: `CreateAccount.java`, `Deposit
Once your toml file is written you can register all the specified contracts as

```bash
$ ${SCALAR_SDK_HOME}/client/bin/register-contracts --properties ./conf/client.properties --contracts-file ./conf/contracts.toml
$ ${SCALAR_SDK_HOME}/client/bin/scalardl register-contracts --properties ./conf/client.properties --contracts-file ./conf/contracts.toml
```

Each successfully registered contract should return status code 200.
Expand All @@ -169,20 +169,20 @@ You can now execute any registered contracts if you would like. For example, use
Create two accounts with ids `a111` and `b222`. (Contract ids can be any string.)

```bash
$ ${SCALAR_SDK_HOME}/client/bin/execute-contract --properties ./conf/client.properties --contract-id create-account --contract-argument '{"id": "a111"}'
$ ${SCALAR_SDK_HOME}/client/bin/execute-contract --properties ./conf/client.properties --contract-id create-account --contract-argument '{"id": "b222"}'
$ ${SCALAR_SDK_HOME}/client/bin/scalardl execute-contract --properties ./conf/client.properties --contract-id create-account --contract-argument '{"id": "a111"}'
$ ${SCALAR_SDK_HOME}/client/bin/scalardl execute-contract --properties ./conf/client.properties --contract-id create-account --contract-argument '{"id": "b222"}'
```

Now, deposit 100 into account `a111`:

```bash
$ ${SCALAR_SDK_HOME}/client/bin/execute-contract --properties ./conf/client.properties --contract-id deposit --contract-argument '{"id": "a111", "amount": 100}'
$ ${SCALAR_SDK_HOME}/client/bin/scalardl execute-contract --properties ./conf/client.properties --contract-id deposit --contract-argument '{"id": "a111", "amount": 100}'
```

Finally, transfer 25 from `a111` to `b222`:

```bash
$ ${SCALAR_SDK_HOME}/client/bin/execute-contract --properties ./conf/client.properties --contract-id transfer --contract-argument '{"from": "a111", "to": "b222", "amount": 100}'
$ ${SCALAR_SDK_HOME}/client/bin/scalardl execute-contract --properties ./conf/client.properties --contract-id transfer --contract-argument '{"from": "a111", "to": "b222", "amount": 100}'
```

If you were running the application itself, you could execute these commands using the [API endpoints](./docs/api_endpoints.md).
Expand Down
4 changes: 2 additions & 2 deletions docs/applications/simple-bank-account/register
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

${SCALAR_SDK_HOME}/client/bin/register-cert -properties ./conf/client.properties
${SCALAR_SDK_HOME}/client/bin/register-contracts -properties ./conf/client.properties -contracts-toml-file ./conf/contracts.toml
${SCALAR_SDK_HOME}/client/bin/scalardl register-cert -properties ./conf/client.properties
${SCALAR_SDK_HOME}/client/bin/scalardl register-contracts -properties ./conf/client.properties -contracts-toml-file ./conf/contracts.toml
14 changes: 7 additions & 7 deletions docs/getting-started-auditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ As we explained, Ledger needs to register its certificate to Auditor, and Audito

Ledger registers its certificate to Auditor
```shell
client/bin/register-cert --properties client.properties.ledger
client/bin/scalardl register-cert --properties client.properties.ledger
```

Auditor registers its certificate to Ledger
```shell
client/bin/register-cert --properties client.properties.auditor
client/bin/scalardl register-cert --properties client.properties.auditor
```

Please configure `client.properties.ledger` and `client.properties.auditor` properly.
Expand All @@ -124,7 +124,7 @@ scalar.dl.client.auditor.host=localhost
Then, you can register your certificate just like you have been doing usually (without Auditor).

```shell
client/bin/register-cert --properties client.properties
client/bin/scalardl register-cert --properties client.properties
```

Note that this registers the certificate to both Ledger and Auditor.
Expand All @@ -134,7 +134,7 @@ Note that this registers the certificate to both Ledger and Auditor.
For registering contracts, you can also do as usual.

```shell
client/bin/register-contract --properties client.properties --contract-id StateUpdater --contract-binary-name com.org1.contract.StateUpdater --contract-class-file build/classes/java/main/com/org1/contract/StateUpdater.class
client/bin/scalardl register-contract --properties client.properties --contract-id StateUpdater --contract-binary-name com.org1.contract.StateUpdater --contract-class-file build/classes/java/main/com/org1/contract/StateUpdater.class
```

Note that this registers the contract to both Ledger and Auditor.
Expand All @@ -144,7 +144,7 @@ Note that this registers the contract to both Ledger and Auditor.
Now you are ready to execute the contract with the following command as usual.

```shell
client/bin/execute-contract --properties client.properties --contract-id StateUpdater --contract-argument '{"asset_id":"some_asset", "state":3}'
client/bin/scalardl execute-contract --properties client.properties --contract-id StateUpdater --contract-argument '{"asset_id":"some_asset", "state":3}'
```

Note that this triggers a little complex protocol between Ledger and Auditor to make them go to the same states without trusting each other.
Expand All @@ -156,13 +156,13 @@ You can also always validate the states of Ledger and Auditor to see if they are
However, validating the states in the Auditor mode uses contract execution; thus, you first need to register [ValidateLedger](https://github.com/scalar-labs/scalardl-java-client-sdk/blob/master/src/main/java/com/scalar/dl/client/contract/ValidateLedger.java) contract as follows. Note that `validate-ledger` is the default contract ID that the client specifies when doing validation.

```shell
client/bin/register-contract --properties client.properties --contract-id validate-ledger --contract-binary-name com.scalar.dl.client.contract.ValidateLedger --contract-class-file /path/to/ValdateLedger.class
client/bin/scalardl register-contract --properties client.properties --contract-id validate-ledger --contract-binary-name com.scalar.dl.client.contract.ValidateLedger --contract-class-file /path/to/ValdateLedger.class
```

Then, you can issue the `validate-ledger` command just like as usually you do.

```shell
client/bin/validate-ledger --properties client.properties --asset-id="some_asset"
client/bin/scalardl validate-ledger --properties client.properties --asset-id="some_asset"
```

If you want to change the contract ID of `ValidateLedger`, you need to change the following configuration to let the client know about it.
Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Next, let's register your certificate to ScalarDL Ledger. Please check [caclient
This time, let's use a simple tool to register your certificate as follows.

```shell
client/bin/register-cert --properties client.properties
client/bin/scalardl register-cert --properties client.properties
```

The registered certificate will allow you to register and execute contracts and will also be used for detecting Byzantine faults in databases.
Expand Down Expand Up @@ -144,7 +144,7 @@ This will generate `build/classes/java/main/com/org1/contract/StateUpdater.class
Let's register your contract. Here again we use a simple tool.

```shell
client/bin/register-contract --properties client.properties --contract-id StateUpdater --contract-binary-name com.org1.contract.StateUpdater --contract-class-file build/classes/java/main/com/org1/contract/StateUpdater.class
client/bin/scalardl register-contract --properties client.properties --contract-id StateUpdater --contract-binary-name com.org1.contract.StateUpdater --contract-class-file build/classes/java/main/com/org1/contract/StateUpdater.class
```

Please set a globally unique ID for the contract ID (e.g. `StateUpdater` in the above command).
Expand All @@ -157,7 +157,7 @@ For example, let's think about a voting application. In the application, anyone
Now you are ready to execute the contract with the following command.

```shell
client/bin/execute-contract --properties client.properties --contract-id StateUpdater --contract-argument '{"asset_id":"some_asset", "state":3}'
client/bin/scalardl execute-contract --properties client.properties --contract-id StateUpdater --contract-argument '{"asset_id":"some_asset", "state":3}'
```

In the contract argument, the value specified with the key `asset_id` must be unique globally for each asset.
Expand All @@ -167,7 +167,7 @@ In the contract argument, the value specified with the key `asset_id` must be un
You can validate the states of Ledger by executing the following command.

```shell
client/bin/validate-ledger --properties client.properties --asset-id="some_asset"
client/bin/scalardl validate-ledger --properties client.properties --asset-id="some_asset"
```

What the validation does is depending on how you set up and configure ScalarDL.
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-write-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Since Functions can read and write arbitrary records through the ScalarDB CRUD i
You then need to register a Function to Ledger before used like you register a Contract.

```
client/bin/register-function --properties client.properties --function-id test-function --function-binary-name com.example.function.TestFunction --function-class-file /path/to/TestFunction.class
client/bin/scalardl register-function --properties client.properties --function-id test-function --function-binary-name com.example.function.TestFunction --function-class-file /path/to/TestFunction.class
```

#### Execute a Function
Expand All @@ -146,7 +146,7 @@ You can specify a Function to execute along with a Contract to execute.
For example, you can execute a function as follows with the command-line tool.

```
client/bin/execute-contract --properties client.properties --contract-id test-contract --contract-argument '{...}' --function-id test-function --function-argument '{...}'
client/bin/scalardl execute-contract --properties client.properties --contract-id test-contract --contract-argument '{...}' --function-id test-function --function-argument '{...}'
```

You can also do it with the [ClientService](https://scalar-labs.github.io/scalardl/javadoc/latest/client/com/scalar/dl/client/service/ClientService.html) as follows.
Expand Down

0 comments on commit 1c8de1f

Please sign in to comment.