@ldgr/client 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -0
- package/dist/client.d.ts +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +24 -3
- package/dist/types.d.ts +111 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,6 +8,22 @@ It does not create a hosted wallet, persist a private key, or replace the
|
|
|
8
8
|
browser extension. Use `@ldgr/wallet-sdk` when a website needs an explicit
|
|
9
9
|
user confirmation in the LDGR extension.
|
|
10
10
|
|
|
11
|
+
## Contract reads
|
|
12
|
+
|
|
13
|
+
Version `0.6.1` publishes `getLedraContract`, `getMilestoneEscrow`,
|
|
14
|
+
`getAtomicOffer`, and `getClaimDistribution`, together with their typed mutation
|
|
15
|
+
methods. It requires `@ldgr/protocol@^0.5.1` for the corresponding payload types.
|
|
16
|
+
Version `0.6.0` does not include these methods. Upgrade the installed client and
|
|
17
|
+
restart consumers before using these contract APIs.
|
|
18
|
+
|
|
19
|
+
## Primary usernames
|
|
20
|
+
|
|
21
|
+
`client.usernames.findPrimary(address)` returns the primary username record or
|
|
22
|
+
`null` when the address has no active primary username. It uses the optional
|
|
23
|
+
lookup endpoint (`?optional=true`); lookup and transport failures still throw.
|
|
24
|
+
`client.usernames.getPrimary(address)` keeps the required lookup behavior and
|
|
25
|
+
throws on the endpoint's default 404 when no primary username exists.
|
|
26
|
+
|
|
11
27
|
## Service wallets and recovery keys
|
|
12
28
|
|
|
13
29
|
`generateLocalWallet()` creates caller-owned key material for a service wallet.
|
|
@@ -214,3 +230,67 @@ if (verification.status === "confirmed") {
|
|
|
214
230
|
requirements, and verifies the exact settled transfer through the
|
|
215
231
|
authoritative Worker. The merchant still owns challenge persistence and
|
|
216
232
|
idempotent fulfillment.
|
|
233
|
+
|
|
234
|
+
## Caller-signed atomic offers
|
|
235
|
+
|
|
236
|
+
`getAtomicOffer(contractId)` reads the authoritative fixed-counterparty offer.
|
|
237
|
+
`openAtomicOffer`, `acceptAtomicOffer`, `cancelAtomicOffer` and `refundAtomicOffer`
|
|
238
|
+
submit typed caller-signed envelopes and return canonical terms plus the committed
|
|
239
|
+
action's `transactionHash`. The four submission types are exported as
|
|
240
|
+
`AtomicOfferOpenSubmission`, `AtomicOfferAcceptSubmission`,
|
|
241
|
+
`AtomicOfferCancelSubmission` and `AtomicOfferRefundSubmission`.
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
const offer = await client.getAtomicOffer(contractId);
|
|
245
|
+
const receipt = await client.acceptAtomicOffer(callerSignedAcceptance);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Sign the protocol's canonical payload using bigint atomic amounts, then transport
|
|
249
|
+
each traded amount as an exact decimal string using that asset's registry
|
|
250
|
+
decimals. `maxFeeAtomic` is an atomic integer string; nonce, timestamp and expiry
|
|
251
|
+
are integer strings. Preserve exact asset codes, signature, fields and original
|
|
252
|
+
open payload hash. These methods forward the supplied envelope unchanged and do
|
|
253
|
+
not sign, resolve aliases, replace nonces or automatically retry. A timeout leaves
|
|
254
|
+
the submission status unknown: read the offer or retry the identical signed
|
|
255
|
+
submission. Exact committed retries return the original action hash, even if a
|
|
256
|
+
later action changed the offer's status.
|
|
257
|
+
|
|
258
|
+
This is the protocol/API/client foundation. First-party wallet provider methods,
|
|
259
|
+
confirmation screens, offer-detail pages and a Utilities builder are deferred.
|
|
260
|
+
|
|
261
|
+
## Caller-signed milestone escrow
|
|
262
|
+
|
|
263
|
+
`getMilestoneEscrow(contractId)` reads the canonical prepaid escrow.
|
|
264
|
+
`openMilestoneEscrow(signed)`, `releaseMilestoneEscrow(signed)` and
|
|
265
|
+
`refundMilestoneEscrow(signed)` submit typed caller-signed envelopes unchanged.
|
|
266
|
+
Opening `amount` and every `milestones[].amount` are exact decimal strings in
|
|
267
|
+
the escrow asset. Nonce, timestamp, expiry and native `maxFeeAtomic` are integer
|
|
268
|
+
strings; release `milestoneIndex` is a zero-based integer number. Every action
|
|
269
|
+
uses the actual escrow asset and its payer nonce lane.
|
|
270
|
+
|
|
271
|
+
Only the payer can release the next step before expiry or refund the residual
|
|
272
|
+
at or after expiry. Records include `releasedMilestones`, `releasedAmount`,
|
|
273
|
+
`remainingAmount` and `refundedAmount`; released payments remain final.
|
|
274
|
+
These methods never sign or rebuild submissions and never retry automatically.
|
|
275
|
+
After an ambiguous submission, reconcile canonical state and preserve the exact
|
|
276
|
+
signed envelope when retrying.
|
|
277
|
+
|
|
278
|
+
## Caller-signed claim distributions
|
|
279
|
+
|
|
280
|
+
`getClaimDistribution(contractId)` reads the canonical prepaid distribution.
|
|
281
|
+
`openClaimDistribution(signed)`, `claimClaimDistribution(signed)` and
|
|
282
|
+
`refundClaimDistribution(signed)` forward typed caller-signed envelopes unchanged.
|
|
283
|
+
Opening `amount` and `allocations[].amount` are exact asset decimal strings over
|
|
284
|
+
HTTP; sign their protocol equivalents as bigint atomic amounts. Nonce, timestamp,
|
|
285
|
+
expiry and opening `maxFeeAtomic` use integer strings. Every action uses the exact
|
|
286
|
+
distribution asset and the signing account's nonce lane.
|
|
287
|
+
|
|
288
|
+
Opening allocates the total to 1–64 unique recipients other than the funder.
|
|
289
|
+
Each recipient can claim its complete zero-based `claimIndex` once before expiry,
|
|
290
|
+
in any order. Claims and refunds require the original `openPayloadHash`; only the
|
|
291
|
+
funder can refund unclaimed funds at or after expiry. Opening pays a capped native
|
|
292
|
+
fee; settlement is fee-free and supports known inactive assets. Records expose
|
|
293
|
+
per-allocation `claimed` flags, `claimedAllocations`, `claimedAmount`,
|
|
294
|
+
`remainingAmount` and `refundedAmount`. Mutations return the committed
|
|
295
|
+
`transactionHash`. These methods never sign, replace nonces or automatically
|
|
296
|
+
retry: preserve the exact signed envelope after an unknown outcome.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type LdgrClientOptions } from "./types";
|
|
2
2
|
export type Transport = {
|
|
3
3
|
readonly get: <T>(path: string) => Promise<T>;
|
|
4
|
+
readonly getOptional: <T>(path: string) => Promise<T | null>;
|
|
4
5
|
readonly post: <T>(path: string, body: unknown) => Promise<T>;
|
|
5
6
|
};
|
|
6
7
|
export declare function createTransport(options: LdgrClientOptions): Transport;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import type { LedraContractDeploySubmission, LedraContractInvokeSubmission, LedraContractRefundSubmission } from "./types";
|
|
2
|
+
export type { LedraContractDeploySubmission, LedraContractInvokeSubmission, LedraContractRefundSubmission, LdgrLedraContract, LdgrLedraContractMutation } from "./types";
|
|
3
|
+
import type { ClaimDistributionOpenSubmission, ClaimDistributionClaimSubmission, ClaimDistributionRefundSubmission, LdgrClaimDistribution, LdgrClaimDistributionMutation } from "./types";
|
|
4
|
+
export type { ClaimDistributionOpenSubmission, ClaimDistributionClaimSubmission, ClaimDistributionRefundSubmission, LdgrClaimDistribution, LdgrClaimDistributionMutation } from "./types";
|
|
5
|
+
import type { MilestoneEscrowOpenSubmission, MilestoneEscrowReleaseSubmission, MilestoneEscrowRefundSubmission, LdgrMilestoneEscrow, LdgrMilestoneEscrowMutation } from "./types";
|
|
6
|
+
export type { MilestoneEscrowOpenSubmission, MilestoneEscrowReleaseSubmission, MilestoneEscrowRefundSubmission, LdgrMilestoneEscrow, LdgrMilestoneEscrowMutation } from "./types";
|
|
7
|
+
import type { AtomicOfferOpenSubmission, AtomicOfferAcceptSubmission, AtomicOfferCancelSubmission, AtomicOfferRefundSubmission, LdgrAtomicOffer, LdgrAtomicOfferMutation } from "./types";
|
|
8
|
+
export type { AtomicOfferOpenSubmission, AtomicOfferAcceptSubmission, AtomicOfferCancelSubmission, AtomicOfferRefundSubmission, LdgrAtomicOffer, LdgrAtomicOfferMutation } from "./types";
|
|
1
9
|
import { type LdgrTransferResult, type SendTransferInput } from "./transfer";
|
|
2
10
|
import { type Ldgr402Requirement } from "@ldgr/protocol";
|
|
3
11
|
import { type LdgrAccountTransactionPage, type LdgrClientOptions, type LdgrAsset, type Ldgr402Verification, type LdgrTransaction, type PaymentExpectation, type PaymentVerification, type CheckoutPaymentExpectation, type CheckoutPaymentVerification, type MerchantPaymentExpectation, type MerchantPaymentVerification, type PaymentSubmission, type SignedSubmission, type SilentPaymentSendInput, type SilentPaymentScanPage, type WalletPublicKeyRecord, type WalletPublicKeyRegistration } from "./types";
|
|
@@ -8,6 +16,23 @@ export declare function createLdgrClient(options: LdgrClientOptions): {
|
|
|
8
16
|
}>;
|
|
9
17
|
getProtocolConfig: () => Promise<Record<string, unknown>>;
|
|
10
18
|
};
|
|
19
|
+
getClaimDistribution: (contractId: string) => Promise<LdgrClaimDistribution>;
|
|
20
|
+
openClaimDistribution: (signed: ClaimDistributionOpenSubmission) => Promise<LdgrClaimDistributionMutation>;
|
|
21
|
+
claimClaimDistribution: (signed: ClaimDistributionClaimSubmission) => Promise<LdgrClaimDistributionMutation>;
|
|
22
|
+
refundClaimDistribution: (signed: ClaimDistributionRefundSubmission) => Promise<LdgrClaimDistributionMutation>;
|
|
23
|
+
getLedraContract: (id: string) => Promise<import("@ldgr/protocol").LedraContractRecord>;
|
|
24
|
+
deployLedraContract: (signed: LedraContractDeploySubmission) => Promise<import("@ldgr/protocol").LedraContractMutation>;
|
|
25
|
+
invokeLedraContract: (signed: LedraContractInvokeSubmission) => Promise<import("@ldgr/protocol").LedraContractMutation>;
|
|
26
|
+
refundLedraContract: (signed: LedraContractRefundSubmission) => Promise<import("@ldgr/protocol").LedraContractMutation>;
|
|
27
|
+
getMilestoneEscrow: (contractId: string) => Promise<LdgrMilestoneEscrow>;
|
|
28
|
+
openMilestoneEscrow: (signed: MilestoneEscrowOpenSubmission) => Promise<LdgrMilestoneEscrowMutation>;
|
|
29
|
+
releaseMilestoneEscrow: (signed: MilestoneEscrowReleaseSubmission) => Promise<LdgrMilestoneEscrowMutation>;
|
|
30
|
+
refundMilestoneEscrow: (signed: MilestoneEscrowRefundSubmission) => Promise<LdgrMilestoneEscrowMutation>;
|
|
31
|
+
getAtomicOffer: (contractId: string) => Promise<LdgrAtomicOffer>;
|
|
32
|
+
openAtomicOffer: (signed: AtomicOfferOpenSubmission) => Promise<LdgrAtomicOfferMutation>;
|
|
33
|
+
acceptAtomicOffer: (signed: AtomicOfferAcceptSubmission) => Promise<LdgrAtomicOfferMutation>;
|
|
34
|
+
cancelAtomicOffer: (signed: AtomicOfferCancelSubmission) => Promise<LdgrAtomicOfferMutation>;
|
|
35
|
+
refundAtomicOffer: (signed: AtomicOfferRefundSubmission) => Promise<LdgrAtomicOfferMutation>;
|
|
11
36
|
accounts: {
|
|
12
37
|
listBalances: (address: string) => Promise<{
|
|
13
38
|
readonly address: string;
|
|
@@ -68,6 +93,7 @@ export declare function createLdgrClient(options: LdgrClientOptions): {
|
|
|
68
93
|
usernames: {
|
|
69
94
|
get: (name: string) => Promise<Record<string, unknown>>;
|
|
70
95
|
getPrimary: (address: string) => Promise<Record<string, unknown>>;
|
|
96
|
+
findPrimary: (address: string) => Promise<Record<string, unknown> | null>;
|
|
71
97
|
listOwned: (address: string, options?: {
|
|
72
98
|
readonly cursor?: string;
|
|
73
99
|
readonly limit?: number;
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ function assertApiPath(path) {
|
|
|
41
41
|
throw new TypeError("path must be an /api/v1/ relative path");
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
async function parseJson(response) {
|
|
44
|
+
async function parseJson(response, allowNull = false) {
|
|
45
45
|
const body = await response.json().catch(() => {
|
|
46
46
|
return;
|
|
47
47
|
});
|
|
@@ -50,6 +50,8 @@ async function parseJson(response) {
|
|
|
50
50
|
const code = typeof body?.code === "string" ? body.code : undefined;
|
|
51
51
|
throw new LdgrClientError(response.status, message, code);
|
|
52
52
|
}
|
|
53
|
+
if (body === null && allowNull)
|
|
54
|
+
return body;
|
|
53
55
|
if (body === undefined || body === null || typeof body !== "object") {
|
|
54
56
|
throw new TypeError("LDGR response must be a JSON object");
|
|
55
57
|
}
|
|
@@ -60,12 +62,13 @@ function createTransport(options) {
|
|
|
60
62
|
const request = options.fetch ?? globalThis.fetch;
|
|
61
63
|
if (typeof request !== "function")
|
|
62
64
|
throw new TypeError("fetch is required");
|
|
63
|
-
const call = async (path, init) => {
|
|
65
|
+
const call = async (path, init, allowNull = false) => {
|
|
64
66
|
assertApiPath(path);
|
|
65
|
-
return parseJson(await request(`${apiBase}${path}`, init));
|
|
67
|
+
return parseJson(await request(`${apiBase}${path}`, init), allowNull);
|
|
66
68
|
};
|
|
67
69
|
return {
|
|
68
70
|
get: (path) => call(path),
|
|
71
|
+
getOptional: (path) => call(path, undefined, true),
|
|
69
72
|
post: (path, body) => call(path, {
|
|
70
73
|
method: "POST",
|
|
71
74
|
headers: { "content-type": "application/json" },
|
|
@@ -516,6 +519,23 @@ function createLdgrClient(options) {
|
|
|
516
519
|
get: () => transport.get("/api/v1/ledger"),
|
|
517
520
|
getProtocolConfig: () => transport.get("/api/v1/protocol/config")
|
|
518
521
|
},
|
|
522
|
+
getClaimDistribution: (contractId) => transport.get(`/api/v1/contracts/claim-distributions/${encodePathSegment(contractId)}`),
|
|
523
|
+
openClaimDistribution: (signed) => transport.post("/api/v1/contracts/claim-distributions", signed),
|
|
524
|
+
claimClaimDistribution: (signed) => transport.post(`/api/v1/contracts/claim-distributions/${encodePathSegment(signed.payload.contractId)}/claim`, signed),
|
|
525
|
+
refundClaimDistribution: (signed) => transport.post(`/api/v1/contracts/claim-distributions/${encodePathSegment(signed.payload.contractId)}/refund`, signed),
|
|
526
|
+
getLedraContract: (id) => transport.get(`/api/v1/contracts/programs/${encodePathSegment(id)}`),
|
|
527
|
+
deployLedraContract: (signed) => transport.post("/api/v1/contracts/programs", signed),
|
|
528
|
+
invokeLedraContract: (signed) => transport.post(`/api/v1/contracts/programs/${encodePathSegment(signed.payload.contractId)}/invoke`, signed),
|
|
529
|
+
refundLedraContract: (signed) => transport.post(`/api/v1/contracts/programs/${encodePathSegment(signed.payload.contractId)}/refund`, signed),
|
|
530
|
+
getMilestoneEscrow: (contractId) => transport.get(`/api/v1/contracts/milestone-escrows/${encodePathSegment(contractId)}`),
|
|
531
|
+
openMilestoneEscrow: (signed) => transport.post("/api/v1/contracts/milestone-escrows", signed),
|
|
532
|
+
releaseMilestoneEscrow: (signed) => transport.post(`/api/v1/contracts/milestone-escrows/${encodePathSegment(signed.payload.contractId)}/release`, signed),
|
|
533
|
+
refundMilestoneEscrow: (signed) => transport.post(`/api/v1/contracts/milestone-escrows/${encodePathSegment(signed.payload.contractId)}/refund`, signed),
|
|
534
|
+
getAtomicOffer: (contractId) => transport.get(`/api/v1/contracts/atomic-offers/${encodePathSegment(contractId)}`),
|
|
535
|
+
openAtomicOffer: (signed) => transport.post("/api/v1/contracts/atomic-offers", signed),
|
|
536
|
+
acceptAtomicOffer: (signed) => transport.post(`/api/v1/contracts/atomic-offers/${encodePathSegment(signed.payload.contractId)}/accept`, signed),
|
|
537
|
+
cancelAtomicOffer: (signed) => transport.post(`/api/v1/contracts/atomic-offers/${encodePathSegment(signed.payload.contractId)}/cancel`, signed),
|
|
538
|
+
refundAtomicOffer: (signed) => transport.post(`/api/v1/contracts/atomic-offers/${encodePathSegment(signed.payload.contractId)}/refund`, signed),
|
|
519
539
|
accounts: {
|
|
520
540
|
listBalances: (address) => transport.get(`/api/v1/balances/${encodePathSegment(address)}`),
|
|
521
541
|
getBalance: (address, asset) => transport.get(`/api/v1/balances/${encodePathSegment(address)}/${encodePathSegment(resolveAsset(asset))}`),
|
|
@@ -577,6 +597,7 @@ function createLdgrClient(options) {
|
|
|
577
597
|
usernames: {
|
|
578
598
|
get: (name) => transport.get(`/api/v1/usernames/${encodePathSegment(name)}`),
|
|
579
599
|
getPrimary: (address) => transport.get(`/api/v1/usernames/by-address/${encodePathSegment(address)}`),
|
|
600
|
+
findPrimary: (address) => transport.getOptional(`/api/v1/usernames/by-address/${encodePathSegment(address)}?optional=true`),
|
|
580
601
|
listOwned: (address, options) => transport.get(queryPath(`/api/v1/usernames/owned-by/${encodePathSegment(address)}`, options ?? {}))
|
|
581
602
|
},
|
|
582
603
|
payments: { verifyTransfer, verifyCheckout, verifyPayment, verifyLdgr402 },
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LedraContractDeployPayload, LedraContractInvokePayload, LedraContractRefundPayload, LedraContractRecord, LedraContractMutation } from '@ldgr/protocol';
|
|
2
|
+
import type { ClaimDistributionOpenPayload, ClaimDistributionClaimPayload, ClaimDistributionRefundPayload } from "@ldgr/protocol";
|
|
3
|
+
import type { MilestoneEscrowOpenPayload, MilestoneEscrowReleasePayload, MilestoneEscrowRefundPayload } from "@ldgr/protocol";
|
|
4
|
+
import type { AssetBridgePolicy, LdgrNetwork, AtomicOfferOpenPayload, AtomicOfferAcceptPayload, AtomicOfferCancelPayload, AtomicOfferRefundPayload } from "@ldgr/protocol";
|
|
2
5
|
import type { LocalLdgrWallet } from "./signer";
|
|
3
6
|
export type LedgerId = 0 | 1;
|
|
4
7
|
export type { LdgrNetwork } from "@ldgr/protocol";
|
|
@@ -104,6 +107,38 @@ export type SignedSubmission = {
|
|
|
104
107
|
readonly feeSponsor?: unknown;
|
|
105
108
|
readonly submittedAtMs?: number;
|
|
106
109
|
};
|
|
110
|
+
/** HTTP amounts are exact decimals; nonce/time/cap fields are integer strings. */
|
|
111
|
+
type AtomicOfferWire<T> = {
|
|
112
|
+
readonly [K in keyof T]: T[K] extends bigint ? string : T[K];
|
|
113
|
+
};
|
|
114
|
+
type AtomicOfferSubmission<T> = Omit<SignedSubmission, "payload" | "feeSponsor"> & {
|
|
115
|
+
readonly payload: AtomicOfferWire<T>;
|
|
116
|
+
};
|
|
117
|
+
export type AtomicOfferOpenSubmission = AtomicOfferSubmission<AtomicOfferOpenPayload>;
|
|
118
|
+
export type AtomicOfferAcceptSubmission = AtomicOfferSubmission<AtomicOfferAcceptPayload>;
|
|
119
|
+
export type AtomicOfferCancelSubmission = AtomicOfferSubmission<AtomicOfferCancelPayload>;
|
|
120
|
+
export type AtomicOfferRefundSubmission = AtomicOfferSubmission<AtomicOfferRefundPayload>;
|
|
121
|
+
export type LdgrAtomicOffer = {
|
|
122
|
+
readonly contractId: string;
|
|
123
|
+
readonly template: "atomic_offer_v1";
|
|
124
|
+
readonly maker: string;
|
|
125
|
+
readonly taker: string;
|
|
126
|
+
readonly offeredAsset: string;
|
|
127
|
+
readonly offeredAmount: string;
|
|
128
|
+
readonly requestedAsset: string;
|
|
129
|
+
readonly requestedAmount: string;
|
|
130
|
+
readonly expiresAt: string;
|
|
131
|
+
readonly status: "open" | "accepted" | "cancelled" | "refunded";
|
|
132
|
+
readonly expired: boolean;
|
|
133
|
+
readonly openPayloadHash: string;
|
|
134
|
+
readonly reference?: string;
|
|
135
|
+
readonly createdTransactionHash: string;
|
|
136
|
+
readonly latestTransactionHash: string;
|
|
137
|
+
readonly terminalTransactionHash?: string;
|
|
138
|
+
};
|
|
139
|
+
export type LdgrAtomicOfferMutation = LdgrAtomicOffer & {
|
|
140
|
+
readonly transactionHash: string;
|
|
141
|
+
};
|
|
107
142
|
export type WalletPublicKeyRegistration = {
|
|
108
143
|
readonly version: 1;
|
|
109
144
|
readonly action: "wallet_key_register";
|
|
@@ -161,7 +196,8 @@ export type LdgrClientOptions = {
|
|
|
161
196
|
readonly network?: LdgrNetwork;
|
|
162
197
|
/** Defaults to the canonical public origin when `network` is supplied. */
|
|
163
198
|
readonly apiBase?: string;
|
|
164
|
-
|
|
199
|
+
/** A Fetch-compatible function; runtime-specific helper properties are not required. */
|
|
200
|
+
readonly fetch?: (...args: Parameters<typeof globalThis.fetch>) => ReturnType<typeof globalThis.fetch>;
|
|
165
201
|
};
|
|
166
202
|
export type LdgrClientErrorBody = {
|
|
167
203
|
readonly error?: unknown;
|
|
@@ -172,3 +208,76 @@ export declare class LdgrClientError extends Error {
|
|
|
172
208
|
readonly code: string | undefined;
|
|
173
209
|
constructor(status: number, message: string, code: string | undefined);
|
|
174
210
|
}
|
|
211
|
+
/** Atomic payload amounts become exact asset decimals over HTTP, including nested steps. */
|
|
212
|
+
type ContractSignedWire<T> = T extends bigint ? string : T extends readonly (infer U)[] ? readonly ContractSignedWire<U>[] : T extends object ? {
|
|
213
|
+
readonly [K in keyof T]: ContractSignedWire<T[K]>;
|
|
214
|
+
} : T;
|
|
215
|
+
type ContractSignedSubmission<T> = Omit<SignedSubmission, "payload" | "feeSponsor"> & {
|
|
216
|
+
readonly payload: ContractSignedWire<T>;
|
|
217
|
+
};
|
|
218
|
+
export type MilestoneEscrowOpenSubmission = ContractSignedSubmission<MilestoneEscrowOpenPayload>;
|
|
219
|
+
export type MilestoneEscrowReleaseSubmission = ContractSignedSubmission<MilestoneEscrowReleasePayload>;
|
|
220
|
+
export type MilestoneEscrowRefundSubmission = ContractSignedSubmission<MilestoneEscrowRefundPayload>;
|
|
221
|
+
export type LdgrMilestoneEscrow = {
|
|
222
|
+
readonly contractId: string;
|
|
223
|
+
readonly template: "milestone_escrow_v1";
|
|
224
|
+
readonly payer: string;
|
|
225
|
+
readonly beneficiary: string;
|
|
226
|
+
readonly asset: string;
|
|
227
|
+
readonly amount: string;
|
|
228
|
+
readonly milestones: readonly {
|
|
229
|
+
readonly label: string;
|
|
230
|
+
readonly amount: string;
|
|
231
|
+
}[];
|
|
232
|
+
readonly releasedMilestones: number;
|
|
233
|
+
readonly releasedAmount: string;
|
|
234
|
+
readonly remainingAmount: string;
|
|
235
|
+
readonly refundedAmount: string;
|
|
236
|
+
readonly expiresAt: string;
|
|
237
|
+
readonly expired: boolean;
|
|
238
|
+
readonly status: "open" | "completed" | "refunded";
|
|
239
|
+
readonly openPayloadHash: string;
|
|
240
|
+
readonly reference?: string;
|
|
241
|
+
readonly createdTransactionHash: string;
|
|
242
|
+
readonly latestTransactionHash: string;
|
|
243
|
+
readonly terminalTransactionHash?: string;
|
|
244
|
+
};
|
|
245
|
+
export type LdgrMilestoneEscrowMutation = LdgrMilestoneEscrow & {
|
|
246
|
+
readonly transactionHash: string;
|
|
247
|
+
};
|
|
248
|
+
/** Atomic payload amounts become exact asset decimals over HTTP, including nested steps. */
|
|
249
|
+
export type ClaimDistributionOpenSubmission = ContractSignedSubmission<ClaimDistributionOpenPayload>;
|
|
250
|
+
export type ClaimDistributionClaimSubmission = ContractSignedSubmission<ClaimDistributionClaimPayload>;
|
|
251
|
+
export type ClaimDistributionRefundSubmission = ContractSignedSubmission<ClaimDistributionRefundPayload>;
|
|
252
|
+
export type LdgrClaimDistribution = {
|
|
253
|
+
readonly contractId: string;
|
|
254
|
+
readonly template: "claim_distribution_v1";
|
|
255
|
+
readonly funder: string;
|
|
256
|
+
readonly asset: string;
|
|
257
|
+
readonly amount: string;
|
|
258
|
+
readonly allocations: readonly {
|
|
259
|
+
readonly to: string;
|
|
260
|
+
readonly amount: string;
|
|
261
|
+
readonly claimed: boolean;
|
|
262
|
+
}[];
|
|
263
|
+
readonly claimedAllocations: number;
|
|
264
|
+
readonly claimedAmount: string;
|
|
265
|
+
readonly remainingAmount: string;
|
|
266
|
+
readonly refundedAmount: string;
|
|
267
|
+
readonly expiresAt: string;
|
|
268
|
+
readonly expired: boolean;
|
|
269
|
+
readonly status: "open" | "completed" | "refunded";
|
|
270
|
+
readonly openPayloadHash: string;
|
|
271
|
+
readonly reference?: string;
|
|
272
|
+
readonly createdTransactionHash: string;
|
|
273
|
+
readonly latestTransactionHash: string;
|
|
274
|
+
readonly terminalTransactionHash?: string;
|
|
275
|
+
};
|
|
276
|
+
export type LdgrClaimDistributionMutation = LdgrClaimDistribution & {
|
|
277
|
+
readonly transactionHash: string;
|
|
278
|
+
};
|
|
279
|
+
export type LedraContractDeploySubmission = ContractSignedSubmission<LedraContractDeployPayload>;
|
|
280
|
+
export type LedraContractInvokeSubmission = ContractSignedSubmission<LedraContractInvokePayload>;
|
|
281
|
+
export type LedraContractRefundSubmission = ContractSignedSubmission<LedraContractRefundPayload>;
|
|
282
|
+
export type LdgrLedraContract = LedraContractRecord;
|
|
283
|
+
export type LdgrLedraContractMutation = LedraContractMutation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldgr/client",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"files": ["dist", "README.md"],
|
|
13
13
|
"publishConfig": { "access": "public" },
|
|
14
14
|
"engines": { "node": ">=20.19.0" },
|
|
15
|
-
"dependencies": { "@ldgr/protocol": "^0.5.
|
|
15
|
+
"dependencies": { "@ldgr/protocol": "^0.5.1" },
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "rm -rf dist && bun build src/index.ts --outdir dist --target node --format esm --packages external &&
|
|
17
|
+
"build": "rm -rf dist && bun build src/index.ts --outdir dist --target node --format esm --packages external && tsrs -p tsconfig.build.json",
|
|
18
18
|
"prepack": "bun run build",
|
|
19
19
|
"test": "bun test",
|
|
20
|
-
"typecheck": "
|
|
20
|
+
"typecheck": "tsrs --noEmit -p tsconfig.json && tsrs --noEmit -p test/tsconfig.json"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"
|
|
23
|
+
"tsrs": "0.20.0-ts7.1.0-beta"
|
|
24
24
|
}
|
|
25
25
|
}
|