@clarigen/core 4.0.1 → 4.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,557 @@
1
+ import { h as SimnetDeploymentPlan, o as DeploymentPlan } from "./deployment-B3q-81ej.cjs";
2
+ import { ClarityAbi as ClarityAbi$1, ClarityAbiTypeTuple as ClarityAbiTypeTuple$1, ClarityValue, ContractPrincipalCV, FungiblePostCondition, NonFungiblePostCondition, PrincipalCV, StacksTransactionWire } from "@stacks/transactions";
3
+ import { StacksNetwork, StacksNetworkName } from "@stacks/network";
4
+
5
+ //#region src/abi-types.d.ts
6
+ type ClarityAbiTypeBuffer = {
7
+ buffer: {
8
+ length: number;
9
+ };
10
+ };
11
+ type ClarityAbiTypeStringAscii = {
12
+ 'string-ascii': {
13
+ length: number;
14
+ };
15
+ };
16
+ type ClarityAbiTypeStringUtf8 = {
17
+ 'string-utf8': {
18
+ length: number;
19
+ };
20
+ };
21
+ type ClarityAbiTypeResponse = {
22
+ response: {
23
+ ok: ClarityAbiType;
24
+ error: ClarityAbiType;
25
+ };
26
+ };
27
+ type ClarityAbiTypeOptional = {
28
+ optional: ClarityAbiType;
29
+ };
30
+ type ClarityAbiTypeTuple = {
31
+ tuple: readonly {
32
+ name: string;
33
+ type: ClarityAbiType;
34
+ }[];
35
+ };
36
+ type ClarityAbiTypeList = {
37
+ list: {
38
+ type: ClarityAbiType;
39
+ length: number;
40
+ };
41
+ };
42
+ type ClarityAbiTypeUInt128 = 'uint128';
43
+ type ClarityAbiTypeInt128 = 'int128';
44
+ type ClarityAbiTypeBool = 'bool';
45
+ type ClarityAbiTypePrincipal = 'principal';
46
+ type ClarityAbiTypeTraitReference = 'trait_reference';
47
+ type ClarityAbiTypeNone = 'none';
48
+ type ClarityAbiTypePrimitive = ClarityAbiTypeUInt128 | ClarityAbiTypeInt128 | ClarityAbiTypeBool | ClarityAbiTypePrincipal | ClarityAbiTypeTraitReference | ClarityAbiTypeNone;
49
+ type ClarityAbiType = ClarityAbiTypePrimitive | ClarityAbiTypeBuffer | ClarityAbiTypeResponse | ClarityAbiTypeOptional | ClarityAbiTypeTuple | ClarityAbiTypeList | ClarityAbiTypeStringAscii | ClarityAbiTypeStringUtf8 | ClarityAbiTypeTraitReference;
50
+ interface ClarityAbiArg {
51
+ name: string;
52
+ type: ClarityAbiType;
53
+ }
54
+ interface ClarityAbiFunction {
55
+ name: string;
56
+ access: 'private' | 'public' | 'read_only';
57
+ args: ClarityAbiArg[];
58
+ outputs: {
59
+ type: ClarityAbiType;
60
+ };
61
+ }
62
+ type TypedAbiArg<T, N$1 extends string> = {
63
+ _t?: T;
64
+ name: N$1;
65
+ };
66
+ type TypedAbiFunction<T extends TypedAbiArg<unknown, string>[], R$1> = ClarityAbiFunction & {
67
+ _t?: T;
68
+ _r?: R$1;
69
+ };
70
+ interface ClarityAbiVariable {
71
+ name: string;
72
+ access: 'variable' | 'constant';
73
+ type: ClarityAbiType;
74
+ }
75
+ type TypedAbiVariable<T> = ClarityAbiVariable & {};
76
+ interface ClarityAbiMap {
77
+ name: string;
78
+ key: ClarityAbiType;
79
+ value: ClarityAbiType;
80
+ }
81
+ type TypedAbiMap<K$1, V$1> = ClarityAbiMap & {
82
+ _k?: K$1;
83
+ _v?: V$1;
84
+ };
85
+ interface ClarityAbiTypeFungibleToken {
86
+ name: string;
87
+ }
88
+ interface ClarityAbiTypeNonFungibleToken<T = unknown> {
89
+ name: string;
90
+ type: ClarityAbiType;
91
+ _t?: T;
92
+ }
93
+ type StacksEpochId = 'Epoch10' | 'Epoch20' | 'Epoch2_05' | 'Epoch21' | 'Epoch22' | 'Epoch23' | 'Epoch24' | 'Epoch25' | 'Epoch30' | 'Epoch31' | 'Epoch32' | 'Epoch33';
94
+ type ClarityVersion = 'Clarity1' | 'Clarity2' | 'Clarity3' | 'Clarity4';
95
+ type TypedAbi = Readonly<{
96
+ functions: {
97
+ [key: string]: TypedAbiFunction<TypedAbiArg<unknown, string>[], unknown>;
98
+ };
99
+ variables: {
100
+ [key: string]: TypedAbiVariable<unknown>;
101
+ };
102
+ maps: {
103
+ [key: string]: TypedAbiMap<unknown, unknown>;
104
+ };
105
+ constants: {
106
+ [key: string]: unknown;
107
+ };
108
+ fungible_tokens: Readonly<ClarityAbiTypeFungibleToken[]>;
109
+ non_fungible_tokens: Readonly<ClarityAbiTypeNonFungibleToken<unknown>[]>;
110
+ contractName: string;
111
+ contractFile?: string;
112
+ }>;
113
+ interface ResponseOk<T, E> {
114
+ value: T;
115
+ isOk: true;
116
+ _e?: E;
117
+ }
118
+ interface ResponseErr<T, E> {
119
+ value: E;
120
+ isOk: false;
121
+ _o?: T;
122
+ }
123
+ type Response<Ok, Err> = ResponseOk<Ok, Err> | ResponseErr<Ok, Err>;
124
+ type OkType<R$1> = R$1 extends ResponseOk<infer V, unknown> ? V : never;
125
+ type ErrType<R$1> = R$1 extends ResponseErr<unknown, infer V> ? V : never;
126
+ //#endregion
127
+ //#region src/clarity-types.d.ts
128
+ declare function ok<T, Err = never>(value: T): ResponseOk<T, Err>;
129
+ declare function err<Ok = never, T = unknown>(value: T): ResponseErr<Ok, T>;
130
+ declare function isResponse<T>(value: Response<T, T> | T): value is Response<T, T>;
131
+ interface ClarityAbi extends ClarityAbi$1 {
132
+ epoch: StacksEpochId;
133
+ clarity_version: ClarityVersion;
134
+ }
135
+ declare function principalToString(principal: PrincipalCV): string;
136
+ /**
137
+ * @param val - ClarityValue
138
+ * @param returnResponse - if true, this will return a "response" object.
139
+ * Otherwise, it returns the inner value of the response (whether ok or err)
140
+ */
141
+ declare function cvToValue<T = any>(val: ClarityValue, returnResponse?: boolean): T;
142
+ /**
143
+ * Converts a hex encoded string to the javascript clarity value object {type: string; value: any}
144
+ * @param hex - the hex encoded string with or without `0x` prefix
145
+ * @param jsonCompat - enable to serialize bigints to strings
146
+ */
147
+ declare function hexToCvValue<T>(hex: string, jsonCompat?: boolean): any;
148
+ type TupleInput = Record<string, any>;
149
+ type CVInput = string | boolean | TupleInput | number | bigint;
150
+ declare const isClarityAbiPrimitive: (val: ClarityAbiType) => val is ClarityAbiTypePrimitive;
151
+ declare const isClarityAbiBuffer: (val: ClarityAbiType) => val is ClarityAbiTypeBuffer;
152
+ declare const isClarityAbiStringAscii: (val: ClarityAbiType) => val is ClarityAbiTypeStringAscii;
153
+ declare const isClarityAbiStringUtf8: (val: ClarityAbiType) => val is ClarityAbiTypeStringUtf8;
154
+ declare const isClarityAbiResponse: (val: ClarityAbiType) => val is ClarityAbiTypeResponse;
155
+ declare const isClarityAbiOptional: (val: ClarityAbiType) => val is ClarityAbiTypeOptional;
156
+ declare const isClarityAbiTuple: (val: ClarityAbiType) => val is ClarityAbiTypeTuple$1;
157
+ declare const isClarityAbiList: (val: ClarityAbiType) => val is ClarityAbiTypeList;
158
+ declare const isClarityAbiTraitReference: (val: ClarityAbiType) => val is "trait_reference";
159
+ declare function parseToCV(input: CVInput, type: ClarityAbiType): ClarityValue;
160
+ declare function cvToString(val: ClarityValue, encoding?: 'tryAscii' | 'hex'): string;
161
+ /**
162
+ * Convert a Clarity value to valid JSON. This does this same thing as
163
+ * `cvToValue`, except that integers are returned as strings, and buffers
164
+ * are returned as hex-encoded strings.
165
+ *
166
+ * @param val - ClarityValue
167
+ */
168
+ declare function cvToJSON<T = any>(val: ClarityValue, returnResponse?: boolean): T;
169
+ declare function transformObjectArgs(func: ClarityAbiFunction, args: Record<string, any>): ClarityValue[];
170
+ declare function transformArgsArray(func: ClarityAbiFunction, args: any[]): ClarityValue[];
171
+ declare function transformArgsToCV(func: ClarityAbiFunction, args: any[] | [Record<string, any>]): ClarityValue[];
172
+ declare function findJsTupleKey(key: string, input: Record<string, any>): string;
173
+ declare function expectOk<Ok>(response: Response<Ok, any>): Ok;
174
+ declare function expectErr<Err>(response: Response<any, Err>): Err;
175
+ type AbiPrimitiveTo<T extends ClarityAbiTypePrimitive> = T extends ClarityAbiTypeInt128 ? bigint : T extends ClarityAbiTypeUInt128 ? bigint : T extends ClarityAbiTypeBool ? boolean : T extends ClarityAbiTypePrincipal ? string : T extends ClarityAbiTypeTraitReference ? string : T extends ClarityAbiTypeNone ? never : T;
176
+ type ReadonlyTuple = {
177
+ readonly tuple: Readonly<ClarityAbiTypeTuple$1['tuple']>;
178
+ };
179
+ type TupleTypeUnion<T> = T extends Readonly<ClarityAbiTypeTuple$1['tuple'][number]> ? { -readonly [Z in T['name']]: AbiTypeTo<T['type']> } : never;
180
+ type UnionToIntersection$1<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
181
+ type Compact$1<T> = { [K in keyof T]: T[K] };
182
+ type AbiTupleTo<T extends ReadonlyTuple> = Compact$1<UnionToIntersection$1<TupleTypeUnion<T['tuple'][number]>>>;
183
+ type AbiTypeTo<T extends ClarityAbiType | ReadonlyTuple> = T extends ClarityAbiTypePrimitive ? AbiPrimitiveTo<T> : T extends ClarityAbiTypeBuffer ? Uint8Array : T extends ClarityAbiTypeStringAscii ? string : T extends ClarityAbiTypeStringUtf8 ? string : T extends ClarityAbiTypeList ? AbiTypeTo<T['list']['type']>[] : T extends ClarityAbiTypeOptional ? AbiTypeTo<T['optional']> | null : T extends ClarityAbiTypeResponse ? Response<AbiTypeTo<T['response']['ok']>, AbiTypeTo<T['response']['error']>> : T extends ReadonlyTuple ? AbiTupleTo<T> : never;
184
+ type FunctionReturnType<T> = T extends TypedAbiFunction<TypedAbiArg<unknown, string>[], infer R> ? R : never;
185
+ type Jsonize<T> = T extends BigInt ? string : T extends Uint8Array ? string : T extends (infer V)[] ? Jsonize<V>[] : T extends Record<keyof T, unknown> ? { [K in keyof T as K]: Jsonize<T[K]> } : T;
186
+ declare function getTypeString(val: ClarityAbiType): string;
187
+ //#endregion
188
+ //#region src/transaction.d.ts
189
+ interface ResultAssets {
190
+ stx: Record<string, string>;
191
+ burns: Record<string, string>;
192
+ tokens: Record<string, Record<string, string>>;
193
+ assets: Record<string, Record<string, string>>;
194
+ }
195
+ //#endregion
196
+ //#region src/factory-types.d.ts
197
+ interface ContractCall<T> {
198
+ function: ClarityAbiFunction;
199
+ nativeArgs: any[];
200
+ functionArgs: ClarityValue[];
201
+ contractAddress: string;
202
+ contractName: string;
203
+ functionName: string;
204
+ _r?: T;
205
+ }
206
+ interface ContractCallTyped<Args$1 extends UnknownArgs, R$1> extends Omit<ContractCall<R$1>, 'nativeArgs'> {
207
+ nativeArgs: ArgsType<Args$1>;
208
+ }
209
+ type ContractFunctions = {
210
+ [key: string]: TypedAbiFunction<UnknownArgs, unknown>;
211
+ };
212
+ type AllContracts = Record<string, TypedAbi>;
213
+ type UnknownArg = TypedAbiArg<unknown, string>;
214
+ type UnknownArgs = UnknownArg[];
215
+ type ArgsTuple<T extends UnknownArgs> = { [K in keyof T]: T[K] extends TypedAbiArg<infer A, string> ? A : never };
216
+ type ArgsRecordUnion<T extends TypedAbiArg<unknown, string>> = T extends TypedAbiArg<infer A, infer N> ? { [K in T as N]: A } : never;
217
+ type InnerUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
218
+ type Compact<T> = { [K in keyof T]: T[K] };
219
+ type UnionToIntersection<T> = Compact<InnerUnionToIntersection<T>>;
220
+ type ArgsRecord<T extends UnknownArgs> = UnionToIntersection<ArgsRecordUnion<T[number]>>;
221
+ type ArgsType<T extends UnknownArgs> = [ArgsRecord<T>] | ArgsTuple<T>;
222
+ type ContractCallFunction<Args$1 extends UnknownArgs, R$1> = {
223
+ (...args: ArgsType<Args$1>): ContractCallTyped<Args$1, R$1>;
224
+ abi: TypedAbiFunction<Args$1, R$1>;
225
+ };
226
+ type FnToContractCall<T> = T extends TypedAbiFunction<infer Arg, infer R> ? ContractCallFunction<Arg, R> : never;
227
+ type FunctionsToContractCalls<T> = T extends ContractFunctions ? { [key in keyof T]: FnToContractCall<T[key]> } : never;
228
+ type ContractsToContractCalls<T> = T extends AllContracts ? { [key in keyof T]: FunctionsToContractCalls<T[key]['functions']> } : never;
229
+ type FullContract<T> = T extends TypedAbi ? FunctionsToContractCalls<T['functions']> & T & {
230
+ identifier: string;
231
+ } & {
232
+ contractFile: string;
233
+ } : never;
234
+ type ContractFactory<T extends AllContracts> = { [key in keyof T]: FullContract<T[key]> };
235
+ //#endregion
236
+ //#region src/types.d.ts
237
+ type Kebab<T extends string, A$1 extends string = ''> = T extends `${infer F}${infer R}` ? Kebab<R, `${A$1}${F extends Lowercase<F> ? '' : '-'}${Lowercase<F>}`> : A$1;
238
+ type KebabObject<T> = T extends Uint8Array ? T : T extends Record<string, unknown> ? { [K in keyof T as K extends string ? Kebab<K> : K]: KebabObject<T[K]> } : T;
239
+ type ExtractArgs<F$1> = F$1 extends TypedAbiFunction<infer Args, unknown> ? ArgsTuple<Args> : never;
240
+ type ExtractArgsRecord<F$1> = F$1 extends TypedAbiFunction<infer Args, unknown> ? ArgsRecord<Args> : never;
241
+ type ContractBuilder<T> = (contractAddress: string, contractName: string) => T;
242
+ interface Contract<T> {
243
+ address: string;
244
+ contractFile: string;
245
+ contract: ContractBuilder<T>;
246
+ abi: ClarityAbi;
247
+ name: string;
248
+ }
249
+ interface Contracts<T> {
250
+ [key: string]: Contract<T>;
251
+ }
252
+ interface ContractInstance<T> {
253
+ identifier: string;
254
+ contract: T;
255
+ }
256
+ type ContractInstances<T extends Contracts<any>> = { [Name in keyof T]: ContractInstance<ReturnType<T[Name]['contract']>> };
257
+ //#endregion
258
+ //#region src/utils.d.ts
259
+ declare const TESTNET_BURN_ADDRESS = "ST000000000000000000002AMW42H";
260
+ declare const MAINNET_BURN_ADDRESS = "SP000000000000000000002Q6VF78";
261
+ declare const toCamelCase: (input: string | number | symbol, titleCase?: boolean) => string;
262
+ declare function toKebabCase(input: string): string;
263
+ declare function getContractName(identifier: string, camelCase?: boolean): string;
264
+ declare const getContractNameFromPath: (path: string) => string;
265
+ declare const getContractIdentifier: <T>(contract: Contract<T>) => string;
266
+ declare const getContractPrincipalCV: <T>(contract: Contract<T>) => ContractPrincipalCV;
267
+ declare function bootContractIdentifier(name: string, mainnet: boolean): string;
268
+ declare function bytesToHex(bytes: Uint8Array): string;
269
+ declare function hexToBytes(hexString: string): Uint8Array;
270
+ declare function bytesToAscii(bytes: Uint8Array): string;
271
+ declare const isNumber: (value: number | string) => value is number;
272
+ type ErrorKeyCheck<K$1> = K$1 extends string ? Lowercase<K$1> extends `err${string}` ? K$1 : never : never;
273
+ type ErrorCodes<C extends TypedAbi['constants']> = { [K in keyof C as ErrorKeyCheck<K>]: C[K] extends {
274
+ isOk: boolean;
275
+ value: infer V;
276
+ } ? V : C[K] };
277
+ type ProjectErrors<T extends {
278
+ contracts: AllContracts;
279
+ }> = { [K in keyof T['contracts']]: ErrorCodes<T['contracts'][K]['constants']> };
280
+ declare function extractErrors<T extends TypedAbi>(contract: T): ErrorCodes<T['constants']>;
281
+ declare function projectErrors<T extends {
282
+ contracts: AllContracts;
283
+ }>(project: T): ProjectErrors<T>;
284
+ //#endregion
285
+ //#region src/events.d.ts
286
+ declare enum CoreNodeEventType {
287
+ ContractEvent = "contract_event",
288
+ StxTransferEvent = "stx_transfer_event",
289
+ StxMintEvent = "stx_mint_event",
290
+ StxBurnEvent = "stx_burn_event",
291
+ StxLockEvent = "stx_lock_event",
292
+ NftTransferEvent = "nft_transfer_event",
293
+ NftMintEvent = "nft_mint_event",
294
+ NftBurnEvent = "nft_burn_event",
295
+ FtTransferEvent = "ft_transfer_event",
296
+ FtMintEvent = "ft_mint_event",
297
+ FtBurnEvent = "ft_burn_event",
298
+ }
299
+ type NonStandardClarityValue = unknown;
300
+ interface CoreNodeEventBase {
301
+ /** 0x-prefix transaction hash. */
302
+ txid: string;
303
+ event_index: number;
304
+ committed: boolean;
305
+ }
306
+ interface SmartContractEvent extends CoreNodeEventBase {
307
+ type: CoreNodeEventType.ContractEvent;
308
+ contract_event: {
309
+ /** Fully qualified contract ID, e.g. "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH.kv-store" */
310
+ contract_identifier: string;
311
+ topic: string;
312
+ value: NonStandardClarityValue;
313
+ /** Hex encoded Clarity value. */
314
+ raw_value: string;
315
+ };
316
+ }
317
+ interface StxTransferEvent extends CoreNodeEventBase {
318
+ type: CoreNodeEventType.StxTransferEvent;
319
+ stx_transfer_event: {
320
+ recipient: string;
321
+ sender: string;
322
+ amount: string;
323
+ };
324
+ }
325
+ interface StxMintEvent extends CoreNodeEventBase {
326
+ type: CoreNodeEventType.StxMintEvent;
327
+ stx_mint_event: {
328
+ recipient: string;
329
+ amount: string;
330
+ };
331
+ }
332
+ interface StxBurnEvent extends CoreNodeEventBase {
333
+ type: CoreNodeEventType.StxBurnEvent;
334
+ stx_burn_event: {
335
+ sender: string;
336
+ amount: string;
337
+ };
338
+ }
339
+ interface StxLockEvent extends CoreNodeEventBase {
340
+ type: CoreNodeEventType.StxLockEvent;
341
+ /** TODO: what dis? */
342
+ committed: boolean;
343
+ stx_lock_event: {
344
+ /** String quoted base10 integer. */
345
+ locked_amount: string;
346
+ /** String quoted base10 integer. */
347
+ unlock_height: string;
348
+ /** STX principal associated with the locked tokens. */
349
+ locked_address: string;
350
+ };
351
+ }
352
+ interface NftTransferEvent extends CoreNodeEventBase {
353
+ type: CoreNodeEventType.NftTransferEvent;
354
+ nft_transfer_event: {
355
+ /** Fully qualified asset ID, e.g. "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH.contract-name.asset-name" */
356
+ asset_identifier: string;
357
+ recipient: string;
358
+ sender: string;
359
+ value: NonStandardClarityValue;
360
+ /** Hex encoded Clarity value. */
361
+ raw_value: string;
362
+ };
363
+ }
364
+ interface NftMintEvent extends CoreNodeEventBase {
365
+ type: CoreNodeEventType.NftMintEvent;
366
+ nft_mint_event: {
367
+ /** Fully qualified asset ID, e.g. "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH.contract-name.asset-name" */
368
+ asset_identifier: string;
369
+ recipient: string;
370
+ value: NonStandardClarityValue;
371
+ /** Hex encoded Clarity value. */
372
+ raw_value: string;
373
+ };
374
+ }
375
+ interface NftBurnEvent extends CoreNodeEventBase {
376
+ type: CoreNodeEventType.NftBurnEvent;
377
+ nft_burn_event: {
378
+ /** Fully qualified asset ID, e.g. "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH.contract-name.asset-name" */
379
+ asset_identifier: string;
380
+ sender: string;
381
+ value: NonStandardClarityValue;
382
+ /** Hex encoded Clarity value. */
383
+ raw_value: string;
384
+ };
385
+ }
386
+ interface FtTransferEvent extends CoreNodeEventBase {
387
+ type: CoreNodeEventType.FtTransferEvent;
388
+ ft_transfer_event: {
389
+ /** Fully qualified asset ID, e.g. "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH.contract-name.asset-name" */
390
+ asset_identifier: string;
391
+ recipient: string;
392
+ sender: string;
393
+ amount: string;
394
+ };
395
+ }
396
+ interface FtMintEvent extends CoreNodeEventBase {
397
+ type: CoreNodeEventType.FtMintEvent;
398
+ ft_mint_event: {
399
+ /** Fully qualified asset ID, e.g. "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH.contract-name.asset-name" */
400
+ asset_identifier: string;
401
+ recipient: string;
402
+ amount: string;
403
+ };
404
+ }
405
+ interface FtBurnEvent extends CoreNodeEventBase {
406
+ type: CoreNodeEventType.FtBurnEvent;
407
+ ft_burn_event: {
408
+ /** Fully qualified asset ID, e.g. "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH.contract-name.asset-name" */
409
+ asset_identifier: string;
410
+ sender: string;
411
+ amount: string;
412
+ };
413
+ }
414
+ type CoreNodeEvent = SmartContractEvent | StxTransferEvent | StxMintEvent | StxBurnEvent | StxLockEvent | FtTransferEvent | FtMintEvent | FtBurnEvent | NftTransferEvent | NftMintEvent | NftBurnEvent;
415
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.ContractEvent): SmartContractEvent[];
416
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.StxTransferEvent): StxTransferEvent[];
417
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.StxMintEvent): StxMintEvent[];
418
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.StxBurnEvent): StxBurnEvent[];
419
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.StxLockEvent): StxLockEvent[];
420
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.NftTransferEvent): NftTransferEvent[];
421
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.NftMintEvent): NftMintEvent[];
422
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.NftBurnEvent): NftBurnEvent[];
423
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.FtTransferEvent): FtTransferEvent[];
424
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.FtMintEvent): FtMintEvent[];
425
+ declare function filterEvents(events: CoreNodeEvent[], type: CoreNodeEventType.FtBurnEvent): FtBurnEvent[];
426
+ //#endregion
427
+ //#region src/contracts.d.ts
428
+ interface MakeContractsOptions {
429
+ deployerAddress?: string;
430
+ }
431
+ declare function makeContracts<T extends Contracts<any>>(contracts: T, options?: MakeContractsOptions): ContractInstances<T>;
432
+ //#endregion
433
+ //#region src/pure/index.d.ts
434
+ interface PureContractInfo {
435
+ abi: ClarityAbi;
436
+ contractAddress: string;
437
+ contractName: string;
438
+ }
439
+ type ContractFn<T> = (args: any) => T;
440
+ type ContractReturn<C extends ContractFn<ContractCalls.ReadOnly<any>>> = C extends ContractFn<ContractCalls.ReadOnly<infer T>> ? T : unknown;
441
+ type ContractReturnOk<C extends ContractFn<ContractCalls.ReadOnly<any>>> = ContractReturn<C> extends Response<infer O, any> ? O : unknown;
442
+ type ContractReturnErr<C extends ContractFn<ContractCalls.ReadOnly<any>>> = ContractReturn<C> extends Response<any, infer E> ? E : unknown;
443
+ interface MapGet<Key, Val> {
444
+ map: ClarityAbiMap;
445
+ nativeKey: Key;
446
+ key: ClarityValue;
447
+ contractAddress: string;
448
+ contractName: string;
449
+ }
450
+ declare namespace ContractCalls {
451
+ type ReadOnly<T> = ContractCall<T>;
452
+ type Public<Ok, Err> = ContractCall<Response<Ok, Err>>;
453
+ type Private<T> = ContractCall<T>;
454
+ type Map<Key, Val> = MapGet<Key, Val>;
455
+ }
456
+ declare const pureProxy: <T extends object>(target: PureContractInfo) => T;
457
+ //#endregion
458
+ //#region src/api/index.d.ts
459
+ interface ApiOptionsUrl {
460
+ url: string;
461
+ network?: undefined;
462
+ }
463
+ type Network = StacksNetwork | StacksNetworkName;
464
+ interface ApiOptionsNetwork {
465
+ network: StacksNetworkName | StacksNetwork;
466
+ url?: undefined;
467
+ }
468
+ type ApiOptionsBase = {
469
+ network: StacksNetwork | StacksNetworkName;
470
+ tip?: string;
471
+ latest?: boolean;
472
+ apiKey?: string;
473
+ headers?: Record<string, string>;
474
+ };
475
+ type ApiOptionsJsonize = ApiOptionsBase & {
476
+ json: true;
477
+ };
478
+ type ApiOptionsNoJson = ApiOptionsBase & {
479
+ json?: false | undefined;
480
+ };
481
+ type ApiOptions = ApiOptionsBase & {
482
+ json?: boolean;
483
+ };
484
+ type JsonIfOption<O extends ApiOptions, R$1> = O extends ApiOptionsJsonize ? Jsonize<R$1> : R$1;
485
+ declare function ro<O extends ApiOptions, T>(tx: ContractCall<T>, options: O): Promise<JsonIfOption<O, T>>;
486
+ declare function roOk<O extends ApiOptions, Ok>(tx: ContractCall<Response<Ok, any>>, options: O): Promise<JsonIfOption<O, Ok>>;
487
+ declare function roErr<O extends ApiOptions, Err>(tx: ContractCall<Response<any, Err>>, options: O): Promise<JsonIfOption<O, Err>>;
488
+ declare function getApiUrl(opts: ApiOptions): string;
489
+ declare function fetchMapGet<Key, Val>(contractId: string, map: TypedAbiMap<Key, Val>, key: Key, options: ApiOptions): Promise<Val | null>;
490
+ declare function broadcast(transaction: StacksTransactionWire, options: ApiOptions): Promise<{
491
+ txId: string;
492
+ stacksTransaction: StacksTransactionWire;
493
+ }>;
494
+ type ClientOptions = Omit<ApiOptions, 'network'>;
495
+ type JsonIf<O extends ClientOptions, T> = JsonIfOption<O & ApiOptions, T>;
496
+ declare class ClarigenClient {
497
+ apiKey?: string | undefined;
498
+ headers?: Record<string, string> | undefined;
499
+ network: StacksNetwork | StacksNetworkName;
500
+ constructor(networkOrUrl: StacksNetwork | StacksNetworkName, apiKey?: string | undefined, headers?: Record<string, string> | undefined);
501
+ private roOptions;
502
+ ro<T, O extends ClientOptions>(tx: ContractCall<T>, options?: O): Promise<JsonIf<O, T>>;
503
+ roOk<T, O extends ClientOptions>(tx: ContractCall<Response<T, any>>, options?: O): Promise<JsonIf<O, T>>;
504
+ roErr<T, O extends ClientOptions>(tx: ContractCall<Response<any, T>>, options?: O): Promise<JsonIf<O, T>>;
505
+ }
506
+ //#endregion
507
+ //#region src/factory.d.ts
508
+ declare const DEPLOYMENT_NETWORKS: readonly ["devnet", "simnet", "testnet", "mainnet"];
509
+ type DeploymentNetwork = (typeof DEPLOYMENT_NETWORKS)[number];
510
+ type DeploymentsForContracts<C extends AllContracts> = { [K in keyof C]: ContractDeployments };
511
+ type ContractDeployments = { [key in DeploymentNetwork]: string | null };
512
+ type Project<C extends AllContracts, D extends DeploymentsForContracts<C>> = {
513
+ contracts: C;
514
+ deployments: D;
515
+ };
516
+ type FullContractWithIdentifier<C extends TypedAbi, Id extends string> = FullContract<C> & {
517
+ identifier: Id;
518
+ };
519
+ type IsDeploymentNetwork<T> = T extends DeploymentNetwork ? DeploymentNetwork extends T ? true : false : never;
520
+ type ProjectFactory<P extends Project<any, any>, N$1 extends DeploymentNetwork> = { [ContractName in keyof P['contracts']]: FullContractWithIdentifier<P['contracts'][ContractName], IsDeploymentNetwork<N$1> extends true ? '' : NonNullable<P['deployments'][ContractName][N$1]>> };
521
+ declare function projectFactory<P extends Project<C, D>, N$1 extends DeploymentNetwork, C extends AllContracts, D extends DeploymentsForContracts<C>>(project: P, network: N$1): ProjectFactory<P, N$1>;
522
+ declare function contractsFactory<T extends AllContracts>(contracts: T, deployer: string): ContractFactory<T>;
523
+ declare function functionsFactory<T extends ContractFunctions>(functions: T, identifier: string): FunctionsToContractCalls<T>;
524
+ /**
525
+ * Provide a contract's types and it's contract identifier to generate
526
+ * a full contract object with all functions available.
527
+ *
528
+ * @param abi - The Clarigen-generated contract types
529
+ * @param identifier - The contract's identifier, like `SP000000000000000000002Q6VF78.bns`
530
+ * @returns
531
+ */
532
+ declare function contractFactory<T extends TypedAbi, Id extends string>(abi: T, identifier: Id): FullContractWithIdentifier<T, Id>;
533
+ declare function deploymentFactory<T extends AllContracts>(contracts: T, deployer: DeploymentPlan): ContractFactory<T>;
534
+ type MapFactory<M extends TypedAbiMap<K$1, V$1>, K$1, V$1> = {
535
+ key: K$1;
536
+ _v?: V$1;
537
+ keyCV: ClarityValue;
538
+ map: M;
539
+ };
540
+ declare function mapFactory<Key, Val>(map: TypedAbiMap<Key, Val>, key: Key): MapFactory<TypedAbiMap<Key, Val>, Key, Val>;
541
+ //#endregion
542
+ //#region src/post-conditions.d.ts
543
+ type AbiWithAssets = Pick<FullContract<TypedAbi>, 'non_fungible_tokens' | 'fungible_tokens' | 'identifier'>;
544
+ type AssetNames<T extends AbiWithAssets> = T['non_fungible_tokens'][number]['name'] | T['fungible_tokens'][number]['name'];
545
+ declare function createAssetInfo<T extends AbiWithAssets>(contract: T, asset: AssetNames<T>): `${string}.${string}::${string}`;
546
+ type NftAssetType<T extends AbiWithAssets> = T['non_fungible_tokens'][0] extends {
547
+ type: infer Type;
548
+ } ? Type extends ClarityAbiType | ReadonlyTuple ? AbiTypeTo<Type> : never : never;
549
+ declare function makeNonFungiblePostCondition<T extends AbiWithAssets>(contract: T, sender: string, condition: 'sent' | 'not-sent', value: NftAssetType<T>): NonFungiblePostCondition;
550
+ declare function makeFungiblePostCondition<T extends AbiWithAssets>(contract: T, sender: string, condition: 'eq' | 'gt' | 'gte' | 'lt' | 'lte', amount: number | bigint | string): FungiblePostCondition;
551
+ //#endregion
552
+ //#region src/raw-clarity.d.ts
553
+ type RawClarityTypeTo<T extends ClarityAbiType, A$1 = any> = T extends ClarityAbiTypePrimitive ? AbiPrimitiveTo<T> : A$1;
554
+ type ResponseType<F$1 extends TypedAbiFunction<UnknownArgs, any>> = F$1 extends TypedAbiFunction<infer A, infer R> ? R : never;
555
+ declare function rawClarityToValue<T = any>(input: string, type: ClarityAbiType): T;
556
+ //#endregion
557
+ export { AbiPrimitiveTo, AbiTupleTo, AbiTypeTo, AllContracts, ApiOptions, ApiOptionsBase, ApiOptionsJsonize, ApiOptionsNetwork, ApiOptionsNoJson, ApiOptionsUrl, ArgsRecord, ArgsTuple, ArgsType, AssetNames, CVInput, ClarigenClient, type ClarityAbi, ClarityAbiArg, ClarityAbiFunction, ClarityAbiMap, ClarityAbiType, ClarityAbiTypeBool, ClarityAbiTypeBuffer, ClarityAbiTypeFungibleToken, ClarityAbiTypeInt128, ClarityAbiTypeList, ClarityAbiTypeNonFungibleToken, ClarityAbiTypeNone, ClarityAbiTypeOptional, ClarityAbiTypePrimitive, ClarityAbiTypePrincipal, ClarityAbiTypeResponse, ClarityAbiTypeStringAscii, ClarityAbiTypeStringUtf8, ClarityAbiTypeTraitReference, ClarityAbiTypeTuple, ClarityAbiTypeUInt128, ClarityAbiVariable, ClarityVersion, Contract, ContractBuilder, ContractCall, ContractCallFunction, ContractCallTyped, type ContractCalls, ContractDeployments, ContractFactory, type ContractFn, ContractFunctions, ContractInstance, ContractInstances, type ContractReturn, type ContractReturnErr, type ContractReturnOk, Contracts, ContractsToContractCalls, CoreNodeEvent, CoreNodeEventBase, CoreNodeEventType, DEPLOYMENT_NETWORKS, DeploymentNetwork, type DeploymentPlan, DeploymentsForContracts, ErrType, ErrorCodes, ExtractArgs, ExtractArgsRecord, FnToContractCall, FtBurnEvent, FtMintEvent, FtTransferEvent, FullContract, FullContractWithIdentifier, FunctionReturnType, FunctionsToContractCalls, JsonIfOption, Jsonize, Kebab, KebabObject, MAINNET_BURN_ADDRESS, MapFactory, Network, NftAssetType, NftBurnEvent, NftMintEvent, NftTransferEvent, NonStandardClarityValue, OkType, Project, ProjectErrors, ProjectFactory, RawClarityTypeTo, ReadonlyTuple, Response, ResponseErr, ResponseOk, ResponseType, ResultAssets, type SimnetDeploymentPlan, SmartContractEvent, StacksEpochId, StxBurnEvent, StxLockEvent, StxMintEvent, StxTransferEvent, TESTNET_BURN_ADDRESS, TupleInput, TypedAbi, TypedAbiArg, TypedAbiFunction, TypedAbiMap, TypedAbiVariable, UnionToIntersection, UnknownArg, UnknownArgs, bootContractIdentifier, broadcast, bytesToAscii, bytesToHex, contractFactory, contractsFactory, createAssetInfo, cvToJSON, cvToString, cvToValue, deploymentFactory, err, expectErr, expectOk, extractErrors, fetchMapGet, filterEvents, findJsTupleKey, functionsFactory, getApiUrl, getContractIdentifier, getContractName, getContractNameFromPath, getContractPrincipalCV, getTypeString, hexToBytes, hexToCvValue, isClarityAbiBuffer, isClarityAbiList, isClarityAbiOptional, isClarityAbiPrimitive, isClarityAbiResponse, isClarityAbiStringAscii, isClarityAbiStringUtf8, isClarityAbiTraitReference, isClarityAbiTuple, isNumber, isResponse, makeContracts, makeFungiblePostCondition, makeNonFungiblePostCondition, mapFactory, ok, parseToCV, principalToString, projectErrors, projectFactory, pureProxy, rawClarityToValue, ro, roErr, roOk, toCamelCase, toKebabCase, transformArgsArray, transformArgsToCV, transformObjectArgs };