From b08bba5e7e6deb34823310e3d3dae6f58e5a97a8 Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Wed, 7 Aug 2024 22:00:07 -0300 Subject: [PATCH 1/3] feat: improve UI/UX for nano state detail and tx data with new custom types --- src/components/TxData.js | 15 ++++++++++--- src/screens/nano/NanoContractDetail.js | 30 ++++++++++++++++++++------ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/components/TxData.js b/src/components/TxData.js index f6c7c33c..f9422cc8 100644 --- a/src/components/TxData.js +++ b/src/components/TxData.js @@ -106,8 +106,8 @@ class TxData extends React.Component { const network = hathorLib.config.getNetwork(); const ncData = this.props.transaction; - const deserializer = new hathorLib.NanoContractTransactionParser(ncData.nc_blueprint_id, ncData.nc_method, ncData.nc_pubkey, ncData.nc_args); - deserializer.parseAddress(network); + const deserializer = new hathorLib.NanoContractTransactionParser(ncData.nc_blueprint_id, ncData.nc_method, ncData.nc_pubkey, network, ncData.nc_args); + deserializer.parseAddress(); await deserializer.parseArguments(); this.setState({ ncDeserializer: deserializer, ncLoading: false }); } @@ -952,10 +952,19 @@ class TxData extends React.Component { } const renderArgValue = (arg) => { - if (arg.type === 'bytes') { + const typeBytesOrigin = ['bytes', 'TxOutputScript', 'TokenUid', 'VertexId']; + if (typeBytesOrigin.includes(arg.type)) { return arg.parsed.toString('hex'); } + if (arg.type === 'Timestamp') { + return hathorLib.dateFormatter.parseTimestamp(arg.parsed); + } + + if (arg.type === 'Amount') { + return numberUtils.prettyValue(arg.parsed, this.props.decimalPlaces); + } + return arg.parsed; } diff --git a/src/screens/nano/NanoContractDetail.js b/src/screens/nano/NanoContractDetail.js index b59d9c22..9a23b544 100644 --- a/src/screens/nano/NanoContractDetail.js +++ b/src/screens/nano/NanoContractDetail.js @@ -32,7 +32,12 @@ function NanoContractDetail() { const context = useContext(GlobalModalContext); const wallet = getGlobalWallet(); - const { nanoContracts, blueprintsData, tokenMetadata, decimalPlaces } = useSelector((state) => { + const { + nanoContracts, + blueprintsData, + tokenMetadata, + decimalPlaces, + } = useSelector((state) => { return { nanoContracts: state.nanoContracts, blueprintsData: state.blueprintsData, @@ -170,12 +175,23 @@ function NanoContractDetail() { return get(blueprintInformation.attributes, field); } - // Some fields should be better parsed, e.g., timestamp, address - // however we don't have a simple and generic way to knowing it - // this was discussed and we will have this in the future, so - // for now we keep this UI and when we have this feature in the - // hathor-core, we can improve the user UI - return value === null ? ' - ' : value; + if (value == null) { + // If value is null or undefined, we show empty string + return null; + } + + // Get type of value but removing possible optional mark (?) to format the value correctly + const type = blueprintInformation.attributes[field].replace('?', ''); + + if (type === 'Timestamp') { + return hathorLib.dateUtils.parseTimestamp(value); + } + + if (type === 'Amount') { + return hathorLib.numberUtils.prettyValue(value, decimalPlaces); + } + + return value; } /** From b5d3e074ea5879ccc9560083167ffd74633ea950 Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Mon, 26 Aug 2024 09:59:15 -0300 Subject: [PATCH 2/3] chore: bump wallet lib to v1.10.0 --- package-lock.json | 19 ++++++++++--------- package.json | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 596d628a..acf2691a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,10 +6,10 @@ "packages": { "": { "name": "hathor-wallet", - "version": "0.29.0-rc.2", + "version": "0.29.0", "hasInstallScript": true, "dependencies": { - "@hathor/wallet-lib": "1.8.0", + "@hathor/wallet-lib": "1.10.0", "@ledgerhq/hw-transport-node-hid": "6.28.1", "@reduxjs/toolkit": "2.2.3", "@sentry/electron": "3.0.7", @@ -2598,10 +2598,11 @@ } }, "node_modules/@hathor/wallet-lib": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@hathor/wallet-lib/-/wallet-lib-1.8.0.tgz", - "integrity": "sha512-G1kLlxZ4Ev3S7hPiq/y9wUl4ns4pndOvuK37q+xqdxieZKCl2/O7lXiiHVOgRN9xOntL/TR66n2UZPpe0p29zQ==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@hathor/wallet-lib/-/wallet-lib-1.10.0.tgz", + "integrity": "sha512-oxQoxnwZNDrgjnvblx0ipVOxMNeM8W2PJkQpyzZJyl1QpRyhqHqqyYD0iSn1bhQEq8C1IRoSrvjsd3Af5eHdWQ==", "dependencies": { + "abstract-level": "1.0.4", "axios": "1.7.2", "bitcore-lib": "8.25.10", "bitcore-mnemonic": "8.25.10", @@ -2611,7 +2612,7 @@ "level": "8.0.1", "lodash": "4.17.21", "long": "5.2.3", - "ws": "8.17.0" + "ws": "8.17.1" }, "engines": { "node": ">=20.0.0", @@ -2619,9 +2620,9 @@ } }, "node_modules/@hathor/wallet-lib/node_modules/ws": { - "version": "8.17.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", - "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index fd1a11e2..2f741f00 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "private": true, "dependencies": { - "@hathor/wallet-lib": "1.8.0", + "@hathor/wallet-lib": "1.10.0", "@ledgerhq/hw-transport-node-hid": "6.28.1", "@reduxjs/toolkit": "2.2.3", "@sentry/electron": "3.0.7", From 688697ffdc562fc49cb18fe87a79831f10a9d5a5 Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Mon, 26 Aug 2024 12:18:16 -0300 Subject: [PATCH 3/3] feat: add contract id --- src/components/TxData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TxData.js b/src/components/TxData.js index f9422cc8..4f5f9ebf 100644 --- a/src/components/TxData.js +++ b/src/components/TxData.js @@ -952,7 +952,7 @@ class TxData extends React.Component { } const renderArgValue = (arg) => { - const typeBytesOrigin = ['bytes', 'TxOutputScript', 'TokenUid', 'VertexId']; + const typeBytesOrigin = ['bytes', 'TxOutputScript', 'TokenUid', 'VertexId', 'ContractId']; if (typeBytesOrigin.includes(arg.type)) { return arg.parsed.toString('hex'); }