@stacks/transactions
Advanced tools
@@ -6,3 +6,3 @@ import { Hex, IntegerType, PrivateKey, PublicKey } from '@stacks/common'; | ||
import { AnchorMode, AuthType, PostConditionMode } from './constants'; | ||
import { LengthPrefixedList, PayloadInput, PayloadWire, PublicKeyWire } from './wire'; | ||
import { LengthPrefixedList, PayloadInput, PayloadWire, PostConditionWire, PublicKeyWire } from './wire'; | ||
export declare class StacksTransactionWire { | ||
@@ -14,3 +14,3 @@ transactionVersion: TransactionVersion; | ||
postConditionMode: PostConditionMode; | ||
postConditions: LengthPrefixedList; | ||
postConditions: LengthPrefixedList<PostConditionWire>; | ||
anchorMode: AnchorMode; | ||
@@ -20,3 +20,3 @@ constructor({ auth, payload, postConditions, postConditionMode, transactionVersion, chainId, network, }: { | ||
auth: Authorization; | ||
postConditions?: LengthPrefixedList; | ||
postConditions?: LengthPrefixedList<PostConditionWire>; | ||
postConditionMode?: PostConditionMode; | ||
@@ -23,0 +23,0 @@ transactionVersion?: TransactionVersion; |
@@ -7,3 +7,3 @@ import { IntegerType } from '@stacks/common'; | ||
export declare function createMemoString(content: string): MemoStringWire; | ||
export declare function createLPList<T extends StacksWire>(values: T[], lengthPrefixBytes?: number): LengthPrefixedList; | ||
export declare function createLPList<T extends StacksWire>(values: T[], lengthPrefixBytes?: number): LengthPrefixedList<T>; | ||
export declare function createMessageSignature(signature: string): MessageSignatureWire; | ||
@@ -10,0 +10,0 @@ export declare function createTokenTransferPayload(recipient: string | PrincipalCV, amount: IntegerType, memo?: string | MemoStringWire): TokenTransferPayloadWire; |
@@ -23,3 +23,3 @@ import { BytesReader } from '../BytesReader'; | ||
export declare function serializeLPListBytes(lpList: LengthPrefixedList): Uint8Array; | ||
export declare function deserializeLPList(serialized: string | Uint8Array | BytesReader, type: StacksWireType, lengthPrefixBytes?: number): LengthPrefixedList; | ||
export declare function deserializeLPList<TType extends StacksWireType = StacksWireType, TWire extends StacksWire = TType extends StacksWireType.Address ? AddressWire : TType extends StacksWireType.LengthPrefixedString ? LengthPrefixedStringWire : TType extends StacksWireType.MemoString ? MemoStringWire : TType extends StacksWireType.Asset ? AssetWire : TType extends StacksWireType.PostCondition ? PostConditionWire : TType extends StacksWireType.PublicKey ? PublicKeyWire : TType extends StacksWireType.TransactionAuthField ? TransactionAuthFieldWire : StacksWire>(serialized: string | Uint8Array | BytesReader, type: TType, lengthPrefixBytes?: number): LengthPrefixedList<TWire>; | ||
export declare function serializePostConditionWire(postCondition: PostConditionWire): string; | ||
@@ -26,0 +26,0 @@ export declare function serializePostConditionWireBytes(postCondition: PostConditionWire): Uint8Array; |
@@ -29,6 +29,6 @@ import { IntegerType } from '@stacks/common'; | ||
} | ||
export interface LengthPrefixedList { | ||
export interface LengthPrefixedList<TWire extends StacksWire = StacksWire> { | ||
readonly type: StacksWireType.LengthPrefixedList; | ||
readonly lengthPrefixBytes: number; | ||
readonly values: StacksWire[]; | ||
readonly values: TWire[]; | ||
} | ||
@@ -35,0 +35,0 @@ export interface AddressWire { |
@@ -6,3 +6,3 @@ import { Hex, IntegerType, PrivateKey, PublicKey } from '@stacks/common'; | ||
import { AnchorMode, AuthType, PostConditionMode } from './constants'; | ||
import { LengthPrefixedList, PayloadInput, PayloadWire, PublicKeyWire } from './wire'; | ||
import { LengthPrefixedList, PayloadInput, PayloadWire, PostConditionWire, PublicKeyWire } from './wire'; | ||
export declare class StacksTransactionWire { | ||
@@ -14,3 +14,3 @@ transactionVersion: TransactionVersion; | ||
postConditionMode: PostConditionMode; | ||
postConditions: LengthPrefixedList; | ||
postConditions: LengthPrefixedList<PostConditionWire>; | ||
anchorMode: AnchorMode; | ||
@@ -20,3 +20,3 @@ constructor({ auth, payload, postConditions, postConditionMode, transactionVersion, chainId, network, }: { | ||
auth: Authorization; | ||
postConditions?: LengthPrefixedList; | ||
postConditions?: LengthPrefixedList<PostConditionWire>; | ||
postConditionMode?: PostConditionMode; | ||
@@ -23,0 +23,0 @@ transactionVersion?: TransactionVersion; |
@@ -7,3 +7,3 @@ import { IntegerType } from '@stacks/common'; | ||
export declare function createMemoString(content: string): MemoStringWire; | ||
export declare function createLPList<T extends StacksWire>(values: T[], lengthPrefixBytes?: number): LengthPrefixedList; | ||
export declare function createLPList<T extends StacksWire>(values: T[], lengthPrefixBytes?: number): LengthPrefixedList<T>; | ||
export declare function createMessageSignature(signature: string): MessageSignatureWire; | ||
@@ -10,0 +10,0 @@ export declare function createTokenTransferPayload(recipient: string | PrincipalCV, amount: IntegerType, memo?: string | MemoStringWire): TokenTransferPayloadWire; |
@@ -23,3 +23,3 @@ import { BytesReader } from '../BytesReader'; | ||
export declare function serializeLPListBytes(lpList: LengthPrefixedList): Uint8Array; | ||
export declare function deserializeLPList(serialized: string | Uint8Array | BytesReader, type: StacksWireType, lengthPrefixBytes?: number): LengthPrefixedList; | ||
export declare function deserializeLPList<TType extends StacksWireType = StacksWireType, TWire extends StacksWire = TType extends StacksWireType.Address ? AddressWire : TType extends StacksWireType.LengthPrefixedString ? LengthPrefixedStringWire : TType extends StacksWireType.MemoString ? MemoStringWire : TType extends StacksWireType.Asset ? AssetWire : TType extends StacksWireType.PostCondition ? PostConditionWire : TType extends StacksWireType.PublicKey ? PublicKeyWire : TType extends StacksWireType.TransactionAuthField ? TransactionAuthFieldWire : StacksWire>(serialized: string | Uint8Array | BytesReader, type: TType, lengthPrefixBytes?: number): LengthPrefixedList<TWire>; | ||
export declare function serializePostConditionWire(postCondition: PostConditionWire): string; | ||
@@ -26,0 +26,0 @@ export declare function serializePostConditionWireBytes(postCondition: PostConditionWire): Uint8Array; |
@@ -29,6 +29,6 @@ import { IntegerType } from '@stacks/common'; | ||
} | ||
export interface LengthPrefixedList { | ||
export interface LengthPrefixedList<TWire extends StacksWire = StacksWire> { | ||
readonly type: StacksWireType.LengthPrefixedList; | ||
readonly lengthPrefixBytes: number; | ||
readonly values: StacksWire[]; | ||
readonly values: TWire[]; | ||
} | ||
@@ -35,0 +35,0 @@ export interface AddressWire { |
{ | ||
"name": "@stacks/transactions", | ||
"version": "7.0.3-beta.0", | ||
"version": "7.0.3-beta.1", | ||
"description": "Javascript library for constructing transactions on the Stacks blockchain.", | ||
@@ -30,4 +30,4 @@ "license": "MIT", | ||
"@noble/secp256k1": "1.7.1", | ||
"@stacks/common": "^7.0.3-beta.0", | ||
"@stacks/network": "^7.0.3-beta.0", | ||
"@stacks/common": "^7.0.3-beta.1", | ||
"@stacks/network": "^7.0.3-beta.1", | ||
"c32check": "^2.0.0", | ||
@@ -37,3 +37,3 @@ "lodash.clonedeep": "^4.5.0" | ||
"devDependencies": { | ||
"@stacks/encryption": "^7.0.3-beta.0", | ||
"@stacks/encryption": "^7.0.3-beta.1", | ||
"@types/common-tags": "^1.8.0", | ||
@@ -67,3 +67,3 @@ "@types/elliptic": "^6.4.12", | ||
}, | ||
"gitHead": "eb45b0150dabe69734769c5b7dce0935db5a419f" | ||
"gitHead": "82ad02092082e73f33979842c82b8d7c5d1a3970" | ||
} |
@@ -53,2 +53,3 @@ import { | ||
PayloadWire, | ||
PostConditionWire, | ||
PublicKeyWire, | ||
@@ -70,3 +71,3 @@ StacksWireType, | ||
postConditionMode: PostConditionMode; | ||
postConditions: LengthPrefixedList; | ||
postConditions: LengthPrefixedList<PostConditionWire>; | ||
@@ -88,3 +89,3 @@ /** @deprecated Not used, starting with Stacks 2.5. Still needed for serialization. */ | ||
auth: Authorization; | ||
postConditions?: LengthPrefixedList; | ||
postConditions?: LengthPrefixedList<PostConditionWire>; | ||
postConditionMode?: PostConditionMode; | ||
@@ -91,0 +92,0 @@ transactionVersion?: TransactionVersion; |
@@ -60,3 +60,3 @@ import { IntegerType, hexToBytes, intToBigInt } from '@stacks/common'; | ||
lengthPrefixBytes?: number | ||
): LengthPrefixedList { | ||
): LengthPrefixedList<T> { | ||
return { | ||
@@ -63,0 +63,0 @@ type: StacksWireType.LengthPrefixedList, |
@@ -289,8 +289,25 @@ import { | ||
export function deserializeLPList( | ||
export function deserializeLPList< | ||
TType extends StacksWireType = StacksWireType, | ||
TWire extends StacksWire = TType extends StacksWireType.Address | ||
? AddressWire | ||
: TType extends StacksWireType.LengthPrefixedString | ||
? LengthPrefixedStringWire | ||
: TType extends StacksWireType.MemoString | ||
? MemoStringWire | ||
: TType extends StacksWireType.Asset | ||
? AssetWire | ||
: TType extends StacksWireType.PostCondition | ||
? PostConditionWire | ||
: TType extends StacksWireType.PublicKey | ||
? PublicKeyWire | ||
: TType extends StacksWireType.TransactionAuthField | ||
? TransactionAuthFieldWire | ||
: StacksWire, | ||
>( | ||
serialized: string | Uint8Array | BytesReader, | ||
type: StacksWireType, | ||
type: TType, | ||
lengthPrefixBytes?: number | ||
// todo: `next` refactor for inversion of control | ||
): LengthPrefixedList { | ||
): LengthPrefixedList<TWire> { | ||
const bytesReader = isInstance(serialized, BytesReader) | ||
@@ -327,3 +344,3 @@ ? serialized | ||
} | ||
return createLPList(l, lengthPrefixBytes); | ||
return createLPList<TWire>(l as TWire[], lengthPrefixBytes); | ||
} | ||
@@ -330,0 +347,0 @@ |
@@ -64,6 +64,6 @@ import { IntegerType } from '@stacks/common'; | ||
export interface LengthPrefixedList { | ||
export interface LengthPrefixedList<TWire extends StacksWire = StacksWire> { | ||
readonly type: StacksWireType.LengthPrefixedList; | ||
readonly lengthPrefixBytes: number; | ||
readonly values: StacksWire[]; | ||
readonly values: TWire[]; | ||
} | ||
@@ -70,0 +70,0 @@ |
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
1880877
0.15%19117
0.12%