Skip to content

Commit

Permalink
Merge pull request #2507 from CityOfZion/CU-2xx228j
Browse files Browse the repository at this point in the history
CU-2xx228j - Show a message when the dApp wants to override some fees
  • Loading branch information
melanke authored Jul 10, 2023
2 parents 2800340 + f09be36 commit cbf29a5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
28 changes: 15 additions & 13 deletions app/components/DappRequest/InvokeFunction/InvokeFunction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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 = () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]",
"@cityofzion/neon-js-legacy-latest": "npm:@cityofzion/[email protected]",
Expand Down
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "1.5.2"
resolved "https://registry.yarnpkg.com/@cityofzion/neo3-invoker/-/neo3-invoker-1.5.2.tgz#0ebf58f8cd74d3b4977aa4cf0efb1b96548b866f"
integrity sha512-kPT9s1p4MHqTk6hq4uF7duAshOpQTdk3pIsR98MnubERdlERcFEO8Sq76ZG4yrKLr6eFB+YxWrY6xjIlyBcb2A==

"@cityofzion/[email protected]":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@cityofzion/neo3-parser/-/neo3-parser-1.6.0.tgz#154d60baa6e6c541321f0d1fa796b38f6bed6aa3"
Expand Down Expand Up @@ -2216,6 +2221,16 @@
"@cityofzion/neon-js" "5.3.0"
chai "~4.3.7"

"@cityofzion/[email protected]":
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/[email protected]", "@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"
Expand Down

0 comments on commit cbf29a5

Please sign in to comment.