UNPKG

@ledgerhq/coin-tron

Version:
1,101 lines (1,099 loc) 60.2 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.dataset = void 0; const errors_1 = require("@ledgerhq/errors"); const bignumber_js_1 = require("bignumber.js"); const invariant_1 = __importDefault(require("invariant")); const transaction_1 = require("../bridge/transaction"); const constants_1 = require("../logic/constants"); const errors_2 = require("../types/errors"); const unactivatedAddress = "TXFeV31qgUQYMLog3axKJeEBbXpQFtHsXD"; const activatedAddress1 = "TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9"; const expectedTokenAccount = (a) => { (0, invariant_1.default)(a && a.type === "TokenAccount", "expected token account"); return a; }; const getTokenAccountId = (account, id) => expectedTokenAccount((account.subAccounts || []).find(a => expectedTokenAccount(a).token.id === id)).id; const tron = { FIXME_ignoreAccountFields: [ "tronResources.cacheTransactionInfoById", // this is a cache, don't save it "tronResources.unwithdrawnReward", // it changes every vote cycles "tronResources.bandwidth", // it changes if a tx is made "tronResources.energy", // it keep changing? ], scanAccounts: [ { name: "tron seed 1", apdus: ` => e00200000d038000002c800000c380000000 <= 41049fc19cbc6d0f525b1c6947b4a36aec74b48e15f2531c5e7e58d272c9e926786da290eb3505d8fab9c83818c1174d9bc96fd18e0527365cba6b9534d43ad5052b2254546962427833526b4a4d6355394171357348337a376a5733455057676b324252419000 => e002000015058000002c800000c3800000000000000000000000 <= 41040897dbec3465fcfa24324d6be690bccab3bdb5bba7f7cbe756d58362336a91a4a8b9bdd0cb25cb97afdde08c85c2081f3a3a4ba96a012c91c835e992783ceca1225452716b526e416a3663654a4659416e3270316545376157726742427774646853399000 => e002000015058000002c800000c3800000010000000000000000 <= 4104af6028b35cd69b028df9bd1a8eccc9f7cc46ca916babe1b87500e17a65b8833e0d4a90e6ba7cfd76492378f43868cc48c89451362033cf5982f2fba92306fc95225448416534424e56787032393371677951457158456b484d705063717447373362699000 => e002000015058000002c800000c3800000020000000000000000 <= 410461936750537e962cb02353c8906cebfd61f35ee0b704be0a02640e5f2e0bb152c0614008db5753fc728cb4fd1eac47f843229ccb928890f3ac805d8cdb6b8e332254576570556e79427a487832616f45674e476f745a484379625a4a5a6531414864579000 => e002000015058000002c800000c3800000030000000000000000 <= 4104fd0fa05cefc7c50894935125c1777bba938043e19ad96fd62d4ee708e5bc5b610f401becc0b4ecb48370e1bbaf4afda6e11b425b424c8ff007205034164399392254544250424b316e386e5831566b5950683766734d35364b4c36473948524d3756639000 => e002000015058000002c800000c3800000040000000000000000 <= 41041da2283f752d855d858ea3b86ef44ed78def4878000e2508ed1a4ca5fce6a120a1f3edfbc14173577057b62e156f4a110410d886bb022e398cf607d8eb26f0c12254527a4164386b37386f623577545748657065447051727555754b596666683438789000 => e002000015058000002c800000c3800000050000000000000000 <= 4104dfeedfe3ec947d26b9b2be199c4d2a1b59b53ce8938fa37a3ebfccba5cd3432457987972d62f5ff7cebffba1655efe26324e25ae1c33d4c6b39d1ccf1a6c433f2254434b4655664672384555394356664b7a7138764c50786b5a5647347641657754649000 => e002000015058000002c800000c3800000060000000000000000 <= 4104f0bc4270d8d593486409062058abeabb87a0f2907b57d0f92a9173164e39b1a12a61ffce4c002f395cab8a790ccd00d41e056a32d285a01b218334d294abbf1f2254526552347a64464537384e614b67555555654869564758534763434434634e796a9000 => e002000015058000002c800000c3800000070000000000000000 <= 4104ac3f861b2006b1d950677b0ac77cc660a497d9e3afcb6caeb2bf4a67943535d56c0915fbd7476e93d50317fd13084ff3eb820a60cc448627e2e1be51c6145dc8225458466556333171675551594d4c6f673361784b4a654542625870514674487358449000 `, }, ], accounts: [ { transactions: [ { name: "sendSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: activatedAddress1, amount: "1000000", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "Send max", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: activatedAddress1, amount: "0", useAllAmount: true, networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: account => ({ amount: account.spendableBalance, errors: {}, warnings: {}, totalSpent: account.spendableBalance, estimatedFees: new bignumber_js_1.BigNumber("0"), }), }, { name: "useAllAmountToUnactivatedAddressSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: unactivatedAddress, amount: "0", useAllAmount: true, networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: (account, _transaction, status) => { return { amount: account.spendableBalance.minus(status.estimatedFees), errors: {}, warnings: {}, totalSpent: account.spendableBalance, }; }, }, { name: "voteSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: activatedAddress1, amount: "0", networkInfo: null, mode: "vote", duration: undefined, resource: undefined, votes: [ { name: "Node 1", address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH", voteCount: 1, }, { name: "Node 2", address: "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U", voteCount: 1, }, ], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "freezeBandwidthSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "1000000", networkInfo: null, mode: "freeze", duration: undefined, resource: "BANDWIDTH", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "freezeEnergySuccess", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "1000000", networkInfo: null, mode: "freeze", duration: undefined, resource: "ENERGY", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "NotEnoughFrozenEnergy", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM", amount: "1000000", networkInfo: null, mode: "unfreeze", duration: undefined, resource: "ENERGY", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { resource: new errors_2.TronNoFrozenForEnergy(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "NotEnoughFrozenBandwidth", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM", amount: "1000000", networkInfo: null, mode: "unfreeze", duration: undefined, resource: "BANDWIDTH", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { resource: new errors_2.TronNoFrozenForBandwidth(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "NoUnfrozenBalances", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "0", networkInfo: null, mode: "withdrawExpireUnfreeze", duration: undefined, votes: [], resource: undefined, }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { resource: new errors_2.TronNoUnfrozenResource(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "InvalidUnDelegateResourceAmount", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM", amount: "100", networkInfo: null, mode: "unDelegateResource", duration: undefined, resource: "BANDWIDTH", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { resource: new errors_2.TronInvalidUnDelegateResourceAmount(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "recipientRequired", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "1000000", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: { recipient: new errors_1.RecipientRequired(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "invalidRecipientIsTheSame", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi", amount: "1000000", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: { recipient: new errors_1.InvalidAddressBecauseDestinationIsAlsoSource(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "invalidRecipientUnknown", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "unknown", amount: "1000000", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: { recipient: new errors_1.InvalidAddress(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "amountRequired", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: activatedAddress1, amount: "0", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { amount: new errors_1.AmountRequired(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "notEnoughBalance", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: activatedAddress1, amount: "1000000000", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000000"), errors: { amount: new errors_1.NotEnoughBalance(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "notEnoughBalance to unactivated", transaction: t => ({ ...t, amount: new bignumber_js_1.BigNumber(100), recipient: unactivatedAddress, }), expectedStatus: () => ({ estimatedFees: constants_1.ACTIVATION_FEES, }), }, { name: "enoughBalance near the max", transaction: (t, account) => ({ ...t, recipient: unactivatedAddress, amount: account.spendableBalance.minus(constants_1.ACTIVATION_FEES).minus(1), }), expectedStatus: () => ({ errors: {}, }), }, { name: "enoughBalance at exactly the max", transaction: (t, account) => ({ ...t, recipient: unactivatedAddress, amount: account.spendableBalance.minus(constants_1.ACTIVATION_FEES), }), expectedStatus: () => ({ errors: {}, }), }, { name: "estimatedFeesWarning", // send 1TRX to new account = +0.1TRX of fees transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: unactivatedAddress, amount: "1000000", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: {}, warnings: { fee: new errors_2.TronUnexpectedFees("Estimated fees"), }, totalSpent: new bignumber_js_1.BigNumber("2100000"), estimatedFees: new bignumber_js_1.BigNumber("1100000"), }, }, { name: "tronSendTrc20ToContractAddressSuccess", transaction: (t, account) => ({ ...t, recipient: "TYmGYpY3LuHHge9jmTtq2aQmSpUpqKcZtJ", // corresponds to a valid deposit contract address subAccountId: getTokenAccountId(account, "tron/trc20/tla2f6vpqdgre67v1736s7bj8ray5wyju7"), amount: new bignumber_js_1.BigNumber("1000000"), }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("13740900"), }, }, { name: "tronSendTrc20ToNewAccountForbidden", transaction: (t, account) => ({ ...t, recipient: unactivatedAddress, subAccountId: getTokenAccountId(account, "tron/trc20/tla2f6vpqdgre67v1736s7bj8ray5wyju7"), amount: new bignumber_js_1.BigNumber("1000000"), }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: { gasLimit: new errors_1.NotEnoughGas(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("27600900"), }, }, // FIXME account have moved... /* { name: "tronSendTrc20NotEnoughEnergyWarning", transaction: fromTransactionRaw({ family: "tron", recipient: activatedAddress1, subAccountId: "tronjs:2:tron:THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi:+TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", amount: "1000000", networkInfo: null, mode: "send", duration: undefined, resource: undefined, votes: [] }), expectedStatus: { amount: new BigNumber("1000000"), errors: {}, warnings: { amount: new TronNotEnoughEnergy() }, totalSpent: new BigNumber("1000000"), estimatedFees: new BigNumber("0") } }, */ { name: "tronSendTrc20Success", transaction: (t, account) => ({ ...t, recipient: activatedAddress1, subAccountId: getTokenAccountId(account, "tron/trc20/tla2f6vpqdgre67v1736s7bj8ray5wyju7"), amount: new bignumber_js_1.BigNumber("1000000"), }), expectedStatus: { amount: new bignumber_js_1.BigNumber("1000000"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("1000000"), estimatedFees: new bignumber_js_1.BigNumber("13740900"), }, }, { name: "tronInvalidFreezeAmount", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "100000", networkInfo: null, mode: "freeze", duration: undefined, resource: "BANDWIDTH", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("100000"), errors: { amount: new errors_2.TronInvalidFreezeAmount(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("100000"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "tronLegacyUnFreezeBandwidth", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "1000000", networkInfo: null, mode: "legacyUnfreeze", duration: undefined, resource: "BANDWIDTH", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, // Not so sure how ot make this test work again, frozen energy seems to be expired. // { // name: "tronNoFrozenForEnergy", // transaction: fromTransactionRaw({ // family: "tron", // recipient: "", // amount: "0", // networkInfo: null, // mode: "unfreeze", // duration: undefined, // resource: "ENERGY", // votes: [], // }), // expectedStatus: { // amount: new BigNumber("0"), // errors: { // resource: new TronNoFrozenForEnergy(), // }, // warnings: {}, // totalSpent: new BigNumber("0"), // estimatedFees: new BigNumber("0"), // }, // }, { name: "tronVoteRequired", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "0", networkInfo: null, mode: "vote", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { vote: new errors_2.TronVoteRequired(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "invalidVoteAddress", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: activatedAddress1, amount: "0", networkInfo: null, mode: "vote", duration: undefined, resource: undefined, votes: [ { name: "Node 1", address: "abcde", voteCount: 1, }, ], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { vote: new errors_1.InvalidAddress(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "tronInvalidVoteCount", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: activatedAddress1, amount: "0", networkInfo: null, mode: "vote", duration: undefined, resource: undefined, votes: [ { name: "Node 1", address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH", voteCount: 0, }, ], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { vote: new errors_2.TronInvalidVoteCount(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "tronNotEnoughTronPower", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "0", networkInfo: null, mode: "vote", duration: undefined, resource: undefined, votes: [ { name: "Node 1", address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH", voteCount: 5, }, { name: "Node 2", address: "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U", voteCount: 5, }, ], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { vote: new errors_2.TronNotEnoughTronPower(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "tronNoReward", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "0", networkInfo: null, mode: "claimReward", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { reward: new errors_2.TronNoReward(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, ], raw: { id: "js:2:tron:THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi:", seedIdentifier: "THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi", name: "Tron 2", derivationMode: "", index: 1, freshAddress: "THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi", freshAddressPath: "44'/195'/0'/0/0", pendingOperations: [], currencyId: "tron", balance: "10006000", spendableBalance: "1606000", subAccounts: [], operations: [], lastSyncDate: "", blockHeight: 0, tronResources: { frozen: { bandwidth: undefined, energy: undefined }, delegatedFrozen: { bandwidth: undefined, energy: undefined }, unFrozen: { bandwidth: [], energy: [] }, legacyFrozen: { bandwidth: { amount: "2000000", expiredAt: "2022-05-23T08:20:39.000Z" }, energy: { amount: "1000000", expiredAt: "2022-05-22T12:51:12.000Z" }, }, votes: [], tronPower: 3, energy: "12", bandwidth: { freeUsed: "0", freeLimit: "600", gainedUsed: "0", gainedLimit: "2", }, unwithdrawnReward: "0", lastWithdrawnRewardDate: undefined, lastVotedDate: undefined, cacheTransactionInfoById: {}, }, }, }, { transactions: [ { name: "claimRewardSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "", amount: "0", networkInfo: null, mode: "claimReward", duration: undefined, resource: undefined, votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: {}, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, { name: "tronNoFrozenForBandwidth", transaction: (0, transaction_1.fromTransactionRaw)({ family: "tron", recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM", amount: "1000000", networkInfo: null, mode: "unfreeze", duration: undefined, resource: "BANDWIDTH", votes: [], }), expectedStatus: { amount: new bignumber_js_1.BigNumber("0"), errors: { resource: new errors_2.TronNoFrozenForBandwidth(), }, warnings: {}, totalSpent: new bignumber_js_1.BigNumber("0"), estimatedFees: new bignumber_js_1.BigNumber("0"), }, }, ], FIXME_tests: [ /** Error: - Expected + Received - "26003017" + "26000197" The live-common ignore all unsupported tokens (by the nano app) transactions. Difference of 2820 (0.00282 TRX) is due to an unsupported tr10 transaction which have fee: https://tronscan.org/#/transaction/6fe0b288e0cce30396afe40b365ee57642be44146acc847672fe3d328309d2b0 To re-enable when the support will be done. */ "balance is sum of ops", ], raw: { id: "js:2:tron:TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9:", seedIdentifier: activatedAddress1, name: "Tron 1", derivationMode: "", index: 0, freshAddress: activatedAddress1, freshAddressPath: "44'/195'/0'/0/0", pendingOperations: [], currencyId: "tron", balance: "26000197", spendableBalance: "197", subAccounts: [], operations: [], lastSyncDate: "", blockHeight: 0, tronResources: { frozen: { bandwidth: undefined, energy: undefined }, delegatedFrozen: { bandwidth: undefined, energy: undefined }, unFrozen: { bandwidth: [], energy: [] }, legacyFrozen: { bandwidth: undefined, energy: { amount: "26000000", expiredAt: "2020-02-01T16:04:51.000Z" }, }, votes: [ { name: "Node 1", address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH", voteCount: 15, }, { name: "Node 2", address: "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U", voteCount: 1, }, { name: "Node 3", address: "TCZvvbn4SCVyNhCAt1L8Kp1qk5rtMiKdBB", voteCount: 2, }, ], tronPower: 26, energy: "326", bandwidth: { freeUsed: "0", freeLimit: "600", gainedUsed: "0", gainedLimit: "0", }, unwithdrawnReward: "1336847", lastWithdrawnRewardDate: "2022-05-19T12:45:36.000Z", lastVotedDate: "2022-05-19T12:43:42.000Z", cacheTransactionInfoById: {}, }, }, }, { transactions: [ { name: "FreezeEnergySuccess", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "1000000", recipient: "", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "271", netLimit: "584", energyUsed: "0", energyLimit: "214", }, family: "tron", mode: "freeze", resource: "ENERGY", duration: 3, votes: [], }), expectedStatus: { errors: {}, warnings: {}, amount: (0, bignumber_js_1.BigNumber)("1000000"), estimatedFees: (0, bignumber_js_1.BigNumber)("0"), totalSpent: (0, bignumber_js_1.BigNumber)("1000000"), }, }, { name: "NotEnoughBalanceToFreeze", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "100000000000000000", recipient: "", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "271", netLimit: "584", energyUsed: "0", energyLimit: "214", }, family: "tron", mode: "freeze", resource: "ENERGY", duration: 3, votes: [], }), expectedStatus: { errors: { amount: new errors_1.NotEnoughBalance(), }, warnings: {}, amount: (0, bignumber_js_1.BigNumber)("100000000000000000"), estimatedFees: (0, bignumber_js_1.BigNumber)("0"), totalSpent: (0, bignumber_js_1.BigNumber)("100000000000000000"), }, }, { name: "FreezeBandwidthSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "1000000", recipient: "", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "271", netLimit: "584", energyUsed: "0", energyLimit: "214", }, family: "tron", mode: "freeze", resource: "BANDWIDTH", duration: 3, votes: [], }), expectedStatus: { errors: {}, warnings: {}, amount: (0, bignumber_js_1.BigNumber)("1000000"), estimatedFees: (0, bignumber_js_1.BigNumber)("0"), totalSpent: (0, bignumber_js_1.BigNumber)("1000000"), }, }, { name: "UnfreezeEnergySuccess", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "1000000", recipient: "", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "271", netLimit: "584", energyUsed: "0", energyLimit: "214", }, family: "tron", mode: "unfreeze", resource: "ENERGY", duration: 3, votes: [], }), expectedStatus: { errors: {}, warnings: {}, amount: (0, bignumber_js_1.BigNumber)("0"), estimatedFees: (0, bignumber_js_1.BigNumber)("0"), totalSpent: (0, bignumber_js_1.BigNumber)("0"), }, }, { name: "NotEnoughEnergyUnfreeze", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "10000000000", recipient: "", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "271", netLimit: "584", energyUsed: "0", energyLimit: "214", }, family: "tron", mode: "unfreeze", resource: "ENERGY", duration: 3, votes: [], }), expectedStatus: { errors: { resource: new errors_2.TronNoFrozenForEnergy(), }, warnings: {}, amount: (0, bignumber_js_1.BigNumber)("0"), estimatedFees: (0, bignumber_js_1.BigNumber)("0"), totalSpent: (0, bignumber_js_1.BigNumber)("0"), }, }, { name: "UnfreezeBandwidthSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "1000000", recipient: "", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "272", netLimit: "584", energyUsed: "0", energyLimit: "214", }, family: "tron", mode: "unfreeze", resource: "BANDWIDTH", duration: 3, votes: [], }), expectedStatus: { errors: {}, warnings: {}, amount: (0, bignumber_js_1.BigNumber)("0"), estimatedFees: (0, bignumber_js_1.BigNumber)("0"), totalSpent: (0, bignumber_js_1.BigNumber)("0"), }, }, { name: "withdrawExpireUnfreezeSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "0", recipient: "", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "274", netLimit: "584", energyUsed: "0", energyLimit: "214", }, family: "tron", mode: "withdrawExpireUnfreeze", resource: null, duration: 3, votes: [], }), expectedStatus: { errors: {}, warnings: {}, amount: (0, bignumber_js_1.BigNumber)("0"), estimatedFees: (0, bignumber_js_1.BigNumber)("0"), totalSpent: (0, bignumber_js_1.BigNumber)("0"), }, }, { name: "UndelegateResourceSuccess", transaction: (0, transaction_1.fromTransactionRaw)({ amount: "1000000", recipient: "TKc4RbfcDf6MrHXENfRAG23ue8YYgaTh8U", useAllAmount: false, subAccountId: null, networkInfo: { family: "tron", freeNetUsed: "0", freeNetLimit: "600", netUsed: "268",