added multicall
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { defineStore } from "pinia";
|
||||
import MemeBurnerJson from "@/assets/contracts/MemeBurner.json";
|
||||
import { useTokenStore } from "./tokens";
|
||||
import { useMultiCallStore } from "./multicall";
|
||||
|
||||
export const useMemeburnerStore = defineStore("memeburner", {
|
||||
state: () => ({
|
||||
@@ -15,8 +17,19 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
return await this.contract.methods.rounds(roundnumber).call();
|
||||
},
|
||||
//returns participated, amount achieved
|
||||
async getSacrificedMeme(roundnumber, address) {
|
||||
return await this.contract.methods.getSacrificedMeme(roundnumber, address).call();
|
||||
async getSacrificedMeme(roundnumber, tokenAddress) {
|
||||
return await this.contract.methods.getSacrificedMeme(roundnumber, tokenAddress).call();
|
||||
},
|
||||
async getSacrificedRound(roundnumber) {
|
||||
const tokenStore = useTokenStore();
|
||||
const calls = [];
|
||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||
const token = tokenStore.token[index];
|
||||
calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
|
||||
}
|
||||
const multicallStore = useMultiCallStore();
|
||||
return await multicallStore.aggregate(calls);
|
||||
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { defineStore } from "pinia";
|
||||
import MulticallJson from "@/assets/contracts/Multicall.json";
|
||||
import { useWalletStore } from "./wallet";
|
||||
|
||||
|
||||
export const useMultiCallStore = defineStore("multicall", {
|
||||
state: () => ({
|
||||
config: MulticallJson,
|
||||
contract: null,
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
async aggregate(calls, parameters = {}) {
|
||||
const callRequests = calls.map((call) => {
|
||||
const callData = call.encodeABI();
|
||||
return {
|
||||
target: call._parent._address,
|
||||
callData,
|
||||
};
|
||||
});
|
||||
|
||||
const { returnData } = await this.contract.methods.aggregate(callRequests).call(parameters);
|
||||
|
||||
return returnData.map((hex, index) => {
|
||||
const types = calls[index]._method.outputs.map((o) =>
|
||||
o.internalType !== o.type && o.internalType !== undefined ? o : o.type
|
||||
);
|
||||
const walletStore = useWalletStore();
|
||||
|
||||
let result = walletStore.web3.eth.abi.decodeParameters(types, hex);
|
||||
|
||||
delete result.__length__;
|
||||
|
||||
result = Object.values(result);
|
||||
return result.length === 1 ? result[0] : result;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
+12
-399
@@ -9,393 +9,6 @@ import MemeBurnerJson from "@/assets/contracts/MemeBurner.json";
|
||||
export const useTokenStore = defineStore("token", {
|
||||
state: () => ({
|
||||
token: [
|
||||
// {
|
||||
// name: "PEPE",
|
||||
// contractAddress: "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
|
||||
// abi: [
|
||||
// {
|
||||
// inputs: [{ internalType: "uint256", name: "_totalSupply", type: "uint256" }],
|
||||
// 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: "previousOwner", type: "address" },
|
||||
// { indexed: true, internalType: "address", name: "newOwner", type: "address" },
|
||||
// ],
|
||||
// name: "OwnershipTransferred",
|
||||
// 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: "owner", type: "address" },
|
||||
// { internalType: "address", name: "spender", 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: "account", type: "address" }],
|
||||
// name: "balanceOf",
|
||||
// outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [
|
||||
// { internalType: "address", name: "_address", type: "address" },
|
||||
// { internalType: "bool", name: "_isBlacklisting", type: "bool" },
|
||||
// ],
|
||||
// name: "blacklist",
|
||||
// outputs: [],
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [{ internalType: "address", name: "", type: "address" }],
|
||||
// name: "blacklists",
|
||||
// outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [{ internalType: "uint256", name: "value", type: "uint256" }],
|
||||
// name: "burn",
|
||||
// outputs: [],
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "decimals",
|
||||
// outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [
|
||||
// { internalType: "address", name: "spender", type: "address" },
|
||||
// { internalType: "uint256", name: "subtractedValue", type: "uint256" },
|
||||
// ],
|
||||
// name: "decreaseAllowance",
|
||||
// outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [
|
||||
// { internalType: "address", name: "spender", type: "address" },
|
||||
// { internalType: "uint256", name: "addedValue", type: "uint256" },
|
||||
// ],
|
||||
// name: "increaseAllowance",
|
||||
// outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "limited",
|
||||
// outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "maxHoldingAmount",
|
||||
// outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "minHoldingAmount",
|
||||
// outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "name",
|
||||
// outputs: [{ internalType: "string", name: "", type: "string" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "owner",
|
||||
// outputs: [{ internalType: "address", name: "", type: "address" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "renounceOwnership",
|
||||
// outputs: [],
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [
|
||||
// { internalType: "bool", name: "_limited", type: "bool" },
|
||||
// { internalType: "address", name: "_uniswapV2Pair", type: "address" },
|
||||
// { internalType: "uint256", name: "_maxHoldingAmount", type: "uint256" },
|
||||
// { internalType: "uint256", name: "_minHoldingAmount", type: "uint256" },
|
||||
// ],
|
||||
// name: "setRule",
|
||||
// outputs: [],
|
||||
// stateMutability: "nonpayable",
|
||||
// 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",
|
||||
// },
|
||||
// {
|
||||
// inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
|
||||
// name: "transferOwnership",
|
||||
// outputs: [],
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [],
|
||||
// name: "uniswapV2Pair",
|
||||
// outputs: [{ internalType: "address", name: "", type: "address" }],
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// name: "SHIBA INU",
|
||||
// contractAddress: "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE",
|
||||
// abi: [
|
||||
// {
|
||||
// constant: true,
|
||||
// inputs: [],
|
||||
// name: "name",
|
||||
// outputs: [{ name: "", type: "string" }],
|
||||
// payable: false,
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: false,
|
||||
// inputs: [
|
||||
// { name: "spender", type: "address" },
|
||||
// { name: "value", type: "uint256" },
|
||||
// ],
|
||||
// name: "approve",
|
||||
// outputs: [{ name: "", type: "bool" }],
|
||||
// payable: false,
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: true,
|
||||
// inputs: [],
|
||||
// name: "totalSupply",
|
||||
// outputs: [{ name: "", type: "uint256" }],
|
||||
// payable: false,
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: false,
|
||||
// inputs: [
|
||||
// { name: "sender", type: "address" },
|
||||
// { name: "recipient", type: "address" },
|
||||
// { name: "amount", type: "uint256" },
|
||||
// ],
|
||||
// name: "transferFrom",
|
||||
// outputs: [{ name: "", type: "bool" }],
|
||||
// payable: false,
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: true,
|
||||
// inputs: [],
|
||||
// name: "decimals",
|
||||
// outputs: [{ name: "", type: "uint8" }],
|
||||
// payable: false,
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: false,
|
||||
// inputs: [
|
||||
// { name: "spender", type: "address" },
|
||||
// { name: "addedValue", type: "uint256" },
|
||||
// ],
|
||||
// name: "increaseAllowance",
|
||||
// outputs: [{ name: "", type: "bool" }],
|
||||
// payable: false,
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: false,
|
||||
// inputs: [{ name: "value", type: "uint256" }],
|
||||
// name: "burn",
|
||||
// outputs: [],
|
||||
// payable: false,
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: true,
|
||||
// inputs: [{ name: "account", type: "address" }],
|
||||
// name: "balanceOf",
|
||||
// outputs: [{ name: "", type: "uint256" }],
|
||||
// payable: false,
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: true,
|
||||
// inputs: [],
|
||||
// name: "symbol",
|
||||
// outputs: [{ name: "", type: "string" }],
|
||||
// payable: false,
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: false,
|
||||
// inputs: [
|
||||
// { name: "spender", type: "address" },
|
||||
// { name: "subtractedValue", type: "uint256" },
|
||||
// ],
|
||||
// name: "decreaseAllowance",
|
||||
// outputs: [{ name: "", type: "bool" }],
|
||||
// payable: false,
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: false,
|
||||
// inputs: [
|
||||
// { name: "recipient", type: "address" },
|
||||
// { name: "amount", type: "uint256" },
|
||||
// ],
|
||||
// name: "transfer",
|
||||
// outputs: [{ name: "", type: "bool" }],
|
||||
// payable: false,
|
||||
// stateMutability: "nonpayable",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// constant: true,
|
||||
// inputs: [
|
||||
// { name: "owner", type: "address" },
|
||||
// { name: "spender", type: "address" },
|
||||
// ],
|
||||
// name: "allowance",
|
||||
// outputs: [{ name: "", type: "uint256" }],
|
||||
// payable: false,
|
||||
// stateMutability: "view",
|
||||
// type: "function",
|
||||
// },
|
||||
// {
|
||||
// inputs: [
|
||||
// { name: "name", type: "string" },
|
||||
// { name: "symbol", type: "string" },
|
||||
// { name: "decimals", type: "uint8" },
|
||||
// { name: "totalSupply", type: "uint256" },
|
||||
// { name: "feeReceiver", type: "address" },
|
||||
// { name: "tokenOwnerAddress", type: "address" },
|
||||
// ],
|
||||
// payable: true,
|
||||
// stateMutability: "payable",
|
||||
// type: "constructor",
|
||||
// },
|
||||
// {
|
||||
// anonymous: false,
|
||||
// inputs: [
|
||||
// { indexed: true, name: "from", type: "address" },
|
||||
// { indexed: true, name: "to", type: "address" },
|
||||
// { indexed: false, name: "value", type: "uint256" },
|
||||
// ],
|
||||
// name: "Transfer",
|
||||
// type: "event",
|
||||
// },
|
||||
// {
|
||||
// anonymous: false,
|
||||
// inputs: [
|
||||
// { indexed: true, name: "owner", type: "address" },
|
||||
// { indexed: true, name: "spender", type: "address" },
|
||||
// { indexed: false, name: "value", type: "uint256" },
|
||||
// ],
|
||||
// name: "Approval",
|
||||
// type: "event",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
name: "$PEPE",
|
||||
logo: "/src/assets/img/token/pepe.png",
|
||||
@@ -406,7 +19,7 @@ export const useTokenStore = defineStore("token", {
|
||||
},
|
||||
backgroundColor: "#4b8501",
|
||||
abi: Meme1Json.abi,
|
||||
contractAddress: Meme1Json.contractAddress,
|
||||
contractAddress: Meme1Json.contractAddress,
|
||||
},
|
||||
{
|
||||
name: "$SHIB",
|
||||
@@ -419,17 +32,17 @@ export const useTokenStore = defineStore("token", {
|
||||
abi: Meme2Json.abi,
|
||||
contractAddress: Meme2Json.contractAddress,
|
||||
},
|
||||
{
|
||||
name: "$ELON",
|
||||
logo: "/src/assets/img/token/elon.png",
|
||||
logoMobile: "/src/assets/img/token/elonMobile.png",
|
||||
vamp: {
|
||||
logo: "/src/assets/img/token/shibvamp.png",
|
||||
name: "$ELON Vamp Token",
|
||||
},
|
||||
abi: null,
|
||||
contractAddress: null,
|
||||
},
|
||||
// {
|
||||
// name: "$ELON",
|
||||
// logo: "/src/assets/img/token/elon.png",
|
||||
// logoMobile: "/src/assets/img/token/elonMobile.png",
|
||||
// vamp: {
|
||||
// logo: "/src/assets/img/token/shibvamp.png",
|
||||
// name: "$ELON Vamp Token",
|
||||
// },
|
||||
// abi: null,
|
||||
// contractAddress: null,
|
||||
// },
|
||||
],
|
||||
activeToken: {
|
||||
address: null,
|
||||
|
||||
@@ -6,7 +6,8 @@ export const useWalletStore = defineStore("wallet", {
|
||||
count: 0,
|
||||
alchemy: null,
|
||||
connected: false,
|
||||
address: null,
|
||||
address: null,
|
||||
web3: null
|
||||
}),
|
||||
getters: {
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user