Skip to content

Commit

Permalink
docs: add pc builder tsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Jul 24, 2023
1 parent 3c819c2 commit 7cbb542
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/transactions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions packages/transactions/src/pc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down Expand Up @@ -192,6 +195,9 @@ class PartialPcWithPrincipal {
}
}

/**
* Not meant to be used directly. Start from `Pc.principal(…)` instead.
*/
class PartialPcFtWithCode {
constructor(
private address: string,
Expand Down Expand Up @@ -236,6 +242,9 @@ class PartialPcFtWithCode {
}
}

/**
* Not meant to be used directly. Start from `Pc.principal(…)` instead.
*/
class PartialPcNftWithCode {
constructor(
private principal: string,
Expand Down

0 comments on commit 7cbb542

Please sign in to comment.