Skip to content

Commit

Permalink
feat: add .tx* helpers to Chain
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Jul 21, 2022
1 parent b78a33d commit 4055962
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silly-lizards-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"clarigen-deno": patch
---

Adds `tx*` helpers to `Chain` for simpler DX
23 changes: 22 additions & 1 deletion src/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { cvToValue } from './encoder.ts';
import { Account, Accounts, contractsFactory, Simnet } from './factory.ts';
import { AllContracts, ContractCallTyped } from './factory-types.ts';
import { ExpectType, TxCall } from './tx.ts';
import { ExpectType, tx, TxCall, txErr, txOk } from './tx.ts';
import { ClarityAbiFunction, ErrType, OkType, Response } from './types.ts';

type Call<R> = ContractCallTyped<unknown, R>;
Expand Down Expand Up @@ -170,6 +170,27 @@ export class Chain {
return receipt;
}

tx<A, R>(
payload: ContractCallTyped<A, R>,
sender: string,
): Receipt<TxCall<R>> {
return this.mineOne(tx(payload, sender));
}

txOk<A, R>(
payload: ContractCallTyped<A, R>,
sender: string,
): Receipt<TxCall<R, true>> {
return this.mineOne(txOk(payload, sender));
}

txErr<A, R>(
payload: ContractCallTyped<A, R>,
sender: string,
): Receipt<TxCall<R, false>> {
return this.mineOne(txErr(payload, sender));
}

// sub-chain accessors

public get sessionId() {
Expand Down

0 comments on commit 4055962

Please sign in to comment.