UNPKG

@firmachain/firma-js

Version:

The Official FirmaChain Javascript SDK written in Typescript

729 lines (728 loc) 36.6 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); var chai_1 = require("chai"); var FirmaSDK_1 = require("../sdk/FirmaSDK"); var FirmaUtil_1 = require("../sdk/FirmaUtil"); var common_1 = require("../sdk/firmachain/common"); var config_test_1 = require("./config_test"); describe('[08. Gas Estimation Test]', function () { var firma; var aliceWallet; var bobWallet; var aliceAddress; var bobAddress; var validatorWallet; var validatorAddress; var valOperAddress; var extractValue = function (events, eventType, attrKey) { var e_1, _a, e_2, _b; try { for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { var event_1 = events_1_1.value; if (event_1.type === eventType) { try { for (var _c = (e_2 = void 0, __values(event_1.attributes)), _d = _c.next(); !_d.done; _d = _c.next()) { var attr = _d.value; if (attr.key === attrKey) { return attr.value; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_d && !_d.done && (_b = _c.return)) _b.call(_c); } finally { if (e_2) throw e_2.error; } } } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1); } finally { if (e_1) throw e_1.error; } } return ""; }; beforeEach(function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig); return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)]; case 1: aliceWallet = _a.sent(); return [4 /*yield*/, aliceWallet.getAddress()]; case 2: aliceAddress = _a.sent(); return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)]; case 3: bobWallet = _a.sent(); return [4 /*yield*/, bobWallet.getAddress()]; case 4: bobAddress = _a.sent(); return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.validatorMnemonic)]; case 5: validatorWallet = _a.sent(); return [4 /*yield*/, validatorWallet.getAddress()]; case 6: validatorAddress = _a.sent(); valOperAddress = FirmaUtil_1.FirmaUtil.getValOperAddressFromAccAddress(validatorAddress); return [2 /*return*/]; } }); }); }); it("1-1. bank send gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var amount, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: amount = 1; return [4 /*yield*/, firma.Bank.getGasEstimationSend(aliceWallet, bobAddress, amount)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("1-2. bank sendToken gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var timestamp, tokenName, tokenId, tokenSymbol, tokenURI, tokenSupply, decimal, mintAmount, sendAmount, createResult, mintResult, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: timestamp = Math.round(+new Date() / 1000); tokenName = "KOMX TOKEN"; tokenId = "ukomx".concat(timestamp); tokenSymbol = "KOMX".concat(timestamp); tokenURI = "https://token.firmachain.dev"; tokenSupply = 100000000; decimal = 6; mintAmount = 10; sendAmount = 1; return [4 /*yield*/, firma.Token.createToken(aliceWallet, tokenName, tokenSymbol, tokenURI, tokenSupply, decimal, true, true)]; case 1: createResult = _a.sent(); (0, chai_1.expect)(createResult.code).to.be.equal(0); return [4 /*yield*/, firma.Token.mint(aliceWallet, tokenId, mintAmount, decimal, aliceAddress)]; case 2: mintResult = _a.sent(); (0, chai_1.expect)(mintResult.code).to.be.equal(0); return [4 /*yield*/, firma.Bank.getGasEstimationSendToken(aliceWallet, bobAddress, tokenId, sendAmount, decimal)]; case 3: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("2-1. Contract addContractLog getGasEstimationFromUnSignedTxList gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var contractHash, timeStamp, eventName, ownerAddress, jsonString, tx1, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: contractHash = "0xsalkdjfasldkjf2"; timeStamp = Math.round(+new Date() / 1000); ; eventName = "CreateContract"; ownerAddress = aliceAddress; jsonString = "{}"; return [4 /*yield*/, firma.Contract.getUnsignedTxAddContractLog(aliceWallet, contractHash, timeStamp, eventName, ownerAddress, jsonString)]; case 1: tx1 = _a.sent(); return [4 /*yield*/, firma.Contract.getGasEstimationFromUnSignedTxList(aliceWallet, [tx1, tx1, tx1, tx1, tx1])]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("2-2. Contract addContractLog gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var contractHash, timeStamp, eventName, ownerAddress, jsonString, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: contractHash = "0xsalkdjfasldkjf2"; timeStamp = Math.round(+new Date() / 1000); ; eventName = "CreateContract"; ownerAddress = aliceAddress; jsonString = "{}"; return [4 /*yield*/, firma.Contract.getGasEstimationAddContractLog(aliceWallet, contractHash, timeStamp, eventName, ownerAddress, jsonString)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("2-3. Contract createContractFile gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var timeStamp, fileHash, ownerAddress, ownerList, jsonString, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: timeStamp = Math.round(+new Date() / 1000); fileHash = "0xklsdjflaksjflaksjf" + timeStamp; ownerAddress = aliceAddress; ownerList = [ownerAddress, bobAddress]; jsonString = "{}"; return [4 /*yield*/, firma.Contract.getGasEstimationCreateContractFile(aliceWallet, fileHash, timeStamp, ownerList, jsonString)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("3-1. NFT Mint gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var gas; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, firma.Nft.getGasEstimationMint(aliceWallet, "https://naver.com")]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("3-2. NFT Transfer gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var result, nftId, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, firma.Nft.mint(aliceWallet, "https://naver.com")]; case 1: result = _a.sent(); (0, chai_1.expect)(result.code).to.be.equal(0); nftId = extractValue(result.events, "message", "nftID"); return [4 /*yield*/, firma.Nft.getGasEstimationTransfer(aliceWallet, bobAddress, nftId)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("3-3. NFT Burn gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var result, nftId, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, firma.Nft.mint(aliceWallet, "https://naver.com")]; case 1: result = _a.sent(); (0, chai_1.expect)(result.code).to.be.equal(0); nftId = extractValue(result.events, "message", "nftID"); return [4 /*yield*/, firma.Nft.getGasEstimationBurn(aliceWallet, nftId)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("4-1. Feegrant GrantPeriodicAllowance gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var spendAmount, expirationDate, periodicAllowanceData, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: spendAmount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr("10"); expirationDate = new Date(); periodicAllowanceData = { basic: { spendLimit: [ { amount: spendAmount, denom: firma.Config.denom } ] }, period: { seconds: BigInt(60 * 60 * 24), nanos: 0 }, periodSpendLimit: [ { amount: spendAmount, denom: firma.Config.denom } ], periodCanSpend: [ { amount: spendAmount, denom: firma.Config.denom } ], periodReset: { seconds: BigInt(Math.floor(expirationDate.getTime() / 1000)), nanos: (expirationDate.getTime() % 1000) * 1000000 } }; return [4 /*yield*/, firma.FeeGrant.getGasEstimationGrantPeriodicAllowance(bobWallet, aliceAddress, periodicAllowanceData)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("4-2. Feegrant GrantBasicAllowance gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var basicAllowance, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: basicAllowance = { spendLimit: [ { amount: "20000", denom: firma.Config.denom } ] }; return [4 /*yield*/, firma.FeeGrant.getGasEstimationGrantBasicAllowance(bobWallet, aliceAddress, basicAllowance)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("4-3. Feegrant revokeAllowance gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var error_1, basicAllowance, result, gas, fee; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, firma.FeeGrant.revokeAllowance(aliceWallet, bobAddress)]; case 1: _a.sent(); return [3 /*break*/, 3]; case 2: error_1 = _a.sent(); return [3 /*break*/, 3]; case 3: basicAllowance = { spendLimit: [ { amount: "20000", denom: firma.Config.denom } ] }; return [4 /*yield*/, firma.FeeGrant.grantBasicAllowance(aliceWallet, bobAddress, basicAllowance)]; case 4: result = _a.sent(); (0, chai_1.expect)(result.code).to.equal(0); return [4 /*yield*/, firma.FeeGrant.getGasEstimationRevokeAllowance(aliceWallet, bobAddress)]; case 5: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); fee = Math.ceil(gas * 0.1); return [4 /*yield*/, firma.FeeGrant.revokeAllowance(aliceWallet, bobAddress, { gas: gas, fee: fee })]; case 6: _a.sent(); return [2 /*return*/]; } }); }); }); it("5-1. Staking delegate gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var amountFCT, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: amountFCT = 60; return [4 /*yield*/, firma.Staking.getGasEstimationDelegate(aliceWallet, valOperAddress, amountFCT)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("5-2. Staking undelegate gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var amount, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: amount = 5; return [4 /*yield*/, firma.Staking.getGasEstimationUndelegate(aliceWallet, valOperAddress, amount)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); /* This test may fail even with a valid call due to the following two reasons: - The maximum number of allowed redelegations (7) has been exceeded - There are no delegated tokens to the srcValidatorAddress */ it("5-3. Staking redelegate gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var validatorList, srcValidatorAddress, dstValidatorAddress, amount, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, firma.Staking.getValidatorList()]; case 1: validatorList = (_a.sent()).dataList; if (validatorList.length < 2) return [2 /*return*/]; srcValidatorAddress = validatorList[0].operator_address; dstValidatorAddress = validatorList[1].operator_address; amount = 10; return [4 /*yield*/, firma.Staking.getGasEstimationRedelegate(aliceWallet, srcValidatorAddress, dstValidatorAddress, amount, { gas: 300000, fee: 30000 })]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("6-1. Distribution withdrawAllRewards gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var delegationList, validatorAddress, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, firma.Staking.getTotalDelegationInfo(aliceAddress)]; case 1: delegationList = (_a.sent()).dataList; validatorAddress = delegationList[0].delegation.validator_address; return [4 /*yield*/, firma.Distribution.getGasEstimationWithdrawAllRewards(aliceWallet, validatorAddress)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("6-2. Distribution withdrawValidatorCommission gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var valOperAddress, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: valOperAddress = FirmaUtil_1.FirmaUtil.getValOperAddressFromAccAddress(validatorAddress); return [4 /*yield*/, firma.Distribution.getGasEstimationWithdrawValidatorCommission(validatorWallet, valOperAddress)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("6-3. Distribution fundCommunityPool gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var amount, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: amount = 1; return [4 /*yield*/, firma.Distribution.getGasEstimationFundCommunityPool(validatorWallet, amount)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("6-4. Distribution setWithdrawAddress gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var gas; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, firma.Distribution.getGasEstimationSetWithdrawAddress(aliceWallet, bobAddress)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("7-1. Gov submitTextProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var initialDepositFCT, title, description, gas, error_2; return __generator(this, function (_a) { switch (_a.label) { case 0: initialDepositFCT = 2500; title = "test submit proposal"; description = "test description"; _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, firma.Gov.getGasEstimationSubmitTextProposal(aliceWallet, title, description, initialDepositFCT)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [3 /*break*/, 4]; case 3: error_2 = _a.sent(); console.log(error_2); return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } }); }); }); it("7-2. Gov submitCommunityPoolSpendProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var initialDepositFCT, title, summary, amountFCT, recipient, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: initialDepositFCT = 2500; title = "Community spend proposal"; summary = "Proposal to spend from community pool"; amountFCT = 1000; recipient = bobAddress; return [4 /*yield*/, firma.Gov.getGasEstimationSubmitCommunityPoolSpendProposal(aliceWallet, title, summary, initialDepositFCT, amountFCT, recipient)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("7-3. Gov submitStakingParamsUpdateProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var initialDepositFCT, title, summary, params, metadata, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: initialDepositFCT = 2500; title = "Staking parameter change proposal"; summary = "This is a Staking parameter change proposal"; return [4 /*yield*/, firma.Staking.getParamsAsStakingParams()]; case 1: params = _a.sent(); params.maxValidators = 100; params.minCommissionRate = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(params.minCommissionRate); metadata = ""; return [4 /*yield*/, firma.Gov.getGasEstimationSubmitStakingParamsUpdateProposal(aliceWallet, title, summary, initialDepositFCT, params, metadata)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("7-4, Gov submitGovParamsUpdateProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var initialDepositFCT, title, summary, params, metadata, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: initialDepositFCT = 5000; title = "Gov parameter change proposal"; summary = "This is a Gov parameter change proposal"; return [4 /*yield*/, firma.Gov.getParamAsGovParams()]; case 1: params = _a.sent(); params.burnProposalDepositPrevote = true; metadata = ""; return [4 /*yield*/, firma.Gov.getGasEstimationSubmitGovParamsUpdateProposal(aliceWallet, title, summary, initialDepositFCT, params, metadata)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("7-5. Gov submitSoftwareUpgradeProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var initialDepositFCT, title, summary, plan, metadata, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: initialDepositFCT = 5000; title = "Software Upgrade proposal1"; summary = "This is a software upgrade proposal"; plan = { name: 'v0.5.1', time: { seconds: BigInt(0), nanos: 0 }, height: BigInt(1050000), info: '' }; metadata = ""; return [4 /*yield*/, firma.Gov.getGasEstimationSubmitSoftwareUpgradeProposal(aliceWallet, title, summary, initialDepositFCT, plan, metadata)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("7-6. Gov deposit gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var initialDepositFCT, title, description, result, proposalId, amount, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: initialDepositFCT = 2500; title = "test submit textProposal(deposit gas)"; description = "test description"; return [4 /*yield*/, firma.Gov.submitTextProposal(aliceWallet, title, description, initialDepositFCT)]; case 1: result = _a.sent(); proposalId = extractValue(result.events, "submit_proposal", "proposal_id"); amount = 1000; return [4 /*yield*/, firma.Gov.getGasEstimationDeposit(aliceWallet, proposalId, amount)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("7-7. Gov vote gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var initialDepositFCT, title, description, result, proposalId, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: initialDepositFCT = 5000; title = "test submit textProposal(vote gas)"; description = "test description"; return [4 /*yield*/, firma.Gov.submitTextProposal(aliceWallet, title, description, initialDepositFCT)]; case 1: result = _a.sent(); proposalId = extractValue(result.events, "submit_proposal", "proposal_id"); return [4 /*yield*/, firma.Gov.getGasEstimationVote(aliceWallet, proposalId, common_1.VotingOption.VOTE_OPTION_YES)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("8-1. Token createToken gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: tokenName = "KOMX TOKEN"; symbol = "KOMX63232"; tokenURI = "https://naver.com"; totalSupply = 10000; decimal = 6; mintable = true; burnable = true; return [4 /*yield*/, firma.Token.getGasEstimationCreateToken(aliceWallet, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable)]; case 1: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("8-2. Token mint gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var timeStamp, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable, createResult, tokenID, amount, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: timeStamp = Math.round(+new Date() / 1000); tokenName = "KOMX TOKEN" + timeStamp; symbol = "KOMX" + timeStamp; tokenURI = "https://naver.com"; totalSupply = 10000; decimal = 6; mintable = true; burnable = true; return [4 /*yield*/, firma.Token.createToken(aliceWallet, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable)]; case 1: createResult = _a.sent(); (0, chai_1.expect)(createResult.code).to.equal(0); tokenID = "ukomx" + timeStamp; amount = 10000; return [4 /*yield*/, firma.Token.getGasEstimationMint(aliceWallet, tokenID, amount, decimal, bobAddress)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("8-3. Token burn gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var timeStamp, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable, createResult, tokenID, amount, mintResult, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: timeStamp = Math.round(+new Date() / 1000); tokenName = "KOMX TOKEN" + timeStamp; symbol = "KOMX" + timeStamp; tokenURI = "https://naver.com"; totalSupply = 10000; decimal = 6; mintable = true; burnable = true; return [4 /*yield*/, firma.Token.createToken(aliceWallet, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable)]; case 1: createResult = _a.sent(); (0, chai_1.expect)(createResult.code).to.equal(0); tokenID = "ukomx" + timeStamp; amount = 10; return [4 /*yield*/, firma.Token.mint(aliceWallet, tokenID, amount, decimal, bobAddress)]; case 2: mintResult = _a.sent(); (0, chai_1.expect)(mintResult.code).to.equal(0); return [4 /*yield*/, firma.Token.getGasEstimationBurn(aliceWallet, tokenID, amount, decimal)]; case 3: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); it("8-4. Token updateTokenURI gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () { var timeStamp, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable, createResult, tokenID, newTokenURI, gas; return __generator(this, function (_a) { switch (_a.label) { case 0: timeStamp = Math.round(+new Date() / 1000); tokenName = "KOMX TOKEN" + timeStamp; symbol = "KOMX" + timeStamp; tokenURI = "https://naver.com"; totalSupply = 10000; decimal = 6; mintable = true; burnable = true; return [4 /*yield*/, firma.Token.createToken(aliceWallet, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable)]; case 1: createResult = _a.sent(); (0, chai_1.expect)(createResult.code).to.equal(0); tokenID = "ukomx" + timeStamp; newTokenURI = "https://firmachain.org"; return [4 /*yield*/, firma.Token.getGasEstimationUpdateTokenURI(aliceWallet, tokenID, newTokenURI)]; case 2: gas = _a.sent(); (0, chai_1.expect)(gas).to.not.equal(0); return [2 /*return*/]; } }); }); }); });