UNPKG

@ledgerhq/coin-casper

Version:
177 lines 7.74 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 transaction_1 = require("../bridge/transaction"); const bignumber_js_1 = __importDefault(require("bignumber.js")); const errors_1 = require("@ledgerhq/errors"); const errors_2 = require("../errors"); const fee_1 = require("../bridge/bridgeHelpers/fee"); const SEED_IDENTIFIER = "0202ba6dc98cbe677711a45bf028a03646f9e588996eb223fad2485e8bc391b01581"; const RECIPIENT_ADDRESS_SECP256k1 = "0203A17118eC0e64c4e4FdbDbEe0eA14D118C9aAf08C6c81bbB776Cae607cEB84EcB"; const RECIPIENT_ADDRESS_EDSA25519 = "0203A17118eC0e64c4e4FdbDbEe0eA14D118C9aAf08C6c81bbB776Cae607cEB84EcB"; const casper = { scanAccounts: [ { name: "casper seed 1", apdus: ` => 11010000142c000080fa010080000000800000000000000000 <= 038c8cb0f62b4efcd0c7868c2e749dda649affe30ff0f95fc91ce48ea67f077d1630323033384338636230663632623445466344304337383638633265373439446461363439614646453330664630663935666339314345343845413637463037374431369000 => 11010000142c000080fa010080000000800000000001000000 <= 02ba6dc98cbe677711a45bf028a03646f9e588996eb223fad2485e8bc391b0158130323032624136444339386362453637373731316134356266303238413033363436463965353838393936654232323366616432343835653862633339316230313538319000 => 11010000142c000080fa010080000000800000000002000000 <= 022aab9b6ed404f8cffe76ce493e1995d195b5f141ee7d5b7fb20fce60f2a4969130323032324141423942364544343034663843464645373663653439334531393935643139354235463134314565374435423766623230464345363066324134393639319000 `, }, ], accounts: [ { raw: { id: `js:2:casper:${SEED_IDENTIFIER}:casper_wallet`, seedIdentifier: SEED_IDENTIFIER, name: "Casper 1", derivationMode: "casper_wallet", index: 0, freshAddress: SEED_IDENTIFIER, freshAddressPath: "44'/506'/0'/0/1", blockHeight: 0, operations: [], pendingOperations: [], currencyId: "casper", lastSyncDate: "", balance: "1000", }, transactions: [ { name: "not a valid address", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", recipient: "novalidaddress", fees: (0, fee_1.getEstimatedFees)().toString(), amount: "1000", }), expectedStatus: { errors: { recipient: new errors_1.InvalidAddress(), }, warnings: {}, }, }, { name: "not enough balance", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", recipient: RECIPIENT_ADDRESS_SECP256k1, fees: (0, fee_1.getEstimatedFees)().toString(), amount: (300 * 1e9).toString(), }), expectedStatus: { errors: { amount: new errors_1.NotEnoughBalance(), }, warnings: {}, }, }, { name: "amount required", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", recipient: RECIPIENT_ADDRESS_SECP256k1, amount: "0", fees: (0, fee_1.getEstimatedFees)().toString(), }), expectedStatus: { errors: { amount: new errors_1.AmountRequired(), }, warnings: {}, }, }, { name: "minimum amount required", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", fees: (0, fee_1.getEstimatedFees)().toString(), recipient: RECIPIENT_ADDRESS_SECP256k1, amount: "1", }), expectedStatus: { errors: { amount: new errors_2.InvalidMinimumAmount(), }, warnings: {}, }, }, { name: "sufficient amount - recipient address secp256k1", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", recipient: RECIPIENT_ADDRESS_SECP256k1, amount: "3", fees: (0, fee_1.getEstimatedFees)().toString(), }), expectedStatus: { amount: new bignumber_js_1.default("3"), errors: {}, warnings: {}, }, }, { name: "sufficient amount - recipient address ed25519", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", recipient: RECIPIENT_ADDRESS_EDSA25519, amount: "3", fees: (0, fee_1.getEstimatedFees)().toString(), }), expectedStatus: { amount: new bignumber_js_1.default("3"), errors: {}, warnings: {}, }, }, { name: "invalid transferID", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", recipient: RECIPIENT_ADDRESS_SECP256k1, fees: (0, fee_1.getEstimatedFees)().toString(), amount: "3", transferId: "afdsaf1", }), expectedStatus: { amount: new bignumber_js_1.default("3"), errors: { sender: new errors_2.CasperInvalidTransferId(), }, warnings: {}, }, }, { name: "may block account warning", transaction: (0, transaction_1.fromTransactionRaw)({ family: "casper", recipient: RECIPIENT_ADDRESS_SECP256k1, fees: (0, fee_1.getEstimatedFees)().toString(), amount: (999 * 1e9).toString(), }), expectedStatus: { errors: {}, warnings: { amount: new errors_2.MayBlockAccount(), }, }, }, ], }, ], }; exports.dataset = { implementations: ["js"], currencies: { casper, }, }; //# sourceMappingURL=bridgeDatasetTest.js.map