From 5254351a4d31f1c11712493db88c08134ccbbde0 Mon Sep 17 00:00:00 2001 From: Matt Peterson Date: Sat, 7 Sep 2024 18:42:59 -0600 Subject: [PATCH 1/3] BinCode test and vitest --- bincode.js | 749 +++++++++++++++++++++++ bincode.test.js | 190 ++++++ hex.js | 34 ++ package-lock.json | 1483 ++++++++++++++++++++++++++++++++++++++++++++- package.json | 5 +- 5 files changed, 2433 insertions(+), 28 deletions(-) create mode 100644 bincode.js create mode 100644 bincode.test.js create mode 100644 hex.js diff --git a/bincode.js b/bincode.js new file mode 100644 index 0000000..97de46d --- /dev/null +++ b/bincode.js @@ -0,0 +1,749 @@ +import { toHex } from "./hex" + +/** + * @template T + * @typedef BinCodeable + * @prop {string} name + * @prop {(bc: BinCode, value: T) => void} encode + * @prop {(bc: BinCode) => T} decode + */ + +/** + * @template T + * @param {BinCodeable} _type + * @param {T} value + */ +export function encode(_type, value) { + const bc = new BinCode(new DataView(new ArrayBuffer(16))); + _type.encode(bc, value); + return bc.slice(); +} + +/** + * @template T + * @param {BinCodeable} _type + * @param {ArrayBuffer} value + */ +export function decode(_type, value) { + const bc = new BinCode(new DataView(value)); + return _type.decode(bc); +} + + +export class BinCode { + /** + * + * @param {DataView} dataview + * @param {number} idx + */ + constructor(dataview, idx=0) { + this.dataview = dataview; + this.idx = idx; + } + + /** + * Returns the slice from 0 to the current index, when done writing. + */ + slice() { + return this.dataview.buffer.slice(0, this.idx); + } + + /** + * @param {number} add + */ + _idxThenAdd(add) { + let idx = this.idx; + this.idx += add; + return idx; + } + + /** + * Returns the current index, before advancing it by `add`. If there are not enough + * bytes in the current dataview, replaces it a new one twice the size. + * @param {number} add + */ + _idxThenAddExtend(add) { + let idx = this.idx; + this.idx += add; + if (this.idx > this.dataview.byteLength) { + // not enough space, extend the dataview + let newlen = Math.max(this.dataview.byteLength * 2, this.idx + add); + let newab = new ArrayBuffer(newlen < 16? 32 : newlen); + new Uint8Array(newab).set(new Uint8Array(this.dataview.buffer), 0); + // console.log("Extending BinCode dataview: ", this.idx, add, this.dataview.byteLength, this.dataview.buffer, ' -> ', newab); + this.dataview = new DataView(newab); + } + return idx; + } + + /** + * @param {any} msg + */ + _debug(msg) { + console.log('DEBUG: ' + msg + ' at ' + this.idx + ': ' + toHex(this.dataview.buffer.slice(this.idx))); + } +} + +/** + * @template T + * @param {BinCodeable} inner + * @returns {BinCodeable} + */ +export function Vec(inner) { + return { + name: 'Vec<' + inner.name + '>', + encode(bc, val) { + VarUint.encode(bc, val.length); + for (let i = 0; i < val.length; i++) { + inner.encode(bc, val[i]); + } + }, + decode(bc) { + let len = VarUint.decode(bc); + let val = new Array(len); + for (let i = 0; i < len; i++) { + val[i] = inner.decode(bc); + } + return val; + } + } +} + +/** + * @template {{}} T + * @param {string} name + * @param {{[k in keyof T]: BinCodeable}} inner + * @returns {BinCodeable} + */ +export function Struct(name, inner) { + return { + name, + encode(bc, val) { + for (const innerKey in inner) { + // const startIdx = bc.idx; + inner[innerKey].encode(bc, val[innerKey]); + // console.log('DEBUG:', 'encode', name + '.' + innerKey, '=', val[innerKey], 'at', startIdx, toHex(bc.dataview.buffer.slice(startIdx, bc.idx))); + } + }, + decode(bc) { + /** @type {any} */ + let val = {}; + for (const innerKey in inner) { + // bc._debug('decode ' + name + '.' + innerKey + ' as ' + inner[innerKey].name); + val[innerKey] = inner[innerKey].decode(bc); + // console.log('DEBUG:', 'decode', name + '.' + innerKey, '=', val[innerKey]); + } + return val; + } + } +} + +/** + * @template T + * @param {string} name + * @param {(val: T) => number} toDiscriminant + * @param {{[k: number]: BinCodeable}} definitions + * @returns {BinCodeable} + */ +export function Enum(name, toDiscriminant, definitions) { + return { + name, + encode(bc, val) { + const discriminant = toDiscriminant(val); + VarUint.encode(bc, discriminant); + definitions[discriminant].encode(bc, val); + }, + decode(bc) { + const discriminant = Number(VarUint.decode(bc)); + if (!(discriminant in definitions)) + throw new Error("Enum " + name + " decode failed, bad discriminant: " + discriminant); + return definitions[discriminant].decode(bc); + } + } +} + +/** + * @template T + * @param {BinCodeable} inner + * @returns {BinCodeable} + */ +export function Option(inner) { + return Enum('Option<' + inner.name + '>', x => x == null? 0 : 1, { + 0: Null, + 1: inner, + }) +} + +/** + * @template T + * @param {() => BinCodeable} makeBincodeable + * @returns {BinCodeable} + */ +export function Lazy(makeBincodeable) { + /** @type {BinCodeable | undefined} */ + let bincodeable = undefined; + return { + get name() { + if (!bincodeable) bincodeable = makeBincodeable(); + return bincodeable.name; + }, + encode(bc, val) { + if (!bincodeable) bincodeable = makeBincodeable(); + bincodeable.encode(bc, val); + }, + decode(bc) { + if (!bincodeable) bincodeable = makeBincodeable(); + return bincodeable.decode(bc); + } + } +} + +/** @type {BinCodeable} */ +export const TODO = { + name: 'TODO', + encode(bc, num) { + throw new Error("TODO"); + }, + decode(bc) { + throw new Error("TODO"); + } +} + +/** @type {BinCodeable} */ +export const Nothing = { + name: 'Nothing', + encode(bc, num) {}, + decode(bc) {} +} + +/** @type {BinCodeable} */ +export const Null = { + name: 'Null', + encode(bc, num) {}, + decode(bc) { return null; } +} + +/** + * Constant doesn't encode or decode any bytes, it just always decodes to the constant value. + * @template T + * @param {T} value + * @returns {BinCodeable} + */ +export function Constant(value) { + return { + name: 'Constant<'+value+'>', + encode(bc, num) {}, + decode(bc) { return value; } + } +} + +/** @type {BinCodeable} */ +export const Uint8 = { + name: 'Uint8', + encode(bc, num) { + bc.dataview.setUint8(bc._idxThenAddExtend(1), num); + }, + decode(bc) { + return bc.dataview.getUint8(bc._idxThenAdd(1)); + } +} + +/** @type {BinCodeable} */ +export const Uint16 = { + name: 'Uint16', + encode(bc, num) { + bc.dataview.setUint16(bc._idxThenAddExtend(2), num, true); + }, + decode(bc) { + return bc.dataview.getUint16(bc._idxThenAdd(2)); + } +} + +/** @type {BinCodeable} */ +export const Uint32 = { + name: 'Uint32', + encode(bc, num) { + bc.dataview.setUint32(bc._idxThenAddExtend(4), num, true); + }, + decode(bc) { + return bc.dataview.getUint32(bc._idxThenAdd(4)); + } +} + +/** @type {BinCodeable} */ +export const Uint64 = { + name: 'Uint64', + encode(bc, num) { + bc.dataview.setBigUint64(bc._idxThenAddExtend(8), num, true); + }, + decode(bc) { + return bc.dataview.getBigUint64(bc._idxThenAdd(8)); + } +} + +/** @type {BinCodeable} */ +export const Uint128 = { + name: 'Uint128', + encode(bc, num) { + let a = BigInt.asUintN(64, num); + let b = BigInt.asUintN(64, num>>64n); + bc.dataview.setBigUint64(bc._idxThenAddExtend(8), a, true); + bc.dataview.setBigUint64(bc._idxThenAddExtend(8), b, true); + }, + decode(bc) { + let a = Uint64.decode(bc); + let b = Uint64.decode(bc); + return BigInt(a.toString() + b.toString()); + } +} + +/** + * @param {bigint} u + */ +function _zigzag(u) { + if (u == 0n) return 0n; + + // To avoid the edge case of Signed::min_value() + // !n is equal to `-n - 1`, so this is: + // !n * 2 + 1 = 2(-n - 1) + 1 = -2n - 2 + 1 = -2n - 1 + if (u < 0) return (-u - 1n) * 2n - 1n; + if (u > 0) return u * 2n; + throw new Error("_zigzag error: " + u); +} + +/** + * @param {bigint} u + */ +function _unzigzag(u) { + if (u % 2n == 0n) { + // positive number + return u >> 1n + } else { + // negative number + // !m * 2 + 1 = u + // !m * 2 = u - 1 + // !m = (u - 1) / 2 + // m = !((u - 1) / 2) + // since we have u is odd, we have floor(u / 2) = floor((u - 1) / 2) + return ((-u) >> 1n) - 1n + } +} + +/** + * @param {bigint} value + */ +function _fitsInNumber(value) { + return value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER +} + +/** @type {BinCodeable} */ +export const VarUint = { + name: 'VarUint', + encode(bc, num) { + if (typeof num === 'number' && (num|0) !== num) + throw new Error("VarUint.encode: not an integer:" + num); + if (num < 0) + throw new Error("VarUint.encode: negative:" + num); + + // console.log('DEBUG:', 'VarUint.encode', num); + + if (num < 251) Uint8.encode(bc, Number(num)); + else if (251 <= num && num < 2**16) { + Uint8.encode(bc, 251); + Uint16.encode(bc, Number(num)); + } + else if (2**16 <= num && num < 2**32) { + Uint8.encode(bc, 252); + Uint32.encode(bc, Number(num)); + } + // TODO: Bignum for the rest of these + else if (2**32 <= num && num < 2**64) { + Uint8.encode(bc, 253); + Uint64.encode(bc, BigInt(num)); + } + else if (2**64 <= num && num < 2**128) { + Uint8.encode(bc, 254); + Uint128.encode(bc, BigInt(num)); + } else { + throw new Error("VarUint.encode error: " + num); + } + }, + + decode(bc) { + let u = BigInt(Uint8.decode(bc)); + if (u < 251) {} + else if (u == 251n) + u = BigInt(Uint16.decode(bc)); + else if (u == 252n) + u = BigInt(Uint32.decode(bc)); + // TODO: Bignum for the rest of these + else if (u == 253n) + u = Uint64.decode(bc); + else if (u == 254n) + u = Uint128.decode(bc); + else + throw new Error("VarUint.decode error: " + u); + + if (_fitsInNumber(u)) return Number(u); + return u; + } +} + +/** @type {BinCodeable} */ +export const VarInt = { + name: 'VarInt', + encode(bc, num) { + if (typeof num === 'number' && (num|0) !== num) + throw new Error("VarInt.encode: not an integer:" + num); + + let bnum = BigInt(num) + bnum = _zigzag(bnum); + if (bnum < 251) Uint8.encode(bc, Number(bnum)); + else if (251 <= bnum && bnum < 2**16) { + Uint8.encode(bc, 251); + Uint16.encode(bc, Number(bnum)); + } + else if (2**16 <= bnum && bnum < 2**32) { + Uint8.encode(bc, 252); + Uint32.encode(bc, Number(bnum)); + } + // TODO: Bignum for the rest of these + else if (2**32 <= bnum && bnum < 2**64) { + Uint8.encode(bc, 253); + Uint64.encode(bc, bnum); + } + else if (2**64 <= bnum && bnum < 2**128) { + Uint8.encode(bc, 254); + Uint128.encode(bc, bnum); + } else { + throw new Error("VarInt.encode error: " + bnum); + } + }, + + decode(bc) { + let u = BigInt(Uint8.decode(bc)); + if (u < 251) {} + else if (u == 251n) + u = BigInt(Uint16.decode(bc)); + else if (u == 252n) + u = BigInt(Uint32.decode(bc)); + // TODO: Bignum for the rest of these + else if (u == 253n) + u = Uint64.decode(bc); + else if (u == 254n) + u = Uint128.decode(bc); + else + throw new Error("VarInt.decode error: " + u); + + u = _unzigzag(u); + if (_fitsInNumber(u)) return Number(u); + return u; + } +} + +/** @type {BinCodeable} */ +export const Bool = { + name: 'Bool', + encode(bc, val) { + return Uint8.encode(bc, val ? 1 : 0); + }, + decode(bc) { + const val = Uint8.decode(bc); + if (val !== 0 && val !== 1) throw new Error("Bool decode error: " + val) + return !!val; + } +} + +/** @type {BinCodeable} */ +export const Bytes = { + name: 'Bytes', + encode(bc, val) { + // console.log('Bytes.encode', val, val.length); + // bc._debug('Bytes.encode length') + VarUint.encode(bc, val.length); + // console.log('After slice', bc.slice()) + let idx = bc._idxThenAddExtend(val.length); + new Uint8Array(bc.dataview.buffer).set(val, idx); + }, + decode(bc) { + let length = Number(VarUint.decode(bc)); + let idx = bc._idxThenAdd(length); + return new Uint8Array(bc.dataview.buffer, idx, length); + } +} + +/** @type {BinCodeable} */ +export const String = { + name: 'String', + encode(bc, val) { + const bytes = new TextEncoder().encode(val); + Bytes.encode(bc, bytes); + }, + decode(bc) { + const bytes = Bytes.decode(bc); + return new TextDecoder().decode(bytes); + } +} + +/** + * @param {number} length + * @returns {BinCodeable} + */ +export function FixedBytes(length) { + return { + name: 'FixedBytes<'+length+'>', + encode(bc, val) { + let idx = bc._idxThenAddExtend(length); + new Uint8Array(bc.dataview.buffer).set(val, idx); + }, + decode(bc) { + let idx = bc._idxThenAdd(length); + return new Uint8Array(bc.dataview.buffer, idx, length); + } + } +} + +export const IdentityCreateTransitionSignable = Lazy(() => + Enum('IdentityCreateTransitionSignable', x => 0, { + 0: Struct('IdentityCreateTransitionV0Signable', { + $version: Constant('0'), + // // When signing, we don't sign the signatures for keys + // #[platform_signable(into = "Vec")] + public_keys: Vec(IdentityPublicKeyInCreationSignable), + asset_lock_proof: RawAssetLockProof, + user_fee_increase: UserFeeIncrease, + // #[platform_signable(exclude_from_sig_hash)] + // signature: BinaryData, + // #[cfg_attr(feature = "state-transition-serde-conversion", serde(skip))] + // #[platform_signable(exclude_from_sig_hash)] + // identity_id: Identifier, + }) + }) +) + +export const IdentityCreateTransition = Lazy(() => + Enum('IdentityCreateTransition', x => 0, { + 0: Struct('IdentityCreateTransitionV0', { + $version: Constant('0'), + // // When signing, we don't sign the signatures for keys + // #[platform_signable(into = "Vec")] + public_keys: Vec(IdentityPublicKeyInCreation), + asset_lock_proof: RawAssetLockProof, + user_fee_increase: UserFeeIncrease, + // #[platform_signable(exclude_from_sig_hash)] + signature: BinaryData, + // #[cfg_attr(feature = "state-transition-serde-conversion", serde(skip))] + // #[platform_signable(exclude_from_sig_hash)] + identity_id: Identifier, + }) + }) +) + +export const KeyID = VarUint; +export const Identifier = FixedBytes(32); +export const BinaryData = Bytes; +export const UserFeeIncrease = VarUint; //Uint16; +export const TimestampMillis = VarUint; //Uint64; + +export const KeyType = VarUint; // enum +export const KeyType_values = [ + 'ECDSA_SECP256K1', + 'BLS12_381', + 'ECDSA_HASH160', + 'BIP13_SCRIPT_HASH', + 'EDDSA_25519_HASH160', +]; + +export const Purpose = VarUint; // enum +export const Purpose_values = [ + 'AUTHENTICATION', + 'ENCRYPTION', + 'DECRYPTION', + 'TRANSFER', + 'SYSTEM', + 'VOTING', +]; + +export const SecurityLevel = VarUint; // enum +export const SecurityLevel_values = [ + 'MASTER', + 'CRITICAL', + 'HIGH', + 'MEDIUM', +]; + +export const ContractBounds = Lazy(() => + Enum('ContractBounds', x => 'document_type_name' in x? 1 : 0, { + 0: Struct('ContractBounds0', { + id: Identifier, + }), + 1: Struct('ContractBounds1', { + id: Identifier, + document_type_name: String, + }) + }) +) + +export const IdentityPublicKeyInCreationSignable = Enum('IdentityPublicKeyInCreationSignable', x => x.$version, { + 0: Struct('IdentityPublicKeyInCreationV0Signable', { + $version: Constant('0'), + id: KeyID, + type: KeyType, + purpose: Purpose, + security_level: SecurityLevel, + contract_bounds: Option(ContractBounds), + read_only: Bool, + data: BinaryData, + // /// The signature is needed for ECDSA_SECP256K1 Key type and BLS12_381 Key type + // #[platform_signable(exclude_from_sig_hash)] + // signature: BinaryData, + }), +}) + +export const IdentityPublicKeyInCreation = Enum('IdentityPublicKeyInCreation', x => x.$version, { + 0: Struct('IdentityPublicKeyInCreationV0', { + $version: Constant('0'), + id: KeyID, + type: KeyType, + purpose: Purpose, + security_level: SecurityLevel, + contract_bounds: Option(ContractBounds), + read_only: Bool, + data: BinaryData, + // /// The signature is needed for ECDSA_SECP256K1 Key type and BLS12_381 Key type + // #[platform_signable(exclude_from_sig_hash)] + signature: BinaryData, + }) +}) + +export const Txid = FixedBytes(32); +export const CycleHash = FixedBytes(32); +export const BLSSignature = FixedBytes(96); +export const ScriptBuf = Bytes; + +export const OutPoint = Struct('OutPoint', { + txid: Txid, + vout: Uint32, +}) + +export const InstantLock = Struct('InstantLock', { + version: Uint8, + inputs: Vec(OutPoint), + txid: Txid, + cyclehash: CycleHash, + signature: BLSSignature, +}) + +export const Witness = Struct('Witness', { + content: Bytes, + witness_elements: Uint64, + indices_start: Uint64, +}) + +export const TxIn = Struct('TxIn', { + previous_output: OutPoint, + script_sig: ScriptBuf, + sequence: Uint32, + witness: Witness +}) + +export const TxOut = Struct('TxOut', { + value: Uint64, + script_pubkey: ScriptBuf, +}) + +export const TransactionPayload = Enum('TransactionPayload', x => -1, { + // TODO +}) + +export const Transaction = Struct('Transaction', { + version: Uint16, + lock_time: Uint32, + input: Vec(TxIn), + output: Vec(TxOut), + special_transaction_payload: Option(TransactionPayload), +}) + +export const InstantAssetLockProof = Struct('InstantAssetLockProof', { + instant_lock: InstantLock, + transaction: Transaction, + output_index: Uint32, +}) + +export const RawInstantLockProof = Struct('RawInstantLockProof', { + instant_lock: BinaryData, + transaction: BinaryData, + output_index: VarUint, //Uint32, +}) + +export const ChainAssetLockProof = Struct('ChainAssetLockProof', { + core_chain_locked_height: Uint32, + out_point: OutPoint, +}) + +export const AssetLockProof = Enum('AssetLockProof', x => 0, { + 0: InstantAssetLockProof, + 1: ChainAssetLockProof, +}) + +export const RawAssetLockProof = Enum('RawAssetLockProof', x => 0, { + 0: RawInstantLockProof, + 1: ChainAssetLockProof, +}) + +export const IdentityPublicKey = Enum('IdentityPublicKey', x => 0, { + 0: Struct('IdentityPublicKeyV0', { + $version: Constant('0'), + id: KeyID, + purpose: Purpose, + security_level: SecurityLevel, + contract_bounds: Option(ContractBounds), + type: KeyType, + read_only: Bool, + data: BinaryData, + disabled_at: Option(TimestampMillis), + }), +}) + +/** + * This is a JSON.stringify replacer that converts keys to camelCase + * and Uint8Array to regular Array to match what to_json* does. + * @param {string} key + * @param {any} value + */ +function jsonCamelCaseReplacer(key, value) { + if (value instanceof Uint8Array) { + return Array.from(value) + } + if (value && typeof value === 'object') { + /** @type {any} */ + let replacement = {}; + for (let k of Object.keys(value)) { + let newkey = k.replace(/_[a-z]/g, val => val[1].toUpperCase()) + replacement[newkey] = value[k]; + } + return replacement; + } + return value; +} +/** + * @param {any} value + */ +export function toJsonCamelCase(value) { + return JSON.stringify(value, jsonCamelCaseReplacer) +} + + + +// TODO! +export const StateTransition = Enum('StateTransition', x => 3, { + // 0: DataContractCreateTransition, //DataContractCreate(DataContractCreateTransition), + // 1: DataContractUpdateTransition, //DataContractUpdate(DataContractUpdateTransition), + // 2: DocumentsBatchTransition, //DocumentsBatch(DocumentsBatchTransition), + 3: IdentityCreateTransition, //IdentityCreate(IdentityCreateTransition), + // 4: IdentityTopUpTransition, //IdentityTopUp(IdentityTopUpTransition), + // 5: IdentityCreditWithdrawalTransition, //IdentityCreditWithdrawal(IdentityCreditWithdrawalTransition), + // 6: IdentityUpdateTransition, //IdentityUpdate(IdentityUpdateTransition), + // 7: IdentityCreditTransferTransition, //IdentityCreditTransfer(IdentityCreditTransferTransition), + // 8: MasternodeVoteTransition, //MasternodeVote(MasternodeVoteTransition), +}) diff --git a/bincode.test.js b/bincode.test.js new file mode 100644 index 0000000..1304fd4 --- /dev/null +++ b/bincode.test.js @@ -0,0 +1,190 @@ +import { it, expect } from 'vitest' +import { fromHex } from './hex' +import { decode, encode, Identifier, IdentityPublicKey, StateTransition, toJsonCamelCase } from './bincode' + +it('should encode/decode IdentityPublicKey', () => { + const master_key_bytes = fromHex('0000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f00') + const master_key = decode(IdentityPublicKey, master_key_bytes.buffer) + + const master_key_json = { + "$version": "0", + "id": 0, + "purpose": 0, + "securityLevel": 0, + "contractBounds": null, + "type": 0, + "readOnly": false, + "data": [3, 58, 154, 139, 30, 76, 88, 26, 25, 135, 114, 76, 102, 151, 19, 93, 49, 192, 126, 231, 172, 130, 126, 106, 89, 206, 192, 34, 176, 77, 81, 5, 95], + "disabledAt": null + } + expect(master_key_json).toEqual(JSON.parse(toJsonCamelCase(master_key))) + expect(master_key_bytes).toEqual(new Uint8Array(encode(IdentityPublicKey, master_key))) + + const master_private_key = fromHex('6c554775029f960891e3edf2d36b26a30d9a4b10034bb49f3a6c4617f557f7bc') + + const other_key_bytes = fromHex('000100010000002102014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e200') + const other_key = decode(IdentityPublicKey, other_key_bytes.buffer) + + const other_key_json = { "$version": "0", "id": 1, "purpose": 0, "securityLevel": 1, "contractBounds": null, "type": 0, "readOnly": false, "data": [2, 1, 70, 3, 1, 141, 196, 55, 100, 45, 218, 22, 244, 199, 252, 80, 228, 130, 221, 35, 226, 70, 128, 188, 179, 165, 150, 108, 59, 52, 56, 72, 226], "disabledAt": null } + expect(other_key_json).toEqual(JSON.parse(toJsonCamelCase(other_key))) + + const other_private_key = fromHex('426ae4838204206cacdfc7a2e04ac6a2d9e3c2e94df935878581c552f22b0096') +}); + +it('should encode/decode Identifier', () => { + const identifier_bytes = fromHex('3dc908599ef8a5a3c510c430a27d4211c805556d99e5c06ffc3ca86a5feb55c3') + const identifier = decode(Identifier, identifier_bytes.buffer) + + // expect(master_key_json).toEqual(JSON.parse(toJsonCamelCase(master_key))) + expect(identifier_bytes).toEqual(new Uint8Array(encode(Identifier, identifier))) +}) + +it('should encode/decode StateTransition', () => { + // const key_signable_bytes = fromHex('0300020000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f000100000100002102014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e200c601011dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e0000000058c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b436a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c8967c46529a967b3822e1ba8a173066296d02593f0f59b3a78a30a7eef9c8a120847729e62e4a32954339286b79fe7590221331cd28d576887a263f45b595d499272f656c3f5176987c976239cac16f972d796ad82931d532102a4f95eec7d809e00000800015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a4000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac000000000200e1f50500000000026a0088130000000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac0000000024000100e1f505000000001976a914271c99481ce1460e4fd62d5a11eecc123d78ee3288ac0000') + const asset_lock_private_key = fromHex('33a9f0603ba69b97dff83e08b4ee36cebbc987739e9749615e1727754f2bf2d2') + + const state_transition_signable_bytes = fromHex('0300020000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f000100000100002102014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e200c601011dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e0000000058c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b436a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c8967c46529a967b3822e1ba8a173066296d02593f0f59b3a78a30a7eef9c8a120847729e62e4a32954339286b79fe7590221331cd28d576887a263f45b595d499272f656c3f5176987c976239cac16f972d796ad82931d532102a4f95eec7d809e00000800015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a4000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac000000000200e1f50500000000026a0088130000000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac0000000024000100e1f505000000001976a914271c99481ce1460e4fd62d5a11eecc123d78ee3288ac0000') + + // asset_lock_proof + // + // ```json + // asset_lock_proof {"instantLock":[1,1,29,187,218,88,97,177,45,117,35,242,10,165,224,212,47,82,222,61,205,45,92,47,233,25,186,103,181,159,5,13,32,110,0,0,0,0,88,196,68,221,9,87,118,125,178,192,173,234,105,253,134,23,146,191,167,92,126,54,77,131,254,133,190,190,188,42,8,180,54,165,102,23,89,26,106,137,35,123,173,166,175,31,155,70,235,164,123,93,137,168,196,228,159,242,208,35,97,130,48,124,137,103,196,101,41,169,103,179,130,46,27,168,161,115,6,98,150,208,37,147,240,245,155,58,120,163,10,126,239,156,138,18,8,71,114,158,98,228,163,41,84,51,146,134,183,159,231,89,2,33,51,28,210,141,87,104,135,162,99,244,91,89,93,73,146,114,246,86,195,245,23,105,135,201,118,35,156,172,22,249,114,215,150,173,130,147,29,83,33,2,164,249,94,236,125,128],"transaction":[0,0,8,0,1,88,132,229,219,157,226,24,35,134,113,87,35,64,178,7,238,133,182,40,7,78,126,70,112,150,194,103,38,107,175,119,164,0,0,0,0,25,118,169,20,136,217,147,30,167,61,96,234,247,229,103,30,252,5,82,185,18,145,31,42,136,172,0,0,0,0,2,0,225,245,5,0,0,0,0,2,106,0,136,19,0,0,0,0,0,0,25,118,169,20,136,217,147,30,167,61,96,234,247,229,103,30,252,5,82,185,18,145,31,42,136,172,0,0,0,0,36,0,1,0,225,245,5,0,0,0,0,25,118,169,20,39,28,153,72,28,225,70,14,79,214,45,90,17,238,204,18,61,120,238,50,136,172],"outputIndex":0} + // ``` + // + const state_transition_bytes = fromHex('0300020000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f411f6ca4070bc91c2e21f785113a4669fa32bdf24f9e0e67966b5186254265b5d2fd52ef7a9ca7e6ed03ef9838c56bbeb32bf0722f11a95982bfa14a61f56d7c523e000100000100002102014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e2411f6776128925163122c68e4ad230cf59c5a8444e518d6a5592d242e9f48e85498e371b78520812536a57ef4400a5e7a43307283c5da62ba343d8f23574c15a2db700c601011dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e0000000058c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b436a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c8967c46529a967b3822e1ba8a173066296d02593f0f59b3a78a30a7eef9c8a120847729e62e4a32954339286b79fe7590221331cd28d576887a263f45b595d499272f656c3f5176987c976239cac16f972d796ad82931d532102a4f95eec7d809e00000800015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a4000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac000000000200e1f50500000000026a0088130000000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac0000000024000100e1f505000000001976a914271c99481ce1460e4fd62d5a11eecc123d78ee3288ac0000411fea1c5e3b0c92c8d02fd52c47fe5f215a828d05c317a997a4a3419a17b9260b9717ccee2603bf5ae411bba1ab8e1d0bbc31cbd73d7d6fefcdb4feb34657b2e5093dc908599ef8a5a3c510c430a27d4211c805556d99e5c06ffc3ca86a5feb55c3') + const state_transition = decode(StateTransition, state_transition_bytes.buffer) + expect(state_transition_bytes).toEqual(new Uint8Array(encode(StateTransition, state_transition))) + + /* + IdentityCreate(V0(IdentityCreateTransitionV0 { + public_keys: [ + V0(IdentityPublicKeyInCreationV0 { + id: 0, + key_type: ECDSA_SECP256K1, + purpose: AUTHENTICATION, + security_level: MASTER, + contract_bounds: None, + read_only: false, + data: BinaryData(0x033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f), + signature: BinaryData(0x1f6ca4070bc91c2e21f785113a4669fa32bdf24f9e0e67966b5186254265b5d2fd52ef7a9ca7e6ed03ef9838c56bbeb32bf0722f11a95982bfa14a61f56d7c523e) + }), + V0(IdentityPublicKeyInCreationV0 { + id: 1, + key_type: ECDSA_SECP256K1, + purpose: AUTHENTICATION, + security_level: CRITICAL, + contract_bounds: None, + read_only: false, + data: BinaryData(0x02014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e2), + signature: BinaryData(0x1f6776128925163122c68e4ad230cf59c5a8444e518d6a5592d242e9f48e85498e371b78520812536a57ef4400a5e7a43307283c5da62ba343d8f23574c15a2db7) + }) + ], + asset_lock_proof: Instant(InstantAssetLockProof { + instant_lock: InstantLock { + version: 1, + inputs: [ + OutPoint { + txid: 0x6e200d059fb567ba19e92f5c2dcd3dde522fd4e0a50af223752db16158dabb1d, + vout: 0 + } + ], + txid: b4082abcbebe85fe834d367e5ca7bf921786fd69eaadc0b27d765709dd44c458, + cyclehash: 0x7c30826123d0f29fe4c4a8895d7ba4eb469b1fafa6ad7b23896a1a591766a536, + signature: [137, 103, 196, 101, 41, 169, 103, 179, 130, 46, 27, 168, 161, 115, 6, 98, 150, 208, + 37, 147, 240, 245, 155, 58, 120, 163, 10, 126, 239, 156, 138, 18, 8, 71, 114, 158, 98, 228, 163, + 41, 84, 51, 146, 134, 183, 159, 231, 89, 2, 33, 51, 28, 210, 141, 87, 104, 135, 162, 99, 244, 91, + 89, 93, 73, 146, 114, 246, 86, 195, 245, 23, 105, 135, 201, 118, 35, 156, 172, 22, 249, 114, 215, + 150, 173, 130, 147, 29, 83, 33, 2, 164, 249, 94, 236, 125, 128] + }, + transaction: Transaction { + version: 0, + lock_time: 0, + input: [ + TxIn { + previous_output: OutPoint { + txid: 0xa477af6b2667c29670467e4e0728b685ee07b240235771862318e29ddbe58458, + vout: 0 + }, + script_sig: Script(OP_DUP OP_HASH160 OP_PUSHBYTES_20 88d9931ea73d60eaf7e5671efc0552b912911f2a OP_EQUALVERIFY OP_CHECKSIG), + sequence: 0, + witness: Witness { content: [], witness_elements: 0, indices_start: 0 } + } + ], + output: [ + TxOut { + value: 100000000, + script_pubkey: Script(OP_RETURN OP_0) + }, + TxOut { + value: 5000, + script_pubkey: Script(OP_DUP OP_HASH160 OP_PUSHBYTES_20 88d9931ea73d60eaf7e5671efc0552b912911f2a OP_EQUALVERIFY OP_CHECKSIG) + } + ], + special_transaction_payload: Some(AssetLockPayloadType(AssetLockPayload { + version: 0, + credit_outputs: [ + TxOut { + value: 100000000, + script_pubkey: Script(OP_DUP OP_HASH160 OP_PUSHBYTES_20 271c99481ce1460e4fd62d5a11eecc123d78ee32 OP_EQUALVERIFY OP_CHECKSIG) + } + ] + })) + }, + output_index: 0 + }), + user_fee_increase: 0, + signature: BinaryData(0x), + identity_id: Identifier(IdentifierBytes32([61, 201, 8, 89, 158, 248, 165, 163, 197, 16, 196, 48, 162, 125, 66, 17, 200, 5, 85, 109, 153, 229, 192, 111, 252, 60, 168, 106, 95, 235, 85, 195])) + })) + */ +}); + +// it('should encode/decode Identity', () => { +// const identity_json = { +// "$version": "0", +// "id": [61, 201, 8, 89, 158, 248, 165, 163, 197, 16, 196, 48, 162, 125, 66, 17, 200, 5, 85, 109, 153, 229, 192, 111, 252, 60, 168, 106, 95, 235, 85, 195], +// "publicKeys": [ +// { +// "$version": "0", +// "id": 0, +// "purpose": 0, +// "securityLevel": 0, +// "contractBounds": null, +// "type": 0, +// "readOnly": false, +// "data": [3, 58, 154, 139, 30, 76, 88, 26, 25, 135, 114, 76, 102, 151, 19, 93, 49, 192, 126, 231, 172, 130, 126, 106, 89, 206, 192, 34, 176, 77, 81, 5, 95], +// "disabledAt": null +// }, { +// "$version": "0", +// "id": 1, +// "purpose": 0, +// "securityLevel": 1, +// "contractBounds": null, +// "type": 0, +// "readOnly": false, +// "data": [2, 1, 70, 3, 1, 141, 196, 55, 100, 45, 218, 22, 244, 199, 252, 80, 228, 130, 221, 35, 226, 70, 128, 188, 179, 165, 150, 108, 59, 52, 56, 72, 226], +// "disabledAt": null +// } +// ], +// "balance": 1000000000, +// "revision": 0 +// } +// // +// // ``` +// // identity V0(IdentityV0 { id: Identifier(IdentifierBytes32([61, 201, 8, 89, 158, 248, 165, 163, 197, 16, 196, 48, 162, 125, 66, 17, 200, 5, 85, 109, 153, 229, 192, 111, 252, 60, 168, 106, 95, 235, 85, 195])), public_keys: {0: V0(IdentityPublicKeyV0 { id: 0, purpose: AUTHENTICATION, security_level: MASTER, contract_bounds: None, key_type: ECDSA_SECP256K1, read_only: false, data: BinaryData(0x033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f), disabled_at: None }), 1: V0(IdentityPublicKeyV0 { id: 1, purpose: AUTHENTICATION, security_level: CRITICAL, contract_bounds: None, key_type: ECDSA_SECP256K1, read_only: false, data: BinaryData(0x02014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e2), disabled_at: None })}, balance: 1000000000, revision: 0 }) +// // ``` +// // +// // ``` +// // identity_create_transition +// // .public_keys +// // .iter_mut() +// // .zip(identity.public_keys().iter()) +// // .try_for_each(|(public_key_with_witness, (_, public_key))| { +// // if public_key.key_type().is_unique_key_type() { +// // let signature = signer.sign(public_key, &key_signable_bytes)?; +// // public_key_with_witness.set_signature(signature); +// // } +// // Ok::<(), ProtocolError>(()) +// // })?; +// // ``` +// }) \ No newline at end of file diff --git a/hex.js b/hex.js new file mode 100644 index 0000000..7171e36 --- /dev/null +++ b/hex.js @@ -0,0 +1,34 @@ +/** + * @type {string[]} + */ +const byteToHex = []; + +for (let n = 0; n <= 0xff; ++n) +{ + const hexOctet = n.toString(16).padStart(2, "0"); + byteToHex.push(hexOctet); +} + +/** + * @param {ArrayBuffer} arrayBuffer + */ +export function toHex(arrayBuffer) +{ + const buff = new Uint8Array(arrayBuffer); + const hexOctets = []; // new Array(buff.length) is even faster (preallocates necessary array size), then use hexOctets[i] instead of .push() + + for (let i = 0; i < buff.length; ++i) + hexOctets.push(byteToHex[buff[i]]); + + return hexOctets.join(""); +} + +/** + * @param {string} string + */ +export function fromHex(string) { + const uint8array = new Uint8Array(Math.ceil(string.length / 2)); + for (let i = 0; i < string.length;) + uint8array[i / 2] = Number.parseInt(string.slice(i, i += 2), 16); + return uint8array; +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 36e16ea..ffb6205 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,21 @@ "dashhd": "^3.3.3", "dashkeys": "^1.1.5", "dashphrase": "^1.4.0", - "dashtx": "^0.20.1" + "dashtx": "^0.20.1", + "vitest": "^2.0.5" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" } }, "node_modules/@dashevo/bls": { @@ -82,6 +96,12 @@ "pbts": "bin/pbts" } }, + "node_modules/@dashevo/protobufjs/node_modules/@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", + "license": "MIT" + }, "node_modules/@dashevo/protobufjs/node_modules/long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", @@ -106,6 +126,374 @@ "integrity": "sha512-3iA+RDZrJsRFPpWhlYkp3EdoFAlKjdqkNFiRwajMrzcpA/G/IBX0AnC1pwRLkTrM+tUowcyGrkJfT03U4ETZeg==", "license": "MIT" }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@grpc/grpc-js": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.4.4.tgz", @@ -169,6 +557,54 @@ "google-protobuf": "^3.14.0" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -233,6 +669,220 @@ "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==", "license": "BSD-3-Clause" }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.2.tgz", + "integrity": "sha512-fSuPrt0ZO8uXeS+xP3b+yYTCBUd05MoSp2N/MFOgjhhUhMmchXlpTQrTpI8T+YAwAQuK7MafsCOxW7VrPMrJcg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.2.tgz", + "integrity": "sha512-xGU5ZQmPlsjQS6tzTTGwMsnKUtu0WVbl0hYpTPauvbRAnmIvpInhJtgjj3mcuJpEiuUw4v1s4BimkdfDWlh7gA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.2.tgz", + "integrity": "sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.2.tgz", + "integrity": "sha512-ZbRaUvw2iN/y37x6dY50D8m2BnDbBjlnMPotDi/qITMJ4sIxNY33HArjikDyakhSv0+ybdUxhWxE6kTI4oX26w==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.2.tgz", + "integrity": "sha512-ztRJJMiE8nnU1YFcdbd9BcH6bGWG1z+jP+IPW2oDUAPxPjo9dverIOyXz76m6IPA6udEL12reYeLojzW2cYL7w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.2.tgz", + "integrity": "sha512-flOcGHDZajGKYpLV0JNc0VFH361M7rnV1ee+NTeC/BQQ1/0pllYcFmxpagltANYt8FYf9+kL6RSk80Ziwyhr7w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.2.tgz", + "integrity": "sha512-69CF19Kp3TdMopyteO/LJbWufOzqqXzkrv4L2sP8kfMaAQ6iwky7NoXTp7bD6/irKgknDKM0P9E/1l5XxVQAhw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.2.tgz", + "integrity": "sha512-48pD/fJkTiHAZTnZwR0VzHrao70/4MlzJrq0ZsILjLW/Ab/1XlVUStYyGt7tdyIiVSlGZbnliqmult/QGA2O2w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.2.tgz", + "integrity": "sha512-cZdyuInj0ofc7mAQpKcPR2a2iu4YM4FQfuUzCVA2u4HI95lCwzjoPtdWjdpDKyHxI0UO82bLDoOaLfpZ/wviyQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.2.tgz", + "integrity": "sha512-RL56JMT6NwQ0lXIQmMIWr1SW28z4E4pOhRRNqwWZeXpRlykRIlEpSWdsgNWJbYBEWD84eocjSGDu/XxbYeCmwg==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.2.tgz", + "integrity": "sha512-PMxkrWS9z38bCr3rWvDFVGD6sFeZJw4iQlhrup7ReGmfn7Oukrr/zweLhYX6v2/8J6Cep9IEA/SmjXjCmSbrMQ==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.2.tgz", + "integrity": "sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.2.tgz", + "integrity": "sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.2.tgz", + "integrity": "sha512-9rRero0E7qTeYf6+rFh3AErTNU1VCQg2mn7CQcI44vNUWM9Ze7MSRS/9RFuSsox+vstRt97+x3sOhEey024FRQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.2.tgz", + "integrity": "sha512-5rA4vjlqgrpbFVVHX3qkrCo/fZTj1q0Xxpg+Z7yIo3J2AilW7t2+n6Q8Jrx+4MrYpAnjttTYF8rr7bP46BPzRw==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.2.tgz", + "integrity": "sha512-6UUxd0+SKomjdzuAcp+HAmxw1FlGBnl1v2yEPSabtx4lBfdXHDVsW7+lQkgz9cNFJGY3AWR7+V8P5BqkD9L9nA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "license": "MIT" + }, "node_modules/@types/long": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", @@ -240,45 +890,138 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", - "license": "MIT" - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "version": "22.5.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.4.tgz", + "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", "license": "MIT", - "engines": { - "node": ">=8" + "dependencies": { + "undici-types": "~6.19.2" } }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "node_modules/@vitest/expect": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.0.5.tgz", + "integrity": "sha512-yHZtwuP7JZivj65Gxoi8upUN2OzHTi3zVfjwdpu2WrvCZPLwsJ2Ey5ILIPccoW23dd/zQBlJ4/dhi7DWNyXCpA==", "license": "MIT", "dependencies": { - "color-convert": "^2.0.1" + "@vitest/spy": "2.0.5", + "@vitest/utils": "2.0.5", + "chai": "^5.1.1", + "tinyrainbow": "^1.2.0" }, - "engines": { - "node": ">=8" + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/pretty-format": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.0.5.tgz", + "integrity": "sha512-h8k+1oWHfwTkyTkb9egzwNMfJAEx4veaPSnMeKbVSjp4euqGSbQlm5+6VHwTr7u4FJslVVsUG5nopCaAYdOmSQ==", + "license": "MIT", + "dependencies": { + "tinyrainbow": "^1.2.0" }, "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" + "url": "https://opencollective.com/vitest" } }, - "node_modules/base-x": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.10.tgz", - "integrity": "sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==", + "node_modules/@vitest/runner": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.0.5.tgz", + "integrity": "sha512-TfRfZa6Bkk9ky4tW0z20WKXFEwwvWhRY+84CnSEtq4+3ZvDlJyY32oNTJtM7AW9ihW90tX/1Q78cb6FjoAs+ig==", "license": "MIT", "dependencies": { - "safe-buffer": "^5.0.1" + "@vitest/utils": "2.0.5", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" } }, - "node_modules/binascii": { + "node_modules/@vitest/snapshot": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.0.5.tgz", + "integrity": "sha512-SgCPUeDFLaM0mIUHfaArq8fD2WbaXG/zVXjRupthYfYGzc8ztbFbu6dUNOblBG7XLMR1kEhS/DNnfCZ2IhdDew==", + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.0.5", + "magic-string": "^0.30.10", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.0.5.tgz", + "integrity": "sha512-c/jdthAhvJdpfVuaexSrnawxZz6pywlTPe84LUB2m/4t3rl2fTo9NFGBG4oWgaD+FTgDDV8hJ/nibT7IfH3JfA==", + "license": "MIT", + "dependencies": { + "tinyspy": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.0.5.tgz", + "integrity": "sha512-d8HKbqIcya+GR67mkZbrzhS5kKhtp8dQLcmRZLGTscGVg7yImT82cIrhtn2L8+VujWcy6KZweApgNmPsTAO/UQ==", + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.0.5", + "estree-walker": "^3.0.3", + "loupe": "^3.1.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/base-x": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.10.tgz", + "integrity": "sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/binascii": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/binascii/-/binascii-0.0.2.tgz", "integrity": "sha512-rA2CrUl1+6yKrn+XgLs8Hdy18OER1UW146nM+ixzhQXDY+Bd3ySkyIJGwF2a4I45JwbvF1mDL/nWkqBwpOcdBA==" @@ -298,6 +1041,15 @@ "base-x": "^3.0.2" } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/cbor": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/cbor/-/cbor-8.1.0.tgz", @@ -319,6 +1071,31 @@ "node": ">=16" } }, + "node_modules/chai": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz", + "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==", + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -348,6 +1125,20 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "license": "MIT" }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/dashhd": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/dashhd/-/dashhd-3.3.3.tgz", @@ -375,12 +1166,76 @@ "dashtx-inspect": "bin/inspect.js" } }, + "node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "license": "MIT" }, + "node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, "node_modules/escalade": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", @@ -390,6 +1245,52 @@ "node": ">=6" } }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/execa": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -399,12 +1300,42 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/google-protobuf": { "version": "3.21.4", "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.4.tgz", "integrity": "sha512-MnG7N936zcKTco4Jd2PX2U96Kf9PxygAPKBug+74LHzmHXmceN16MmRcdgZv+DGef/S9YvQAfRsNCn4cjf9yyQ==", "license": "(BSD-3-Clause AND Apache-2.0)" }, + "node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=16.17.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -414,6 +1345,24 @@ "node": ">=8" } }, + "node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC" + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -432,6 +1381,66 @@ "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==", "license": "Apache-2.0" }, + "node_modules/loupe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", + "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==", + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/magic-string": { + "version": "0.30.11", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz", + "integrity": "sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "license": "MIT" + }, + "node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/nofilter": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/nofilter/-/nofilter-3.1.0.tgz", @@ -441,6 +1450,106 @@ "node": ">=12.19" } }, + "node_modules/npm-run-path": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", + "license": "MIT", + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "license": "MIT", + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picocolors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", + "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.4.45", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.45.tgz", + "integrity": "sha512-7KTLTdzdZZYscUc65XmjFiB73vBhBfbPztCYdUNvlaso9PrzjzcmjqBPR0lNGkcVlcO4BjiO5rK/qNz+XAen1Q==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.1", + "source-map-js": "^1.2.0" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, "node_modules/protobufjs": { "version": "6.11.4", "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.4.tgz", @@ -482,6 +1591,41 @@ "node": ">=0.10.0" } }, + "node_modules/rollup": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.21.2.tgz", + "integrity": "sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw==", + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.5" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.21.2", + "@rollup/rollup-android-arm64": "4.21.2", + "@rollup/rollup-darwin-arm64": "4.21.2", + "@rollup/rollup-darwin-x64": "4.21.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.21.2", + "@rollup/rollup-linux-arm-musleabihf": "4.21.2", + "@rollup/rollup-linux-arm64-gnu": "4.21.2", + "@rollup/rollup-linux-arm64-musl": "4.21.2", + "@rollup/rollup-linux-powerpc64le-gnu": "4.21.2", + "@rollup/rollup-linux-riscv64-gnu": "4.21.2", + "@rollup/rollup-linux-s390x-gnu": "4.21.2", + "@rollup/rollup-linux-x64-gnu": "4.21.2", + "@rollup/rollup-linux-x64-musl": "4.21.2", + "@rollup/rollup-win32-arm64-msvc": "4.21.2", + "@rollup/rollup-win32-ia32-msvc": "4.21.2", + "@rollup/rollup-win32-x64-msvc": "4.21.2", + "fsevents": "~2.3.2" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -514,6 +1658,66 @@ "node": ">=10" } }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "license": "ISC" + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/source-map-js": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", + "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", + "license": "MIT" + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -540,12 +1744,239 @@ "node": ">=8" } }, + "node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "license": "MIT" + }, + "node_modules/tinypool": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.1.tgz", + "integrity": "sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==", + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", + "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.0.tgz", + "integrity": "sha512-q5nmENpTHgiPVd1cJDDc9cVoYN5x4vCvwT3FMilvKPKneCBZAxn2YWQjDF0UMcE9k0Cay1gBiDfTMU0g+mPMQA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "license": "MIT" + }, "node_modules/varint": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==", "license": "MIT" }, + "node_modules/vite": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.3.tgz", + "integrity": "sha512-IH+nl64eq9lJjFqU+/yrRnrHPVTlgy42/+IzbOdaFDVlyLgI/wDlf+FCobXLX1cT0X5+7LMyH1mIy2xJdLfo8Q==", + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.0.5.tgz", + "integrity": "sha512-LdsW4pxj0Ot69FAoXZ1yTnA9bjGohr2yNBU7QKRxpz8ITSkhuDl6h3zS/tvgz4qrNjeRnvrWeXQ8ZF7Um4W00Q==", + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.5", + "pathe": "^1.1.2", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.0.5.tgz", + "integrity": "sha512-8GUxONfauuIdeSl5f9GTgVEpg5BTOlplET4WEDaeY2QBiN8wSm68vxN/tb5z405OwppfoCavnwXafiaYBC/xOA==", + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.3.0", + "@vitest/expect": "2.0.5", + "@vitest/pretty-format": "^2.0.5", + "@vitest/runner": "2.0.5", + "@vitest/snapshot": "2.0.5", + "@vitest/spy": "2.0.5", + "@vitest/utils": "2.0.5", + "chai": "^5.1.1", + "debug": "^4.3.5", + "execa": "^8.0.1", + "magic-string": "^0.30.10", + "pathe": "^1.1.2", + "std-env": "^3.7.0", + "tinybench": "^2.8.0", + "tinypool": "^1.0.0", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.0.5", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.0.5", + "@vitest/ui": "2.0.5", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index 82d3666..ccd9a07 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A lightweight library Dash Platform identities, data contracts, and documents", "main": "dashplatform.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "vitest", "jshint": "npx -p jshint@2.x -- jshint -c ./.jshintrc ./*.js", "lint": "npm run jshint && npm run tsc", "prettier": "npx -p prettier@3.x -- prettier -w '**/*.{js,md}'", @@ -25,6 +25,7 @@ "dashhd": "^3.3.3", "dashkeys": "^1.1.5", "dashphrase": "^1.4.0", - "dashtx": "^0.20.1" + "dashtx": "^0.20.1", + "vitest": "^2.0.5" } } From f0c76b0134957f7d0e2a2efb1a2c2c335d3cf2ff Mon Sep 17 00:00:00 2001 From: Matt Peterson Date: Sat, 7 Sep 2024 20:59:53 -0600 Subject: [PATCH 2/3] StateTransitionSignable --- bincode.js | 12 ++++++++++++ bincode.test.js | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bincode.js b/bincode.js index 97de46d..b346c11 100644 --- a/bincode.js +++ b/bincode.js @@ -747,3 +747,15 @@ export const StateTransition = Enum('StateTransition', x => 3, { // 7: IdentityCreditTransferTransition, //IdentityCreditTransfer(IdentityCreditTransferTransition), // 8: MasternodeVoteTransition, //MasternodeVote(MasternodeVoteTransition), }) + +export const StateTransitionSignable = Enum('StateTransition', x => 3, { + // 0: DataContractCreateTransition, //DataContractCreate(DataContractCreateTransition), + // 1: DataContractUpdateTransition, //DataContractUpdate(DataContractUpdateTransition), + // 2: DocumentsBatchTransition, //DocumentsBatch(DocumentsBatchTransition), + 3: IdentityCreateTransitionSignable, //IdentityCreate(IdentityCreateTransition), + // 4: IdentityTopUpTransition, //IdentityTopUp(IdentityTopUpTransition), + // 5: IdentityCreditWithdrawalTransition, //IdentityCreditWithdrawal(IdentityCreditWithdrawalTransition), + // 6: IdentityUpdateTransition, //IdentityUpdate(IdentityUpdateTransition), + // 7: IdentityCreditTransferTransition, //IdentityCreditTransfer(IdentityCreditTransferTransition), + // 8: MasternodeVoteTransition, //MasternodeVote(MasternodeVoteTransition), +}) diff --git a/bincode.test.js b/bincode.test.js index 1304fd4..7e52494 100644 --- a/bincode.test.js +++ b/bincode.test.js @@ -1,6 +1,6 @@ import { it, expect } from 'vitest' import { fromHex } from './hex' -import { decode, encode, Identifier, IdentityPublicKey, StateTransition, toJsonCamelCase } from './bincode' +import { decode, encode, Identifier, IdentityPublicKey, StateTransition, StateTransitionSignable, toJsonCamelCase } from './bincode' it('should encode/decode IdentityPublicKey', () => { const master_key_bytes = fromHex('0000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f00') @@ -44,7 +44,9 @@ it('should encode/decode StateTransition', () => { const asset_lock_private_key = fromHex('33a9f0603ba69b97dff83e08b4ee36cebbc987739e9749615e1727754f2bf2d2') const state_transition_signable_bytes = fromHex('0300020000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f000100000100002102014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e200c601011dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e0000000058c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b436a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c8967c46529a967b3822e1ba8a173066296d02593f0f59b3a78a30a7eef9c8a120847729e62e4a32954339286b79fe7590221331cd28d576887a263f45b595d499272f656c3f5176987c976239cac16f972d796ad82931d532102a4f95eec7d809e00000800015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a4000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac000000000200e1f50500000000026a0088130000000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac0000000024000100e1f505000000001976a914271c99481ce1460e4fd62d5a11eecc123d78ee3288ac0000') - + const state_transition_signable = decode(StateTransitionSignable, state_transition_signable_bytes.buffer) + expect(state_transition_signable_bytes).toEqual(new Uint8Array(encode(StateTransitionSignable, state_transition_signable))) + // asset_lock_proof // // ```json From a43b07990a31ff510908192625a95b0b0ffc423c Mon Sep 17 00:00:00 2001 From: Matt Peterson Date: Mon, 9 Sep 2024 11:13:31 -0600 Subject: [PATCH 3/3] Fix types and dedup signable --- bincode.js | 113 ++++++++++++++++++++---------------------------- bincode.test.js | 8 ++-- 2 files changed, 52 insertions(+), 69 deletions(-) diff --git a/bincode.js b/bincode.js index b346c11..700a9bf 100644 --- a/bincode.js +++ b/bincode.js @@ -13,8 +13,8 @@ import { toHex } from "./hex" * @param {BinCodeable} _type * @param {T} value */ -export function encode(_type, value) { - const bc = new BinCode(new DataView(new ArrayBuffer(16))); +export function encode(_type, value, options={}) { + const bc = new BinCode(new DataView(new ArrayBuffer(16)), 0, options); _type.encode(bc, value); return bc.slice(); } @@ -24,8 +24,8 @@ export function encode(_type, value) { * @param {BinCodeable} _type * @param {ArrayBuffer} value */ -export function decode(_type, value) { - const bc = new BinCode(new DataView(value)); +export function decode(_type, value, options={}) { + const bc = new BinCode(new DataView(value), 0, options); return _type.decode(bc); } @@ -35,10 +35,12 @@ export class BinCode { * * @param {DataView} dataview * @param {number} idx + * @param {any} options */ - constructor(dataview, idx=0) { + constructor(dataview, idx=0, options={}) { this.dataview = dataview; this.idx = idx; + this.options = options; } /** @@ -100,6 +102,7 @@ export function Vec(inner) { }, decode(bc) { let len = VarUint.decode(bc); + /** @type {any[]} */ let val = new Array(len); for (let i = 0; i < len; i++) { val[i] = inner.decode(bc); @@ -137,13 +140,23 @@ export function Struct(name, inner) { } } } - -/** + +/** + * @template T + * @typedef {{[k in keyof T]: T[k] extends BinCodeable? U : never}[keyof T]} EnumType + */ + +/** * @template T + * @typedef {T extends infer U? {[k in keyof U]: U[k]} : never} Expand + */ + +/** + * @template {{[k: number]: BinCodeable}} T * @param {string} name - * @param {(val: T) => number} toDiscriminant - * @param {{[k: number]: BinCodeable}} definitions - * @returns {BinCodeable} + * @param {(val: EnumType) => number} toDiscriminant + * @param {T} definitions + * @returns {BinCodeable>} */ export function Enum(name, toDiscriminant, definitions) { return { @@ -165,7 +178,6 @@ export function Enum(name, toDiscriminant, definitions) { /** * @template T * @param {BinCodeable} inner - * @returns {BinCodeable} */ export function Option(inner) { return Enum('Option<' + inner.name + '>', x => x == null? 0 : 1, { @@ -198,7 +210,7 @@ export function Lazy(makeBincodeable) { } } -/** @type {BinCodeable} */ +/** @type {BinCodeable} */ export const TODO = { name: 'TODO', encode(bc, num) { @@ -216,7 +228,7 @@ export const Nothing = { decode(bc) {} } -/** @type {BinCodeable} */ +/** @type {BinCodeable} */ export const Null = { name: 'Null', encode(bc, num) {}, @@ -503,23 +515,24 @@ export function FixedBytes(length) { } } -export const IdentityCreateTransitionSignable = Lazy(() => - Enum('IdentityCreateTransitionSignable', x => 0, { - 0: Struct('IdentityCreateTransitionV0Signable', { - $version: Constant('0'), - // // When signing, we don't sign the signatures for keys - // #[platform_signable(into = "Vec")] - public_keys: Vec(IdentityPublicKeyInCreationSignable), - asset_lock_proof: RawAssetLockProof, - user_fee_increase: UserFeeIncrease, - // #[platform_signable(exclude_from_sig_hash)] - // signature: BinaryData, - // #[cfg_attr(feature = "state-transition-serde-conversion", serde(skip))] - // #[platform_signable(exclude_from_sig_hash)] - // identity_id: Identifier, - }) - }) -) +/** + * @template T + * @param {BinCodeable} inner + * @returns {BinCodeable} + */ +export function NotSignable(inner) { + return { + name: 'NotSignable<' + inner.name + '>', + encode(bc, value) { + if (!bc.options.signable) + inner.encode(bc, value); + }, + decode(bc) { + if (!bc.options.signable) + return inner.decode(bc); + } + } +} export const IdentityCreateTransition = Lazy(() => Enum('IdentityCreateTransition', x => 0, { @@ -531,10 +544,10 @@ export const IdentityCreateTransition = Lazy(() => asset_lock_proof: RawAssetLockProof, user_fee_increase: UserFeeIncrease, // #[platform_signable(exclude_from_sig_hash)] - signature: BinaryData, + signature: NotSignable(BinaryData), // #[cfg_attr(feature = "state-transition-serde-conversion", serde(skip))] // #[platform_signable(exclude_from_sig_hash)] - identity_id: Identifier, + identity_id: NotSignable(Identifier), }) }) ) @@ -584,23 +597,7 @@ export const ContractBounds = Lazy(() => }) ) -export const IdentityPublicKeyInCreationSignable = Enum('IdentityPublicKeyInCreationSignable', x => x.$version, { - 0: Struct('IdentityPublicKeyInCreationV0Signable', { - $version: Constant('0'), - id: KeyID, - type: KeyType, - purpose: Purpose, - security_level: SecurityLevel, - contract_bounds: Option(ContractBounds), - read_only: Bool, - data: BinaryData, - // /// The signature is needed for ECDSA_SECP256K1 Key type and BLS12_381 Key type - // #[platform_signable(exclude_from_sig_hash)] - // signature: BinaryData, - }), -}) - -export const IdentityPublicKeyInCreation = Enum('IdentityPublicKeyInCreation', x => x.$version, { +export const IdentityPublicKeyInCreation = Enum('IdentityPublicKeyInCreation', x => +x.$version, { 0: Struct('IdentityPublicKeyInCreationV0', { $version: Constant('0'), id: KeyID, @@ -612,7 +609,7 @@ export const IdentityPublicKeyInCreation = Enum('IdentityPublicKeyInCreation', x data: BinaryData, // /// The signature is needed for ECDSA_SECP256K1 Key type and BLS12_381 Key type // #[platform_signable(exclude_from_sig_hash)] - signature: BinaryData, + signature: NotSignable(BinaryData), }) }) @@ -733,9 +730,7 @@ export function toJsonCamelCase(value) { return JSON.stringify(value, jsonCamelCaseReplacer) } - - -// TODO! +// TODO: Implement all the other transitions export const StateTransition = Enum('StateTransition', x => 3, { // 0: DataContractCreateTransition, //DataContractCreate(DataContractCreateTransition), // 1: DataContractUpdateTransition, //DataContractUpdate(DataContractUpdateTransition), @@ -747,15 +742,3 @@ export const StateTransition = Enum('StateTransition', x => 3, { // 7: IdentityCreditTransferTransition, //IdentityCreditTransfer(IdentityCreditTransferTransition), // 8: MasternodeVoteTransition, //MasternodeVote(MasternodeVoteTransition), }) - -export const StateTransitionSignable = Enum('StateTransition', x => 3, { - // 0: DataContractCreateTransition, //DataContractCreate(DataContractCreateTransition), - // 1: DataContractUpdateTransition, //DataContractUpdate(DataContractUpdateTransition), - // 2: DocumentsBatchTransition, //DocumentsBatch(DocumentsBatchTransition), - 3: IdentityCreateTransitionSignable, //IdentityCreate(IdentityCreateTransition), - // 4: IdentityTopUpTransition, //IdentityTopUp(IdentityTopUpTransition), - // 5: IdentityCreditWithdrawalTransition, //IdentityCreditWithdrawal(IdentityCreditWithdrawalTransition), - // 6: IdentityUpdateTransition, //IdentityUpdate(IdentityUpdateTransition), - // 7: IdentityCreditTransferTransition, //IdentityCreditTransfer(IdentityCreditTransferTransition), - // 8: MasternodeVoteTransition, //MasternodeVote(MasternodeVoteTransition), -}) diff --git a/bincode.test.js b/bincode.test.js index 7e52494..617d812 100644 --- a/bincode.test.js +++ b/bincode.test.js @@ -44,8 +44,8 @@ it('should encode/decode StateTransition', () => { const asset_lock_private_key = fromHex('33a9f0603ba69b97dff83e08b4ee36cebbc987739e9749615e1727754f2bf2d2') const state_transition_signable_bytes = fromHex('0300020000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f000100000100002102014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e200c601011dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e0000000058c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b436a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c8967c46529a967b3822e1ba8a173066296d02593f0f59b3a78a30a7eef9c8a120847729e62e4a32954339286b79fe7590221331cd28d576887a263f45b595d499272f656c3f5176987c976239cac16f972d796ad82931d532102a4f95eec7d809e00000800015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a4000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac000000000200e1f50500000000026a0088130000000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac0000000024000100e1f505000000001976a914271c99481ce1460e4fd62d5a11eecc123d78ee3288ac0000') - const state_transition_signable = decode(StateTransitionSignable, state_transition_signable_bytes.buffer) - expect(state_transition_signable_bytes).toEqual(new Uint8Array(encode(StateTransitionSignable, state_transition_signable))) + const state_transition_signable = decode(StateTransition, state_transition_signable_bytes.buffer, {signable: true}) + expect(state_transition_signable_bytes).toEqual(new Uint8Array(encode(StateTransition, state_transition_signable, {signable: true}))) // asset_lock_proof // @@ -54,8 +54,8 @@ it('should encode/decode StateTransition', () => { // ``` // const state_transition_bytes = fromHex('0300020000000000000021033a9a8b1e4c581a1987724c6697135d31c07ee7ac827e6a59cec022b04d51055f411f6ca4070bc91c2e21f785113a4669fa32bdf24f9e0e67966b5186254265b5d2fd52ef7a9ca7e6ed03ef9838c56bbeb32bf0722f11a95982bfa14a61f56d7c523e000100000100002102014603018dc437642dda16f4c7fc50e482dd23e24680bcb3a5966c3b343848e2411f6776128925163122c68e4ad230cf59c5a8444e518d6a5592d242e9f48e85498e371b78520812536a57ef4400a5e7a43307283c5da62ba343d8f23574c15a2db700c601011dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e0000000058c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b436a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c8967c46529a967b3822e1ba8a173066296d02593f0f59b3a78a30a7eef9c8a120847729e62e4a32954339286b79fe7590221331cd28d576887a263f45b595d499272f656c3f5176987c976239cac16f972d796ad82931d532102a4f95eec7d809e00000800015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a4000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac000000000200e1f50500000000026a0088130000000000001976a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac0000000024000100e1f505000000001976a914271c99481ce1460e4fd62d5a11eecc123d78ee3288ac0000411fea1c5e3b0c92c8d02fd52c47fe5f215a828d05c317a997a4a3419a17b9260b9717ccee2603bf5ae411bba1ab8e1d0bbc31cbd73d7d6fefcdb4feb34657b2e5093dc908599ef8a5a3c510c430a27d4211c805556d99e5c06ffc3ca86a5feb55c3') - const state_transition = decode(StateTransition, state_transition_bytes.buffer) - expect(state_transition_bytes).toEqual(new Uint8Array(encode(StateTransition, state_transition))) + const state_transition = decode(StateTransition, state_transition_bytes.buffer, {signable: false}) + expect(state_transition_bytes).toEqual(new Uint8Array(encode(StateTransition, state_transition, {signable: false}))) /* IdentityCreate(V0(IdentityCreateTransitionV0 {