@inodra/sui 0.1.0
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/LICENSE +202 -0
- package/README.md +237 -0
- package/bin/inodra-sui.mjs +2 -0
- package/dist/chunk-3CBLVI6J.js +426 -0
- package/dist/chunk-3CBLVI6J.js.map +1 -0
- package/dist/chunk-4HKKW5QN.js +80 -0
- package/dist/chunk-4HKKW5QN.js.map +1 -0
- package/dist/chunk-74XGJJJI.js +33 -0
- package/dist/chunk-74XGJJJI.js.map +1 -0
- package/dist/chunk-D6FZYWG7.js +99 -0
- package/dist/chunk-D6FZYWG7.js.map +1 -0
- package/dist/chunk-LZZMTSLH.js +31 -0
- package/dist/chunk-LZZMTSLH.js.map +1 -0
- package/dist/chunk-M3M2L6BW.js +29 -0
- package/dist/chunk-M3M2L6BW.js.map +1 -0
- package/dist/chunk-NSXRC5XW.js +298 -0
- package/dist/chunk-NSXRC5XW.js.map +1 -0
- package/dist/chunk-OGMBYWTG.js +537 -0
- package/dist/chunk-OGMBYWTG.js.map +1 -0
- package/dist/chunk-U6D5LGNF.js +111 -0
- package/dist/chunk-U6D5LGNF.js.map +1 -0
- package/dist/chunk-ZSW3EWGF.js +539 -0
- package/dist/chunk-ZSW3EWGF.js.map +1 -0
- package/dist/cli.js +665 -0
- package/dist/cli.js.map +1 -0
- package/dist/events.cjs +3273 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +47 -0
- package/dist/events.d.ts +47 -0
- package/dist/events.js +2578 -0
- package/dist/events.js.map +1 -0
- package/dist/graphql.cjs +129 -0
- package/dist/graphql.cjs.map +1 -0
- package/dist/graphql.d.cts +36 -0
- package/dist/graphql.d.ts +36 -0
- package/dist/graphql.js +10 -0
- package/dist/graphql.js.map +1 -0
- package/dist/grpc-web.cjs +129 -0
- package/dist/grpc-web.cjs.map +1 -0
- package/dist/grpc-web.d.cts +31 -0
- package/dist/grpc-web.d.ts +31 -0
- package/dist/grpc-web.js +10 -0
- package/dist/grpc-web.js.map +1 -0
- package/dist/grpc.cjs +131 -0
- package/dist/grpc.cjs.map +1 -0
- package/dist/grpc.d.cts +34 -0
- package/dist/grpc.d.ts +34 -0
- package/dist/grpc.js +10 -0
- package/dist/grpc.js.map +1 -0
- package/dist/index-CGBN_EI5.d.ts +4800 -0
- package/dist/index-CVO2Kj8a.d.cts +4800 -0
- package/dist/index.cjs +4723 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +504 -0
- package/dist/index.d.ts +504 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/manage.cjs +376 -0
- package/dist/manage.cjs.map +1 -0
- package/dist/manage.d.cts +2 -0
- package/dist/manage.d.ts +2 -0
- package/dist/manage.js +8 -0
- package/dist/manage.js.map +1 -0
- package/dist/network-CEg2MJY3.d.cts +60 -0
- package/dist/network-CEg2MJY3.d.ts +60 -0
- package/dist/node.cjs +4759 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +28 -0
- package/dist/node.d.ts +28 -0
- package/dist/node.js +73 -0
- package/dist/node.js.map +1 -0
- package/dist/reflection-Bx44-Fs1.d.ts +4639 -0
- package/dist/reflection-Cf7WFH6H.d.cts +4639 -0
- package/dist/reflection-FEGYA7DU.js +9 -0
- package/dist/reflection-FEGYA7DU.js.map +1 -0
- package/dist/runtime-OWKF3LZ7.js +37 -0
- package/dist/runtime-OWKF3LZ7.js.map +1 -0
- package/dist/warp.cjs +633 -0
- package/dist/warp.cjs.map +1 -0
- package/dist/warp.d.cts +195 -0
- package/dist/warp.d.ts +195 -0
- package/dist/warp.js +12 -0
- package/dist/warp.js.map +1 -0
- package/dist/webhooks.cjs +104 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +35 -0
- package/dist/webhooks.d.ts +35 -0
- package/dist/webhooks.js +7 -0
- package/dist/webhooks.js.map +1 -0
- package/llms.txt +189 -0
- package/package.json +119 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import { I as InodraAuth, a as InodraNetwork, b as INODRA_ENDPOINTS } from './network-CEg2MJY3.js';
|
|
2
|
+
export { A as AuthCredentials, r as resolveAuth } from './network-CEg2MJY3.js';
|
|
3
|
+
import { I as InodraHttpClient, S as Success, O as Operation, Q as Query, u as components, B as Body, h as CreateStreamResponse, d as CreateEventStreamInput, C as CreateAddressStreamInput, b as CreateCoinStreamInput, f as CreateObjectStreamInput, L as ListStreamsResponse, W as WarpStream, U as UpdateStreamInput, p as UpdateStreamResponse, D as DeleteStreamResponse, e as CreateEventWebhookInput, i as CreateWebhookResponse, a as CreateAddressWebhookInput, c as CreateCoinWebhookInput, g as CreateObjectWebhookInput, o as ListWebhooksResponse, s as Webhook, q as UpdateWebhookInput, r as UpdateWebhookResponse, j as DeleteWebhookResponse, n as InodraResponseMeta } from './index-CGBN_EI5.js';
|
|
4
|
+
export { k as InodraHttpClientOptions, l as InodraManagementClient, m as InodraManagementClientOptions, P as Page, R as RequestOptions, t as paginate } from './index-CGBN_EI5.js';
|
|
5
|
+
import { SuiGraphQLClient } from '@mysten/sui/graphql';
|
|
6
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
7
|
+
import * as zod from 'zod';
|
|
8
|
+
import * as zod_v4_core from 'zod/v4/core';
|
|
9
|
+
import { aC as EventSchemaReflector, C as CatalogEventId, a as CatalogEventPayload, d4 as WarpEventPayload, d6 as WebhookEventBody } from './reflection-Bx44-Fs1.js';
|
|
10
|
+
import { WarpSseStream, WarpWebSocketStream, WarpSseStreamOptions, WarpWebSocketStreamOptions } from './warp.js';
|
|
11
|
+
export { IterateStreamOptions, WarpConnectedInfo, WarpEvent, WarpStreamEvents, WarpStreamOptions, iterateStream } from './warp.js';
|
|
12
|
+
import { VerifyWebhookSignatureOptions } from './webhooks.js';
|
|
13
|
+
export { verifyWebhookSignature } from './webhooks.js';
|
|
14
|
+
|
|
15
|
+
type MeOp = Operation<"/auth/me", "get">;
|
|
16
|
+
type UsageOp = Operation<"/usage/stats", "get">;
|
|
17
|
+
/**
|
|
18
|
+
* The authenticated principal: API key introspection and usage/billing stats.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const me = await inodra.account.me(); // org, project, network, tier
|
|
22
|
+
* const usage = await inodra.account.usage(); // CU consumed/remaining, p95s
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare class AccountNamespace {
|
|
26
|
+
private readonly http;
|
|
27
|
+
constructor(http: InodraHttpClient);
|
|
28
|
+
/** Who am I — key, organization, project, network, tier, subscription. */
|
|
29
|
+
me(): Promise<Success<MeOp>>;
|
|
30
|
+
/** Usage stats for the current billing period (CU, requests, latency). */
|
|
31
|
+
usage(): Promise<Success<UsageOp>>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type ProtocolsOp = Operation<"/catalog/protocols", "get">;
|
|
35
|
+
type EventsOp = Operation<"/catalog/events", "get">;
|
|
36
|
+
/**
|
|
37
|
+
* Curated protocol event catalog — the live counterpart of the generated
|
|
38
|
+
* schemas in `@inodra/sui/events`. Use it to browse protocols/events and
|
|
39
|
+
* pre-fill webhook or Warp subscriptions with canonical event types.
|
|
40
|
+
*/
|
|
41
|
+
declare class CatalogNamespace {
|
|
42
|
+
private readonly http;
|
|
43
|
+
constructor(http: InodraHttpClient);
|
|
44
|
+
protocols(query?: Query<ProtocolsOp>): Promise<Success<ProtocolsOp>>;
|
|
45
|
+
events(query?: Query<EventsOp>): Promise<Success<EventsOp>>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type AccountOp = Operation<"/accounts/{address}", "get">;
|
|
49
|
+
type BalanceOp = Operation<"/accounts/{address}/balance", "get">;
|
|
50
|
+
type AccountObjectsOp = Operation<"/accounts/{address}/objects", "get">;
|
|
51
|
+
type AccountTxsOp = Operation<"/accounts/{address}/transactions", "get">;
|
|
52
|
+
type DelegationsOp = Operation<"/accounts/{address}/delegations", "get">;
|
|
53
|
+
type CoinOp = Operation<"/coins/{coinType}", "get">;
|
|
54
|
+
type CoinMetadataOp = Operation<"/coins/type/{coinType}", "get">;
|
|
55
|
+
type ObjectMetadataOp = Operation<"/objects/metadata", "post">;
|
|
56
|
+
type ObjectTxsOp = Operation<"/objects/{objectId}/transactions", "get">;
|
|
57
|
+
type PackageOp = Operation<"/packages/{packageId}", "get">;
|
|
58
|
+
type ChainInfoOp = Operation<"/chain/info", "get">;
|
|
59
|
+
type ChainStakingOp = Operation<"/chain/staking", "get">;
|
|
60
|
+
type ChainStatsOp = Operation<"/chain/stats", "get">;
|
|
61
|
+
type ValidatorsOp = Operation<"/validators", "get">;
|
|
62
|
+
type ValidatorsApyOp = Operation<"/validators/apy", "get">;
|
|
63
|
+
type ValidatorsCommissionOp = Operation<"/validators/commission", "get">;
|
|
64
|
+
type ValidatorOp = Operation<"/validators/{validatorAddress}", "get">;
|
|
65
|
+
type SuinsResolveOp = Operation<"/suins/resolve/{name}", "get">;
|
|
66
|
+
type SuinsReverseOp = Operation<"/suins/reverse/{address}", "get">;
|
|
67
|
+
type SuinsBatchOp = Operation<"/suins/resolve/batch", "post">;
|
|
68
|
+
type SuinsAvailabilityOp = Operation<"/suins/availability/{name}", "get">;
|
|
69
|
+
/**
|
|
70
|
+
* Indexer-backed data API: accounts, coins, objects, packages, chain,
|
|
71
|
+
* validators, and SuiNS. Mainnet only (testnet projects get 403 on these).
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* const balance = await inodra.data.accounts.balance("0x...");
|
|
75
|
+
* for await (const tx of inodra.data.accounts.iterateTransactions("0x...")) { … }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare class DataNamespace {
|
|
79
|
+
private readonly http;
|
|
80
|
+
constructor(http: InodraHttpClient);
|
|
81
|
+
readonly accounts: {
|
|
82
|
+
get: (address: string) => Promise<Success<AccountOp>>;
|
|
83
|
+
balance: (address: string) => Promise<Success<BalanceOp>>;
|
|
84
|
+
objects: (address: string, query?: Query<AccountObjectsOp>) => Promise<Success<AccountObjectsOp>>;
|
|
85
|
+
/** Every owned object, walking all pages lazily. */
|
|
86
|
+
iterateObjects: (address: string, query?: Query<AccountObjectsOp>) => AsyncGenerator<{
|
|
87
|
+
data?: components["schemas"]["SuiObject"];
|
|
88
|
+
error?: string;
|
|
89
|
+
}, void, undefined>;
|
|
90
|
+
transactions: (address: string, query?: Query<AccountTxsOp>) => Promise<Success<AccountTxsOp>>;
|
|
91
|
+
/** Every transaction, walking all pages lazily. */
|
|
92
|
+
iterateTransactions: (address: string, query?: Query<AccountTxsOp>) => AsyncGenerator<{
|
|
93
|
+
digest: string;
|
|
94
|
+
checkpoint?: string | null;
|
|
95
|
+
timestampMs?: string | null;
|
|
96
|
+
transaction?: unknown;
|
|
97
|
+
effects?: unknown;
|
|
98
|
+
events?: {
|
|
99
|
+
id: {
|
|
100
|
+
txDigest: string;
|
|
101
|
+
eventSeq: string;
|
|
102
|
+
};
|
|
103
|
+
packageId?: string | null;
|
|
104
|
+
transactionModule?: string | null;
|
|
105
|
+
sender?: string | null;
|
|
106
|
+
type: string;
|
|
107
|
+
timestampMs?: string | null;
|
|
108
|
+
}[] | null;
|
|
109
|
+
objectChanges?: unknown[] | null;
|
|
110
|
+
balanceChanges?: {
|
|
111
|
+
owner: {
|
|
112
|
+
[key: string]: string;
|
|
113
|
+
};
|
|
114
|
+
coinType: string;
|
|
115
|
+
amount: string;
|
|
116
|
+
}[] | null;
|
|
117
|
+
confirmedLocalExecution?: boolean | null;
|
|
118
|
+
errors?: string[];
|
|
119
|
+
} | {
|
|
120
|
+
type: "sent" | "received";
|
|
121
|
+
transactionDigest: string;
|
|
122
|
+
timestamp?: string;
|
|
123
|
+
amount?: string | null;
|
|
124
|
+
coinType?: string | null;
|
|
125
|
+
counterparty?: string | null;
|
|
126
|
+
transaction: components["schemas"]["SuiTransactionBlockResponse"];
|
|
127
|
+
}, void, undefined>;
|
|
128
|
+
delegations: (address: string) => Promise<Success<DelegationsOp>>;
|
|
129
|
+
};
|
|
130
|
+
readonly coins: {
|
|
131
|
+
/** Coin denomination (supply, holders, decimals, …). */
|
|
132
|
+
get: (coinType: string) => Promise<Success<CoinOp>>;
|
|
133
|
+
/** Display metadata: name, symbol, icon, description, links. */
|
|
134
|
+
metadata: (coinType: string) => Promise<Success<CoinMetadataOp>>;
|
|
135
|
+
};
|
|
136
|
+
readonly objects: {
|
|
137
|
+
/** Metadata (type, name, image, project) for one object id. */
|
|
138
|
+
metadata: (input: Body<ObjectMetadataOp>) => Promise<Success<ObjectMetadataOp>>;
|
|
139
|
+
transactions: (objectId: string, query?: Query<ObjectTxsOp>) => Promise<Success<ObjectTxsOp>>;
|
|
140
|
+
/** Every transaction touching the object, walking all pages lazily. */
|
|
141
|
+
iterateTransactions: (objectId: string, query?: Query<ObjectTxsOp>) => AsyncGenerator<{
|
|
142
|
+
digest: string;
|
|
143
|
+
checkpoint?: string | null;
|
|
144
|
+
timestampMs?: string | null;
|
|
145
|
+
transaction?: unknown;
|
|
146
|
+
effects?: unknown;
|
|
147
|
+
events?: {
|
|
148
|
+
id: {
|
|
149
|
+
txDigest: string;
|
|
150
|
+
eventSeq: string;
|
|
151
|
+
};
|
|
152
|
+
packageId?: string | null;
|
|
153
|
+
transactionModule?: string | null;
|
|
154
|
+
sender?: string | null;
|
|
155
|
+
type: string;
|
|
156
|
+
timestampMs?: string | null;
|
|
157
|
+
}[] | null;
|
|
158
|
+
objectChanges?: unknown[] | null;
|
|
159
|
+
balanceChanges?: {
|
|
160
|
+
owner: {
|
|
161
|
+
[key: string]: string;
|
|
162
|
+
};
|
|
163
|
+
coinType: string;
|
|
164
|
+
amount: string;
|
|
165
|
+
}[] | null;
|
|
166
|
+
confirmedLocalExecution?: boolean | null;
|
|
167
|
+
errors?: string[];
|
|
168
|
+
}, void, undefined>;
|
|
169
|
+
};
|
|
170
|
+
readonly packages: {
|
|
171
|
+
get: (packageId: string) => Promise<Success<PackageOp>>;
|
|
172
|
+
};
|
|
173
|
+
readonly chain: {
|
|
174
|
+
info: () => Promise<Success<ChainInfoOp>>;
|
|
175
|
+
staking: () => Promise<Success<ChainStakingOp>>;
|
|
176
|
+
stats: () => Promise<Success<ChainStatsOp>>;
|
|
177
|
+
};
|
|
178
|
+
readonly validators: {
|
|
179
|
+
list: (query?: Query<ValidatorsOp>) => Promise<Success<ValidatorsOp>>;
|
|
180
|
+
apy: () => Promise<Success<ValidatorsApyOp>>;
|
|
181
|
+
commission: () => Promise<Success<ValidatorsCommissionOp>>;
|
|
182
|
+
get: (validatorAddress: string) => Promise<Success<ValidatorOp>>;
|
|
183
|
+
};
|
|
184
|
+
readonly suins: {
|
|
185
|
+
/** SuiNS name → address. */
|
|
186
|
+
resolve: (name: string) => Promise<Success<SuinsResolveOp>>;
|
|
187
|
+
/** Address → primary SuiNS name. */
|
|
188
|
+
reverse: (address: string) => Promise<Success<SuinsReverseOp>>;
|
|
189
|
+
resolveBatch: (input: Body<SuinsBatchOp>) => Promise<Success<SuinsBatchOp>>;
|
|
190
|
+
availability: (name: string) => Promise<Success<SuinsAvailabilityOp>>;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
interface EventsNamespaceContext {
|
|
195
|
+
auth: InodraAuth;
|
|
196
|
+
network: InodraNetwork;
|
|
197
|
+
/** GraphQL endpoint override (custom endpoints). */
|
|
198
|
+
graphqlUrl?: string;
|
|
199
|
+
fetch?: typeof globalThis.fetch;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Typed payloads for ARBITRARY Move events (beyond the curated catalog) via
|
|
203
|
+
* on-chain struct reflection. Schemas are built once and cached per type.
|
|
204
|
+
*
|
|
205
|
+
* ```ts
|
|
206
|
+
* const schema = await inodra.events.schemaFor("0xpkg::vault::Deposit<0x2::sui::SUI>");
|
|
207
|
+
* stream.on("message", async (msg) => {
|
|
208
|
+
* const payload = await inodra.events.parseEvent(msg, "0xpkg::vault::Deposit");
|
|
209
|
+
* if (payload) console.log(payload.amount); // validated + normalized
|
|
210
|
+
* });
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* For catalog events prefer the statically-typed helpers in
|
|
214
|
+
* `@inodra/sui/events` (`parseCatalogEvent`) — reflection is for your own
|
|
215
|
+
* or uncataloged protocols. The zod machinery loads on first use.
|
|
216
|
+
*/
|
|
217
|
+
declare class EventsNamespace {
|
|
218
|
+
private readonly ctx;
|
|
219
|
+
private reflectorPromise;
|
|
220
|
+
constructor(ctx: EventsNamespaceContext);
|
|
221
|
+
/** The underlying reflector (shared cache across calls). */
|
|
222
|
+
reflector(): Promise<EventSchemaReflector>;
|
|
223
|
+
/**
|
|
224
|
+
* Build (and cache) a loose, normalizing zod schema for any concrete
|
|
225
|
+
* Move event type, by reflecting its struct layout on-chain. Generic
|
|
226
|
+
* types are typed concretely from their instantiation.
|
|
227
|
+
*/
|
|
228
|
+
schemaFor(type: string): Promise<zod.ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
|
229
|
+
/**
|
|
230
|
+
* Validate + normalize an event payload against the reflected schema.
|
|
231
|
+
* Accepts a Warp stream message, a bare event payload, or a webhook
|
|
232
|
+
* body. Returns undefined for other event types; throws on schema
|
|
233
|
+
* mismatch. Pass a base type (no `<…>`) to match every instantiation —
|
|
234
|
+
* each is reflected and typed concretely.
|
|
235
|
+
*/
|
|
236
|
+
parseEvent(message: unknown, type: string): Promise<Record<string, unknown> | undefined>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
interface WarpNamespaceContext {
|
|
240
|
+
http: InodraHttpClient;
|
|
241
|
+
auth: InodraAuth;
|
|
242
|
+
network: InodraNetwork;
|
|
243
|
+
/** REST base URL override (custom endpoints) — used for SSE stream URLs. */
|
|
244
|
+
restBaseUrl?: string;
|
|
245
|
+
/** WS base URL override (custom endpoints). */
|
|
246
|
+
warpWsBaseUrl?: string;
|
|
247
|
+
/** Custom fetch implementation, threaded into SSE streams. */
|
|
248
|
+
fetch?: typeof globalThis.fetch;
|
|
249
|
+
}
|
|
250
|
+
type ConnectOptions = Omit<WarpSseStreamOptions, "auth" | "apiKey" | "subscriptionId" | "network">;
|
|
251
|
+
type ConnectWebSocketOptions = Omit<WarpWebSocketStreamOptions, "auth" | "apiKey" | "subscriptionId" | "network">;
|
|
252
|
+
interface StreamCatalogEventOptions extends ConnectOptions, ConnectWebSocketOptions {
|
|
253
|
+
/** Optional sender address filter for the subscription. */
|
|
254
|
+
sender?: CreateEventStreamInput["sender"];
|
|
255
|
+
/** Optional field-level filters for the subscription (max 10). */
|
|
256
|
+
eventFieldFilters?: CreateEventStreamInput["eventFieldFilters"];
|
|
257
|
+
/** Delivery transport. Defaults to "sse". */
|
|
258
|
+
transport?: "sse" | "ws";
|
|
259
|
+
/**
|
|
260
|
+
* Delete the subscription when the stream closes or iteration ends.
|
|
261
|
+
* Defaults to false — pass true for one-off consumers so they don't
|
|
262
|
+
* accumulate subscriptions against the plan limit. Note: if the process
|
|
263
|
+
* dies before close(), the subscription survives; give long-lived
|
|
264
|
+
* consumers a managed subscription instead.
|
|
265
|
+
*/
|
|
266
|
+
ephemeral?: boolean;
|
|
267
|
+
}
|
|
268
|
+
/** A typed catalog event with its delivery envelope. */
|
|
269
|
+
interface CatalogEventMessage<Id extends CatalogEventId> {
|
|
270
|
+
/** Validated, normalized Move event payload. */
|
|
271
|
+
payload: CatalogEventPayload<Id>;
|
|
272
|
+
/** Delivery envelope: txDigest, checkpoint, timestamp, sender, raw type. */
|
|
273
|
+
envelope: WarpEventPayload;
|
|
274
|
+
}
|
|
275
|
+
interface CatalogEventStream<Id extends CatalogEventId> extends AsyncIterable<CatalogEventMessage<Id>> {
|
|
276
|
+
/** The created Warp subscription (delete it when done unless ephemeral). */
|
|
277
|
+
subscription: CreateStreamResponse["data"];
|
|
278
|
+
/** The underlying transport stream (for on("error"), lastEventId, …). */
|
|
279
|
+
stream: WarpSseStream | WarpWebSocketStream;
|
|
280
|
+
/** Close the stream; deletes the subscription when ephemeral. */
|
|
281
|
+
close(): Promise<void>;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Warp streams: subscription CRUD plus live SSE/WebSocket delivery.
|
|
285
|
+
*
|
|
286
|
+
* ```ts
|
|
287
|
+
* const sub = await inodra.warp.createEventStream({ eventType });
|
|
288
|
+
* const stream = inodra.warp.connect(sub.id);
|
|
289
|
+
* stream.on("message", (event) => console.log(event.data));
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare class WarpNamespace {
|
|
293
|
+
private readonly ctx;
|
|
294
|
+
constructor(ctx: WarpNamespaceContext);
|
|
295
|
+
createEventStream(input: CreateEventStreamInput): Promise<CreateStreamResponse>;
|
|
296
|
+
createAddressStream(input: CreateAddressStreamInput): Promise<CreateStreamResponse>;
|
|
297
|
+
createCoinStream(input: CreateCoinStreamInput): Promise<CreateStreamResponse>;
|
|
298
|
+
createObjectStream(input: CreateObjectStreamInput): Promise<CreateStreamResponse>;
|
|
299
|
+
list(): Promise<ListStreamsResponse>;
|
|
300
|
+
get(id: string): Promise<WarpStream>;
|
|
301
|
+
update(id: string, input: UpdateStreamInput): Promise<UpdateStreamResponse>;
|
|
302
|
+
delete(id: string): Promise<DeleteStreamResponse>;
|
|
303
|
+
/**
|
|
304
|
+
* Open an SSE connection to a Warp subscription and start it.
|
|
305
|
+
* At-least-once delivery; reconnects resume from the last event ID.
|
|
306
|
+
*/
|
|
307
|
+
connect(subscriptionId: string, options?: ConnectOptions): WarpSseStream;
|
|
308
|
+
/**
|
|
309
|
+
* Open a WebSocket connection to a Warp subscription and start it.
|
|
310
|
+
* Exactly-once delivery via acks (automatic by default).
|
|
311
|
+
*/
|
|
312
|
+
connectWebSocket(subscriptionId: string, options?: ConnectWebSocketOptions): WarpWebSocketStream;
|
|
313
|
+
/**
|
|
314
|
+
* One call from catalog id to typed live events: resolves the event's
|
|
315
|
+
* canonical type for this network, creates the subscription, connects,
|
|
316
|
+
* and yields validated payloads.
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* const swaps = await inodra.warp.streamCatalogEvent("cetus.swap", {
|
|
320
|
+
* ephemeral: true,
|
|
321
|
+
* });
|
|
322
|
+
* for await (const { payload, envelope } of swaps) {
|
|
323
|
+
* console.log(envelope.txDigest, payload.amount_in);
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
streamCatalogEvent<Id extends CatalogEventId>(id: Id, options?: StreamCatalogEventOptions): Promise<CatalogEventStream<Id>>;
|
|
328
|
+
private sseUrl;
|
|
329
|
+
private wsUrl;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Webhooks: subscription CRUD plus delivery signature verification.
|
|
334
|
+
*
|
|
335
|
+
* ```ts
|
|
336
|
+
* const hook = await inodra.webhooks.createEvent({ eventType, url });
|
|
337
|
+
* // in your receiver:
|
|
338
|
+
* const valid = await inodra.webhooks.verifySignature({ payload, signature, secret });
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare class WebhooksNamespace {
|
|
342
|
+
private readonly http;
|
|
343
|
+
constructor(http: InodraHttpClient);
|
|
344
|
+
createEvent(input: CreateEventWebhookInput): Promise<CreateWebhookResponse>;
|
|
345
|
+
createAddress(input: CreateAddressWebhookInput): Promise<CreateWebhookResponse>;
|
|
346
|
+
createCoin(input: CreateCoinWebhookInput): Promise<CreateWebhookResponse>;
|
|
347
|
+
createObject(input: CreateObjectWebhookInput): Promise<CreateWebhookResponse>;
|
|
348
|
+
list(): Promise<ListWebhooksResponse>;
|
|
349
|
+
get(id: string): Promise<Webhook>;
|
|
350
|
+
update(id: string, input: UpdateWebhookInput): Promise<UpdateWebhookResponse>;
|
|
351
|
+
delete(id: string): Promise<DeleteWebhookResponse>;
|
|
352
|
+
/** Verify an incoming webhook delivery's X-Inodra-Signature header. */
|
|
353
|
+
verifySignature(options: VerifyWebhookSignatureOptions): Promise<boolean>;
|
|
354
|
+
/**
|
|
355
|
+
* Verify and parse an incoming event-webhook delivery in one step
|
|
356
|
+
* (Stripe's constructEvent pattern). Throws InodraWebhookSignatureError
|
|
357
|
+
* on a bad or expired signature, and a zod error if the body doesn't
|
|
358
|
+
* look like an Inodra delivery.
|
|
359
|
+
*
|
|
360
|
+
* Pair with `matchCatalogEvent`/`parseCatalogEvent` from
|
|
361
|
+
* `@inodra/sui/events` to narrow the payload to a catalog event type.
|
|
362
|
+
*
|
|
363
|
+
* ```ts
|
|
364
|
+
* const body = await inodra.webhooks.constructEvent({
|
|
365
|
+
* payload: rawBody, // exact raw string — do not JSON.parse first
|
|
366
|
+
* signature: req.headers["x-inodra-signature"],
|
|
367
|
+
* secret: process.env.INODRA_WEBHOOK_SECRET,
|
|
368
|
+
* });
|
|
369
|
+
* const swap = parseCatalogEvent(body, "cetus.swap");
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
constructEvent(options: VerifyWebhookSignatureOptions): Promise<WebhookEventBody>;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Per-protocol endpoint overrides (all optional; defaults come from network). */
|
|
376
|
+
interface InodraEndpointOverrides {
|
|
377
|
+
/** REST base URL, e.g. http://localhost:3000/v1 */
|
|
378
|
+
rest?: string;
|
|
379
|
+
/** GraphQL endpoint URL. */
|
|
380
|
+
graphql?: string;
|
|
381
|
+
/** host:port for native gRPC transports. */
|
|
382
|
+
grpc?: string;
|
|
383
|
+
/** Base URL for gRPC-Web transports. */
|
|
384
|
+
grpcWeb?: string;
|
|
385
|
+
/** WS base URL for Warp streams, e.g. ws://localhost:3000/v1 */
|
|
386
|
+
warpWs?: string;
|
|
387
|
+
}
|
|
388
|
+
interface InodraOptions {
|
|
389
|
+
/** Credentials: an API key string, {apiKey}, {sessionToken}, or a provider. */
|
|
390
|
+
auth?: InodraAuth;
|
|
391
|
+
/** Shorthand for `auth: { apiKey }`. */
|
|
392
|
+
apiKey?: string;
|
|
393
|
+
/** Defaults to "mainnet". */
|
|
394
|
+
network?: InodraNetwork;
|
|
395
|
+
/** Endpoint overrides for self-hosted / local development. */
|
|
396
|
+
endpoints?: InodraEndpointOverrides;
|
|
397
|
+
/** REST retry budget for 429/5xx. Defaults to 2. */
|
|
398
|
+
maxRetries?: number;
|
|
399
|
+
/** REST per-request timeout in milliseconds. Defaults to 30000. */
|
|
400
|
+
timeoutMs?: number;
|
|
401
|
+
/** Custom fetch implementation. */
|
|
402
|
+
fetch?: typeof globalThis.fetch;
|
|
403
|
+
/** Called with rate-limit/credit info after every REST response. */
|
|
404
|
+
onResponseMeta?: (meta: InodraResponseMeta) => void;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* The Inodra client — one entry point, one credential, every product surface.
|
|
408
|
+
*
|
|
409
|
+
* ```ts
|
|
410
|
+
* const inodra = new Inodra({ network: "mainnet", auth: { apiKey } });
|
|
411
|
+
*
|
|
412
|
+
* const balance = await inodra.grpc.core.getBalance({ owner, coinType });
|
|
413
|
+
* const sub = await inodra.warp.createEventStream({ eventType });
|
|
414
|
+
* const stream = inodra.warp.connect(sub.id);
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* Namespaces are created lazily on first access. The `grpc` client uses a
|
|
418
|
+
* fetch-based gRPC-Web transport that works in every runtime; on Node.js,
|
|
419
|
+
* import `Inodra` from `@inodra/sui/node` for native HTTP/2 gRPC instead.
|
|
420
|
+
*
|
|
421
|
+
* Bundle note: this entry statically references `@mysten/sui`. Frontend apps
|
|
422
|
+
* that only need Warp/webhooks and want a Mysten-free bundle should import
|
|
423
|
+
* from the lean subpaths (`@inodra/sui/warp`, `@inodra/sui/manage`, …).
|
|
424
|
+
*/
|
|
425
|
+
declare class Inodra {
|
|
426
|
+
readonly network: InodraNetwork;
|
|
427
|
+
/** The underlying REST transport (shared by all REST namespaces). */
|
|
428
|
+
readonly http: InodraHttpClient;
|
|
429
|
+
protected readonly options: InodraOptions;
|
|
430
|
+
protected readonly auth: InodraAuth;
|
|
431
|
+
private memo;
|
|
432
|
+
constructor(options: InodraOptions);
|
|
433
|
+
/** Rate-limit/credit info from the most recent REST response. */
|
|
434
|
+
get lastResponseMeta(): InodraResponseMeta | undefined;
|
|
435
|
+
/**
|
|
436
|
+
* Sui gRPC client (@mysten/sui) over Inodra's authenticated gateway.
|
|
437
|
+
* Uses a fetch-based gRPC-Web transport — works in browsers, edge
|
|
438
|
+
* runtimes, and Node. For native HTTP/2 gRPC on Node, use
|
|
439
|
+
* `@inodra/sui/node`.
|
|
440
|
+
*/
|
|
441
|
+
get grpc(): SuiGrpcClient;
|
|
442
|
+
/** Sui GraphQL client (@mysten/sui) over Inodra's authenticated gateway. */
|
|
443
|
+
get graphql(): SuiGraphQLClient;
|
|
444
|
+
/** Warp streams: subscription CRUD + live SSE/WebSocket delivery. */
|
|
445
|
+
get warp(): WarpNamespace;
|
|
446
|
+
/** Webhooks: subscription CRUD + delivery signature verification. */
|
|
447
|
+
get webhooks(): WebhooksNamespace;
|
|
448
|
+
/** Indexer-backed data: accounts, coins, packages, validators, SuiNS, …. */
|
|
449
|
+
get data(): DataNamespace;
|
|
450
|
+
/** Curated protocol event catalog (live view). */
|
|
451
|
+
get catalog(): CatalogNamespace;
|
|
452
|
+
/** The authenticated principal: key introspection + usage stats. */
|
|
453
|
+
get account(): AccountNamespace;
|
|
454
|
+
/** Reflection-based typed payloads for arbitrary (uncataloged) events. */
|
|
455
|
+
get events(): EventsNamespace;
|
|
456
|
+
/** Default endpoints for this client's network. */
|
|
457
|
+
get endpoints(): (typeof INODRA_ENDPOINTS)[InodraNetwork];
|
|
458
|
+
protected createGrpcClient(): SuiGrpcClient;
|
|
459
|
+
protected lazy<T>(key: string, create: () => T): T;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
declare class InodraError extends Error {
|
|
463
|
+
readonly status: number;
|
|
464
|
+
readonly requestId?: string;
|
|
465
|
+
readonly body?: unknown;
|
|
466
|
+
/** Stable machine-readable error code from the API (e.g. "QUOTA_EXCEEDED"). */
|
|
467
|
+
readonly code?: string;
|
|
468
|
+
constructor(message: string, options: {
|
|
469
|
+
status: number;
|
|
470
|
+
requestId?: string;
|
|
471
|
+
body?: unknown;
|
|
472
|
+
code?: string;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
declare class InodraAuthenticationError extends InodraError {
|
|
476
|
+
constructor(options: {
|
|
477
|
+
status: number;
|
|
478
|
+
requestId?: string;
|
|
479
|
+
body?: unknown;
|
|
480
|
+
code?: string;
|
|
481
|
+
message?: string;
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
declare class InodraRateLimitError extends InodraError {
|
|
485
|
+
readonly retryAfterSeconds?: number;
|
|
486
|
+
constructor(options: {
|
|
487
|
+
status: number;
|
|
488
|
+
requestId?: string;
|
|
489
|
+
body?: unknown;
|
|
490
|
+
code?: string;
|
|
491
|
+
retryAfterSeconds?: number;
|
|
492
|
+
message?: string;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
declare class InodraTimeoutError extends Error {
|
|
496
|
+
constructor(timeoutMs: number);
|
|
497
|
+
}
|
|
498
|
+
declare class InodraWebhookSignatureError extends Error {
|
|
499
|
+
constructor();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
declare const SDK_VERSION = "0.1.0";
|
|
503
|
+
|
|
504
|
+
export { AccountNamespace, type CatalogEventMessage, type CatalogEventStream, CatalogNamespace, type ConnectOptions, type ConnectWebSocketOptions, CreateAddressStreamInput, CreateAddressWebhookInput, CreateCoinStreamInput, CreateCoinWebhookInput, CreateEventStreamInput, CreateEventWebhookInput, CreateObjectStreamInput, CreateObjectWebhookInput, CreateStreamResponse, CreateWebhookResponse, DataNamespace, DeleteStreamResponse, DeleteWebhookResponse, EventsNamespace, INODRA_ENDPOINTS, Inodra, InodraAuth, InodraAuthenticationError, type InodraEndpointOverrides, InodraError, InodraHttpClient, InodraNetwork, type InodraOptions, InodraRateLimitError, InodraResponseMeta, InodraTimeoutError, InodraWebhookSignatureError, ListStreamsResponse, ListWebhooksResponse, SDK_VERSION, type StreamCatalogEventOptions, UpdateStreamInput, UpdateStreamResponse, UpdateWebhookInput, UpdateWebhookResponse, VerifyWebhookSignatureOptions, WarpNamespace, WarpSseStream, WarpSseStreamOptions, WarpStream, WarpWebSocketStream, WarpWebSocketStreamOptions, Webhook, WebhooksNamespace };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountNamespace,
|
|
3
|
+
CatalogNamespace,
|
|
4
|
+
DataNamespace,
|
|
5
|
+
EventsNamespace,
|
|
6
|
+
Inodra,
|
|
7
|
+
WarpNamespace,
|
|
8
|
+
WebhooksNamespace,
|
|
9
|
+
paginate
|
|
10
|
+
} from "./chunk-OGMBYWTG.js";
|
|
11
|
+
import {
|
|
12
|
+
verifyWebhookSignature
|
|
13
|
+
} from "./chunk-4HKKW5QN.js";
|
|
14
|
+
import "./chunk-M3M2L6BW.js";
|
|
15
|
+
import "./chunk-74XGJJJI.js";
|
|
16
|
+
import {
|
|
17
|
+
WarpSseStream,
|
|
18
|
+
WarpWebSocketStream,
|
|
19
|
+
iterateStream
|
|
20
|
+
} from "./chunk-ZSW3EWGF.js";
|
|
21
|
+
import {
|
|
22
|
+
InodraAuthenticationError,
|
|
23
|
+
InodraError,
|
|
24
|
+
InodraHttpClient,
|
|
25
|
+
InodraManagementClient,
|
|
26
|
+
InodraRateLimitError,
|
|
27
|
+
InodraTimeoutError,
|
|
28
|
+
InodraWebhookSignatureError
|
|
29
|
+
} from "./chunk-NSXRC5XW.js";
|
|
30
|
+
import {
|
|
31
|
+
INODRA_ENDPOINTS,
|
|
32
|
+
SDK_VERSION,
|
|
33
|
+
resolveAuth
|
|
34
|
+
} from "./chunk-U6D5LGNF.js";
|
|
35
|
+
export {
|
|
36
|
+
AccountNamespace,
|
|
37
|
+
CatalogNamespace,
|
|
38
|
+
DataNamespace,
|
|
39
|
+
EventsNamespace,
|
|
40
|
+
INODRA_ENDPOINTS,
|
|
41
|
+
Inodra,
|
|
42
|
+
InodraAuthenticationError,
|
|
43
|
+
InodraError,
|
|
44
|
+
InodraHttpClient,
|
|
45
|
+
InodraManagementClient,
|
|
46
|
+
InodraRateLimitError,
|
|
47
|
+
InodraTimeoutError,
|
|
48
|
+
InodraWebhookSignatureError,
|
|
49
|
+
SDK_VERSION,
|
|
50
|
+
WarpNamespace,
|
|
51
|
+
WarpSseStream,
|
|
52
|
+
WarpWebSocketStream,
|
|
53
|
+
WebhooksNamespace,
|
|
54
|
+
iterateStream,
|
|
55
|
+
paginate,
|
|
56
|
+
resolveAuth,
|
|
57
|
+
verifyWebhookSignature
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|