@taquito/local-forging
Version:
Provide local forging functionality to be with taquito
1,405 lines (1,398 loc) • 112 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@taquito/utils'), require('@taquito/core'), require('bignumber.js')) :
typeof define === 'function' && define.amd ? define(['exports', '@taquito/utils', '@taquito/core', 'bignumber.js'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoLocalForging = {}, global.utils, global.core, global.BigNumber));
})(this, (function (exports, utils, core, BigNumber) { 'use strict';
const toHexString = (bytes) => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
const pad = (num, paddingLen = 8) => {
return num.toString(16).padStart(paddingLen, '0');
};
/*
* Some code in this file is originally from sotez
* Copyright (c) 2018 Andrew Kishino
*/
// See: https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
const ENTRYPOINT_MAX_LENGTH$1 = 31;
exports.CODEC = void 0;
(function (CODEC) {
CODEC["SECRET"] = "secret";
CODEC["RAW"] = "raw";
CODEC["TZ1"] = "tz1";
CODEC["BRANCH"] = "branch";
CODEC["ZARITH"] = "zarith";
CODEC["PUBLIC_KEY"] = "public_key";
CODEC["PKH"] = "pkh";
CODEC["PKH_ARR"] = "pkhArr";
CODEC["DELEGATE"] = "delegate";
CODEC["SCRIPT"] = "script";
CODEC["BALLOT_STATEMENT"] = "ballotStmt";
CODEC["PROPOSAL"] = "proposal";
CODEC["PROPOSAL_ARR"] = "proposalArr";
CODEC["INT32"] = "int32";
CODEC["INT16"] = "int16";
CODEC["PARAMETERS"] = "parameters";
CODEC["ADDRESS"] = "address";
CODEC["SMART_CONTRACT_ADDRESS"] = "smart_contract_address";
CODEC["SMART_ROLLUP_ADDRESS"] = "smart_rollup_address";
CODEC["SMART_ROLLUP_COMMITMENT_HASH"] = "smart_rollup_commitment_hash";
CODEC["VALUE"] = "value";
CODEC["PADDED_BYTES"] = "padded_bytes";
CODEC["SMART_ROLLUP_MESSAGE"] = "smart_rollup_message";
CODEC["MANAGER"] = "manager";
CODEC["BLOCK_PAYLOAD_HASH"] = "blockPayloadHash";
CODEC["ENTRYPOINT"] = "entrypoint";
CODEC["OPERATION"] = "operation";
CODEC["OP_ACTIVATE_ACCOUNT"] = "activate_account";
CODEC["OP_DELEGATION"] = "delegation";
CODEC["OP_TRANSACTION"] = "transaction";
CODEC["OP_ORIGINATION"] = "origination";
CODEC["OP_BALLOT"] = "ballot";
CODEC["OP_FAILING_NOOP"] = "failing_noop";
CODEC["OP_ATTESTATION"] = "attestation";
CODEC["OP_ATTESTATION_WITH_DAL"] = "attestation_with_dal";
CODEC["OP_SEED_NONCE_REVELATION"] = "seed_nonce_revelation";
CODEC["OP_REVEAL"] = "reveal";
CODEC["OP_PROPOSALS"] = "proposals";
CODEC["OP_REGISTER_GLOBAL_CONSTANT"] = "register_global_constant";
CODEC["OP_TRANSFER_TICKET"] = "transfer_ticket";
CODEC["BURN_LIMIT"] = "burn_limit";
CODEC["OP_INCREASE_PAID_STORAGE"] = "increase_paid_storage";
CODEC["OP_UPDATE_CONSENSUS_KEY"] = "update_consensus_key";
CODEC["SIGNATURE_PROOF"] = "signature_proof";
CODEC["OP_DRAIN_DELEGATE"] = "drain_delegate";
CODEC["DEPOSITS_LIMIT"] = "deposits_limit";
CODEC["OP_SET_DEPOSITS_LIMIT"] = "set_deposits_limit";
CODEC["OP_SMART_ROLLUP_ORIGINATE"] = "smart_rollup_originate";
CODEC["PVM_KIND"] = "pvm_kind";
CODEC["OP_SMART_ROLLUP_ADD_MESSAGES"] = "smart_rollup_add_messages";
CODEC["OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE"] = "smart_rollup_execute_outbox_message";
CODEC["OP_DAL_PUBLISH_COMMITMENT"] = "dal_publish_commitment";
CODEC["SLOT_HEADER"] = "slot_header";
})(exports.CODEC || (exports.CODEC = {}));
// See https://tezos.gitlab.io/shell/p2p_api.html#alpha-michelson-v1-primitives-enumeration-unsigned-8-bit-integer
const opMapping$1 = {
'00': 'parameter',
'01': 'storage',
'02': 'code',
'03': 'False',
'04': 'Elt',
'05': 'Left',
'06': 'None',
'07': 'Pair',
'08': 'Right',
'09': 'Some',
'0a': 'True',
'0b': 'Unit',
'0c': 'PACK',
'0d': 'UNPACK',
'0e': 'BLAKE2B',
'0f': 'SHA256',
'10': 'SHA512',
'11': 'ABS',
'12': 'ADD',
'13': 'AMOUNT',
'14': 'AND',
'15': 'BALANCE',
'16': 'CAR',
'17': 'CDR',
'18': 'CHECK_SIGNATURE',
'19': 'COMPARE',
'1a': 'CONCAT',
'1b': 'CONS',
'1c': 'CREATE_ACCOUNT', // Removed in Edo
'1d': 'CREATE_CONTRACT', // Removed in Edo
'1e': 'IMPLICIT_ACCOUNT',
'1f': 'DIP',
'20': 'DROP',
'21': 'DUP',
'22': 'EDIV',
'23': 'EMPTY_MAP',
'24': 'EMPTY_SET',
'25': 'EQ',
'26': 'EXEC',
'27': 'FAILWITH',
'28': 'GE',
'29': 'GET',
'2a': 'GT',
'2b': 'HASH_KEY',
'2c': 'IF',
'2d': 'IF_CONS',
'2e': 'IF_LEFT',
'2f': 'IF_NONE',
'30': 'INT',
'31': 'LAMBDA',
'32': 'LE',
'33': 'LEFT',
'34': 'LOOP',
'35': 'LSL',
'36': 'LSR',
'37': 'LT',
'38': 'MAP',
'39': 'MEM',
'3a': 'MUL',
'3b': 'NEG',
'3c': 'NEQ',
'3d': 'NIL',
'3e': 'NONE',
'3f': 'NOT',
'40': 'NOW',
'41': 'OR',
'42': 'PAIR',
'43': 'PUSH',
'44': 'RIGHT',
'45': 'SIZE',
'46': 'SOME',
'47': 'SOURCE',
'48': 'SENDER',
'49': 'SELF',
'4a': 'STEPS_TO_QUOTA', // Removed in Edo
'4b': 'SUB',
'4c': 'SWAP',
'4d': 'TRANSFER_TOKENS',
'4e': 'SET_DELEGATE',
'4f': 'UNIT',
'50': 'UPDATE',
'51': 'XOR',
'52': 'ITER',
'53': 'LOOP_LEFT',
'54': 'ADDRESS',
'55': 'CONTRACT',
'56': 'ISNAT',
'57': 'CAST',
'58': 'RENAME',
'59': 'bool',
'5a': 'contract',
'5b': 'int',
'5c': 'key',
'5d': 'key_hash',
'5e': 'lambda',
'5f': 'list',
'60': 'map',
'61': 'big_map',
'62': 'nat',
'63': 'option',
'64': 'or',
'65': 'pair',
'66': 'set',
'67': 'signature',
'68': 'string',
'69': 'bytes',
'6a': 'mutez',
'6b': 'timestamp',
'6c': 'unit',
'6d': 'operation',
'6e': 'address',
'6f': 'SLICE',
'70': 'DIG',
'71': 'DUG',
'72': 'EMPTY_BIG_MAP',
'73': 'APPLY',
'74': 'chain_id',
'75': 'CHAIN_ID',
'76': 'LEVEL',
'77': 'SELF_ADDRESS',
'78': 'never',
'79': 'NEVER',
'7a': 'UNPAIR',
'7b': 'VOTING_POWER',
'7c': 'TOTAL_VOTING_POWER',
'7d': 'KECCAK',
'7e': 'SHA3',
'7f': 'PAIRING_CHECK',
'80': 'bls12_381_g1',
'81': 'bls12_381_g2',
'82': 'bls12_381_fr',
'83': 'sapling_state',
'84': 'sapling_transaction_deprecated',
'85': 'SAPLING_EMPTY_STATE',
'86': 'SAPLING_VERIFY_UPDATE',
'87': 'ticket',
'88': 'TICKET_DEPRECATED',
'89': 'READ_TICKET',
'8a': 'SPLIT_TICKET',
'8b': 'JOIN_TICKETS',
'8c': 'GET_AND_UPDATE',
'8d': 'chest',
'8e': 'chest_key',
'8f': 'OPEN_CHEST',
'90': 'VIEW',
'91': 'view',
'92': 'constant',
'93': 'SUB_MUTEZ',
'94': 'tx_rollup_l2_address',
'95': 'MIN_BLOCK_TIME',
'96': 'sapling_transaction',
'97': 'EMIT',
'98': 'Lambda_rec',
'99': 'LAMBDA_REC',
'9a': 'TICKET',
'9b': 'BYTES',
'9c': 'NAT',
'9d': 'Ticket',
};
const opMappingReverse = (() => {
const result = {};
Object.keys(opMapping$1).forEach((key) => {
result[opMapping$1[key]] = key;
});
return result;
})();
// See https://tezos.gitlab.io/shell/p2p_api.html
const kindMapping$1 = {
0x04: 'activate_account',
0x6b: 'reveal',
0x6e: 'delegation',
0x6c: 'transaction',
0x6d: 'origination',
0x06: 'ballot',
0x15: 'attestation',
0x17: 'attestation_with_dal',
0x01: 'seed_nonce_revelation',
0x05: 'proposals',
0x6f: 'register_global_constant',
0x9e: 'transfer_ticket',
0x70: 'set_deposits_limit',
0x71: 'increase_paid_storage',
0x72: 'update_consensus_key',
0x09: 'drain_delegate',
0xc8: 'smart_rollup_originate',
0xc9: 'smart_rollup_add_messages',
0xce: 'smart_rollup_execute_outbox_message',
0xe6: 'dal_publish_commitment',
0x11: 'failing_noop',
};
const kindMappingReverse$1 = (() => {
const result = {};
Object.keys(kindMapping$1).forEach((key) => {
const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
result[kindMapping$1[keyNum]] = pad(keyNum, 2);
});
return result;
})();
// See https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
const entrypointMapping$1 = {
'00': 'default',
'01': 'root',
'02': 'do',
'03': 'set_delegate',
'04': 'remove_delegate',
'05': 'deposit',
'06': 'stake',
'07': 'unstake',
'08': 'finalize_unstake',
'09': 'set_delegate_parameters',
};
const entrypointMappingReverse$1 = (() => {
const result = {};
Object.keys(entrypointMapping$1).forEach((key) => {
result[entrypointMapping$1[key]] = key;
});
return result;
})();
/**
* @category Error
* @description Error that indicates an invalid operation content being passed or used
*/ class InvalidOperationSchemaError extends core.ParameterValidationError {
constructor(operation, errorDetail) {
super();
this.operation = operation;
this.errorDetail = errorDetail;
this.name = 'InvalidOperationSchemaError';
this.message = `Invalid operation content recevied`;
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
}
}
/**
* @category Error
* @description Error that indicates an entrypoint name exceeding maximum length
*/
class OversizedEntryPointError extends core.ParameterValidationError {
constructor(entrypoint) {
super();
this.entrypoint = entrypoint;
this.name = 'OversizedEntryPointError';
this.message = `Invalid entrypoint length "${entrypoint.length}", maximum length is "${ENTRYPOINT_MAX_LENGTH$1}".`;
}
}
/**
* @category Error
* @description Error that indicates an invalid ballot value being used
*/
class InvalidBallotValueError extends core.ParameterValidationError {
constructor(ballotValue) {
super();
this.ballotValue = ballotValue;
this.name = 'InvalidBallotValueError';
this.message = `Invalid ballot value "${ballotValue}" expecting one of the following: "yay", "nay", "pass".`;
}
}
/**
* @category Error
* @description Error that indicates a failure when trying to decode ballot value
*/
class DecodeBallotValueError extends core.ParameterValidationError {
constructor(ballotValue) {
super();
this.ballotValue = ballotValue;
this.name = 'DecodeBallotValueError';
this.message = `Invalid ballot value "${ballotValue}", cannot be decoded.`;
}
}
/**
* @category Error
* @description Error that indicates unexpected Michelson Value being passed or used
*/
class UnexpectedMichelsonValueError extends core.ParameterValidationError {
constructor(value) {
super();
this.value = value;
this.name = 'UnexpectedMichelsonValueError';
this.message = `Invalid Michelson value "${value}", unalbe to encode.`;
}
}
/**
* @category Error
* @description Error that indicates a failure when trying to decode an operation
*/
class OperationDecodingError extends core.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'OperationDecodingError';
}
}
/**
* @category Error
* @description Error that indicates a failure when trying to encode an operation
*/
class OperationEncodingError extends core.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'OperationEncodingError';
}
}
/**
* @category Error
* @description Error that indicates an unsupported operation being passed or used
*/
class UnsupportedOperationError extends core.ParameterValidationError {
constructor(op) {
super();
this.op = op;
this.name = 'UnsupportedOperationError';
this.message = `Unsupported operation "${op}", can submit an issue on our github for feature request.`;
}
}
/**
* @cateogry Error
* @description Error that indicates an unsupported pvm being passed or used
*/
class UnsupportedPvmKindError extends core.ParameterValidationError {
constructor(pvm) {
super();
this.pvm = pvm;
this.name = 'UnsupportedPvmKindError';
this.message = `Invalid Pvm kind "${pvm}" expecting either "arith" or "wasm_2_0_0".`;
}
}
/**
* @category Error
* @description Error that indicates an unsupported pvm to decode
*/
class DecodePvmKindError extends core.ParameterValidationError {
constructor(pvm) {
super();
this.pvm = pvm;
this.name = 'DecodePvmKindError';
this.message = `Invalid Pvm kind "${pvm}", cannot be decoded.`;
}
}
/**
* @category Error
* @description Error that indicates an invalid Smart Rollup Address (sr1)
*/
class InvalidSmartRollupAddressError extends core.ParameterValidationError {
constructor(address, errorDetail) {
super();
this.address = address;
this.errorDetail = errorDetail;
this.name = 'InvalidSmartRollupAddress';
this.message = `Invalid smart rollup address "${address}"`;
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
}
}
/**
* @category Error
* @description Error that indicates an invalid Smart Rollup commitment hash (src1)
*/
class InvalidSmartRollupCommitmentHashError extends core.ParameterValidationError {
constructor(hash, errorDetail) {
super();
this.hash = hash;
this.errorDetail = errorDetail;
this.name = 'InvalidSmartRollupCommitmentHashError';
this.message = `Invalid smart rollup commitment hash "${hash}"`;
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
}
}
/**
* @category Error
* @description Error that indicates an invalid dal commitment (sh)
*/
class InvalidDalCommitmentError extends core.ParameterValidationError {
constructor(commitment, errorDetail) {
super();
this.commitment = commitment;
this.errorDetail = errorDetail;
this.name = 'InvalidDalCommitmentError';
this.message = `Invalid dal commitment "${commitment}"`;
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
}
}
class Uint8ArrayConsumer {
static fromHexString(hex) {
const lowHex = hex.toLowerCase();
if (/^(([a-f]|\d){2})*$/.test(lowHex)) {
const arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map((byte) => parseInt(byte, 16)));
return new Uint8ArrayConsumer(arr);
}
else {
throw new core.InvalidHexStringError(lowHex);
}
}
constructor(arr, offset = 0) {
this.arr = arr;
this.offset = offset;
}
consume(count) {
const subArr = this.arr.subarray(this.offset, this.offset + count);
this.offset += count;
return subArr;
}
get(idx) {
return this.arr[this.offset + idx];
}
length() {
return this.arr.length - this.offset;
}
slice(start, end) {
return new Uint8ArrayConsumer(this.arr.slice(start, end));
}
}
const isPrim = (value) => {
return 'prim' in value;
};
const isBytes = (value) => {
return 'bytes' in value && typeof value.bytes === 'string';
};
const isString = (value) => {
return 'string' in value && typeof value.string === 'string';
};
const isInt = (value) => {
return 'int' in value && typeof value.int === 'string';
};
const scriptEncoder = (script) => {
const code = valueEncoder(script.code);
const storage = valueEncoder(script.storage);
return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`;
};
const scriptDecoder = (value) => {
const code = extractRequiredLen(value);
const storage = extractRequiredLen(value);
return {
code: valueDecoder(new Uint8ArrayConsumer(code)),
storage: valueDecoder(new Uint8ArrayConsumer(storage)),
};
};
const valueEncoder = (value) => {
if (Array.isArray(value)) {
const encoded = value.map((x) => valueEncoder(x)).join('');
const len = encoded.length / 2;
return `02${pad(len)}${encoded}`;
}
else if (isPrim(value)) {
return primEncoder(value);
}
else if (isBytes(value)) {
return bytesEncoder(value);
}
else if (isString(value)) {
return stringEncoder(value);
}
else if (isInt(value)) {
return intEncoder(value);
}
throw new UnexpectedMichelsonValueError(JSON.stringify(value));
};
const valueDecoder = (value) => {
const preamble = value.consume(1);
switch (preamble[0]) {
case 0x0a:
return bytesDecoder(value);
case 0x01:
return stringDecoder(value);
case 0x00:
return intDecoder(value);
case 0x02: {
const val = new Uint8ArrayConsumer(extractRequiredLen(value));
const results = [];
while (val.length() > 0) {
results.push(valueDecoder(val));
}
return results;
}
default:
return primDecoder(value, preamble);
}
};
const extractRequiredLen = (value, bytesLength = 4) => {
const len = value.consume(bytesLength);
const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
return value.consume(valueLen);
};
/**
* @description parse bytes into multiple items of an array
* @param value Uint8ArrayConsumer class of forged segment to parse
* @param bytesLength default 4 bytes for length of variable bytes
* @returns array of Uint8Array values for each array item
*/
const stripLengthPrefixFromBytes = (value, bytesLength = 4) => {
const ret = [];
let values = value;
while (values.length()) {
const len = values.consume(bytesLength);
const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
ret.push(values.consume(valueLen));
values = values.slice(valueLen + bytesLength);
}
return ret;
};
const bytesEncoder = (value) => {
if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
throw new core.InvalidHexStringError(value.bytes);
}
const len = value.bytes.length / 2;
return `0a${pad(len)}${value.bytes}`;
};
const bytesDecoder = (value) => {
const bytes = extractRequiredLen(value);
return {
bytes: Buffer.from(bytes).toString('hex'),
};
};
const stringEncoder = (value) => {
const str = Buffer.from(value.string, 'utf8').toString('hex');
const hexLength = str.length / 2;
return `01${pad(hexLength)}${str}`;
};
const stringDecoder = (value) => {
const str = extractRequiredLen(value);
return {
string: Buffer.from(str).toString('utf8'),
};
};
const intEncoder = ({ int }) => {
const num = new BigNumber.BigNumber(int, 10);
const positiveMark = num.toString(2)[0] === '-' ? '1' : '0';
const binary = num.toString(2).replace(/-/g, '');
const pad = binary.length <= 6
? 6
: (binary.length - 6) % 7
? binary.length + 7 - ((binary.length - 6) % 7)
: binary.length;
const splitted = binary.padStart(pad, '0').match(/\d{6,7}/g);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const reversed = splitted.reverse();
reversed[0] = positiveMark + reversed[0];
const numHex = reversed.map((x, i) =>
// Add one to the last chunk
parseInt((i === reversed.length - 1 ? '0' : '1') + x, 2)
.toString(16)
.padStart(2, '0'));
return `00${numHex.join('')}`;
};
const intDecoder = (value) => {
let c = value.consume(1)[0];
const hexNumber = [];
const isNotLastChunkMask = 1 << 7;
while (c & isNotLastChunkMask) {
hexNumber.push(c);
c = value.consume(1)[0];
}
hexNumber.push(c);
const isNegative = !!((1 << 6) & hexNumber[0]);
hexNumber[0] = hexNumber[0] & 0b1111111;
const numBin = hexNumber
.map((x, i) => x
.toString(2)
.slice(i === 0 ? -6 : -7)
.padStart(i === 0 ? 6 : 7, '0'))
.reverse();
let num = new BigNumber.BigNumber(numBin.join(''), 2);
if (isNegative) {
num = num.times(-1);
}
return {
int: num.toFixed(),
};
};
const primEncoder = (value) => {
const hasAnnot = +Array.isArray(value.annots);
const argsCount = Array.isArray(value.args) ? value.args.length : 0;
// Specify the number of args max is 3 without annotation
const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
const op = opMappingReverse[value.prim];
let encodedArgs = (value.args || []).map((arg) => valueEncoder(arg)).join('');
const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots(value.annots) : '';
if ((value.prim === 'LAMBDA' || value.prim === 'LAMBDA_REC') && argsCount) {
encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
}
if ((value.prim === 'pair' || value.prim === 'Pair') && argsCount > 2) {
encodedArgs =
encodedAnnots === ''
? pad(encodedArgs.length / 2) + encodedArgs + pad(0)
: pad(encodedArgs.length / 2) + encodedArgs;
}
if (value.prim === 'view' && value.args) {
encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
}
return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
};
const primDecoder = (value, preamble) => {
const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
let argsCount = Math.floor((preamble[0] - 0x03) / 2);
const op = value.consume(1)[0].toString(16).padStart(2, '0');
const result = {
prim: opMapping$1[op],
};
if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
value.consume(4);
}
if (opMapping$1[op] === 'view') {
if (argsCount != 0) {
return primViewDecoder(value, result);
}
else {
return result;
}
}
let combPairArgs;
let combPairAnnots;
if ((opMapping$1[op] === 'pair' || opMapping$1[op] === 'Pair') && argsCount > 2) {
combPairArgs = decodeCombPair(value);
argsCount = 0;
combPairAnnots = decodeAnnots(value);
}
const args = new Array(argsCount).fill(0).map(() => valueDecoder(value));
if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
value.consume(4);
}
if (combPairArgs) {
result['args'] = combPairArgs;
}
else if (args.length) {
result['args'] = args;
}
if (combPairAnnots && combPairAnnots[0] !== '') {
result['annots'] = combPairAnnots;
}
else if (hasAnnot) {
result['annots'] = decodeAnnots(value);
}
return result;
};
const primViewDecoder = (value, result) => {
value.consume(4);
result['args'] = new Array(4).fill(0).map(() => valueDecoder(value));
value.consume(4);
return result;
};
const decodeCombPair = (val) => {
const array = new Uint8ArrayConsumer(extractRequiredLen(val));
const args = [];
while (array.length() > 0) {
args.push(valueDecoder(array));
}
return args;
};
const encodeAnnots = (value) => {
const mergedAnnot = value
.map((x) => {
return Buffer.from(x, 'utf8').toString('hex');
})
.join('20');
const len = mergedAnnot.length / 2;
return `${pad(len)}${mergedAnnot}`;
};
const decodeAnnots = (val) => {
const len = val.consume(4);
const annotLen = parseInt(Buffer.from(len).toString('hex'), 16);
const restOfAnnot = val.consume(annotLen);
const restOfAnnotHex = Buffer.from(restOfAnnot).toString('hex');
return restOfAnnotHex.split('20').map((x) => Buffer.from(x, 'hex').toString('utf8'));
};
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
const prefixEncoder$1 = (prefix) => (str) => {
return utils.buf2hex(Buffer.from(utils.b58cdecode(str, utils.prefix[prefix])));
};
const prefixDecoder$1 = (pre) => (str) => {
const val = str.consume(utils.prefixLength[pre]);
return utils.b58cencode(val, utils.prefix[pre]);
};
const tz1Decoder$1 = prefixDecoder$1(utils.Prefix.TZ1);
const branchDecoder$1 = prefixDecoder$1(utils.Prefix.B);
const publicKeyHashDecoder$1 = (val) => {
const prefix = val.consume(1);
if (prefix[0] === 0x00) {
return prefixDecoder$1(utils.Prefix.TZ1)(val);
}
else if (prefix[0] === 0x01) {
return prefixDecoder$1(utils.Prefix.TZ2)(val);
}
else if (prefix[0] === 0x02) {
return prefixDecoder$1(utils.Prefix.TZ3)(val);
}
else if (prefix[0] === 0x03) {
return prefixDecoder$1(utils.Prefix.TZ4)(val);
}
};
const publicKeyHashesDecoder$1 = (val) => {
if (!boolDecoder$1(val)) {
return;
}
const publicKeyHashes = [];
val.consume(4);
while (val.length() > 0) {
publicKeyHashes.push(publicKeyHashDecoder$1(val));
}
return publicKeyHashes;
};
const branchEncoder$1 = prefixEncoder$1(utils.Prefix.B);
const tz1Encoder$1 = prefixEncoder$1(utils.Prefix.TZ1);
const boolEncoder$1 = (bool) => (bool ? 'ff' : '00');
const proposalEncoder$1 = (proposal) => {
return prefixEncoder$1(utils.Prefix.P)(proposal);
};
const proposalDecoder$1 = (proposal) => {
return prefixDecoder$1(utils.Prefix.P)(proposal);
};
const proposalsDecoder$1 = (proposal) => {
const proposals = [];
proposal.consume(4);
while (proposal.length() > 0) {
proposals.push(proposalDecoder$1(proposal));
}
return proposals;
};
const proposalsEncoder$1 = (proposals) => {
return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder$1(x)).join('');
};
const ballotEncoder$1 = (ballot) => {
switch (ballot) {
case 'yay':
return '00';
case 'nay':
return '01';
case 'pass':
return '02';
default:
throw new InvalidBallotValueError(ballot);
}
};
const ballotDecoder$1 = (ballot) => {
const value = ballot.consume(1);
switch (value[0]) {
case 0x00:
return 'yay';
case 0x01:
return 'nay';
case 0x02:
return 'pass';
default:
throw new DecodeBallotValueError(value[0].toString());
}
};
const pvmKindEncoder$1 = (pvm) => {
switch (pvm) {
case 'arith':
return '00';
case 'wasm_2_0_0':
return '01';
case 'riscv':
return '02';
default:
throw new UnsupportedPvmKindError(pvm);
}
};
const pvmKindDecoder$1 = (pvm) => {
const value = pvm.consume(1);
switch (value[0]) {
case 0x00:
return 'arith';
case 0x01:
return 'wasm_2_0_0';
case 0x02:
return 'riscv';
default:
throw new DecodePvmKindError(value[0].toString());
}
};
const delegateEncoder$1 = (val) => {
if (val) {
return boolEncoder$1(true) + publicKeyHashEncoder$1(val);
}
else {
return boolEncoder$1(false);
}
};
const int32Encoder$1 = (val) => {
const num = parseInt(String(val), 10);
const byte = [];
for (let i = 0; i < 4; i++) {
const shiftBy = (4 - (i + 1)) * 8;
byte.push((num & (0xff << shiftBy)) >> shiftBy);
}
return Buffer.from(byte).toString('hex');
};
const int32Decoder$1 = (val) => {
const num = val.consume(4);
let finalNum = 0;
for (let i = 0; i < num.length; i++) {
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
}
return finalNum;
};
const int16Encoder$1 = (val) => {
const num = parseInt(String(val), 10);
const byte = [];
for (let i = 0; i < 2; i++) {
const shiftBy = (2 - (i + 1)) * 8;
byte.push((num & (0xff << shiftBy)) >> shiftBy);
}
return Buffer.from(byte).toString('hex');
};
const int16Decoder$1 = (val) => {
const num = val.consume(2);
let finalNum = 0;
for (let i = 0; i < num.length; i++) {
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
}
return finalNum;
};
const boolDecoder$1 = (val) => {
const bool = val.consume(1);
return bool[0] === 0xff;
};
const delegateDecoder$1 = (val) => {
const hasDelegate = boolDecoder$1(val);
if (hasDelegate) {
return publicKeyHashDecoder$1(val);
}
};
const publicKeyHashEncoder$1 = (val) => {
const pubkeyPrefix = val.substring(0, 3);
switch (pubkeyPrefix) {
case utils.Prefix.TZ1:
return '00' + prefixEncoder$1(utils.Prefix.TZ1)(val);
case utils.Prefix.TZ2:
return '01' + prefixEncoder$1(utils.Prefix.TZ2)(val);
case utils.Prefix.TZ3:
return '02' + prefixEncoder$1(utils.Prefix.TZ3)(val);
case utils.Prefix.TZ4:
return '03' + prefixEncoder$1(utils.Prefix.TZ4)(val);
default:
throw new utils.InvalidKeyHashError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
` expecting one for the following "${utils.Prefix.TZ1}", "${utils.Prefix.TZ2}", "${utils.Prefix.TZ3}" or "${utils.Prefix.TZ4}".`);
}
};
const publicKeyHashesEncoder$1 = (val) => {
if (!val) {
return boolEncoder$1(false);
}
if (val.length === 0) {
return boolEncoder$1(true) + pad(0);
}
const publicKeyHashes = val.reduce((prev, curr) => {
return prev + publicKeyHashEncoder$1(curr);
}, '');
return boolEncoder$1(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
};
const publicKeyEncoder$1 = (val) => {
const pubkeyPrefix = val.substring(0, 4);
switch (pubkeyPrefix) {
case utils.Prefix.EDPK:
return '00' + prefixEncoder$1(utils.Prefix.EDPK)(val);
case utils.Prefix.SPPK:
return '01' + prefixEncoder$1(utils.Prefix.SPPK)(val);
case utils.Prefix.P2PK:
return '02' + prefixEncoder$1(utils.Prefix.P2PK)(val);
case utils.Prefix.BLPK:
return '03' + prefixEncoder$1(utils.Prefix.BLPK)(val);
default:
throw new utils.InvalidPublicKeyError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
` expecting one of the following '${utils.Prefix.EDPK}', '${utils.Prefix.SPPK}', '${utils.Prefix.P2PK}' or '${utils.Prefix.BLPK}'.`);
}
};
const addressEncoder$1 = (val) => {
const pubkeyPrefix = val.substring(0, 3);
switch (pubkeyPrefix) {
case utils.Prefix.TZ1:
case utils.Prefix.TZ2:
case utils.Prefix.TZ3:
case utils.Prefix.TZ4:
return '00' + publicKeyHashEncoder$1(val);
case utils.Prefix.KT1:
return '01' + prefixEncoder$1(utils.Prefix.KT1)(val) + '00';
default:
throw new core.InvalidAddressError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
` expecting one of the following prefix '${utils.Prefix.TZ1}', ${utils.Prefix.TZ2}', '${utils.Prefix.TZ3}', '${utils.Prefix.TZ4}' or '${utils.Prefix.KT1}'.`);
}
};
const smartRollupAddressEncoder$1 = (val) => {
if (val.substring(0, 3) !== utils.Prefix.SR1) {
throw new InvalidSmartRollupAddressError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SR1}'.`);
}
return prefixEncoder$1(utils.Prefix.SR1)(val);
};
const smartContractAddressEncoder$1 = (val) => {
const prefix = val.substring(0, 3);
if (prefix === utils.Prefix.KT1) {
return '01' + prefixEncoder$1(utils.Prefix.KT1)(val) + '00';
}
throw new core.InvalidContractAddressError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.KT1}'.`);
};
const publicKeyDecoder$1 = (val) => {
const preamble = val.consume(1);
switch (preamble[0]) {
case 0x00:
return prefixDecoder$1(utils.Prefix.EDPK)(val);
case 0x01:
return prefixDecoder$1(utils.Prefix.SPPK)(val);
case 0x02:
return prefixDecoder$1(utils.Prefix.P2PK)(val);
case 0x03:
return prefixDecoder$1(utils.Prefix.BLPK)(val);
default:
throw new utils.InvalidPublicKeyError(val.toString(), utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED));
}
};
const smartRollupCommitmentHashEncoder$1 = (val) => {
const prefix = val.substring(0, 4);
if (prefix === utils.Prefix.SRC1) {
return prefixEncoder$1(utils.Prefix.SRC1)(val);
}
throw new InvalidSmartRollupCommitmentHashError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SRC1}'`);
};
const addressDecoder$1 = (val) => {
const preamble = val.consume(1);
switch (preamble[0]) {
case 0x00:
return publicKeyHashDecoder$1(val);
case 0x01: {
const address = prefixDecoder$1(utils.Prefix.KT1)(val);
val.consume(1);
return address;
}
default:
throw new core.InvalidAddressError(val.toString(), ': Unable to decode.');
}
};
const smartRollupAddressDecoder$1 = (val) => {
const address = prefixDecoder$1(utils.Prefix.SR1)(val);
if (address.substring(0, 3) !== utils.Prefix.SR1) {
throw new InvalidSmartRollupAddressError(address, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SR1}'.`);
}
return address;
};
const smartContractAddressDecoder$1 = (val) => {
const preamble = val.consume(1);
if (preamble[0] === 0x01) {
const scAddress = prefixDecoder$1(utils.Prefix.KT1)(val);
val.consume(1);
return scAddress;
}
throw new core.InvalidContractAddressError(val.toString(), utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED));
};
const smartRollupCommitmentHashDecoder$1 = (val) => {
const address = prefixDecoder$1(utils.Prefix.SRC1)(val);
if (address.substring(0, 4) !== utils.Prefix.SRC1) {
throw new InvalidSmartRollupCommitmentHashError(address, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SRC1}'`);
}
return address;
};
const zarithEncoder$1 = (n) => {
const fn = [];
let nn = new BigNumber(n, 10);
if (nn.isNaN()) {
throw new TypeError(`Invalid zarith number ${n}`);
}
// eslint-disable-next-line no-constant-condition
while (true) {
if (nn.lt(128)) {
if (nn.lt(16))
fn.push('0');
fn.push(nn.toString(16));
break;
}
else {
let b = nn.mod(128);
nn = nn.minus(b);
nn = nn.dividedBy(128);
b = b.plus(128);
fn.push(b.toString(16));
}
}
return fn.join('');
};
const zarithDecoder$1 = (n) => {
let mostSignificantByte = 0;
while (mostSignificantByte < n.length() && (n.get(mostSignificantByte) & 128) !== 0) {
mostSignificantByte += 1;
}
let num = new BigNumber(0);
for (let i = mostSignificantByte; i >= 0; i -= 1) {
const tmp = n.get(i) & 0x7f;
num = num.multipliedBy(128);
num = num.plus(tmp);
}
n.consume(mostSignificantByte + 1);
return new BigNumber(num).toString();
};
const entrypointDecoder$1 = (value) => {
const preamble = pad(value.consume(1)[0], 2);
if (preamble in entrypointMapping$1) {
return entrypointMapping$1[preamble];
}
else {
const entry = extractRequiredLen(value, 1);
const entrypoint = Buffer.from(entry).toString('utf8');
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
throw new OversizedEntryPointError(entrypoint);
}
return entrypoint;
}
};
const parametersDecoder$1 = (val) => {
const preamble = val.consume(1);
if (preamble[0] === 0x00) {
return;
}
else {
const encodedEntrypoint = entrypointDecoder$1(val);
const params = extractRequiredLen(val);
const parameters = valueDecoder(new Uint8ArrayConsumer(params));
return {
entrypoint: encodedEntrypoint,
value: parameters,
};
}
};
const entrypointEncoder$1 = (entrypoint) => {
if (entrypoint in entrypointMappingReverse$1) {
return `${entrypointMappingReverse$1[entrypoint]}`;
}
else {
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
throw new OversizedEntryPointError(entrypoint);
}
const value = { string: entrypoint };
return `ff${valueEncoder(value).slice(8)}`;
}
};
const parametersEncoder$1 = (val) => {
if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
return '00';
}
const encodedEntrypoint = entrypointEncoder$1(val.entrypoint);
const parameters = valueEncoder(val.value);
const length = pad(parameters.length / 2);
return `ff${encodedEntrypoint}${length}${parameters}`;
};
const valueParameterEncoder$1 = (value) => {
const valueEncoded = valueEncoder(value);
return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
};
const valueParameterDecoder$1 = (val) => {
const value = extractRequiredLen(val);
return valueDecoder(new Uint8ArrayConsumer(value));
};
const blockPayloadHashEncoder$1 = prefixEncoder$1(utils.Prefix.VH);
const blockPayloadHashDecoder$1 = prefixDecoder$1(utils.Prefix.VH);
const entrypointNameEncoder$1 = (entrypoint) => {
const value = { string: entrypoint };
return `${valueEncoder(value).slice(2)}`;
};
const entrypointNameDecoder$1 = (val) => {
const entry = extractRequiredLen(val);
return Buffer.from(entry).toString('utf8');
};
const burnLimitEncoder$1 = (val) => {
return !val ? '00' : `ff${zarithEncoder$1(val)}`;
};
const burnLimitDecoder$1 = (value) => {
const prefix = value.consume(1);
if (Buffer.from(prefix).toString('hex') !== '00') {
return zarithDecoder$1(value);
}
};
const depositsLimitEncoder$1 = (val) => {
return !val ? '00' : `ff${zarithEncoder$1(val)}`;
};
const depositsLimitDecoder$1 = (value) => {
const prefix = value.consume(1);
if (Buffer.from(prefix).toString('hex') !== '00') {
return zarithDecoder$1(value);
}
};
const signatureV1Encoder = (val) => {
const signaturePrefix = val.substring(0, 5);
switch (signaturePrefix) {
case utils.Prefix.EDSIG:
return paddedBytesEncoder$1(prefixEncoder$1(utils.Prefix.EDSIG)(val));
case utils.Prefix.SPSIG:
return paddedBytesEncoder$1(prefixEncoder$1(utils.Prefix.SPSIG)(val));
case utils.Prefix.P2SIG:
return paddedBytesEncoder$1(prefixEncoder$1(utils.Prefix.P2SIG)(val));
case utils.Prefix.BLSIG:
return paddedBytesEncoder$1(prefixEncoder$1(utils.Prefix.BLSIG)(val));
default:
throw new core.InvalidSignatureError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
` expecting one of the following '${utils.Prefix.EDSIG}', '${utils.Prefix.SPSIG}', '${utils.Prefix.P2SIG}' or '${utils.Prefix.BLSIG}'.`);
}
};
const signatureV1Decoder = (val) => {
val.consume(4);
if (val.length().toString() === '96') {
return prefixDecoder$1(utils.Prefix.BLSIG)(val);
}
else {
throw new core.ProhibitedActionError('currently we only support decoding of BLSIG signatures');
}
};
const signatureProofEncoder = (val) => {
if (val) {
return boolEncoder$1(true) + signatureV1Encoder(val);
}
else {
return boolEncoder$1(false);
}
};
const signatureProofDecoder = (value) => {
const hasProof = boolDecoder$1(value);
if (hasProof) {
return signatureV1Decoder(value);
}
};
const paddedBytesEncoder$1 = (val, paddingLength = 8) => {
return `${pad(val.length / 2, paddingLength)}${val}`;
};
const paddedBytesDecoder$1 = (val) => {
const value = extractRequiredLen(val);
return Buffer.from(value).toString('hex');
};
const smartRollupMessageEncoder$1 = (val) => {
const message = val.reduce((prev, curr) => {
return prev + `${pad(curr.length / 2)}${curr}`;
}, '');
return `${pad(message.length / 2)}${message}`;
};
const smartRollupMessageDecoder$1 = (val) => {
const valueArray = extractRequiredLen(val);
const ret = stripLengthPrefixFromBytes(new Uint8ArrayConsumer(valueArray));
return ret.map((value) => Buffer.from(value).toString('hex'));
};
const dalCommitmentEncoder$1 = (val) => {
const prefix = val.substring(0, 2);
if (prefix === utils.Prefix.SH) {
return prefixEncoder$1(utils.Prefix.SH)(val);
}
throw new InvalidDalCommitmentError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SH}'`);
};
const dalCommitmentDecoder$1 = (val) => {
const commitment = prefixDecoder$1(utils.Prefix.SH)(val);
if (commitment.substring(0, 2) !== utils.Prefix.SH) {
throw new InvalidDalCommitmentError(commitment, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SH}'`);
}
return commitment;
};
const slotHeaderEncoder$1 = (val) => {
return pad(val.slot_index, 2) + dalCommitmentEncoder$1(val.commitment) + val.commitment_proof;
};
const slotHeaderDecoder$1 = (val) => {
const preamble = val.consume(1);
return {
slot_index: Number(preamble[0].toString(10)),
commitment: dalCommitmentDecoder$1(val),
commitment_proof: toHexString(val.consume(96)), // rpcForger expect commitment_proof bytes to be len 96
};
};
const ManagerOperationSchema$1 = {
branch: exports.CODEC.BRANCH,
contents: [exports.CODEC.OPERATION],
};
const ActivationSchema$1 = {
pkh: exports.CODEC.TZ1,
secret: exports.CODEC.SECRET,
};
const RevealSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
public_key: exports.CODEC.PUBLIC_KEY,
};
const DelegationSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
delegate: exports.CODEC.DELEGATE,
};
const TransactionSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
amount: exports.CODEC.ZARITH,
destination: exports.CODEC.ADDRESS,
parameters: exports.CODEC.PARAMETERS,
};
const OriginationSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
balance: exports.CODEC.ZARITH,
delegate: exports.CODEC.DELEGATE,
script: exports.CODEC.SCRIPT,
};
const BallotSchema$1 = {
source: exports.CODEC.PKH,
period: exports.CODEC.INT32,
proposal: exports.CODEC.PROPOSAL,
ballot: exports.CODEC.BALLOT_STATEMENT,
};
const AttestationSchema$1 = {
slot: exports.CODEC.INT16,
level: exports.CODEC.INT32,
round: exports.CODEC.INT32,
block_payload_hash: exports.CODEC.BLOCK_PAYLOAD_HASH,
};
const AttestationWithDalSchema$1 = {
slot: exports.CODEC.INT16,
level: exports.CODEC.INT32,
round: exports.CODEC.INT32,
block_payload_hash: exports.CODEC.BLOCK_PAYLOAD_HASH,
dal_attestation: exports.CODEC.ZARITH,
};
const SeedNonceRevelationSchema$1 = {
level: exports.CODEC.INT32,
nonce: exports.CODEC.RAW,
};
const ProposalsSchema$1 = {
source: exports.CODEC.PKH,
period: exports.CODEC.INT32,
proposals: exports.CODEC.PROPOSAL_ARR,
};
const RegisterGlobalConstantSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
value: exports.CODEC.VALUE,
};
const TransferTicketSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
ticket_contents: exports.CODEC.VALUE,
ticket_ty: exports.CODEC.VALUE,
ticket_ticketer: exports.CODEC.ADDRESS,
ticket_amount: exports.CODEC.ZARITH,
destination: exports.CODEC.ADDRESS,
entrypoint: exports.CODEC.ENTRYPOINT,
};
const IncreasePaidStorageSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
amount: exports.CODEC.ZARITH,
destination: exports.CODEC.SMART_CONTRACT_ADDRESS,
};
const UpdateConsensusKeySchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
pk: exports.CODEC.PUBLIC_KEY,
proof: exports.CODEC.SIGNATURE_PROOF,
};
const DrainDelegateSchema$1 = {
consensus_key: exports.CODEC.PKH,
delegate: exports.CODEC.PKH,
destination: exports.CODEC.PKH,
};
const SetDepositsLimitSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
limit: exports.CODEC.DEPOSITS_LIMIT,
};
const SmartRollupOriginateSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
pvm_kind: exports.CODEC.PVM_KIND,
kernel: exports.CODEC.PADDED_BYTES,
parameters_ty: exports.CODEC.VALUE,
whitelist: exports.CODEC.PKH_ARR,
};
const SmartRollupAddMessagesSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
message: exports.CODEC.SMART_ROLLUP_MESSAGE,
};
const SmartRollupExecuteOutboxMessageSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
rollup: exports.CODEC.SMART_ROLLUP_ADDRESS,
cemented_commitment: exports.CODEC.SMART_ROLLUP_COMMITMENT_HASH,
output_proof: exports.CODEC.PADDED_BYTES,
};
const DalPublishCommitmentSchema$1 = {
source: exports.CODEC.PKH,
fee: exports.CODEC.ZARITH,
counter: exports.CODEC.ZARITH,
gas_limit: exports.CODEC.ZARITH,
storage_limit: exports.CODEC.ZARITH,
slot_header: exports.CODEC.SLOT_HEADER,
};
const FailingNoopSchema$1 = {
arbitrary: exports.CODEC.PADDED_BYTES,
};
const operationEncoder$1 = (encoders) => (operation) => {
if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse$1)) {
throw new core.InvalidOperationKindError(operation.kind);
}
return kindMappingReverse$1[operation.kind] + encoders[operatio