-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
1 parent
7c16c39
commit d05d60f
Showing
3 changed files
with
333 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script lang="ts"> | ||
import { ethers } from "ethers"; | ||
import { HORSE } from "../domain/token"; | ||
import { pendingTransactions } from "../store/transactions"; | ||
import { signer } from "../store/signer"; | ||
import { errorToast, successToast } from "../utils/toast"; | ||
import { _ } from "svelte-i18n"; | ||
import { Funnel } from "svelte-heros-v2"; | ||
import MintableERC20 from "../constants/abi/MintableERC20"; | ||
import { fromChain } from "../store/chain"; | ||
import { switchNetwork } from "@wagmi/core"; | ||
import { CHAIN_MAINNET } from "../domain/chain"; | ||
import Tooltip from "./Tooltip.svelte"; | ||
import TooltipModal from "./modals/TooltipModal.svelte"; | ||
import { token } from "../store/token"; | ||
export let onMint: () => Promise<void>; | ||
let tooltipOpen: boolean = false; | ||
async function mint() { | ||
try { | ||
if ($fromChain.id !== HORSE.addresses[0].chainId) { | ||
await switchNetwork({ | ||
chainId: CHAIN_MAINNET.id, | ||
}); | ||
} | ||
const contract = new ethers.Contract( | ||
HORSE.addresses[0].address, | ||
MintableERC20, | ||
$signer | ||
); | ||
const tx = await contract.mint(ethers.utils.parseEther("1000")); | ||
pendingTransactions.update((store) => { | ||
store.push(tx); | ||
return store; | ||
}); | ||
successToast($_("toast.transactionSent")); | ||
await $signer.provider.waitForTransaction(tx.hash, 1); | ||
await onMint(); | ||
} catch (e) { | ||
console.log(e); | ||
errorToast($_("toast.errorSendingTransaction")); | ||
} | ||
} | ||
</script> | ||
|
||
<button class="btn" on:click={mint}> | ||
<Funnel class="mr-2" /> Faucet | ||
</button> | ||
<Tooltip /> | ||
|
||
<TooltipModal title="{$token.symbol} Faucet" bind:isOpen={tooltipOpen}> | ||
<span slot="body"> | ||
<p class="text-left"> | ||
You can request 1000 {$token.symbol}. {$token.symbol} is only available to | ||
be minted on Ethereum A1. If you are on Taiko A1, your network will be changed | ||
first. You must have a small amount of ether in your Ethereum A1 wallet to | ||
send the transaction. | ||
</p> | ||
</span> | ||
</TooltipModal> |
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,255 @@ | ||
export default [ | ||
{ | ||
inputs: [], | ||
stateMutability: "nonpayable", | ||
type: "constructor", | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
internalType: "address", | ||
name: "owner", | ||
type: "address", | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: "address", | ||
name: "spender", | ||
type: "address", | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: "uint256", | ||
name: "value", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "Approval", | ||
type: "event", | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
internalType: "address", | ||
name: "from", | ||
type: "address", | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: "address", | ||
name: "to", | ||
type: "address", | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: "uint256", | ||
name: "value", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "Transfer", | ||
type: "event", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address", | ||
name: "", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "address", | ||
name: "", | ||
type: "address", | ||
}, | ||
], | ||
name: "allowance", | ||
outputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "", | ||
type: "uint256", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address", | ||
name: "spender", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "approve", | ||
outputs: [ | ||
{ | ||
internalType: "bool", | ||
name: "", | ||
type: "bool", | ||
}, | ||
], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address", | ||
name: "", | ||
type: "address", | ||
}, | ||
], | ||
name: "balanceOf", | ||
outputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "", | ||
type: "uint256", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "burn", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "decimals", | ||
outputs: [ | ||
{ | ||
internalType: "uint8", | ||
name: "", | ||
type: "uint8", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "mint", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "name", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "symbol", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "totalSupply", | ||
outputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "", | ||
type: "uint256", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address", | ||
name: "recipient", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "transfer", | ||
outputs: [ | ||
{ | ||
internalType: "bool", | ||
name: "", | ||
type: "bool", | ||
}, | ||
], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address", | ||
name: "sender", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "address", | ||
name: "recipient", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "transferFrom", | ||
outputs: [ | ||
{ | ||
internalType: "bool", | ||
name: "", | ||
type: "bool", | ||
}, | ||
], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
]; |