Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dgridnev committed Jun 7, 2024
2 parents adadcc6 + acf706c commit 421609e
Show file tree
Hide file tree
Showing 72 changed files with 3,803 additions and 210 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ val hamcrestVersion: String by project
val mockkVersion: String by project
val springMockkVersion: String by project
val wireMockVersion: String by project
val kotestVersion: String by project

val ktorVersion: String by project

Expand Down Expand Up @@ -303,6 +304,7 @@ configure(
dependency("org.hamcrest:hamcrest-library:$hamcrestVersion")

dependency("com.github.tomakehurst:wiremock-jre8:$wireMockVersion")
dependency("io.kotest:kotest-runner-junit5:$kotestVersion")
}
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ hamcrestVersion=2.2
mockkVersion=1.12.3
springMockkVersion=3.1.1
wireMockVersion=2.33.2
kotestVersion=5.0.0

# Publishing values
githubUrl=https://github.com/waves-enterprise/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.wavesenterprise.sdk.node.domain.sign

import com.wavesenterprise.sdk.node.domain.Address
import com.wavesenterprise.sdk.node.domain.DataEntry
import com.wavesenterprise.sdk.node.domain.Fee
import com.wavesenterprise.sdk.node.domain.FeeAssetId
import com.wavesenterprise.sdk.node.domain.Password
import com.wavesenterprise.sdk.node.domain.PermitDataEntry
import com.wavesenterprise.sdk.node.domain.TxVersion
import com.wavesenterprise.sdk.node.domain.tx.DataTx

Expand All @@ -15,7 +15,7 @@ data class DataSignRequest(
val fee: Fee,
val feeAssetId: FeeAssetId? = null,
val author: Address,
val data: List<PermitDataEntry>,
val data: List<DataEntry>,
) : SignRequest<DataTx> {
override fun withAddress(address: Address) = copy(senderAddress = address)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ data class RegisterNodeSignRequest(
override val password: Password? = null,
val fee: Fee,
val opType: OpType,
val target: Address,
val targetPublicKey: PublicKey,
val nodeName: NodeName,
) : SignRequest<RegisterNodeTx> {
Expand All @@ -30,7 +29,6 @@ data class RegisterNodeSignRequest(
fun RegisterNodeSignRequest.toTx(senderPublicKey: PublicKey) = RegisterNodeTx(
id = TxId.EMPTY,
senderPublicKey = senderPublicKey,
target = target,
targetPublicKey = targetPublicKey,
nodeName = nodeName,
opType = opType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.wavesenterprise.sdk.node.domain.tx

import com.wavesenterprise.sdk.node.domain.Address
import com.wavesenterprise.sdk.node.domain.DataEntry
import com.wavesenterprise.sdk.node.domain.Fee
import com.wavesenterprise.sdk.node.domain.FeeAssetId
import com.wavesenterprise.sdk.node.domain.PermitDataEntry
import com.wavesenterprise.sdk.node.domain.PublicKey
import com.wavesenterprise.sdk.node.domain.Signature
import com.wavesenterprise.sdk.node.domain.Timestamp
Expand All @@ -18,7 +18,7 @@ data class DataTx(
@FieldInfo(required = true, sinceVersion = 1, bytesPosition = 2)
val authorPublicKey: PublicKey,
@FieldInfo(required = true, sinceVersion = 1, bytesPosition = 3)
val data: List<PermitDataEntry>,
val data: List<DataEntry>,
@FieldInfo(required = true, sinceVersion = 1, bytesPosition = 4)
override val timestamp: Timestamp,
@FieldInfo(required = true, sinceVersion = 1, bytesPosition = 5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ data class RegisterNodeTx(
override val id: TxId,
@FieldInfo(required = true, sinceVersion = 1, bytesPosition = 1)
val senderPublicKey: PublicKey,
val target: Address,
@FieldInfo(required = true, sinceVersion = 1, bytesPosition = 2)
val targetPublicKey: PublicKey,
@FieldInfo(required = true, sinceVersion = 1, bytesPosition = 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ dependencies {
implementation(kotlin("stdlib"))

api(project(":we-node-client-grpc:we-node-client-grpc-java"))

testImplementation("io.mockk:mockk")
testImplementation("io.kotest:kotest-runner-junit5")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation("org.junit.jupiter:junit-jupiter-engine")
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ object AtomicBadgeMapper {
@JvmStatic
internal fun domainInternal(atomicBadge: ProtoAtomicBadge): AtomicBadge =
AtomicBadge(
trustedSender = Address(atomicBadge.trustedSender.byteArray())
trustedSender = Address(atomicBadge.trustedSender.value.byteArray())
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.wavesenterprise.sdk.node.client.grpc.mapper

import com.wavesenterprise.sdk.node.client.grpc.mapper.GrpcTypesMapper.byteArray
import com.wavesenterprise.sdk.node.domain.Address
import com.wavesenterprise.sdk.node.domain.Amount
import com.wavesenterprise.sdk.node.domain.Transfer
import com.wavesenterprise.transaction.protobuf.Transfer as ProtoTransfer

object TransferMapper {

@JvmStatic
fun ProtoTransfer.domain(): Transfer =
domainInternal(this)

@JvmStatic
internal fun domainInternal(protoTransfer: ProtoTransfer): Transfer =
Transfer(
recipient = Address(protoTransfer.recipient.byteArray()),
amount = Amount(protoTransfer.amount),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.wavesenterprise.sdk.node.domain.TxVersion
import com.wavesenterprise.sdk.node.domain.tx.AtomicTx
import com.wavesenterprise.transaction.protobuf.AtomicTransaction
import com.wavesenterprise.transaction.protobuf.atomicTransaction
import com.wavesenterprise.transaction.protobuf.minerOrNull

object AtomicTxMapper {
@JvmStatic
Expand Down Expand Up @@ -48,13 +49,10 @@ object AtomicTxMapper {
AtomicTx(
id = TxId(tx.id.byteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.toByteArray()),
miner = tx.minerOrNull?.let { Address(it.value.byteArray()) },
txs = tx.transactionsList.map { it.domain(version) },
timestamp = Timestamp.fromUtcTimestamp(tx.timestamp),
proofs = tx.proofsList?.let { dtoProofs ->
dtoProofs.map {
Signature(it.byteArray())
}
},
timestamp = Timestamp(tx.timestamp),
proofs = tx.proofsList?.map { Signature(it.byteArray()) },
senderAddress = Address(tx.senderAddress.byteArray()),
fee = Fee(0),
version = version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,12 @@ object BurnTxMapper {
BurnTx(
id = TxId(tx.id.byteArray()),
chainId = ChainId(tx.chainId.toByte()),
senderPublicKey = PublicKey(tx.senderPublicKey.toByteArray()),
assetId = tx.assetId?.let {
AssetId.fromByteArray(it.byteArray())
},
senderPublicKey = PublicKey(tx.senderPublicKey.byteArray()),
assetId = AssetId(tx.assetId.byteArray()),
amount = Amount(tx.amount),
fee = Fee(tx.fee),
timestamp = Timestamp.fromUtcTimestamp(tx.timestamp),
proofs = tx.proofsList?.let { dtoProofs ->
dtoProofs.map {
Signature(it.byteArray())
}
},
proofs = tx.proofsList?.map { Signature(it.byteArray()) },
senderAddress = Address(tx.senderAddress.byteArray()),
version = version,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.wavesenterprise.sdk.node.domain.TxVersion
import com.wavesenterprise.sdk.node.domain.contract.ContractId
import com.wavesenterprise.sdk.node.domain.contract.ContractVersion
import com.wavesenterprise.sdk.node.domain.tx.CallContractTx
import com.wavesenterprise.transaction.protobuf.DataEntry
import com.wavesenterprise.transaction.protobuf.docker.CallContractTransaction
import com.wavesenterprise.transaction.protobuf.docker.atomicBadgeOrNull
import com.wavesenterprise.transaction.protobuf.docker.callContractTransaction
Expand Down Expand Up @@ -60,23 +59,21 @@ object CallContractTxMapper {
internal fun domainInternal(tx: CallContractTransaction, version: TxVersion): CallContractTx =
CallContractTx(
id = TxId(tx.id.byteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.toByteArray()),
contractId = ContractId.fromByteArray(tx.contractId.toByteArray()),
params = tx.paramsList.map { param: DataEntry ->
param.domain()
},
senderPublicKey = PublicKey(tx.senderPublicKey.byteArray()),
contractId = ContractId(
txId = TxId(tx.contractId.byteArray())
),
params = tx.paramsList.map { it.domain() },
fee = Fee(tx.fee),
timestamp = Timestamp.fromUtcTimestamp(tx.timestamp),
timestamp = Timestamp(tx.timestamp),
contractVersion = ContractVersion(tx.contractVersion),
feeAssetId = tx.feeAssetIdOrNull?.let {
FeeAssetId.fromByteArray(it.byteArray())
FeeAssetId(
txId = TxId(it.value.byteArray())
)
},
atomicBadge = tx.atomicBadgeOrNull?.domain(),
proofs = tx.proofsList?.let { dtoProofs ->
dtoProofs.map {
Signature(it.byteArray())
}
},
proofs = tx.proofsList?.map { Signature(it.byteArray()) },
senderAddress = Address(tx.senderAddress.byteArray()),
version = version,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
package com.wavesenterprise.sdk.node.client.grpc.mapper.tx

import com.wavesenterprise.sdk.node.client.grpc.mapper.GrpcTypesMapper.byteArray
import com.wavesenterprise.sdk.node.domain.Address
import com.wavesenterprise.sdk.node.domain.Alias
import com.wavesenterprise.sdk.node.domain.Fee
import com.wavesenterprise.sdk.node.domain.FeeAssetId
import com.wavesenterprise.sdk.node.domain.PublicKey
import com.wavesenterprise.sdk.node.domain.Signature
import com.wavesenterprise.sdk.node.domain.Timestamp
import com.wavesenterprise.sdk.node.domain.TxId
import com.wavesenterprise.sdk.node.domain.TxVersion
import com.wavesenterprise.sdk.node.domain.tx.CreateAliasTx
import com.wavesenterprise.transaction.protobuf.CreateAliasTransaction
import com.wavesenterprise.transaction.protobuf.feeAssetIdOrNull

object CreateAliasTxMapper {

fun dtoInternal(tx: CreateAliasTx): CreateAliasTransaction {
TODO("Not yet implemented")
}

@JvmStatic
fun CreateAliasTransaction.domain(version: TxVersion): CreateAliasTx =
domainInternal(this, version)

@JvmStatic
internal fun domainInternal(tx: CreateAliasTransaction, version: TxVersion): CreateAliasTx =
CreateAliasTx(
id = TxId(tx.id.byteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.toByteArray()),
alias = Alias(tx.alias.toString()),
fee = Fee(tx.fee),
timestamp = Timestamp.fromUtcTimestamp(tx.timestamp),
feeAssetId = tx.feeAssetIdOrNull?.let { FeeAssetId.fromByteArray(it.value.toByteArray()) },
proofs = tx.proofsList?.map { Signature(it.byteArray()) },
senderAddress = Address(tx.senderAddress.toByteArray()),
version = version,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.wavesenterprise.sdk.node.domain.contract.ContractImage
import com.wavesenterprise.sdk.node.domain.contract.ContractImageHash
import com.wavesenterprise.sdk.node.domain.contract.ContractName
import com.wavesenterprise.sdk.node.domain.tx.CreateContractTx
import com.wavesenterprise.transaction.protobuf.DataEntry
import com.wavesenterprise.transaction.protobuf.docker.CreateContractTransaction
import com.wavesenterprise.transaction.protobuf.docker.apiVersionOrNull
import com.wavesenterprise.transaction.protobuf.docker.atomicBadgeOrNull
Expand Down Expand Up @@ -69,26 +68,22 @@ object CreateContractTxMapper {
internal fun domainInternal(tx: CreateContractTransaction, version: TxVersion): CreateContractTx =
CreateContractTx(
id = TxId(tx.id.byteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.toByteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.byteArray()),
image = ContractImage(tx.image),
imageHash = ContractImageHash(tx.imageHash),
contractName = ContractName(tx.contractName),
params = tx.paramsList.map { param: DataEntry ->
param.domain()
},
params = tx.paramsList.map { it.domain() },
fee = Fee(tx.fee),
timestamp = Timestamp.fromUtcTimestamp(tx.timestamp),
timestamp = Timestamp(tx.timestamp),
feeAssetId = tx.feeAssetIdOrNull?.let {
FeeAssetId.fromByteArray(it.byteArray())
FeeAssetId(
txId = TxId(it.value.byteArray())
)
},
atomicBadge = tx.atomicBadgeOrNull?.domain(),
validationPolicy = tx.validationPolicyOrNull?.domain(),
apiVersion = tx.apiVersionOrNull?.domain(),
proofs = tx.proofsList?.let { dtoProofs ->
dtoProofs.map {
Signature(it.byteArray())
}
},
proofs = tx.proofsList?.map { Signature(it.byteArray()) },
senderAddress = Address(tx.senderAddress.byteArray()),
version = version,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ object CreatePolicyTxMapper {
internal fun domainInternal(tx: CreatePolicyTransaction, version: TxVersion): CreatePolicyTx =
CreatePolicyTx(
id = TxId(tx.id.byteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.toByteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.byteArray()),
policyName = PolicyName(tx.policyName),
description = PolicyDescription(tx.description),
recipients = tx.recipientsList.map { Address(it.byteArray()) },
owners = tx.ownersList.map { Address(it.byteArray()) },
timestamp = Timestamp.fromUtcTimestamp(tx.timestamp),
fee = Fee(tx.fee),
feeAssetId = tx.feeAssetIdOrNull?.let {
FeeAssetId.fromByteArray(it.byteArray())
},
feeAssetId = tx.feeAssetIdOrNull?.let { FeeAssetId.fromByteArray(it.value.byteArray()) },
atomicBadge = tx.atomicBadgeOrNull?.domain(),
proofs = tx.proofsList?.let { dtoProofs ->
dtoProofs.map {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
package com.wavesenterprise.sdk.node.client.grpc.mapper.tx

import com.wavesenterprise.sdk.node.client.grpc.mapper.DataEntryMapper.domain
import com.wavesenterprise.sdk.node.client.grpc.mapper.GrpcTypesMapper.byteArray
import com.wavesenterprise.sdk.node.domain.Address
import com.wavesenterprise.sdk.node.domain.Fee
import com.wavesenterprise.sdk.node.domain.FeeAssetId
import com.wavesenterprise.sdk.node.domain.PublicKey
import com.wavesenterprise.sdk.node.domain.Signature
import com.wavesenterprise.sdk.node.domain.Timestamp
import com.wavesenterprise.sdk.node.domain.TxId
import com.wavesenterprise.sdk.node.domain.TxVersion
import com.wavesenterprise.sdk.node.domain.tx.DataTx
import com.wavesenterprise.transaction.protobuf.DataTransaction
import com.wavesenterprise.transaction.protobuf.feeAssetIdOrNull

object DataTxMapper {

fun dtoInternal(tx: DataTx): DataTransaction {
TODO("Not yet implemented")
}

@JvmStatic
fun DataTransaction.domain(version: TxVersion): DataTx =
domainInternal(this, version)

@JvmStatic
internal fun domainInternal(tx: DataTransaction, version: TxVersion): DataTx =
DataTx(
id = TxId(tx.id.byteArray()),
senderPublicKey = PublicKey(tx.senderPublicKey.byteArray()),
authorPublicKey = PublicKey(tx.authorPublicKey.byteArray()),
data = tx.dataList.map { it.domain() },
fee = Fee(tx.fee),
feeAssetId = tx.feeAssetIdOrNull?.let {
FeeAssetId(
txId = TxId(it.value.byteArray())
)
},
timestamp = Timestamp(tx.timestamp),
proofs = tx.proofsList?.map { Signature(it.byteArray()) },
senderAddress = Address(tx.senderAddress.byteArray()),
authorAddress = Address(tx.authorPublicKey.byteArray()),
version = version,
)
}
Loading

0 comments on commit 421609e

Please sign in to comment.