Sha256: 3768d14f8030e4bdc415ccfbd7da048349f33248d5b87b801ceb8c3f61e7c749
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setScript = 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 setScript(paramsOrTx, seed) { const type = ts_types_1.TRANSACTION_TYPE.SET_SCRIPT; const version = paramsOrTx.version || defaultVersions_1.DEFAULT_VERSIONS.SET_SCRIPT; const seedsAndIndexes = generic_1.convertToPairs(seed); const senderPublicKey = generic_1.getSenderPublicKey(seedsAndIndexes, paramsOrTx); if (paramsOrTx.script === undefined) throw new Error('Script field cannot be undefined. Use null explicitly to remove script'); let scriptBytes = proto_serialize_1.scriptToProto(paramsOrTx.script); const computedFee = scriptBytes != null ? (Math.ceil(scriptBytes.length / 1024) * 100000) : 500000; const tx = { type, version, senderPublicKey, chainId: generic_1.networkByte(paramsOrTx.chainId, 87), fee: generic_1.fee(paramsOrTx, computedFee), timestamp: paramsOrTx.timestamp || Date.now(), proofs: paramsOrTx.proofs || [], id: '', script: generic_1.base64Prefix(paramsOrTx.script), }; validators_1.validate.setScript(tx); const bytes = version > 1 ? 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.setScript = setScript; //# sourceMappingURL=set-script.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/set-script.js |