Skip to content

Commit

Permalink
Mainnet (#316)
Browse files Browse the repository at this point in the history
* feat: add mainnet contarct

* feat: use mainnet link for showing hash operation status

* feat: remove all gas fee estimation components

* feat: add creator address to the minted nft token metadata

* feat: update smart contract entrypoints

* feat: remove testnet warning banner

* fix: hide full container for estimated gas fee

* feat: get estimated token id for sharing the new minted nft
  • Loading branch information
bhaskarSingh authored Mar 29, 2021
1 parent 53e756f commit dbe99a2
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 153 deletions.
32 changes: 16 additions & 16 deletions src/components/NavBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,24 @@ function NavBar(props) {
}
}

useEffect(() => {
if (typeof window !== 'undefined') {
let banner = localStorage.getItem('alertBanner');
if (banner !== null) {
setAlertBanner(JSON.parse(banner));
} else {
setAlertBanner(true);
}
}
}, []);

useEffect(() => {
localStorage.setItem('alertBanner', JSON.stringify(alertBanner));
}, [alertBanner]);
// useEffect(() => {
// if (typeof window !== 'undefined') {
// let banner = localStorage.getItem('alertBanner');
// if (banner !== null) {
// setAlertBanner(JSON.parse(banner));
// } else {
// setAlertBanner(true);
// }
// }
// }, []);

// useEffect(() => {
// localStorage.setItem('alertBanner', JSON.stringify(alertBanner));
// }, [alertBanner]);

return (
<nav className={`bg-base-900 font-mulish`}>
<div
{/* <div
style={{ background: 'rgba(245,158,11,0.2)' }}
className={`text-white top-0 px-30 py-2 flex items-center justify-between ${
alertBanner === true ? 'flex' : 'hidden'
Expand All @@ -125,7 +125,7 @@ function NavBar(props) {
<button onClick={() => setAlertBanner(false)}>
<MdClose size="24" />
</button>
</div>
</div> */}
<div className="px-30 py-8 flex justify-between items-center">
<Link to="/tezos">
<Theme className={`h-18 w-auto`} />
Expand Down
6 changes: 3 additions & 3 deletions src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NetworkType } from '@airgap/beacon-sdk';
export const APP_NAME = 'Cryptocodeschool';

// allowed: 'mainnet', 'carthagenet', 'labnet' or 'sandbox'(http://localhost:8732) https://delphinet.smartpy.io
export const NETWORK = NetworkType.EDONET;
export const INDEXER_NETWORK = 'edo2net';
export const NETWORK = NetworkType.MAINNET;
export const INDEXER_NETWORK = 'mainnet';

export const CONTRACT_ADDRESS = 'KT1QVn7QUtU9DgHPpqrWgohg2cPDg7EWEJRd';
export const CONTRACT_ADDRESS = 'KT1V6cNW5jTUxEwmMhxvNHkMF3Bkm5a9Cfrt';
40 changes: 25 additions & 15 deletions src/pages/tezos/claim-transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
convertMutezToXtz,
getXTZPriceInUSD,
getXTZPrice,
getAllTokensCount,
} from 'src/utils/indexer';
import { InMemorySigner } from '@taquito/signer';
import { estimateNFTMintFee } from 'src/utils/gas_estimates';
Expand Down Expand Up @@ -165,7 +166,7 @@ function Transaction({ location }) {
const [user, setUser] = useAtom(userAtom);
const [isUser] = useAtom(isUserAtom);

const [botTokenId, setTokenId] = useState(false);
const [botTokenId, setTokenId] = useState(0);
const [copyLink, setCopyLink] = useState(false);
const [claimButtonDisabled, setClaimButtonDisabledStatus] = useState(true);

Expand Down Expand Up @@ -199,6 +200,15 @@ function Transaction({ location }) {
}
}, []);

useAsync(async () => {
try {
const result = await getAllTokensCount();
setTokenId(result);
} catch (error) {
console.log(error);
}
}, []);

const ErrorModal = () => {
return (
<div
Expand Down Expand Up @@ -249,11 +259,11 @@ function Transaction({ location }) {
'': jsonURI,
});

const RnId = (deepness = 10) =>
parseInt(Date.now() + Math.random() * deepness);
// const RnId = (deepness = 10) =>
// parseInt(Date.now() + Math.random() * deepness);

const randomId = RnId();
setTokenId(randomId);
// const randomId = RnId();
// setTokenId(randomId);
const contract = await Tezos.wallet.at(CONTRACT_ADDRESS);

const op = await contract.methods.mint(metadata).send();
Expand Down Expand Up @@ -290,13 +300,13 @@ function Transaction({ location }) {
}
}, [user]);

