Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stacks/transactions

Package Overview
Dependencies
Maintainers
5
Versions
662
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stacks/transactions - npm Package Compare versions

Comparing version 6.14.1-pr.81 to 6.14.1-pr.82

4

dist/authorization.js

@@ -118,3 +118,3 @@ "use strict";

}
const signature = (0, wire_1.deserializeMessageSignatureBytes)(bytesReader);
const signature = (0, wire_1.deserializeMessageSignature)(bytesReader);
return {

@@ -134,3 +134,3 @@ hashMode,

const fee = BigInt('0x' + (0, common_1.bytesToHex)(bytesReader.readBytes(8)));
const fields = (0, wire_1.deserializeLPListBytes)(bytesReader, wire_1.StacksWireType.TransactionAuthField)
const fields = (0, wire_1.deserializeLPList)(bytesReader, wire_1.StacksWireType.TransactionAuthField)
.values;

@@ -137,0 +137,0 @@ let haveUncompressed = false;

@@ -7,3 +7,3 @@ export declare function isEnum<T extends string, TEnumValue extends number>(enumVariable: {

consumed: number;
constructor(arr: Uint8Array);
constructor(bytes: string | Uint8Array);
readBytes(length: number): Uint8Array;

@@ -10,0 +10,0 @@ readUInt32BE(): number;

@@ -22,5 +22,5 @@ "use strict";

class BytesReader {
constructor(arr) {
constructor(bytes) {
this.consumed = 0;
this.source = arr;
this.source = typeof bytes === 'string' ? (0, common_1.hexToBytes)(bytes) : bytes;
}

@@ -27,0 +27,0 @@ readBytes(length) {

@@ -37,7 +37,7 @@ "use strict";

case _1.ClarityWireType.address:
const sAddress = (0, wire_1.deserializeAddressBytes)(bytesReader);
const sAddress = (0, wire_1.deserializeAddress)(bytesReader);
return (0, _1.standardPrincipalCVFromAddress)(sAddress);
case _1.ClarityWireType.contract:
const cAddress = (0, wire_1.deserializeAddressBytes)(bytesReader);
const contractName = (0, wire_1.deserializeLPStringBytes)(bytesReader);
const cAddress = (0, wire_1.deserializeAddress)(bytesReader);
const contractName = (0, wire_1.deserializeLPString)(bytesReader);
return (0, _1.contractPrincipalCVFromAddress)(cAddress, contractName);

@@ -63,3 +63,3 @@ case _1.ClarityWireType.ok:

for (let i = 0; i < tupleLength; i++) {
const clarityName = (0, wire_1.deserializeLPStringBytes)(bytesReader).content;
const clarityName = (0, wire_1.deserializeLPString)(bytesReader).content;
if (clarityName === undefined) {

@@ -66,0 +66,0 @@ throw new errors_1.DeserializationError('"content" is undefined');

@@ -6,3 +6,3 @@ import { bytesToHex, concatArray, hexToBytes, intToBigInt, intToBytes, writeUInt16BE, } from '@stacks/common';

import { cloneDeep, leftPadHex, txidFromData } from './utils';
import { addressFromPublicKeys, createEmptyAddress, createLPList, deserializeLPListBytes, deserializeMessageSignatureBytes, serializeLPListBytes, serializeMessageSignatureBytes, StacksWireType, } from './wire';
import { addressFromPublicKeys, createEmptyAddress, createLPList, deserializeLPList, deserializeMessageSignature, serializeLPListBytes, serializeMessageSignatureBytes, StacksWireType, } from './wire';
export function emptyMessageSignature() {

@@ -107,3 +107,3 @@ return {

}
const signature = deserializeMessageSignatureBytes(bytesReader);
const signature = deserializeMessageSignature(bytesReader);
return {

@@ -122,3 +122,3 @@ hashMode,

const fee = BigInt('0x' + bytesToHex(bytesReader.readBytes(8)));
const fields = deserializeLPListBytes(bytesReader, StacksWireType.TransactionAuthField)
const fields = deserializeLPList(bytesReader, StacksWireType.TransactionAuthField)
.values;

@@ -125,0 +125,0 @@ let haveUncompressed = false;

@@ -7,3 +7,3 @@ export declare function isEnum<T extends string, TEnumValue extends number>(enumVariable: {

consumed: number;
constructor(arr: Uint8Array);
constructor(bytes: string | Uint8Array);
readBytes(length: number): Uint8Array;

@@ -10,0 +10,0 @@ readUInt32BE(): number;

@@ -1,2 +0,2 @@

import { bytesToHex, readUInt16BE, readUInt32BE, readUInt8 } from '@stacks/common';
import { bytesToHex, hexToBytes, readUInt16BE, readUInt32BE, readUInt8 } from '@stacks/common';
function createEnumChecker(enumVariable) {

@@ -18,5 +18,5 @@ const enumValues = Object.values(enumVariable).filter(v => typeof v === 'number');

export class BytesReader {
constructor(arr) {
constructor(bytes) {
this.consumed = 0;
this.source = arr;
this.source = typeof bytes === 'string' ? hexToBytes(bytes) : bytes;
}

@@ -23,0 +23,0 @@ readBytes(length) {

@@ -5,3 +5,3 @@ import { bytesToAscii, bytesToTwosBigInt, bytesToUtf8, hexToBytes } from '@stacks/common';

import { DeserializationError } from '../errors';
import { deserializeAddressBytes, deserializeLPStringBytes } from '../wire';
import { deserializeAddress, deserializeLPString } from '../wire';
export function deserializeCV(serializedClarityValue) {

@@ -35,7 +35,7 @@ let bytesReader;

case ClarityWireType.address:
const sAddress = deserializeAddressBytes(bytesReader);
const sAddress = deserializeAddress(bytesReader);
return standardPrincipalCVFromAddress(sAddress);
case ClarityWireType.contract:
const cAddress = deserializeAddressBytes(bytesReader);
const contractName = deserializeLPStringBytes(bytesReader);
const cAddress = deserializeAddress(bytesReader);
const contractName = deserializeLPString(bytesReader);
return contractPrincipalCVFromAddress(cAddress, contractName);

@@ -61,3 +61,3 @@ case ClarityWireType.ok:

for (let i = 0; i < tupleLength; i++) {
const clarityName = deserializeLPStringBytes(bytesReader).content;
const clarityName = deserializeLPString(bytesReader).content;
if (clarityName === undefined) {

@@ -64,0 +64,0 @@ throw new DeserializationError('"content" is undefined');

@@ -1,2 +0,2 @@

import { bytesToHex, concatArray, hexToBytes, intToBigInt, writeUInt32BE, } from '@stacks/common';
import { bytesToHex, concatArray, intToBigInt, isInstance, writeUInt32BE, } from '@stacks/common';
import { DEFAULT_CHAIN_ID, STACKS_MAINNET, STACKS_TESTNET, TransactionVersion, whenTransactionVersion, } from '@stacks/network';

@@ -10,3 +10,3 @@ import { serializePayloadBytes } from '.';

import { cloneDeep, txidFromData } from './utils';
import { StacksWireType, createLPList, createMessageSignature, createTransactionAuthField, deserializeLPListBytes, deserializePayloadBytes, serializeLPListBytes, } from './wire';
import { StacksWireType, createLPList, createMessageSignature, createTransactionAuthField, deserializeLPList, deserializePayload, serializeLPListBytes, } from './wire';
export class StacksTransaction {

@@ -139,17 +139,3 @@ constructor(version, auth, payload, postConditions, postConditionMode, anchorMode, chainId) {

export function deserializeTransaction(tx) {
let bytesReader;
if (typeof tx === 'string') {
if (tx.slice(0, 2).toLowerCase() === '0x') {
bytesReader = new BytesReader(hexToBytes(tx.slice(2)));
}
else {
bytesReader = new BytesReader(hexToBytes(tx));
}
}
else if (tx instanceof Uint8Array) {
bytesReader = new BytesReader(tx);
}
else {
bytesReader = tx;
}
const bytesReader = isInstance(tx, BytesReader) ? tx : new BytesReader(tx);
const version = bytesReader.readUInt8Enum(TransactionVersion, n => {

@@ -166,4 +152,4 @@ throw new Error(`Could not parse ${n} as TransactionVersion`);

});
const postConditions = deserializeLPListBytes(bytesReader, StacksWireType.PostCondition);
const payload = deserializePayloadBytes(bytesReader);
const postConditions = deserializeLPList(bytesReader, StacksWireType.PostCondition);
const payload = deserializePayload(bytesReader);
return new StacksTransaction(version, auth, payload, postConditions, postConditionMode, anchorMode, chainId);

@@ -170,0 +156,0 @@ }

import { BytesReader } from '../BytesReader';
import { AddressWire, AssetWire, LengthPrefixedList, LengthPrefixedStringWire, MemoStringWire, MessageSignatureWire, PayloadInput, PayloadWire, PostConditionPrincipalWire, PostConditionWire, PublicKeyWire, StacksWireType, TransactionAuthFieldWire } from './types';
import { AddressWire, AssetWire, LengthPrefixedList, LengthPrefixedStringWire, MemoStringWire, MessageSignatureWire, PayloadInput, PayloadWire, PostConditionPrincipalWire, PostConditionWire, PublicKeyWire, TransactionAuthFieldWire } from './types';
export declare function serializeAddress(address: AddressWire): string;
export declare function deserializeAddress(serialized: string): AddressWire;
export declare function serializePrincipal(principal: PostConditionPrincipalWire): string;
export declare function deserializePrincipal(serialized: string): PostConditionPrincipalWire;
export declare function serializeLPString(lps: LengthPrefixedStringWire): string;
export declare function deserializeLPString(serialized: string, prefixBytes?: number, maxLength?: number): LengthPrefixedStringWire;
export declare function serializeMemoString(memoString: MemoStringWire): string;
export declare function deserializeMemoString(serialized: string): MemoStringWire;
export declare function serializeAsset(info: AssetWire): string;
export declare function deserializeAsset(serialized: string): AssetWire;
export declare function serializeLPList(lpList: LengthPrefixedList): string;
export declare function deserializeLPList(serialized: string, type: StacksWireType, lengthPrefixBytes?: number): LengthPrefixedList;
export declare function serializePostCondition(postCondition: PostConditionWire): string;
export declare function deserializePostCondition(serialized: string): PostConditionWire;
export declare function serializePayload(payload: PayloadInput): string;
export declare function serializePayloadBytes(payload: PayloadInput): Uint8Array;
export declare function deserializePayload(serialized: string): PayloadWire;
export declare function deserializePayloadBytes(serialized: Uint8Array | BytesReader): PayloadWire;
export declare function deserializeMessageSignature(serialized: string): MessageSignatureWire;
export declare function deserializeMessageSignatureBytes(serialized: Uint8Array | BytesReader): MessageSignatureWire;
export declare function deserializeTransactionAuthField(serialized: string): TransactionAuthFieldWire;
export declare function deserializeTransactionAuthFieldBytes(serialized: Uint8Array | BytesReader): TransactionAuthFieldWire;
export declare function deserializePayload(serialized: string | Uint8Array | BytesReader): PayloadWire;
export declare function deserializeMessageSignature(serialized: string | Uint8Array | BytesReader): MessageSignatureWire;
export declare function deserializeTransactionAuthField(serialized: string | Uint8Array | BytesReader): TransactionAuthFieldWire;
export declare function serializeMessageSignature(messageSignature: MessageSignatureWire): string;

@@ -31,3 +21,2 @@ export declare function serializeMessageSignatureBytes(messageSignature: MessageSignatureWire): Uint8Array;

export declare function serializePublicKeyBytes(key: PublicKeyWire): Uint8Array;
export declare function deserializePublicKey(serialized: string): PublicKeyWire;
export declare function deserializePublicKeyBytes(serialized: Uint8Array | BytesReader): PublicKeyWire;
export declare function deserializePublicKey(serialized: string | Uint8Array | BytesReader): PublicKeyWire;

@@ -39,20 +39,20 @@ import { bytesToHex, bytesToUtf8, concatArray, hexToBytes, hexToInt, intToBigInt, intToBytes, intToHex, isInstance, utf8ToBytes, writeUInt32BE, writeUInt8, } from '@stacks/common';

}
export function deserializeStacksWireBytes(bytesReader, type, listType) {
export function deserializeStacksWire(bytesReader, type, listType) {
switch (type) {
case StacksWireType.Address:
return deserializeAddressBytes(bytesReader);
return deserializeAddress(bytesReader);
case StacksWireType.Principal:
return deserializePrincipalBytes(bytesReader);
return deserializePrincipal(bytesReader);
case StacksWireType.LengthPrefixedString:
return deserializeLPStringBytes(bytesReader);
return deserializeLPString(bytesReader);
case StacksWireType.MemoString:
return deserializeMemoStringBytes(bytesReader);
return deserializeMemoString(bytesReader);
case StacksWireType.Asset:
return deserializeAssetBytes(bytesReader);
return deserializeAsset(bytesReader);
case StacksWireType.PostCondition:
return deserializePostConditionBytes(bytesReader);
return deserializePostCondition(bytesReader);
case StacksWireType.PublicKey:
return deserializePublicKeyBytes(bytesReader);
return deserializePublicKey(bytesReader);
case StacksWireType.Payload:
return deserializePayloadBytes(bytesReader);
return deserializePayload(bytesReader);
case StacksWireType.LengthPrefixedList:

@@ -62,5 +62,5 @@ if (!listType) {

}
return deserializeLPListBytes(bytesReader, listType);
return deserializeLPList(bytesReader, listType);
case StacksWireType.MessageSignature:
return deserializeMessageSignatureBytes(bytesReader);
return deserializeMessageSignature(bytesReader);
default:

@@ -80,5 +80,2 @@ throw new Error('Could not recognize StacksWireType');

export function deserializeAddress(serialized) {
return deserializeAddressBytes(hexToBytes(serialized));
}
export function deserializeAddressBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -107,5 +104,2 @@ ? serialized

export function deserializePrincipal(serialized) {
return deserializePrincipalBytes(hexToBytes(serialized));
}
export function deserializePrincipalBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -120,7 +114,7 @@ ? serialized

}
const address = deserializeAddressBytes(bytesReader);
const address = deserializeAddress(bytesReader);
if (prefix === PostConditionPrincipalId.Standard) {
return { type: StacksWireType.Principal, prefix, address };
}
const contractName = deserializeLPStringBytes(bytesReader);
const contractName = deserializeLPString(bytesReader);
return {

@@ -145,5 +139,2 @@ type: StacksWireType.Principal,

export function deserializeLPString(serialized, prefixBytes, maxLength) {
return deserializeLPStringBytes(hexToBytes(serialized), prefixBytes, maxLength);
}
export function deserializeLPStringBytes(serialized, prefixBytes, maxLength) {
prefixBytes = prefixBytes ? prefixBytes : 1;

@@ -168,5 +159,2 @@ const bytesReader = isInstance(serialized, BytesReader)

export function deserializeMemoString(serialized) {
return deserializeMemoStringBytes(hexToBytes(serialized));
}
export function deserializeMemoStringBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -190,5 +178,2 @@ ? serialized

export function deserializeAsset(serialized) {
return deserializeAssetBytes(hexToBytes(serialized));
}
export function deserializeAssetBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -199,5 +184,5 @@ ? serialized

type: StacksWireType.Asset,
address: deserializeAddressBytes(bytesReader),
contractName: deserializeLPStringBytes(bytesReader),
assetName: deserializeLPStringBytes(bytesReader),
address: deserializeAddress(bytesReader),
contractName: deserializeLPString(bytesReader),
assetName: deserializeLPString(bytesReader),
};

@@ -218,5 +203,2 @@ }

export function deserializeLPList(serialized, type, lengthPrefixBytes) {
return deserializeLPListBytes(hexToBytes(serialized), type, lengthPrefixBytes);
}
export function deserializeLPListBytes(serialized, type, lengthPrefixBytes) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -230,21 +212,21 @@ ? serialized

case StacksWireType.Address:
l.push(deserializeAddressBytes(bytesReader));
l.push(deserializeAddress(bytesReader));
break;
case StacksWireType.LengthPrefixedString:
l.push(deserializeLPStringBytes(bytesReader));
l.push(deserializeLPString(bytesReader));
break;
case StacksWireType.MemoString:
l.push(deserializeMemoStringBytes(bytesReader));
l.push(deserializeMemoString(bytesReader));
break;
case StacksWireType.Asset:
l.push(deserializeAssetBytes(bytesReader));
l.push(deserializeAsset(bytesReader));
break;
case StacksWireType.PostCondition:
l.push(deserializePostConditionBytes(bytesReader));
l.push(deserializePostCondition(bytesReader));
break;
case StacksWireType.PublicKey:
l.push(deserializePublicKeyBytes(bytesReader));
l.push(deserializePublicKey(bytesReader));
break;
case StacksWireType.TransactionAuthField:
l.push(deserializeTransactionAuthFieldBytes(bytesReader));
l.push(deserializeTransactionAuthField(bytesReader));
break;

@@ -279,5 +261,2 @@ }

export function deserializePostCondition(serialized) {
return deserializePostConditionBytes(hexToBytes(serialized));
}
export function deserializePostConditionBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -289,3 +268,3 @@ ? serialized

});
const principal = deserializePrincipalBytes(bytesReader);
const principal = deserializePrincipal(bytesReader);
let conditionCode;

@@ -308,3 +287,3 @@ let asset;

case PostConditionType.Fungible:
asset = deserializeAssetBytes(bytesReader);
asset = deserializeAsset(bytesReader);
conditionCode = bytesReader.readUInt8Enum(FungibleConditionCode, n => {

@@ -323,3 +302,3 @@ throw new DeserializationError(`Could not read ${n} as FungibleConditionCode`);

case PostConditionType.NonFungible:
asset = deserializeAssetBytes(bytesReader);
asset = deserializeAsset(bytesReader);
const assetName = deserializeCV(bytesReader);

@@ -334,3 +313,3 @@ conditionCode = bytesReader.readUInt8Enum(NonFungibleConditionCode, n => {

conditionCode,
asset: asset,
asset,
assetName,

@@ -399,5 +378,2 @@ };

export function deserializePayload(serialized) {
return deserializePayloadBytes(hexToBytes(serialized));
}
export function deserializePayloadBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -413,8 +389,8 @@ ? serialized

const amount = intToBigInt(bytesReader.readBytes(8));
const memo = deserializeMemoStringBytes(bytesReader);
const memo = deserializeMemoString(bytesReader);
return createTokenTransferPayload(recipient, amount, memo);
case PayloadType.ContractCall:
const contractAddress = deserializeAddressBytes(bytesReader);
const contractCallName = deserializeLPStringBytes(bytesReader);
const functionName = deserializeLPStringBytes(bytesReader);
const contractAddress = deserializeAddress(bytesReader);
const contractCallName = deserializeLPString(bytesReader);
const functionName = deserializeLPString(bytesReader);
const functionArgs = [];

@@ -428,4 +404,4 @@ const numberOfArgs = bytesReader.readUInt32BE();

case PayloadType.SmartContract:
const smartContractName = deserializeLPStringBytes(bytesReader);
const codeBody = deserializeLPStringBytes(bytesReader, 4, 100000);
const smartContractName = deserializeLPString(bytesReader);
const codeBody = deserializeLPString(bytesReader, 4, 100000);
return createSmartContractPayload(smartContractName, codeBody);

@@ -436,4 +412,4 @@ case PayloadType.VersionedSmartContract: {

});
const smartContractName = deserializeLPStringBytes(bytesReader);
const codeBody = deserializeLPStringBytes(bytesReader, 4, 100000);
const smartContractName = deserializeLPString(bytesReader);
const codeBody = deserializeLPString(bytesReader, 4, 100000);
return createSmartContractPayload(smartContractName, codeBody, clarityVersion);

@@ -472,5 +448,2 @@ }

export function deserializeMessageSignature(serialized) {
return deserializeMessageSignatureBytes(hexToBytes(serialized));
}
export function deserializeMessageSignatureBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -482,5 +455,2 @@ ? serialized

export function deserializeTransactionAuthField(serialized) {
return deserializeTransactionAuthFieldBytes(hexToBytes(serialized));
}
export function deserializeTransactionAuthFieldBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -494,9 +464,9 @@ ? serialized

case AuthFieldType.PublicKeyCompressed:
return createTransactionAuthField(PubKeyEncoding.Compressed, deserializePublicKeyBytes(bytesReader));
return createTransactionAuthField(PubKeyEncoding.Compressed, deserializePublicKey(bytesReader));
case AuthFieldType.PublicKeyUncompressed:
return createTransactionAuthField(PubKeyEncoding.Uncompressed, createStacksPublicKey(uncompressPublicKey(deserializePublicKeyBytes(bytesReader).data)));
return createTransactionAuthField(PubKeyEncoding.Uncompressed, createStacksPublicKey(uncompressPublicKey(deserializePublicKey(bytesReader).data)));
case AuthFieldType.SignatureCompressed:
return createTransactionAuthField(PubKeyEncoding.Compressed, deserializeMessageSignatureBytes(bytesReader));
return createTransactionAuthField(PubKeyEncoding.Compressed, deserializeMessageSignature(bytesReader));
case AuthFieldType.SignatureUncompressed:
return createTransactionAuthField(PubKeyEncoding.Uncompressed, deserializeMessageSignatureBytes(bytesReader));
return createTransactionAuthField(PubKeyEncoding.Uncompressed, deserializeMessageSignature(bytesReader));
default:

@@ -540,5 +510,2 @@ throw new Error(`Unknown auth field type: ${JSON.stringify(authFieldType)}`);

export function deserializePublicKey(serialized) {
return deserializePublicKeyBytes(hexToBytes(serialized));
}
export function deserializePublicKeyBytes(serialized) {
const bytesReader = isInstance(serialized, BytesReader)

@@ -545,0 +512,0 @@ ? serialized

@@ -142,17 +142,3 @@ "use strict";

function deserializeTransaction(tx) {
let bytesReader;
if (typeof tx === 'string') {
if (tx.slice(0, 2).toLowerCase() === '0x') {
bytesReader = new BytesReader_1.BytesReader((0, common_1.hexToBytes)(tx.slice(2)));
}
else {
bytesReader = new BytesReader_1.BytesReader((0, common_1.hexToBytes)(tx));
}
}
else if (tx instanceof Uint8Array) {
bytesReader = new BytesReader_1.BytesReader(tx);
}
else {
bytesReader = tx;
}
const bytesReader = (0, common_1.isInstance)(tx, BytesReader_1.BytesReader) ? tx : new BytesReader_1.BytesReader(tx);
const version = bytesReader.readUInt8Enum(network_1.TransactionVersion, n => {

@@ -169,4 +155,4 @@ throw new Error(`Could not parse ${n} as TransactionVersion`);

});
const postConditions = (0, wire_1.deserializeLPListBytes)(bytesReader, wire_1.StacksWireType.PostCondition);
const payload = (0, wire_1.deserializePayloadBytes)(bytesReader);
const postConditions = (0, wire_1.deserializeLPList)(bytesReader, wire_1.StacksWireType.PostCondition);
const payload = (0, wire_1.deserializePayload)(bytesReader);
return new StacksTransaction(version, auth, payload, postConditions, postConditionMode, anchorMode, chainId);

@@ -173,0 +159,0 @@ }

import { BytesReader } from '../BytesReader';
import { AddressWire, AssetWire, LengthPrefixedList, LengthPrefixedStringWire, MemoStringWire, MessageSignatureWire, PayloadInput, PayloadWire, PostConditionPrincipalWire, PostConditionWire, PublicKeyWire, StacksWireType, TransactionAuthFieldWire } from './types';
import { AddressWire, AssetWire, LengthPrefixedList, LengthPrefixedStringWire, MemoStringWire, MessageSignatureWire, PayloadInput, PayloadWire, PostConditionPrincipalWire, PostConditionWire, PublicKeyWire, TransactionAuthFieldWire } from './types';
export declare function serializeAddress(address: AddressWire): string;
export declare function deserializeAddress(serialized: string): AddressWire;
export declare function serializePrincipal(principal: PostConditionPrincipalWire): string;
export declare function deserializePrincipal(serialized: string): PostConditionPrincipalWire;
export declare function serializeLPString(lps: LengthPrefixedStringWire): string;
export declare function deserializeLPString(serialized: string, prefixBytes?: number, maxLength?: number): LengthPrefixedStringWire;
export declare function serializeMemoString(memoString: MemoStringWire): string;
export declare function deserializeMemoString(serialized: string): MemoStringWire;
export declare function serializeAsset(info: AssetWire): string;
export declare function deserializeAsset(serialized: string): AssetWire;
export declare function serializeLPList(lpList: LengthPrefixedList): string;
export declare function deserializeLPList(serialized: string, type: StacksWireType, lengthPrefixBytes?: number): LengthPrefixedList;
export declare function serializePostCondition(postCondition: PostConditionWire): string;
export declare function deserializePostCondition(serialized: string): PostConditionWire;
export declare function serializePayload(payload: PayloadInput): string;
export declare function serializePayloadBytes(payload: PayloadInput): Uint8Array;
export declare function deserializePayload(serialized: string): PayloadWire;
export declare function deserializePayloadBytes(serialized: Uint8Array | BytesReader): PayloadWire;
export declare function deserializeMessageSignature(serialized: string): MessageSignatureWire;
export declare function deserializeMessageSignatureBytes(serialized: Uint8Array | BytesReader): MessageSignatureWire;
export declare function deserializeTransactionAuthField(serialized: string): TransactionAuthFieldWire;
export declare function deserializeTransactionAuthFieldBytes(serialized: Uint8Array | BytesReader): TransactionAuthFieldWire;
export declare function deserializePayload(serialized: string | Uint8Array | BytesReader): PayloadWire;
export declare function deserializeMessageSignature(serialized: string | Uint8Array | BytesReader): MessageSignatureWire;
export declare function deserializeTransactionAuthField(serialized: string | Uint8Array | BytesReader): TransactionAuthFieldWire;
export declare function serializeMessageSignature(messageSignature: MessageSignatureWire): string;

@@ -31,3 +21,2 @@ export declare function serializeMessageSignatureBytes(messageSignature: MessageSignatureWire): Uint8Array;

export declare function serializePublicKeyBytes(key: PublicKeyWire): Uint8Array;
export declare function deserializePublicKey(serialized: string): PublicKeyWire;
export declare function deserializePublicKeyBytes(serialized: Uint8Array | BytesReader): PublicKeyWire;
export declare function deserializePublicKey(serialized: string | Uint8Array | BytesReader): PublicKeyWire;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializePublicKeyBytes = exports.deserializePublicKey = exports.serializePublicKeyBytes = exports.serializePublicKey = exports.serializeTransactionAuthFieldBytes = exports.serializeTransactionAuthField = exports.serializeMessageSignatureBytes = exports.serializeMessageSignature = exports.deserializeTransactionAuthFieldBytes = exports.deserializeTransactionAuthField = exports.deserializeMessageSignatureBytes = exports.deserializeMessageSignature = exports.deserializePayloadBytes = exports.deserializePayload = exports.serializePayloadBytes = exports.serializePayload = exports.deserializePostConditionBytes = exports.deserializePostCondition = exports.serializePostConditionBytes = exports.serializePostCondition = exports.deserializeLPListBytes = exports.deserializeLPList = exports.serializeLPListBytes = exports.serializeLPList = exports.deserializeAssetBytes = exports.deserializeAsset = exports.serializeAssetBytes = exports.serializeAsset = exports.deserializeMemoStringBytes = exports.deserializeMemoString = exports.serializeMemoStringBytes = exports.serializeMemoString = exports.deserializeLPStringBytes = exports.deserializeLPString = exports.serializeLPStringBytes = exports.serializeLPString = exports.deserializePrincipalBytes = exports.deserializePrincipal = exports.serializePrincipalBytes = exports.serializePrincipal = exports.deserializeAddressBytes = exports.deserializeAddress = exports.serializeAddressBytes = exports.serializeAddress = exports.deserializeStacksWireBytes = exports.serializeStacksWireBytes = exports.serializeStacksWire = void 0;
exports.deserializePublicKey = exports.serializePublicKeyBytes = exports.serializePublicKey = exports.serializeTransactionAuthFieldBytes = exports.serializeTransactionAuthField = exports.serializeMessageSignatureBytes = exports.serializeMessageSignature = exports.deserializeTransactionAuthField = exports.deserializeMessageSignature = exports.deserializePayload = exports.serializePayloadBytes = exports.serializePayload = exports.deserializePostCondition = exports.serializePostConditionBytes = exports.serializePostCondition = exports.deserializeLPList = exports.serializeLPListBytes = exports.serializeLPList = exports.deserializeAsset = exports.serializeAssetBytes = exports.serializeAsset = exports.deserializeMemoString = exports.serializeMemoStringBytes = exports.serializeMemoString = exports.deserializeLPString = exports.serializeLPStringBytes = exports.serializeLPString = exports.deserializePrincipal = exports.serializePrincipalBytes = exports.serializePrincipal = exports.deserializeAddress = exports.serializeAddressBytes = exports.serializeAddress = exports.deserializeStacksWire = exports.serializeStacksWireBytes = exports.serializeStacksWire = void 0;
const common_1 = require("@stacks/common");

@@ -44,20 +44,20 @@ const BytesReader_1 = require("../BytesReader");

exports.serializeStacksWireBytes = serializeStacksWireBytes;
function deserializeStacksWireBytes(bytesReader, type, listType) {
function deserializeStacksWire(bytesReader, type, listType) {
switch (type) {
case types_1.StacksWireType.Address:
return deserializeAddressBytes(bytesReader);
return deserializeAddress(bytesReader);
case types_1.StacksWireType.Principal:
return deserializePrincipalBytes(bytesReader);
return deserializePrincipal(bytesReader);
case types_1.StacksWireType.LengthPrefixedString:
return deserializeLPStringBytes(bytesReader);
return deserializeLPString(bytesReader);
case types_1.StacksWireType.MemoString:
return deserializeMemoStringBytes(bytesReader);
return deserializeMemoString(bytesReader);
case types_1.StacksWireType.Asset:
return deserializeAssetBytes(bytesReader);
return deserializeAsset(bytesReader);
case types_1.StacksWireType.PostCondition:
return deserializePostConditionBytes(bytesReader);
return deserializePostCondition(bytesReader);
case types_1.StacksWireType.PublicKey:
return deserializePublicKeyBytes(bytesReader);
return deserializePublicKey(bytesReader);
case types_1.StacksWireType.Payload:
return deserializePayloadBytes(bytesReader);
return deserializePayload(bytesReader);
case types_1.StacksWireType.LengthPrefixedList:

@@ -67,5 +67,5 @@ if (!listType) {

}
return deserializeLPListBytes(bytesReader, listType);
return deserializeLPList(bytesReader, listType);
case types_1.StacksWireType.MessageSignature:
return deserializeMessageSignatureBytes(bytesReader);
return deserializeMessageSignature(bytesReader);
default:

@@ -75,3 +75,3 @@ throw new Error('Could not recognize StacksWireType');

}
exports.deserializeStacksWireBytes = deserializeStacksWireBytes;
exports.deserializeStacksWire = deserializeStacksWire;
function serializeAddress(address) {

@@ -89,6 +89,2 @@ return (0, common_1.bytesToHex)(serializeAddressBytes(address));

function deserializeAddress(serialized) {
return deserializeAddressBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializeAddress = deserializeAddress;
function deserializeAddressBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -101,3 +97,3 @@ ? serialized

}
exports.deserializeAddressBytes = deserializeAddressBytes;
exports.deserializeAddress = deserializeAddress;
function serializePrincipal(principal) {

@@ -121,6 +117,2 @@ return (0, common_1.bytesToHex)(serializePrincipalBytes(principal));

function deserializePrincipal(serialized) {
return deserializePrincipalBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializePrincipal = deserializePrincipal;
function deserializePrincipalBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -135,7 +127,7 @@ ? serialized

}
const address = deserializeAddressBytes(bytesReader);
const address = deserializeAddress(bytesReader);
if (prefix === constants_1.PostConditionPrincipalId.Standard) {
return { type: types_1.StacksWireType.Principal, prefix, address };
}
const contractName = deserializeLPStringBytes(bytesReader);
const contractName = deserializeLPString(bytesReader);
return {

@@ -148,3 +140,3 @@ type: types_1.StacksWireType.Principal,

}
exports.deserializePrincipalBytes = deserializePrincipalBytes;
exports.deserializePrincipal = deserializePrincipal;
function serializeLPString(lps) {

@@ -164,6 +156,2 @@ return (0, common_1.bytesToHex)(serializeLPStringBytes(lps));

function deserializeLPString(serialized, prefixBytes, maxLength) {
return deserializeLPStringBytes((0, common_1.hexToBytes)(serialized), prefixBytes, maxLength);
}
exports.deserializeLPString = deserializeLPString;
function deserializeLPStringBytes(serialized, prefixBytes, maxLength) {
prefixBytes = prefixBytes ? prefixBytes : 1;

@@ -177,3 +165,3 @@ const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

}
exports.deserializeLPStringBytes = deserializeLPStringBytes;
exports.deserializeLPString = deserializeLPString;
function serializeMemoString(memoString) {

@@ -192,6 +180,2 @@ return (0, common_1.bytesToHex)(serializeMemoStringBytes(memoString));

function deserializeMemoString(serialized) {
return deserializeMemoStringBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializeMemoString = deserializeMemoString;
function deserializeMemoStringBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -204,3 +188,3 @@ ? serialized

}
exports.deserializeMemoStringBytes = deserializeMemoStringBytes;
exports.deserializeMemoString = deserializeMemoString;
function serializeAsset(info) {

@@ -219,6 +203,2 @@ return (0, common_1.bytesToHex)(serializeAssetBytes(info));

function deserializeAsset(serialized) {
return deserializeAssetBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializeAsset = deserializeAsset;
function deserializeAssetBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -229,8 +209,8 @@ ? serialized

type: types_1.StacksWireType.Asset,
address: deserializeAddressBytes(bytesReader),
contractName: deserializeLPStringBytes(bytesReader),
assetName: deserializeLPStringBytes(bytesReader),
address: deserializeAddress(bytesReader),
contractName: deserializeLPString(bytesReader),
assetName: deserializeLPString(bytesReader),
};
}
exports.deserializeAssetBytes = deserializeAssetBytes;
exports.deserializeAsset = deserializeAsset;
function serializeLPList(lpList) {

@@ -251,6 +231,2 @@ return (0, common_1.bytesToHex)(serializeLPListBytes(lpList));

function deserializeLPList(serialized, type, lengthPrefixBytes) {
return deserializeLPListBytes((0, common_1.hexToBytes)(serialized), type, lengthPrefixBytes);
}
exports.deserializeLPList = deserializeLPList;
function deserializeLPListBytes(serialized, type, lengthPrefixBytes) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -264,21 +240,21 @@ ? serialized

case types_1.StacksWireType.Address:
l.push(deserializeAddressBytes(bytesReader));
l.push(deserializeAddress(bytesReader));
break;
case types_1.StacksWireType.LengthPrefixedString:
l.push(deserializeLPStringBytes(bytesReader));
l.push(deserializeLPString(bytesReader));
break;
case types_1.StacksWireType.MemoString:
l.push(deserializeMemoStringBytes(bytesReader));
l.push(deserializeMemoString(bytesReader));
break;
case types_1.StacksWireType.Asset:
l.push(deserializeAssetBytes(bytesReader));
l.push(deserializeAsset(bytesReader));
break;
case types_1.StacksWireType.PostCondition:
l.push(deserializePostConditionBytes(bytesReader));
l.push(deserializePostCondition(bytesReader));
break;
case types_1.StacksWireType.PublicKey:
l.push(deserializePublicKeyBytes(bytesReader));
l.push(deserializePublicKey(bytesReader));
break;
case types_1.StacksWireType.TransactionAuthField:
l.push(deserializeTransactionAuthFieldBytes(bytesReader));
l.push(deserializeTransactionAuthField(bytesReader));
break;

@@ -289,3 +265,3 @@ }

}
exports.deserializeLPListBytes = deserializeLPListBytes;
exports.deserializeLPList = deserializeLPList;
function serializePostCondition(postCondition) {

@@ -317,6 +293,2 @@ return (0, common_1.bytesToHex)(serializePostConditionBytes(postCondition));

function deserializePostCondition(serialized) {
return deserializePostConditionBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializePostCondition = deserializePostCondition;
function deserializePostConditionBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -328,3 +300,3 @@ ? serialized

});
const principal = deserializePrincipalBytes(bytesReader);
const principal = deserializePrincipal(bytesReader);
let conditionCode;

@@ -347,3 +319,3 @@ let asset;

case constants_1.PostConditionType.Fungible:
asset = deserializeAssetBytes(bytesReader);
asset = deserializeAsset(bytesReader);
conditionCode = bytesReader.readUInt8Enum(constants_1.FungibleConditionCode, n => {

@@ -362,3 +334,3 @@ throw new errors_1.DeserializationError(`Could not read ${n} as FungibleConditionCode`);

case constants_1.PostConditionType.NonFungible:
asset = deserializeAssetBytes(bytesReader);
asset = deserializeAsset(bytesReader);
const assetName = (0, clarity_1.deserializeCV)(bytesReader);

@@ -373,3 +345,3 @@ conditionCode = bytesReader.readUInt8Enum(constants_1.NonFungibleConditionCode, n => {

conditionCode,
asset: asset,
asset,
assetName,

@@ -379,3 +351,3 @@ };

}
exports.deserializePostConditionBytes = deserializePostConditionBytes;
exports.deserializePostCondition = deserializePostCondition;
function serializePayload(payload) {

@@ -442,6 +414,2 @@ return (0, common_1.bytesToHex)(serializePayloadBytes(payload));

function deserializePayload(serialized) {
return deserializePayloadBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializePayload = deserializePayload;
function deserializePayloadBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -457,8 +425,8 @@ ? serialized

const amount = (0, common_1.intToBigInt)(bytesReader.readBytes(8));
const memo = deserializeMemoStringBytes(bytesReader);
const memo = deserializeMemoString(bytesReader);
return (0, create_1.createTokenTransferPayload)(recipient, amount, memo);
case constants_1.PayloadType.ContractCall:
const contractAddress = deserializeAddressBytes(bytesReader);
const contractCallName = deserializeLPStringBytes(bytesReader);
const functionName = deserializeLPStringBytes(bytesReader);
const contractAddress = deserializeAddress(bytesReader);
const contractCallName = deserializeLPString(bytesReader);
const functionName = deserializeLPString(bytesReader);
const functionArgs = [];

@@ -472,4 +440,4 @@ const numberOfArgs = bytesReader.readUInt32BE();

case constants_1.PayloadType.SmartContract:
const smartContractName = deserializeLPStringBytes(bytesReader);
const codeBody = deserializeLPStringBytes(bytesReader, 4, 100000);
const smartContractName = deserializeLPString(bytesReader);
const codeBody = deserializeLPString(bytesReader, 4, 100000);
return (0, create_1.createSmartContractPayload)(smartContractName, codeBody);

@@ -480,4 +448,4 @@ case constants_1.PayloadType.VersionedSmartContract: {

});
const smartContractName = deserializeLPStringBytes(bytesReader);
const codeBody = deserializeLPStringBytes(bytesReader, 4, 100000);
const smartContractName = deserializeLPString(bytesReader);
const codeBody = deserializeLPString(bytesReader, 4, 100000);
return (0, create_1.createSmartContractPayload)(smartContractName, codeBody, clarityVersion);

@@ -515,8 +483,4 @@ }

}
exports.deserializePayloadBytes = deserializePayloadBytes;
exports.deserializePayload = deserializePayload;
function deserializeMessageSignature(serialized) {
return deserializeMessageSignatureBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializeMessageSignature = deserializeMessageSignature;
function deserializeMessageSignatureBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -527,8 +491,4 @@ ? serialized

}
exports.deserializeMessageSignatureBytes = deserializeMessageSignatureBytes;
exports.deserializeMessageSignature = deserializeMessageSignature;
function deserializeTransactionAuthField(serialized) {
return deserializeTransactionAuthFieldBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializeTransactionAuthField = deserializeTransactionAuthField;
function deserializeTransactionAuthFieldBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -542,9 +502,9 @@ ? serialized

case constants_1.AuthFieldType.PublicKeyCompressed:
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Compressed, deserializePublicKeyBytes(bytesReader));
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Compressed, deserializePublicKey(bytesReader));
case constants_1.AuthFieldType.PublicKeyUncompressed:
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Uncompressed, (0, keys_1.createStacksPublicKey)((0, keys_1.uncompressPublicKey)(deserializePublicKeyBytes(bytesReader).data)));
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Uncompressed, (0, keys_1.createStacksPublicKey)((0, keys_1.uncompressPublicKey)(deserializePublicKey(bytesReader).data)));
case constants_1.AuthFieldType.SignatureCompressed:
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Compressed, deserializeMessageSignatureBytes(bytesReader));
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Compressed, deserializeMessageSignature(bytesReader));
case constants_1.AuthFieldType.SignatureUncompressed:
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Uncompressed, deserializeMessageSignatureBytes(bytesReader));
return (0, create_1.createTransactionAuthField)(constants_1.PubKeyEncoding.Uncompressed, deserializeMessageSignature(bytesReader));
default:

@@ -554,3 +514,3 @@ throw new Error(`Unknown auth field type: ${JSON.stringify(authFieldType)}`);

}
exports.deserializeTransactionAuthFieldBytes = deserializeTransactionAuthFieldBytes;
exports.deserializeTransactionAuthField = deserializeTransactionAuthField;
function serializeMessageSignature(messageSignature) {

@@ -596,6 +556,2 @@ return (0, common_1.bytesToHex)(serializeMessageSignatureBytes(messageSignature));

function deserializePublicKey(serialized) {
return deserializePublicKeyBytes((0, common_1.hexToBytes)(serialized));
}
exports.deserializePublicKey = deserializePublicKey;
function deserializePublicKeyBytes(serialized) {
const bytesReader = (0, common_1.isInstance)(serialized, BytesReader_1.BytesReader)

@@ -608,3 +564,3 @@ ? serialized

}
exports.deserializePublicKeyBytes = deserializePublicKeyBytes;
exports.deserializePublicKey = deserializePublicKey;
//# sourceMappingURL=serialization.js.map
{
"name": "@stacks/transactions",
"version": "6.14.1-pr.81+991a12b8",
"version": "6.14.1-pr.82+c0ef9c25",
"description": "Javascript library for constructing transactions on the Stacks blockchain.",

@@ -30,4 +30,4 @@ "license": "MIT",

"@noble/secp256k1": "1.7.1",
"@stacks/common": "^6.14.1-pr.81+991a12b8",
"@stacks/network": "^6.14.1-pr.81+991a12b8",
"@stacks/common": "^6.14.1-pr.82+c0ef9c25",
"@stacks/network": "^6.14.1-pr.82+c0ef9c25",
"c32check": "^2.0.0",

@@ -37,3 +37,3 @@ "lodash.clonedeep": "^4.5.0"

"devDependencies": {
"@stacks/encryption": "^6.14.1-pr.81+991a12b8",
"@stacks/encryption": "^6.14.1-pr.82+c0ef9c25",
"@types/common-tags": "^1.8.0",

@@ -67,3 +67,3 @@ "@types/elliptic": "^6.4.12",

},
"gitHead": "991a12b82dd40702205904ef4ad7a5efff09f359"
"gitHead": "c0ef9c2543527148c703c17a8e90d905f8f86ea7"
}

@@ -34,4 +34,4 @@ import {

createLPList,
deserializeLPListBytes,
deserializeMessageSignatureBytes,
deserializeLPList,
deserializeMessageSignature,
MessageSignatureWire,

@@ -262,3 +262,3 @@ PublicKeyWire,

}
const signature = deserializeMessageSignatureBytes(bytesReader);
const signature = deserializeMessageSignature(bytesReader);
return {

@@ -282,3 +282,3 @@ hashMode,

const fields = deserializeLPListBytes(bytesReader, StacksWireType.TransactionAuthField)
const fields = deserializeLPList(bytesReader, StacksWireType.TransactionAuthField)
.values as TransactionAuthFieldWire[];

@@ -285,0 +285,0 @@

@@ -1,2 +0,2 @@

import { bytesToHex, readUInt16BE, readUInt32BE, readUInt8 } from '@stacks/common';
import { bytesToHex, hexToBytes, readUInt16BE, readUInt32BE, readUInt8 } from '@stacks/common';

@@ -50,4 +50,4 @@ function createEnumChecker<T extends string, TEnumValue extends number>(enumVariable: {

constructor(arr: Uint8Array) {
this.source = arr;
constructor(bytes: string | Uint8Array) {
this.source = typeof bytes === 'string' ? hexToBytes(bytes) : bytes;
}

@@ -54,0 +54,0 @@

@@ -23,3 +23,3 @@ import { bytesToAscii, bytesToTwosBigInt, bytesToUtf8, hexToBytes } from '@stacks/common';

import { DeserializationError } from '../errors';
import { deserializeAddressBytes, deserializeLPStringBytes } from '../wire';
import { deserializeAddress, deserializeLPString } from '../wire';

@@ -79,8 +79,8 @@ /**

case ClarityWireType.address:
const sAddress = deserializeAddressBytes(bytesReader);
const sAddress = deserializeAddress(bytesReader);
return standardPrincipalCVFromAddress(sAddress) as T;
case ClarityWireType.contract:
const cAddress = deserializeAddressBytes(bytesReader);
const contractName = deserializeLPStringBytes(bytesReader);
const cAddress = deserializeAddress(bytesReader);
const contractName = deserializeLPString(bytesReader);
return contractPrincipalCVFromAddress(cAddress, contractName) as T;

@@ -112,3 +112,3 @@

for (let i = 0; i < tupleLength; i++) {
const clarityName = deserializeLPStringBytes(bytesReader).content;
const clarityName = deserializeLPString(bytesReader).content;
if (clarityName === undefined) {

@@ -115,0 +115,0 @@ throw new DeserializationError('"content" is undefined');

@@ -8,4 +8,4 @@ import {

concatArray,
hexToBytes,
intToBigInt,
isInstance,
writeUInt32BE,

@@ -60,4 +60,4 @@ } from '@stacks/common';

createTransactionAuthField,
deserializeLPListBytes,
deserializePayloadBytes,
deserializeLPList,
deserializePayload,
serializeLPListBytes,

@@ -317,14 +317,3 @@ } from './wire';

export function deserializeTransaction(tx: string | Uint8Array | BytesReader) {
let bytesReader: BytesReader; // todo: add readerFrom method
if (typeof tx === 'string') {
if (tx.slice(0, 2).toLowerCase() === '0x') {
bytesReader = new BytesReader(hexToBytes(tx.slice(2)));
} else {
bytesReader = new BytesReader(hexToBytes(tx));
}
} else if (tx instanceof Uint8Array) {
bytesReader = new BytesReader(tx);
} else {
bytesReader = tx;
}
const bytesReader = isInstance(tx, BytesReader) ? tx : new BytesReader(tx);
const version = bytesReader.readUInt8Enum(TransactionVersion, n => {

@@ -341,4 +330,4 @@ throw new Error(`Could not parse ${n} as TransactionVersion`);

});
const postConditions = deserializeLPListBytes(bytesReader, StacksWireType.PostCondition);
const payload = deserializePayloadBytes(bytesReader);
const postConditions = deserializeLPList(bytesReader, StacksWireType.PostCondition);
const payload = deserializePayload(bytesReader);

@@ -345,0 +334,0 @@ return new StacksTransaction(

@@ -111,4 +111,4 @@ import {

/** @internal */
export function deserializeStacksWireBytes(
bytesReader: BytesReader,
export function deserializeStacksWire(
bytesReader: string | Uint8Array | BytesReader,
type: StacksWireType,

@@ -119,17 +119,17 @@ listType?: StacksWireType

case StacksWireType.Address:
return deserializeAddressBytes(bytesReader);
return deserializeAddress(bytesReader);
case StacksWireType.Principal:
return deserializePrincipalBytes(bytesReader);
return deserializePrincipal(bytesReader);
case StacksWireType.LengthPrefixedString:
return deserializeLPStringBytes(bytesReader);
return deserializeLPString(bytesReader);
case StacksWireType.MemoString:
return deserializeMemoStringBytes(bytesReader);
return deserializeMemoString(bytesReader);
case StacksWireType.Asset:
return deserializeAssetBytes(bytesReader);
return deserializeAsset(bytesReader);
case StacksWireType.PostCondition:
return deserializePostConditionBytes(bytesReader);
return deserializePostCondition(bytesReader);
case StacksWireType.PublicKey:
return deserializePublicKeyBytes(bytesReader);
return deserializePublicKey(bytesReader);
case StacksWireType.Payload:
return deserializePayloadBytes(bytesReader);
return deserializePayload(bytesReader);
case StacksWireType.LengthPrefixedList:

@@ -139,5 +139,5 @@ if (!listType) {

}
return deserializeLPListBytes(bytesReader, listType);
return deserializeLPList(bytesReader, listType);
case StacksWireType.MessageSignature:
return deserializeMessageSignatureBytes(bytesReader);
return deserializeMessageSignature(bytesReader);
default:

@@ -159,7 +159,4 @@ throw new Error('Could not recognize StacksWireType');

export function deserializeAddress(serialized: string): AddressWire {
return deserializeAddressBytes(hexToBytes(serialized));
}
/** @internal */
export function deserializeAddressBytes(serialized: Uint8Array | BytesReader): AddressWire {
export function deserializeAddress(serialized: string | Uint8Array | BytesReader): AddressWire {
const bytesReader = isInstance(serialized, BytesReader)

@@ -193,8 +190,5 @@ ? serialized

export function deserializePrincipal(serialized: string): PostConditionPrincipalWire {
return deserializePrincipalBytes(hexToBytes(serialized));
}
/** @internal */
export function deserializePrincipalBytes(
serialized: Uint8Array | BytesReader
export function deserializePrincipal(
serialized: string | Uint8Array | BytesReader
): PostConditionPrincipalWire {

@@ -210,7 +204,7 @@ const bytesReader = isInstance(serialized, BytesReader)

}
const address = deserializeAddressBytes(bytesReader);
const address = deserializeAddress(bytesReader);
if (prefix === PostConditionPrincipalId.Standard) {
return { type: StacksWireType.Principal, prefix, address } as StandardPrincipalWire;
}
const contractName = deserializeLPStringBytes(bytesReader);
const contractName = deserializeLPString(bytesReader);
return {

@@ -237,15 +231,8 @@ type: StacksWireType.Principal,

/** @internal */
export function deserializeLPString(
serialized: string,
serialized: string | Uint8Array | BytesReader,
prefixBytes?: number,
maxLength?: number
): LengthPrefixedStringWire {
return deserializeLPStringBytes(hexToBytes(serialized), prefixBytes, maxLength);
}
/** @internal */
export function deserializeLPStringBytes(
serialized: Uint8Array | BytesReader,
prefixBytes?: number,
maxLength?: number
): LengthPrefixedStringWire {
prefixBytes = prefixBytes ? prefixBytes : 1;

@@ -272,7 +259,6 @@ const bytesReader = isInstance(serialized, BytesReader)

export function deserializeMemoString(serialized: string): MemoStringWire {
return deserializeMemoStringBytes(hexToBytes(serialized));
}
/** @internal */
export function deserializeMemoStringBytes(serialized: Uint8Array | BytesReader): MemoStringWire {
export function deserializeMemoString(
serialized: string | Uint8Array | BytesReader
): MemoStringWire {
const bytesReader = isInstance(serialized, BytesReader)

@@ -298,7 +284,4 @@ ? serialized

export function deserializeAsset(serialized: string): AssetWire {
return deserializeAssetBytes(hexToBytes(serialized));
}
/** @internal */
export function deserializeAssetBytes(serialized: Uint8Array | BytesReader): AssetWire {
export function deserializeAsset(serialized: string | Uint8Array | BytesReader): AssetWire {
const bytesReader = isInstance(serialized, BytesReader)

@@ -309,5 +292,5 @@ ? serialized

type: StacksWireType.Asset,
address: deserializeAddressBytes(bytesReader),
contractName: deserializeLPStringBytes(bytesReader),
assetName: deserializeLPStringBytes(bytesReader),
address: deserializeAddress(bytesReader),
contractName: deserializeLPString(bytesReader),
assetName: deserializeLPString(bytesReader),
};

@@ -330,16 +313,9 @@ }

// todo: `next` refactor for inversion of control
/** @internal */
export function deserializeLPList(
serialized: string,
serialized: string | Uint8Array | BytesReader,
type: StacksWireType,
lengthPrefixBytes?: number
// todo: `next` refactor for inversion of control
): LengthPrefixedList {
return deserializeLPListBytes(hexToBytes(serialized), type, lengthPrefixBytes);
}
/** @internal */
export function deserializeLPListBytes(
serialized: Uint8Array | BytesReader,
type: StacksWireType,
lengthPrefixBytes?: number
): LengthPrefixedList {
const bytesReader = isInstance(serialized, BytesReader)

@@ -354,21 +330,21 @@ ? serialized

case StacksWireType.Address:
l.push(deserializeAddressBytes(bytesReader));
l.push(deserializeAddress(bytesReader));
break;
case StacksWireType.LengthPrefixedString:
l.push(deserializeLPStringBytes(bytesReader));
l.push(deserializeLPString(bytesReader));
break;
case StacksWireType.MemoString:
l.push(deserializeMemoStringBytes(bytesReader));
l.push(deserializeMemoString(bytesReader));
break;
case StacksWireType.Asset:
l.push(deserializeAssetBytes(bytesReader));
l.push(deserializeAsset(bytesReader));
break;
case StacksWireType.PostCondition:
l.push(deserializePostConditionBytes(bytesReader));
l.push(deserializePostCondition(bytesReader));
break;
case StacksWireType.PublicKey:
l.push(deserializePublicKeyBytes(bytesReader));
l.push(deserializePublicKey(bytesReader));
break;
case StacksWireType.TransactionAuthField:
l.push(deserializeTransactionAuthFieldBytes(bytesReader));
l.push(deserializeTransactionAuthField(bytesReader));
break;

@@ -415,8 +391,5 @@ }

export function deserializePostCondition(serialized: string): PostConditionWire {
return deserializePostConditionBytes(hexToBytes(serialized));
}
/** @internal */
export function deserializePostConditionBytes(
serialized: Uint8Array | BytesReader
export function deserializePostCondition(
serialized: string | Uint8Array | BytesReader
): PostConditionWire {

@@ -430,3 +403,3 @@ const bytesReader = isInstance(serialized, BytesReader)

const principal = deserializePrincipalBytes(bytesReader);
const principal = deserializePrincipal(bytesReader);

@@ -450,3 +423,3 @@ let conditionCode;

case PostConditionType.Fungible:
asset = deserializeAssetBytes(bytesReader);
asset = deserializeAsset(bytesReader);
conditionCode = bytesReader.readUInt8Enum(FungibleConditionCode, n => {

@@ -465,3 +438,3 @@ throw new DeserializationError(`Could not read ${n} as FungibleConditionCode`);

case PostConditionType.NonFungible:
asset = deserializeAssetBytes(bytesReader);
asset = deserializeAsset(bytesReader);
const assetName = deserializeCV(bytesReader);

@@ -476,3 +449,3 @@ conditionCode = bytesReader.readUInt8Enum(NonFungibleConditionCode, n => {

conditionCode,
asset: asset,
asset,
assetName,

@@ -546,7 +519,4 @@ };

export function deserializePayload(serialized: string): PayloadWire {
return deserializePayloadBytes(hexToBytes(serialized));
}
/** @ignore */
export function deserializePayloadBytes(serialized: Uint8Array | BytesReader): PayloadWire {
export function deserializePayload(serialized: string | Uint8Array | BytesReader): PayloadWire {
const bytesReader = isInstance(serialized, BytesReader)

@@ -563,8 +533,8 @@ ? serialized

const amount = intToBigInt(bytesReader.readBytes(8));
const memo = deserializeMemoStringBytes(bytesReader);
const memo = deserializeMemoString(bytesReader);
return createTokenTransferPayload(recipient, amount, memo);
case PayloadType.ContractCall:
const contractAddress = deserializeAddressBytes(bytesReader);
const contractCallName = deserializeLPStringBytes(bytesReader);
const functionName = deserializeLPStringBytes(bytesReader);
const contractAddress = deserializeAddress(bytesReader);
const contractCallName = deserializeLPString(bytesReader);
const functionName = deserializeLPString(bytesReader);
const functionArgs: ClarityValue[] = [];

@@ -583,4 +553,4 @@ const numberOfArgs = bytesReader.readUInt32BE();

case PayloadType.SmartContract:
const smartContractName = deserializeLPStringBytes(bytesReader);
const codeBody = deserializeLPStringBytes(bytesReader, 4, 100_000);
const smartContractName = deserializeLPString(bytesReader);
const codeBody = deserializeLPString(bytesReader, 4, 100_000);
return createSmartContractPayload(smartContractName, codeBody);

@@ -592,4 +562,4 @@

});
const smartContractName = deserializeLPStringBytes(bytesReader);
const codeBody = deserializeLPStringBytes(bytesReader, 4, 100_000);
const smartContractName = deserializeLPString(bytesReader);
const codeBody = deserializeLPString(bytesReader, 4, 100_000);
return createSmartContractPayload(smartContractName, codeBody, clarityVersion);

@@ -637,8 +607,5 @@ }

export function deserializeMessageSignature(serialized: string): MessageSignatureWire {
return deserializeMessageSignatureBytes(hexToBytes(serialized));
}
/** @ignore */
export function deserializeMessageSignatureBytes(
serialized: Uint8Array | BytesReader
export function deserializeMessageSignature(
serialized: string | Uint8Array | BytesReader
): MessageSignatureWire {

@@ -653,8 +620,5 @@ const bytesReader = isInstance(serialized, BytesReader)

export function deserializeTransactionAuthField(serialized: string): TransactionAuthFieldWire {
return deserializeTransactionAuthFieldBytes(hexToBytes(serialized));
}
/** @ignore */
export function deserializeTransactionAuthFieldBytes(
serialized: Uint8Array | BytesReader
export function deserializeTransactionAuthField(
serialized: string | Uint8Array | BytesReader
): TransactionAuthFieldWire {

@@ -672,3 +636,3 @@ const bytesReader = isInstance(serialized, BytesReader)

PubKeyEncoding.Compressed,
deserializePublicKeyBytes(bytesReader)
deserializePublicKey(bytesReader)
);

@@ -678,3 +642,3 @@ case AuthFieldType.PublicKeyUncompressed:

PubKeyEncoding.Uncompressed,
createStacksPublicKey(uncompressPublicKey(deserializePublicKeyBytes(bytesReader).data))
createStacksPublicKey(uncompressPublicKey(deserializePublicKey(bytesReader).data))
);

@@ -684,3 +648,3 @@ case AuthFieldType.SignatureCompressed:

PubKeyEncoding.Compressed,
deserializeMessageSignatureBytes(bytesReader)
deserializeMessageSignature(bytesReader)
);

@@ -690,3 +654,3 @@ case AuthFieldType.SignatureUncompressed:

PubKeyEncoding.Uncompressed,
deserializeMessageSignatureBytes(bytesReader)
deserializeMessageSignature(bytesReader)
);

@@ -743,7 +707,4 @@ default:

export function deserializePublicKey(serialized: string): PublicKeyWire {
return deserializePublicKeyBytes(hexToBytes(serialized));
}
/** @ignore */
export function deserializePublicKeyBytes(serialized: Uint8Array | BytesReader): PublicKeyWire {
export function deserializePublicKey(serialized: string | Uint8Array | BytesReader): PublicKeyWire {
const bytesReader = isInstance(serialized, BytesReader)

@@ -750,0 +711,0 @@ ? serialized

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc