Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
Releases prior to `2.0.0` were published before this changelog was added and
are not documented here.

## [2.1.0]

### Added

- `addLedgerEntries` posts a batch of Ledger Entries atomically.
- Strongly-typed batch payloads. Codegen now emits one payload per Ledger Entry
type into your generated client, derived from the per-entry-type
`addLedgerEntry` operations in the codegen input. Because a batch mutation
takes one list of one input type, GraphQL cannot type each entry's
`parameters` field individually; these payloads do. Pass them to
`addLedgerEntries` directly, mixed with raw `AddLedgerEntryInput` values.
Payload names always carry the entry type version, defaulting to `V1`.
- Ledger Line tags can now be updated using `updateLedgerEntry`.

## [2.0.0]

### Changed
Expand Down
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Read the [Using custom queries](#using-custom-queries) section to learn how to u

### Post a Ledger Entry

To [post](https://fragment.dev/docs#post-ledger-entries-post-to-the-api) a Ledger Entry defined in your schema:
To [post](https://fragment.dev/guides/post-ledger-entries#post-to-the-api) a Ledger Entry defined in your schema:

```typescript
await fragment.addLedgerEntry({
Expand All @@ -53,7 +53,7 @@ await fragment.addLedgerEntry({
});
```

To post a Ledger Entry with lines [defined at runtime](https://fragment.dev/docs#post-ledger-entries-runtime-entries):
To post a Ledger Entry with lines [defined at runtime](https://fragment.dev/guides/post-ledger-entries#runtime-entries):

```typescript
await fragment.addLedgerEntryRuntime({
Expand Down Expand Up @@ -127,9 +127,38 @@ await fragment.PostUserFundsAccount_v2({

Each version can have different parameters and line structures, and the generated methods will reflect those differences.

### Post a batch of Ledger Entries

To [post](https://fragment.dev/guides/post-ledger-entries#batch-ledger-entries) a batch of Ledger Entries atomically:

```typescript
import { userFundsAccountV1 } from './src/fragment-client.ts';

await fragment.addLedgerEntries({
entries: [
userFundsAccountV1({
ik: "some-ik-1",
ledgerIk: "your-ledger-ik",
posted: "1968-01-01T16:45:00Z",
user_id: "user-1",
funding_amount: "20000",
}),
userFundsAccountV1({
ik: "some-ik-2",
ledgerIk: "your-ledger-ik",
posted: "1968-01-01T16:45:00Z",
user_id: "user-2",
funding_amount: "20000",
}),
],
});
```

Construct the entries in the batch using the typed payloads generated for your Schema, named `<entryType>V<typeVersion>`. They are exported from your generated client alongside `getSdk`.

### Sync transactions

To sync transaction using a [Custom Link](https://fragment.dev/docs#reconcile-transactions-link-any-system):
To sync transaction using a [Custom Link](https://fragment.dev/guides/sync-payments#custom-link):

```typescript
import { CurrencyCode } from "@fragment-dev/node-client";
Expand Down Expand Up @@ -169,7 +198,7 @@ await fragment.syncCustomTxs({

### Reconcile a transaction

To [reconcile](https://fragment.dev/docs#reconcile-transactions) a transaction:
To [reconcile](https://fragment.dev/guides/reconcile-payments#reconcile-a-tx) a transaction:

```typescript
await fragment.reconcileTx({
Expand All @@ -186,7 +215,7 @@ await fragment.reconcileTx({
});
```

To reconcile a Ledger Entry with lines [defined at runtime](https://fragment.dev/docs#post-ledger-entries-runtime-entries):
To reconcile a Ledger Entry with lines [defined at runtime](https://fragment.dev/guides/post-ledger-entries#runtime-entries):

```typescript
await fragment.reconcileTxRuntime({
Expand Down Expand Up @@ -272,7 +301,7 @@ const result = await fragment.listLedgerAccounts({
assert(result.ledger?.ledgerAccounts?.nodes, "Failed to list ledger accounts");
```

To retrieve Ledger Accounts with [balances](https://fragment.dev/docs#read-balances):
To retrieve Ledger Accounts with [balances](https://fragment.dev/guides/read-balances):

```typescript
const result = await fragment.listLedgerAccountBalances({
Expand All @@ -282,7 +311,7 @@ const result = await fragment.listLedgerAccountBalances({
assert(result.ledger?.ledgerAccounts?.nodes, "Failed to list ledger accounts");
```

To retrieve [multi-currency](https://fragment.dev/docs#handle-currencies) Ledger Accounts with balances:
To retrieve [multi-currency](https://fragment.dev/guides/handle-currencies) Ledger Accounts with balances:

```typescript
const result = await fragment.listMultiCurrencyLedgerAccountBalances({
Expand Down
29 changes: 27 additions & 2 deletions dist/cjs/generated/generated.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion dist/cjs/src/typedBatchEntries.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions dist/cjs/types/generated/generated.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/types/generated/generated.d.ts.map

Large diffs are not rendered by default.

Loading
Loading