-
Notifications
You must be signed in to change notification settings - Fork 0
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
19 changed files
with
322 additions
and
2,138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as React from 'react'; | ||
import { useConnectedMetaMask, useMetaMask } from 'metamask-react'; | ||
import Web3Client from '../../web3/Web3Client'; | ||
import Container from '../reusable/Container'; | ||
import Heading from '../reusable/Heading'; | ||
|
||
const Balance = () => { | ||
const { account, ethereum } = useConnectedMetaMask(); | ||
const [balance, setBalance] = React.useState(0); | ||
|
||
React.useEffect(() => { | ||
const client = new Web3Client(account, ethereum); | ||
client.balanceOf(account).then((balance) => { | ||
setBalance(balance); | ||
}); | ||
}); | ||
|
||
return ( | ||
<Container.Container> | ||
<Heading.H2>Your current balance: {balance}</Heading.H2> | ||
</Container.Container> | ||
); | ||
}; | ||
|
||
export default Balance; |
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
51 changes: 51 additions & 0 deletions
51
app/src/js/components/Form/RenounceOwnership/RenounceOwnershipForm.tsx
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,51 @@ | ||
import * as React from 'react'; | ||
import { useConnectedMetaMask } from 'metamask-react'; | ||
|
||
import Container from '../../reusable/Container'; | ||
import Heading from '../../reusable/Heading'; | ||
import Button from '../../reusable/Button'; | ||
import Web3Client from '../../../web3/Web3Client'; | ||
import Alerts from '../../reusable/Alerts'; | ||
|
||
const RenounceOwnershipForm = () => { | ||
const { account, ethereum } = useConnectedMetaMask(); | ||
const [pendingTx, setPendingTx] = React.useState<boolean>(false); | ||
const [error, setError] = React.useState<string>(); | ||
|
||
const onTransfer = () => { | ||
setPendingTx(true); | ||
const client = new Web3Client(account, ethereum); | ||
client | ||
.renounceOwnership() | ||
.then(() => { | ||
setPendingTx(false); | ||
setError(undefined); | ||
}) | ||
.catch((e) => { | ||
setError(e.message); | ||
setPendingTx(false); | ||
}); | ||
}; | ||
|
||
const btnDisabled = pendingTx; | ||
|
||
return ( | ||
<Container.FlexCols className="items-center"> | ||
<Heading.H2>Renounce ownership</Heading.H2> | ||
<Button.Danger | ||
disabled={btnDisabled} | ||
onClick={onTransfer} | ||
className="!mt-4" | ||
> | ||
Renounce ownership | ||
</Button.Danger> | ||
{error && ( | ||
<Alerts.Danger> | ||
<p>{error}</p> | ||
</Alerts.Danger> | ||
)} | ||
</Container.FlexCols> | ||
); | ||
}; | ||
|
||
export default RenounceOwnershipForm; |
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
Oops, something went wrong.