diff --git a/package-lock.json b/package-lock.json index ef0d703..a65cd00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,8 @@ "big.js": "^6.2.1", "chain-registry": "1.33.6", "classnames": "^2.5.1", - "coreum-js": "^2.16.1", + "coreum-js-nightly": "^2.18.1", + "google-protobuf": "^3.21.2", "graz": "^0.1.11", "next": "14.2.2", "pino-pretty": "^11.0.0", @@ -34,6 +35,7 @@ "sharp": "^0.33.3" }, "devDependencies": { + "@types/google-protobuf": "^3.15.12", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", @@ -1642,6 +1644,11 @@ "node": ">=6.9.0" } }, + "node_modules/@bufbuild/protobuf": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.2.3.tgz", + "integrity": "sha512-tFQoXHJdkEOSwj5tRIZSPNUuXK3RaR7T1nUrPgbYX1pUbvqqaaZAsfo+NXBPsz5rZMSKVFrgK1WL8Q/MSLvprg==" + }, "node_modules/@celo/base": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/@celo/base/-/base-3.2.0.tgz", @@ -5056,6 +5063,12 @@ "@types/node": "*" } }, + "node_modules/@types/google-protobuf": { + "version": "3.15.12", + "resolved": "https://registry.npmjs.org/@types/google-protobuf/-/google-protobuf-3.15.12.tgz", + "integrity": "sha512-40um9QqwHjRS92qnOaDpL7RmDK15NuZYo9HihiJRbYkMQZlWnuH8AdvbMy8/o6lgLmKbDUKa+OALCltHdbOTpQ==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -7371,11 +7384,12 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, - "node_modules/coreum-js": { - "version": "2.16.1", - "resolved": "https://registry.npmjs.org/coreum-js/-/coreum-js-2.16.1.tgz", - "integrity": "sha512-sjpS0a4N9DVAEu3GWkYApZIveyg1Vfj0xxN6P0htzbEzENr3fZKXlg1mf8wAi2XUlgPyxmz9ikqgvx/GA0Tl/w==", + "node_modules/coreum-js-nightly": { + "version": "2.18.1", + "resolved": "https://registry.npmjs.org/coreum-js-nightly/-/coreum-js-nightly-2.18.1.tgz", + "integrity": "sha512-r5MRGaN5ETIXQEjQ0ZnbCfPvRsGOsyum2/GdSO4Eo39Bc0esQbrTTsevDfOgk3G7PzUF/2EePQauX0/oA5xAkQ==", "dependencies": { + "@bufbuild/protobuf": "^2.2.3", "@cosmjs/amino": "0.31.1", "@cosmjs/cosmwasm-stargate": "0.31.1", "@cosmjs/crypto": "0.31.1", @@ -7393,7 +7407,7 @@ "ws": "^8.13.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/amino": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/amino": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.31.1.tgz", "integrity": "sha512-kkB9IAkNEUFtjp/uwHv95TgM8VGJ4VWfZwrTyLNqBDD1EpSX2dsNrmUe7k8OMPzKlZUFcKmD4iA0qGvIwzjbGA==", @@ -7404,7 +7418,7 @@ "@cosmjs/utils": "^0.31.1" } }, - "node_modules/coreum-js/node_modules/@cosmjs/cosmwasm-stargate": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/cosmwasm-stargate": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.31.1.tgz", "integrity": "sha512-5hwv4oztFnpqnFaXhYxZc93na3qdxylT2kqms4pLzD8CWMEQmrwhdM4KpZimrsyZK55WiMQtTPsdSh7M8KLOow==", @@ -7422,7 +7436,7 @@ "pako": "^2.0.2" } }, - "node_modules/coreum-js/node_modules/@cosmjs/crypto": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/crypto": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.31.1.tgz", "integrity": "sha512-4R/SqdzdVzd4E5dpyEh1IKm5GbTqwDogutyIyyb1bcOXiX/x3CrvPI9Tb4WSIMDLvlb5TVzu2YnUV51Q1+6mMA==", @@ -7436,7 +7450,7 @@ "libsodium-wrappers-sumo": "^0.7.11" } }, - "node_modules/coreum-js/node_modules/@cosmjs/encoding": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/encoding": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.31.1.tgz", "integrity": "sha512-IuxP6ewwX6vg9sUJ8ocJD92pkerI4lyG8J5ynAM3NaX3q+n+uMoPRSQXNeL9bnlrv01FF1kIm8if/f5F7ZPtkA==", @@ -7446,12 +7460,12 @@ "readonly-date": "^1.0.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/encoding/node_modules/bech32": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/encoding/node_modules/bech32": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" }, - "node_modules/coreum-js/node_modules/@cosmjs/json-rpc": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/json-rpc": { "version": "0.31.3", "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.31.3.tgz", "integrity": "sha512-7LVYerXjnm69qqYR3uA6LGCrBW2EO5/F7lfJxAmY+iII2C7xO3a0vAjMSt5zBBh29PXrJVS6c2qRP22W1Le2Wg==", @@ -7460,7 +7474,7 @@ "xstream": "^11.14.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/math": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/math": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.31.1.tgz", "integrity": "sha512-kiuHV6m6DSB8/4UV1qpFhlc4ul8SgLXTGRlYkYiIIP4l0YNeJ+OpPYaOlEgx4Unk2mW3/O2FWYj7Jc93+BWXng==", @@ -7468,7 +7482,7 @@ "bn.js": "^5.2.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/proto-signing": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/proto-signing": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.31.1.tgz", "integrity": "sha512-hipbBVrssPu+jnmRzQRP5hhS/mbz2nU7RvxG/B1ZcdNhr1AtZC5DN09OTUoEpMSRgyQvScXmk/NTbyf+xmCgYg==", @@ -7482,7 +7496,7 @@ "long": "^4.0.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/socket": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/socket": { "version": "0.31.3", "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.31.3.tgz", "integrity": "sha512-aqrDGGi7os/hsz5p++avI4L0ZushJ+ItnzbqA7C6hamFSCJwgOkXaOUs+K9hXZdX4rhY7rXO4PH9IH8q09JkTw==", @@ -7493,7 +7507,7 @@ "xstream": "^11.14.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/socket/node_modules/ws": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/socket/node_modules/ws": { "version": "7.5.10", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", @@ -7513,7 +7527,7 @@ } } }, - "node_modules/coreum-js/node_modules/@cosmjs/stargate": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/stargate": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.31.1.tgz", "integrity": "sha512-TqOJZYOH5W3sZIjR6949GfjhGXO3kSHQ3/KmE+SuKyMMmQ5fFZ45beawiRtVF0/CJg5RyPFyFGJKhb1Xxv3Lcg==", @@ -7532,7 +7546,7 @@ "xstream": "^11.14.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/stream": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/stream": { "version": "0.31.3", "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.31.3.tgz", "integrity": "sha512-8keYyI7X0RjsLyVcZuBeNjSv5FA4IHwbFKx7H60NHFXszN8/MvXL6aZbNIvxtcIHHsW7K9QSQos26eoEWlAd+w==", @@ -7540,7 +7554,7 @@ "xstream": "^11.14.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/tendermint-rpc": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/tendermint-rpc": { "version": "0.31.1", "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.31.1.tgz", "integrity": "sha512-KX+wwi725sSePqIxfMPPOqg+xTETV8BHGOBhRhCZXEl5Fq48UlXXq3/yG1sn7K67ADC0kqHqcCF41Wn1GxNNPA==", @@ -7557,12 +7571,12 @@ "xstream": "^11.14.0" } }, - "node_modules/coreum-js/node_modules/@cosmjs/utils": { + "node_modules/coreum-js-nightly/node_modules/@cosmjs/utils": { "version": "0.31.3", "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.31.3.tgz", "integrity": "sha512-VBhAgzrrYdIe0O5IbKRqwszbQa7ZyQLx9nEQuHQ3HUplQW7P44COG/ye2n6AzCudtqxmwdX7nyX8ta1J07GoqA==" }, - "node_modules/coreum-js/node_modules/axios": { + "node_modules/coreum-js-nightly/node_modules/axios": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", @@ -7570,7 +7584,7 @@ "follow-redirects": "^1.14.0" } }, - "node_modules/coreum-js/node_modules/cosmjs-types": { + "node_modules/coreum-js-nightly/node_modules/cosmjs-types": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/cosmjs-types/-/cosmjs-types-0.8.0.tgz", "integrity": "sha512-Q2Mj95Fl0PYMWEhA2LuGEIhipF7mQwd9gTQ85DdP9jjjopeoGaDxvmPa5nakNzsq7FnO1DMTatXTAx6bxMH7Lg==", @@ -7579,15 +7593,15 @@ "protobufjs": "~6.11.2" } }, - "node_modules/coreum-js/node_modules/long": { + "node_modules/coreum-js-nightly/node_modules/long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, - "node_modules/coreum-js/node_modules/ws": { - "version": "8.17.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", - "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", + "node_modules/coreum-js-nightly/node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index 852f426..78aa2c2 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "big.js": "^6.2.1", "chain-registry": "1.33.6", "classnames": "^2.5.1", - "coreum-js": "^2.16.1", + "coreum-js-nightly": "^2.18.1", + "google-protobuf": "^3.21.2", "graz": "^0.1.11", "next": "14.2.2", "pino-pretty": "^11.0.0", @@ -34,6 +35,7 @@ "sharp": "^0.33.3" }, "devDependencies": { + "@types/google-protobuf": "^3.15.12", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", diff --git a/public/images/modal/edit-bg.svg b/public/images/modal/edit-bg.svg new file mode 100644 index 0000000..1c9c3c3 --- /dev/null +++ b/public/images/modal/edit-bg.svg @@ -0,0 +1,1628 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/ConfirmationModalImage/index.tsx b/src/assets/ConfirmationModalImage/index.tsx index 33c2cf9..a1b668f 100644 --- a/src/assets/ConfirmationModalImage/index.tsx +++ b/src/assets/ConfirmationModalImage/index.tsx @@ -28,6 +28,8 @@ export const ConfirmationModalImage: FC = ({ return DEXUnifiedRefAmountChange; case ConfirmationModalImageType.DEXWhitelistedDenoms: return DEXWhitelistedDenoms; + case ConfirmationModalImageType.Edit: + return Edit; default: return null } diff --git a/src/assets/GeneralIcon/index.tsx b/src/assets/GeneralIcon/index.tsx index 50dd230..8abce52 100644 --- a/src/assets/GeneralIcon/index.tsx +++ b/src/assets/GeneralIcon/index.tsx @@ -538,6 +538,25 @@ export const GeneralIcon: FC = ({ ); + case GeneralIconType.Edit: + return ( + + + + + ); default: return null; } diff --git a/src/components/ConfirmBurnModal/index.tsx b/src/components/ConfirmBurnModal/index.tsx index 06493a8..d070a17 100644 --- a/src/components/ConfirmBurnModal/index.tsx +++ b/src/components/ConfirmBurnModal/index.tsx @@ -8,7 +8,7 @@ import { setIsConfirmBurnModalOpen, setIsTxExecuting } from "@/features/general/ import { setBurnAmount } from "@/features/burn/burnSlice"; import { convertUnitToSubunit } from "@/helpers/convertUnitToSubunit"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { ModalInfoRow } from "../ModalInfoRow"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; diff --git a/src/components/ConfirmClawbackModal/index.tsx b/src/components/ConfirmClawbackModal/index.tsx index 4809bd8..d81831a 100644 --- a/src/components/ConfirmClawbackModal/index.tsx +++ b/src/components/ConfirmClawbackModal/index.tsx @@ -7,7 +7,7 @@ import { useCallback, useMemo, useState } from "react"; import { setIsConfirmClawbackModalOpen, setIsTxExecuting } from "@/features/general/generalSlice"; import { convertUnitToSubunit } from "@/helpers/convertUnitToSubunit"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { ModalInfoRow } from "../ModalInfoRow"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; diff --git a/src/components/ConfirmEditNFTDataModal/index.tsx b/src/components/ConfirmEditNFTDataModal/index.tsx new file mode 100644 index 0000000..8db4349 --- /dev/null +++ b/src/components/ConfirmEditNFTDataModal/index.tsx @@ -0,0 +1,130 @@ +import { AlertType, ButtonType, ConfirmationModalImageType } from "@/shared/types"; +import { ConfirmationModal } from "../ConfirmationModal"; +import { ConfirmationModalImage } from "@/assets/ConfirmationModalImage"; +import { Button } from "../Button"; +import { useAppDispatch, useAppSelector } from "@/store/hooks"; +import { useCallback, useMemo, useState } from "react"; +import { setIsConfirmEditNFTModalOpen, setIsConfirmNFTDeWhitelistModalOpen, setIsEditNFTModalOpen, setIsTxExecuting, setIsWhitelistNFTModalOpen } from "@/features/general/generalSlice"; +import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; +import { NFT } from "coreum-js-nightly"; +import { dispatchAlert } from "@/features/alerts/alertsSlice"; +import { setSelectedNFTClass, setSelectedNFTSend, setShouldRefetchNFTItems } from "@/features/nft/nftSlice"; +import { DataDynamicIndexedItem, dataEditorFromJSON } from "coreum-js-nightly/dist/main/coreum/asset/nft/v1/types"; +import { convertStringToAny, convertStringToUint8Array } from "@/helpers/convertStringToAny"; + +export const ConfirmEditNFTDataModal = () => { + const isConfirmEditNFTModalOpen = useAppSelector(state => state.general.isConfirmEditNFTModalOpen); + const selectedNFTSend = useAppSelector(state => state.nfts.selectedNFTSend); + const selectedNFTClass = useAppSelector(state => state.nfts.selectedNFTClass); + const account = useAppSelector(state => state.general.account); + const editNFTData = useAppSelector(state => state.nfts.editNFTData); + const isTxExecuting = useAppSelector(state => state.general.isTxExecuting); + + const [isTxSuccessful, setIsTxSuccessful] = useState(false); + + const dispatch = useAppDispatch(); + const { signingClient, getTxFee } = useEstimateTxGasFee(); + + const handleClose = useCallback(() => { + dispatch(setIsConfirmEditNFTModalOpen(false)); + dispatch(setSelectedNFTClass(null)); + dispatch(setSelectedNFTSend(null)); + setIsTxSuccessful(false); + }, []); + + const handleBackClick = useCallback(() => { + dispatch(setIsConfirmEditNFTModalOpen(false)); + dispatch(setIsEditNFTModalOpen(true)); + }, []); + + const handleConfirm = useCallback(async () => { + dispatch(setIsTxExecuting(true)); + + try { + const nftDataValue = convertStringToUint8Array(editNFTData); + const newData = DataDynamicIndexedItem.create({ data: nftDataValue }); + const editNFTDataMsg = NFT.UpdateData({ + sender: account, + classId: selectedNFTClass?.id || '', + id: selectedNFTSend?.id || '', + items: [newData], + }); + + const txFee = await getTxFee([editNFTDataMsg]); + await signingClient?.signAndBroadcast(account, [editNFTDataMsg], txFee ? txFee.fee : 'auto'); + setIsTxSuccessful(true); + dispatch(setShouldRefetchNFTItems(true)); + } catch (error) { + console.log({ error }); + + dispatch(dispatchAlert({ + type: AlertType.Error, + title: 'Update NFT Data Failed', + message: (error as { message: string}).message, + })); + } + + dispatch(setIsTxExecuting(false)); + }, [account, getTxFee, selectedNFTSend, signingClient, selectedNFTClass, editNFTData]); + + const renderContent = useMemo(() => { + if (isTxSuccessful) { + return ( +
+
+ Successfully Updated NFT Data +
+
+
+
+ ); + } + + return ( +
+
+
+ Edit NFT Data +
+
+ This action will immediately update the NFT data and might affect the current owner. Would you like to proceed? +
+
+
+
+
+ ); + }, [handleBackClick, handleClose, handleConfirm, isTxExecuting, isTxSuccessful]); + + return ( + + + {renderContent} + + ); +}; diff --git a/src/components/ConfirmFreezeModal/index.tsx b/src/components/ConfirmFreezeModal/index.tsx index 3ecf2fb..4bfb710 100644 --- a/src/components/ConfirmFreezeModal/index.tsx +++ b/src/components/ConfirmFreezeModal/index.tsx @@ -8,7 +8,7 @@ import { setIsConfirmFreezeModalOpen, setIsTxExecuting } from "@/features/genera import { setFreezeAmount, setFreezeWalletAddress } from "@/features/freeze/freezeSlice"; import { convertUnitToSubunit } from "@/helpers/convertUnitToSubunit"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { ModalInfoRow } from "../ModalInfoRow"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; diff --git a/src/components/ConfirmGlobalFreezeModal/index.tsx b/src/components/ConfirmGlobalFreezeModal/index.tsx index 129adba..45e6c54 100644 --- a/src/components/ConfirmGlobalFreezeModal/index.tsx +++ b/src/components/ConfirmGlobalFreezeModal/index.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmGlobalFreezeModalOpen, setIsTxExecuting } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { shouldRefetchBalances } from "@/features/balances/balancesSlice"; diff --git a/src/components/ConfirmGlobalUnfreezeModal/index.tsx b/src/components/ConfirmGlobalUnfreezeModal/index.tsx index 1c0b8ff..198d763 100644 --- a/src/components/ConfirmGlobalUnfreezeModal/index.tsx +++ b/src/components/ConfirmGlobalUnfreezeModal/index.tsx @@ -5,7 +5,7 @@ import { Button } from "../Button"; import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmGlobalUnfreezeModalOpen, setIsTxExecuting } from "@/features/general/generalSlice"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; diff --git a/src/components/ConfirmMintModal/index.tsx b/src/components/ConfirmMintModal/index.tsx index 2ce92ea..b83ee1a 100644 --- a/src/components/ConfirmMintModal/index.tsx +++ b/src/components/ConfirmMintModal/index.tsx @@ -7,7 +7,7 @@ import { useCallback, useMemo, useState } from "react"; import { setIsConfirmMintModalOpen, setIsTxExecuting } from "@/features/general/generalSlice"; import { setMintAmount } from "@/features/mint/mintSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { convertUnitToSubunit } from "@/helpers/convertUnitToSubunit"; import { ModalInfoRow } from "../ModalInfoRow"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; diff --git a/src/components/ConfirmNFTBurnModal/index.tsx b/src/components/ConfirmNFTBurnModal/index.tsx index 57323df..e4544b3 100644 --- a/src/components/ConfirmNFTBurnModal/index.tsx +++ b/src/components/ConfirmNFTBurnModal/index.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsBurnNFTModalOpen, setIsConfirmNFTBurnModalOpen, setIsTxExecuting } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { NFT } from "coreum-js"; +import { NFT } from "coreum-js-nightly"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { NFTItem } from "../NFTItem"; import { setSelectedNFTClass, setSelectedNFTSend, setShouldRefetchNFTItems } from "@/features/nft/nftSlice"; diff --git a/src/components/ConfirmNFTDeWhitelistModal/index.tsx b/src/components/ConfirmNFTDeWhitelistModal/index.tsx index d770e8c..c705983 100644 --- a/src/components/ConfirmNFTDeWhitelistModal/index.tsx +++ b/src/components/ConfirmNFTDeWhitelistModal/index.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmNFTDeWhitelistModalOpen, setIsTxExecuting, setIsWhitelistNFTModalOpen } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { NFT } from "coreum-js"; +import { NFT } from "coreum-js-nightly"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { NFTItem } from "../NFTItem"; import { setSelectedNFTClass, setSelectedNFTSend, setShouldRefetchNFTItems } from "@/features/nft/nftSlice"; diff --git a/src/components/ConfirmNFTFreezeModal/index.tsx b/src/components/ConfirmNFTFreezeModal/index.tsx index ed12994..0d3fffb 100644 --- a/src/components/ConfirmNFTFreezeModal/index.tsx +++ b/src/components/ConfirmNFTFreezeModal/index.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmNFTFreezeModalOpen, setIsFreezeNFTModalOpen, setIsTxExecuting } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { NFT } from "coreum-js"; +import { NFT } from "coreum-js-nightly"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { NFTItem } from "../NFTItem"; import { setSelectedNFTClass, setSelectedNFTSend, setShouldRefetchNFTItems } from "@/features/nft/nftSlice"; diff --git a/src/components/ConfirmNFTMintModal/index.tsx b/src/components/ConfirmNFTMintModal/index.tsx index 2a0b7b2..2d4d28f 100644 --- a/src/components/ConfirmNFTMintModal/index.tsx +++ b/src/components/ConfirmNFTMintModal/index.tsx @@ -6,11 +6,14 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmNFTMintModalOpen, setIsTxExecuting } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { NFT, convertStringToAny } from "coreum-js"; +import { NFT } from "coreum-js-nightly"; import { ModalInfoRow } from "../ModalInfoRow"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { setNFTData, setNFTID, setNFTRecipient, setNFTURI, setNFTURIHash, setSelectedNFTClass, setShouldRefetchNFTItems } from "@/features/nft/nftSlice"; import { shortenAddress } from "@/helpers/shortenAddress"; +import { convertStringToAny, convertStringToDataDynamic, convertStringToUint8Array } from "@/helpers/convertStringToAny"; +import { DataDynamic, DataDynamicItem } from "coreum-js-nightly/dist/main/coreum/asset/nft/v1/types"; +import { Any } from "google-protobuf/google/protobuf/any_pb"; export const ConfirmNFTMintModal = () => { const isConfirmNFTMintModalOpen = useAppSelector(state => state.general.isConfirmNFTMintModalOpen); @@ -43,18 +46,29 @@ export const ConfirmNFTMintModal = () => { const handleConfirm = useCallback(async () => { dispatch(setIsTxExecuting(true)); try { - const nftDataValue = convertStringToAny(nftData); - const nftMintObj = { + const newData = convertStringToDataDynamic([{ editors: [0, 1], data: btoa(nftData) }]); + let mintNFTMsg = NFT.Mint({ sender: account, classId: selectedCollection?.id || '', id: nftId, uri: nftURI, uriHash: nftURIHash, recipient: nftRecipient, - data: nftDataValue, - }; + data: newData as any, + }); - const mintNFTMsg = NFT.Mint(nftMintObj); + if (nftData.length && newData && (newData as any).array.length) { + mintNFTMsg = { + ...mintNFTMsg, + value: { + ...mintNFTMsg.value, + data: { + typeUrl: (newData as any)?.array[0], + value: (newData as any)?.array[1], + } as any, + } + }; + } const txFee = await getTxFee([mintNFTMsg]); await signingClient?.signAndBroadcast(account, [mintNFTMsg], txFee ? txFee.fee : 'auto'); @@ -197,3 +211,8 @@ export const ConfirmNFTMintModal = () => { ); }; + + + + +// Data for Mint NFT diff --git a/src/components/ConfirmNFTUnfreezeModal/index.tsx b/src/components/ConfirmNFTUnfreezeModal/index.tsx index 72ee1a8..56666a8 100644 --- a/src/components/ConfirmNFTUnfreezeModal/index.tsx +++ b/src/components/ConfirmNFTUnfreezeModal/index.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmNFTUnfreezeModalOpen, setIsTxExecuting, setIsUnfreezeNFTModalOpen } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { NFT } from "coreum-js"; +import { NFT } from "coreum-js-nightly"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { NFTItem } from "../NFTItem"; import { setSelectedNFTClass, setSelectedNFTSend, setShouldRefetchNFTItems } from "@/features/nft/nftSlice"; diff --git a/src/components/ConfirmNFTWhitelistModal/index.tsx b/src/components/ConfirmNFTWhitelistModal/index.tsx index 8e40bb3..f46cda2 100644 --- a/src/components/ConfirmNFTWhitelistModal/index.tsx +++ b/src/components/ConfirmNFTWhitelistModal/index.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmNFTWhitelistModalOpen, setIsTxExecuting, setIsWhitelistNFTModalOpen } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { NFT } from "coreum-js"; +import { NFT } from "coreum-js-nightly"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { NFTItem } from "../NFTItem"; import { setSelectedNFTClass, setSelectedNFTSend, setShouldRefetchNFTItems } from "@/features/nft/nftSlice"; diff --git a/src/components/ConfirmUnfreezeModal/index.tsx b/src/components/ConfirmUnfreezeModal/index.tsx index d169b2d..b6ba22d 100644 --- a/src/components/ConfirmUnfreezeModal/index.tsx +++ b/src/components/ConfirmUnfreezeModal/index.tsx @@ -8,7 +8,7 @@ import { setIsConfirmUnfreezeModalOpen, setIsTxExecuting } from "@/features/gene import { setUnfreezeAmount, setUnfreezeWalletAddress } from "@/features/unfreeze/unfreezeSlice"; import { convertUnitToSubunit } from "@/helpers/convertUnitToSubunit"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { ModalInfoRow } from "../ModalInfoRow"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; diff --git a/src/components/ConfirmUpdateUnifiedRefAmountModal/index.tsx b/src/components/ConfirmUpdateUnifiedRefAmountModal/index.tsx index 3a4d4c0..04c4fbc 100644 --- a/src/components/ConfirmUpdateUnifiedRefAmountModal/index.tsx +++ b/src/components/ConfirmUpdateUnifiedRefAmountModal/index.tsx @@ -12,7 +12,7 @@ import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { Decimal } from "../Decimal"; import { shouldRefetchBalances } from "@/features/balances/balancesSlice"; import { setDexRefAmount } from "@/features/dex/dexSlice"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; export const ConfirmUpdateDexUnifiedRefAmountModal = () => { const isConfirmUpdateDexUnifiedRefAmountOpen = useAppSelector(state => state.general.isConfirmUpdateDexUnifiedRefAmountOpen); diff --git a/src/components/ConfirmUpdateWhitelistedDenomsModal/index.tsx b/src/components/ConfirmUpdateWhitelistedDenomsModal/index.tsx index 0172cba..a82951c 100644 --- a/src/components/ConfirmUpdateWhitelistedDenomsModal/index.tsx +++ b/src/components/ConfirmUpdateWhitelistedDenomsModal/index.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "@/store/hooks"; import { useCallback, useMemo, useState } from "react"; import { setIsConfirmUpdateDexWhitelistedDenomsOpen, setIsTxExecuting } from "@/features/general/generalSlice"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; import { shouldRefetchBalances } from "@/features/balances/balancesSlice"; diff --git a/src/components/ConfirmWhitelistModal/index.tsx b/src/components/ConfirmWhitelistModal/index.tsx index daca462..f9157f0 100644 --- a/src/components/ConfirmWhitelistModal/index.tsx +++ b/src/components/ConfirmWhitelistModal/index.tsx @@ -8,7 +8,7 @@ import { setIsConfirmWhitelistModalOpen, setIsTxExecuting } from "@/features/gen import { setWhitelistAmount, setWhitelistWalletAddress } from "@/features/whitelist/whitelistSlice"; import { convertUnitToSubunit } from "@/helpers/convertUnitToSubunit"; import { useEstimateTxGasFee } from "@/hooks/useEstimateTxGasFee"; -import { FT } from "coreum-js"; +import { FT } from "coreum-js-nightly"; import { setSelectedCurrency, shouldRefetchCurrencies } from "@/features/currencies/currenciesSlice"; import { ModalInfoRow } from "../ModalInfoRow"; import { dispatchAlert } from "@/features/alerts/alertsSlice"; diff --git a/src/components/EditNFTModal/index.tsx b/src/components/EditNFTModal/index.tsx new file mode 100644 index 0000000..8ea3b97 --- /dev/null +++ b/src/components/EditNFTModal/index.tsx @@ -0,0 +1,138 @@ +import { setIsConfirmEditNFTModalOpen, setIsConfirmNFTDeWhitelistModalOpen, setIsDeWhitelistNFTModalOpen, setIsEditNFTModalOpen, setIsNFTCollectionViewModalOpen } from "@/features/general/generalSlice"; +import { useAppDispatch, useAppSelector } from "@/store/hooks"; +import { useCallback, useMemo, useState } from "react"; +import { Modal } from "../Modal"; +import { Button } from "../Button"; +import { ButtonType, ChainInfo } from "@/shared/types"; +import { NFTItem } from "../NFTItem"; +import { Input } from "../Input"; +import { pasteValueFromClipboard } from "@/helpers/pasteValueFromClipboard"; +import { validateAddress } from "@/helpers/validateAddress"; +import { setDeWhitelistAccount, setEditNFTData } from "@/features/nft/nftSlice"; +import { FileUpload } from "../FileUpload"; +import { TextArea } from "../TextArea"; +import classNames from "classnames"; + +export const EditNFTModal = () => { + const isEditNFTModalOpen = useAppSelector(state => state.general.isEditNFTModalOpen); + const selectedNFTSend = useAppSelector(state => state.nfts.selectedNFTSend); + const selectedNFTClass = useAppSelector(state => state.nfts.selectedNFTClass); + const chains = useAppSelector(state => state.chains.list); + + const [data, setData] = useState(''); + const [fileContent, setFileContent] = useState(''); + + const coreumChain = useMemo(() => { + return chains.find((chain: ChainInfo) => chain.pretty_name.toLowerCase() === 'coreum'); + }, [chains]); + + const dispatch = useAppDispatch(); + + const handleCloseModal = useCallback(() => { + dispatch(setIsEditNFTModalOpen(false)); + setData(''); + }, []); + + const handleOnClickBackButton = useCallback(() => { + dispatch(setIsEditNFTModalOpen(false)); + dispatch(setIsNFTCollectionViewModalOpen(true)); + setData(''); + }, []); + + const handleConfirmEditNFTToken = useCallback(() => { + dispatch(setIsConfirmEditNFTModalOpen(true)); + dispatch(setIsEditNFTModalOpen(false)); + dispatch(setEditNFTData(fileContent.length ? fileContent : data)); + setData(''); + }, [data, fileContent]); + + const isFormValid = useMemo(() => { + if (selectedNFTSend && (!!data.length || !!fileContent.length)) { + return true; + } + + return false; + }, [selectedNFTSend, data.length, fileContent.length]); + + return ( + +
+
+
+

+ Name +

+
+

+ {selectedNFTSend?.name || ''} +

+
+
+
+

+ URI +

+
+

+ {`${selectedNFTSend?.uri || ''}${selectedNFTSend?.uri_hash || ''}`} +

+
+
+
+
+ +
+ +
+
+ Or +
+
+