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 3bddcc5 commit ec88d1d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/transactions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ 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.
*
* @example
* ```
* import { Pc } from '@stacks/transactions';
* Pc.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6').willSendEq(10000).ustx();
* ```
*/
export * as Pc from './pc';
export {
createFungiblePostCondition,
Expand Down
11 changes: 10 additions & 1 deletion packages/transactions/src/pc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type NftString = `${ContractIdString}::${string}`;
* @example
* ```
* import { Pc } from '@stacks/transactions';
* Pc.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6').willSendEq(100).stx();
* Pc.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6').willSendEq(10000).ustx();
* ```
*/
export function principal(principal: AddressString | ContractIdString) {
Expand All @@ -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 ec88d1d

Please sign in to comment.