diff --git a/js/hubs/components/ReleasePurchase.js b/js/hubs/components/ReleasePurchase.js
index 9169f9db..313c67e8 100644
--- a/js/hubs/components/ReleasePurchase.js
+++ b/js/hubs/components/ReleasePurchase.js
@@ -28,6 +28,10 @@ const WalletConnectModal = dynamic(() =>
import('@nina-protocol/nina-internal-sdk/esm/WalletConnectModal')
)
+const UnverifiedModal = dynamic(() =>
+ import('@nina-protocol/nina-internal-sdk/esm/UnverifiedModal')
+)
+
import dynamic from 'next/dynamic'
const BUTTON_WIDTH = '155px'
@@ -67,6 +71,8 @@ const ReleasePurchase = (props) => {
const [showNoSolModal, setShowNoSolModal] = useState(false)
const [showWalletModal, setShowWalletModal] = useState(false)
const [coinflowPurchasePending, setCoinflowPurchasePending] = useState(false)
+ const [showUnverifiedModal, setShowUnverifiedModal] = useState(false)
+ const [verificationError, setVerificationError] = useState('')
const txPending = useMemo(
() => releasePurchaseTransactionPending[releasePubkey],
@@ -171,6 +177,10 @@ const ReleasePurchase = (props) => {
}
const showCompletedTransaction = (result) => {
+ if (result.msg.indexOf('Unauthorized') > -1) {
+ setShowUnverifiedModal(true)
+ setVerificationError(result.msg)
+ }
enqueueSnackbar(result.msg, {
variant: result.success ? 'success' : 'warn',
})
@@ -331,6 +341,11 @@ const ReleasePurchase = (props) => {
+
)
}
diff --git a/js/sdk/rollup.config.js b/js/sdk/rollup.config.js
index 9c8e61a6..8d157fa1 100644
--- a/js/sdk/rollup.config.js
+++ b/js/sdk/rollup.config.js
@@ -62,6 +62,7 @@ export default [
CoinflowModal: 'src/components/CoinflowModal.js',
PurchaseModal: 'src/components/PurchaseModal.js',
CoinflowWithdrawModal: 'src/components/CoinflowWithdrawModal.js',
+ UnverifiedModal: 'src/components/UnverifiedModal.js',
},
output: [
{
diff --git a/js/sdk/src/components/UnverifiedModal.js b/js/sdk/src/components/UnverifiedModal.js
new file mode 100644
index 00000000..bbe9e44e
--- /dev/null
+++ b/js/sdk/src/components/UnverifiedModal.js
@@ -0,0 +1,84 @@
+import React from 'react'
+import { styled } from '@mui/material/styles'
+import Paper from '@mui/material/Paper'
+import Modal from '@mui/material/Modal'
+import Backdrop from '@mui/material/Backdrop'
+import Fade from '@mui/material/Fade'
+import Button from '@mui/material/Button'
+import Typography from '@mui/material/Typography'
+import Link from 'next/link'
+
+const UnverifiedModal = ({ open, setOpen, error }) => {
+ const handleClose = () => {
+ setOpen(false)
+ }
+ return (
+
+ handleClose()}
+ closeAfterTransition
+ BackdropComponent={Backdrop}
+ BackdropProps={{
+ timeout: 500,
+ }}
+ >
+
+
+
+ {error}
+
+ {' '}
+
+
+
+
+ )
+}
+
+const Root = styled('div')(() => ({
+ display: 'flex',
+ alignItems: 'center',
+ width: '100%',
+}))
+
+const StyledModal = styled(Modal)(() => ({
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+}))
+
+const StyledPaper = styled(Paper)(({ theme }) => ({
+ backgroundColor: theme.palette.background.paper,
+ border: '2px solid #000',
+ boxShadow: theme.shadows[5],
+ padding: theme.spacing(2, 4, 3),
+ width: '40vw',
+ maxHeight: '90vh',
+ overflowY: 'auto',
+ zIndex: '10',
+ display: 'flex',
+ flexDirection: 'column',
+ [theme.breakpoints.down('md')]: {
+ width: 'unset',
+ margin: '15px',
+ padding: theme.spacing(2),
+ },
+}))
+
+export default UnverifiedModal
diff --git a/js/sdk/src/contexts/Release/release.js b/js/sdk/src/contexts/Release/release.js
index 0f785ff3..91beff5a 100644
--- a/js/sdk/src/contexts/Release/release.js
+++ b/js/sdk/src/contexts/Release/release.js
@@ -572,6 +572,7 @@ const releaseContextHelper = ({
provider,
ninaClient,
usdcBalance,
+ solBalance,
hubPubkey
)
@@ -887,7 +888,8 @@ const releaseContextHelper = ({
releasePubkey,
provider,
ninaClient,
- usdcBalance
+ usdcBalance,
+ solBalance
)
await getConfirmTransaction(txid, provider.connection)
diff --git a/js/sdk/src/index.js b/js/sdk/src/index.js
index cdf9a626..423f50b5 100644
--- a/js/sdk/src/index.js
+++ b/js/sdk/src/index.js
@@ -39,3 +39,4 @@ export { default as HubPostCreate } from './components/HubPostCreate'
export { default as CoinflowModal } from './components/CoinflowModal'
export { default as PurchaseModal } from './components/PurchaseModal'
export { default as CoinflowWithdrawModal } from './components/CoinflowWithdrawModal'
+export { default as UnverifiedModal } from './components/UnverifiedModal'
diff --git a/js/sdk/src/utils/releasePurchaseHelper.js b/js/sdk/src/utils/releasePurchaseHelper.js
index b316272a..a6606520 100644
--- a/js/sdk/src/utils/releasePurchaseHelper.js
+++ b/js/sdk/src/utils/releasePurchaseHelper.js
@@ -120,6 +120,7 @@ const releasePurchaseHelper = async (
provider,
ninaClient,
usdcBalance,
+ solBalance,
hubPubkey = null
) => {
let hub
@@ -127,7 +128,7 @@ const releasePurchaseHelper = async (
const program = await ninaClient.useProgram()
const release = await program.account.release.fetch(releasePubkey)
- if (release.price.toNumber() === 0) {
+ if (release.price.toNumber() === 0 && solBalance === 0) {
const message = new TextEncoder().encode(releasePubkey.toBase58())
const messageBase64 = encodeBase64(message)
const signature = await provider.wallet.signMessage(message)
diff --git a/js/web/components/ReleasePurchase.js b/js/web/components/ReleasePurchase.js
index 4bfae023..87f9d7bc 100644
--- a/js/web/components/ReleasePurchase.js
+++ b/js/web/components/ReleasePurchase.js
@@ -41,6 +41,10 @@ const WalletConnectModal = dynamic(() =>
import('@nina-protocol/nina-internal-sdk/esm/WalletConnectModal')
)
+const UnverifiedModal = dynamic(() =>
+ import('@nina-protocol/nina-internal-sdk/esm/UnverifiedModal')
+)
+
const ReleasePurchase = (props) => {
const {
releasePubkey,
@@ -85,6 +89,8 @@ const ReleasePurchase = (props) => {
const [description, setDescription] = useState()
const [showWalletModal, setShowWalletModal] = useState(false)
const [coinflowPurchasePending, setCoinflowPurchasePending] = useState(false)
+ const [showUnverifiedModal, setShowUnverifiedModal] = useState(false)
+ const [verificationError, setVerificationError] = useState('')
const txPending = useMemo(
() => releasePurchaseTransactionPending[releasePubkey],
@@ -207,6 +213,10 @@ const ReleasePurchase = (props) => {
}
const showCompletedTransaction = (result) => {
+ if (result.msg.indexOf('Unauthorized') > -1) {
+ setShowUnverifiedModal(true)
+ setVerificationError(result.msg)
+ }
enqueueSnackbar(result.msg, {
variant: result.success ? 'success' : 'warn',
})
@@ -415,6 +425,11 @@ const ReleasePurchase = (props) => {
)}
+
)
}
diff --git a/programs/nina/src/instructions/release_init.rs b/programs/nina/src/instructions/release_init.rs
index 16a1e32c..5335c922 100644
--- a/programs/nina/src/instructions/release_init.rs
+++ b/programs/nina/src/instructions/release_init.rs
@@ -79,7 +79,7 @@ pub fn handler(
ctx.accounts.release_signer.to_account_info().clone(),
ctx.accounts.metadata.to_account_info().clone(),
ctx.accounts.release_mint.clone(),
- ctx.accounts.payer.clone(),
+ ctx.accounts.authority.clone(),
ctx.accounts.metadata_program.to_account_info().clone(),
ctx.accounts.token_program.clone(),
ctx.accounts.system_program.clone(),
diff --git a/programs/nina/src/instructions/release_init_with_credit.rs b/programs/nina/src/instructions/release_init_with_credit.rs
index 9244367c..b510083e 100644
--- a/programs/nina/src/instructions/release_init_with_credit.rs
+++ b/programs/nina/src/instructions/release_init_with_credit.rs
@@ -104,7 +104,7 @@ pub fn handler(
ctx.accounts.release_signer.to_account_info().clone(),
ctx.accounts.metadata.to_account_info().clone(),
ctx.accounts.release_mint.clone(),
- ctx.accounts.payer.clone(),
+ ctx.accounts.authority.clone(),
ctx.accounts.metadata_program.to_account_info().clone(),
ctx.accounts.token_program.clone(),
ctx.accounts.system_program.clone(),