UNPKG

@vechain/vebetterdao-contracts

Version:

Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.

32 lines (31 loc) 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertB3trForVot3 = void 0; const typechain_types_1 = require("../../typechain-types"); const sdk_core_1 = require("@vechain/sdk-core"); const utils_1 = require("@repo/utils"); const chunk_1 = require("./chunk"); const config_1 = require("@repo/config"); const sdk_network_1 = require("@vechain/sdk-network"); const thorClient = sdk_network_1.ThorClient.at((0, config_1.getConfig)().nodeUrl); const convertB3trForVot3 = async (b3tr, vot3, accounts) => { console.log(`Converting B3TR for VOT3...`); const acctChunks = (0, chunk_1.chunk)(accounts, 100); const b3trAddr = await b3tr.getAddress(); const vot3Addr = await vot3.getAddress(); for (const chunk of acctChunks) { await Promise.all(chunk.map(async (account) => { const clauses = []; const b3trAmount = await b3tr.balanceOf(account.key.address.toString()); clauses.push(sdk_core_1.Clause.callFunction(sdk_core_1.Address.of(b3trAddr), sdk_core_1.ABIContract.ofAbi(typechain_types_1.B3TR__factory.abi).getFunction("approve"), [ vot3Addr, b3trAmount, ])); clauses.push(sdk_core_1.Clause.callFunction(sdk_core_1.Address.of(vot3Addr), sdk_core_1.ABIContract.ofAbi(typechain_types_1.VOT3__factory.abi).getFunction("convertToVOT3"), [ b3trAmount, ])); await utils_1.TransactionUtils.sendTx(thorClient, clauses, account.key.pk); })); } }; exports.convertB3trForVot3 = convertB3trForVot3;