72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
import { DeployFunction } from "hardhat-deploy/types";
|
|
import { deplayOne, updateArray } from "../scripts/utils"
|
|
|
|
|
|
const deployTokenMall: DeployFunction =
|
|
async function (hre: HardhatRuntimeEnvironment) {
|
|
const provider = hre.ethers.provider;
|
|
const from = await (await provider.getSigner()).getAddress();
|
|
const config = require(`../config/config_${hre.network.name}`);
|
|
const { paywallet, tokenToBuy, paymentTokens, verifier } = config.market
|
|
|
|
// const name = "Test USDC";
|
|
// const symbol = "TUSD";
|
|
// const ret = await hre.deployments.deploy("MintableBaseToken", {
|
|
// from,
|
|
// args: [name, symbol],
|
|
// log: true,
|
|
// });
|
|
// console.log("==MintableBaseToken addr=", ret.address);
|
|
// updateArray({
|
|
// name: "TestUSDC",
|
|
// type: "erc20",
|
|
// json: "assets/contracts/MintableBaseToken.json",
|
|
// address: ret.address,
|
|
// network: hre.network.name,
|
|
// });
|
|
|
|
// const name = "Test Token";
|
|
// const symbol = "TCEC";
|
|
// const ret = await hre.deployments.deploy("MintableBaseToken", {
|
|
// from,
|
|
// args: [name, symbol],
|
|
// log: true,
|
|
// });
|
|
// console.log("==MintableBaseToken addr=", ret.address);
|
|
// updateArray({
|
|
// name: "TestToken",
|
|
// type: "erc20",
|
|
// json: "assets/contracts/MintableBaseToken.json",
|
|
// address: ret.address,
|
|
// network: hre.network.name,
|
|
// });
|
|
|
|
|
|
const tokenMall = await deplayOne({
|
|
hre,
|
|
name: "TokenMall",
|
|
type: "logic",
|
|
contractName: "TokenMall",
|
|
args: [paywallet, tokenToBuy, verifier, 3600],
|
|
verify: true,
|
|
});
|
|
|
|
const tokenMallContract = await hre.ethers.getContractAt("TokenMall", tokenMall.address);
|
|
let tx = await tokenMallContract.updateCurrencySupport(paymentTokens[0], true);
|
|
await tx.wait();
|
|
console.log("==tokenMall updateCurrencySupport");
|
|
|
|
const tokenContract = await hre.ethers.getContractAt("MintableBaseToken", tokenToBuy);
|
|
tx = await tokenContract.mint(paywallet, '1000000000000000000000000');
|
|
await tx.wait();
|
|
console.log("==token minted to tokenMall");
|
|
tx = await tokenContract.approve(tokenMall.address, '1000000000000000000000000');
|
|
await tx.wait();
|
|
console.log("==token approved to tokenMall");
|
|
};
|
|
|
|
deployTokenMall.tags = ["TokenMall"];
|
|
|
|
export default deployTokenMall;
|