From 5b7358238537625f5799d8ff837170db5a35e7e3 Mon Sep 17 00:00:00 2001 From: Mama1emon Date: Mon, 16 Dec 2024 14:13:05 +0400 Subject: [PATCH] AND-9347 Send (TON): cannot send some of ton's tokens if the amount is longer than Long (from support team) --- blockchain/build.gradle | 4 ++-- .../blockchain/blockchains/ton/TonTransactionBuilder.kt | 4 ++-- .../src/main/java/com/tangem/blockchain/common/Amount.kt | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/blockchain/build.gradle b/blockchain/build.gradle index 6e6b6c47a..38531d2c7 100644 --- a/blockchain/build.gradle +++ b/blockchain/build.gradle @@ -108,8 +108,8 @@ dependencies { implementation files('libs/hedera-sdk-java-2.29.0.jar') implementation "com.tangem:blstlib:master-6@aar" - implementation "com.tangem:wallet-core:4.0.46-tangem1@aar" - implementation("com.tangem:wallet-core-proto:4.0.46-tangem1") { + implementation "com.tangem:wallet-core:4.0.46-tangem4@aar" + implementation("com.tangem:wallet-core-proto:4.0.46-tangem4") { exclude group: 'com.google.protobuf', module: 'protobuf-javalite' } diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ton/TonTransactionBuilder.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ton/TonTransactionBuilder.kt index 5f7ca7766..84af70b9d 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ton/TonTransactionBuilder.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ton/TonTransactionBuilder.kt @@ -2,11 +2,11 @@ package com.tangem.blockchain.blockchains.ton import com.google.protobuf.ByteString import com.tangem.blockchain.common.* +import com.tangem.blockchain.extensions.Result import com.tangem.common.KeyPair import com.tangem.common.card.EllipticCurve import com.tangem.crypto.CryptoUtils import wallet.core.jni.proto.TheOpenNetwork -import com.tangem.blockchain.extensions.Result internal class TonTransactionBuilder(private val walletAddress: String) { @@ -73,7 +73,7 @@ internal class TonTransactionBuilder(private val walletAddress: String) { val jettonTransfer = TheOpenNetwork.JettonTransfer.newBuilder() .setTransfer(transfer) - .setJettonAmount(amount.longValueOrZero) + .setJettonAmount(ByteString.copyFrom(amount.byteArrayValue)) .setToOwner(destination) .setResponseAddress(walletAddress) .setForwardAmount(1) // some amount needed to send "jetton transfer notification", use minimum diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/Amount.kt b/blockchain/src/main/java/com/tangem/blockchain/common/Amount.kt index 0a8f370d5..0133df081 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/Amount.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/Amount.kt @@ -17,6 +17,8 @@ data class Amount( // Be careful! The property may overflow if the decimals are much larger than the long value. val longValueOrZero: Long by lazy { value?.movePointRight(decimals)?.toLong() ?: 0L } + val byteArrayValue: ByteArray? by lazy { value?.movePointRight(decimals)?.toBigInteger()?.toByteArray() } + constructor( value: BigDecimal?, blockchain: Blockchain,