use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class SecretProofTransactionMapping method apply.
@Override
public TransferTransaction apply(JsonObject input) {
TransactionInfo transactionInfo = this.createTransactionInfo(input.getJsonObject("meta"));
JsonObject transaction = input.getJsonObject("transaction");
Deadline deadline = new Deadline(extractBigInteger(transaction.getJsonArray("deadline")));
List<Mosaic> mosaics = new ArrayList<>();
if (transaction.getJsonArray("mosaics") != null) {
mosaics = transaction.getJsonArray("mosaics").stream().map(item -> (JsonObject) item).map(mosaic -> new Mosaic(new MosaicId(extractBigInteger(mosaic.getJsonArray("id"))), extractBigInteger(mosaic.getJsonArray("amount")))).collect(Collectors.toList());
}
Message message = PlainMessage.Empty;
if (transaction.getJsonObject("message") != null) {
try {
message = new PlainMessage(new String(Hex.decode(transaction.getJsonObject("message").getString("payload")), "UTF-8"));
} catch (UnsupportedEncodingException e) {
message = new PlainMessage(transaction.getJsonObject("message").getString("payload"));
}
}
return new TransferTransaction(extractNetworkType(transaction.getInteger("version")), extractTransactionVersion(transaction.getInteger("version")), deadline, extractBigInteger(transaction.getJsonArray("fee")), Address.createFromEncoded(transaction.getString("recipient")), mosaics, message, transaction.getString("signature"), new PublicAccount(transaction.getString("signer"), extractNetworkType(transaction.getInteger("version"))), transactionInfo);
}
use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicInfoTest method shouldReturnIsSupplyMutableWhenIsMutable.
@Test
void shouldReturnIsSupplyMutableWhenIsMutable() {
MosaicProperties mosaicProperties = new MosaicProperties(true, true, true, 3, BigInteger.valueOf(10));
MosaicInfo mosaicInfo = new MosaicInfo(true, 0, "5A3CD9B09CD1E8000159249B", new NamespaceId(new BigInteger("-8884663987180930485")), new MosaicId(new BigInteger("-3087871471161192663")), new BigInteger("100"), new BigInteger("0"), new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), mosaicProperties);
assertTrue(mosaicInfo.isSupplyMutable());
}
use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicInfoTest method shouldReturnIsTransferableWhenItsTransferable.
@Test
void shouldReturnIsTransferableWhenItsTransferable() {
MosaicProperties mosaicProperties = new MosaicProperties(true, true, true, 3, BigInteger.valueOf(10));
MosaicInfo mosaicInfo = new MosaicInfo(true, 0, "5A3CD9B09CD1E8000159249B", new NamespaceId(new BigInteger("-8884663987180930485")), new MosaicId(new BigInteger("-3087871471161192663")), new BigInteger("100"), new BigInteger("0"), new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), mosaicProperties);
assertTrue(mosaicInfo.isTransferable());
}
use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicInfoTest method createAMosaicInfoViaConstructor.
@Test
void createAMosaicInfoViaConstructor() {
MosaicProperties mosaicProperties = new MosaicProperties(true, true, true, 3, BigInteger.valueOf(10));
NamespaceId namespaceId = new NamespaceId(new BigInteger("-8884663987180930485"));
MosaicId mosaicId = new MosaicId(new BigInteger("-3087871471161192663"));
MosaicInfo mosaicInfo = new MosaicInfo(true, 0, "5A3CD9B09CD1E8000159249B", namespaceId, mosaicId, new BigInteger("100"), new BigInteger("0"), new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), mosaicProperties);
assertEquals(true, mosaicInfo.isActive());
assertTrue(mosaicInfo.getIndex() == 0);
assertEquals("5A3CD9B09CD1E8000159249B", mosaicInfo.getMetaId());
assertEquals(namespaceId, mosaicInfo.getNamespaceId());
assertEquals(mosaicId, mosaicInfo.getMosaicId());
assertEquals(new BigInteger("100"), mosaicInfo.getSupply());
assertEquals(new BigInteger("0"), mosaicInfo.getHeight());
assertEquals(new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), mosaicInfo.getOwner());
assertTrue(mosaicInfo.isSupplyMutable());
assertTrue(mosaicInfo.isTransferable());
assertTrue(mosaicInfo.isLevyMutable());
assertEquals(3, mosaicInfo.getDivisibility());
assertEquals(BigInteger.valueOf(10), mosaicInfo.getDuration());
}
use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class NamespaceInfoTest method createANamespaceInfoViaConstructor.
@Test
void createANamespaceInfoViaConstructor() {
NamespaceId namespaceId = new NamespaceId(new BigInteger("-8884663987180930485"));
NamespaceInfo namespaceInfo = new NamespaceInfo(true, 0, "5A3CD9B09CD1E8000159249B", NamespaceType.RootNamespace, 1, Arrays.asList(namespaceId), new NamespaceId(new BigInteger("0")), new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), new BigInteger("1"), new BigInteger("-1"));
assertEquals(true, namespaceInfo.isActive());
assertTrue(namespaceInfo.getIndex() == 0);
assertEquals("5A3CD9B09CD1E8000159249B", namespaceInfo.getMetaId());
assertTrue(namespaceInfo.getType() == NamespaceType.RootNamespace);
assertTrue(namespaceInfo.getDepth() == 1);
assertEquals(namespaceId, namespaceInfo.getLevels().get(0));
Assertions.assertEquals(new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), namespaceInfo.getOwner());
assertEquals(new BigInteger("1"), namespaceInfo.getStartHeight());
assertEquals(new BigInteger("-1"), namespaceInfo.getEndHeight());
}
Aggregations