mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-17 18:11:54 +00:00
248ba1c1c8
Compute max fees for transaction related requests and display the results to user. Also: - Add helper to convert from hex (backend) to decimal (frontend) values. - Add helper to convert from float gwei to hex wei - Update tests to accommodate for the new dependencies. Sourcing of account balances is not included therefore the transaction is allowed to go through even if the account balance is insufficient. An error will be generated by the backend in this case. Updates: #15192
41 lines
1.5 KiB
Nim
41 lines
1.5 KiB
Nim
import unittest
|
|
|
|
import app/modules/main/wallet_section/poc_wallet_connect/helpers
|
|
|
|
import app/modules/shared_modules/wallet_connect/helpers
|
|
|
|
suite "wallet connect":
|
|
|
|
test "hexToDec":
|
|
check(hexToDec("0x3") == "3")
|
|
check(hexToDec("f") == "15")
|
|
|
|
test "convertFeesInfoToHex":
|
|
const feesInfoJson = "{\"maxFees\":\"24528.282681\",\"maxFeePerGas\":1.168013461,\"maxPriorityFeePerGas\":0.036572351,\"gasPrice\":\"1.168013461\"}"
|
|
|
|
check(convertFeesInfoToHex(feesInfoJson) == """{"maxFeePerGas":"0x459E7895","maxPriorityFeePerGas":"0x22E0CBF"}""")
|
|
|
|
test "parse deep link url":
|
|
const testUrl = "https://status.app/wc?uri=wc%3Aa4f32854428af0f5b6635fb7a3cb2cfe174eaad63b9d10d52ef1c686f8eab862%402%3Frelay-protocol%3Dirn%26symKey%3D4ccbae2b4c81c26fbf4a6acee9de2771705d467de9a1d24c80240e8be59de6be"
|
|
|
|
let (resOk, wcUri) = extractAndCheckUriParameter(testUrl)
|
|
|
|
check(resOk)
|
|
check(wcUri == "wc:a4f32854428af0f5b6635fb7a3cb2cfe174eaad63b9d10d52ef1c686f8eab862@2?relay-protocol=irn&symKey=4ccbae2b4c81c26fbf4a6acee9de2771705d467de9a1d24c80240e8be59de6be")
|
|
|
|
test "parse another valid deep link url":
|
|
const testUrl = "https://status.app/notwc?uri=lt%3Asomevalue"
|
|
|
|
let (resOk, wcUri) = extractAndCheckUriParameter(testUrl)
|
|
|
|
check(not resOk)
|
|
check(wcUri == "")
|
|
|
|
test "parse a WC no-prefix deeplink":
|
|
const testUrl = "https://status.app/wc?uri=w4%3Atest"
|
|
|
|
let (resOk, wcUri) = extractAndCheckUriParameter(testUrl)
|
|
|
|
check(not resOk)
|
|
check(wcUri == "")
|