Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/evm nftgame1 #111

Merged
merged 37 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9622bcf
NFTGame1 - Initial Commit
Jun 25, 2022
81c58ad
Fixed file name
jsheely Jun 25, 2022
bbaa754
changed nftgame1 to nft-game
gelicamarie Jun 27, 2022
95aa6f4
Changes to add tokenAttributes at mint
Jun 27, 2022
8f39ce1
Fixes in NFTGame.sol
Jun 27, 2022
b1d6374
contract updates
gelicamarie Jun 27, 2022
78ba5b3
js update
gelicamarie Jun 27, 2022
ff47671
Dynamic Attribute v1 Code
Jul 12, 2022
c3c0589
Bug fix
Jul 12, 2022
5abed3f
Pull the right tsconfig
jsheely Jul 12, 2022
b11c93f
Moved code for react merge
jsheely Jul 12, 2022
ae6ed89
Added new methods from contract
jsheely Jul 12, 2022
d83163a
Updated NewInstance story and updated names to work
jsheely Jul 12, 2022
d80cc0e
fixed broken build and added new stories files (almost there)
kendylkey Jul 12, 2022
4f3e4b2
more changes
kendylkey Jul 12, 2022
6512c92
Merge remote-tracking branch 'github-desktop-0xtp/feat/evm-nftgame1' …
kendylkey Jul 12, 2022
3f51a08
all new functions added
kendylkey Jul 13, 2022
7f79669
docs setup step 1 (still need md files)
kendylkey Jul 13, 2022
d36bd60
Level-up bug fixes
Jul 13, 2022
e8cbf2c
intro and stories pages
kendylkey Jul 13, 2022
b9d5f9d
forgot this func
kendylkey Jul 13, 2022
a5579f7
forgot these functions
kendylkey Jul 13, 2022
fc83ada
docs complete
kendylkey Jul 13, 2022
8557f3d
Merge remote-tracking branch 'github-desktop-0xtp/feat/evm-nftgame1' …
kendylkey Jul 13, 2022
053ddf9
deploy script and tests
Jul 13, 2022
727cef3
Adding NFTGame.sol
Jul 13, 2022
13c8879
Merge branch 'main' into pr/0xtp/111
jsheely Jul 13, 2022
101afc2
Updating the NFT game code to the new library code
jsheely Jul 13, 2022
22817a4
Updated NFT-Game to run
jsheely Jul 13, 2022
d53eb7e
Server side minting
jsheely Jul 15, 2022
01595e5
Updated mint stories
jsheely Jul 15, 2022
c71bc28
Updated all the stories to point to /react
jsheely Jul 15, 2022
93d15fa
Include stories for the jsx reference
jsheely Jul 15, 2022
c05732b
Updates to NFT Game demo
jsheely Jul 17, 2022
8297020
Null check
jsheely Jul 17, 2022
badccc9
Clean up
jsheely Jul 17, 2022
b4bcab9
Updated ReadME
jsheely Jul 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions apps/ethereum/nest/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
41 changes: 22 additions & 19 deletions apps/ethereum/nft-game/components/CreateInstance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ import { styled } from '../stitches.config';
import { Button } from './basics/Button';
import { InfoHeading } from './basics/InfoHeading';
import { InputContainer, Label, StyledInput } from './basics/Input';
import { useEthereum } from '@decentology/hyperverse-ethereum';
import { useNFTGame } from '@decentology/hyperverse-evm-nft-game-1';
import { useEthereum } from '@decentology/hyperverse-ethereum/react';
import { useNFTGame } from '@decentology/hyperverse-evm-nft-game/react';
import { useMutation, useQuery } from 'react-query';
import { NavLink } from './basics/NavLink';

export const CreateInstance = () => {
const { account } = useEthereum();
const NFTGame = useNFTGame();

const { data: instance } = useQuery('instance', () => NFTGame.checkInstance!(account), {
enabled: !!NFTGame.factoryContract,
});

const { data: instanceAddress } = useQuery('instanceAddress', () => NFTGame.getProxy!(account), {
enabled: !!NFTGame.factoryContract && !!instance,
enabled: !!NFTGame.factoryContract && !!NFTGame.checkInstance,
});

console.log(instanceAddress);
const { data: instanceAddress } = useQuery(
'instanceAddress',
() => NFTGame.getProxy!(account),
{
enabled: !!NFTGame.factoryContract && !!instance,
}
);

const [tokenName, setTokenName] = React.useState<string>('');
const [tokenSymbol, setTokenSymbol] = React.useState<string>('');
Expand All @@ -47,7 +48,14 @@ export const CreateInstance = () => {
/>
{!!instanceAddress && (
<InfoBox>
<InfoContainer><NavLink to={`https://rinkeby.etherscan.io/address/${instanceAddress}`} external>{instanceAddress}</NavLink></InfoContainer>
<InfoContainer>
<NavLink
to={`https://rinkeby.etherscan.io/address/${instanceAddress}`}
external
>
{instanceAddress}
</NavLink>
</InfoContainer>
</InfoBox>
)}

Expand Down Expand Up @@ -99,15 +107,14 @@ export const Container = styled('div', {

variants: {
instance: {
true : {
true: {
alignItems: 'center',
flexDirection: 'row',
columnGap: 10,
justifyContent: 'space-between',

}
}
}
},
},
},
});

