Sha256: 6cae004216d153fceb84220e64744d3332a42cec05fc678e9fe99069068c6979

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.issue = void 0;
const ts_lib_crypto_1 = require("@waves/ts-lib-crypto");
const generic_1 = require("../generic");
const marshall_1 = require("@waves/marshall");
const validators_1 = require("../validators");
const proto_serialize_1 = require("../proto-serialize");
const defaultVersions_1 = require("../defaultVersions");
const ts_types_1 = require("@waves/ts-types");
function issue(paramsOrTx, seed) {
    const type = ts_types_1.TRANSACTION_TYPE.ISSUE;
    const version = paramsOrTx.version || defaultVersions_1.DEFAULT_VERSIONS.ISSUE;
    const seedsAndIndexes = generic_1.convertToPairs(seed);
    const senderPublicKey = generic_1.getSenderPublicKey(seedsAndIndexes, paramsOrTx);
    const tx = {
        type,
        version,
        senderPublicKey,
        name: paramsOrTx.name,
        description: paramsOrTx.description,
        quantity: paramsOrTx.quantity,
        script: paramsOrTx.script == null ? null : generic_1.base64Prefix(paramsOrTx.script),
        decimals: paramsOrTx.decimals == null ? 8 : paramsOrTx.decimals,
        reissuable: paramsOrTx.reissuable || false,
        fee: checkForNFT(paramsOrTx) ? generic_1.fee(paramsOrTx, 100000) : generic_1.fee(paramsOrTx, 100000000),
        timestamp: paramsOrTx.timestamp || Date.now(),
        chainId: generic_1.networkByte(paramsOrTx.chainId, 87),
        proofs: paramsOrTx.proofs || [],
        id: '',
    };
    validators_1.validate.issue(tx);
    const bytes = version > 2 ? proto_serialize_1.txToProtoBytes(tx) : marshall_1.binary.serializeTx(tx);
    seedsAndIndexes.forEach(([s, i]) => generic_1.addProof(tx, ts_lib_crypto_1.signBytes(s, bytes), i));
    tx.id = ts_lib_crypto_1.base58Encode(ts_lib_crypto_1.blake2b(bytes));
    return tx;
}
exports.issue = issue;
const checkForNFT = (paramsOrTx) => {
    return paramsOrTx.quantity === 1 && paramsOrTx.reissuable == false && paramsOrTx.decimals == 0;
};
//# sourceMappingURL=issue.js.map

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/@waves/waves-transactions/dist/transactions/issue.js