From f09be36756566e5f467b49dcd3e83f163fbf4027 Mon Sep 17 00:00:00 2001 From: Raul Duarte Pereira Date: Fri, 7 Jul 2023 12:19:27 -0300 Subject: [PATCH] CU-2xx228j - Show a message when the dApp wants to override some fees --- .../InvokeFunction/InvokeFunction.jsx | 28 ++++++++++--------- package.json | 2 +- yarn.lock | 15 ++++++++++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/components/DappRequest/InvokeFunction/InvokeFunction.jsx b/app/components/DappRequest/InvokeFunction/InvokeFunction.jsx index 923c390db..9916b92ce 100644 --- a/app/components/DappRequest/InvokeFunction/InvokeFunction.jsx +++ b/app/components/DappRequest/InvokeFunction/InvokeFunction.jsx @@ -23,7 +23,6 @@ import Deny from '../../../assets/icons/deny_connection.svg' import Tooltip from '../../Tooltip' import Info from '../../../assets/icons/info.svg' -import { convertToArbitraryDecimals } from '../../../core/formatters' import { getNode, getRPCEndpoint } from '../../../actions/nodeStorageActions' import Invocation from './Invocation' import InvokeResult from './InvokeResult' @@ -37,7 +36,7 @@ type Props = { publicKey: string, history: any, showSuccessNotification({ message: string }): any, - showInfoNotification({ message: string, autoDismiss: number }): any, + showInfoNotification({ message: string, autoDismiss?: number }): any, hideNotification(id: string): any, theme: string, net: string, @@ -67,6 +66,18 @@ const InvokeFunction = ({ async () => { try { setLoading(true) + + if ( + requestParams.extraNetworkFee || + requestParams.extraSystemFee || + requestParams.networkFeeOverride || + requestParams.systemFeeOverride + ) { + showInfoNotification({ + message: 'The dApp has overwritten the fees', + }) + } + const account = new n3Wallet.Account(publicKey) let rpcAddress = await getNode(net) if (!rpcAddress) { @@ -76,21 +87,12 @@ const InvokeFunction = ({ const invoker = await NeonInvoker.init({ rpcAddress, account }) const { total } = await invoker.calculateFee(requestParams) - const extraNetworkFee = convertToArbitraryDecimals( - requestParams.extraNetworkFee ?? 0, - 8, - ) - const extraSystemFee = convertToArbitraryDecimals( - requestParams.extraSystemFee ?? 0, - 8, - ) - - setFee(total + Number(extraNetworkFee) + Number(extraSystemFee)) + setFee(total) } finally { setLoading(false) } }, - [publicKey, net, requestParams], + [publicKey, net, requestParams, showInfoNotification], ) const reject = () => { diff --git a/package.json b/package.json index d85b35853..e72368e20 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "@cityofzion/bs-neo-legacy": "0.3.0", "@cityofzion/bs-neo3": "0.3.0", "@cityofzion/dora-ts": "^0.0.9", - "@cityofzion/neon-invoker": "1.5.1", + "@cityofzion/neon-invoker": "1.5.2", "@cityofzion/neon-js": "5.3.0", "@cityofzion/neon-js-legacy": "npm:@cityofzion/neon-js@3.11.9", "@cityofzion/neon-js-legacy-latest": "npm:@cityofzion/neon-js@4.9.0", diff --git a/yarn.lock b/yarn.lock index ac58d0613..ab998f701 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2107,6 +2107,11 @@ resolved "https://registry.yarnpkg.com/@cityofzion/neo3-invoker/-/neo3-invoker-1.5.1.tgz#13a0f448aac13afa305a806a724fd0a4764915f0" integrity sha512-P1w9Ajxa3S5lT+cvsjF/ZDpZFuvvg3e/bVC87PBbpD+FysVFsONlZCIomevkSV4LnzCgrxDQ00KzmYOiNHvWcg== +"@cityofzion/neo3-invoker@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@cityofzion/neo3-invoker/-/neo3-invoker-1.5.2.tgz#0ebf58f8cd74d3b4977aa4cf0efb1b96548b866f" + integrity sha512-kPT9s1p4MHqTk6hq4uF7duAshOpQTdk3pIsR98MnubERdlERcFEO8Sq76ZG4yrKLr6eFB+YxWrY6xjIlyBcb2A== + "@cityofzion/neo3-parser@1.6.0": version "1.6.0" resolved "https://registry.yarnpkg.com/@cityofzion/neo3-parser/-/neo3-parser-1.6.0.tgz#154d60baa6e6c541321f0d1fa796b38f6bed6aa3" @@ -2216,6 +2221,16 @@ "@cityofzion/neon-js" "5.3.0" chai "~4.3.7" +"@cityofzion/neon-invoker@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@cityofzion/neon-invoker/-/neon-invoker-1.5.2.tgz#9188985659df1998d0138c6be8f36c04d76cb759" + integrity sha512-rW0Z8vaLE5RvUyOfNBJTSlVJ+MyYWiz+/1fx8d5I3/cxJVNXAKIyS0Igs9T3eUH219rodhXjd/515uygdVseZA== + dependencies: + "@cityofzion/neo3-invoker" "1.5.2" + "@cityofzion/neon-core" "5.3.0" + "@cityofzion/neon-js" "5.3.0" + chai "~4.3.7" + "@cityofzion/neon-js-legacy-latest@npm:@cityofzion/neon-js@4.9.0", "@cityofzion/neon-js@^4.7.1", "@cityofzion/neon-js@^4.8.3": version "4.9.0" resolved "https://registry.yarnpkg.com/@cityofzion/neon-js/-/neon-js-4.9.0.tgz#39f46720cff76f807128d5882832a3d722d9fd25"