-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from tronprotocol/main
update to 0.3.0
- Loading branch information
Showing
7 changed files
with
158 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ ext { | |
} | ||
|
||
allprojects { | ||
version '0.2.1' | ||
version '0.3.0' | ||
group = 'org.tron.trident' | ||
|
||
repositories { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
trident-java/core/src/main/java/org/tron/trident/core/contract/ContractConstructor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.tron.trident.core.contract; | ||
|
||
import org.bouncycastle.util.encoders.Hex; | ||
|
||
import com.google.protobuf.ByteString; | ||
import org.tron.trident.abi.datatypes.Type; | ||
import org.tron.trident.abi.TypeEncoder; | ||
import org.tron.trident.core.exceptions.ContractCreateException; | ||
import org.tron.trident.proto.Common.SmartContract.ABI; | ||
import org.tron.trident.proto.Common.SmartContract.ABI.Entry; | ||
import org.tron.trident.proto.Common.SmartContract.ABI.Entry.Param; | ||
|
||
import java.lang.StringBuilder; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ContractConstructor { | ||
|
||
private Entry rawConstructor; | ||
|
||
private List paramTypes; | ||
|
||
private boolean payable; | ||
|
||
private ByteString bytecode = null; | ||
|
||
public ContractConstructor(Entry raw) { | ||
this.rawConstructor = raw; | ||
this.paramTypes = new ArrayList<String>(); | ||
|
||
for (Param p : raw.getInputsList()) { | ||
paramTypes.add(p.getType()); | ||
} | ||
|
||
this.payable = raw.getPayable(); | ||
} | ||
|
||
public Entry getRawConstructor() { | ||
return this.rawConstructor; | ||
} | ||
|
||
public List getParamTypes() { | ||
return this.paramTypes; | ||
} | ||
|
||
public boolean getPayable() { | ||
return this.payable; | ||
} | ||
|
||
public ByteString getBytecode() { | ||
return this.bytecode; | ||
} | ||
|
||
public void encodeParameter(List<Type> params) throws ContractCreateException { | ||
if (params.size() != paramTypes.size()) { | ||
throw new ContractCreateException("Parameter amount doesn't match."); | ||
} | ||
StringBuilder builder = new StringBuilder(); | ||
for (Type p : params) { | ||
builder.append(TypeEncoder.encode(p)); | ||
} | ||
this.bytecode = ByteString.copyFrom(Hex.decode(builder.toString())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ent-java/core/src/main/java/org/tron/trident/core/exceptions/ContractCreateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.tron.trident.core.exceptions; | ||
|
||
public class ContractCreateException extends Exception { | ||
|
||
public ContractCreateException(String message) { | ||
super(message); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
trident-java/core/src/main/java/org/tron/trident/core/exceptions/IllegalException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters