Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/src/main/java/org/kin/sdk/base/KinAccountContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class KinAccountContextImpl private constructor(
destinationAccount,
KinBinaryMemo.Builder(processingAppIdx.value)
.setForeignKey(listOf(invoice).toProto().sha224Hash().decode())
.setTranferType(type)
.setTransferType(type)
.build()
.toKinMemo(),
Optional.of(invoice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ data class KinBinaryMemo internal constructor(
private var typeId: TransferType? = null
private var foreignKeyBytes: ByteArray? = null

fun setTranferType(typeId: TransferType): Builder =
fun setTransferType(typeId: TransferType): Builder =
also { this.typeId = typeId }

fun setForeignKey(foreignKeyBytes: ByteArray): Builder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ class KinServiceImplTest {
listOf(KinPaymentItem(KinAmount(123), destinationAccount.id, Optional.of(invoice))),
KinBinaryMemo.Builder(destinationKinAppIdx.value)
.setForeignKey(invoiceList.id.invoiceHash.decode())
.setTranferType(KinBinaryMemo.TransferType.Spend)
.setTransferType(KinBinaryMemo.TransferType.Spend)
.build()
.toKinMemo(),
QuarkAmount(100)
Expand Down
34 changes: 17 additions & 17 deletions base/src/test/kotlin/org/kin/sdk/base/models/KinBinaryMemoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import kotlin.test.assertTrue
class KinBinaryMemoTest {

@Test
fun testAgoraEncoding_specicFK() {
fun testAgoraEncoding_specificFK() {
val agoraMemo = KinBinaryMemo.Builder(10, 1, 2)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(byteArrayOf(0xAE.toByte(), 0xFD.toByte()))
.build()

Expand All @@ -34,7 +34,7 @@ class KinBinaryMemoTest {
(0..500).forEach {
println("index: $it")
val agoraMemo = KinBinaryMemo.Builder(10, 1, 2)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray())
.build()

Expand Down Expand Up @@ -67,7 +67,7 @@ class KinBinaryMemoTest {
(0..500).forEach {
println("index: $it")
val agoraMemo = KinBinaryMemo.Builder(10, 1, 2)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()

Expand Down Expand Up @@ -98,7 +98,7 @@ class KinBinaryMemoTest {
fun testAgoraEncoding_appIdx_validRange() {
(0..65535).forEach { index ->
val agoraMemo = KinBinaryMemo.Builder(index, 3, 7)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()

Expand All @@ -117,15 +117,15 @@ class KinBinaryMemoTest {
@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_appIdx_invalid_tooSmall() {
KinBinaryMemo.Builder(appIdx = -1, magicByteIndicator = 1, version = 7)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}

@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_appIdx_invalid_tooLarge() {
KinBinaryMemo.Builder(65536, 1, 2)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}
Expand All @@ -140,7 +140,7 @@ class KinBinaryMemoTest {
@Test
fun testAgoraEncoding_no_fk_default_0s() {
val memo = KinBinaryMemo.Builder(123, 1, 2)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.build()

assertTrue {
Expand Down Expand Up @@ -182,7 +182,7 @@ class KinBinaryMemoTest {
fun testAgoraEncoding_magicByteIndicator_validRange() {
(0..3).forEach { index ->
val agoraMemo = KinBinaryMemo.Builder(65535, index, 7)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()

Expand All @@ -202,15 +202,15 @@ class KinBinaryMemoTest {
@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_magicByteIndicator_invalid_tooSmall() {
KinBinaryMemo.Builder(65535, -1, 7)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}

@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_magicByteIndicator_invalid_tooLarge() {
KinBinaryMemo.Builder(65535, 3, 8)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}
Expand All @@ -219,7 +219,7 @@ class KinBinaryMemoTest {
fun testAgoraEncoding_version_validRange() {
(0..7).forEach { index ->
val agoraMemo = KinBinaryMemo.Builder(65535, 3, index)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()

Expand All @@ -238,15 +238,15 @@ class KinBinaryMemoTest {
@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_version_invalid_tooSmall() {
KinBinaryMemo.Builder(65535, 3, -1)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}

@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_version_invalid_tooLarge() {
KinBinaryMemo.Builder(65535, 3, 8)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}
Expand All @@ -256,7 +256,7 @@ class KinBinaryMemoTest {

fun verifyTypeId(inputTypeId: KinBinaryMemo.TransferType) {
val agoraMemo = KinBinaryMemo.Builder(65535, 3, 7)
.setTranferType(inputTypeId)
.setTransferType(inputTypeId)
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()

Expand All @@ -281,15 +281,15 @@ class KinBinaryMemoTest {
@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_typeId_invalid_tooSmall() {
KinBinaryMemo.Builder(65535, 3, -1)
.setTranferType(KinBinaryMemo.TransferType.ANY(-1))
.setTransferType(KinBinaryMemo.TransferType.ANY(-1))
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}

@Test(expected = KinBinaryMemo.Builder.KinBinaryMemoFormatException::class)
fun testAgoraEncoding_typeId_invalid_tooLarge() {
KinBinaryMemo.Builder(65535, 3, 8)
.setTranferType(KinBinaryMemo.TransferType.ANY(32))
.setTransferType(KinBinaryMemo.TransferType.ANY(32))
.setForeignKey(UUID.randomUUID().toByteArray() + UUID.randomUUID().toByteArray())
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ModernSendTransactionViewModel(
KinAmount(amount),
KinAccount.Id(destinationAddress),
KinBinaryMemo.Builder(DEMO_APP_IDX.value)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.build()
.toKinMemo()
).then({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ModernTransactionLoadTestingViewModel(
KinAmount(10),
KinAccount.Id(destinationAddress),
KinBinaryMemo.Builder(DemoAppConfig.DEMO_APP_IDX.value)
.setTranferType(KinBinaryMemo.TransferType.P2P)
.setTransferType(KinBinaryMemo.TransferType.P2P)
.build()
.toKinMemo()
).then({
Expand Down