Search in sources :

Example 6 with AssetIssueCapsule

use of org.tron.core.capsule.AssetIssueCapsule in project java-tron by tronprotocol.

the class ParticipateAssetIssueActuatorTest method initAssetIssue.

private void initAssetIssue(long startTimestmp, long endTimestmp) {
    AssetIssueContract assetIssueContract = AssetIssueContract.newBuilder().setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS))).setName(ByteString.copyFrom(ByteArray.fromString(ASSET_NAME))).setTotalSupply(TOTAL_SUPPLY).setTrxNum(TRX_NUM).setNum(NUM).setStartTime(startTimestmp).setEndTime(endTimestmp).setDecayRatio(DECAY_RATIO).setVoteScore(VOTE_SCORE).setDescription(ByteString.copyFrom(ByteArray.fromString(DESCRIPTION))).setUrl(ByteString.copyFrom(ByteArray.fromString(URL))).build();
    AssetIssueCapsule assetIssueCapsule = new AssetIssueCapsule(assetIssueContract);
    dbManager.getAssetIssueStore().put(assetIssueCapsule.getName().toByteArray(), assetIssueCapsule);
}
Also used : AssetIssueCapsule(org.tron.core.capsule.AssetIssueCapsule) AssetIssueContract(org.tron.protos.Contract.AssetIssueContract)

Example 7 with AssetIssueCapsule

use of org.tron.core.capsule.AssetIssueCapsule in project java-tron by tronprotocol.

the class TransferAssetActuatorTest method createCapsule.

/**
 * create temp Capsule test need.
 */
@Before
public void createCapsule() {
    AccountCapsule ownerCapsule = new AccountCapsule(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), ByteString.copyFromUtf8("owner"), AccountType.AssetIssue);
    ownerCapsule.addAsset(ASSET_NAME, 10000L);
    AccountCapsule toAccountCapsule = new AccountCapsule(ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS)), ByteString.copyFromUtf8("toAccount"), AccountType.Normal);
    AssetIssueContract assetIssueContract = AssetIssueContract.newBuilder().setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))).setName(ByteString.copyFrom(ByteArray.fromString(ASSET_NAME))).setTotalSupply(TOTAL_SUPPLY).setTrxNum(TRX_NUM).setNum(NUM).setStartTime(START_TIME).setEndTime(END_TIME).setDecayRatio(DECAY_RATIO).setVoteScore(VOTE_SCORE).setDescription(ByteString.copyFrom(ByteArray.fromString(DESCRIPTION))).setUrl(ByteString.copyFrom(ByteArray.fromString(URL))).build();
    AssetIssueCapsule assetIssueCapsule = new AssetIssueCapsule(assetIssueContract);
    dbManager.getAccountStore().put(ownerCapsule.getAddress().toByteArray(), ownerCapsule);
    dbManager.getAccountStore().put(toAccountCapsule.getAddress().toByteArray(), toAccountCapsule);
    dbManager.getAssetIssueStore().put(assetIssueCapsule.getName().toByteArray(), assetIssueCapsule);
}
Also used : AccountCapsule(org.tron.core.capsule.AccountCapsule) AssetIssueCapsule(org.tron.core.capsule.AssetIssueCapsule) AssetIssueContract(org.tron.protos.Contract.AssetIssueContract) Before(org.junit.Before)

Aggregations

AssetIssueCapsule (org.tron.core.capsule.AssetIssueCapsule)7 AccountCapsule (org.tron.core.capsule.AccountCapsule)6 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 ContractExeException (org.tron.core.exception.ContractExeException)4 ContractValidateException (org.tron.core.exception.ContractValidateException)3 Contract (org.tron.protos.Contract)3 AssetIssueContract (org.tron.protos.Contract.AssetIssueContract)3 Test (org.junit.Test)2 TransactionResultCapsule (org.tron.core.capsule.TransactionResultCapsule)2 DateTime (org.joda.time.DateTime)1 Before (org.junit.Before)1 BalanceInsufficientException (org.tron.core.exception.BalanceInsufficientException)1