price constraints working

This commit is contained in:
Tim Olson
2023-11-05 16:50:06 -04:00
parent b483974268
commit bec1b33d22
13 changed files with 195 additions and 67 deletions

45
src/components/Faucet.vue Normal file
View File

@@ -0,0 +1,45 @@
<template>
<phone-card v-if="s.mockenv">
<v-card-title><v-icon icon="mdi-faucet"/>&nbsp;Mock Coin Faucet</v-card-title>
<v-card-text>Mockchain provides infinite amounts of MOCK (Mockcoin) and USD (Universally Stable Denomination) for your vault. Click the button below to get a million of each: </v-card-text>
<v-card-item>
<v-table plain>
<tbody>
<tr v-for="token of tokens">
<td><v-btn prepend-icon='mdi-plus' :text="'Gib '+token.symbol" @click="gib(token)" class="my-3" variant="outlined"/></td>
<td>{{token.name}}</td>
</tr>
</tbody>
</v-table>
</v-card-item>
</phone-card>
</template>
<script setup>
import {useStore} from "@/store/store";
import PhoneCard from "@/components/PhoneCard.vue";
import {ethers} from "ethers";
import {computed, ref} from "vue";
import {pendTransaction} from "@/blockchain/wallet.js";
import {mockErc20Abi} from "@/blockchain/abi.js";
const s = useStore()
function gib(token) {
const tokenAddr = token.address
const vault = s.vault
const amount = 1_000_000n * 10n ** BigInt(token.decimals);
async function send(signer) {
return await new ethers.Contract(tokenAddr, mockErc20Abi, signer).mint(vault, amount);
}
pendTransaction(send)
}
const tokens = computed(()=>!s.mockCoins? [] : s.mockCoins.map((addr)=>s.tokens[addr]))
</script>
<style scoped lang="scss">
@use "src/styles/vars" as *;
</style>