Skip to content

Commit fb3af59

Browse files
Update README.md
version 2.0.1 - README.md
1 parent fd47b90 commit fb3af59

File tree

1 file changed

+74
-23
lines changed

1 file changed

+74
-23
lines changed

README.md

Lines changed: 74 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ https://github.com/SimplyUb/MultiChainJavaAPI
1111

1212
### System requirements
1313

14-
These compilation instructions have been tested on Windows 7.0 and Ubuntu 12.4 x64 only with Java 1.7.0_80
14+
These compilation instructions have been tested on Windows 7.0 and Ubuntu 12.4 x64 only with Java 1.7.0_80 with Multichain 2.0 beta 2.
1515

1616

1717
## Dependencies
1818

19+
* Multichain 2.0 beta 2
1920
* Java 1.7.0 is needed, upper version should be compatible.
2021
* All other dependencies are managed by Maven.
2122

@@ -46,62 +47,111 @@ Next versions will decide to integrate (or not) theses commands.
4647

4748
### Project Architecture
4849

49-
#### multichain.command and MultiChainCommand
50-
The package multichain.command and the Class `MultiChainCommand` are the essentials of the project.
51-
They contain Java commands to call.
50+
#### multichain.command and CommandManager
51+
The package multichain.command and the Class `CommandManager` are the essentials of the project.
52+
They contain Java ***the*** command to call.
5253

53-
Examples of command calls can be found in `multichain.test.command`.
54+
```
55+
public Object invoke(CommandElt command, Object... parameters) throws MultichainException
56+
```
57+
- command : Multichain command to call
58+
- parameters : (optional) list of parameters joined to the command
59+
60+
Examples of command calls can be found in `test/multichain.command.CommandManagerTest`.
5461

5562
A simple example to get addresses :
5663
```
5764
//BlockChain has to be created and started before
58-
multiChainCommand = new MultiChainCommand("localhost", "6824", "multichainrpc","73oYQWzx45hossFPPWUgicpLvHhsD8PempYxnSF6bnY9");
65+
CommandManager commandManager= new CommandManager("localhost", "6824", "multichainrpc","73oYQWzx45hossFPPWUgicpLvHhsD8PempYxnSF6bnY9");
5966
6067
// localhost is the IP used by Multichain
6168
// 6824 is, here, the port used by the BlockChain, corresponding of the value of default-rpc-port in the file params.dat
6269
// multichainrpc and 73oYQWzx45h... are login and password to access to RPC commands, values can be found in the file multichain.conf
6370
64-
List<String> result = null;
71+
Object addressResult = null;
72+
6573
try {
66-
result = multiChainCommand.getAddressCommand().getAddresses();
74+
addressResult = commandManager.invoke(CommandElt.GETADDRESSES);
6775
} catch (MultichainException e) {
68-
// TODO Auto-generated catch block
69-
e.printStackTrace();
76+
e.printStackTrace();
77+
fail();
7078
}
7179
72-
//result contains the addresses of the wallet as list of String.
80+
//result contains the addresses of the wallet as list of String (verbose is false).
81+
//class java.util.ArrayList
82+
//class java.lang.String
83+
84+
try {
85+
addressResult = commandManager.invoke(CommandElt.GETADDRESSES, true);
86+
} catch (MultichainException e) {
87+
e.printStackTrace();
88+
fail();
89+
}
90+
91+
//result contains the addresses of the wallet as list of Addresses (verbose is true).
92+
//class java.util.ArrayList
93+
//class multichain.object.Address
7394
```
7495

96+
#### multichain.command.CommandElt
97+
98+
This Enum contains command definitions, for example :
99+
```
100+
GETADDRESSES("getaddresses", null, new Class<?>[] {String.class, Address.class}, true),
101+
```
102+
|element name | GETADDRESSES |
103+
|-|-|
104+
| multichain command | **"getaddresses"** : call this multichain command |
105+
| input parameters | **null** : *#TODO#* |
106+
| output parameters | **new Class<?>[] {String.class, Address.class}** : output can be either String or Address |
107+
| output list flag | **true** : output will follow list format |
108+
109+
`multichain.object.formatters.GenericOutputFormatter` is the only formatter and is based on the output defined in this Enum. To format Json to Java, it's using [Gson API](https://github.com/google/gson).
110+
75111

76112
#### multichain.object
77-
The package `multichain.object` contains Java objects which can be used to call functions or returned by functions.
113+
The package `multichain.object` contains Java objects which can be used to call functions (in queryobjects) or returned by functions.
114+
115+
#### a few examples
116+
```
117+
String message = (String) commandManager.invoke(CommandElt.GETNEWADDRESS);
78118
79-
The package contains `formatters` with technical classes used to format Json to Java using [Gson API](https://github.com/google/gson).
119+
List<Permission> listPermissions = (List<Permission>) commandManager.invoke(CommandElt.LISTPERMISSIONS);
80120
81-
#### multichain.test.object.formatters
82-
The package `multichain.test` contains Java unit test.
83-
Test are written with `main()` function to be executed on whatever IDE or system used.
121+
String message = (String) commandManager.invoke(CommandElt.GRANT, addressString, GrantElt.grantElements(permissions));
84122
85-
The package `command` has to contain unit tests for each command.
86-
The package `object.formatters` is helpful to test the good work of Formatters Json<->Java.
123+
AssetParams params = new AssetParams(name, true);
124+
String message = (String) commandManager.invoke(CommandElt.ISSUEFROM, fromAddressString, toAddressString, params, quantity, 1);
125+
126+
MultiBalance balance = (MultiBalance)commandManager.invoke(CommandElt.GETMULTIBALANCES);
127+
128+
List<BalanceAssetGeneral> balance = (List<BalanceAssetGeneral>)commandManager.invoke(CommandElt.GETADDRESSBALANCES, AddressString);
129+
130+
Map<String, Double> basket = new HashMap();
131+
basket.put(assetName1, assetQty1);
132+
basket.put(assetName2, assetQty2);
133+
String message = (String)commandManager.invoke(CommandElt.SENDFROM, fromAddressString, toAddressString, basket);
134+
String message = (String)commandManager.invoke(CommandElt.SENDWITHDATAFROM, fromAddressString, toAddressString, basket, metadata);
135+
```
87136

88137

89138
## Versions
90139

91-
Todo :
92-
* integrate new functions
140+
### 2.0.1
141+
* All new version :-)
142+
* Only one calling command : **invoke**
93143

94-
### 3.0
144+
### 1.3.0
95145
* Direct RPC Server calls
96146
* Dependencies under Maven
97147

98-
### 2.0
148+
### 1.2.0
99149
Based on functions contained in MultiChain 1.0 Beta 1
100150

101151
Integrated functions about :
102152
* Streams
103153

104-
### 1.0
154+
### 1.1.0
105155
Based on functions contained in MultiChain Alpha 24
106156

107157
Integrated functions about :
@@ -136,3 +186,4 @@ GNU General Public License for more details.
136186
You should have received a copy of the GNU General Public License
137187
along with this program. If not, see <http://www.gnu.org/licenses/>.
138188
```
189+

0 commit comments

Comments
 (0)