UNPKG

@ledgerhq/coin-near

Version:
224 lines • 9.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dataset = void 0; const errors_1 = require("@ledgerhq/errors"); const bignumber_js_1 = require("bignumber.js"); const errors_2 = require("../errors"); const transaction_1 = require("../transaction"); const ACCOUNT_ADDRESS = "18d68decb70d4d4fd267d19a0d25edc06ad079e69ded41233a10976cf36391ec"; const ACTIVE_RECIPIENT_ADDRESS = "3cfb4df771c29cf040e2534b71b4df08b6232e7248aefc7decf45d2b40f80ad5"; const INACTIVE_RECIPIENT_ADDRESS = "6cbf3b0f8d8b4667bf64bf44b4fefa830e4cef0e5da1e5cfb4015b5a755c4ac0"; const VALIDATOR_ADDRESS = "figment.poolv1.near"; const DEFAULT_AMOUNT = "100000000"; const BIG_AMOUNT = "1000000000000000000000000"; const near = { scanAccounts: [ { name: "near seed 1", apdus: ` => 80040157148000002c8000018d800000008000000080000000 <= 18d68decb70d4d4fd267d19a0d25edc06ad079e69ded41233a10976cf36391ec9000 => 80040157148000002c8000018d800000008000000080000001 <= 6cbf3b0f8d8b4667bf64bf44b4fefa830e4cef0e5da1e5cfb4015b5a755c4ac09000 => 80040157148000002c8000018d800000008000000080000002 <= 59dff1cf9185758c0c2f878c37a175280f3967dca8fee6e4ad0c4aa26daf8e5c9000 `, }, ], accounts: [ { // Skipping due to rewards being auto-compounded, no operation as evidence FIXME_tests: ["balance is sum of ops"], raw: { id: `js:2:near:${ACCOUNT_ADDRESS}:nearbip44h`, seedIdentifier: `${ACCOUNT_ADDRESS}`, name: "NEAR 1", derivationMode: "nearbip44h", index: 0, freshAddress: `${ACCOUNT_ADDRESS}`, freshAddressPath: "44'/397'/0'/0'/0'", blockHeight: 0, operations: [], pendingOperations: [], currencyId: "near", lastSyncDate: "", balance: "47162281393064900000001", }, transactions: [ { name: "Recipient and sender must not be the same", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: ACCOUNT_ADDRESS, amount: DEFAULT_AMOUNT, mode: "send", }), expectedStatus: { amount: new bignumber_js_1.BigNumber(DEFAULT_AMOUNT), errors: {}, warnings: { recipient: new errors_1.InvalidAddressBecauseDestinationIsAlsoSource(), }, }, }, { name: "Not enough balance", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: ACTIVE_RECIPIENT_ADDRESS, amount: BIG_AMOUNT, mode: "send", }), expectedStatus: { errors: { amount: new errors_1.NotEnoughBalance(), }, warnings: {}, }, }, { name: "New implicit account", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: INACTIVE_RECIPIENT_ADDRESS, amount: DEFAULT_AMOUNT, mode: "send", }), expectedStatus: { errors: {}, warnings: { recipient: new errors_2.NearNewAccountWarning(), }, }, }, { name: "New named account", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: "brand-new-account-8172987103.near", amount: DEFAULT_AMOUNT, mode: "send", }), expectedStatus: { errors: { recipient: new errors_2.NearNewNamedAccountError(), }, warnings: {}, }, }, { name: "Amount does not cover activation fee", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: INACTIVE_RECIPIENT_ADDRESS, amount: DEFAULT_AMOUNT, mode: "send", }), expectedStatus: { errors: { amount: new errors_2.NearActivationFeeNotCovered(), }, warnings: {}, }, }, { name: "Send max with active staking positions", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: ACTIVE_RECIPIENT_ADDRESS, amount: DEFAULT_AMOUNT, useAllAmount: true, mode: "send", }), expectedStatus: { errors: {}, warnings: { amount: new errors_2.NearRecommendUnstake(), }, }, }, { name: "Staking threshold not met", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: VALIDATOR_ADDRESS, amount: "1", mode: "stake", }), expectedStatus: { errors: { amount: new errors_2.NearStakingThresholdNotMet(), }, warnings: {}, }, }, { name: "Unstaking more than is staked", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: VALIDATOR_ADDRESS, amount: BIG_AMOUNT, mode: "unstake", }), expectedStatus: { errors: { amount: new errors_2.NearNotEnoughStaked(), }, warnings: {}, }, }, { name: "Withdrawing more than is unstaked", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: VALIDATOR_ADDRESS, amount: BIG_AMOUNT, mode: "withdraw", }), expectedStatus: { errors: { amount: new errors_2.NearNotEnoughAvailable(), }, warnings: {}, }, }, { name: "Staking max", transaction: (0, transaction_1.fromTransactionRaw)({ family: "near", recipient: VALIDATOR_ADDRESS, amount: DEFAULT_AMOUNT, useAllAmount: true, mode: "stake", }), expectedStatus: { errors: {}, warnings: { amount: new errors_2.NearUseAllAmountStakeWarning(), }, }, }, ], }, ], }; exports.dataset = { implementations: ["js"], currencies: { near, }, }; describe("Near bridge", () => { test.todo("This is an empty test to make jest command pass. Remove it once there is a real test."); }); /** * NOTE: if tests are added to this file, * like done in libs/coin-polkadot/src/bridge.integration.test.ts for example, * this file fill need to be imported in ledger-live-common * libs/ledger-live-common/src/families/algorand/bridge.integration.test.ts * like done for polkadot. * cf. * - libs/coin-polkadot/src/bridge.integration.test.ts * - libs/ledger-live-common/src/families/polkadot/bridge.integration.test.ts */ //# sourceMappingURL=bridge.dataset.js.map