mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-02-11 09:45:49 +00:00
added minting page
This commit is contained in:
parent
c4d021981c
commit
3aae1d1a3c
104
package-lock.json
generated
104
package-lock.json
generated
@ -55,6 +55,7 @@
|
|||||||
"react-infinite-scroller": "^1.2.6",
|
"react-infinite-scroller": "^1.2.6",
|
||||||
"react-intersection-observer": "^9.13.0",
|
"react-intersection-observer": "^9.13.0",
|
||||||
"react-json-view-lite": "^2.0.1",
|
"react-json-view-lite": "^2.0.1",
|
||||||
|
"react-loader-spinner": "^6.1.6",
|
||||||
"react-qr-code": "^2.0.15",
|
"react-qr-code": "^2.0.15",
|
||||||
"react-quill": "^2.0.0",
|
"react-quill": "^2.0.0",
|
||||||
"react-redux": "^9.1.2",
|
"react-redux": "^9.1.2",
|
||||||
@ -2887,6 +2888,11 @@
|
|||||||
"integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==",
|
"integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/stylis": {
|
||||||
|
"version": "4.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/stylis/-/stylis-4.2.5.tgz",
|
||||||
|
"integrity": "sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw=="
|
||||||
|
},
|
||||||
"node_modules/@types/trusted-types": {
|
"node_modules/@types/trusted-types": {
|
||||||
"version": "2.0.7",
|
"version": "2.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||||
@ -3593,6 +3599,14 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/camelize": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001599",
|
"version": "1.0.30001599",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001599.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001599.tgz",
|
||||||
@ -4027,6 +4041,24 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/css-color-keywords": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/css-to-react-native": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"camelize": "^1.0.0",
|
||||||
|
"css-color-keywords": "^1.0.0",
|
||||||
|
"postcss-value-parser": "^4.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/css.escape": {
|
"node_modules/css.escape": {
|
||||||
"version": "1.5.1",
|
"version": "1.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
|
||||||
@ -6372,7 +6404,6 @@
|
|||||||
"version": "3.3.7",
|
"version": "3.3.7",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
||||||
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
|
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
|
||||||
"devOptional": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@ -9106,10 +9137,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.4.37",
|
"version": "8.4.38",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.37.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
|
||||||
"integrity": "sha512-7iB/v/r7Woof0glKLH8b1SPHrsX7uhdO+Geb41QpF/+mWZHU3uxxSlN+UXGVit1PawOYDToO+AbZzhBzWRDwbQ==",
|
"integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==",
|
||||||
"devOptional": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@ -9133,6 +9163,11 @@
|
|||||||
"node": "^10 || ^12 || >=14"
|
"node": "^10 || ^12 || >=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/postcss-value-parser": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
|
||||||
|
},
|
||||||
"node_modules/prelude-ls": {
|
"node_modules/prelude-ls": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
|
||||||
@ -9631,6 +9666,27 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
|
||||||
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
|
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/react-loader-spinner": {
|
||||||
|
"version": "6.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-loader-spinner/-/react-loader-spinner-6.1.6.tgz",
|
||||||
|
"integrity": "sha512-x5h1Jcit7Qn03MuKlrWcMG9o12cp9SNDVHVJTNRi9TgtGPKcjKiXkou4NRfLAtXaFB3+Z8yZsVzONmPzhv2ErA==",
|
||||||
|
"dependencies": {
|
||||||
|
"react-is": "^18.2.0",
|
||||||
|
"styled-components": "^6.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.0.0 || ^17.0.0 || ^18.0.0",
|
||||||
|
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/react-loader-spinner/node_modules/react-is": {
|
||||||
|
"version": "18.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
|
||||||
|
"integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg=="
|
||||||
|
},
|
||||||
"node_modules/react-qr-code": {
|
"node_modules/react-qr-code": {
|
||||||
"version": "2.0.15",
|
"version": "2.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/react-qr-code/-/react-qr-code-2.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/react-qr-code/-/react-qr-code-2.0.15.tgz",
|
||||||
@ -10258,6 +10314,11 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/shallowequal": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ=="
|
||||||
|
},
|
||||||
"node_modules/shebang-command": {
|
"node_modules/shebang-command": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||||
@ -10358,7 +10419,6 @@
|
|||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
|
||||||
"integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
|
"integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
|
||||||
"devOptional": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@ -10491,6 +10551,38 @@
|
|||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/styled-components": {
|
||||||
|
"version": "6.1.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.13.tgz",
|
||||||
|
"integrity": "sha512-M0+N2xSnAtwcVAQeFEsGWFFxXDftHUD7XrKla06QbpUMmbmtFBMMTcKWvFXtWxuD5qQkB8iU5gk6QASlx2ZRMw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@emotion/is-prop-valid": "1.2.2",
|
||||||
|
"@emotion/unitless": "0.8.1",
|
||||||
|
"@types/stylis": "4.2.5",
|
||||||
|
"css-to-react-native": "3.2.0",
|
||||||
|
"csstype": "3.1.3",
|
||||||
|
"postcss": "8.4.38",
|
||||||
|
"shallowequal": "1.1.0",
|
||||||
|
"stylis": "4.3.2",
|
||||||
|
"tslib": "2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 16"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/styled-components"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">= 16.8.0",
|
||||||
|
"react-dom": ">= 16.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/styled-components/node_modules/stylis": {
|
||||||
|
"version": "4.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.2.tgz",
|
||||||
|
"integrity": "sha512-bhtUjWd/z6ltJiQwg0dUfxEJ+W+jdqQd8TbWLWyeIJHlnsqmGLRFFd8e5mA0AZi/zx90smXRlN66YMTcaSFifg=="
|
||||||
|
},
|
||||||
"node_modules/stylis": {
|
"node_modules/stylis": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz",
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"html-to-text": "^9.0.5",
|
"html-to-text": "^9.0.5",
|
||||||
"jssha": "3.3.1",
|
"jssha": "3.3.1",
|
||||||
|
"lit": "^3.2.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mime": "^4.0.4",
|
"mime": "^4.0.4",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
@ -58,6 +59,7 @@
|
|||||||
"react-infinite-scroller": "^1.2.6",
|
"react-infinite-scroller": "^1.2.6",
|
||||||
"react-intersection-observer": "^9.13.0",
|
"react-intersection-observer": "^9.13.0",
|
||||||
"react-json-view-lite": "^2.0.1",
|
"react-json-view-lite": "^2.0.1",
|
||||||
|
"react-loader-spinner": "^6.1.6",
|
||||||
"react-qr-code": "^2.0.15",
|
"react-qr-code": "^2.0.15",
|
||||||
"react-quill": "^2.0.0",
|
"react-quill": "^2.0.0",
|
||||||
"react-redux": "^9.1.2",
|
"react-redux": "^9.1.2",
|
||||||
@ -65,7 +67,6 @@
|
|||||||
"react-virtuoso": "^4.10.4",
|
"react-virtuoso": "^4.10.4",
|
||||||
"recoil": "^0.7.7",
|
"recoil": "^0.7.7",
|
||||||
"short-unique-id": "^5.2.0",
|
"short-unique-id": "^5.2.0",
|
||||||
"lit": "^3.2.1",
|
|
||||||
"slate": "^0.103.0",
|
"slate": "^0.103.0",
|
||||||
"slate-react": "^0.109.0",
|
"slate-react": "^0.109.0",
|
||||||
"tiptap-extension-resize-image": "^1.1.8",
|
"tiptap-extension-resize-image": "^1.1.8",
|
||||||
|
68
src/App.tsx
68
src/App.tsx
@ -46,6 +46,7 @@ import CloseIcon from "@mui/icons-material/Close";
|
|||||||
import { JsonView, allExpanded, darkStyles } from 'react-json-view-lite';
|
import { JsonView, allExpanded, darkStyles } from 'react-json-view-lite';
|
||||||
import 'react-json-view-lite/dist/index.css';
|
import 'react-json-view-lite/dist/index.css';
|
||||||
import HelpIcon from '@mui/icons-material/Help';
|
import HelpIcon from '@mui/icons-material/Help';
|
||||||
|
import EngineeringIcon from '@mui/icons-material/Engineering';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createAccount,
|
createAccount,
|
||||||
@ -120,6 +121,8 @@ import { Wallets } from "./Wallets";
|
|||||||
import './utils/seedPhrase/RandomSentenceGenerator';
|
import './utils/seedPhrase/RandomSentenceGenerator';
|
||||||
import { test } from "vitest";
|
import { test } from "vitest";
|
||||||
import { useHandleUserInfo } from "./components/Group/useHandleUserInfo";
|
import { useHandleUserInfo } from "./components/Group/useHandleUserInfo";
|
||||||
|
import { Minting } from "./components/Minting/Minting";
|
||||||
|
import { isRunningGateway } from "./qortalRequests";
|
||||||
|
|
||||||
type extStates =
|
type extStates =
|
||||||
| "not-authenticated"
|
| "not-authenticated"
|
||||||
@ -329,6 +332,8 @@ function App() {
|
|||||||
const {downloadResource} = useFetchResources()
|
const {downloadResource} = useFetchResources()
|
||||||
const [showSeed, setShowSeed] = useState(false)
|
const [showSeed, setShowSeed] = useState(false)
|
||||||
const [creationStep, setCreationStep] = useState(1)
|
const [creationStep, setCreationStep] = useState(1)
|
||||||
|
const [isOpenMinting, setIsOpenMinting] = useState(false)
|
||||||
|
|
||||||
const setIsDisabledEditorEnter = useSetRecoilState(isDisabledEditorEnterAtom)
|
const setIsDisabledEditorEnter = useSetRecoilState(isDisabledEditorEnterAtom)
|
||||||
const {
|
const {
|
||||||
isShow: isShowInfo,
|
isShow: isShowInfo,
|
||||||
@ -1651,6 +1656,54 @@ function App() {
|
|||||||
alignItems: 'center'
|
alignItems: 'center'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{extState === "authenticated" && isMainWindow && (
|
||||||
|
<MyContext.Provider
|
||||||
|
value={{
|
||||||
|
txList,
|
||||||
|
setTxList,
|
||||||
|
memberGroups,
|
||||||
|
setMemberGroups,
|
||||||
|
isShow,
|
||||||
|
onCancel,
|
||||||
|
onOk,
|
||||||
|
show,
|
||||||
|
userInfo,
|
||||||
|
message,
|
||||||
|
rootHeight,
|
||||||
|
showInfo,
|
||||||
|
openSnackGlobal: openSnack,
|
||||||
|
setOpenSnackGlobal: setOpenSnack,
|
||||||
|
infoSnackCustom: infoSnack,
|
||||||
|
setInfoSnackCustom: setInfoSnack,
|
||||||
|
downloadResource,
|
||||||
|
getIndividualUserInfo
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TaskManger getUserInfo={getUserInfo} />
|
||||||
|
</MyContext.Provider>
|
||||||
|
)}
|
||||||
|
<Spacer height="20px" />
|
||||||
|
<ButtonBase onClick={async ()=> {
|
||||||
|
try {
|
||||||
|
const res = await isRunningGateway()
|
||||||
|
if(res) throw new Error('Cannot view minting details on the gateway')
|
||||||
|
setIsOpenMinting(true)
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
setOpenSnack(true)
|
||||||
|
setInfoSnack({
|
||||||
|
type: 'error',
|
||||||
|
message: error?.message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<EngineeringIcon sx={{
|
||||||
|
color: 'var(--unread)'
|
||||||
|
}} />
|
||||||
|
</ButtonBase>
|
||||||
|
|
||||||
|
|
||||||
|
<Spacer height="20px" />
|
||||||
{(desktopViewMode === "apps" || desktopViewMode === "home") && (
|
{(desktopViewMode === "apps" || desktopViewMode === "home") && (
|
||||||
<ButtonBase onClick={()=> {
|
<ButtonBase onClick={()=> {
|
||||||
if(desktopViewMode === "apps"){
|
if(desktopViewMode === "apps"){
|
||||||
@ -1755,17 +1808,7 @@ function App() {
|
|||||||
{!isMobile && renderProfile()}
|
{!isMobile && renderProfile()}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
position: "fixed",
|
|
||||||
right: "25px",
|
|
||||||
bottom: "25px",
|
|
||||||
width: "350px",
|
|
||||||
zIndex: 100000,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TaskManger getUserInfo={getUserInfo} />
|
|
||||||
</Box>
|
|
||||||
</MyContext.Provider>
|
</MyContext.Provider>
|
||||||
)}
|
)}
|
||||||
{isOpenSendQort && isMainWindow && (
|
{isOpenSendQort && isMainWindow && (
|
||||||
@ -3306,6 +3349,9 @@ function App() {
|
|||||||
}} />
|
}} />
|
||||||
</ButtonBase>
|
</ButtonBase>
|
||||||
)}
|
)}
|
||||||
|
{isOpenMinting && (
|
||||||
|
<Minting setIsOpenMinting={setIsOpenMinting} groups={memberGroups} myAddress={address} show={show} setTxList={setTxList} txList={txList}/>
|
||||||
|
)}
|
||||||
</AppContainer>
|
</AppContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
82
src/background-cases.ts
Normal file
82
src/background-cases.ts
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import { getKeyPair, getLastRef, processTransactionVersion2 } from "./background";
|
||||||
|
import Base58 from "./deps/Base58";
|
||||||
|
import { createTransaction } from "./transactions/transactions";
|
||||||
|
|
||||||
|
|
||||||
|
export async function createRewardShareCase(data) {
|
||||||
|
const {recipientPublicKey} = data;
|
||||||
|
const resKeyPair = await getKeyPair();
|
||||||
|
const parsedData = JSON.parse(resKeyPair);
|
||||||
|
const uint8PrivateKey = Base58.decode(parsedData.privateKey);
|
||||||
|
const uint8PublicKey = Base58.decode(parsedData.publicKey);
|
||||||
|
const keyPair = {
|
||||||
|
privateKey: uint8PrivateKey,
|
||||||
|
publicKey: uint8PublicKey,
|
||||||
|
};
|
||||||
|
let lastRef = await getLastRef();
|
||||||
|
|
||||||
|
const tx = await createTransaction(38, keyPair, {
|
||||||
|
recipientPublicKey,
|
||||||
|
percentageShare: 0,
|
||||||
|
lastReference: lastRef,
|
||||||
|
});
|
||||||
|
|
||||||
|
const signedBytes = Base58.encode(tx.signedBytes);
|
||||||
|
|
||||||
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
|
if (!res?.signature)
|
||||||
|
throw new Error("Transaction was not able to be processed");
|
||||||
|
return res
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function removeRewardShareCase(data) {
|
||||||
|
|
||||||
|
const {rewardShareKeyPairPublicKey, recipient, percentageShare} = data;
|
||||||
|
const resKeyPair = await getKeyPair();
|
||||||
|
const parsedData = JSON.parse(resKeyPair);
|
||||||
|
const uint8PrivateKey = Base58.decode(parsedData.privateKey);
|
||||||
|
const uint8PublicKey = Base58.decode(parsedData.publicKey);
|
||||||
|
const keyPair = {
|
||||||
|
privateKey: uint8PrivateKey,
|
||||||
|
publicKey: uint8PublicKey,
|
||||||
|
};
|
||||||
|
let lastRef = await getLastRef();
|
||||||
|
|
||||||
|
const tx = await createTransaction(381, keyPair, {
|
||||||
|
rewardShareKeyPairPublicKey,
|
||||||
|
recipient,
|
||||||
|
percentageShare,
|
||||||
|
lastReference: lastRef,
|
||||||
|
});
|
||||||
|
|
||||||
|
const signedBytes = Base58.encode(tx.signedBytes);
|
||||||
|
|
||||||
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
|
if (!res?.signature)
|
||||||
|
throw new Error("Transaction was not able to be processed");
|
||||||
|
return res
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function getRewardSharePrivateKeyCase(data) {
|
||||||
|
const {recipientPublicKey} = data
|
||||||
|
const resKeyPair = await getKeyPair();
|
||||||
|
const parsedData = JSON.parse(resKeyPair);
|
||||||
|
const uint8PrivateKey = Base58.decode(parsedData.privateKey);
|
||||||
|
const uint8PublicKey = Base58.decode(parsedData.publicKey);
|
||||||
|
const keyPair = {
|
||||||
|
privateKey: uint8PrivateKey,
|
||||||
|
publicKey: uint8PublicKey,
|
||||||
|
};
|
||||||
|
let lastRef = await getLastRef();
|
||||||
|
|
||||||
|
const tx = await createTransaction(38, keyPair, {
|
||||||
|
recipientPublicKey,
|
||||||
|
percentageShare: 0,
|
||||||
|
lastReference: lastRef,
|
||||||
|
});
|
||||||
|
|
||||||
|
return tx?._base58RewardShareSeed
|
||||||
|
}
|
@ -32,6 +32,7 @@ import { Sha256 } from "asmcrypto.js";
|
|||||||
import { TradeBotRespondMultipleRequest } from "./transactions/TradeBotRespondMultipleRequest";
|
import { TradeBotRespondMultipleRequest } from "./transactions/TradeBotRespondMultipleRequest";
|
||||||
import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from "./constants/resourceTypes";
|
import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from "./constants/resourceTypes";
|
||||||
import TradeBotRespondRequest from './transactions/TradeBotRespondRequest';
|
import TradeBotRespondRequest from './transactions/TradeBotRespondRequest';
|
||||||
|
import { createRewardShareCase, getRewardSharePrivateKeyCase, removeRewardShareCase } from './background-cases';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1258,7 +1259,7 @@ export const sendQortFee = async (): Promise<number> => {
|
|||||||
return qortFee;
|
return qortFee;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getNameOrAddress(receiver) {
|
export async function getNameOrAddress(receiver) {
|
||||||
try {
|
try {
|
||||||
const isAddress = validateAddress(receiver);
|
const isAddress = validateAddress(receiver);
|
||||||
if (isAddress) {
|
if (isAddress) {
|
||||||
@ -4633,6 +4634,48 @@ chrome?.runtime?.onMessage.addListener((request, sender, sendResponse) => {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "createRewardShare": {
|
||||||
|
const {
|
||||||
|
recipientPublicKey
|
||||||
|
} = request.payload;
|
||||||
|
createRewardShareCase({recipientPublicKey})
|
||||||
|
.then((res) => {
|
||||||
|
sendResponse(res);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
sendResponse({ error: error?.message });
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "getRewardSharePrivateKey": {
|
||||||
|
const {
|
||||||
|
recipientPublicKey
|
||||||
|
} = request.payload;
|
||||||
|
getRewardSharePrivateKeyCase({recipientPublicKey})
|
||||||
|
.then((res) => {
|
||||||
|
sendResponse(res);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
sendResponse({ error: error?.message });
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "removeRewardShare": {
|
||||||
|
const {
|
||||||
|
rewardShareKeyPairPublicKey, recipient, percentageShare
|
||||||
|
} = request.payload;
|
||||||
|
removeRewardShareCase({rewardShareKeyPairPublicKey, recipient, percentageShare})
|
||||||
|
.then((res) => {
|
||||||
|
sendResponse(res);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
sendResponse({ error: error?.message });
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "addEnteredQmailTimestamp": {
|
case "addEnteredQmailTimestamp": {
|
||||||
addEnteredQmailTimestamp()
|
addEnteredQmailTimestamp()
|
||||||
|
1198
src/components/Minting/Minting.tsx
Normal file
1198
src/components/Minting/Minting.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@ import TaskAltIcon from "@mui/icons-material/TaskAlt";
|
|||||||
import ExpandLess from "@mui/icons-material/ExpandLess";
|
import ExpandLess from "@mui/icons-material/ExpandLess";
|
||||||
import ExpandMore from "@mui/icons-material/ExpandMore";
|
import ExpandMore from "@mui/icons-material/ExpandMore";
|
||||||
import { MyContext, getBaseApiReact, isMobile } from "../../App";
|
import { MyContext, getBaseApiReact, isMobile } from "../../App";
|
||||||
|
import { executeEvent } from "../../utils/events";
|
||||||
|
|
||||||
export const TaskManger = ({ getUserInfo }) => {
|
export const TaskManger = ({ getUserInfo }) => {
|
||||||
const { txList, setTxList, memberGroups } = useContext(MyContext);
|
const { txList, setTxList, memberGroups } = useContext(MyContext);
|
||||||
@ -39,7 +40,7 @@ export const TaskManger = ({ getUserInfo }) => {
|
|||||||
await new Promise((res) =>
|
await new Promise((res) =>
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
res(null);
|
res(null);
|
||||||
}, 300000)
|
}, 60000)
|
||||||
);
|
);
|
||||||
setTxList((prev) => {
|
setTxList((prev) => {
|
||||||
let previousData = [...prev];
|
let previousData = [...prev];
|
||||||
@ -62,7 +63,7 @@ export const TaskManger = ({ getUserInfo }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
intervals.current[signature] = setInterval(getAnswer, 120000);
|
intervals.current[signature] = setInterval(getAnswer, 60000);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -96,7 +97,15 @@ export const TaskManger = ({ getUserInfo }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
prev.forEach((tx) => {
|
|
||||||
|
|
||||||
|
return previousData;
|
||||||
|
});
|
||||||
|
}, [memberGroups, getUserInfo]);
|
||||||
|
|
||||||
|
useEffect(()=> {
|
||||||
|
|
||||||
|
txList.forEach((tx) => {
|
||||||
if (
|
if (
|
||||||
["created-common-secret", "joined-group-request", "join-request-accept"].includes(
|
["created-common-secret", "joined-group-request", "join-request-accept"].includes(
|
||||||
tx?.type
|
tx?.type
|
||||||
@ -113,11 +122,17 @@ export const TaskManger = ({ getUserInfo }) => {
|
|||||||
getStatus({ signature: tx.signature }, getUserInfo);
|
getStatus({ signature: tx.signature }, getUserInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if((tx?.type === "remove-rewardShare" || tx?.type === "add-rewardShare") && tx?.signature && !tx.done){
|
||||||
|
if (!intervals.current[tx.signature]) {
|
||||||
|
const sendEventForRewardShare = ()=> {
|
||||||
|
executeEvent('refresh-rewardshare-list', {})
|
||||||
|
}
|
||||||
|
getStatus({ signature: tx.signature }, sendEventForRewardShare);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return previousData;
|
}, [txList])
|
||||||
});
|
|
||||||
}, [memberGroups, getUserInfo]);
|
|
||||||
|
|
||||||
if (isMobile || txList?.length === 0 || txList.every((item) => item?.done))
|
if (isMobile || txList?.length === 0 || txList.every((item) => item?.done))
|
||||||
return null;
|
return null;
|
||||||
@ -128,9 +143,9 @@ export const TaskManger = ({ getUserInfo }) => {
|
|||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
sx={{
|
sx={{
|
||||||
position: "fixed",
|
// position: "fixed",
|
||||||
bottom: 16,
|
// bottom: 16,
|
||||||
right: 16,
|
// right: 16,
|
||||||
bgcolor: "primary.main",
|
bgcolor: "primary.main",
|
||||||
color: "white",
|
color: "white",
|
||||||
":hover": { bgcolor: "primary.dark" },
|
":hover": { bgcolor: "primary.dark" },
|
||||||
|
46
src/transactions/RemoveRewardShareTransaction.ts
Normal file
46
src/transactions/RemoveRewardShareTransaction.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { DYNAMIC_FEE_TIMESTAMP } from "../constants/constants"
|
||||||
|
import Base58 from "../deps/Base58"
|
||||||
|
import publicKeyToAddress from "../utils/generateWallet/publicKeyToAddress"
|
||||||
|
import TransactionBase from "./TransactionBase"
|
||||||
|
|
||||||
|
|
||||||
|
export default class RemoveRewardShareTransaction extends TransactionBase {
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.type = 38
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
set rewardShareKeyPairPublicKey(rewardShareKeyPairPublicKey) {
|
||||||
|
this._rewardShareKeyPairPublicKey = Base58.decode(rewardShareKeyPairPublicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
set recipient(recipient) {
|
||||||
|
const _address = publicKeyToAddress(this._keyPair.publicKey)
|
||||||
|
this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
|
||||||
|
|
||||||
|
if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
|
||||||
|
this.fee = _address === recipient ? 0 : 0.01
|
||||||
|
} else {
|
||||||
|
this.fee = _address === recipient ? 0 : 0.001
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set percentageShare(share) {
|
||||||
|
this._percentageShare = share * 100
|
||||||
|
this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare)
|
||||||
|
}
|
||||||
|
|
||||||
|
get params() {
|
||||||
|
const params = super.params
|
||||||
|
params.push(
|
||||||
|
this._recipient,
|
||||||
|
this._rewardShareKeyPairPublicKey,
|
||||||
|
this._percentageShareBytes,
|
||||||
|
this._feeBytes
|
||||||
|
)
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
}
|
60
src/transactions/RewardShareTransaction.ts
Normal file
60
src/transactions/RewardShareTransaction.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import TransactionBase from './TransactionBase'
|
||||||
|
|
||||||
|
import { Sha256 } from 'asmcrypto.js'
|
||||||
|
import nacl from '../deps/nacl-fast'
|
||||||
|
import ed2curve from '../deps/ed2curve'
|
||||||
|
import { DYNAMIC_FEE_TIMESTAMP } from '../constants/constants'
|
||||||
|
import publicKeyToAddress from '../utils/generateWallet/publicKeyToAddress'
|
||||||
|
|
||||||
|
export default class RewardShareTransaction extends TransactionBase {
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.type = 38
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set recipientPublicKey(recipientPublicKey) {
|
||||||
|
this._base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? this.constructor.Base58.encode(recipientPublicKey) : recipientPublicKey
|
||||||
|
this._recipientPublicKey = this.constructor.Base58.decode(this._base58RecipientPublicKey)
|
||||||
|
this.recipient = publicKeyToAddress(this._recipientPublicKey)
|
||||||
|
|
||||||
|
const convertedPrivateKey = ed2curve.convertSecretKey(this._keyPair.privateKey)
|
||||||
|
const convertedPublicKey = ed2curve.convertPublicKey(this._recipientPublicKey)
|
||||||
|
const sharedSecret = new Uint8Array(32)
|
||||||
|
|
||||||
|
nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey)
|
||||||
|
|
||||||
|
this._rewardShareSeed = new Sha256().process(sharedSecret).finish().result
|
||||||
|
this._base58RewardShareSeed = this.constructor.Base58.encode(this._rewardShareSeed)
|
||||||
|
this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(this._rewardShareSeed)
|
||||||
|
|
||||||
|
if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
|
||||||
|
this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.01)
|
||||||
|
} else {
|
||||||
|
this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.001)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set recipient(recipient) {
|
||||||
|
this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
|
||||||
|
}
|
||||||
|
|
||||||
|
set percentageShare(share) {
|
||||||
|
this._percentageShare = share * 100
|
||||||
|
this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare)
|
||||||
|
}
|
||||||
|
|
||||||
|
get params() {
|
||||||
|
const params = super.params
|
||||||
|
params.push(
|
||||||
|
this._recipient,
|
||||||
|
this._rewardShareKeyPair.publicKey,
|
||||||
|
this._percentageShareBytes,
|
||||||
|
this._feeBytes
|
||||||
|
)
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,8 @@ import RegisterNameTransaction from './RegisterNameTransaction.js'
|
|||||||
import VoteOnPollTransaction from './VoteOnPollTransaction.js'
|
import VoteOnPollTransaction from './VoteOnPollTransaction.js'
|
||||||
import CreatePollTransaction from './CreatePollTransaction.js'
|
import CreatePollTransaction from './CreatePollTransaction.js'
|
||||||
import DeployAtTransaction from './DeployAtTransaction.js'
|
import DeployAtTransaction from './DeployAtTransaction.js'
|
||||||
|
import RewardShareTransaction from './RewardShareTransaction.js'
|
||||||
|
import RemoveRewardShareTransaction from './RemoveRewardShareTransaction.js'
|
||||||
|
|
||||||
export const transactionTypes = {
|
export const transactionTypes = {
|
||||||
3: RegisterNameTransaction,
|
3: RegisterNameTransaction,
|
||||||
@ -36,7 +37,9 @@ export const transactionTypes = {
|
|||||||
29: GroupInviteTransaction,
|
29: GroupInviteTransaction,
|
||||||
30: CancelGroupInviteTransaction,
|
30: CancelGroupInviteTransaction,
|
||||||
31: JoinGroupTransaction,
|
31: JoinGroupTransaction,
|
||||||
32: LeaveGroupTransaction
|
32: LeaveGroupTransaction,
|
||||||
|
38: RewardShareTransaction,
|
||||||
|
381: RemoveRewardShareTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user