@fizzyflow/endless-vector 0.0.7 → 0.0.10

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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { SuiClient, GetObjectParams, GetDynamicFieldsParams } from '@mysten/sui/client';
1
+ import type { SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import type { Transaction, TransactionResult, TransactionObjectArgument } from '@mysten/sui/transactions';
3
+ import type { Signer } from '@mysten/sui/cryptography';
3
4
 
4
5
  /**
5
6
  * Custom function to sign and execute transactions
@@ -10,22 +11,38 @@ export type CustomSignAndExecuteTransactionFunction = (tx: Transaction) => Promi
10
11
  * Configuration parameters for creating an EndlessVector instance
11
12
  */
12
13
  export interface EndlessVectorConstructorParams {
13
- /** Sui client instance for blockchain interactions */
14
- suiClient?: SuiClient;
14
+ /** Sui gRPC client instance for blockchain interactions */
15
+ suiClient?: SuiGrpcClient;
15
16
  /** ID or address of the EndlessVector on the Sui blockchain */
16
17
  id?: string;
17
18
  /** Adds write capability if provided, ID of the Move package containing the EndlessVector module or 'mainnet', 'testnet' to use known IDs */
18
19
  packageId?: string | null;
19
20
  /** Adds write capability if provided, function should accept Sui transaction, sign and submit it to the blockchain and return its digest */
20
21
  signAndExecuteTransaction?: CustomSignAndExecuteTransactionFunction | null;
22
+ /** Walrus SDK client for blob reads and writes */
23
+ walrusClient?: any | null;
24
+ /** Walrus publisher HTTP URL for blob uploads (fallback if no walrusClient) */
25
+ publisherUrl?: string | null;
26
+ /** Walrus aggregator HTTP URL for blob reads (fallback if no walrusClient) */
27
+ aggregatorUrl?: string | null;
28
+ /** Sui address of the transaction sender, required for Walrus blob writes */
29
+ senderAddress?: string | null;
30
+ /** SealClient for Seal encryption/decryption */
31
+ sealClient?: any | null;
32
+ /** Pre-built SessionKey for Seal operations */
33
+ sessionKey?: any | null;
34
+ /** Keypair or signer to mint a SessionKey when needed */
35
+ signer?: Signer | null;
36
+ /** SessionKey TTL in minutes (default: 5) */
37
+ sealTtlMin?: number;
21
38
  }
22
39
 
23
40
  /**
24
41
  * Configuration parameters for creating a new EndlessVector via static create method
25
42
  */
26
43
  export interface EndlessVectorCreateParams {
27
- /** Sui client instance for blockchain interactions */
28
- suiClient: SuiClient;
44
+ /** Sui gRPC client instance for blockchain interactions */
45
+ suiClient: SuiGrpcClient;
29
46
  /** ID of the Move package containing the EndlessVector module */
30
47
  packageId: string;
31
48
  /** Function to sign and execute transactions */
@@ -41,6 +58,20 @@ export interface EndlessVectorCreateParams {
41
58
  /** Poll interval in ms, default 1000 */
42
59
  pollIntervalMs?: number;
43
60
  };
61
+ /** Walrus SDK client for blob reads and writes */
62
+ walrusClient?: any | null;
63
+ /** Walrus aggregator HTTP URL for blob reads (fallback if no walrusClient) */
64
+ aggregatorUrl?: string | null;
65
+ /** Sui address of the transaction sender, required for Walrus blob writes */
66
+ senderAddress?: string | null;
67
+ /** SealClient — when provided, the vector is created with Seal encryption */
68
+ sealClient?: any | null;
69
+ /** Pre-built SessionKey for Seal operations */
70
+ sessionKey?: any | null;
71
+ /** Keypair or signer to mint a SessionKey when needed */
72
+ signer?: Signer | null;
73
+ /** SessionKey TTL in minutes (default: 5) */
74
+ sealTtlMin?: number;
44
75
  }
45
76
 
46
77
  /**
@@ -65,8 +96,8 @@ export interface TransactionOptions {
65
96
  * Configuration parameters for creating an EndlessVectorHistory instance
66
97
  */
67
98
  export interface EndlessVectorHistoryConstructorParams {
68
- /** Sui client instance for blockchain interactions */
69
- suiClient?: SuiClient;
99
+ /** Sui gRPC client instance for blockchain interactions */
100
+ suiClient?: SuiGrpcClient;
70
101
  /** Unique identifier for this history item */
71
102
  id?: string;
72
103
  /** Index position of this history item in the sequence */
@@ -83,8 +114,8 @@ export interface EndlessVectorHistoryConstructorParams {
83
114
  * Configuration parameters for creating an EndlessVectorArchive instance
84
115
  */
85
116
  export interface EndlessVectorArchiveConstructorParams {
86
- /** Sui client instance for blockchain interactions */
87
- suiClient?: SuiClient;
117
+ /** Sui gRPC client instance for blockchain interactions */
118
+ suiClient?: SuiGrpcClient;
88
119
  /** ID or address of the EndlessVectorArchive on the Sui blockchain */
89
120
  id?: string;
90
121
  /** Index position of this archive item in the sequence */
@@ -96,72 +127,144 @@ export interface EndlessVectorArchiveConstructorParams {
96
127
  }
97
128
 
98
129
  /**
99
- * Represents a history item in an EndlessVector, managing a segment of the vector's data.
100
- * Each history item stores a portion of the vector's elements and maintains metadata
101
- * about its position and relationships with adjacent history items.
130
+ * Represents a single item stored in an EndlessVector.
131
+ * Items can be bytes (on-chain), blob (Walrus-stored), or empty.
102
132
  */
103
- export declare class EndlessVectorHistory {
104
- suiClient: SuiClient;
105
- id: string;
106
- index: number;
133
+ declare class EndlessVectorItem {
134
+ type: 'bytes' | 'blob' | 'empty';
135
+ meta: Uint8Array;
136
+
137
+ constructor(params?: {
138
+ type?: 'bytes' | 'blob' | 'empty';
139
+ bytes?: Uint8Array | null;
140
+ blobData?: any | null;
141
+ meta?: Uint8Array;
142
+ endlessVector?: EndlessVector | null;
143
+ endlessVectorHistory?: EndlessVectorHistory | null;
144
+ });
145
+
146
+ get isBytes(): boolean;
147
+ get isBlob(): boolean;
148
+ get isEmpty(): boolean;
149
+ get size(): number;
150
+
151
+ bytes(): Promise<Uint8Array>;
152
+ blobData(): any | null;
153
+
154
+ static fromGrpcJson(raw: any, context?: {
155
+ endlessVector?: EndlessVector | null;
156
+ endlessVectorHistory?: EndlessVectorHistory | null;
157
+ }): EndlessVectorItem;
158
+
159
+ static concatBytes(head: EndlessVectorItem, tail: EndlessVectorItem): Uint8Array;
160
+ }
107
161
 
108
- constructor(params?: EndlessVectorHistoryConstructorParams);
162
+ /**
163
+ * Walrus blob read/write companion for EndlessVector.
164
+ * Attached as `endlessVector.walrus` on every EndlessVector instance.
165
+ */
166
+ declare class EndlessVectorWalrus {
167
+ constructor(params?: {
168
+ endlessVector?: EndlessVector;
169
+ walrusClient?: any | null;
170
+ publisherUrl?: string | null;
171
+ aggregatorUrl?: string | null;
172
+ senderAddress?: string | null;
173
+ });
109
174
 
175
+ readBlobBytes(blobData: any): Promise<Uint8Array>;
110
176
  /**
111
- * Sets the fields data for this history item. Called by loader of EndlessVector.
177
+ * Minimum Walrus storage `end_epoch` across every Blob in this vector (items +
178
+ * history + non-burned archive), read on-chain via transaction simulation.
179
+ * Resolves to `null` when the vector holds no blobs.
112
180
  */
113
- setFields(fields: any): void;
114
-
181
+ minBlobEndEpoch(): Promise<number | null>;
115
182
  /**
116
- * Checks if this history item has been initialized and is ready for use.
183
+ * Exact WAL cost (FROST) to bring every blob up to `targetEndEpoch` via
184
+ * {@link extendBlobsToEpoch}, read on-chain via simulation. `0n` if nothing needs it.
117
185
  */
118
- isReady(): boolean;
119
-
186
+ extendBlobsCostToEpoch(targetEndEpoch: number): Promise<bigint>;
120
187
  /**
121
- * Initializes this history item by loading its data from the blockchain.
122
- * Uses promise-based synchronization to prevent multiple concurrent initializations.
188
+ * Builds (without executing) the transaction that extends every blob up to
189
+ * `targetEndEpoch`. Sources/returns the WAL payment automatically unless `walCoin` is given.
123
190
  */
124
- initialize(): Promise<boolean>;
125
-
191
+ getExtendBlobsToEpochTransaction(targetEndEpoch: number, params?: {
192
+ cost?: bigint;
193
+ walCoin?: TransactionObjectArgument;
194
+ txToAppendTo?: Transaction | null;
195
+ }): Promise<Transaction>;
126
196
  /**
127
- * Gets the last index position that this history item covers.
197
+ * Extends every blob up to `targetEndEpoch` in one transaction; resolves to the new
198
+ * minimum blob end epoch.
128
199
  */
129
- get endsAt(): number | undefined;
200
+ extendBlobsToEpoch(targetEndEpoch: number, params?: {
201
+ cost?: bigint;
202
+ walCoin?: TransactionObjectArgument;
203
+ timeout?: number;
204
+ pollIntervalMs?: number;
205
+ }): Promise<number | null>;
206
+ getPushBlobTransaction(blobObjectId: string, txToAppendTo?: Transaction | null): Transaction;
207
+ pushBlob(data: Uint8Array, params?: {
208
+ epochs?: number;
209
+ deletable?: boolean;
210
+ timeout?: number;
211
+ pollIntervalMs?: number;
212
+ }): Promise<{ blobId: string; blobObjectId: string }>;
213
+ }
130
214
 
131
- /**
132
- * Indicates whether the first item in this history contains suffix bytes that should be
133
- * added to the last item from the previous history segment.
134
- */
135
- get firstItemIsFromPreviousHistory(): boolean;
215
+ /**
216
+ * Seal encryption companion for EndlessVector.
217
+ * Attached as `endlessVector.seal` on every EndlessVector instance;
218
+ * only active when a sealClient is supplied at construction time.
219
+ */
220
+ declare class EndlessVectorSeal {
221
+ _sessionKey: any | null;
222
+
223
+ constructor(params?: {
224
+ endlessVector?: EndlessVector;
225
+ sealClient?: any | null;
226
+ sessionKey?: any | null;
227
+ signer?: any | null;
228
+ sealTtlMin?: number;
229
+ });
230
+
231
+ get isEnabled(): boolean;
232
+
233
+ static generateAesKey(): Uint8Array;
234
+ setAesKey(key: Uint8Array): void;
235
+ wrapAesKey(aesKey: Uint8Array): Promise<Uint8Array>;
236
+ encryptItem(plaintext: Uint8Array): Promise<Uint8Array>;
237
+ decryptItem(payload: Uint8Array): Promise<Uint8Array>;
238
+ }
136
239
 
137
- /**
138
- * Gets the first index position that this history item covers.
139
- */
140
- get startsAt(): number;
240
+ /**
241
+ * Represents a history item in an EndlessVector, managing a segment of the vector's data.
242
+ */
243
+ declare class EndlessVectorHistory {
244
+ suiClient: SuiGrpcClient;
245
+ id: string;
246
+ index: number;
141
247
 
142
- /**
143
- * Gets the number of bytes from the next history item that should be appended
144
- * to the last item in this history segment.
145
- */
248
+ constructor(params?: EndlessVectorHistoryConstructorParams);
249
+
250
+ setFields(fields: any): void;
251
+ isReady(): boolean;
252
+ initialize(): Promise<boolean>;
253
+
254
+ get endsAt(): number | undefined;
255
+ get firstItemIsFromPreviousHistory(): boolean;
256
+ get startsAt(): number;
146
257
  get followedByNextBytes(): number;
147
258
 
148
- /**
149
- * Retrieves the byte array at the specified index within this history segment.
150
- */
151
259
  at(i: number): Promise<Uint8Array>;
152
-
153
- /**
154
- * Gets the suffix bytes stored in this history item that should be appended
155
- * to the last item of the previous history segment.
156
- */
157
- getSuffixStoredBytes(): Uint8Array;
260
+ getSuffixStoredBytes(): Promise<Uint8Array>;
158
261
  }
159
262
 
160
263
  /**
161
264
  * Represents an archive item in an EndlessVector
162
265
  */
163
- export declare class EndlessVectorArchive {
164
- suiClient: SuiClient;
266
+ declare class EndlessVectorArchive {
267
+ suiClient: SuiGrpcClient;
165
268
  id: string;
166
269
  index: number;
167
270
  historyTableId: string | null;
@@ -169,59 +272,25 @@ export declare class EndlessVectorArchive {
169
272
 
170
273
  constructor(params?: EndlessVectorArchiveConstructorParams);
171
274
 
172
- /**
173
- * Sets the fields data for this archive item. Called by loader of EndlessVector.
174
- */
175
275
  setFields(fields: any): void;
176
-
177
- /**
178
- * Checks if this archive item has been initialized and is ready for use.
179
- */
180
276
  isReady(): boolean;
181
277
 
182
- /**
183
- * Gets the total number of items stored in this archive.
184
- */
185
278
  get length(): number;
186
-
187
- /**
188
- * Gets the first index position that this archive covers.
189
- */
190
279
  get startsAt(): number;
191
-
192
- /**
193
- * Gets the last index position that this archive covers.
194
- */
195
280
  get endsAt(): number | undefined;
196
281
 
197
- /**
198
- * Initializes this archive item by loading its data from the blockchain.
199
- */
200
282
  initialize(): Promise<boolean>;
201
-
202
- /**
203
- * Gets a history item within this archive by its index.
204
- */
205
283
  getHistory(historyIndex: number | string): Promise<EndlessVectorHistory>;
206
-
207
- /**
208
- * Retrieves the byte array at the specified index within this archive.
209
- */
210
284
  at(i: number): Promise<Uint8Array>;
211
-
212
- /**
213
- * Gets suffix bytes from a history item at the specified index within this archive.
214
- */
215
285
  getSuffixFromHistoryItemOfIndex(i: number): Promise<Uint8Array>;
216
286
  }
217
287
 
218
288
  /**
219
289
  * Represents an endless vector data structure that can grow beyond Sui object size limits
220
- * by storing overflow data in history items. Provides seamless access to all elements regardless
221
- * of whether they're stored in the current object or historical segments.
290
+ * by storing overflow data in history items.
222
291
  */
223
- export declare class EndlessVector {
224
- suiClient: SuiClient;
292
+ declare class EndlessVector {
293
+ suiClient: SuiGrpcClient;
225
294
  id: string;
226
295
  binaryLength: number;
227
296
  length: number;
@@ -233,26 +302,26 @@ export declare class EndlessVector {
233
302
  archivedAtLength: number;
234
303
  archivedFromLength: number;
235
304
  burnedArchiveCount: number;
305
+ sealEncryptedKey: Uint8Array | null;
306
+ seal: EndlessVectorSeal;
307
+ walrus: EndlessVectorWalrus;
236
308
 
237
309
  constructor(params?: EndlessVectorConstructorParams);
238
310
 
239
- /**
240
- * Static factory method to create a new empty EndlessVector on the blockchain.
241
- */
311
+ get packageId(): string | null;
312
+
313
+ static getPackageId(network: string): string | null;
314
+
315
+ isEncrypted(): Promise<boolean>;
316
+
242
317
  static create(params: EndlessVectorCreateParams): Promise<EndlessVector>;
243
318
 
244
- /**
245
- * Creates an empty EndlessVector and returns the vector input reference.
246
- */
247
319
  static getCreateTransactionAndReturnVectorInput(
248
320
  params: GetCreateTransactionParams,
249
321
  arr?: Uint8Array | null,
250
322
  txToAppendTo?: Transaction | null
251
323
  ): Promise<TransactionResult>;
252
324
 
253
- /**
254
- * Attach move calls to transaction, to push item into endlessvector, handling large arrays by chunking them.
255
- */
256
325
  static composePushTransaction(
257
326
  packageId: string,
258
327
  vectorInput: TransactionObjectArgument,
@@ -260,89 +329,44 @@ export declare class EndlessVector {
260
329
  tx: Transaction
261
330
  ): Transaction;
262
331
 
263
- /**
264
- * Check if the EndlessVector instance is writable
265
- */
266
332
  get isWritable(): boolean;
267
-
268
- /**
269
- * Gets the first index that is stored in the current EndlessVector object (not in history items).
270
- */
271
333
  get firstNotHistoryIndex(): number;
272
334
 
273
- /**
274
- * Forces re-initialization of the EndlessVector to reload data from the blockchain.
275
- */
276
335
  reInitialize(): void;
277
-
278
- /**
279
- * Initializes the EndlessVector by loading data from the Sui blockchain.
280
- */
281
336
  initialize(): Promise<void>;
282
337
 
283
- /**
284
- * Gets a history item by its index, loading it from the blockchain if needed.
285
- */
286
338
  getHistory(historyIndex: number | string): Promise<EndlessVectorHistory>;
287
-
288
- /**
289
- * Gets an archive item by its index, loading it from the blockchain if needed.
290
- */
291
339
  getArchive(archiveIndex: number | string): Promise<EndlessVectorArchive>;
292
340
 
293
- /**
294
- * Loads multiple history items in a single batch request for efficiency.
295
- */
296
341
  loadHistoryItemsBunch(historyItems: EndlessVectorHistory[]): Promise<void>;
297
-
298
- /**
299
- * Loads a single history item, batching requests for efficiency.
300
- */
301
342
  loadHistoryItem(historyItem: EndlessVectorHistory): Promise<EndlessVectorHistory>;
302
-
303
- /**
304
- * Loads multiple archive items in a single batch request for efficiency.
305
- */
306
343
  loadArchiveItemsBunch(archiveItems: EndlessVectorArchive[]): Promise<void>;
307
-
308
- /**
309
- * Loads a single archive item, batching requests for efficiency.
310
- */
311
344
  loadArchiveItem(archiveItem: EndlessVectorArchive): Promise<EndlessVectorArchive>;
312
345
 
313
- /**
314
- * Retrieves the byte array at the specified index from either current items or history.
315
- */
316
346
  at(i: number): Promise<Uint8Array>;
317
-
318
- /**
319
- * Gets suffix bytes from a history item at the specified index.
320
- */
321
347
  getSuffixFromHistoryItemOfIndex(i: number): Promise<Uint8Array | undefined>;
322
348
 
323
- /**
324
- * Creates a transaction to push new byte arrays to the EndlessVector.
325
- */
326
349
  getPushTransaction(arr: Uint8Array | Uint8Array[], txToAppendTo?: Transaction | null): Transaction;
327
-
328
- /**
329
- * Pushes new byte array to the EndlessVector, creating and executing the necessary transaction.
330
- */
331
350
  push(arr: Uint8Array | Uint8Array[], params?: TransactionOptions): Promise<boolean>;
332
351
 
333
- /**
334
- * Creates a transaction to concatenate EndlessVector(s) into this one.
335
- */
336
352
  getConcatTransaction(
337
353
  other: string | EndlessVector | Array<string | EndlessVector>,
338
354
  txToAppendTo?: Transaction | null
339
355
  ): Transaction;
340
-
341
- /**
342
- * Concatenates EndlessVector(s) into this one, creating and executing the necessary transaction.
343
- */
344
356
  concat(other: string | EndlessVector | Array<string | EndlessVector>, params?: TransactionOptions): Promise<boolean>;
357
+
358
+ getArchiveTransaction(txToAppendTo?: Transaction | null): Transaction;
359
+ archive(params?: TransactionOptions): Promise<boolean>;
360
+
361
+ getBurnArchiveTransaction(txToAppendTo?: Transaction | null): Transaction;
362
+ burnArchive(params?: TransactionOptions): Promise<boolean>;
363
+
364
+ executeAndWaitForTransaction(tx: Transaction, params?: {
365
+ timeout?: number;
366
+ pollIntervalMs?: number;
367
+ include?: any;
368
+ }): Promise<any>;
345
369
  }
346
370
 
347
371
  export { EndlessVector as default };
348
- export { EndlessVector, EndlessVectorArchive, EndlessVectorHistory };
372
+ export { EndlessVector, EndlessVectorArchive, EndlessVectorHistory, EndlessVectorItem, EndlessVectorWalrus, EndlessVectorSeal };
package/index.js CHANGED
@@ -1,10 +1,14 @@
1
1
  import EndlessVector from "./EndlessVector.js";
2
2
  import EndlessVectorArchive from "./EndlessVectorArchive.js";
3
3
  import EndlessVectorHistory from "./EndlessVectorHistory.js";
4
+ import EndlessVectorItem from "./EndlessVectorItem.js";
5
+ import EndlessVectorWalrus from "./EndlessVectorWalrus.js";
4
6
 
5
7
  export {
6
8
  EndlessVector as default,
7
9
  EndlessVector,
8
10
  EndlessVectorArchive,
9
- EndlessVectorHistory
11
+ EndlessVectorHistory,
12
+ EndlessVectorItem,
13
+ EndlessVectorWalrus,
10
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fizzyflow/endless-vector",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -23,15 +23,25 @@
23
23
  "access": "public"
24
24
  },
25
25
  "author": "suidouble (https://github.com/suidouble)",
26
- "license": "Apache-2.0",
26
+ "license": "AGPL-3.0",
27
27
  "scripts": {
28
- "test": "tap -j1 -t320 ./test/*.test.js"
28
+ "test": "vitest run ./test/*.test.js",
29
+ "test:walrus-blobs": "vitest run ./test/walrus_blobs.test.js",
30
+ "test:walrus-blobs-sdk": "vitest run ./test/walrus_blobs_sdk.test.js",
31
+ "test:walrus-blobs-history": "vitest run --config vitest.config.js ./test/walrus_blobs_history.test.js",
32
+ "test:walrus-blobs-extend": "vitest run --config vitest.config.js ./test/walrus_blobs_extend.test.js",
33
+ "test:base": "vitest run ./test/base.test.js",
34
+ "test:seal": "vitest run --config vitest.config.js ./test/seal.test.js"
29
35
  },
30
36
  "peerDependencies": {
31
- "@mysten/sui": "^1.45.0"
37
+ "@mysten/sui": "^2.16.0"
32
38
  },
33
39
  "devDependencies": {
34
- "suidouble": "^1.45.0",
35
- "tap": "^21.1.0"
40
+ "@mysten/seal": "^1.1.3",
41
+ "@mysten/sui": "^2.16.0",
42
+ "@noble/ciphers": "^2.2.0",
43
+ "suidouble": "^2.16.0",
44
+ "tap": "^21.1.0",
45
+ "vitest": "^3.2.0"
36
46
  }
37
47
  }