-
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.
Merge pull request #7 from itxtoledo/feat/integrations
Feat/integrations
- Loading branch information
Showing
15 changed files
with
608 additions
and
358 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
VITE_WC_PROJECT_ID=b57492a3490d9766ce9d2e3f30f6a755 | ||
VITE_PRESALE_FACTORY=0x016e627e24b8bCD5753afA90FE95E72338f72e12 |
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
52 changes: 52 additions & 0 deletions
52
apps/app/src/components/intgration_components/withdrawETH.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,52 @@ | ||
import { Button } from "@/components/ui/button"; | ||
|
||
import * as React from "react"; | ||
|
||
//importing necessary wagmi contracts integrations | ||
import { | ||
useWriteContract, | ||
useWaitForTransactionReceipt, | ||
type BaseError, | ||
} from "wagmi"; | ||
|
||
// importing contract ABI | ||
import abi from "@tokenization-platform/contracts/abi_ts/contracts/Presale.sol/Presale"; | ||
|
||
export function WithdrawETH() { | ||
const { data: hash, isPending, error, writeContract } = useWriteContract(); | ||
async function submit(e: React.FormEvent<HTMLFormElement>) { | ||
e.preventDefault(); | ||
|
||
writeContract({ | ||
address: "0xE3920963fedC0b83cdd8CBdAB0fce942ee95eD59", | ||
abi, | ||
functionName: "withdrawETH", | ||
}); | ||
} | ||
|
||
const { isLoading: isConfirming, isSuccess: isConfirmed } = | ||
useWaitForTransactionReceipt({ | ||
hash, | ||
}); | ||
|
||
return ( | ||
<form onSubmit={submit}> | ||
<div className="grid gap-4"> | ||
<Button | ||
type="submit" | ||
disabled={isPending} | ||
variant="outline" | ||
className="bg-black text-white" | ||
> | ||
{isPending ? "Confirming..." : "Withdraw ETH"} | ||
</Button> | ||
{hash && <div>Transaction Hash: {hash}</div>} | ||
{isConfirming && <div>Waiting for confirmation...</div>} | ||
{isConfirmed && <div>Transaction confirmed.</div>} | ||
{error && ( | ||
<div>Error: {(error as BaseError).shortMessage || error.message}</div> | ||
)} | ||
</div> | ||
</form> | ||
); | ||
} |
68 changes: 68 additions & 0 deletions
68
apps/app/src/components/intgration_components/withdrawTokens.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,68 @@ | ||
import { Button } from "@/components/ui/button"; | ||
import { Input } from "@/components/ui/input"; | ||
|
||
import * as React from "react"; | ||
|
||
//importing necessary wagmi contracts integrations | ||
import { | ||
useWriteContract, | ||
useWaitForTransactionReceipt, | ||
type BaseError, | ||
} from "wagmi"; | ||
|
||
// importing contract ABI | ||
import abi from "@tokenization-platform/contracts/abi_ts/contracts/Presale.sol/Presale"; | ||
|
||
export function WithdrawToken() { | ||
const { data: hash, isPending, error, writeContract } = useWriteContract(); | ||
async function submit(e: React.FormEvent<HTMLFormElement>) { | ||
e.preventDefault(); | ||
const formData = new FormData(e.target as HTMLFormElement); | ||
const tokenAddress = formData.get("tokenAddress") as "0x{string}"; | ||
|
||
writeContract({ | ||
address: "0xE3920963fedC0b83cdd8CBdAB0fce942ee95eD59", | ||
abi, | ||
functionName: "withdrawToken", | ||
args: [tokenAddress], | ||
}); | ||
} | ||
|
||
const { isLoading: isConfirming, isSuccess: isConfirmed } = | ||
useWaitForTransactionReceipt({ | ||
hash, | ||
}); | ||
|
||
return ( | ||
<form onSubmit={submit}> | ||
<div> | ||
<label htmlFor="recipient" className="block text-muted-foreground mb-1"> | ||
Token Address | ||
</label> | ||
<Input | ||
id="recipient" | ||
type="text" | ||
name="tokenAddress" | ||
placeholder="0x..." | ||
className="w-full" | ||
/> | ||
</div> | ||
<div className="grid gap-4"> | ||
<Button | ||
type="submit" | ||
disabled={isPending} | ||
variant="outline" | ||
className="bg-black text-white" | ||
> | ||
{isPending ? "Confirming..." : "Withdraw Tokens"} | ||
</Button> | ||
{hash && <div>Transaction Hash: {hash}</div>} | ||
{isConfirming && <div>Waiting for confirmation...</div>} | ||
{isConfirmed && <div>Transaction confirmed.</div>} | ||
{error && ( | ||
<div>Error: {(error as BaseError).shortMessage || error.message}</div> | ||
)} | ||
</div> | ||
</form> | ||
); | ||
} |
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.