diff --git a/packages/transactions/src/index.ts b/packages/transactions/src/index.ts index c00333128..47d083a84 100644 --- a/packages/transactions/src/index.ts +++ b/packages/transactions/src/index.ts @@ -30,6 +30,30 @@ export { isTokenTransferPayload, serializePayload, } from './payload'; +/** + * ### `Pc.` Post Condition Builder + * @beta Interface may be subject to change in future releases. + * + * The Pc namespace is provided as a convenience to build post conditions. + * The pattern chains methods together to build a post condition. + * `PRINCIPAL -> [AMOUNT] -> CODE -> ASSET` + * + * The builder starts with the {@link Pc.principal} method. + * + * Some partial classes are used along the way, but aren't intended to be used directly. + * - {@link PartialPcWithPrincipal} + * - {@link PartialPcFtWithCode} + * - {@link PartialPcNftWithCode} + * + * @param {AddressString | ContractIdString} principal The principal to check, which should/should-not be sending assets. A string in the format "address" or "address.contractId". + * @returns A partial post condition builder, which can be chained into a final post condition. + * + * @example + * ``` + * import { Pc } from '@stacks/transactions'; + * Pc.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6').willSendEq(100).stx(); + * ``` + */ export * as Pc from './pc'; export { createFungiblePostCondition, diff --git a/packages/transactions/src/pc.ts b/packages/transactions/src/pc.ts index 8ed151e56..e3673a44e 100644 --- a/packages/transactions/src/pc.ts +++ b/packages/transactions/src/pc.ts @@ -55,6 +55,9 @@ export function principal(principal: AddressString | ContractIdString) { return new PartialPcWithPrincipal(principal, undefined); } +/** + * Not meant to be used directly. Start from `Pc.principal(…)` instead. + */ class PartialPcWithPrincipal { constructor(private address: string, private contractName?: string) {} @@ -192,6 +195,9 @@ class PartialPcWithPrincipal { } } +/** + * Not meant to be used directly. Start from `Pc.principal(…)` instead. + */ class PartialPcFtWithCode { constructor( private address: string, @@ -236,6 +242,9 @@ class PartialPcFtWithCode { } } +/** + * Not meant to be used directly. Start from `Pc.principal(…)` instead. + */ class PartialPcNftWithCode { constructor( private principal: string,