mirror of
https://github.com/alexgo-io/clarity-codegen.git
synced 2026-01-12 14:34:34 +08:00
feat(composeTxOptionsFactory): auto narrow post condition type
This commit is contained in:
@@ -14,26 +14,25 @@ import type {
|
|||||||
ParameterObjOfDescriptor,
|
ParameterObjOfDescriptor,
|
||||||
} from "./contractBase";
|
} from "./contractBase";
|
||||||
|
|
||||||
type PostCondition =
|
type PostConditionPlain = FungiblePostCondition | StxPostCondition;
|
||||||
| FungiblePostCondition
|
type PostConditionWire = FungiblePostConditionWire | STXPostConditionWire;
|
||||||
| StxPostCondition
|
type PostCondition = PostConditionPlain | PostConditionWire;
|
||||||
| FungiblePostConditionWire
|
|
||||||
| STXPostConditionWire;
|
|
||||||
|
|
||||||
export interface ContractCallOptions {
|
export interface ContractCallOptions<PC extends PostCondition> {
|
||||||
contractAddress: string;
|
contractAddress: string;
|
||||||
contractName: string;
|
contractName: string;
|
||||||
functionName: string;
|
functionName: string;
|
||||||
functionArgs: ClarityValue[];
|
functionArgs: ClarityValue[];
|
||||||
anchorMode: AnchorMode;
|
anchorMode: AnchorMode;
|
||||||
postConditionMode: PostConditionMode;
|
postConditionMode: PostConditionMode;
|
||||||
postConditions?: PostCondition[];
|
postConditions?: PC[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ComposeTxOptionsFn<Contracts extends ContractBaseType> = <
|
export type ComposeTxOptionsFn<Contracts extends ContractBaseType> = <
|
||||||
T extends StringOnly<keyof Contracts>,
|
T extends StringOnly<keyof Contracts>,
|
||||||
F extends StringOnly<keyof Contracts[T]>,
|
F extends StringOnly<keyof Contracts[T]>,
|
||||||
Descriptor extends Contracts[T][F]
|
Descriptor extends Contracts[T][F],
|
||||||
|
PC extends PostCondition
|
||||||
>(
|
>(
|
||||||
contractName: T,
|
contractName: T,
|
||||||
functionName: F,
|
functionName: F,
|
||||||
@@ -42,9 +41,9 @@ export type ComposeTxOptionsFn<Contracts extends ContractBaseType> = <
|
|||||||
: never,
|
: never,
|
||||||
options?: {
|
options?: {
|
||||||
deployerAddress?: string;
|
deployerAddress?: string;
|
||||||
postConditions?: PostCondition[];
|
postConditions?: PC[];
|
||||||
}
|
}
|
||||||
) => ContractCallOptions;
|
) => ContractCallOptions<PC>;
|
||||||
|
|
||||||
export const composeTxOptionsFactory =
|
export const composeTxOptionsFactory =
|
||||||
<T extends ContractBaseType>(
|
<T extends ContractBaseType>(
|
||||||
|
|||||||
Reference in New Issue
Block a user