From c55ee03d39ee99ed8e4c5be2f69c48dcf464976c Mon Sep 17 00:00:00 2001 From: Jarryd Allison Date: Mon, 3 Apr 2023 13:06:17 -0600 Subject: [PATCH 1/2] Updates to wcjs 3.0.0 --- CHANGELOG.md | 1 + package-lock.json | 89 +------------ package.json | 2 +- src/App.js | 2 +- src/Components/UserAccount/UserAccount.tsx | 13 +- src/redux/features/asset/assetSlice.ts | 148 ++++++++------------- src/redux/hooks/useProposal.tsx | 17 +-- src/redux/hooks/useStaking.tsx | 6 +- src/redux/hooks/useVoting.tsx | 6 +- src/utils/cookie/getCookie.js | 1 - src/utils/number/currencyFormat.tsx | 6 +- 11 files changed, 86 insertions(+), 205 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2107891f..1eee940b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Update hash icon #487 - Replace hash icons #489 - Update validator metrics #494 +- Update to wcjs 3.0.0 #499 ## 3.5.0 diff --git a/package-lock.json b/package-lock.json index 125ece6c..9aeb206d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@provenanceio/wallet-utils": "2.6.0", - "@provenanceio/walletconnect-js": "2.1.1", + "@provenanceio/walletconnect-js": "3.0.0", "@reduxjs/toolkit": "1.8.1", "bech32": "2.0.0", "big.js": "6.1.1", @@ -3645,9 +3645,9 @@ } }, "node_modules/@provenanceio/walletconnect-js": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-2.1.1.tgz", - "integrity": "sha512-q7W3FUlP7G+EGDMehw5vney92SY2Er9bKAXmKCs7fOZzjMrkNbrW1V9XmQePv9vVXFFXQVl9osC81MzufWZPbA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-3.0.0.tgz", + "integrity": "sha512-eWQWm36lX8hfUoT8TaUMZi3kvu57ITg8Y7FRIF8JRxfBVJ80ZDXgNAGXwzIev7Sq+jkq0W0dszy0dpYWdaFkYw==", "dependencies": { "@babel/runtime": "7.19.0", "@walletconnect/client": "1.8.0", @@ -3659,23 +3659,9 @@ "qrcode": "1.5.1", "secp256k1": "4.0.3", "stream": "npm:stream-browserify@3.0.0", - "styled-components": "^5.3.6", "util": "npm:util@0.12.5" } }, - "node_modules/@provenanceio/walletconnect-js/node_modules/@emotion/is-prop-valid": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.0.tgz", - "integrity": "sha512-3aDpDprjM0AwaxGE09bOPkNxHpBd+kA6jty3RnaEXdweX1DF1U3VQpPYb0g1IStAuK7SVQ1cy+bNBBKp4W3Fjg==", - "dependencies": { - "@emotion/memoize": "^0.8.0" - } - }, - "node_modules/@provenanceio/walletconnect-js/node_modules/@emotion/memoize": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.0.tgz", - "integrity": "sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==" - }, "node_modules/@provenanceio/walletconnect-js/node_modules/bip32": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bip32/-/bip32-3.1.0.tgz", @@ -3692,36 +3678,6 @@ "node": ">=6.0.0" } }, - "node_modules/@provenanceio/walletconnect-js/node_modules/styled-components": { - "version": "5.3.6", - "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-5.3.6.tgz", - "integrity": "sha512-hGTZquGAaTqhGWldX7hhfzjnIYBZ0IXQXkCYdvF1Sq3DsUaLx6+NTHC5Jj1ooM2F68sBiVz3lvhfwQs/S3l6qg==", - "hasInstallScript": true, - "dependencies": { - "@babel/helper-module-imports": "^7.0.0", - "@babel/traverse": "^7.4.5", - "@emotion/is-prop-valid": "^1.1.0", - "@emotion/stylis": "^0.8.4", - "@emotion/unitless": "^0.7.4", - "babel-plugin-styled-components": ">= 1.12.0", - "css-to-react-native": "^3.0.0", - "hoist-non-react-statics": "^3.0.0", - "shallowequal": "^1.1.0", - "supports-color": "^5.5.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/styled-components" - }, - "peerDependencies": { - "react": ">= 16.8.0", - "react-dom": ">= 16.8.0", - "react-is": ">= 16.8.0" - } - }, "node_modules/@reduxjs/toolkit": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.8.1.tgz", @@ -34447,9 +34403,9 @@ } }, "@provenanceio/walletconnect-js": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-2.1.1.tgz", - "integrity": "sha512-q7W3FUlP7G+EGDMehw5vney92SY2Er9bKAXmKCs7fOZzjMrkNbrW1V9XmQePv9vVXFFXQVl9osC81MzufWZPbA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-3.0.0.tgz", + "integrity": "sha512-eWQWm36lX8hfUoT8TaUMZi3kvu57ITg8Y7FRIF8JRxfBVJ80ZDXgNAGXwzIev7Sq+jkq0W0dszy0dpYWdaFkYw==", "requires": { "@babel/runtime": "7.19.0", "@walletconnect/client": "1.8.0", @@ -34461,23 +34417,9 @@ "qrcode": "1.5.1", "secp256k1": "4.0.3", "stream": "npm:stream-browserify@3.0.0", - "styled-components": "^5.3.6", "util": "npm:util@0.12.5" }, "dependencies": { - "@emotion/is-prop-valid": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.0.tgz", - "integrity": "sha512-3aDpDprjM0AwaxGE09bOPkNxHpBd+kA6jty3RnaEXdweX1DF1U3VQpPYb0g1IStAuK7SVQ1cy+bNBBKp4W3Fjg==", - "requires": { - "@emotion/memoize": "^0.8.0" - } - }, - "@emotion/memoize": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.0.tgz", - "integrity": "sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==" - }, "bip32": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bip32/-/bip32-3.1.0.tgz", @@ -34490,23 +34432,6 @@ "typeforce": "^1.11.5", "wif": "^2.0.6" } - }, - "styled-components": { - "version": "5.3.6", - "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-5.3.6.tgz", - "integrity": "sha512-hGTZquGAaTqhGWldX7hhfzjnIYBZ0IXQXkCYdvF1Sq3DsUaLx6+NTHC5Jj1ooM2F68sBiVz3lvhfwQs/S3l6qg==", - "requires": { - "@babel/helper-module-imports": "^7.0.0", - "@babel/traverse": "^7.4.5", - "@emotion/is-prop-valid": "^1.1.0", - "@emotion/stylis": "^0.8.4", - "@emotion/unitless": "^0.7.4", - "babel-plugin-styled-components": ">= 1.12.0", - "css-to-react-native": "^3.0.0", - "hoist-non-react-statics": "^3.0.0", - "shallowequal": "^1.1.0", - "supports-color": "^5.5.0" - } } } }, diff --git a/package.json b/package.json index 1481e0d8..139238be 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "sideEffects": false, "dependencies": { "@provenanceio/wallet-utils": "2.6.0", - "@provenanceio/walletconnect-js": "2.1.1", + "@provenanceio/walletconnect-js": "3.0.0", "@reduxjs/toolkit": "1.8.1", "bech32": "2.0.0", "big.js": "6.1.1", diff --git a/src/App.js b/src/App.js index c6f60f2b..8a306e3c 100644 --- a/src/App.js +++ b/src/App.js @@ -99,7 +99,7 @@ const App = () => { - + diff --git a/src/Components/UserAccount/UserAccount.tsx b/src/Components/UserAccount/UserAccount.tsx index b24eab1e..67b11c04 100644 --- a/src/Components/UserAccount/UserAccount.tsx +++ b/src/Components/UserAccount/UserAccount.tsx @@ -59,7 +59,7 @@ const Link = styled(BaseLink)` const UserAccount = ({ isMobile }: { isMobile: boolean }) => { const { isLoggedIn, setWalletUrl, setIsLoggedIn } = useApp(); const { walletConnectService: wcs, walletConnectState } = useWalletConnect(); - const { connected, address } = walletConnectState; + const { status, address } = walletConnectState; const theme = useTheme(); const position = isMobile ? 'above' : 'left'; const [visible, setVisible] = useState(false); @@ -69,8 +69,8 @@ const UserAccount = ({ isMobile }: { isMobile: boolean }) => { useOnEscape(deactivateShowPopup); useEffect(() => { - setIsLoggedIn(connected); - }, [connected, setIsLoggedIn]); + setIsLoggedIn(status === 'connected'); + }, [status, setIsLoggedIn]); const handleLogout = () => { setWalletUrl(''); @@ -119,13 +119,14 @@ const UserAccount = ({ isMobile }: { isMobile: boolean }) => { title="Scan the QRCode with your mobile Provenance Blockchain Wallet." className="QR-Code-Modal" devWallets={[ - 'figure_web', - 'figure_web_test', 'figure_mobile_test', + 'figure_hosted_test', + // @ts-ignore 'provenance_extension', + // @ts-ignore 'provenance_mobile', ]} - hideWallets={isProd ? ['figure_web_test', 'figure_mobile_test'] : ['figure_web']} + hideWallets={isProd ? ['figure_hosted_test'] : ['figure_hosted']} /> ); diff --git a/src/redux/features/asset/assetSlice.ts b/src/redux/features/asset/assetSlice.ts index 299134e1..5fb23991 100644 --- a/src/redux/features/asset/assetSlice.ts +++ b/src/redux/features/asset/assetSlice.ts @@ -1,19 +1,14 @@ -import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; +import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'; import qs from 'query-string'; -import { RootState } from "redux/app/store"; -import { - ASSET_DETAIL_URL, - ASSETS_LIST_URL, - TX_INFO_URL, - ASSETS_DIST_URL -} from "consts"; +import { RootState } from 'redux/app/store'; +import { ASSET_DETAIL_URL, ASSETS_LIST_URL, TX_INFO_URL, ASSETS_DIST_URL } from 'consts'; import { formatDenom, setCookie } from 'utils'; -import { ajax } from "../api"; +import { ajax } from '../api'; interface AssetInfo { attributes?: { - attribute: string; - data: string; + attribute: string; + data: string; }[]; holderCount?: number; holdingAccount?: string; @@ -51,7 +46,7 @@ interface AssetInfo { nonFungibleCount: number; }; txnCount?: number; -}; +} export interface TransactionsModule { pages: number; @@ -73,12 +68,12 @@ export interface TransactionsModule { signers: { signers: string[]; threshold: number | null; - }, + }; status?: string; feepayer?: { type: string; address: string; - } + }; }[]; total: number; rollupTotals?: { @@ -87,7 +82,7 @@ export interface TransactionsModule { denom: string; }; }; -}; +} interface AssetHolders { pages: number; @@ -106,7 +101,7 @@ interface AssetHolders { }; }; total: number; -}; +} interface AllAssets { pages: number; @@ -137,7 +132,7 @@ interface AllAssets { }; }; total: number; -}; +} interface AssetMetadata { description: string; @@ -149,7 +144,7 @@ interface AssetMetadata { display: string; name: string; symbol: string; -}; +} interface AssetDist { amount: { @@ -160,7 +155,7 @@ interface AssetDist { percentTotal?: string; percent: string; range: string; -}; +} interface AssetState { // Asset Information @@ -169,19 +164,19 @@ interface AssetState { totalBalancePrice: string; assetInfoLoading: boolean; // Asset Transactions (Admin) - assetAdminTransactions: TransactionsModule["results"]; + assetAdminTransactions: TransactionsModule['results']; assetAdminTransactionsLoading: boolean; - assetAdminTransactionsPages: TransactionsModule["pages"]; + assetAdminTransactionsPages: TransactionsModule['pages']; // Asset Transactions (Transfer) - assetTransferTransactions: TransactionsModule["results"]; + assetTransferTransactions: TransactionsModule['results']; assetTransferTransactionsLoading: boolean; - assetTransferTransactionsPages: TransactionsModule["pages"]; + assetTransferTransactionsPages: TransactionsModule['pages']; // Asset Holders - assetHolders: AssetHolders["results"]; + assetHolders: AssetHolders['results']; assetHoldersLoading: boolean; - assetHoldersPages: AssetHolders["pages"]; + assetHoldersPages: AssetHolders['pages']; // Assets List - assets: AllAssets["results"][]; + assets: AllAssets['results'][]; assetsPages: number; assetsLoading: boolean; // Asset Metadata @@ -191,13 +186,13 @@ interface AssetState { // Assets distribution assetsDist: AssetDist[]; assetsDistLoading: boolean; -}; +} export const initialState: AssetState = { // Asset Information assetInfo: {}, - pricePerToken: "", - totalBalancePrice: "", + pricePerToken: '', + totalBalancePrice: '', assetInfoLoading: false, // Asset Transactions (Admin) assetAdminTransactions: [], @@ -238,23 +233,15 @@ export const GET_ASSETS_DIST = 'GET_ASSETS_DIST'; /* ----------------- ** ACTIONS -------------------*/ -export const getAssetInfo = createAsyncThunk( - GET_ASSET_INFO, - (id: string) => - ajax({ - url: `${ASSET_DETAIL_URL}/detail/${id}`, - }) +export const getAssetInfo = createAsyncThunk(GET_ASSET_INFO, (id: string) => + ajax({ + url: `${ASSET_DETAIL_URL}/detail/${id}`, + }) ); export const getAssetsList = createAsyncThunk( GET_ASSETS_LIST, - ({ - page = 1, - count = 10, - }: { - page?: number, - count?: number, - }) => + ({ page = 1, count = 10 }: { page?: number; count?: number }) => ajax({ url: `${ASSETS_LIST_URL}?${qs.stringify({ page, count })}`, }) @@ -262,15 +249,7 @@ export const getAssetsList = createAsyncThunk( export const getAssetHolders = createAsyncThunk( GET_ASSET_HOLDERS, - ({ - assetId, - page = 1, - count = 10, - }: { - assetId: string, - page?: number, - count?: number, - }) => + ({ assetId, page = 1, count = 10 }: { assetId: string; page?: number; count?: number }) => ajax({ url: `${ASSET_DETAIL_URL}/holders?${qs.stringify({ id: assetId, page, count })}`, }) @@ -278,15 +257,7 @@ export const getAssetHolders = createAsyncThunk( export const getAssetAdminTransactions = createAsyncThunk( GET_ASSET_ADMIN_TRANSACTIONS, - ({ - denom, - page = 1, - count = 10, - }: { - denom: string, - page?: number, - count?: number, - }) => + ({ denom, page = 1, count = 10 }: { denom: string; page?: number; count?: number }) => ajax({ url: `${TX_INFO_URL}/module/ASSET?${qs.stringify({ denom, page, count })}`, }) @@ -294,34 +265,22 @@ export const getAssetAdminTransactions = createAsyncThunk( export const getAssetTransferTransactions = createAsyncThunk( GET_ASSET_TRANSFER_TRANSACTIONS, - ({ - denom, - page = 1, - count = 10, - }: { - denom: string, - page?: number, - count?: number, - }) => + ({ denom, page = 1, count = 10 }: { denom: string; page?: number; count?: number }) => ajax({ url: `${TX_INFO_URL}/module/TRANSFER?${qs.stringify({ denom, page, count })}`, }) ); -export const getAssetMetadata = createAsyncThunk( - GET_ASSET_METADATA, - () => - ajax({ - url: `${ASSET_DETAIL_URL}/metadata`, - }) +export const getAssetMetadata = createAsyncThunk(GET_ASSET_METADATA, () => + ajax({ + url: `${ASSET_DETAIL_URL}/metadata`, + }) ); -export const getAssetsDist = createAsyncThunk( - GET_ASSETS_DIST, - () => - ajax({ - url: `${ASSETS_DIST_URL}`, - }) +export const getAssetsDist = createAsyncThunk(GET_ASSETS_DIST, () => + ajax({ + url: `${ASSETS_DIST_URL}`, + }) ); export const assetActions = { @@ -393,7 +352,7 @@ export const assetSlice = createSlice({ }) .addCase(getAssetsList.fulfilled, (state, { payload }) => { state.assetsLoading = false; - state.assets = payload.data.results.map((result: AllAssets["results"]) => ({ + state.assets = payload.data.results.map((result: AllAssets['results']) => ({ ...result, lastTxTimestamp: result.lastTxTimestamp === 'null' ? null : result.lastTxTimestamp, pricePerToken: result.supply?.pricePerToken @@ -403,7 +362,7 @@ export const assetSlice = createSlice({ { decimal: 2, minimumFractionDigits: 2, - }, + } )}` : '-- --', totalBalancePrice: result.supply?.totalBalancePrice @@ -430,18 +389,18 @@ export const assetSlice = createSlice({ state.assetInfo = payload.data; state.pricePerToken = payload.data.supply.pricePerToken ? formatDenom( - payload.data.supply.pricePerToken.amount, - payload.data.supply.pricePerToken.denom, - { decimal: 2, minimumFractionDigits: 2 } - ) + payload.data.supply.pricePerToken.amount, + payload.data.supply.pricePerToken.denom, + { decimal: 2, minimumFractionDigits: 2 } + ) : '-- --'; state.totalBalancePrice = payload.data.supply.totalBalancePrice - ? formatDenom( - payload.data.supply.totalBalancePrice.amount, - payload.data.supply.totalBalancePrice.denom, - { decimal: 2, minimumFractionDigits: 2 } - ) - : '-- --'; + ? formatDenom( + payload.data.supply.totalBalancePrice.amount, + payload.data.supply.totalBalancePrice.denom, + { decimal: 2, minimumFractionDigits: 2 } + ) + : '-- --'; }) .addCase(getAssetInfo.rejected, (state) => { state.assetInfoLoading = false; @@ -456,6 +415,7 @@ export const assetSlice = createSlice({ .addCase(getAssetMetadata.fulfilled, (state, { payload }) => { // Used by currencyFormat setCookie('assetMetadata', JSON.stringify(payload.data), 5); + window.localStorage.setItem('assetMetadata', JSON.stringify(payload.data)); state.assetMetadataLoading = false; state.assetMetadata = payload.data; }) @@ -490,4 +450,4 @@ SELECTORS -------------------*/ export const selectAsset = (state: RootState) => state.asset; -export default assetSlice.reducer; \ No newline at end of file +export default assetSlice.reducer; diff --git a/src/redux/hooks/useProposal.tsx b/src/redux/hooks/useProposal.tsx index cbd68334..f3aee171 100644 --- a/src/redux/hooks/useProposal.tsx +++ b/src/redux/hooks/useProposal.tsx @@ -1,7 +1,6 @@ import { useEffect, useState } from 'react'; import styled from 'styled-components'; import { useWalletConnect, WINDOW_MESSAGES } from '@provenanceio/walletconnect-js'; -import { BroadcastResults } from '@provenanceio/walletconnect-js/lib/types'; // @ts-ignore import useToggle from 'react-tiny-hooks/use-toggle'; import { useApp } from 'redux/hooks'; @@ -28,25 +27,21 @@ export const useProposal = () => { // Event listeners for wallet messages useEffect(() => { - // Success message for transaction messages - const submitSuccess = (result: BroadcastResults) => { + wcs.addListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, (result) => { setShouldPull(true); setSubmitted(true); - }; - wcs.addListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, submitSuccess); + }); // Fail message for transaction messages - const submitFailure = (result: BroadcastResults) => { + wcs.addListener(WINDOW_MESSAGES.SEND_MESSAGE_FAILED, (result) => { setSubmitted(false); deactivateModalOpen(); - }; - wcs.addListener(WINDOW_MESSAGES.SEND_MESSAGE_FAILED, submitFailure); + }); // Remove event listeners when no longer needed return () => { - wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, submitSuccess); - wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_FAILED, submitFailure); - wcs.removeAllListeners(); + wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, () => {}); + wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_FAILED, () => {}); }; }, [wcs, deactivateModalOpen]); diff --git a/src/redux/hooks/useStaking.tsx b/src/redux/hooks/useStaking.tsx index 9a10695a..1ec7c9c5 100644 --- a/src/redux/hooks/useStaking.tsx +++ b/src/redux/hooks/useStaking.tsx @@ -12,7 +12,6 @@ import { useWalletConnect, WINDOW_MESSAGES } from '@provenanceio/walletconnect-j import useToggle from 'react-tiny-hooks/use-toggle'; import { useApp, useAccounts } from 'redux/hooks'; import OgButton from 'Components/Button'; -import { BroadcastResults } from '@provenanceio/walletconnect-js/lib/types'; const Button = styled(OgButton)` text-transform: capitalize; @@ -96,14 +95,14 @@ export const useStaking = () => { // Event listeners for wallet messages useEffect(() => { // Success message for transaction messages - const submitSuccess = (result: BroadcastResults) => { + const submitSuccess = () => { setShouldPull(true); deactivateModalOpen(); }; wcs.addListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, submitSuccess); // Fail message for transaction messages - const submitFailure = (result: BroadcastResults) => { + const submitFailure = () => { setShouldPull(false); }; wcs.addListener(WINDOW_MESSAGES.SEND_MESSAGE_FAILED, submitFailure); @@ -112,7 +111,6 @@ export const useStaking = () => { return () => { wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, submitSuccess); wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_FAILED, submitFailure); - wcs.removeAllListeners(); }; }, [wcs, deactivateModalOpen]); diff --git a/src/redux/hooks/useVoting.tsx b/src/redux/hooks/useVoting.tsx index 11240331..dbce031f 100644 --- a/src/redux/hooks/useVoting.tsx +++ b/src/redux/hooks/useVoting.tsx @@ -6,7 +6,6 @@ import { useWalletConnect, WINDOW_MESSAGES } from '@provenanceio/walletconnect-j import useToggle from 'react-tiny-hooks/use-toggle'; import { useApp, useAccounts } from 'redux/hooks'; import OgButton from 'Components/Button'; -import { BroadcastResults } from '@provenanceio/walletconnect-js/lib/types'; const Button = styled(OgButton)` text-transform: capitalize; @@ -32,13 +31,13 @@ export const useVoting = () => { // Event listeners for wallet messages useEffect(() => { // Success message for transaction messages - const submitSuccess = (result: BroadcastResults) => { + const submitSuccess = () => { setVoted(true); }; wcs.addListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, submitSuccess); // Fail message for transaction messages - const submitFailure = (result: BroadcastResults) => { + const submitFailure = () => { setVoted(false); deactivateModalOpen(); }; @@ -48,7 +47,6 @@ export const useVoting = () => { return () => { wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_COMPLETE, submitSuccess); wcs.removeListener(WINDOW_MESSAGES.SEND_MESSAGE_FAILED, submitFailure); - wcs.removeAllListeners(); }; }, [wcs, deactivateModalOpen]); diff --git a/src/utils/cookie/getCookie.js b/src/utils/cookie/getCookie.js index fe292f63..c21bb0a6 100644 --- a/src/utils/cookie/getCookie.js +++ b/src/utils/cookie/getCookie.js @@ -7,6 +7,5 @@ export const getCookie = (cookieName, skipClean = false) => { if (!exists) return null; const foundValue = cookieValues.split(`${cookieName}=`)[1].split(';')[0]; const cleanFoundValue = foundValue.replace(/[^\w\s]/gi, ''); - return skipClean ? foundValue : cleanFoundValue; }; diff --git a/src/utils/number/currencyFormat.tsx b/src/utils/number/currencyFormat.tsx index 313bd69e..5c8d03f4 100644 --- a/src/utils/number/currencyFormat.tsx +++ b/src/utils/number/currencyFormat.tsx @@ -3,7 +3,11 @@ import { getCookie } from 'utils'; export const currencyFormat = (value = 0, initialDenom: string, toBase = false) => { // Get the metadata from the cookie set by assetReducer - const assetMetadata = JSON.parse(getCookie('assetMetadata', true) || '[]'); + let assetMetadata = JSON.parse(getCookie('assetMetadata', true) || '[]'); + if (assetMetadata.length === 0) { + assetMetadata = window.localStorage.getItem('assetMetadata'); + if (assetMetadata) assetMetadata = JSON.parse(assetMetadata); + } // Find the individual denom metadata from the list, if it exists const denomInfo = assetMetadata?.find( From a7a0c26849d7f316519bd87506d6afe02975b84c Mon Sep 17 00:00:00 2001 From: AJ Webb Date: Thu, 31 Aug 2023 08:49:23 -1000 Subject: [PATCH 2/2] bump libs --- package-lock.json | 85 ++++++++++++++++++++++++----------------------- package.json | 4 +-- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index 690fca4a..b85c32eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "3.5.0", "license": "Apache-2.0", "dependencies": { - "@provenanceio/wallet-utils": "2.6.0", - "@provenanceio/walletconnect-js": "3.0.0", + "@provenanceio/wallet-utils": "2.9.0", + "@provenanceio/walletconnect-js": "3.6.0", "@reduxjs/toolkit": "1.8.1", "bech32": "2.0.0", "big.js": "6.1.1", @@ -3816,9 +3816,9 @@ } }, "node_modules/@provenanceio/wallet-utils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@provenanceio/wallet-utils/-/wallet-utils-2.6.0.tgz", - "integrity": "sha512-f0WgAnXnu5ACmV5FzWol2m/bOqmN0l2by7nlwPZT+PjRo2c80qbLCrXFOgduLm8omlhJ1rS1+sU5mAxaq2qOWw==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@provenanceio/wallet-utils/-/wallet-utils-2.9.0.tgz", + "integrity": "sha512-qxTN4HZqgk+vVOIeGehFpGvCwuC/9TI+a4g/PvtVK/yEVsrERVZg5yifCyWr9jtJdKgcCYk/JBmZd7cmE65oSg==", "dependencies": { "@tendermint/belt": "0.3.0", "@tendermint/sig": "0.6.0", @@ -3842,37 +3842,38 @@ } }, "node_modules/@provenanceio/walletconnect-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-3.0.0.tgz", - "integrity": "sha512-eWQWm36lX8hfUoT8TaUMZi3kvu57ITg8Y7FRIF8JRxfBVJ80ZDXgNAGXwzIev7Sq+jkq0W0dszy0dpYWdaFkYw==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-3.6.0.tgz", + "integrity": "sha512-7MSbrQ0cVIJY3x+b2kPkEJSf9OYMiC/fc6EEl62FhiyRjbiARfAsS+ULWbA7b8zdckwr00zdSaBS/cE6phcbfg==", "dependencies": { - "@babel/runtime": "7.19.0", "@walletconnect/client": "1.8.0", "@walletconnect/utils": "1.8.0", "base64url": "3.0.1", - "bip32": "3.1.0", "buffer": "npm:buffer@6.0.3", "crypto": "npm:crypto-browserify@3.12.0", "qrcode": "1.5.1", - "secp256k1": "4.0.3", + "secp256k1": "5.0.0", "stream": "npm:stream-browserify@3.0.0", "util": "npm:util@0.12.5" } }, - "node_modules/@provenanceio/walletconnect-js/node_modules/bip32": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bip32/-/bip32-3.1.0.tgz", - "integrity": "sha512-eoeajYEzJ4d6yyVtby8C+XkCeKItiC4Mx56a0M9VaqTMC73SWOm4xVZG7SaR8e/yp4eSyky2XcBpH3DApPdu7Q==", + "node_modules/@provenanceio/walletconnect-js/node_modules/node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" + }, + "node_modules/@provenanceio/walletconnect-js/node_modules/secp256k1": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-5.0.0.tgz", + "integrity": "sha512-TKWX8xvoGHrxVdqbYeZM9w+izTF4b9z3NhSaDkdn81btvuh+ivbIMGT/zQvDtTFWhRlThpoz6LEYTr7n8A5GcA==", + "hasInstallScript": true, "dependencies": { - "bs58check": "^2.1.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "ripemd160": "^2.0.2", - "typeforce": "^1.11.5", - "wif": "^2.0.6" + "elliptic": "^6.5.4", + "node-addon-api": "^5.0.0", + "node-gyp-build": "^4.2.0" }, "engines": { - "node": ">=6.0.0" + "node": ">=14.0.0" } }, "node_modules/@reduxjs/toolkit": { @@ -34696,9 +34697,9 @@ } }, "@provenanceio/wallet-utils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@provenanceio/wallet-utils/-/wallet-utils-2.6.0.tgz", - "integrity": "sha512-f0WgAnXnu5ACmV5FzWol2m/bOqmN0l2by7nlwPZT+PjRo2c80qbLCrXFOgduLm8omlhJ1rS1+sU5mAxaq2qOWw==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@provenanceio/wallet-utils/-/wallet-utils-2.9.0.tgz", + "integrity": "sha512-qxTN4HZqgk+vVOIeGehFpGvCwuC/9TI+a4g/PvtVK/yEVsrERVZg5yifCyWr9jtJdKgcCYk/JBmZd7cmE65oSg==", "requires": { "@tendermint/belt": "0.3.0", "@tendermint/sig": "0.6.0", @@ -34717,34 +34718,34 @@ } }, "@provenanceio/walletconnect-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-3.0.0.tgz", - "integrity": "sha512-eWQWm36lX8hfUoT8TaUMZi3kvu57ITg8Y7FRIF8JRxfBVJ80ZDXgNAGXwzIev7Sq+jkq0W0dszy0dpYWdaFkYw==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@provenanceio/walletconnect-js/-/walletconnect-js-3.6.0.tgz", + "integrity": "sha512-7MSbrQ0cVIJY3x+b2kPkEJSf9OYMiC/fc6EEl62FhiyRjbiARfAsS+ULWbA7b8zdckwr00zdSaBS/cE6phcbfg==", "requires": { - "@babel/runtime": "7.19.0", "@walletconnect/client": "1.8.0", "@walletconnect/utils": "1.8.0", "base64url": "3.0.1", - "bip32": "3.1.0", "buffer": "npm:buffer@6.0.3", "crypto": "npm:crypto-browserify@3.12.0", "qrcode": "1.5.1", - "secp256k1": "4.0.3", + "secp256k1": "5.0.0", "stream": "npm:stream-browserify@3.0.0", "util": "npm:util@0.12.5" }, "dependencies": { - "bip32": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bip32/-/bip32-3.1.0.tgz", - "integrity": "sha512-eoeajYEzJ4d6yyVtby8C+XkCeKItiC4Mx56a0M9VaqTMC73SWOm4xVZG7SaR8e/yp4eSyky2XcBpH3DApPdu7Q==", - "requires": { - "bs58check": "^2.1.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "ripemd160": "^2.0.2", - "typeforce": "^1.11.5", - "wif": "^2.0.6" + "node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" + }, + "secp256k1": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-5.0.0.tgz", + "integrity": "sha512-TKWX8xvoGHrxVdqbYeZM9w+izTF4b9z3NhSaDkdn81btvuh+ivbIMGT/zQvDtTFWhRlThpoz6LEYTr7n8A5GcA==", + "requires": { + "elliptic": "^6.5.4", + "node-addon-api": "^5.0.0", + "node-gyp-build": "^4.2.0" } } } diff --git a/package.json b/package.json index b06c73d4..ea15a9fd 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "private": false, "sideEffects": false, "dependencies": { - "@provenanceio/wallet-utils": "2.6.0", - "@provenanceio/walletconnect-js": "3.0.0", + "@provenanceio/wallet-utils": "2.9.0", + "@provenanceio/walletconnect-js": "3.6.0", "@reduxjs/toolkit": "1.8.1", "bech32": "2.0.0", "big.js": "6.1.1",