(invocation);
+ }
+
+ /**
+ * 解析合约方法调用的返回值;
+ *
+ * 用法示例:
+ *
+ * import static com.jd.blockchain.transaction.ContractReturnValue.*;
+ *
+ *
+ * LongValueHolder retnHolder = decode(contract.issue(assetKey, amount));
+ *
+ * PreparedTransaction prepTx = tx.prepare();
+ * prepTx.sign(userKey);
+ * prepTx.commit()
+ *
+ * long retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
+ *
+ *
+ * @param call
+ * @return
+ */
+ public static LongValueHolder decode(long call) {
+ ContractInvocation invocation = ContractInvocationStub.take();
+ return new LongValueHolder(invocation);
+ }
+
+ /**
+ * 解析合约方法调用的返回值;
+ *
+ * 用法示例:
+ *
+ * import static com.jd.blockchain.transaction.ContractReturnValue.*;
+ *
+ *
+ * IntValueHolder retnHolder = decode(contract.issue(assetKey, amount));
+ *
+ * PreparedTransaction prepTx = tx.prepare();
+ * prepTx.sign(userKey);
+ * prepTx.commit()
+ *
+ * int retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
+ *
+ *
+ * @param call
+ * @return
+ */
+ public static IntValueHolder decode(int call) {
+ ContractInvocation invocation = ContractInvocationStub.take();
+ return new IntValueHolder(invocation);
+ }
+
+ /**
+ * 解析合约方法调用的返回值;
+ *
+ * 用法示例:
+ *
+ * import static com.jd.blockchain.transaction.ContractReturnValue.*;
+ *
+ *
+ * ShortValueHolder retnHolder = decode(contract.issue(assetKey, amount));
+ *
+ * PreparedTransaction prepTx = tx.prepare();
+ * prepTx.sign(userKey);
+ * prepTx.commit()
+ *
+ * short retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
+ *
+ *
+ * @param call
+ * @return
+ */
+ public static ShortValueHolder decode(short call) {
+ ContractInvocation invocation = ContractInvocationStub.take();
+ return new ShortValueHolder(invocation);
+ }
+
+ /**
+ * 解析合约方法调用的返回值;
+ *
+ * 用法示例:
+ *
+ * import static com.jd.blockchain.transaction.ContractReturnValue.*;
+ *
+ *
+ * ByteValueHolder retnHolder = decode(contract.issue(assetKey, amount));
+ *
+ * PreparedTransaction prepTx = tx.prepare();
+ * prepTx.sign(userKey);
+ * prepTx.commit()
+ *
+ * byte retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
+ *
+ *
+ * @param call
+ * @return
+ */
+ public static ByteValueHolder decode(byte call) {
+ ContractInvocation invocation = ContractInvocationStub.take();
+ return new ByteValueHolder(invocation);
+ }
+
+ /**
+ * 解析合约方法调用的返回值;
+ *
+ * 用法示例:
+ *
+ * import static com.jd.blockchain.transaction.ContractReturnValue.*;
+ *
+ *
+ * BooleanValueHolder retnHolder = decode(contract.issue(assetKey, amount));
+ *
+ * PreparedTransaction prepTx = tx.prepare();
+ * prepTx.sign(userKey);
+ * prepTx.commit()
+ *
+ * boolean retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
+ *
+ *
+ * @param call
+ * @return
+ */
+ public static BooleanValueHolder decode(boolean call) {
+ ContractInvocation invocation = ContractInvocationStub.take();
+ return new BooleanValueHolder(invocation);
+ }
+
+
+ //----------------------- 内部类型 -----------------------
+
+
+
+}
diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ContractReturns.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ContractReturns.java
deleted file mode 100644
index a4e4bdcd..00000000
--- a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ContractReturns.java
+++ /dev/null
@@ -1,418 +0,0 @@
-package com.jd.blockchain.transaction;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-public class ContractReturns {
-
- /**
- * 解析合约方法调用的返回值;
- *
- * 用法示例:
- *
- * ReturnValue retnHolder = decode(contract.issue(assetKey, amount));
- *
- * PreparedTransaction prepTx = tx.prepare();
- * prepTx.sign(userKey);
- * prepTx.commit()
- *
- * String retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
- *
- *
- * @param
- * @param call
- * @return
- */
- public static ReturnValue decode(T call) {
- ContractInvocation invocation = ContractInvocationStub.take();
- return new ReturnValue(invocation);
- }
-
- /**
- * 解析合约方法调用的返回值;
- *
- * 用法示例:
- *
- * ReturnLongValue retnHolder = decode(contract.issue(assetKey, amount));
- *
- * PreparedTransaction prepTx = tx.prepare();
- * prepTx.sign(userKey);
- * prepTx.commit()
- *
- * long retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
- *
- *
- * @param call
- * @return
- */
- public static ReturnLongValue decode(long call) {
- ContractInvocation invocation = ContractInvocationStub.take();
- return new ReturnLongValue(invocation);
- }
-
- /**
- * 解析合约方法调用的返回值;
- *
- * 用法示例:
- *
- * ReturnLongValue retnHolder = decode(contract.issue(assetKey, amount));
- *
- * PreparedTransaction prepTx = tx.prepare();
- * prepTx.sign(userKey);
- * prepTx.commit()
- *
- * int retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
- *
- *
- * @param call
- * @return
- */
- public static ReturnIntValue decode(int call) {
- ContractInvocation invocation = ContractInvocationStub.take();
- return new ReturnIntValue(invocation);
- }
-
- /**
- * 解析合约方法调用的返回值;
- *
- * 用法示例:
- *
- * ReturnLongValue retnHolder = decode(contract.issue(assetKey, amount));
- *
- * PreparedTransaction prepTx = tx.prepare();
- * prepTx.sign(userKey);
- * prepTx.commit()
- *
- * short retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
- *
- *
- * @param call
- * @return
- */
- public static ReturnShortValue decode(short call) {
- ContractInvocation invocation = ContractInvocationStub.take();
- return new ReturnShortValue(invocation);
- }
-
- /**
- * 解析合约方法调用的返回值;
- *
- * 用法示例:
- *
- * ReturnLongValue retnHolder = decode(contract.issue(assetKey, amount));
- *
- * PreparedTransaction prepTx = tx.prepare();
- * prepTx.sign(userKey);
- * prepTx.commit()
- *
- * byte retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
- *
- *
- * @param call
- * @return
- */
- public static ReturnByteValue decode(byte call) {
- ContractInvocation invocation = ContractInvocationStub.take();
- return new ReturnByteValue(invocation);
- }
-
- /**
- * 解析合约方法调用的返回值;
- *
- * 用法示例:
- *
- * ReturnLongValue retnHolder = decode(contract.issue(assetKey, amount));
- *
- * PreparedTransaction prepTx = tx.prepare();
- * prepTx.sign(userKey);
- * prepTx.commit()
- *
- * boolean retnValue = retnHolder.get(); //这是同步方法,会阻塞当前线程等待交易提交后返回结果;
- *
- *
- * @param call
- * @return
- */
- public static ReturnBooleanValue decode(boolean call) {
- ContractInvocation invocation = ContractInvocationStub.take();
- return new ReturnBooleanValue(invocation);
- }
-
-
- //----------------------- 内部类型 -----------------------
-
-
- private static class ReturnValueBase {
- private ContractInvocation invocation;
-
- private ReturnValueBase(ContractInvocation invocation) {
- this.invocation = invocation;
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @return
- */
- private Object get() {
- try {
- return invocation.getReturnValue().get();
- } catch (InterruptedException | ExecutionException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @param unit
- * @return
- * @throws TimeoutException
- */
- private Object get(long timeout, TimeUnit unit) throws TimeoutException {
- try {
- return invocation.getReturnValue().get(timeout, unit);
- } catch (InterruptedException | ExecutionException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
- }
-
- public static class ReturnValue extends ReturnValueBase {
-
- private ReturnValue(ContractInvocation invocation) {
- super(invocation);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @return
- */
- @SuppressWarnings("unchecked")
- public T get() {
- return (T) super.get();
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @return
- * @throws TimeoutException
- */
- public T get(long timeout) throws TimeoutException {
- return get(timeout, TimeUnit.MILLISECONDS);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @param unit
- * @return
- * @throws TimeoutException
- */
- @SuppressWarnings("unchecked")
- public T get(long timeout, TimeUnit unit) throws TimeoutException {
- return (T) super.get(timeout, unit);
- }
- }
-
- public static class ReturnLongValue extends ReturnValueBase {
-
- private ReturnLongValue(ContractInvocation invocation) {
- super(invocation);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @return
- */
- public long get() {
- return (long) super.get();
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @return
- * @throws TimeoutException
- */
- public long get(long timeout) throws TimeoutException {
- return get(timeout, TimeUnit.MILLISECONDS);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @param unit
- * @return
- * @throws TimeoutException
- */
- public long get(long timeout, TimeUnit unit) throws TimeoutException {
- return (long) super.get(timeout, unit);
- }
- }
-
- public static class ReturnIntValue extends ReturnValueBase {
-
- private ReturnIntValue(ContractInvocation invocation) {
- super(invocation);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @return
- */
- public int get() {
- return (int) super.get();
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @return
- * @throws TimeoutException
- */
- public int get(long timeout) throws TimeoutException {
- return get(timeout, TimeUnit.MILLISECONDS);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @param unit
- * @return
- * @throws TimeoutException
- */
- public int get(long timeout, TimeUnit unit) throws TimeoutException {
- return (int) super.get(timeout, unit);
- }
- }
-
- public static class ReturnShortValue extends ReturnValueBase {
-
- private ReturnShortValue(ContractInvocation invocation) {
- super(invocation);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @return
- */
- public short get() {
- return (short) super.get();
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @return
- * @throws TimeoutException
- */
- public short get(long timeout) throws TimeoutException {
- return get(timeout, TimeUnit.MILLISECONDS);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @param unit
- * @return
- * @throws TimeoutException
- */
- public short get(long timeout, TimeUnit unit) throws TimeoutException {
- return (short) super.get(timeout, unit);
- }
- }
-
- public static class ReturnByteValue extends ReturnValueBase {
-
- private ReturnByteValue(ContractInvocation invocation) {
- super(invocation);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @return
- */
- public byte get() {
- return (byte) super.get();
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @return
- * @throws TimeoutException
- */
- public byte get(long timeout) throws TimeoutException {
- return get(timeout, TimeUnit.MILLISECONDS);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @param unit
- * @return
- * @throws TimeoutException
- */
- public byte get(long timeout, TimeUnit unit) throws TimeoutException {
- return (byte) super.get(timeout, unit);
- }
- }
-
- public static class ReturnBooleanValue extends ReturnValueBase {
-
- private ReturnBooleanValue(ContractInvocation invocation) {
- super(invocation);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @return
- */
- public boolean get() {
- return (boolean) super.get();
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @return
- * @throws TimeoutException
- */
- public boolean get(long timeout) throws TimeoutException {
- return get(timeout, TimeUnit.MILLISECONDS);
- }
-
- /**
- * 等待结果合约调用的结果返回;
- *
- * @param timeout
- * @param unit
- * @return
- * @throws TimeoutException
- */
- public boolean get(long timeout, TimeUnit unit) throws TimeoutException {
- return (boolean) super.get(timeout, unit);
- }
- }
-}
diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/IntValueHolder.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/IntValueHolder.java
new file mode 100644
index 00000000..05394652
--- /dev/null
+++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/IntValueHolder.java
@@ -0,0 +1,43 @@
+package com.jd.blockchain.transaction;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class IntValueHolder extends ValueHolderBase {
+
+ IntValueHolder(ContractInvocation invocation) {
+ super(invocation);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @return
+ */
+ public int get() {
+ return (int) super.getValue();
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @return
+ * @throws TimeoutException
+ */
+ public int get(long timeout) throws TimeoutException {
+ return get(timeout, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @param unit
+ * @return
+ * @throws TimeoutException
+ */
+ public int get(long timeout, TimeUnit unit) throws TimeoutException {
+ return (int) super.getValue(timeout, unit);
+ }
+}
\ No newline at end of file
diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/LongValueHolder.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/LongValueHolder.java
new file mode 100644
index 00000000..6d9b0593
--- /dev/null
+++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/LongValueHolder.java
@@ -0,0 +1,43 @@
+package com.jd.blockchain.transaction;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class LongValueHolder extends ValueHolderBase {
+
+ LongValueHolder(ContractInvocation invocation) {
+ super(invocation);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @return
+ */
+ public long get() {
+ return (long) super.getValue();
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @return
+ * @throws TimeoutException
+ */
+ public long get(long timeout) throws TimeoutException {
+ return get(timeout, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @param unit
+ * @return
+ * @throws TimeoutException
+ */
+ public long get(long timeout, TimeUnit unit) throws TimeoutException {
+ return (long) super.getValue(timeout, unit);
+ }
+}
\ No newline at end of file
diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ShortValueHolder.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ShortValueHolder.java
new file mode 100644
index 00000000..70343c4a
--- /dev/null
+++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ShortValueHolder.java
@@ -0,0 +1,43 @@
+package com.jd.blockchain.transaction;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class ShortValueHolder extends ValueHolderBase {
+
+ ShortValueHolder(ContractInvocation invocation) {
+ super(invocation);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @return
+ */
+ public short get() {
+ return (short) super.getValue();
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @return
+ * @throws TimeoutException
+ */
+ public short get(long timeout) throws TimeoutException {
+ return get(timeout, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @param unit
+ * @return
+ * @throws TimeoutException
+ */
+ public short get(long timeout, TimeUnit unit) throws TimeoutException {
+ return (short) super.getValue(timeout, unit);
+ }
+}
\ No newline at end of file
diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ValueHolder.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ValueHolder.java
new file mode 100644
index 00000000..6f6db109
--- /dev/null
+++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ValueHolder.java
@@ -0,0 +1,45 @@
+package com.jd.blockchain.transaction;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class ValueHolder extends ValueHolderBase {
+
+ ValueHolder(ContractInvocation invocation) {
+ super(invocation);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public T get() {
+ return (T) super.getValue();
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @return
+ * @throws TimeoutException
+ */
+ public T get(long timeout) throws TimeoutException {
+ return get(timeout, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @param unit
+ * @return
+ * @throws TimeoutException
+ */
+ @SuppressWarnings("unchecked")
+ public T get(long timeout, TimeUnit unit) throws TimeoutException {
+ return (T) super.getValue(timeout, unit);
+ }
+ }
\ No newline at end of file
diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ValueHolderBase.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ValueHolderBase.java
new file mode 100644
index 00000000..41d32f4e
--- /dev/null
+++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/ValueHolderBase.java
@@ -0,0 +1,42 @@
+package com.jd.blockchain.transaction;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+class ValueHolderBase {
+ private ContractInvocation invocation;
+
+ protected ValueHolderBase(ContractInvocation invocation) {
+ this.invocation = invocation;
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @return
+ */
+ protected Object getValue() {
+ try {
+ return invocation.getReturnValue().get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * 等待结果合约调用的结果返回;
+ *
+ * @param timeout
+ * @param unit
+ * @return
+ * @throws TimeoutException
+ */
+ protected Object getValue(long timeout, TimeUnit unit) throws TimeoutException {
+ try {
+ return invocation.getReturnValue().get(timeout, unit);
+ } catch (InterruptedException | ExecutionException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+ }
\ No newline at end of file
diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java
index b6a5444a..65074fc6 100644
--- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java
+++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Contract_Demo.java
@@ -1,9 +1,8 @@
package com.jd.blockchain.sdk.samples;
import static com.jd.blockchain.sdk.samples.SDKDemo_Constant.readChainCodes;
-import static com.jd.blockchain.transaction.ContractReturns.decode;
+import static com.jd.blockchain.transaction.ContractReturnValue.decode;
-import com.jd.blockchain.contract.EventResult;
import com.jd.blockchain.contract.TransferContract;
import com.jd.blockchain.ledger.BlockchainKeyGenerator;
import com.jd.blockchain.ledger.BlockchainKeypair;
@@ -11,9 +10,8 @@ import com.jd.blockchain.ledger.KVDataEntry;
import com.jd.blockchain.ledger.PreparedTransaction;
import com.jd.blockchain.ledger.TransactionResponse;
import com.jd.blockchain.ledger.TransactionTemplate;
-import com.jd.blockchain.transaction.ContractEventExecutor;
-import com.jd.blockchain.transaction.ContractReturns.ReturnLongValue;
-import com.jd.blockchain.transaction.ContractReturns.ReturnValue;
+import com.jd.blockchain.transaction.LongValueHolder;
+import com.jd.blockchain.transaction.ValueHolder;
import com.jd.blockchain.utils.Bytes;
public class SDK_Contract_Demo extends SDK_Base_Demo {
@@ -94,7 +92,7 @@ public class SDK_Contract_Demo extends SDK_Base_Demo {
TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash);
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnValue result = decode(transferContract.readAll(address, account));
+ ValueHolder result = decode(transferContract.readAll(address, account));
commit(txTpl);
return result.get();
}
@@ -103,7 +101,7 @@ public class SDK_Contract_Demo extends SDK_Base_Demo {
TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash);
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnLongValue result = decode(transferContract.read(address, account));
+ LongValueHolder result = decode(transferContract.read(address, account));
commit(txTpl);
return result.get();
}
@@ -124,7 +122,7 @@ public class SDK_Contract_Demo extends SDK_Base_Demo {
TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash);
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnValue result = decode(transferContract.transfer(address, from, to, money));
+ ValueHolder result = decode(transferContract.transfer(address, from, to, money));
commit(txTpl);
return result.get();
}
@@ -144,7 +142,7 @@ public class SDK_Contract_Demo extends SDK_Base_Demo {
if (useContract) {
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnValue result = decode(transferContract.create(address, account, money));
+ ValueHolder result = decode(transferContract.create(address, account, money));
commit(txTpl);
return result.get();
} else {
diff --git a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDKDemo_Contract_Test.java b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDKDemo_Contract_Test.java
index 3959261e..57f7d947 100644
--- a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDKDemo_Contract_Test.java
+++ b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDKDemo_Contract_Test.java
@@ -1,7 +1,7 @@
package test.com.jd.blockchain.sdk.test;
import static com.jd.blockchain.sdk.samples.SDKDemo_Constant.readChainCodes;
-import static com.jd.blockchain.transaction.ContractReturns.decode;
+import static com.jd.blockchain.transaction.ContractReturnValue.decode;
import org.junit.Before;
import org.junit.Test;
@@ -19,8 +19,8 @@ import com.jd.blockchain.sdk.BlockchainService;
import com.jd.blockchain.sdk.client.GatewayServiceFactory;
import com.jd.blockchain.sdk.samples.SDKDemo_Constant;
import com.jd.blockchain.tools.keygen.KeyGenCommand;
-import com.jd.blockchain.transaction.ContractReturns.ReturnLongValue;
-import com.jd.blockchain.transaction.ContractReturns.ReturnValue;
+import com.jd.blockchain.transaction.LongValueHolder;
+import com.jd.blockchain.transaction.ValueHolder;
import com.jd.blockchain.utils.Bytes;
public class SDKDemo_Contract_Test {
@@ -108,7 +108,7 @@ public class SDKDemo_Contract_Test {
TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash);
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnValue result = decode(transferContract.readAll(address, account));
+ ValueHolder result = decode(transferContract.readAll(address, account));
commit(txTpl);
return result.get();
}
@@ -117,7 +117,7 @@ public class SDKDemo_Contract_Test {
TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash);
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnLongValue result = decode(transferContract.read(address, account));
+ LongValueHolder result = decode(transferContract.read(address, account));
commit(txTpl);
return result.get();
}
@@ -126,7 +126,7 @@ public class SDKDemo_Contract_Test {
TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash);
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnValue result = decode(transferContract.transfer(address, from, to, money));
+ ValueHolder result = decode(transferContract.transfer(address, from, to, money));
commit(txTpl);
return result.get();
}
@@ -146,7 +146,7 @@ public class SDKDemo_Contract_Test {
if (useContract) {
// 使用合约创建
TransferContract transferContract = txTpl.contract(contractAddress, TransferContract.class);
- ReturnValue result = decode(transferContract.create(address, account, money));
+ ValueHolder result = decode(transferContract.create(address, account, money));
commit(txTpl);
return result.get();
} else {
diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java
index 034c3a6c..463d525f 100644
--- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java
+++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java
@@ -8,6 +8,7 @@
*/
package test.com.jd.blockchain.intgr;
+import static com.jd.blockchain.transaction.ContractReturnValue.decode;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -29,7 +30,6 @@ import org.springframework.core.io.ClassPathResource;
import com.jd.blockchain.binaryproto.DataContractRegistry;
import com.jd.blockchain.contract.ContractSerializeUtils;
-import com.jd.blockchain.contract.EventResult;
import com.jd.blockchain.contract.ReadContract;
import com.jd.blockchain.crypto.AddressEncoding;
import com.jd.blockchain.crypto.AsymmetricKeypair;
@@ -51,8 +51,7 @@ import com.jd.blockchain.sdk.BlockchainService;
import com.jd.blockchain.storage.service.DbConnection;
import com.jd.blockchain.storage.service.DbConnectionFactory;
import com.jd.blockchain.tools.initializer.LedgerBindingConfig;
-import com.jd.blockchain.transaction.ContractEventExecutor;
-import static com.jd.blockchain.transaction.ContractReturns.*;
+import com.jd.blockchain.transaction.ValueHolder;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.concurrent.ThreadInvoker;
import com.jd.blockchain.utils.net.NetworkAddress;
@@ -587,7 +586,7 @@ public class IntegrationBase {
ReadContract readContract1 = txContract.contract(contractDeployKey.getAddress(), ReadContract.class);
- ReturnValue result1 = decode(readContract1.read(newDataAccount.getAddress().toBase58(), key1));
+ ValueHolder result1 = decode(readContract1.read(newDataAccount.getAddress().toBase58(), key1));
ReadContract readContract2 = txContract.contract(contractDeployKey.getAddress(), ReadContract.class);
@@ -595,7 +594,7 @@ public class IntegrationBase {
ReadContract readContract3 = txContract.contract(contractDeployKey.getAddress(), ReadContract.class);
- ReturnValue result3 = decode(readContract3.readVersion(newDataAccount.getAddress().toBase58(), key2));
+ ValueHolder result3 = decode(readContract3.readVersion(newDataAccount.getAddress().toBase58(), key2));
// 签名;
PreparedTransaction contractPtx = txContract.prepare();