Skip to content

Commit 3892481

Browse files
author
Jagrut Kosti
committed
Added missing grant command for assets
1 parent 0d03567 commit 3892481

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/main/java/multichain/command/GrantCommand.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ public static String grantFrom(String addressFrom, String address, int permissio
171171
return executeGrantFrom(addressFrom, address, permissions);
172172
}
173173

174+
/**
175+
* Grants permissions to addresses From an address
176+
* grantfrom "from-address" "to-address(es)" "permission(s)" ( native-amount "comment" "comment-to" startblock endblock )
177+
*
178+
* @param addressFrom address from which to grant permission (should have admin rights)
179+
* @param address address to which the permission should be granted
180+
* @param assetPermission asset permission in the format: assetName.permission e.g. rootStream.write. Possible values are write, admin and issue for assets
181+
* @return transaction ID
182+
* @throws MultichainException
183+
*/
184+
public static String grantFrom(String addressFrom, String address, String assetPermission) throws MultichainException {
185+
return executeGrantFrom(addressFrom, address, assetPermission);
186+
}
187+
174188
/**
175189
* listpermissions ("permission(s)" "address" verbose)
176190
*

src/main/java/multichain/command/builders/QueryBuilderGrant.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,23 @@ protected static String executeGrantFrom(String addressFrom, String address, int
173173
return execute(CommandEnum.GRANTFROM, formatJson(addressFrom), formatJson(address), formatJson(permissionsFormated));
174174
}
175175

176+
/**
177+
* Grants permissions to addresses From an address
178+
* grantfrom "from-address" "to-address(es)" "permission(s)" ( native-amount "comment" "comment-to" startblock endblock )
179+
*
180+
* @param addressFrom address from which to grant permission (should have admin rights)
181+
* @param address address to which the permission should be granted
182+
* @param assetPermission asset permission in the format: assetName.permission e.g. rootStream.write. Possible values are write, admin and issue for assets
183+
* @return transaction ID
184+
* @throws MultichainException
185+
*/
186+
protected static String executeGrantFrom(String addressFrom, String address, String assetPermission) throws MultichainException {
187+
MultichainTestParameter.isNotNullOrEmpty("addressFrom", addressFrom);
188+
MultichainTestParameter.isNotNullOrEmpty("address", address);
189+
MultichainTestParameter.isNotNullOrEmpty("assetPermission", assetPermission);
190+
191+
return execute(CommandEnum.GRANTFROM, addressFrom, address, assetPermission);
192+
}
176193
/**
177194
*
178195
* listpermissions ("permission(s)" "address" verbose)
@@ -215,7 +232,10 @@ protected static String executeListPermissions(int permissions, String address,
215232
* @throws MultichainException
216233
*/
217234
protected static String executeListPermissions(String streamPermission, String address, boolean verbose) throws MultichainException {
218-
return execute(CommandEnum.LISTPERMISSIONS, streamPermission, address, formatJson(verbose));
235+
if (address != null && !address.isEmpty())
236+
return execute(CommandEnum.LISTPERMISSIONS, streamPermission, address, formatJson(verbose));
237+
else
238+
return execute(CommandEnum.LISTPERMISSIONS, streamPermission);
219239
}
220240

221241
/**

0 commit comments

Comments
 (0)