@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
39 lines (38 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mintStargateNFTs = exports.stakeVET = void 0;
const hardhat_1 = require("hardhat");
/**
* Add a Vechain Node token of a specific level to the owner
* @param levelId - The level ID of the node
* @param ownerPrivateKey - The private key of the owner (hex string with 0x prefix)
* @param stargateMock - The StargateMock contract
*/
const stakeVET = async (levelId, owner, stargateMock) => {
if (!stargateMock)
throw new Error("StargateMock not found");
// Create fresh contract instance each call to avoid VeChain adapter bug
// where consecutive calls from the same signer lose calldata (data: '')
const stargateAddress = await stargateMock.getAddress();
const stargate = (await hardhat_1.ethers.getContractAt("Stargate", stargateAddress));
const stargateNFTAddress = await stargate.stargateNFT();
const stargateNFT = await hardhat_1.ethers.getContractAt("StargateNFT", stargateNFTAddress);
const level = await stargateNFT.getLevel(levelId);
if (!level)
throw new Error("Level not found");
const tx = await stargate.connect(owner).stake(levelId, { value: level.vetAmountRequiredToStake, gasLimit: 10000000 });
await tx.wait();
console.log(`Stargate NFT staked with level ${levelId} for owner ${owner.address}`);
};
exports.stakeVET = stakeVET;
/**
* Mint Stargate NFTs for a list of accounts
* @param vechainNodes - The VechainNodesMock contract
* @param accounts - The list of accounts
*/
const mintStargateNFTs = async (stargateMock, accounts, levels) => {
for (let i = 0; i < accounts.length; i++) {
await (0, exports.stakeVET)(levels[i], accounts[i], stargateMock);
}
};
exports.mintStargateNFTs = mintStargateNFTs;