@fepvenancio/stela-sdk 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/README.md +155 -0
- package/dist/index.cjs +2078 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +496 -0
- package/dist/index.d.ts +496 -0
- package/dist/index.js +2041 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
- package/src/abi/erc20.json +54 -0
- package/src/abi/locker.json +50 -0
- package/src/abi/stela.json +1186 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import { RpcProvider, Account, Contract } from 'starknet';
|
|
2
|
+
|
|
3
|
+
/** Supported StarkNet networks */
|
|
4
|
+
type Network = 'sepolia' | 'mainnet';
|
|
5
|
+
/** Token standard types supported by the Stela protocol */
|
|
6
|
+
type AssetType = 'ERC20' | 'ERC721' | 'ERC1155' | 'ERC4626';
|
|
7
|
+
/** Possible states of an inscription */
|
|
8
|
+
type InscriptionStatus = 'open' | 'partial' | 'filled' | 'repaid' | 'liquidated' | 'expired' | 'cancelled';
|
|
9
|
+
/** All valid inscription statuses as an array */
|
|
10
|
+
declare const VALID_STATUSES: readonly InscriptionStatus[];
|
|
11
|
+
/** Human-readable labels for each inscription status */
|
|
12
|
+
declare const STATUS_LABELS: Record<InscriptionStatus, string>;
|
|
13
|
+
/** A single StarkNet call (matches starknet.js Call type) */
|
|
14
|
+
interface Call {
|
|
15
|
+
contractAddress: string;
|
|
16
|
+
entrypoint: string;
|
|
17
|
+
calldata: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** An asset within an inscription (matches the Cairo Asset struct) */
|
|
21
|
+
interface Asset {
|
|
22
|
+
/** Contract address of the token */
|
|
23
|
+
asset_address: string;
|
|
24
|
+
/** Token standard */
|
|
25
|
+
asset_type: AssetType;
|
|
26
|
+
/** Token amount (ERC20/ERC1155/ERC4626) */
|
|
27
|
+
value: bigint;
|
|
28
|
+
/** Token ID (ERC721/ERC1155) */
|
|
29
|
+
token_id: bigint;
|
|
30
|
+
}
|
|
31
|
+
/** Parameters for creating a new inscription (matches Cairo InscriptionParams) */
|
|
32
|
+
interface InscriptionParams {
|
|
33
|
+
is_borrow: boolean;
|
|
34
|
+
debt_assets: Asset[];
|
|
35
|
+
interest_assets: Asset[];
|
|
36
|
+
collateral_assets: Asset[];
|
|
37
|
+
/** Duration in seconds */
|
|
38
|
+
duration: bigint;
|
|
39
|
+
/** Deadline as unix timestamp (seconds) */
|
|
40
|
+
deadline: bigint;
|
|
41
|
+
multi_lender: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Raw inscription data as stored on-chain (matches Cairo StoredInscription) */
|
|
44
|
+
interface StoredInscription {
|
|
45
|
+
borrower: string;
|
|
46
|
+
lender: string;
|
|
47
|
+
duration: bigint;
|
|
48
|
+
deadline: bigint;
|
|
49
|
+
signed_at: bigint;
|
|
50
|
+
issued_debt_percentage: bigint;
|
|
51
|
+
is_repaid: boolean;
|
|
52
|
+
liquidated: boolean;
|
|
53
|
+
multi_lender: boolean;
|
|
54
|
+
debt_asset_count: number;
|
|
55
|
+
interest_asset_count: number;
|
|
56
|
+
collateral_asset_count: number;
|
|
57
|
+
}
|
|
58
|
+
/** Parsed inscription with computed status and ID */
|
|
59
|
+
interface Inscription extends StoredInscription {
|
|
60
|
+
id: string;
|
|
61
|
+
status: InscriptionStatus;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Row shape returned by the /api/inscriptions list endpoint */
|
|
65
|
+
interface InscriptionRow {
|
|
66
|
+
id: string;
|
|
67
|
+
creator: string;
|
|
68
|
+
borrower: string | null;
|
|
69
|
+
lender: string | null;
|
|
70
|
+
status: string;
|
|
71
|
+
issued_debt_percentage: string;
|
|
72
|
+
multi_lender: boolean;
|
|
73
|
+
duration: string;
|
|
74
|
+
deadline: string;
|
|
75
|
+
signed_at: string | null;
|
|
76
|
+
debt_asset_count: number;
|
|
77
|
+
interest_asset_count: number;
|
|
78
|
+
collateral_asset_count: number;
|
|
79
|
+
created_at_ts: string;
|
|
80
|
+
assets: AssetRow[];
|
|
81
|
+
}
|
|
82
|
+
/** Asset row shape from the inscription_assets table */
|
|
83
|
+
interface AssetRow {
|
|
84
|
+
inscription_id: string;
|
|
85
|
+
asset_role: 'debt' | 'interest' | 'collateral';
|
|
86
|
+
asset_index: number;
|
|
87
|
+
asset_address: string;
|
|
88
|
+
asset_type: string;
|
|
89
|
+
value: string | null;
|
|
90
|
+
token_id: string | null;
|
|
91
|
+
}
|
|
92
|
+
/** Standard API response envelope for list endpoints */
|
|
93
|
+
interface ApiListResponse<T> {
|
|
94
|
+
data: T[];
|
|
95
|
+
meta: {
|
|
96
|
+
page: number;
|
|
97
|
+
limit: number;
|
|
98
|
+
total: number;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Standard API response envelope for detail endpoints */
|
|
102
|
+
interface ApiDetailResponse<T> {
|
|
103
|
+
data: T;
|
|
104
|
+
}
|
|
105
|
+
/** Treasury asset balance info */
|
|
106
|
+
interface TreasuryAsset {
|
|
107
|
+
asset_address: string;
|
|
108
|
+
asset_type: string;
|
|
109
|
+
balance: string;
|
|
110
|
+
}
|
|
111
|
+
/** ERC1155 share balance for a lender on an inscription */
|
|
112
|
+
interface ShareBalance {
|
|
113
|
+
inscription_id: string;
|
|
114
|
+
holder: string;
|
|
115
|
+
balance: string;
|
|
116
|
+
}
|
|
117
|
+
/** Locker account info for an inscription */
|
|
118
|
+
interface LockerInfo {
|
|
119
|
+
inscription_id: string;
|
|
120
|
+
locker_address: string;
|
|
121
|
+
is_unlocked: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Raw event as returned from StarkNet RPC */
|
|
125
|
+
interface RawEvent {
|
|
126
|
+
keys: string[];
|
|
127
|
+
data: string[];
|
|
128
|
+
transaction_hash: string;
|
|
129
|
+
block_number: number;
|
|
130
|
+
}
|
|
131
|
+
/** InscriptionCreated event */
|
|
132
|
+
interface InscriptionCreatedEvent {
|
|
133
|
+
type: 'InscriptionCreated';
|
|
134
|
+
inscription_id: bigint;
|
|
135
|
+
creator: string;
|
|
136
|
+
is_borrow: boolean;
|
|
137
|
+
transaction_hash: string;
|
|
138
|
+
block_number: number;
|
|
139
|
+
}
|
|
140
|
+
/** InscriptionSigned event */
|
|
141
|
+
interface InscriptionSignedEvent {
|
|
142
|
+
type: 'InscriptionSigned';
|
|
143
|
+
inscription_id: bigint;
|
|
144
|
+
borrower: string;
|
|
145
|
+
lender: string;
|
|
146
|
+
issued_debt_percentage: bigint;
|
|
147
|
+
shares_minted: bigint;
|
|
148
|
+
transaction_hash: string;
|
|
149
|
+
block_number: number;
|
|
150
|
+
}
|
|
151
|
+
/** InscriptionCancelled event */
|
|
152
|
+
interface InscriptionCancelledEvent {
|
|
153
|
+
type: 'InscriptionCancelled';
|
|
154
|
+
inscription_id: bigint;
|
|
155
|
+
creator: string;
|
|
156
|
+
transaction_hash: string;
|
|
157
|
+
block_number: number;
|
|
158
|
+
}
|
|
159
|
+
/** InscriptionRepaid event */
|
|
160
|
+
interface InscriptionRepaidEvent {
|
|
161
|
+
type: 'InscriptionRepaid';
|
|
162
|
+
inscription_id: bigint;
|
|
163
|
+
repayer: string;
|
|
164
|
+
transaction_hash: string;
|
|
165
|
+
block_number: number;
|
|
166
|
+
}
|
|
167
|
+
/** InscriptionLiquidated event */
|
|
168
|
+
interface InscriptionLiquidatedEvent {
|
|
169
|
+
type: 'InscriptionLiquidated';
|
|
170
|
+
inscription_id: bigint;
|
|
171
|
+
liquidator: string;
|
|
172
|
+
transaction_hash: string;
|
|
173
|
+
block_number: number;
|
|
174
|
+
}
|
|
175
|
+
/** SharesRedeemed event */
|
|
176
|
+
interface SharesRedeemedEvent {
|
|
177
|
+
type: 'SharesRedeemed';
|
|
178
|
+
inscription_id: bigint;
|
|
179
|
+
redeemer: string;
|
|
180
|
+
shares: bigint;
|
|
181
|
+
transaction_hash: string;
|
|
182
|
+
block_number: number;
|
|
183
|
+
}
|
|
184
|
+
/** TransferSingle (ERC1155) event from the Stela contract */
|
|
185
|
+
interface TransferSingleEvent {
|
|
186
|
+
type: 'TransferSingle';
|
|
187
|
+
operator: string;
|
|
188
|
+
from: string;
|
|
189
|
+
to: string;
|
|
190
|
+
id: bigint;
|
|
191
|
+
value: bigint;
|
|
192
|
+
transaction_hash: string;
|
|
193
|
+
block_number: number;
|
|
194
|
+
}
|
|
195
|
+
/** Discriminated union of all Stela protocol events */
|
|
196
|
+
type StelaEvent = InscriptionCreatedEvent | InscriptionSignedEvent | InscriptionCancelledEvent | InscriptionRepaidEvent | InscriptionLiquidatedEvent | SharesRedeemedEvent | TransferSingleEvent;
|
|
197
|
+
|
|
198
|
+
/** State of a locker account */
|
|
199
|
+
interface LockerState {
|
|
200
|
+
/** Contract address of the deployed locker */
|
|
201
|
+
address: string;
|
|
202
|
+
/** Whether the locker restrictions have been removed */
|
|
203
|
+
isUnlocked: boolean;
|
|
204
|
+
}
|
|
205
|
+
/** A call to be executed through the locker account */
|
|
206
|
+
interface LockerCall extends Call {
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Deployed Stela protocol contract addresses per network */
|
|
210
|
+
declare const STELA_ADDRESS: Record<Network, string>;
|
|
211
|
+
/** Validate and return a Network value, defaulting to 'sepolia' */
|
|
212
|
+
declare function resolveNetwork(raw?: string): Network;
|
|
213
|
+
|
|
214
|
+
/** Maximum basis points (100%) */
|
|
215
|
+
declare const MAX_BPS = 10000n;
|
|
216
|
+
/** Virtual share offset used in share calculations (1e16) */
|
|
217
|
+
declare const VIRTUAL_SHARE_OFFSET = 10000000000000000n;
|
|
218
|
+
/** Numeric enum values for asset types (matches Cairo contract) */
|
|
219
|
+
declare const ASSET_TYPE_ENUM: Record<AssetType, number>;
|
|
220
|
+
/** Reverse mapping: numeric enum value to AssetType name */
|
|
221
|
+
declare const ASSET_TYPE_NAMES: Record<number, AssetType>;
|
|
222
|
+
|
|
223
|
+
/** Convert a bigint to a [low, high] calldata pair for StarkNet u256 */
|
|
224
|
+
declare const toU256: (n: bigint) => [string, string];
|
|
225
|
+
/** Convert a { low, high } u256 pair back to a bigint */
|
|
226
|
+
declare const fromU256: (u: {
|
|
227
|
+
low: bigint;
|
|
228
|
+
high: bigint;
|
|
229
|
+
}) => bigint;
|
|
230
|
+
/** Convert a u256 { low, high } to a 0x-prefixed 64-char hex string (for DB keys) */
|
|
231
|
+
declare const inscriptionIdToHex: (u: {
|
|
232
|
+
low: bigint;
|
|
233
|
+
high: bigint;
|
|
234
|
+
}) => string;
|
|
235
|
+
|
|
236
|
+
/** Convert any address-like value (string, bigint, number) to a hex string */
|
|
237
|
+
declare function toHex(value: unknown): string;
|
|
238
|
+
/** Truncate an address for display: 0x1a2b...3c4d */
|
|
239
|
+
declare function formatAddress(address: unknown): string;
|
|
240
|
+
/** Normalize an address to a fully-padded, checksummed hex string */
|
|
241
|
+
declare function normalizeAddress(address: unknown): string;
|
|
242
|
+
/** Compare two addresses for equality (handles different padding/casing) */
|
|
243
|
+
declare function addressesEqual(a: unknown, b: unknown): boolean;
|
|
244
|
+
|
|
245
|
+
/** Convert human-readable amount (e.g. "1.5") to on-chain value using decimals */
|
|
246
|
+
declare function parseAmount(humanAmount: string, decimals: number): bigint;
|
|
247
|
+
/** Format a raw token value (string) given its decimals */
|
|
248
|
+
declare function formatTokenValue(raw: string | null, decimals: number): string;
|
|
249
|
+
|
|
250
|
+
/** Format duration in seconds to human-readable (e.g. "7d 0h", "2h", "30m") */
|
|
251
|
+
declare function formatDuration(seconds: number | bigint): string;
|
|
252
|
+
/** Format a unix timestamp (seconds) to locale string */
|
|
253
|
+
declare function formatTimestamp(ts: bigint): string;
|
|
254
|
+
|
|
255
|
+
/** Input shape for computeStatus — accepts both bigint and number fields */
|
|
256
|
+
interface StatusInput {
|
|
257
|
+
signed_at: number | bigint;
|
|
258
|
+
duration: number | bigint;
|
|
259
|
+
issued_debt_percentage: number | bigint;
|
|
260
|
+
is_repaid: boolean;
|
|
261
|
+
liquidated: boolean;
|
|
262
|
+
deadline?: number | bigint;
|
|
263
|
+
status?: string;
|
|
264
|
+
}
|
|
265
|
+
/** Compute the inscription status from on-chain fields */
|
|
266
|
+
declare function computeStatus(a: StatusInput, nowSeconds?: number): InscriptionStatus;
|
|
267
|
+
|
|
268
|
+
interface TokenInfo {
|
|
269
|
+
symbol: string;
|
|
270
|
+
name: string;
|
|
271
|
+
decimals: number;
|
|
272
|
+
addresses: Partial<Record<Network, string>>;
|
|
273
|
+
logoUrl?: string;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Curated StarkNet token list.
|
|
278
|
+
* Addresses sourced from official deployments.
|
|
279
|
+
*/
|
|
280
|
+
declare const TOKENS: TokenInfo[];
|
|
281
|
+
/** Get tokens available on a specific network */
|
|
282
|
+
declare function getTokensForNetwork(network: string): TokenInfo[];
|
|
283
|
+
/** Find a token by its address (any network) */
|
|
284
|
+
declare function findTokenByAddress(address: string): TokenInfo | undefined;
|
|
285
|
+
|
|
286
|
+
/** Convert a fill percentage to shares, matching the contract's share math */
|
|
287
|
+
declare function convertToShares(percentage: bigint, totalSupply: bigint, currentIssuedPercentage: bigint): bigint;
|
|
288
|
+
/** Scale a value by a percentage in basis points */
|
|
289
|
+
declare function scaleByPercentage(value: bigint, percentage: bigint): bigint;
|
|
290
|
+
/** Convert shares back to a percentage of the inscription */
|
|
291
|
+
declare function sharesToPercentage(shares: bigint, totalSupply: bigint, currentIssuedPercentage: bigint): bigint;
|
|
292
|
+
/** Calculate the fee portion of shares given a fee in basis points */
|
|
293
|
+
declare function calculateFeeShares(shares: bigint, feeBps: bigint): bigint;
|
|
294
|
+
|
|
295
|
+
/** Event selectors for all Stela protocol events */
|
|
296
|
+
declare const SELECTORS: {
|
|
297
|
+
readonly InscriptionCreated: string;
|
|
298
|
+
readonly InscriptionSigned: string;
|
|
299
|
+
readonly InscriptionCancelled: string;
|
|
300
|
+
readonly InscriptionRepaid: string;
|
|
301
|
+
readonly InscriptionLiquidated: string;
|
|
302
|
+
readonly SharesRedeemed: string;
|
|
303
|
+
readonly TransferSingle: string;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/** Parse a single raw event into a typed StelaEvent. Returns null if unrecognized. */
|
|
307
|
+
declare function parseEvent(raw: RawEvent): StelaEvent | null;
|
|
308
|
+
/** Parse an array of raw events, skipping unrecognized ones. */
|
|
309
|
+
declare function parseEvents(rawEvents: RawEvent[]): StelaEvent[];
|
|
310
|
+
|
|
311
|
+
interface InscriptionClientOptions {
|
|
312
|
+
stelaAddress: string;
|
|
313
|
+
provider: RpcProvider;
|
|
314
|
+
account?: Account;
|
|
315
|
+
}
|
|
316
|
+
declare class InscriptionClient {
|
|
317
|
+
private contract;
|
|
318
|
+
private address;
|
|
319
|
+
private account?;
|
|
320
|
+
constructor(opts: InscriptionClientOptions);
|
|
321
|
+
getInscription(inscriptionId: bigint): Promise<StoredInscription>;
|
|
322
|
+
getLocker(inscriptionId: bigint): Promise<string>;
|
|
323
|
+
getInscriptionFee(): Promise<bigint>;
|
|
324
|
+
convertToShares(inscriptionId: bigint, percentage: bigint): Promise<bigint>;
|
|
325
|
+
buildCreateInscription(params: InscriptionParams): Call;
|
|
326
|
+
buildSignInscription(inscriptionId: bigint, bps: bigint): Call;
|
|
327
|
+
buildCancelInscription(inscriptionId: bigint): Call;
|
|
328
|
+
buildRepay(inscriptionId: bigint): Call;
|
|
329
|
+
buildLiquidate(inscriptionId: bigint): Call;
|
|
330
|
+
buildRedeem(inscriptionId: bigint, shares: bigint): Call;
|
|
331
|
+
/**
|
|
332
|
+
* Execute one or more calls via the connected account.
|
|
333
|
+
* Pass approval calls to bundle ERC20 approve + protocol call atomically.
|
|
334
|
+
*/
|
|
335
|
+
execute(calls: Call[]): Promise<{
|
|
336
|
+
transaction_hash: string;
|
|
337
|
+
}>;
|
|
338
|
+
createInscription(params: InscriptionParams, approvals?: Call[]): Promise<{
|
|
339
|
+
transaction_hash: string;
|
|
340
|
+
}>;
|
|
341
|
+
signInscription(inscriptionId: bigint, bps: bigint, approvals?: Call[]): Promise<{
|
|
342
|
+
transaction_hash: string;
|
|
343
|
+
}>;
|
|
344
|
+
cancelInscription(inscriptionId: bigint): Promise<{
|
|
345
|
+
transaction_hash: string;
|
|
346
|
+
}>;
|
|
347
|
+
repay(inscriptionId: bigint, approvals?: Call[]): Promise<{
|
|
348
|
+
transaction_hash: string;
|
|
349
|
+
}>;
|
|
350
|
+
liquidate(inscriptionId: bigint): Promise<{
|
|
351
|
+
transaction_hash: string;
|
|
352
|
+
}>;
|
|
353
|
+
redeem(inscriptionId: bigint, shares: bigint): Promise<{
|
|
354
|
+
transaction_hash: string;
|
|
355
|
+
}>;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
interface ShareClientOptions {
|
|
359
|
+
stelaAddress: string;
|
|
360
|
+
provider: RpcProvider;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Client for reading ERC1155 share balances on the Stela contract.
|
|
364
|
+
* Inscription IDs are token IDs — each lender receives shares as ERC1155 tokens.
|
|
365
|
+
*/
|
|
366
|
+
declare class ShareClient {
|
|
367
|
+
private contract;
|
|
368
|
+
constructor(opts: ShareClientOptions);
|
|
369
|
+
/** Get share balance for an account on a specific inscription */
|
|
370
|
+
balanceOf(account: string, inscriptionId: bigint): Promise<bigint>;
|
|
371
|
+
/** Get share balances for multiple account/inscription pairs */
|
|
372
|
+
balanceOfBatch(accounts: string[], inscriptionIds: bigint[]): Promise<bigint[]>;
|
|
373
|
+
/** Check if an operator is approved for all tokens of an owner */
|
|
374
|
+
isApprovedForAll(owner: string, operator: string): Promise<boolean>;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare class LockerClient {
|
|
378
|
+
private stelaContract;
|
|
379
|
+
private provider;
|
|
380
|
+
private account?;
|
|
381
|
+
constructor(stelaContract: Contract, provider: RpcProvider, account?: Account | undefined);
|
|
382
|
+
/** Get the Locker TBA address for an inscription */
|
|
383
|
+
getLockerAddress(inscriptionId: bigint): Promise<string>;
|
|
384
|
+
/** Check if a locker is unlocked */
|
|
385
|
+
isUnlocked(inscriptionId: bigint): Promise<boolean>;
|
|
386
|
+
/** Get full locker state */
|
|
387
|
+
getLockerState(inscriptionId: bigint): Promise<LockerState>;
|
|
388
|
+
/** Read ERC20 balance held by a locker */
|
|
389
|
+
getLockerBalance(inscriptionId: bigint, tokenAddress: string): Promise<bigint>;
|
|
390
|
+
/** Read multiple ERC20 balances held by a locker */
|
|
391
|
+
getLockerBalances(inscriptionId: bigint, tokenAddresses: string[]): Promise<Map<string, bigint>>;
|
|
392
|
+
/**
|
|
393
|
+
* Build a Call to execute an arbitrary call through the Locker TBA.
|
|
394
|
+
* The Locker's __execute__ function proxies calls from the locker's address.
|
|
395
|
+
* This is how a DAO retains governance power over locked collateral.
|
|
396
|
+
*
|
|
397
|
+
* The locker uses SNIP-6 account standard (__execute__). The calldata
|
|
398
|
+
* encodes an array of Call structs, each with:
|
|
399
|
+
* - to: felt252 (ContractAddress)
|
|
400
|
+
* - selector: felt252
|
|
401
|
+
* - calldata: Array<felt252> (length-prefixed)
|
|
402
|
+
*/
|
|
403
|
+
buildLockerExecute(lockerAddress: string, innerCalls: Call[]): Call;
|
|
404
|
+
/**
|
|
405
|
+
* Execute a governance call through the Locker.
|
|
406
|
+
* Requires account to be the inscription's borrower (NFT owner).
|
|
407
|
+
*/
|
|
408
|
+
executeThrough(inscriptionId: bigint, innerCall: Call): Promise<{
|
|
409
|
+
transaction_hash: string;
|
|
410
|
+
}>;
|
|
411
|
+
/**
|
|
412
|
+
* Execute multiple governance calls through the Locker in a single tx.
|
|
413
|
+
*/
|
|
414
|
+
executeThroughBatch(inscriptionId: bigint, innerCalls: Call[]): Promise<{
|
|
415
|
+
transaction_hash: string;
|
|
416
|
+
}>;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
interface ApiClientOptions {
|
|
420
|
+
baseUrl?: string;
|
|
421
|
+
}
|
|
422
|
+
interface ListInscriptionsParams {
|
|
423
|
+
status?: string;
|
|
424
|
+
address?: string;
|
|
425
|
+
page?: number;
|
|
426
|
+
limit?: number;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* HTTP client for the Stela indexer API.
|
|
430
|
+
* Provides typed access to indexed inscription data, treasury views, and locker info.
|
|
431
|
+
*/
|
|
432
|
+
declare class ApiClient {
|
|
433
|
+
private baseUrl;
|
|
434
|
+
constructor(opts?: ApiClientOptions);
|
|
435
|
+
/** List inscriptions with optional filters */
|
|
436
|
+
listInscriptions(params?: ListInscriptionsParams): Promise<ApiListResponse<InscriptionRow>>;
|
|
437
|
+
/** Get a single inscription by ID */
|
|
438
|
+
getInscription(id: string): Promise<ApiDetailResponse<InscriptionRow>>;
|
|
439
|
+
/** Get events for a specific inscription */
|
|
440
|
+
getInscriptionEvents(id: string): Promise<ApiListResponse<InscriptionEventRow>>;
|
|
441
|
+
/** Get treasury asset balances for an address */
|
|
442
|
+
getTreasuryView(address: string): Promise<ApiListResponse<TreasuryAsset>>;
|
|
443
|
+
/** Get locker info for inscriptions of an address */
|
|
444
|
+
getLockers(address: string): Promise<ApiListResponse<LockerInfo>>;
|
|
445
|
+
/** Get share balances for an address */
|
|
446
|
+
getShareBalances(address: string): Promise<ApiListResponse<ShareBalance>>;
|
|
447
|
+
private get;
|
|
448
|
+
}
|
|
449
|
+
declare class ApiError extends Error {
|
|
450
|
+
readonly status: number;
|
|
451
|
+
readonly url: string;
|
|
452
|
+
constructor(status: number, message: string, url: string);
|
|
453
|
+
}
|
|
454
|
+
/** Shape of an inscription event row from the API */
|
|
455
|
+
interface InscriptionEventRow {
|
|
456
|
+
id: number;
|
|
457
|
+
inscription_id: string;
|
|
458
|
+
event_type: string;
|
|
459
|
+
tx_hash: string;
|
|
460
|
+
block_number: number;
|
|
461
|
+
timestamp: string | null;
|
|
462
|
+
data: Record<string, unknown> | null;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
interface StelaSdkOptions {
|
|
466
|
+
/** StarkNet RPC provider */
|
|
467
|
+
provider: RpcProvider;
|
|
468
|
+
/** Connected account for write operations (optional for read-only) */
|
|
469
|
+
account?: Account;
|
|
470
|
+
/** Network name or auto-detect from provider */
|
|
471
|
+
network?: Network | string;
|
|
472
|
+
/** Custom API base URL */
|
|
473
|
+
apiBaseUrl?: string;
|
|
474
|
+
/** Override the contract address (for custom deployments) */
|
|
475
|
+
stelaAddress?: string;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Main SDK facade that wires together all clients.
|
|
479
|
+
*
|
|
480
|
+
* ```ts
|
|
481
|
+
* const sdk = new StelaSdk({ provider, account, network: 'sepolia' })
|
|
482
|
+
* const inscription = await sdk.inscriptions.getInscription(1n)
|
|
483
|
+
* const shares = await sdk.shares.balanceOf(myAddress, 1n)
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
declare class StelaSdk {
|
|
487
|
+
readonly inscriptions: InscriptionClient;
|
|
488
|
+
readonly shares: ShareClient;
|
|
489
|
+
readonly locker: LockerClient;
|
|
490
|
+
readonly api: ApiClient;
|
|
491
|
+
readonly network: Network;
|
|
492
|
+
readonly stelaAddress: string;
|
|
493
|
+
constructor(opts: StelaSdkOptions);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, type ApiClientOptions, type ApiDetailResponse, ApiError, type ApiListResponse, type Asset, type AssetRow, type AssetType, type Call, type Inscription, type InscriptionCancelledEvent, InscriptionClient, type InscriptionClientOptions, type InscriptionCreatedEvent, type InscriptionEventRow, type InscriptionLiquidatedEvent, type InscriptionParams, type InscriptionRepaidEvent, type InscriptionRow, type InscriptionSignedEvent, type InscriptionStatus, type ListInscriptionsParams, type LockerCall, LockerClient, type LockerInfo, type LockerState, MAX_BPS, type Network, type RawEvent, SELECTORS, STATUS_LABELS, STELA_ADDRESS, type ShareBalance, ShareClient, type ShareClientOptions, type SharesRedeemedEvent, type StatusInput, type StelaEvent, StelaSdk, type StelaSdkOptions, type StoredInscription, TOKENS, type TokenInfo, type TransferSingleEvent, type TreasuryAsset, VALID_STATUSES, VIRTUAL_SHARE_OFFSET, addressesEqual, calculateFeeShares, computeStatus, convertToShares, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, getTokensForNetwork, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, sharesToPercentage, toHex, toU256 };
|