const estimatedTotalCost = useAsync(async () => {
try {
return await estimateNFTMintFee();
} catch (err) {
console.log('err', err);
}
}, []);
// const estimatedTotalCost = useAsync(async () => {
// try {
// return await estimateNFTMintFee();
// } catch (err) {
// console.log('err', err);
// }
// }, []);

return (
<div className=" bg-base-900 ">
Expand Down Expand Up @@ -361,7 +371,7 @@ function Transaction({ location }) {
<Heading heading="Confirm your claim" />
<TransactionContainer>
<Cost type="Cryptobot Cost" main={'Free'} caption={''} />
<div className="bg-base-600 mt-4 px-8 rounded">
{/* <div className="bg-base-600 mt-4 px-8 rounded">
{estimatedTotalCost.loading ? (
<Cost
type="Estimated Network Fee"
Expand Down Expand Up @@ -392,7 +402,7 @@ function Transaction({ location }) {
/>
</div>
)}
</div>
</div> */}
<div>
{getUserBalance.loading ? null : getUserBalance.error ? (
<div className="text-error-500 text-center">
Expand Down Expand Up @@ -496,7 +506,7 @@ function Transaction({ location }) {
<Button
onClick={() => {
window.open(
`https://delphinet.tzkt.io/${opHash ? opHash : ''}`,
`https://mainnet.tzkt.io/${opHash ? opHash : ''}`,
'_blank',
);
}}
Expand Down
194 changes: 91 additions & 103 deletions src/pages/tezos/cryptobot/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -188,60 +188,58 @@ function BotView({ location }) {
<ModalHeading>
Are you sure to withdraw cryptobot from sale ?
</ModalHeading>
<TransactionContainer>
<Cost
{/* <Cost
type="Estimated Network Fee"
main={`${convertMutezToXtz(4556)} XTZ`}
caption={
xtzPrice ? `$ ${getXTZPriceInUSD(xtzPrice.price, 4556)}` : null
}
tooltip
/>
<div>
{getUserBalance.loading ? null : getUserBalance.error ? (
<div className="text-error-500">
Error: {getUserBalance.error.message}
</div>
) : (
<div>
{getUserBalance.value === 0 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Your account is empty.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : getUserBalance.value < 0.5 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Insufficient balance. You need additional of 0.5 XTZ
balance to proceed further.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : null}
</div>
)}
</div>
</TransactionContainer>
/> */}
<div>
{getUserBalance.loading ? null : getUserBalance.error ? (
<div className="text-error-500">
Error: {getUserBalance.error.message}
</div>
) : (
<div>
{getUserBalance.value === 0 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Your account is empty.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : getUserBalance.value < 0.5 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Insufficient balance. You need additional of 0.5 XTZ balance
to proceed further.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : null}
</div>
)}
</div>
<div>
<Button
size="lg"
Expand Down Expand Up @@ -361,60 +359,50 @@ function BotView({ location }) {
</div>
</InputContainer>
</form>
<TransactionContainer>
<Cost
type="Estimated Network Fee"
main={`${convertMutezToXtz(4556)} XTZ`}
caption={
xtzPrice ? `$ ${getXTZPriceInUSD(xtzPrice.price, 4556)}` : null
}
tooltip
/>
<div>
{getUserBalance.loading ? null : getUserBalance.error ? (
<div className="text-error-500">
Error: {getUserBalance.error.message}
</div>
) : (
<div>
{getUserBalance.value === 0 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Your account is empty.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : getUserBalance.value < 0.5 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Insufficient balance. You need additional of 0.5 XTZ
balance to proceed further.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : null}
</div>
)}
</div>
</TransactionContainer>
<div>
{getUserBalance.loading ? null : getUserBalance.error ? (
<div className="text-error-500">
Error: {getUserBalance.error.message}
</div>
) : (
<div>
{getUserBalance.value === 0 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Your account is empty.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : getUserBalance.value < 0.5 ? (
<div
className="mt-3 py-3 px-5 mb-4 text-white text-sm rounded border border-error-600 bg-opacity-25 bg-error-500"
role="alert"
>
Insufficient balance. You need additional of 0.5 XTZ balance
to proceed further.{' '}
<strong>
<a
target="_blank"
href="https://www.notion.so/Guide-to-getting-XTZ-57aeea1b7a1947ef9ffc195189f4a0ff"
className="underline"
>
How to obtain XTZ tokens ?
</a>
</strong>
</div>
) : null}
</div>
)}
</div>
<div>
<Button
size="lg"
Expand Down Expand Up @@ -828,7 +816,7 @@ function ConfirmationModel(opHash) {
<Button
onClick={() => {
window.open(
`https://delphinet.tzkt.io/${opHash ? opHash : ''}`,
`https://mainnet.tzkt.io/${opHash ? opHash : ''}`,
'_blank',
);
}}
Expand Down
Loading

0 comments on commit dbe99a2

Please sign in to comment.