export const Inputs = styled('div', {
Expand Down Expand Up @@ -137,8 +144,6 @@ const InfoBox = styled(Inputs, {
width: '80%',
marginBottom: 0,
display: 'flex',


});

const InfoContainer = styled(InputContainer, {
Expand All @@ -148,6 +153,4 @@ const InfoContainer = styled(InputContainer, {
justifyContent: 'center',
alignItems: 'flex-end',
border: 'none',


});
4 changes: 2 additions & 2 deletions apps/ethereum/nft-game/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TenantMint } from "./Mint"
export const Dashboard = () => {
return (
<Container>
<Heading>NFTGame-1 Module</Heading>
<Heading>NFTGame Module</Heading>

<SubContainer>

Expand Down Expand Up @@ -37,4 +37,4 @@ const SubContainer = styled('div', {
display: 'flex',
flexDirection: 'column',
rowGap: 16,
})
})
10 changes: 5 additions & 5 deletions apps/ethereum/nft-game/components/GetAtrributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { styled } from '../stitches.config';
import { Button } from './basics/Button';
import { InfoHeading } from './basics/InfoHeading';
import { InputContainer, Label, StyledInput } from './basics/Input';
import { useEthereum } from '@decentology/hyperverse-ethereum';
import { useNFTGame } from '@decentology/hyperverse-evm-nft-game-1';
import { useEthereum } from '@decentology/hyperverse-ethereum/react';
import { useNFTGame } from '@decentology/hyperverse-evm-nft-game/react';
import { useMutation, useQuery } from 'react-query';
import { Container, Inputs, ButtonContainer } from './CreateInstance';

Expand All @@ -16,11 +16,11 @@ export const GetAttributes = () => {
enabled: !!NFTGame.factoryContract,
});

const [tokenId, setTokenId] = React.useState<string | undefined>();
const [tokenId, setTokenId] = React.useState<number>();

const { data: attributes, isLoading, refetch } = useQuery(
'attributes',
() => NFTGame.getAttributes!(tokenId),
() => NFTGame.getAttributesByTokenId!(tokenId!),
{
enabled: !!NFTGame.factoryContract,
}
Expand All @@ -39,7 +39,7 @@ export const GetAttributes = () => {
<Label>Token ID</Label>
<StyledInput
placeholder="Token ID"
onChange={(e) => setTokenId(e.target.value)}
onChange={(e) => setTokenId(parseInt(e.target.value))}
/>
</InputContainer>
</Inputs>
Expand Down
2 changes: 1 addition & 1 deletion apps/ethereum/nft-game/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styled } from '../stitches.config'
import { HEADER_LINKS } from '../utils/constants'
import { Github } from './basics/icons'
import { NavLink } from './basics/NavLink'
import { useEthereum } from '@decentology/hyperverse-ethereum'
import { useEthereum } from '@decentology/hyperverse-ethereum/react'
import dynamic from 'next/dynamic'

export function Header() {
Expand Down
74 changes: 63 additions & 11 deletions apps/ethereum/nft-game/components/Mint.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEthereum } from '@decentology/hyperverse-ethereum';
import { useNFTGame } from '@decentology/hyperverse-evm-nft-game-1';
import { useEthereum } from '@decentology/hyperverse-ethereum/react';
import { useNFTGame } from '@decentology/hyperverse-evm-nft-game/react';
import React from 'react';
import { useMutation, useQuery } from 'react-query';
import { styled } from '../stitches.config';
Expand All @@ -18,9 +18,14 @@ export const TenantMint = () => {

const [reciever, setReciever] = React.useState<string>('');
const [tokenName, setTokenName] = React.useState<string>('');
const [eyeId, setEyeId] = React.useState<string>('');
const [mouthId, setMouthId] = React.useState<string>('');
const [bodyId, setBodyId] = React.useState<string>('');
const [eyeId, setEyeId] = React.useState<number>();
const [mouthId, setMouthId] = React.useState<number>();
const [bodyId, setBodyId] = React.useState<number>();
const [level, setLevel] = React.useState<number>();
const [standardChoices, setStandardChoices] = React.useState<string>();
const [standardOptions, setStandardOptions] = React.useState<string>();
const [specialChoices, setSpecialChoices] = React.useState<string>();
const [specialOptions, setSpecialOptions] = React.useState<string>();

const { mutate, isLoading } = useMutation('tenantMint', NFTGame.tenantMint);

Expand All @@ -29,9 +34,14 @@ export const TenantMint = () => {
mutate({
to: reciever,
tokenName,
eyeId,
mouthId,
bodyId,
eyeId: eyeId!,
mouthId: mouthId!,
bodyId: bodyId!,
level: level!,
specialChoices: specialChoices?.split(',').map((x) => parseInt(x)) || [],
specialOptions: specialOptions?.split(',').map((x) => parseInt(x)) || [],
standardChoices: standardChoices?.split(',').map((x) => parseInt(x)) || [],
standardOptions: standardOptions?.split(',').map((x) => parseInt(x)) || [],
});
} catch (error) {
throw error;
Expand Down Expand Up @@ -59,20 +69,62 @@ export const TenantMint = () => {
<Inputs>
<InputContainer>
<Label>Eye Id</Label>
<StyledInput placeholder="Eye Id" onChange={(e) => setEyeId(e.target.value)} />
<StyledInput
placeholder="Eye Id"
onChange={(e) => setEyeId(parseInt(e.target.value))}
/>
</InputContainer>
<InputContainer>
<Label>Mouth Id</Label>
<StyledInput
placeholder="Mouth Id"
onChange={(e) => setMouthId(e.target.value)}
onChange={(e) => setMouthId(parseInt(e.target.value))}
/>
</InputContainer>
<InputContainer>
<Label>Body Id</Label>
<StyledInput
placeholder="Body Id"
onChange={(e) => setBodyId(e.target.value)}
onChange={(e) => setBodyId(parseInt(e.target.value))}
/>
</InputContainer>
<InputContainer>
<Label>Level</Label>
<StyledInput
placeholder="Level"
onChange={(e) => setLevel(parseInt(e.target.value))}
/>
</InputContainer>
</Inputs>
<Inputs>
<InputContainer>
<Label>Standard Choices</Label>
<StyledInput
placeholder="1,1,0,0"
onChange={(e) => setStandardChoices(e.target.value)}
/>
</InputContainer>
<InputContainer>
<Label>Standard Options</Label>
<StyledInput
placeholder="1,1,0,0"
onChange={(e) => setStandardOptions(e.target.value)}
/>
</InputContainer>
</Inputs>
<Inputs>
<InputContainer>
<Label>Special Choices</Label>
<StyledInput
placeholder="0,0"
onChange={(e) => setSpecialChoices(e.target.value)}
/>
</InputContainer>
<InputContainer>
<Label>Special Options</Label>
<StyledInput
placeholder="0,0"
onChange={(e) => setSpecialOptions(e.target.value)}
/>
</InputContainer>
</Inputs>
Expand Down
2 changes: 1 addition & 1 deletion apps/ethereum/nft-game/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const withTM = require('next-transpile-modules')([
'@decentology/unstated-next',
'@decentology/hyperverse',
'@decentology/hyperverse-ethereum',
'@decentology/hyperverse-evm-nft-game-1',
'@decentology/hyperverse-evm-nft-game',
]);

module.exports = withTM({
Expand Down
5 changes: 3 additions & 2 deletions apps/ethereum/nft-game/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@decentology/hyperverse": "workspace:^",
"@decentology/hyperverse-ethereum": "workspace:^",
"@decentology/hyperverse-evm-nft-game-1": "workspace:^",
"@decentology/hyperverse-evm-nft-game": "workspace:^",
"@decentology/unstated-next": "^1.1.1",
"@radix-ui/react-hover-card": "^0.1.5",
"@stitches/react": "^1.2.6",
Expand All @@ -21,7 +21,8 @@
"next-transpile-modules": "^9.0.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-query": "^3.38.0"
"react-query": "^3.38.0",
"react-toastify": "^9.0.5"
},
"devDependencies": {
"@decentology/config": "^1.0.0",
Expand Down
Loading