staking 授权

This commit is contained in:
yuyongdong 2024-09-10 17:44:38 +08:00
parent c976b7b5ce
commit d000729ada
2 changed files with 11 additions and 4 deletions

View File

@ -35,11 +35,11 @@ export class ERC20 {
return contract.allowance(owner, spender);
}
async approve(tokenAddress, amount) {
async approve(address, tokenAddress, amount) {
const provider = this.bc.eoaProvider;
this.bc.checkAndChangeChain(chainId, provider);
const contract = new Contract(tokenAddress, erc20Abi, provider.getSigner());
const tx = await contract.approve(amount);
const tx = await contract.approve(address, amount);
await tx.wait();
return tx;
}

View File

@ -138,8 +138,10 @@
<script setup>
import {ref} from "vue";
import stakingDialog from "./cecDialog.vue"
import { STAKING_ADDRESSES } from "@/configs/configchain"
import { BlockChain } from "@/components/chain/BlockChain"
const bc = new BlockChain();
const chainId = parseInt(import.meta.env.VUE_APP_STAKING_CHAIN);
const cecDialogVisible = ref(false)
const handleClose = () => {
cecDialogVisible.value = false
@ -155,8 +157,13 @@ const dialogUnstakeText = ref({
})
const unCecStaked = async () => {
console.log((1*1e18).toString())
let res = await bc.staking.stakeCec((1*1e18).toString())
console.log(STAKING_ADDRESSES[chainId].stakedCecTracker,(1*1e18).toString())
// try{
let res = await bc.erc20.approve(STAKING_ADDRESSES[chainId].stakedCecTracker,(1*1e18).toString())
// } catch (e) {
// console.log(e)
// }
// let res = await bc.staking.stakeCec((1*1e18).toString())
console.log(res)
}