"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const txTypes = {
    0x01: 'BOND',
    0x02: 'UNBOND',
    0x03: 'NULL_TX',
    0x04: 'NAMESPACE_REGISTER',
    0x05: 'ASSET_CLASS_REGISTER',
    0x06: 'ASSET_ISSUE',
    0x07: 'ASSET_TRANSFER',
    0x08: 'REGISTER_ADDRESS',
    0x09: 'NAMESPACE_TRANSFER',
    0x0a: 'ASSET_CLASS_UPDATE',
    0x0b: 'ASSET_CLASS_DELETE',
    0x0c: 'NAMESPACE_DELETE',
    0x0d: 'ADDRESS_PERMISSIONS',
    0x0e: 'ADDRESS_DELETE',
    0x0f: 'PRIVILEGED_OPERATION',
    0x10: 'MEMO',
    0x11: 'ISSUER_TRANSFER',
    0x12: 'ENCUMBER',
    0x13: 'UNENCUMBER',
    0x14: 'EXERSISE_ENCUMBRANCE',
    0x15: 'LOCK_ASSET',
    0x16: 'UNLOCK_ASSET',
    0x17: 'POA_ADD',
    0x18: 'POA_DELETE',
    0x19: 'ISSUER_TRANSFER_FROM_MANY',
    0x1a: 'LOCK_HOLDING',
    0x1b: 'UNLOCK_HOLDING',
    0x1c: 'ASSET_ISSUE_AND_ENCUMBER',
    // Missing WFL & POA...
    0x80: 'ASSET_TRANSFER_X_CHAIN',
    0x81: 'X_CHAIN_TX_PACKAGE',
    0x82: 'ADD_X_CHAIN',
    0x83: 'DELETE_X_CHAIN',
    0x84: 'STOCK_SPLIT',
    0x85: 'DIVIDEND',
    0x86: 'TRANSFER_TO_MANY',
    0x90: 'NEW_CONTRACT',
    0x91: 'CANCEL_CONTRACT',
    0x92: 'COMMIT_TO_CONTRACT',
    0x93: 'NOTIFY_CONTRACT',
    0x100: 'JSON_CREATE_DATA_NAMESPACE',
    0x101: 'JSON_DELETE_DATA_NAMESPACE',
    0x102: 'JSON_UPDATE_DATA_NAMESPACE',
    0x103: 'JSON_CREATE_DATA_DOCUMENT',
    0x104: 'JSON_UPDATE_DATA_DOCUMENT',
    0x106: 'JSON_DELETE_DATA_DOCUMENT',
    0x105: 'JSON_UPDATE_DESCRIPTION',
    0x107: 'JSON_CREATE_VALIDATOR',
    0x10f: 'JSON_DELETE_VALIDATOR',
    0x108: 'JSON_CREATE_ALGORITHM',
    0x109: 'JSON_CREATE_ACL',
    0x10d: 'JSON_DELETE_ACL',
    0x10a: 'JSON_UPDATE_ACL',
    0x10b: 'JSON_CREATE_ACL_ROLE',
    0x10c: 'JSON_UPDATE_ACL_ROLE',
    0x10e: 'JSON_DELETE_ACL_ROLE',
};
const baseTx = ['chainId', 'version', 'txType', 'hash', 'nonce', 'updated', 'fromPublicKey', 'fromAddress', 'timestamp', 'powerOfAttorney'];
const baseTrailer = ['metadata', 'signature', 'height'];
const txTemplates = {
    0x01: [...baseTx, 'toSignorePubKey', 'returnAddress', 'amount', 'signature', 'height'],
    0x02: [...baseTx, 'toAddress', 'amount', 'signature', 'protocol', 'metadata', 'height'],
    0x03: [...baseTx, 'signature', 'height'],
    0x04: [...baseTx, 'namespace', ...baseTrailer],
    0x05: [...baseTx, 'namespace', 'classId', ...baseTrailer],
    0x06: [...baseTx, 'namespace', 'classId', 'toAddress', 'amount', 'protocol', 'metadata', 'signature', 'height'],
    0x07: [...baseTx, 'namespace', 'classId', 'toAddress', 'amount', 'signature', 'protocol', 'metadata', 'height'],
    0x08: [...baseTx, 'toAddress', ...baseTrailer],
    0x09: [...baseTx, 'namespace', 'toAddress', 'signature', 'height'],
    0x0a: [...baseTx, 'namespace', 'classId', ...baseTrailer],
    0x0b: [...baseTx, 'namespace', 'classId', ...baseTrailer],
    0x0c: [...baseTx, 'namespace', ...baseTrailer],
    0x0d: [...baseTx, 'toAddress', 'addressPermissions', 'transactions', ...baseTrailer],
    0x0e: [...baseTx, 'protocol', ...baseTrailer],
    0x0f: [...baseTx],
    0x10: [...baseTx, 'payload', ...baseTrailer],
    0x11: [...baseTx, 'namespace', 'classId', 'sourceAddress', 'toChainId', 'toAddress', 'amount', 'protocol', ...baseTrailer],
    0x12: [...baseTx, 'subjectAddress', 'namespace', 'classId', 'amount', 'txData', 'protocol', ...baseTrailer],
    0x13: [...baseTx, 'subjectAddress', 'namespace', 'classId', 'amount', 'reference', 'protocol', ...baseTrailer],
    0x14: [...baseTx, 'toChainId', 'toAddress', 'subjectAddress', 'namespace', 'classId', 'amount', 'reference', 'protocol', ...baseTrailer],
    0x15: [...baseTx, 'namespace', 'classId', 'lockDetails', 'metadata', ...baseTrailer],
    0x16: [...baseTx, 'namespace', 'classId', ...baseTrailer],
    0x17: [...baseTx, 'reference', 'attorneyAddress', 'startDate', 'endDate', 'itemData', 'protocol', ...baseTrailer],
    0x18: [...baseTx, 'reference', 'protocol', ...baseTrailer],
    0x19: [...baseTx, 'namespace', 'classId', 'amount', 'subjectAddress', 'signature', 'protocol', 'metadata', 'height'],
    0x1a: [...baseTx, 'subjectAddress', 'namespace', 'classId', 'amount', 'protocol', ...baseTrailer],
    0x1b: [...baseTx, 'subjectAddress', 'namespace', 'classId', 'amount', 'protocol', ...baseTrailer],
    0x1c: [...baseTx, 'namespace', 'classId', 'toAddress', 'amount', 'encumbranceData', 'protocol', ...baseTrailer],
    0x80: [...baseTx, 'namespace', 'classId', 'toChainId', 'toAddress', 'amount', 'signature', 'protocol', 'metadata', 'height'],
    0x81: [...baseTx, 'fromChainId', 'txVersion', 'baseHash', 'signodes', 'txHashList', 'xChainSigs', 'txList', 'blockTimestamp'],
    0x82: [...baseTx, 'newChainId', 'newBlockHeight', 'newChainParams', 'newChainSigNodes', 'signature', 'height'],
    0x83: [...baseTx, 'xChainId', ...baseTrailer],
    0x84: [...baseTx, 'namespace', 'classId', 'ratio', 'referenceStateHash', ...baseTrailer],
    0x85: [...baseTx],
    0x86: [...baseTx, 'namespace', 'classId', 'amount', 'toChainId', 'toAddresses', ...baseTrailer],
    0x90: [...baseTx, 'contractAddress', 'contractData', 'signature', 'height'],
    0x91: [...baseTx],
    0x92: [...baseTx, 'contractAddress', 'commitData', 'signature', 'height'],
    0x93: [...baseTx],
};
exports.createTx = (tx) => {
    const newTx = {};
    txTemplates[tx[2]].forEach((key, i) => newTx[key] = tx[i]);
    newTx.txType = txTypes[tx[2]];
    return newTx;
};
