-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
573 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Text, Modal, Button } from "@nextui-org/react"; | ||
import { TransactionType } from "../common/types"; | ||
import { useLpNft } from "../hooks/token"; | ||
import { useActionCreator } from "../state/game/hooks"; | ||
|
||
export default ({ visible, closeHandler }) => { | ||
const addAction = useActionCreator(); | ||
|
||
const lpNft = useLpNft(); | ||
|
||
const lpNftTokenAddress = lpNft ? lpNft.tokenAddress : ""; | ||
const lpNftTokenId = lpNft ? lpNft.tokenId : ""; | ||
const lpNftName = lpNft ? lpNft.name : ""; | ||
const lpNftImageUri = lpNft ? lpNft.imageUri : ""; | ||
|
||
const handleDepositLpNft = async () => { | ||
const [depositActionId, wait] = await addAction({ | ||
type: TransactionType.DEPOSIT_LP_NFT, | ||
tokenAddress: lpNftTokenAddress, | ||
tokenId: lpNftTokenId, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
closeButton | ||
aria-labelledby="modal-title" | ||
open={visible} | ||
onClose={closeHandler} | ||
> | ||
<Modal.Header> | ||
<Text id="modal-title" size={18}> | ||
Deposit your LP NFT | ||
</Text> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<h4>{lpNftName}</h4> | ||
<img src={lpNftImageUri} /> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button auto onClick={handleDepositLpNft}> | ||
Deposit | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import * as React from "react"; | ||
import { Text, Modal, Input, Row, Button } from "@nextui-org/react"; | ||
//import { useDispatch } from "react-redux"; | ||
import { FaCoins } from "react-icons/fa"; | ||
import { useActionCreator } from "../state/game/hooks"; | ||
import { TransactionType } from "../common/types"; | ||
import Select from "react-select"; | ||
import { useStableList } from "../hooks/token"; | ||
import { CONTRACTS } from "../ether/contracts"; | ||
|
||
export default ({ visible, closeHandler }) => { | ||
//const dispatch = useDispatch() | ||
const addAction = useActionCreator(); | ||
const [depositValue, setDepositValue] = React.useState(0); | ||
const [stableAddress, setStableAddress] = React.useState(0); | ||
const stableList = useStableList(); | ||
|
||
const stables = stableList.map((stable) => { | ||
return { | ||
value: stable.address, | ||
label: stable.name, | ||
}; | ||
}); | ||
|
||
const onDepositValueChange = (event) => setDepositValue(event.target.value); | ||
const onStableAddressChange = (newValue) => setStableAddress(newValue.value); | ||
const handleMintLpNft = async () => { | ||
// TODO: Get network name | ||
const networkName = "localhost"; | ||
|
||
// Fetch abi list | ||
const contracts = CONTRACTS[networkName]; | ||
const abis = | ||
contracts && contracts.InputFacet && contracts.ERC20PortalFacet | ||
? contracts | ||
: CONTRACTS.localhost; | ||
|
||
// Get the staker contract address | ||
const uniV3StakerAddress = abis.UniV3Staker.address; | ||
|
||
const [approvalActionId, forApproval] = await addAction({ | ||
type: TransactionType.APPROVE_ERC20, | ||
tokenAddress: stableAddress, | ||
spender: uniV3StakerAddress, | ||
amount: depositValue, | ||
}); | ||
|
||
await forApproval; | ||
|
||
const [action, wait] = await addAction({ | ||
type: TransactionType.MINT_LP_NFT, | ||
stableAddress: stableAddress, | ||
stableAmount: depositValue, | ||
}); | ||
|
||
await wait; | ||
}; | ||
|
||
return ( | ||
<Modal | ||
closeButton | ||
aria-labelledby="modal-title" | ||
open={visible} | ||
onClose={closeHandler} | ||
> | ||
<Modal.Header> | ||
<Text id="modal-title" size={18}> | ||
Mint your chess set | ||
</Text> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Row> | ||
<Input | ||
clearable | ||
bordered | ||
fullWidth | ||
color="primary" | ||
size="lg" | ||
placeholder="Deposit amount" | ||
contentLeft={<FaCoins />} | ||
onChange={onDepositValueChange} | ||
/> | ||
<Select options={stables} onChange={onStableAddressChange} /> | ||
</Row> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button auto onClick={handleMintLpNft}> | ||
Mint | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import * as React from "react"; | ||
import { Text, Modal, Input, Row, Button } from "@nextui-org/react"; | ||
import { FaCoins } from "react-icons/fa"; | ||
import { useActionCreator } from "../state/game/hooks"; | ||
import { TransactionType } from "../common/types"; | ||
import Select from "react-select"; | ||
import { useStableList } from "../hooks/token"; | ||
|
||
export default ({ visible, closeHandler }) => { | ||
const addAction = useActionCreator(); | ||
const [depositValue, setMintValue] = React.useState(0); | ||
const [stableAddress, setStableAddress] = React.useState(0); | ||
const stableList = useStableList(); | ||
|
||
const stables = stableList.map((stable) => { | ||
return { | ||
value: stable.address, | ||
label: stable.name, | ||
}; | ||
}); | ||
|
||
const onMintValueChange = (event) => setMintValue(event.target.value); | ||
const onStableAddressChange = (newValue) => setStableAddress(newValue.value); | ||
const handleMintStables = async () => { | ||
await addAction({ | ||
type: TransactionType.MINT_ERC20, | ||
tokenAddress: stableAddress, | ||
tokenAmount: depositValue, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
closeButton | ||
aria-labelledby="modal-title" | ||
open={visible} | ||
onClose={closeHandler} | ||
> | ||
<Modal.Header> | ||
<Text id="modal-title" size={18}> | ||
Mint stable coins | ||
</Text> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Row> | ||
<Input | ||
clearable | ||
bordered | ||
fullWidth | ||
color="primary" | ||
size="lg" | ||
placeholder="Mint amount" | ||
contentLeft={<FaCoins />} | ||
onChange={onMintValueChange} | ||
/> | ||
<Select options={stables} onChange={onStableAddressChange} /> | ||
</Row> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button auto onClick={handleMintStables}> | ||
Mint | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Text, Modal } from "@nextui-org/react"; | ||
import { useLpNft } from "../hooks/token"; | ||
|
||
export default ({ visible, closeHandler }) => { | ||
const lpNft = useLpNft(); | ||
|
||
const lpNftName = lpNft ? lpNft.name : ""; | ||
const lpNftImageUri = lpNft ? lpNft.imageUri : ""; | ||
|
||
return ( | ||
<Modal | ||
closeButton | ||
aria-labelledby="modal-title" | ||
open={visible} | ||
onClose={closeHandler} | ||
> | ||
<Modal.Header> | ||
<Text id="modal-title" size={18}> | ||
View your LP NFT | ||
</Text> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<h4>{lpNftName}</h4> | ||
<img src={lpNftImageUri} /> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
}; |
Oops, something went wrong.