@intent-engine/client 0.1.23 → 0.1.26

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.
Files changed (72) hide show
  1. package/dist/src/budget.d.ts +6 -4
  2. package/dist/src/budget.js +24 -9
  3. package/dist/src/budget.js.map +1 -1
  4. package/dist/src/client-errors.d.ts +28 -0
  5. package/dist/src/client-errors.js +55 -0
  6. package/dist/src/client-errors.js.map +1 -0
  7. package/dist/src/client-intents.d.ts +12 -0
  8. package/dist/src/client-intents.js +133 -0
  9. package/dist/src/client-intents.js.map +1 -0
  10. package/dist/src/client-reads.d.ts +7 -0
  11. package/dist/src/client-reads.js +61 -0
  12. package/dist/src/client-reads.js.map +1 -0
  13. package/dist/src/client-settle.d.ts +2 -0
  14. package/dist/src/client-settle.js +84 -0
  15. package/dist/src/client-settle.js.map +1 -0
  16. package/dist/src/client-types.d.ts +145 -0
  17. package/dist/src/client-types.js +9 -0
  18. package/dist/src/client-types.js.map +1 -0
  19. package/dist/src/client-watch.d.ts +4 -0
  20. package/dist/src/client-watch.js +97 -0
  21. package/dist/src/client-watch.js.map +1 -0
  22. package/dist/src/client.d.ts +4 -140
  23. package/dist/src/client.js +16 -309
  24. package/dist/src/client.js.map +1 -1
  25. package/dist/src/confirmation.d.ts +11 -0
  26. package/dist/src/confirmation.js +94 -0
  27. package/dist/src/confirmation.js.map +1 -0
  28. package/dist/src/intent-notifications.d.ts +13 -0
  29. package/dist/src/intent-notifications.js +106 -0
  30. package/dist/src/intent-notifications.js.map +1 -0
  31. package/dist/src/job-deliveries.d.ts +40 -0
  32. package/dist/src/job-deliveries.js +92 -0
  33. package/dist/src/job-deliveries.js.map +1 -0
  34. package/dist/src/job-memos.d.ts +16 -0
  35. package/dist/src/job-memos.js +51 -0
  36. package/dist/src/job-memos.js.map +1 -0
  37. package/dist/src/job-origins.d.ts +30 -0
  38. package/dist/src/job-origins.js +53 -0
  39. package/dist/src/job-origins.js.map +1 -0
  40. package/dist/src/job-proofs.d.ts +17 -0
  41. package/dist/src/job-proofs.js +54 -0
  42. package/dist/src/job-proofs.js.map +1 -0
  43. package/dist/src/job-scan.d.ts +20 -0
  44. package/dist/src/job-scan.js +70 -0
  45. package/dist/src/job-scan.js.map +1 -0
  46. package/dist/src/job-specs.d.ts +40 -0
  47. package/dist/src/job-specs.js +107 -0
  48. package/dist/src/job-specs.js.map +1 -0
  49. package/dist/src/jobs.d.ts +6 -77
  50. package/dist/src/jobs.js +6 -186
  51. package/dist/src/jobs.js.map +1 -1
  52. package/dist/src/memoized-transport.d.ts +4 -0
  53. package/dist/src/memoized-transport.js +66 -0
  54. package/dist/src/memoized-transport.js.map +1 -0
  55. package/dist/src/rpc-retry.d.ts +16 -0
  56. package/dist/src/rpc-retry.js +62 -0
  57. package/dist/src/rpc-retry.js.map +1 -0
  58. package/dist/src/rpc-shapes.d.ts +230 -0
  59. package/dist/src/rpc-shapes.js +2 -0
  60. package/dist/src/rpc-shapes.js.map +1 -0
  61. package/dist/src/rpc-transport.d.ts +6 -0
  62. package/dist/src/rpc-transport.js +236 -0
  63. package/dist/src/rpc-transport.js.map +1 -0
  64. package/dist/src/svm.js +83 -27
  65. package/dist/src/svm.js.map +1 -1
  66. package/dist/src/transaction-keys.d.ts +6 -0
  67. package/dist/src/transaction-keys.js +19 -0
  68. package/dist/src/transaction-keys.js.map +1 -0
  69. package/dist/src/transport.d.ts +7 -223
  70. package/dist/src/transport.js +6 -467
  71. package/dist/src/transport.js.map +1 -1
  72. package/package.json +16 -5
