Skip to content

Commit 0a31236

Browse files
committed
<fix>(codec): fix abi bytesN codec.
1 parent 62ccc9b commit 0a31236

File tree

10 files changed

+96
-77
lines changed

10 files changed

+96
-77
lines changed

sdk-codec/src/main/java/org/fisco/bcos/sdk/codec/ABICodec.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ private Type buildType(ABIDefinition.NamedType namedType, String param)
222222
return type;
223223
}
224224

225+
// static bytesN
225226
if (typeStr.startsWith("bytes")) {
226227
String lengthStr = typeStr.substring("bytes".length());
227228
int length;
@@ -238,22 +239,16 @@ private Type buildType(ABIDefinition.NamedType namedType, String param)
238239
logger.error(errorMsg);
239240
throw new ABICodecException(errorMsg);
240241
}
241-
242-
JsonNode jsonNode = this.objectMapper.readTree(param);
243-
assert jsonNode.isArray();
244-
if (jsonNode.size() != length) {
242+
byte[] bytesN = param.getBytes();
243+
if (bytesN.length != length) {
245244
String errorMsg =
246245
String.format(
247246
"expected byte array at length %d but length of provided in data is %d",
248-
length, jsonNode.size());
247+
length, bytesN.length);
249248
logger.error(errorMsg);
250249
throw new ABICodecException(errorMsg);
251250
}
252251

