Updated on 2026-08-14
This commit is contained in:
commit
b3369e30bb
5 changed files with 24 additions and 45 deletions
Binary file not shown.
BIN
app/libs/walletconnect-1.5.6.aar
Normal file
BIN
app/libs/walletconnect-1.5.6.aar
Normal file
Binary file not shown.
|
|
@ -475,40 +475,6 @@ class WalletConnectManager {
|
|||
store.dispatchOnMain(WalletConnectAction.SwitchBlockchain(blockchain, session))
|
||||
}
|
||||
}
|
||||
client.onCustomRequest = { id: Long, data: String ->
|
||||
Timber.d("Custom Request")
|
||||
Timber.d(data)
|
||||
val request = EthSignHelper.parseCustomRequest(data)
|
||||
|
||||
when (request.method) {
|
||||
WCMethodExtended.ETH_SIGN_TYPE_DATA_V4 -> handleTypedDataV4(request, client, id)
|
||||
else -> {
|
||||
Timber.d("WC: unrecognized custom request")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun handleTypedDataV4(request: CustomJsonRpcRequest, client: WCClient, id: Long) {
|
||||
val message = EthSignHelper.tryToParseEthTypedMessage(request)
|
||||
if (message != null) {
|
||||
Timber.d("onEthSign_v4: $message")
|
||||
// Analytics.logWcEvent(
|
||||
// AnalyticsAnOld.WcAnalyticsEvent.Action(
|
||||
// AnalyticsAnOld.WcAction.PersonalSign
|
||||
// )
|
||||
// )
|
||||
sessions[client.session]?.toWalletConnectSession()?.let { sessionData ->
|
||||
store.dispatchOnMain(
|
||||
WalletConnectAction.HandlePersonalSignRequest(
|
||||
message,
|
||||
sessionData,
|
||||
id
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ import com.tangem.tap.store
|
|||
import com.tangem.tap.tangemSdk
|
||||
import com.tangem.tap.tangemSdkManager
|
||||
import com.trustwallet.walletconnect.models.ethereum.WCEthereumSignMessage
|
||||
import com.trustwallet.walletconnect.models.ethereum.WCEthereumSignMessage.WCSignType.MESSAGE
|
||||
import com.trustwallet.walletconnect.models.ethereum.WCEthereumSignMessage.WCSignType.PERSONAL_MESSAGE
|
||||
import com.trustwallet.walletconnect.models.ethereum.WCEthereumSignMessage.WCSignType.TYPED_MESSAGE
|
||||
import com.trustwallet.walletconnect.models.ethereum.WCEthereumTransaction
|
||||
import timber.log.Timber
|
||||
import java.math.BigDecimal
|
||||
|
|
@ -206,19 +209,15 @@ class WalletConnectSdkHelper {
|
|||
session: WalletConnectSession,
|
||||
id: Long,
|
||||
): WcPersonalSignData {
|
||||
val messageData =
|
||||
try {
|
||||
message.data.removePrefix(HEX_PREFIX).hexToBytes()
|
||||
} catch (exception: Exception) {
|
||||
message.data.asciiToHex()!!.hexToBytes()
|
||||
}
|
||||
val messageData = when (message.type) {
|
||||
MESSAGE, PERSONAL_MESSAGE -> createMessageData(message)
|
||||
TYPED_MESSAGE -> EthereumUtils.makeTypedDataHash(message.data)
|
||||
}
|
||||
|
||||
val messageString = message.data.hexToAscii()
|
||||
?: EthSignHelper.tryToParseEthTypedMessageString(message.data)
|
||||
?: message.data
|
||||
|
||||
val prefixData = (ETH_MESSAGE_PREFIX + messageData.size.toString()).toByteArray()
|
||||
val hashToSign = (prefixData + messageData).toKeccak()
|
||||
|
||||
val dialogData = PersonalSignDialogData(
|
||||
dAppName = session.peerMeta.name,
|
||||
message = messageString,
|
||||
|
|
@ -226,13 +225,24 @@ class WalletConnectSdkHelper {
|
|||
id = id,
|
||||
)
|
||||
return WcPersonalSignData(
|
||||
hash = hashToSign,
|
||||
hash = messageData,
|
||||
session = session,
|
||||
id = id,
|
||||
dialogData = dialogData,
|
||||
)
|
||||
}
|
||||
|
||||
private fun createMessageData(message: WCEthereumSignMessage): ByteArray {
|
||||
val messageData = try {
|
||||
message.data.removePrefix(HEX_PREFIX).hexToBytes()
|
||||
} catch (exception: Exception) {
|
||||
message.data.asciiToHex()?.hexToBytes() ?: byteArrayOf()
|
||||
}
|
||||
|
||||
val prefixData = (ETH_MESSAGE_PREFIX + messageData.size.toString()).toByteArray()
|
||||
return (prefixData + messageData).toKeccak()
|
||||
}
|
||||
|
||||
private fun String.hexToAscii(): String? {
|
||||
return try {
|
||||
removePrefix(HEX_PREFIX).hexToBytes()
|
||||
|
|
|
|||
|
|
@ -58,8 +58,11 @@ object Versions {
|
|||
// endregion Other libraries
|
||||
|
||||
// region Tangem
|
||||
const val tangemBlockchainSdk = "develop-133"
|
||||
const val tangemBlockchainSdk = "develop-140"
|
||||
|
||||
// const val tangemBlockchainSdk = "0.0.1"
|
||||
const val tangemCardSgk = "develop-165"
|
||||
// const val tangemCardSgk = "0.0.1"
|
||||
// endregion Tangem
|
||||
|
||||
// region Testing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue