From 5fa342815328e38a9f1f043d6a71092bda7d8883 Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sun, 31 Mar 2024 11:08:11 +0200 Subject: [PATCH 1/7] Increase level of fee spending validation in preflightCurrencyTransfer --- src/utils/api/channels/vrpc/requests/preflight.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/api/channels/vrpc/requests/preflight.js b/src/utils/api/channels/vrpc/requests/preflight.js index df2e41ab..7127fae7 100644 --- a/src/utils/api/channels/vrpc/requests/preflight.js +++ b/src/utils/api/channels/vrpc/requests/preflight.js @@ -509,6 +509,14 @@ export const preflightCurrencyTransfer = async (coinObj, channelId, activeUser, } }) + Object.keys(validation.fees).forEach((key) => { + const value = BigNumber(validation.fees[key]); + + if (((feecurrency != null && key !== feecurrency) || (feecurrency == null && key !== systemId)) && value.isGreaterThan(0)) { + throw new Error("Can only spend fee in fee currency (if specified) or system currency.") + } + }) + const preflightTx = Transaction.fromHex(fundRes.result.hex, networks.verus); const inputs = [] From 32e6a69a2f646e93d24ee7ffa6b7b8546dcbdd98 Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sun, 31 Mar 2024 11:30:39 +0200 Subject: [PATCH 2/7] Update SendModal and SendCoin components to disable mapping field when not applicable --- src/actions/actions/sendModal/dispatchers/sendModal.js | 2 +- src/components/SendModal/SendModal.js | 2 +- src/containers/Coin/SendCoin/SendCoin.js | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/actions/actions/sendModal/dispatchers/sendModal.js b/src/actions/actions/sendModal/dispatchers/sendModal.js index 1f0710db..3eee5ad5 100644 --- a/src/actions/actions/sendModal/dispatchers/sendModal.js +++ b/src/actions/actions/sendModal/dispatchers/sendModal.js @@ -103,7 +103,7 @@ export const openConvertOrCrossChainSendModal = (coinObj, subWallet, data) => { [SEND_MODAL_SHOW_CONVERTTO_FIELD]: true, [SEND_MODAL_SHOW_EXPORTTO_FIELD]: true, [SEND_MODAL_SHOW_VIA_FIELD]: true, - [SEND_MODAL_SHOW_MAPPING_FIELD]: true, + [SEND_MODAL_SHOW_MAPPING_FIELD]: coinObj.proto === 'eth' || coinObj.proto === 'erc20', [SEND_MODAL_ADVANCED_FORM]: false, [SEND_MODAL_SHOW_IS_PRECONVERT]: false, [SEND_MODAL_DISABLED_INPUTS]: {} diff --git a/src/components/SendModal/SendModal.js b/src/components/SendModal/SendModal.js index e769f844..25c5d27c 100644 --- a/src/components/SendModal/SendModal.js +++ b/src/components/SendModal/SendModal.js @@ -27,7 +27,7 @@ class SendModal extends Component { super(props); this.DEFAULT_MODAL_HEIGHTS = { - [TRADITIONAL_CRYPTO_SEND_MODAL]: 442, + [TRADITIONAL_CRYPTO_SEND_MODAL]: 624, [CONVERSION_SEND_MODAL]: 624, [WITHDRAW_SEND_MODAL]: 624, [DEPOSIT_SEND_MODAL]: 624, diff --git a/src/containers/Coin/SendCoin/SendCoin.js b/src/containers/Coin/SendCoin/SendCoin.js index c4b923dd..c8b8bd60 100644 --- a/src/containers/Coin/SendCoin/SendCoin.js +++ b/src/containers/Coin/SendCoin/SendCoin.js @@ -83,7 +83,9 @@ const SendCoin = ({ navigation }) => { [SEND_MODAL_SHOW_MAPPING_FIELD]: true, [SEND_MODAL_SHOW_VIA_FIELD]: false, [SEND_MODAL_ADVANCED_FORM]: false, - [SEND_MODAL_DISABLED_INPUTS]: {} + [SEND_MODAL_DISABLED_INPUTS]: { + [SEND_MODAL_MAPPING_FIELD]: activeCoin.proto === 'vrsc' + } }, }, { From 316b8c657cfa9f1967e4d2ad9759eb14b144b717 Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sun, 31 Mar 2024 12:24:30 +0200 Subject: [PATCH 3/7] Fix condition for ethBridgeDelegatorActive in preflightCurrencyTransfer --- src/utils/api/channels/vrpc/requests/preflight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/api/channels/vrpc/requests/preflight.js b/src/utils/api/channels/vrpc/requests/preflight.js index 7127fae7..576e0903 100644 --- a/src/utils/api/channels/vrpc/requests/preflight.js +++ b/src/utils/api/channels/vrpc/requests/preflight.js @@ -385,7 +385,7 @@ export const preflightCurrencyTransfer = async (coinObj, channelId, activeUser, */ const transDest = outputInfo.params[0].data; - if (ethBridgeDelegatorActive) { + if (ethBridgeDelegatorActive || (exportto !== "i9nwxtKuVYX4MSbeULLiK2ttVi6rUEhh4X" && exportto !== "iCtawpxUiCc2sEupt7Z4u8SDAncGZpgSKm")) { if (!transDest.transfer_destination.isGateway()) throw new Error("Expected gateway output"); if (transDest.transfer_destination.gateway_id !== exportto) throw new Error("Expected gateway_id to match exportto"); if (transDest.transfer_destination.gateway_code !== "i3UXS5QPRQGNRDDqVnyWTnmFCTHDbzmsYk") throw new Error("Expected null gateway_code"); From 426a5dd2c885880f35d37ddfe6de232c47ce541c Mon Sep 17 00:00:00 2001 From: michaeltout Date: Wed, 10 Apr 2024 13:00:30 +0200 Subject: [PATCH 4/7] Change decimal number for tBTC --- src/utils/CoinData/CoinsList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/CoinData/CoinsList.js b/src/utils/CoinData/CoinsList.js index 792b6e09..87d3744d 100644 --- a/src/utils/CoinData/CoinsList.js +++ b/src/utils/CoinData/CoinsList.js @@ -937,7 +937,7 @@ export const coinsList = { compatible_channels: [ERC20, GENERAL], theme_color: '#000000', dominant_channel: ERC20, - decimals: DEFAULT_DECIMALS, + decimals: ETHERS, tags: [], proto: 'erc20', rate_url_params: {coin_paprika: 'tbtc-tbtc'}, From 15205b00c8bc9b399c67287a3c038dd7ea58e92d Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Wed, 10 Apr 2024 12:49:48 -0700 Subject: [PATCH 5/7] update version --- android/app/build.gradle | 2 +- env/main.android.json | 2 +- env/main.ios.json | 2 +- ios/assets/env/main.json | 2 +- ios/verusMobile.xcodeproj/project.pbxproj | 4 ++-- package.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index d39022ef..15c709d6 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -4,7 +4,7 @@ import com.android.build.OutputFile def versionMajor = 1 def versionMinor = 0 -def versionRevision = 9 +def versionRevision = 10 def versionBuild = 0 def keystorePropertiesFile = rootProject.file("keystore.properties"); diff --git a/env/main.android.json b/env/main.android.json index b02c238e..07c5d124 100644 --- a/env/main.android.json +++ b/env/main.android.json @@ -1,5 +1,5 @@ { - "APP_VERSION": "1.0.9", + "APP_VERSION": "1.0.10", "ELECTRUM_PROTOCOL_CHANGE": 1.4, "KEY_DERIVATION_VERSION": 1, diff --git a/env/main.ios.json b/env/main.ios.json index 0a4d906c..9431d1ec 100644 --- a/env/main.ios.json +++ b/env/main.ios.json @@ -1,5 +1,5 @@ { - "APP_VERSION": "1.0.9", + "APP_VERSION": "1.0.10", "ELECTRUM_PROTOCOL_CHANGE": 1.4, "KEY_DERIVATION_VERSION": 1, diff --git a/ios/assets/env/main.json b/ios/assets/env/main.json index 0a4d906c..9431d1ec 100644 --- a/ios/assets/env/main.json +++ b/ios/assets/env/main.json @@ -1,5 +1,5 @@ { - "APP_VERSION": "1.0.9", + "APP_VERSION": "1.0.10", "ELECTRUM_PROTOCOL_CHANGE": 1.4, "KEY_DERIVATION_VERSION": 1, diff --git a/ios/verusMobile.xcodeproj/project.pbxproj b/ios/verusMobile.xcodeproj/project.pbxproj index b39c83ed..ee3cea63 100644 --- a/ios/verusMobile.xcodeproj/project.pbxproj +++ b/ios/verusMobile.xcodeproj/project.pbxproj @@ -721,7 +721,7 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/react-native-webview\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/rn-fetch-blob\"", ); - MARKETING_VERSION = 1.0.9; + MARKETING_VERSION = 1.0.10; PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.verusmobile; PRODUCT_NAME = verusmobile; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -792,7 +792,7 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/react-native-webview\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/rn-fetch-blob\"", ); - MARKETING_VERSION = 1.0.9; + MARKETING_VERSION = 1.0.10; PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.verusmobile; PRODUCT_NAME = verusmobile; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/package.json b/package.json index 6acd410a..8a5ef531 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "verusmobile", - "version": "1.0.9", + "version": "1.0.10", "private": true, "scripts": { "postinstall": "./node_modules/.bin/rn-nodeify --hack --install --yarn && npx jetify", From 080151dc31e1c50826e28c71b4e1259a7990e2f7 Mon Sep 17 00:00:00 2001 From: michaeltout Date: Thu, 11 Apr 2024 20:31:10 +0200 Subject: [PATCH 6/7] Fix preflightBridgeTransfer function to set secondreserveid to NULL_ETH_ADDRESS when via is null --- src/utils/api/channels/erc20/requests/preflight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/api/channels/erc20/requests/preflight.js b/src/utils/api/channels/erc20/requests/preflight.js index 365a1dee..58b87fd7 100644 --- a/src/utils/api/channels/erc20/requests/preflight.js +++ b/src/utils/api/channels/erc20/requests/preflight.js @@ -251,7 +251,7 @@ export const preflightBridgeTransfer = async (coinObj, channelId, activeUser, ou if (via != null) { secondreserveid = finalDestinationCurrencyAddress; - } + } else secondreserveid = NULL_ETH_ADDRESS; if (importToSource) { destinationcurrency = finalDestinationCurrencyAddress; From 75474e613ff6cd673193f807d2cd3ec6c6b7f062 Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sat, 13 Apr 2024 20:06:19 +0200 Subject: [PATCH 7/7] Update gas fee modifier in preflightBridgeTransfer function --- src/utils/api/channels/erc20/requests/preflight.js | 11 ++++++----- src/utils/constants/web3Constants.js | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils/api/channels/erc20/requests/preflight.js b/src/utils/api/channels/erc20/requests/preflight.js index 58b87fd7..ef37e410 100644 --- a/src/utils/api/channels/erc20/requests/preflight.js +++ b/src/utils/api/channels/erc20/requests/preflight.js @@ -19,7 +19,8 @@ import { ETH_VERUS_BRIDGE_CONTRACT_PRELAUNCH_RESERVE_TRANSFER_FEE, MKR_VETH, ETH_VERUS_BRIDGE_CONTRACT_RESERVE_TRANSFER_FEE_WEI, - MINIMUM_IMPORT_FEE_WEI + MINIMUM_IMPORT_FEE_WEI, + GAS_PRICE_MODIFIER } from '../../../../constants/web3Constants'; import { getCurrency, getIdentity } from "../../verusid/callCreators" import { getSystemNameFromSystemId } from "../../../../CoinData/CoinData" @@ -271,8 +272,8 @@ export const preflightBridgeTransfer = async (coinObj, channelId, activeUser, ou const baseGasPrice = await Web3Provider.DefaultProvider.getGasPrice(); const minGasPrice = ethers.BigNumber.from(MINIMUM_GAS_PRICE_WEI_DELEGATOR_CONTRACT); - const gasPriceModifier = ethers.BigNumber.from("2"); - const modifiedGasPrice = baseGasPrice.add(baseGasPrice.div(gasPriceModifier)); + const gasFeeModifier = ethers.BigNumber.from("4"); + const modifiedGasPrice = baseGasPrice.add(GAS_PRICE_MODIFIER); const gasPrice = modifiedGasPrice.gte(minGasPrice) ? modifiedGasPrice : minGasPrice; const minimumImportFee = ethers.BigNumber.from(MINIMUM_IMPORT_FEE_WEI) @@ -364,7 +365,7 @@ export const preflightBridgeTransfer = async (coinObj, channelId, activeUser, ou let gasEst = coinObj.currency_id !== ETH_CONTRACT_ADDRESS ? ethers.BigNumber.from(ERC20_BRIDGE_TRANSFER_GAS_LIMIT) - : transferGas.add(transferGas.div(gasPriceModifier)); + : transferGas.add(transferGas.div(gasFeeModifier)); if (coinObj.currency_id !== ETH_CONTRACT_ADDRESS) { const contract = Web3Provider.getContract(coinObj.currency_id).connect(signer); @@ -374,7 +375,7 @@ export const preflightBridgeTransfer = async (coinObj, channelId, activeUser, ou coinsToUnits(satsToCoins(BigNumber(satoshis)), coinObj.decimals).toString(), { from: fromAddress, gasLimit: INITIAL_GAS_LIMIT, gasPrice: gasPrice }, )) - approvalGasFee = approvalGasFee.add(approvalGasFee.div(gasPriceModifier)); + approvalGasFee = approvalGasFee.add(approvalGasFee.div(gasFeeModifier)); gasEst = gasEst.add(approvalGasFee) } diff --git a/src/utils/constants/web3Constants.js b/src/utils/constants/web3Constants.js index e5aac65c..4db64a16 100644 --- a/src/utils/constants/web3Constants.js +++ b/src/utils/constants/web3Constants.js @@ -24,9 +24,11 @@ export const ETH_VERUS_BRIDGE_DEST_SYSTEM_ID = "0x00000000000000000000000000000 export const MINIMUM_GAS_PRICE_WEI_DELEGATOR_CONTRACT = "3000000000" +export const GAS_PRICE_MODIFIER = "2000000000" + export const MINIMUM_IMPORT_FEE_WEI = "10000000000000000" export const GAS_TRANSACTION_IMPORT_FEE = "1400000" export const INITIAL_GAS_LIMIT = 6000000 export const FALLBACK_GAS_BRIDGE_TRANSFER = 1000000 -export const ERC20_BRIDGE_TRANSFER_GAS_LIMIT = 1000000 \ No newline at end of file +export const ERC20_BRIDGE_TRANSFER_GAS_LIMIT = 750000 \ No newline at end of file