@@ -0,0 +1,145 @@
1
+ import type { Address, Instruction, KeyPairSigner, Signature, TransactionSigner } from "@solana/kit";
2
+ import type { Config, EngineEvent, Intent, IntentParams } from "@intent-engine/core";
3
+ import type { Priority } from "./budget.js";
4
+ import type { EngineError } from "./errors.js";
5
+ import type { DeliverInput, Delivery, DeliveryRecord, Job, Spec, SpecFetch } from "./jobs.js";
6
+ import type { Notifications, Simulation, Transport } from "./transport.js";
7
+ export type ClientOptions = {
8
+ url: string;
9
+ transport?: Transport;
10
+ notifications?: Notifications;
11
+ priority?: Priority;
12
+ pollMs?: number;
13
+ resyncSeconds?: number;
14
+ fetch?: SpecFetch;
15
+ };
16
+ export type IntentAccount = {
17
+ address: Address;
18
+ intent: Intent;
19
+ };
20
+ export type IntentFilter = {
21
+ owner?: Address;
22
+ status?: number;
23
+ };
24
+ export type WatchCallback = (changed: IntentAccount[], closed: IntentAccount[]) => void;
25
+ export type WatchOptions = {
26
+ owner?: Address;
27
+ onError?: (error: unknown) => void;
28
+ };
29
+ export type Mint = {
30
+ decimals: number;
31
+ tokenProgram: Address;
32
+ };
33
+ export type CreateIntentInput = {
34
+ signer: TransactionSigner;
35
+ params: IntentParams;
36
+ inputMint: Address;
37
+ outputMint: Address;
38
+ expiresIn?: bigint;
39
+ expiresAt?: bigint;
40
+ nonce?: bigint;
41
+ receiver?: Address;
42
+ specUrl?: string;
43
+ };
44
+ export type CreatedIntent = {
45
+ signature: Signature;
46
+ intent: Address;
47
+ nonce: bigint;
48
+ };
49
+ export type SettleProofInput = {
50
+ judge: KeyPairSigner;
51
+ owner: Address;
52
+ nonce: bigint;
53
+ payTo: Address;
54
+ result: bigint;
55
+ payer?: TransactionSigner;
56
+ deliveredSha256?: string;
57
+ };
58
+ export type HistoryEvent = EngineEvent & {
59
+ signature: Signature;
60
+ slot: bigint;
61
+ blockTime: bigint | null;
62
+ deliveredSha256?: string;
63
+ };
64
+ export type FillInput = {
65
+ solver: TransactionSigner;
66
+ owner: Address;
67
+ nonce: bigint;
68
+ amountIn?: bigint;
69
+ amountOut?: bigint;
70
+ route?: readonly Instruction[];
71
+ };
72
+ export type Fill = {
73
+ steps: 1 | 2;
74
+ solver: Address;
75
+ delivered: bigint;
76
+ required: bigint;
77
+ fee: bigint;
78
+ net: bigint;
79
+ signature: Signature;
80
+ slot: bigint;
81
+ blockTime: bigint | null;
82
+ };
83
+ export type TokenBalance = {
84
+ mint: Address;
85
+ name: string | undefined;
86
+ account: Address;
87
+ amount: bigint;
88
+ decimals: number;
89
+ };
90
+ export type Balances = {
91
+ sol: bigint;
92
+ tokens: TokenBalance[];
93
+ };
94
+ export type Client = {
95
+ readonly url: string;
96
+ readonly transport: Transport;
97
+ config(): Promise<Config>;
98
+ intent(owner: Address, nonce: bigint): Promise<IntentAccount | null>;
99
+ intents(filter?: IntentFilter): Promise<IntentAccount[]>;
100
+ history(intent: Address, limit?: number): Promise<HistoryEvent[]>;
101
+ nextNonce(owner: Address): Promise<bigint>;
102
+ simulate(instructions: readonly Instruction[], signer: TransactionSigner): Promise<Simulation>;
103
+ send(instructions: readonly Instruction[], signer: TransactionSigner): Promise<Signature>;
104
+ watch(onChange: WatchCallback, signal: AbortSignal, filter?: WatchOptions): Promise<void>;
105
+ explain(error: unknown): EngineError | null;
106
+ mint(address: Address): Promise<Mint>;
107
+ chainTime(): Promise<bigint>;
108
+ createIntent(input: CreateIntentInput): Promise<CreatedIntent>;
109
+ cancel(signer: TransactionSigner, nonce: bigint): Promise<Signature>;
110
+ unwrap(signer: TransactionSigner): Promise<Signature | null>;
111
+ settleProof(input: SettleProofInput): Promise<Signature>;
112
+ fill(input: FillInput): Promise<Signature>;
113
+ fillOf(intent: Address): Promise<Fill | null>;
114
+ expire(cranker: TransactionSigner, owner: Address, nonce: bigint): Promise<Signature>;
115
+ close(cranker: TransactionSigner, owner: Address, nonce: bigint): Promise<Signature>;
116
+ balances(owner: Address, mints: readonly Address[]): Promise<Balances>;
117
+ jobs(filter?: {
118
+ attestor?: Address;
119
+ }): Promise<Job[]>;
120
+ spec(intent: Address): Promise<Spec | null>;
121
+ deliver(input: DeliverInput): Promise<Signature>;
122
+ deliveries(filter: {
123
+ judge: Address;
124
+ intent?: Address;
125
+ }): Promise<Delivery[]>;
126
+ deliveryRecord(filter: {
127
+ judge: Address;
128
+ intent?: Address;
129
+ pages?: number;
130
+ }): Promise<DeliveryRecord>;
131
+ };
132
+ export declare const SPEC_URL_NEEDS_PROOF = "specUrl needs an AttestedResult intent with a non-zero specHash";
133
+ export declare const DEFAULT_EXPIRES_IN = 3600n;
134
+ export declare const MIN_EXPIRES_IN = 60n;
135
+ export declare const MAX_EXPIRES_IN = 31536000n;
136
+ export declare const EXPIRES_IN_RANGE: string;
137
+ export declare const HISTORY_LIMIT = 100;
138
+ export declare const WATCH_POLL_MS = 2000;
139
+ export declare const WATCH_WAIT_SECONDS = 10;
140
+ export type ClientContext = {
141
+ transport: Transport;
142
+ send(instructions: readonly Instruction[], signer: TransactionSigner): Promise<Signature>;
143
+ mint(address: Address): Promise<Mint>;
144
+ config(): Promise<Config>;
145
+ };
@@ -0,0 +1,9 @@
1
+ export const SPEC_URL_NEEDS_PROOF = "specUrl needs an AttestedResult intent with a non-zero specHash";
2
+ export const DEFAULT_EXPIRES_IN = 3600n;
3
+ export const MIN_EXPIRES_IN = 60n;
4
+ export const MAX_EXPIRES_IN = 31536000n;
5
+ export const EXPIRES_IN_RANGE = `expiresIn must be from ${MIN_EXPIRES_IN} to ${MAX_EXPIRES_IN} seconds`;
6
+ export const HISTORY_LIMIT = 100;
7
+ export const WATCH_POLL_MS = 2_000;
8
+ export const WATCH_WAIT_SECONDS = 10;
9
+ //# sourceMappingURL=client-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-types.js","sourceRoot":"","sources":["../../src/client-types.ts"],"names":[],"mappings":"AA4GA,MAAM,CAAC,MAAM,oBAAoB,GAAG,iEAAiE,CAAC;AAEtG,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAM,CAAC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAClC,MAAM,CAAC,MAAM,cAAc,GAAG,SAAW,CAAC;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,cAAc,OAAO,cAAc,UAAU,CAAC;AACxG,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IntentAccount, WatchCallback, WatchOptions } from "./client-types.js";
2
+ import { type Notifications, type ProgramAccount, type Transport } from "./transport.js";
3
+ export declare const decoded: ({ address, data }: ProgramAccount) => IntentAccount;
4
+ export declare function watchIntents(transport: Transport, notifications: Notifications | undefined, pollMs: number, resyncSeconds: number): (onChange: WatchCallback, signal: AbortSignal, filter?: WatchOptions) => Promise<void>;
@@ -0,0 +1,97 @@
1
+ import { getIntentDecoder } from "@intent-engine/core";
2
+ import { changesFrom, pause } from "./transport.js";
3
+ export const decoded = ({ address, data }) => ({ address, intent: getIntentDecoder().decode(data) });
4
+ export function watchIntents(transport, notifications, pollMs, resyncSeconds) {
5
+ const watch = async (onChange, signal, filter = {}) => {
6
+ if (signal.aborted) {
7
+ return;
8
+ }
9
+ const seen = new Map();
10
+ const fresh = (accounts) => accounts.flatMap((account) => {
11
+ const view = decoded(account);
12
+ if (filter.owner !== undefined && view.intent.owner !== filter.owner) {
13
+ return [];
14
+ }
15
+ const key = Buffer.from(account.data).toString("base64");
16
+ if (seen.get(account.address)?.key === key) {
17
+ return [];
18
+ }
19
+ seen.set(account.address, { key, view });
20
+ return [view];
21
+ });
22
+ let read = false;
23
+ const report = (changed, closed, first = false) => {
24
+ if ((changed.length > 0 || closed.length > 0 || first) && !signal.aborted) {
25
+ onChange(changed, closed);
26
+ }
27
+ };
28
+ let highest;
29
+ const raise = (slot) => {
30
+ if (slot !== undefined && (highest === undefined || slot > highest)) {
31
+ highest = slot;
32
+ }
33
+ };
34
+ const failed = (error) => {
35
+ if (!signal.aborted) {
36
+ filter.onError?.(error);
37
+ }
38
+ };
39
+ const sync = async (heard) => {
40
+ raise(heard);
41
+ const floor = highest;
42
+ const reading = {
43
+ ...(floor === undefined ? {} : { minContextSlot: floor }),
44
+ onSlot: (slot) => {
45
+ reading.at = slot;
46
+ },
47
+ };
48
+ const accounts = await transport.intents(filter.owner, reading).catch((error) => {
49
+ failed(error);
50
+ return null;
51
+ });
52
+ if (accounts === null) {
53
+ return;
54
+ }
55
+ if (reading.at !== undefined && floor !== undefined && reading.at < floor) {
56
+ failed(new Error(`the intents read at slot ${reading.at} is older than slot ${floor}, which the watch has already seen`));
57
+ return;
58
+ }
59
+ raise(reading.at);
60
+ const present = new Set(accounts.map(({ address }) => address));
61
+ const changed = fresh(accounts);
62
+ const closed = [...seen].filter(([address]) => !present.has(address)).map(([, { view }]) => view);
63
+ for (const { address } of closed) {
64
+ seen.delete(address);
65
+ }
66
+ report(changed, closed, !read);
67
+ read = true;
68
+ };
69
+ if (notifications === undefined) {
70
+ while (!signal.aborted) {
71
+ await sync();
72
+ await pause(pollMs, signal);
73
+ }
74
+ return;
75
+ }
76
+ const changes = changesFrom(notifications);
77
+ const stop = () => changes.close();
78
+ signal.addEventListener("abort", stop, { once: true });
79
+ try {
80
+ await sync();
81
+ let synced = Date.now();
82
+ while (!signal.aborted) {
83
+ report(fresh((await changes.wait(resyncSeconds)) ?? []), []);
84
+ if (!signal.aborted && Date.now() - synced >= resyncSeconds * 1000) {
85
+ await sync(changes.slot?.());
86
+ synced = Date.now();
87
+ }
88
+ }
89
+ }
90
+ finally {
91
+ signal.removeEventListener("abort", stop);
92
+ changes.close();
93
+ }
94
+ };
95
+ return watch;
96
+ }
97
+ //# sourceMappingURL=client-watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-watch.js","sourceRoot":"","sources":["../../src/client-watch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAsB,KAAK,EAAuC,MAAM,gBAAgB,CAAC;AAE7G,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAkB,EAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,MAAM,CAAC,IAAI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G,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC;YACH,MAAM,IAAI,EAAE,CAAC;YACb,IAAI,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACxB,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACvB,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC7D,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,IAAI,aAAa,GAAG,IAAI,EAAE,CAAC;oBACnE,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBAC7B,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,141 +1,5 @@
1
- import { type Address, type Instruction, type KeyPairSigner, type Signature, type TransactionSigner } from "@solana/kit";
2
- import { type Config, type EngineEvent, type Intent, type IntentParams } from "@intent-engine/core";
3
- import { type Priority } from "./budget.js";
4
- import { type EngineError } from "./errors.js";
5
- import { type DeliverInput, type Delivery, type Job, type Spec, type SpecFetch } from "./jobs.js";
6
- import { type Notifications, type Simulation, type Transport } from "./transport.js";
7
- export type ClientOptions = {
8
- url: string;
9
- transport?: Transport;
10
- notifications?: Notifications;
11
- priority?: Priority;
12
- pollMs?: number;
13
- resyncSeconds?: number;
14
- fetch?: SpecFetch;
15
- };
16
- export type IntentAccount = {
17
- address: Address;
18
- intent: Intent;
19
- };
20
- export type IntentFilter = {
21
- owner?: Address;
22
- status?: number;
23
- };
24
- export type WatchCallback = (changed: IntentAccount[], closed: IntentAccount[]) => void;
25
- export type Mint = {
26
- decimals: number;
27
- tokenProgram: Address;
28
- };
29
- export type CreateIntentInput = {
30
- signer: TransactionSigner;
31
- params: IntentParams;
32
- inputMint: Address;
33
- outputMint: Address;
34
- expiresIn?: bigint;
35
- expiresAt?: bigint;
36
- nonce?: bigint;
37
- receiver?: Address;
38
- specUrl?: string;
39
- };
40
- export type CreatedIntent = {
41
- signature: Signature;
42
- intent: Address;
43
- nonce: bigint;
44
- };
45
- export type SettleProofInput = {
46
- judge: KeyPairSigner;
47
- owner: Address;
48
- nonce: bigint;
49
- payTo: Address;
50
- result: bigint;
51
- payer?: TransactionSigner;
52
- deliveredSha256?: string;
53
- };
54
- export type HistoryEvent = EngineEvent & {
55
- signature: Signature;
56
- slot: bigint;
57
- blockTime: bigint | null;
58
- };
59
- export type FillInput = {
60
- solver: TransactionSigner;
61
- owner: Address;
62
- nonce: bigint;
63
- amountIn?: bigint;
64
- amountOut?: bigint;
65
- route?: readonly Instruction[];
66
- };
67
- export type Fill = {
68
- steps: 1 | 2;
69
- solver: Address;
70
- delivered: bigint;
71
- required: bigint;
72
- fee: bigint;
73
- net: bigint;
74
- signature: Signature;
75
- slot: bigint;
76
- blockTime: bigint | null;
77
- };
78
- export type TokenBalance = {
79
- mint: Address;
80
- name: string | undefined;
81
- account: Address;
82
- amount: bigint;
83
- decimals: number;
84
- };
85
- export type Balances = {
86
- sol: bigint;
87
- tokens: TokenBalance[];
88
- };
89
- export type Client = {
90
- readonly url: string;
91
- readonly transport: Transport;
92
- config(): Promise<Config>;
93
- intent(owner: Address, nonce: bigint): Promise<IntentAccount | null>;
94
- intents(filter?: IntentFilter): Promise<IntentAccount[]>;
95
- history(intent: Address, limit?: number): Promise<HistoryEvent[]>;
96
- nextNonce(owner: Address): Promise<bigint>;
97
- simulate(instructions: readonly Instruction[], signer: TransactionSigner): Promise<Simulation>;
98
- send(instructions: readonly Instruction[], signer: TransactionSigner): Promise<Signature>;
99
- watch(onChange: WatchCallback, signal: AbortSignal, filter?: {
100
- owner?: Address;
101
- }): Promise<void>;
102
- explain(error: unknown): EngineError | null;
103
- mint(address: Address): Promise<Mint>;
104
- chainTime(): Promise<bigint>;
105
- createIntent(input: CreateIntentInput): Promise<CreatedIntent>;
106
- cancel(signer: TransactionSigner, nonce: bigint): Promise<Signature>;
107
- unwrap(signer: TransactionSigner): Promise<Signature | null>;
108
- settleProof(input: SettleProofInput): Promise<Signature>;
109
- fill(input: FillInput): Promise<Signature>;
110
- fillOf(intent: Address): Promise<Fill | null>;
111
- expire(cranker: TransactionSigner, owner: Address, nonce: bigint): Promise<Signature>;
112
- close(cranker: TransactionSigner, owner: Address, nonce: bigint): Promise<Signature>;
113
- balances(owner: Address, mints: readonly Address[]): Promise<Balances>;
114
- jobs(filter?: {
115
- attestor?: Address;
116
- }): Promise<Job[]>;
117
- spec(intent: Address): Promise<Spec | null>;
118
- deliver(input: DeliverInput): Promise<Signature>;
119
- deliveries(filter: {
120
- judge: Address;
121
- intent?: Address;
122
- }): Promise<Delivery[]>;
123
- };
124
- export declare const SPEC_URL_NEEDS_PROOF = "specUrl needs an AttestedResult intent with a non-zero specHash";
125
- export declare const DEFAULT_EXPIRES_IN = 3600n;
126
- export declare const HISTORY_LIMIT = 100;
127
- export declare const WATCH_POLL_MS = 2000;
128
- export declare const WATCH_WAIT_SECONDS = 10;
129
- export declare class NoFreeNonce extends Error {
130
- readonly owner: Address;
131
- constructor(owner: Address);
132
- }
133
- export declare class NotSettleable extends Error {
134
- readonly intent: Address;
135
- constructor(intent: Address, reason: string);
136
- }
137
- export declare class NotFillable extends Error {
138
- readonly intent: Address;
139
- constructor(intent: Address, reason: string);
140
- }
1
+ import { type Client, type ClientOptions } from "./client-types.js";
2
+ export type { Balances, Client, ClientOptions, CreatedIntent, CreateIntentInput, Fill, FillInput, HistoryEvent, IntentAccount, IntentFilter, Mint, SettleProofInput, TokenBalance, WatchCallback, WatchOptions, } from "./client-types.js";
3
+ export { DEFAULT_EXPIRES_IN, EXPIRES_IN_RANGE, HISTORY_LIMIT, MAX_EXPIRES_IN, MIN_EXPIRES_IN, SPEC_URL_NEEDS_PROOF, WATCH_POLL_MS, WATCH_WAIT_SECONDS, } from "./client-types.js";
4
+ export { EscrowExpired, NoFreeNonce, NotFillable, NotSettleable, PayeeMoved, PayToNotWallet } from "./client-errors.js";
141
5
  export declare function createClient(options: ClientOptions): Client;