253-
byte[] bytes = new byte[jsonNode.size()];
254-
for (int i = 0; i < jsonNode.size(); ++i) {
255-
bytes[i] = ((byte) jsonNode.get(i).asInt());
256-
}
257252
try {
258253
Class<?> bytesClass =
259254
Class.forName(
@@ -262,7 +257,7 @@ private Type buildType(ABIDefinition.NamedType namedType, String param)
262257
(Type)
263258
bytesClass
264259
.getDeclaredConstructor(byte[].class)
265-
.newInstance(bytes);
260+
.newInstance(bytesN);
266261
} catch (ClassNotFoundException
267262
| NoSuchMethodException
268263
| InstantiationException

sdk-service/src/main/java/org/fisco/bcos/sdk/client/Client.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -296,88 +296,83 @@ void sendTransactionAsync(
296296
* Ledger operation: get block by hash
297297
*
298298
* @param blockHash the hashcode of the block
299-
* @param returnFullTransactionObjects the boolean define the tx is full or not
299+
* @param onlyTxHash the boolean define the tx is full or not
300300
* @return a block
301301
*/
302-
BcosBlock getBlockByHash(
303-
String blockHash, boolean onlyHeader, boolean returnFullTransactionObjects);
302+
BcosBlock getBlockByHash(String blockHash, boolean onlyHeader, boolean onlyTxHash);
304303

305304
/**
306305
* Ledger operation: get block by hash
307306
*
308307
* @param node the node rpc request send to
309308
* @param blockHash the hashcode of the block
310-
* @param returnFullTransactionObjects the boolean define the tx is full or not
309+
* @param onlyTxHash the boolean define the tx is full or not
311310
* @return a block
312311
*/
313-
BcosBlock getBlockByHash(
314-
String node,
315-
String blockHash,
316-
boolean onlyHeader,
317-
boolean returnFullTransactionObjects);
312+
BcosBlock getBlockByHash(String node, String blockHash, boolean onlyHeader, boolean onlyTxHash);
318313

319314
/**
320315
* Ledger operation: async get block by hash
321316
*
322317
* @param blockHash the hashcode of the block
323-
* @param returnFullTransactionObjects the boolean define the tx is full or not
318+
* @param onlyTxHash the boolean define the tx is full or not
324319
* @param callback the callback that will be called when receive the response
325320
*/
326321
void getBlockByHashAsync(
327322
String blockHash,
328323
boolean onlyHeader,
329-
boolean returnFullTransactionObjects,
324+
boolean onlyTxHash,
330325
RespCallback<BcosBlock> callback);
331326

332327
/**
333328
* Ledger operation: async get block by hash
334329
*
335330
* @param node the node rpc request send to
336331
* @param blockHash the hashcode of the block
337-
* @param returnFullTransactionObjects the boolean define the tx is full or not
332+
* @param onlyTxHash the boolean define the tx is full or not
338333
* @param callback the callback that will be called when receive the response
339334
*/
340335
void getBlockByHashAsync(
341336
String node,
342337
String blockHash,
343338
boolean onlyHeader,
344-
boolean returnFullTransactionObjects,
339+
boolean onlyTxHash,
345340
RespCallback<BcosBlock> callback);
346341

347342
/**
348343
* Ledger operation: get block by block number
349344
*
350345
* @param blockNumber the number of the block
351346
* @param onlyHeader the boolean define if only return header
352-
* @param isOnlyTxHash the boolean define if only return tx hash
347+
* @param onlyTxHash the boolean define if only return tx hash
353348
* @return block
354349
*/
355-
BcosBlock getBlockByNumber(BigInteger blockNumber, boolean onlyHeader, boolean isOnlyTxHash);
350+
BcosBlock getBlockByNumber(BigInteger blockNumber, boolean onlyHeader, boolean onlyTxHash);
356351

357352
/**
358353
* Ledger operation: get block by block number
359354
*
360355
* @param node the node rpc request send to
361356
* @param blockNumber the number of the block
362357
* @param onlyHeader the boolean define if only return header
363-
* @param isOnlyTxHash the boolean define if only return tx hash
358+
* @param onlyTxHash the boolean define if only return tx hash
364359
* @return block
365360
*/
366361
BcosBlock getBlockByNumber(
367-
String node, BigInteger blockNumber, boolean onlyHeader, boolean isOnlyTxHash);
362+
String node, BigInteger blockNumber, boolean onlyHeader, boolean onlyTxHash);
368363

369364
/**
370365
* Ledger operation: async get block by block number
371366
*
372367
* @param blockNumber the number of the block
373368
* @param onlyHeader the boolean if only need header
374-
* @param isOnlyTxHash the boolean if you need all transactions
369+
* @param onlyTxHash the boolean if you need all transactions
375370
* @param callback the callback that will be called when receive the response
376371
*/
377372
void getBlockByNumberAsync(
378373
BigInteger blockNumber,
379374
boolean onlyHeader,
380-
boolean isOnlyTxHash,
375+
boolean onlyTxHash,
381376
RespCallback<BcosBlock> callback);
382377

383378
/**
@@ -386,14 +381,14 @@ void getBlockByNumberAsync(
386381
* @param node the node rpc request send to
387382
* @param blockNumber the number of the block
388383
* @param onlyHeader the boolean if only need header
389-
* @param isOnlyTxHash the boolean if you need all transactions
384+
* @param onlyTxHash the boolean if you need all transactions
390385
* @param callback the callback that will be called when receive the response
391386
*/
392387
void getBlockByNumberAsync(
393388
String node,
394389
BigInteger blockNumber,
395390
boolean onlyHeader,
396-
boolean isOnlyTxHash,
391+
boolean onlyTxHash,
397392
RespCallback<BcosBlock> callback);
398393

399394
/**

sdk-service/src/main/java/org/fisco/bcos/sdk/client/ClientImpl.java

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -380,106 +380,92 @@ public void getTotalTransactionCountAsync(
380380
}
381381

382382
@Override
383-
public BcosBlock getBlockByHash(
384-
String blockHash, boolean onlyHeader, boolean returnFullTransactionObjects) {
385-
return this.getBlockByHash("", blockHash, onlyHeader, returnFullTransactionObjects);
383+
public BcosBlock getBlockByHash(String blockHash, boolean onlyHeader, boolean onlyTxHash) {
384+
return this.getBlockByHash("", blockHash, onlyHeader, onlyTxHash);
386385
}
387386

388387
@Override
389388
public BcosBlock getBlockByHash(
390-
String node,
391-
String blockHash,
392-
boolean onlyHeader,
393-
boolean returnFullTransactionObjects) {
389+
String node, String blockHash, boolean onlyHeader, boolean onlyTxHash) {
394390
node = Objects.isNull(node) ? "" : node;
395391
return this.callRemoteMethod(
396392
this.groupID,
397393
node,
398394
new JsonRpcRequest(
399395
JsonRpcMethods.GET_BLOCK_BY_HASH,
400-
Arrays.asList(
401-
this.groupID,
402-
node,
403-
blockHash,
404-
onlyHeader,
405-
returnFullTransactionObjects)),
396+
Arrays.asList(this.groupID, node, blockHash, onlyHeader, onlyTxHash)),
406397
BcosBlock.class);
407398
}
408399

409400
@Override
410401
public void getBlockByHashAsync(
411402
String blockHash,
412403
boolean onlyHeader,
413-
boolean returnFullTransactionObjects,
404+
boolean onlyTxHash,
414405
RespCallback<BcosBlock> callback) {
415-
this.getBlockByHash("", blockHash, onlyHeader, returnFullTransactionObjects);
406+
this.getBlockByHash("", blockHash, onlyHeader, onlyTxHash);
416407
}
417408

418409
@Override
419410
public void getBlockByHashAsync(
420411
String node,
421412
String blockHash,
422413
boolean onlyHeader,
423-
boolean returnFullTransactionObjects,
414+
boolean onlyTxHash,
424415
RespCallback<BcosBlock> callback) {
425416
node = Objects.isNull(node) ? "" : node;
426417
this.asyncCallRemoteMethod(
427418
this.groupID,
428419
node,
429420
new JsonRpcRequest(
430421
JsonRpcMethods.GET_BLOCK_BY_HASH,
431-
Arrays.asList(
432-
this.groupID,
433-
node,
434-
blockHash,
435-
onlyHeader,
436-
returnFullTransactionObjects)),
422+
Arrays.asList(this.groupID, node, blockHash, onlyHeader, onlyTxHash)),
437423
BcosBlock.class,
438424
callback);
439425
}
440426

441427
@Override
442428
public BcosBlock getBlockByNumber(
443-
BigInteger blockNumber, boolean onlyHeader, boolean isOnlyTxHash) {
444-
return this.getBlockByNumber("", blockNumber, onlyHeader, isOnlyTxHash);
429+
BigInteger blockNumber, boolean onlyHeader, boolean onlyTxHash) {
430+
return this.getBlockByNumber("", blockNumber, onlyHeader, onlyTxHash);
445431
}
446432

447433
@Override
448434
public BcosBlock getBlockByNumber(
449-
String node, BigInteger blockNumber, boolean onlyHeader, boolean isOnlyTxHash) {
435+
String node, BigInteger blockNumber, boolean onlyHeader, boolean onlyTxHash) {
450436
node = Objects.isNull(node) ? "" : node;
451437
return this.callRemoteMethod(
452438
this.groupID,
453439
node,
454440
new JsonRpcRequest(
455441
JsonRpcMethods.GET_BLOCK_BY_NUMBER,
456-
Arrays.asList(this.groupID, node, blockNumber, onlyHeader, isOnlyTxHash)),
442+
Arrays.asList(this.groupID, node, blockNumber, onlyHeader, onlyTxHash)),
457443
BcosBlock.class);
458444
}
459445

460446
@Override
461447
public void getBlockByNumberAsync(
462448
BigInteger blockNumber,
463449
boolean onlyHeader,
464-
boolean isOnlyTxHash,
450+
boolean onlyTxHash,
465451
RespCallback<BcosBlock> callback) {
466-
this.getBlockByNumberAsync("", blockNumber, onlyHeader, isOnlyTxHash, callback);
452+
this.getBlockByNumberAsync("", blockNumber, onlyHeader, onlyTxHash, callback);
467453
}
468454

469455
@Override
470456
public void getBlockByNumberAsync(
471457
String node,
472458
BigInteger blockNumber,
473459
boolean onlyHeader,
474-
boolean isOnlyTxHash,
460+
boolean onlyTxHash,
475461
RespCallback<BcosBlock> callback) {
476462
node = Objects.isNull(node) ? "" : node;
477463
this.asyncCallRemoteMethod(
478464
this.groupID,
479465
node,
480466
new JsonRpcRequest(
481467
JsonRpcMethods.GET_BLOCK_BY_NUMBER,
482-
Arrays.asList(this.groupID, node, blockNumber, onlyHeader, isOnlyTxHash)),
468+
Arrays.asList(this.groupID, node, blockNumber, onlyHeader, onlyTxHash)),
483469
BcosBlock.class,
484470
callback);
485471
}

sdk-transaction/src/main/java/org/fisco/bcos/sdk/contract/auth/manager/AuthManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public TransactionReceipt voteProposal(BigInteger proposalId, Boolean agree) {
192192
* @param transactionResponse which get proposal from
193193
* @return proposal id
194194
*/
195-
public BigInteger getProposal(TransactionResponse transactionResponse)
195+
private BigInteger getProposal(TransactionResponse transactionResponse)
196196
throws TransactionException {
197197
if (transactionResponse == null) {
198198
throw new TransactionException("Decode transaction response error");
@@ -236,7 +236,7 @@ public CommitteeInfo getCommitteeInfo() throws ContractException {
236236
* @param account the account to check
237237
* @return true or false
238238
*/
239-
public Boolean hasDeployAuth(String account) throws ContractException {
239+
public Boolean checkDeployAuth(String account) throws ContractException {
240240
return contractAuthPrecompiled.hasDeployAuth(account);
241241
}
242242

sdk-transaction/src/main/java/org/fisco/bcos/sdk/contract/precompiled/crud/KVTableService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;
3333
import org.fisco.bcos.sdk.utils.StringUtils;
3434

35-
/** This class not support in FISCO BCOS 3.0.0 rc1 Do not use it. */
3635
public class KVTableService {
3736
private final KVTablePrecompiled kvTablePrecompiled;
3837
private static final String VALUE_FIELDS_DELIMITER = ",";

0 commit comments

Comments
 (0)