|
1 | 1 | package com.cryptape.cita.protocol.account; |
2 | 2 |
|
| 3 | +import com.cryptape.cita.utils.Numeric; |
3 | 4 | import java.io.File; |
4 | 5 | import java.io.IOException; |
5 | 6 | import java.math.BigInteger; |
@@ -49,14 +50,40 @@ public RawTransactionManager getTransactionManager() { |
49 | 50 |
|
50 | 51 | /// TODO: get contract address from receipt after deploy, then return contract name |
51 | 52 | public AppSendTransaction deploy( |
52 | | - File contractFile, String nonce, long quota, |
53 | | - int version, BigInteger chainId, String value) |
54 | | - throws IOException, InterruptedException, CompiledContract.ContractCompileError { |
| 53 | + File contractFile, String nonce, long quota, |
| 54 | + int version, BigInteger chainId, String value) |
| 55 | + throws IOException, InterruptedException, CompiledContract.ContractCompileError { |
55 | 56 | CompiledContract contract = new CompiledContract(contractFile); |
56 | 57 | String contractBin = contract.getBin(); |
57 | 58 | return this.transactionManager |
58 | | - .sendTransaction("", contractBin, quota, nonce, getValidUntilBlock(), |
59 | | - version, chainId, value); |
| 59 | + .sendTransaction("", contractBin, quota, nonce, getValidUntilBlock(), |
| 60 | + version, chainId, value); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * |
| 65 | + * @param contractFile |
| 66 | + * @param constructorCode add by timmyz, fulfill the construction contract situations |
| 67 | + * @param nonce |
| 68 | + * @param quota |
| 69 | + * @param version |
| 70 | + * @param chainId |
| 71 | + * @param value |
| 72 | + * @return |
| 73 | + * @throws IOException |
| 74 | + * @throws InterruptedException |
| 75 | + * @throws CompiledContract.ContractCompileError |
| 76 | + */ |
| 77 | + public AppSendTransaction deploy( |
| 78 | + File contractFile, String constructorCode, String nonce, long quota, |
| 79 | + int version, BigInteger chainId, String value) |
| 80 | + throws IOException, InterruptedException, CompiledContract.ContractCompileError { |
| 81 | + CompiledContract contract = new CompiledContract(contractFile); |
| 82 | + String contractBin = contract.getBin(); |
| 83 | + String data = constructorCode != null ? contractBin + Numeric.cleanHexPrefix(constructorCode) : contractBin; |
| 84 | + return this.transactionManager |
| 85 | + .sendTransaction("", data, quota, nonce, getValidUntilBlock(), |
| 86 | + version, chainId, value); |
60 | 87 | } |
61 | 88 |
|
62 | 89 | public Flowable<AppSendTransaction> deployAsync( |
|
0 commit comments