@mysten/walrus 1.0.4 → 1.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.
@@ -0,0 +1,227 @@
1
+ import { WalrusClientError } from "../error.mjs";
2
+ import { CertificateBcs, parseCertificateFromBase64 } from "../utils/bcs.mjs";
3
+ import { fromBase64, toBase64 } from "@mysten/bcs";
4
+ import { Transaction } from "@mysten/sui/transactions";
5
+
6
+ //#region src/flows/write-blob.ts
7
+ function createWriteBlobFlow(client, ctx, options) {
8
+ const { resume } = options;
9
+ let encodeState;
10
+ let registerState;
11
+ let uploadState;
12
+ let certifyState;
13
+ const resumeBlobObjectId = resume && "blobObjectId" in resume ? resume.blobObjectId : void 0;
14
+ const resumeTxDigest = resume && "txDigest" in resume ? resume.txDigest : void 0;
15
+ const resumeNonce = resume && "nonce" in resume && resume.nonce ? fromBase64(resume.nonce) : void 0;
16
+ const resumeBlobId = resume ? resume.blobId : void 0;
17
+ const encode = async () => {
18
+ if (!encodeState) {
19
+ const { blob } = options;
20
+ const hasUploadRelay = ctx.hasUploadRelay();
21
+ const metadata$1 = hasUploadRelay ? await client.computeBlobMetadata({
22
+ bytes: blob,
23
+ nonce: resumeNonce
24
+ }) : await client.encodeBlob(blob);
25
+ if (resumeBlobId && metadata$1.blobId !== resumeBlobId) throw new WalrusClientError(`Resume blobId mismatch: expected ${resumeBlobId}, got ${metadata$1.blobId}. The blob content may have changed.`);
26
+ encodeState = {
27
+ metadata: metadata$1,
28
+ size: blob.length,
29
+ data: hasUploadRelay ? blob : void 0
30
+ };
31
+ }
32
+ const { metadata, size } = encodeState;
33
+ return {
34
+ step: "encoded",
35
+ blobId: metadata.blobId,
36
+ rootHash: toBase64(metadata.rootHash),
37
+ unencodedSize: size,
38
+ ..."nonce" in metadata ? { nonce: toBase64(metadata.nonce) } : {}
39
+ };
40
+ };
41
+ const register = ({ epochs, deletable, owner, attributes }) => {
42
+ if (!encodeState) throw new Error("encode must be executed before calling register");
43
+ const { metadata, size } = encodeState;
44
+ const transaction = new Transaction();
45
+ transaction.setSenderIfNotSet(owner);
46
+ if (ctx.hasUploadRelay()) {
47
+ const meta = metadata;
48
+ transaction.add(client.sendUploadRelayTip({
49
+ size,
50
+ blobDigest: meta.blobDigest,
51
+ nonce: meta.nonce
52
+ }));
53
+ }
54
+ transaction.transferObjects([client.registerBlob({
55
+ size,
56
+ epochs,
57
+ blobId: metadata.blobId,
58
+ rootHash: metadata.rootHash,
59
+ deletable,
60
+ attributes
61
+ })], owner);
62
+ registerState = {
63
+ ...encodeState,
64
+ deletable
65
+ };
66
+ return transaction;
67
+ };
68
+ const upload = async (options$1) => {
69
+ if (!encodeState) throw new Error("encode must be executed before calling upload");
70
+ const { metadata, data } = encodeState;
71
+ const deletable = options$1?.deletable ?? registerState?.deletable ?? false;
72
+ let blobObject;
73
+ if (resumeBlobObjectId) blobObject = await client.getBlobObject(resumeBlobObjectId);
74
+ else if (options$1?.digest) blobObject = await ctx.getCreatedBlob(options$1.digest);
75
+ else throw new Error("Either resume.blobObjectId or upload digest must be provided");
76
+ let certificate;
77
+ if (ctx.hasUploadRelay()) {
78
+ const meta = metadata;
79
+ certificate = (await client.writeBlobToUploadRelay({
80
+ blobId: metadata.blobId,
81
+ blob: data,
82
+ nonce: meta.nonce,
83
+ txDigest: options$1?.digest ?? resumeTxDigest,
84
+ blobObjectId: blobObject.id,
85
+ deletable,
86
+ encodingType: meta.metadata.encodingType,
87
+ signal: options$1?.signal
88
+ })).certificate;
89
+ } else {
90
+ const meta = metadata;
91
+ const confirmations = await client.writeEncodedBlobToNodes({
92
+ blobId: metadata.blobId,
93
+ objectId: blobObject.id,
94
+ metadata: meta.metadata,
95
+ sliversByNode: meta.sliversByNode,
96
+ deletable,
97
+ signal: options$1?.signal
98
+ });
99
+ certificate = await client.certificateFromConfirmations({
100
+ confirmations,
101
+ blobId: metadata.blobId,
102
+ blobObjectId: blobObject.id,
103
+ deletable
104
+ });
105
+ }
106
+ uploadState = {
107
+ blobObject,
108
+ blobId: metadata.blobId,
109
+ deletable,
110
+ certificate
111
+ };
112
+ const txDigest = options$1?.digest ?? resumeTxDigest;
113
+ return {
114
+ step: "uploaded",
115
+ blobId: metadata.blobId,
116
+ blobObjectId: blobObject.id,
117
+ ...txDigest ? { txDigest } : {},
118
+ certificate: CertificateBcs.serialize(certificate).toBase64()
119
+ };
120
+ };
121
+ const certify = () => {
122
+ if (!uploadState) throw new Error("upload must be executed before calling certify");
123
+ const { blobObject, blobId, deletable, certificate } = uploadState;
124
+ const transaction = client.certifyBlobTransaction({
125
+ certificate,
126
+ blobId,
127
+ blobObjectId: blobObject.id,
128
+ deletable
129
+ });
130
+ certifyState = {
131
+ blobObject,
132
+ blobId,
133
+ transaction
134
+ };
135
+ return transaction;
136
+ };
137
+ const executeRegister = async ({ signer, ...options$1 }) => {
138
+ const transaction = register(options$1);
139
+ const { digest } = await ctx.executeTransaction(transaction, signer, "register blob");
140
+ return {
141
+ step: "registered",
142
+ blobId: encodeState.metadata.blobId,
143
+ blobObjectId: (await ctx.getCreatedBlob(digest)).id,
144
+ txDigest: digest,
145
+ ..."nonce" in encodeState.metadata ? { nonce: toBase64(encodeState.metadata.nonce) } : {}
146
+ };
147
+ };
148
+ const executeCertify = async ({ signer }) => {
149
+ const transaction = certify();
150
+ await ctx.executeTransaction(transaction, signer, "certify blob");
151
+ const blobObject = await ctx.loadBlobObject(uploadState.blobObject.id);
152
+ return {
153
+ step: "certified",
154
+ blobId: uploadState.blobId,
155
+ blobObjectId: blobObject.id,
156
+ blobObject
157
+ };
158
+ };
159
+ const getBlob = async () => {
160
+ if (!certifyState && !uploadState) throw new Error("upload or certify must be executed before calling getBlob");
161
+ const state = certifyState ?? uploadState;
162
+ const blobObject = await ctx.loadBlobObject(state.blobObject.id);
163
+ return {
164
+ step: "certified",
165
+ blobId: state.blobId,
166
+ blobObjectId: blobObject.id,
167
+ blobObject
168
+ };
169
+ };
170
+ const restoreUploadState = async (resumeData, deletable) => {
171
+ uploadState = {
172
+ blobObject: await client.getBlobObject(resumeData.blobObjectId),
173
+ blobId: resumeData.blobId,
174
+ deletable,
175
+ certificate: parseCertificateFromBase64(resumeData.certificate)
176
+ };
177
+ };
178
+ /** @yields {WriteBlobStep} */
179
+ async function* run(options$1) {
180
+ const resumeStep = resume?.step;
181
+ const stepOrder = [
182
+ "encoded",
183
+ "registered",
184
+ "uploaded",
185
+ "certified"
186
+ ];
187
+ const resumeIndex = resumeStep ? stepOrder.indexOf(resumeStep) : -1;
188
+ if (resumeIndex >= stepOrder.indexOf("certified")) return;
189
+ if (resumeIndex < stepOrder.indexOf("encoded")) yield await encode();
190
+ else if (resumeIndex < stepOrder.indexOf("uploaded")) await encode();
191
+ let registerDigest;
192
+ if (!resumeBlobObjectId) {
193
+ const regResult = await executeRegister({
194
+ signer: options$1.signer,
195
+ epochs: options$1.epochs,
196
+ deletable: options$1.deletable,
197
+ owner: options$1.owner ?? options$1.signer.toSuiAddress(),
198
+ attributes: options$1.attributes
199
+ });
200
+ registerDigest = regResult.txDigest;
201
+ yield regResult;
202
+ } else registerState = {
203
+ ...encodeState,
204
+ deletable: options$1.deletable
205
+ };
206
+ if (resumeIndex < stepOrder.indexOf("uploaded")) yield await upload({
207
+ digest: registerDigest ?? resumeTxDigest,
208
+ signal: options$1.signal
209
+ });
210
+ else await restoreUploadState(resume, options$1.deletable);
211
+ yield await executeCertify({ signer: options$1.signer });
212
+ }
213
+ return {
214
+ encode,
215
+ register,
216
+ upload,
217
+ certify,
218
+ getBlob,
219
+ executeRegister,
220
+ executeCertify,
221
+ run
222
+ };
223
+ }
224
+
225
+ //#endregion
226
+ export { createWriteBlobFlow };
227
+ //# sourceMappingURL=write-blob.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-blob.mjs","names":["metadata","options"],"sources":["../../src/flows/write-blob.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/bcs';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport type { Blob } from '../contracts/walrus/blob.js';\nimport { WalrusClientError } from '../error.js';\nimport type {\n\tEncodingType,\n\tProtocolMessageCertificate,\n\tSliversForNode,\n\tWriteBlobFlow,\n\tWriteBlobFlowOptions,\n\tWriteBlobFlowRegisterOptions,\n\tWriteBlobFlowRunOptions,\n\tWriteBlobFlowUploadOptions,\n\tWriteBlobStep,\n\tWriteBlobStepCertified,\n\tWriteBlobStepEncoded,\n\tWriteBlobStepRegistered,\n\tWriteBlobStepUploaded,\n} from '../types.js';\nimport { CertificateBcs, parseCertificateFromBase64 } from '../utils/bcs.js';\nimport type { WalrusClient } from '../client.js';\n\nexport interface WriteBlobFlowContext {\n\thasUploadRelay(): boolean;\n\texecuteTransaction(\n\t\ttransaction: Transaction,\n\t\tsigner: Signer,\n\t\taction: string,\n\t): Promise<{ digest: string }>;\n\tgetCreatedBlob(digest: string): Promise<(typeof Blob)['$inferType']>;\n\tloadBlobObject(objectId: string): Promise<(typeof Blob)['$inferType']>;\n}\n\ntype BlobMetadataResult = {\n\tblobId: string;\n\trootHash: Uint8Array;\n\tmetadata: { encodingType: string; unencodedLength: bigint };\n\tnonce: Uint8Array;\n\tblobDigest: () => Promise<Uint8Array>;\n};\n\ntype EncodeBlobResult = {\n\tblobId: string;\n\trootHash: Uint8Array;\n\tmetadata: Awaited<ReturnType<WalrusClient['encodeBlob']>>['metadata'];\n\tsliversByNode: SliversForNode[];\n};\n\ntype EncodeState = {\n\tmetadata: BlobMetadataResult | EncodeBlobResult;\n\tsize: number;\n\tdata?: Uint8Array;\n};\n\ntype RegisterState = EncodeState & { deletable: boolean };\n\ntype UploadState = {\n\tblobObject: (typeof Blob)['$inferType'];\n\tblobId: string;\n\tdeletable: boolean;\n\tcertificate: ProtocolMessageCertificate;\n};\n\ntype CertifyState = {\n\tblobObject: (typeof Blob)['$inferType'];\n\tblobId: string;\n\ttransaction: Transaction;\n};\n\nexport function createWriteBlobFlow(\n\tclient: WalrusClient,\n\tctx: WriteBlobFlowContext,\n\toptions: WriteBlobFlowOptions,\n): WriteBlobFlow {\n\tconst { resume } = options;\n\tlet encodeState: EncodeState | undefined;\n\tlet registerState: RegisterState | undefined;\n\tlet uploadState: UploadState | undefined;\n\tlet certifyState: CertifyState | undefined;\n\n\tconst resumeBlobObjectId = resume && 'blobObjectId' in resume ? resume.blobObjectId : undefined;\n\tconst resumeTxDigest = resume && 'txDigest' in resume ? resume.txDigest : undefined;\n\tconst resumeNonce =\n\t\tresume && 'nonce' in resume && resume.nonce ? fromBase64(resume.nonce) : undefined;\n\tconst resumeBlobId = resume ? resume.blobId : undefined;\n\n\tconst encode = async (): Promise<WriteBlobStepEncoded> => {\n\t\tif (!encodeState) {\n\t\t\tconst { blob } = options;\n\t\t\tconst hasUploadRelay = ctx.hasUploadRelay();\n\t\t\tconst metadata = hasUploadRelay\n\t\t\t\t? await client.computeBlobMetadata({\n\t\t\t\t\t\tbytes: blob,\n\t\t\t\t\t\tnonce: resumeNonce,\n\t\t\t\t\t})\n\t\t\t\t: await client.encodeBlob(blob);\n\n\t\t\tif (resumeBlobId && metadata.blobId !== resumeBlobId) {\n\t\t\t\tthrow new WalrusClientError(\n\t\t\t\t\t`Resume blobId mismatch: expected ${resumeBlobId}, got ${metadata.blobId}. The blob content may have changed.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tencodeState = {\n\t\t\t\tmetadata,\n\t\t\t\tsize: blob.length,\n\t\t\t\tdata: hasUploadRelay ? blob : undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst { metadata, size } = encodeState!;\n\t\treturn {\n\t\t\tstep: 'encoded' as const,\n\t\t\tblobId: metadata.blobId,\n\t\t\trootHash: toBase64(metadata.rootHash),\n\t\t\tunencodedSize: size,\n\t\t\t...('nonce' in metadata ? { nonce: toBase64(metadata.nonce) } : {}),\n\t\t};\n\t};\n\n\tconst register = ({ epochs, deletable, owner, attributes }: WriteBlobFlowRegisterOptions) => {\n\t\tif (!encodeState) {\n\t\t\tthrow new Error('encode must be executed before calling register');\n\t\t}\n\n\t\tconst { metadata, size } = encodeState;\n\t\tconst transaction = new Transaction();\n\t\ttransaction.setSenderIfNotSet(owner);\n\n\t\tif (ctx.hasUploadRelay()) {\n\t\t\tconst meta = metadata as BlobMetadataResult;\n\t\t\ttransaction.add(\n\t\t\t\tclient.sendUploadRelayTip({\n\t\t\t\t\tsize,\n\t\t\t\t\tblobDigest: meta.blobDigest,\n\t\t\t\t\tnonce: meta.nonce,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\ttransaction.transferObjects(\n\t\t\t[\n\t\t\t\tclient.registerBlob({\n\t\t\t\t\tsize,\n\t\t\t\t\tepochs,\n\t\t\t\t\tblobId: metadata.blobId,\n\t\t\t\t\trootHash: metadata.rootHash,\n\t\t\t\t\tdeletable,\n\t\t\t\t\tattributes,\n\t\t\t\t}),\n\t\t\t],\n\t\t\towner,\n\t\t);\n\n\t\tregisterState = { ...encodeState, deletable };\n\n\t\treturn transaction;\n\t};\n\n\tconst upload = async (options?: WriteBlobFlowUploadOptions): Promise<WriteBlobStepUploaded> => {\n\t\tif (!encodeState) {\n\t\t\tthrow new Error('encode must be executed before calling upload');\n\t\t}\n\n\t\tconst { metadata, data } = encodeState;\n\t\tconst deletable = options?.deletable ?? registerState?.deletable ?? false;\n\n\t\tlet blobObject: (typeof Blob)['$inferType'];\n\t\tif (resumeBlobObjectId) {\n\t\t\tblobObject = await client.getBlobObject(resumeBlobObjectId);\n\t\t} else if (options?.digest) {\n\t\t\tblobObject = await ctx.getCreatedBlob(options.digest);\n\t\t} else {\n\t\t\tthrow new Error('Either resume.blobObjectId or upload digest must be provided');\n\t\t}\n\n\t\tlet certificate: ProtocolMessageCertificate;\n\t\tif (ctx.hasUploadRelay()) {\n\t\t\tconst meta = metadata as BlobMetadataResult;\n\t\t\tcertificate = (\n\t\t\t\tawait client.writeBlobToUploadRelay({\n\t\t\t\t\tblobId: metadata.blobId,\n\t\t\t\t\tblob: data!,\n\t\t\t\t\tnonce: meta.nonce,\n\t\t\t\t\ttxDigest: options?.digest ?? resumeTxDigest!,\n\t\t\t\t\tblobObjectId: blobObject.id,\n\t\t\t\t\tdeletable,\n\t\t\t\t\tencodingType: meta.metadata.encodingType as EncodingType,\n\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t})\n\t\t\t).certificate;\n\t\t} else {\n\t\t\tconst meta = metadata as EncodeBlobResult;\n\t\t\tconst confirmations = await client.writeEncodedBlobToNodes({\n\t\t\t\tblobId: metadata.blobId,\n\t\t\t\tobjectId: blobObject.id,\n\t\t\t\tmetadata: meta.metadata,\n\t\t\t\tsliversByNode: meta.sliversByNode,\n\t\t\t\tdeletable,\n\t\t\t\tsignal: options?.signal,\n\t\t\t});\n\n\t\t\tcertificate = await client.certificateFromConfirmations({\n\t\t\t\tconfirmations,\n\t\t\t\tblobId: metadata.blobId,\n\t\t\t\tblobObjectId: blobObject.id,\n\t\t\t\tdeletable,\n\t\t\t});\n\t\t}\n\n\t\tuploadState = { blobObject, blobId: metadata.blobId, deletable, certificate };\n\n\t\tconst txDigest = options?.digest ?? resumeTxDigest;\n\t\treturn {\n\t\t\tstep: 'uploaded' as const,\n\t\t\tblobId: metadata.blobId,\n\t\t\tblobObjectId: blobObject.id,\n\t\t\t...(txDigest ? { txDigest } : {}),\n\t\t\tcertificate: CertificateBcs.serialize(certificate).toBase64(),\n\t\t};\n\t};\n\n\tconst certify = (): Transaction => {\n\t\tif (!uploadState) {\n\t\t\tthrow new Error('upload must be executed before calling certify');\n\t\t}\n\n\t\tconst { blobObject, blobId, deletable, certificate } = uploadState;\n\t\tconst transaction = client.certifyBlobTransaction({\n\t\t\tcertificate,\n\t\t\tblobId,\n\t\t\tblobObjectId: blobObject.id,\n\t\t\tdeletable,\n\t\t});\n\n\t\tcertifyState = { blobObject, blobId, transaction };\n\t\treturn transaction;\n\t};\n\n\tconst executeRegister = async ({\n\t\tsigner,\n\t\t...options\n\t}: WriteBlobFlowRegisterOptions & { signer: Signer }): Promise<WriteBlobStepRegistered> => {\n\t\tconst transaction = register(options);\n\t\tconst { digest } = await ctx.executeTransaction(transaction, signer, 'register blob');\n\n\t\treturn {\n\t\t\tstep: 'registered' as const,\n\t\t\tblobId: encodeState!.metadata.blobId,\n\t\t\tblobObjectId: (await ctx.getCreatedBlob(digest)).id,\n\t\t\ttxDigest: digest,\n\t\t\t...('nonce' in encodeState!.metadata ? { nonce: toBase64(encodeState!.metadata.nonce) } : {}),\n\t\t};\n\t};\n\n\tconst executeCertify = async ({\n\t\tsigner,\n\t}: {\n\t\tsigner: Signer;\n\t}): Promise<WriteBlobStepCertified> => {\n\t\tconst transaction = certify();\n\t\tawait ctx.executeTransaction(transaction, signer, 'certify blob');\n\n\t\tconst blobObject = await ctx.loadBlobObject(uploadState!.blobObject.id);\n\t\treturn {\n\t\t\tstep: 'certified' as const,\n\t\t\tblobId: uploadState!.blobId,\n\t\t\tblobObjectId: blobObject.id,\n\t\t\tblobObject,\n\t\t};\n\t};\n\n\tconst getBlob = async (): Promise<WriteBlobStepCertified> => {\n\t\tif (!certifyState && !uploadState) {\n\t\t\tthrow new Error('upload or certify must be executed before calling getBlob');\n\t\t}\n\n\t\tconst state = certifyState ?? uploadState!;\n\t\tconst blobObject = await ctx.loadBlobObject(state.blobObject.id);\n\t\treturn {\n\t\t\tstep: 'certified' as const,\n\t\t\tblobId: state.blobId,\n\t\t\tblobObjectId: blobObject.id,\n\t\t\tblobObject,\n\t\t};\n\t};\n\n\tconst restoreUploadState = async (resumeData: WriteBlobStepUploaded, deletable: boolean) => {\n\t\tconst blobObject = await client.getBlobObject(resumeData.blobObjectId);\n\t\tuploadState = {\n\t\t\tblobObject,\n\t\t\tblobId: resumeData.blobId,\n\t\t\tdeletable,\n\t\t\tcertificate: parseCertificateFromBase64(resumeData.certificate),\n\t\t};\n\t};\n\n\t/** @yields {WriteBlobStep} */\n\tasync function* run(options: WriteBlobFlowRunOptions): AsyncGenerator<WriteBlobStep> {\n\t\tconst resumeStep = resume?.step;\n\t\tconst stepOrder = ['encoded', 'registered', 'uploaded', 'certified'] as const;\n\t\tconst resumeIndex = resumeStep ? stepOrder.indexOf(resumeStep) : -1;\n\n\t\t// Already certified — nothing to do\n\t\tif (resumeIndex >= stepOrder.indexOf('certified')) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (resumeIndex < stepOrder.indexOf('encoded')) {\n\t\t\tyield await encode();\n\t\t} else if (resumeIndex < stepOrder.indexOf('uploaded')) {\n\t\t\tawait encode(); // Re-encode to populate internal state for upload\n\t\t}\n\n\t\tlet registerDigest: string | undefined;\n\t\tif (!resumeBlobObjectId) {\n\t\t\tconst regResult = await executeRegister({\n\t\t\t\tsigner: options.signer,\n\t\t\t\tepochs: options.epochs,\n\t\t\t\tdeletable: options.deletable,\n\t\t\t\towner: options.owner ?? options.signer.toSuiAddress(),\n\t\t\t\tattributes: options.attributes,\n\t\t\t});\n\t\t\tregisterDigest = regResult.txDigest;\n\t\t\tyield regResult;\n\t\t} else {\n\t\t\tregisterState = {\n\t\t\t\t...encodeState!,\n\t\t\t\tdeletable: options.deletable,\n\t\t\t};\n\t\t}\n\n\t\tif (resumeIndex < stepOrder.indexOf('uploaded')) {\n\t\t\tconst uploadResult = await upload({\n\t\t\t\tdigest: registerDigest ?? resumeTxDigest,\n\t\t\t\tsignal: options.signal,\n\t\t\t});\n\t\t\tyield uploadResult;\n\t\t} else {\n\t\t\tawait restoreUploadState(resume as WriteBlobStepUploaded, options.deletable);\n\t\t}\n\n\t\tconst certResult = await executeCertify({ signer: options.signer });\n\t\tyield certResult;\n\t}\n\n\treturn {\n\t\tencode,\n\t\tregister,\n\t\tupload,\n\t\tcertify,\n\t\tgetBlob,\n\t\texecuteRegister,\n\t\texecuteCertify,\n\t\trun,\n\t};\n}\n"],"mappings":";;;;;;AA0EA,SAAgB,oBACf,QACA,KACA,SACgB;CAChB,MAAM,E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E;EACpF,MAAM,aAAa,QAAQ;EAC3B,MAAM,YAAY;GAAC;GAAW;GAAc;GAAY;GAAY;EACpE,MAAM,cAAc,aAAa,UAAU,QAAQ,WAAW,GAAG;AAGjE,MAAI,eAAe,UAAU,QAAQ,YAAY,CAChD;AAGD,MAAI,cAAc,UAAU,QAAQ,UAAU,CAC7C,OAAM,MAAM,QAAQ;WACV,cAAc,UAAU,QAAQ,WAAW,CACrD,OAAM,QAAQ;EAGf,IAAI;AACJ,MAAI,CAAC,oBAAoB;GACxB,MAAM,YAAY,MAAM,gBAAgB;IACvC,QAAQA,UAAQ;IAChB,QAAQA,UAAQ;IAChB,WAAWA,UAAQ;IACnB,OAAOA,UAAQ,SAASA,UAAQ,OAAO,cAAc;IACrD,YAAYA,UAAQ;IACpB,CAAC;AACF,oBAAiB,UAAU;AAC3B,SAAM;QAEN,iBAAgB;GACf,GAAG;GACH,WAAWA,UAAQ;GACnB;AAGF,MAAI,cAAc,UAAU,QAAQ,WAAW,CAK9C,OAJqB,MAAM,OAAO;GACjC,QAAQ,kBAAkB;GAC1B,QAAQA,UAAQ;GAChB,CAAC;MAGF,OAAM,mBAAmB,QAAiCA,UAAQ,UAAU;AAI7E,QADmB,MAAM,eAAe,EAAE,QAAQA,UAAQ,QAAQ,CAAC;;AAIpE,QAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA"}
@@ -0,0 +1,112 @@
1
+ import { encodeQuiltPatchId } from "../utils/quilts.mjs";
2
+
3
+ //#region src/flows/write-files.ts
4
+ function createWriteFilesFlow(client, { files, resume }) {
5
+ let quiltBytes;
6
+ let quiltIndex;
7
+ const blobFlow = client.writeBlobFlow({
8
+ get blob() {
9
+ if (!quiltBytes) throw new Error("encode must be executed before accessing blob");
10
+ return quiltBytes;
11
+ },
12
+ resume
13
+ });
14
+ const encode = async () => {
15
+ if (!quiltBytes) {
16
+ const { quilt, index } = await client.encodeQuilt({ blobs: await Promise.all(files.map(async (file, i) => ({
17
+ contents: await file.bytes(),
18
+ identifier: await file.getIdentifier() ?? `file-${i}`,
19
+ tags: await file.getTags() ?? {}
20
+ }))) });
21
+ quiltBytes = quilt;
22
+ quiltIndex = index;
23
+ }
24
+ return blobFlow.encode();
25
+ };
26
+ const register = (options) => {
27
+ if (!quiltBytes) throw new Error("encode must be executed before calling register");
28
+ return blobFlow.register({
29
+ ...options,
30
+ attributes: {
31
+ _walrusBlobType: "quilt",
32
+ ...options.attributes
33
+ }
34
+ });
35
+ };
36
+ const listFiles = async () => {
37
+ if (!quiltIndex) throw new Error("encode must be executed before calling listFiles");
38
+ const certResult = await blobFlow.getBlob();
39
+ return quiltIndex.patches.map((patch) => ({
40
+ id: encodeQuiltPatchId({
41
+ quiltId: certResult.blobId,
42
+ patchId: {
43
+ version: 1,
44
+ startIndex: patch.startIndex,
45
+ endIndex: patch.endIndex
46
+ }
47
+ }),
48
+ blobId: certResult.blobId,
49
+ blobObject: certResult.blobObject
50
+ }));
51
+ };
52
+ /** @yields {WriteBlobStep} */
53
+ async function* run(options) {
54
+ const resumeStep = resume?.step;
55
+ const stepOrder = [
56
+ "encoded",
57
+ "registered",
58
+ "uploaded",
59
+ "certified"
60
+ ];
61
+ const resumeIndex = resumeStep ? stepOrder.indexOf(resumeStep) : -1;
62
+ if (resumeIndex >= stepOrder.indexOf("certified")) return;
63
+ if (resumeIndex < stepOrder.indexOf("encoded")) yield await encode();
64
+ else if (resumeIndex < stepOrder.indexOf("uploaded")) await encode();
65
+ const resumeBlobObjectId = resume && "blobObjectId" in resume ? resume.blobObjectId : void 0;
66
+ let registerDigest;
67
+ if (!resumeBlobObjectId) {
68
+ const regResult = await blobFlow.executeRegister({
69
+ signer: options.signer,
70
+ epochs: options.epochs,
71
+ deletable: options.deletable,
72
+ owner: options.owner ?? options.signer.toSuiAddress(),
73
+ attributes: {
74
+ _walrusBlobType: "quilt",
75
+ ...options.attributes
76
+ }
77
+ });
78
+ registerDigest = regResult.txDigest;
79
+ yield regResult;
80
+ }
81
+ if (resumeIndex < stepOrder.indexOf("uploaded")) yield await blobFlow.upload({
82
+ digest: registerDigest,
83
+ deletable: options.deletable,
84
+ signal: options.signal
85
+ });
86
+ if (resumeIndex < stepOrder.indexOf("certified")) yield await blobFlow.executeCertify({ signer: options.signer });
87
+ }
88
+ return {
89
+ encode,
90
+ register,
91
+ upload: blobFlow.upload,
92
+ certify: blobFlow.certify,
93
+ listFiles,
94
+ executeRegister: async (options) => {
95
+ const { signer, ...rest } = options;
96
+ return blobFlow.executeRegister({
97
+ signer,
98
+ ...rest,
99
+ attributes: {
100
+ _walrusBlobType: "quilt",
101
+ ...rest.attributes
102
+ }
103
+ });
104
+ },
105
+ executeCertify: blobFlow.executeCertify,
106
+ run
107
+ };
108
+ }
109
+
110
+ //#endregion
111
+ export { createWriteFilesFlow };
112
+ //# sourceMappingURL=write-files.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-files.mjs","names":[],"sources":["../../src/flows/write-files.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type {\n\tWriteBlobFlowOptions,\n\tWriteBlobStep,\n\tWriteBlobStepEncoded,\n\tWriteFilesFlow,\n\tWriteFilesFlowOptions,\n\tWriteFilesFlowRegisterOptions,\n\tWriteFilesFlowRunOptions,\n} from '../types.js';\nimport { encodeQuiltPatchId } from '../utils/quilts.js';\nimport type { WalrusClient } from '../client.js';\n\nexport function createWriteFilesFlow(\n\tclient: WalrusClient,\n\t{ files, resume }: WriteFilesFlowOptions,\n): WriteFilesFlow {\n\tlet quiltBytes: Uint8Array | undefined;\n\tlet quiltIndex: Awaited<ReturnType<typeof client.encodeQuilt>>['index'] | undefined;\n\n\tconst blobFlow = client.writeBlobFlow({\n\t\tget blob(): Uint8Array {\n\t\t\tif (!quiltBytes) {\n\t\t\t\tthrow new Error('encode must be executed before accessing blob');\n\t\t\t}\n\t\t\treturn quiltBytes;\n\t\t},\n\t\tresume,\n\t} as WriteBlobFlowOptions); // Cast needed: blob is a lazy getter populated by encode()\n\n\tconst encode = async (): Promise<WriteBlobStepEncoded> => {\n\t\tif (!quiltBytes) {\n\t\t\tconst { quilt, index } = await client.encodeQuilt({\n\t\t\t\tblobs: await Promise.all(\n\t\t\t\t\tfiles.map(async (file, i) => ({\n\t\t\t\t\t\tcontents: await file.bytes(),\n\t\t\t\t\t\tidentifier: (await file.getIdentifier()) ?? `file-${i}`,\n\t\t\t\t\t\ttags: (await file.getTags()) ?? {},\n\t\t\t\t\t})),\n\t\t\t\t),\n\t\t\t});\n\t\t\tquiltBytes = quilt;\n\t\t\tquiltIndex = index;\n\t\t}\n\n\t\treturn blobFlow.encode();\n\t};\n\n\tconst register = (options: WriteFilesFlowRegisterOptions): Transaction => {\n\t\tif (!quiltBytes) {\n\t\t\tthrow new Error('encode must be executed before calling register');\n\t\t}\n\n\t\treturn blobFlow.register({\n\t\t\t...options,\n\t\t\tattributes: {\n\t\t\t\t_walrusBlobType: 'quilt',\n\t\t\t\t...options.attributes,\n\t\t\t},\n\t\t});\n\t};\n\n\tconst listFiles = async () => {\n\t\tif (!quiltIndex) {\n\t\t\tthrow new Error('encode must be executed before calling listFiles');\n\t\t}\n\n\t\tconst certResult = await blobFlow.getBlob();\n\t\treturn quiltIndex.patches.map((patch) => ({\n\t\t\tid: encodeQuiltPatchId({\n\t\t\t\tquiltId: certResult.blobId,\n\t\t\t\tpatchId: {\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tstartIndex: patch.startIndex,\n\t\t\t\t\tendIndex: patch.endIndex,\n\t\t\t\t},\n\t\t\t}),\n\t\t\tblobId: certResult.blobId,\n\t\t\tblobObject: certResult.blobObject,\n\t\t}));\n\t};\n\n\t/** @yields {WriteBlobStep} */\n\tasync function* run(options: WriteFilesFlowRunOptions): AsyncGenerator<WriteBlobStep> {\n\t\tconst resumeStep = resume?.step;\n\t\tconst stepOrder = ['encoded', 'registered', 'uploaded', 'certified'] as const;\n\t\tconst resumeIndex = resumeStep ? stepOrder.indexOf(resumeStep) : -1;\n\n\t\tif (resumeIndex >= stepOrder.indexOf('certified')) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (resumeIndex < stepOrder.indexOf('encoded')) {\n\t\t\tyield await encode();\n\t\t} else if (resumeIndex < stepOrder.indexOf('uploaded')) {\n\t\t\tawait encode();\n\t\t}\n\n\t\tconst resumeBlobObjectId = resume && 'blobObjectId' in resume ? resume.blobObjectId : undefined;\n\t\tlet registerDigest: string | undefined;\n\t\tif (!resumeBlobObjectId) {\n\t\t\tconst regResult = await blobFlow.executeRegister({\n\t\t\t\tsigner: options.signer,\n\t\t\t\tepochs: options.epochs,\n\t\t\t\tdeletable: options.deletable,\n\t\t\t\towner: options.owner ?? options.signer.toSuiAddress(),\n\t\t\t\tattributes: {\n\t\t\t\t\t_walrusBlobType: 'quilt',\n\t\t\t\t\t...options.attributes,\n\t\t\t\t},\n\t\t\t});\n\t\t\tregisterDigest = regResult.txDigest;\n\t\t\tyield regResult;\n\t\t}\n\n\t\tif (resumeIndex < stepOrder.indexOf('uploaded')) {\n\t\t\tyield await blobFlow.upload({\n\t\t\t\tdigest: registerDigest,\n\t\t\t\tdeletable: options.deletable,\n\t\t\t\tsignal: options.signal,\n\t\t\t});\n\t\t}\n\n\t\tif (resumeIndex < stepOrder.indexOf('certified')) {\n\t\t\tyield await blobFlow.executeCertify({ signer: options.signer });\n\t\t}\n\t}\n\n\treturn {\n\t\tencode: encode,\n\t\tregister: register,\n\t\tupload: blobFlow.upload,\n\t\tcertify: blobFlow.certify,\n\t\tlistFiles: listFiles,\n\t\texecuteRegister: async (options: WriteFilesFlowRegisterOptions & { signer: Signer }) => {\n\t\t\tconst { signer, ...rest } = options;\n\t\t\treturn blobFlow.executeRegister({\n\t\t\t\tsigner,\n\t\t\t\t...rest,\n\t\t\t\tattributes: {\n\t\t\t\t\t_walrusBlobType: 'quilt',\n\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AAY;GAAC;GAAW;GAAc;GAAY;GAAY;EACpE,MAAM,cAAc,aAAa,UAAU,QAAQ,WAAW,GAAG;AAEjE,MAAI,eAAe,UAAU,QAAQ,YAAY,CAChD;AAGD,MAAI,cAAc,UAAU,QAAQ,UAAU,CAC7C,OAAM,MAAM,QAAQ;WACV,cAAc,UAAU,QAAQ,WAAW,CACrD,OAAM,QAAQ;EAGf,MAAM,qBAAqB,UAAU,kBAAkB,SAAS,OAAO,eAAe;EACtF,IAAI;AACJ,MAAI,CAAC,oBAAoB;GACxB,MAAM,YAAY,MAAM,SAAS,gBAAgB;IAChD,QAAQ,QAAQ;IAChB,QAAQ,QAAQ;IAChB,WAAW,QAAQ;IACnB,OAAO,QAAQ,SAAS,QAAQ,OAAO,cAAc;IACrD,YAAY;KACX,iBAAiB;KACjB,GAAG,QAAQ;KACX;IACD,CAAC;AACF,oBAAiB,UAAU;AAC3B,SAAM;;AAGP,MAAI,cAAc,UAAU,QAAQ,WAAW,CAC9C,OAAM,MAAM,SAAS,OAAO;GAC3B,QAAQ;GACR,WAAW,QAAQ;GACnB,QAAQ,QAAQ;GAChB,CAAC;AAGH,MAAI,cAAc,UAAU,QAAQ,YAAY,CAC/C,OAAM,MAAM,SAAS,eAAe,EAAE,QAAQ,QAAQ,QAAQ,CAAC;;AAIjE,QAAO;EACE;EACE;EACV,QAAQ,SAAS;EACjB,SAAS,SAAS;EACP;EACX,iBAAiB,OAAO,YAAgE;GACvF,MAAM,EAAE,QAAQ,GAAG,SAAS;AAC5B,UAAO,SAAS,gBAAgB;IAC/B;IACA,GAAG;IACH,YAAY;KACX,iBAAiB;KACjB,GAAG,KAAK;KACR;IACD,CAAC;;EAEH,gBAAgB,SAAS;EACzB;EACA"}
package/dist/index.d.mts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { blobIdFromInt, blobIdToInt } from "./utils/bcs.mjs";
2
+ import { StoredOnNodeStatus } from "./storage-node/types.mjs";
2
3
  import { StorageNodeClientOptions } from "./storage-node/client.mjs";
3
4
  import { FileReader, WalrusFile } from "./files/file.mjs";
4
- import { CertifyBlobOptions, CommitteeInfo, ComputeBlobMetadataOptions, DeletableConfirmationOptions, DeleteBlobOptions, EncodingType, ExtendBlobOptions, GetBlobMetadataOptions, GetCertificationEpochOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ProtocolMessageCertificate, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageNode, StorageWithSizeOptions, TipStrategy, UploadRelayConfig, UploadRelayTipConfig, WalrusClientConfig, WalrusClientExtensionOptions, WalrusClientRequestOptions, WalrusOptions, WalrusPackageConfig, WriteBlobAttributesOptions, WriteBlobFlow, WriteBlobFlowOptions, WriteBlobFlowRegisterOptions, WriteBlobFlowUploadOptions, WriteBlobOptions, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteFilesFlow, WriteFilesFlowOptions, WriteFilesFlowRegisterOptions, WriteFilesFlowUploadOptions, WriteFilesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions } from "./types.mjs";
5
+ import { CertifyBlobOptions, CommitteeInfo, ComputeBlobMetadataOptions, DeletableConfirmationOptions, DeleteBlobOptions, EncodingType, ExtendBlobOptions, GetBlobMetadataOptions, GetCertificationEpochOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ProtocolMessageCertificate, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageNode, StorageWithSizeOptions, TipStrategy, UploadRelayConfig, UploadRelayTipConfig, WalrusClientConfig, WalrusClientExtensionOptions, WalrusClientRequestOptions, WalrusOptions, WalrusPackageConfig, WriteBlobAttributesOptions, WriteBlobBaseOptions, WriteBlobFlow, WriteBlobFlowOptions, WriteBlobFlowRegisterOptions, WriteBlobFlowRunOptions, WriteBlobFlowUploadOptions, WriteBlobOptions, WriteBlobStep, WriteBlobStepCertified, WriteBlobStepEncoded, WriteBlobStepRegistered, WriteBlobStepUploaded, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteFilesFlow, WriteFilesFlowOptions, WriteFilesFlowRegisterOptions, WriteFilesFlowRunOptions, WriteFilesFlowUploadOptions, WriteFilesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions } from "./types.mjs";
5
6
  import { WalrusBlob } from "./files/blob.mjs";
6
7
  import { WalrusClient, walrus } from "./client.mjs";
7
8
  import { MAINNET_WALRUS_PACKAGE_CONFIG, TESTNET_WALRUS_PACKAGE_CONFIG } from "./constants.mjs";
8
9
  import { AuthenticationError, BadRequestError, BlobNotRegisteredError, ConflictError, ConnectionError, ConnectionTimeoutError, InternalServerError, LegallyUnavailableError, NotFoundError, PermissionDeniedError, RateLimitError, StorageNodeAPIError, StorageNodeError, UnprocessableEntityError, UserAbortError } from "./storage-node/error.mjs";
9
10
  import { BehindCurrentEpochError, BlobBlockedError, BlobNotCertifiedError, InconsistentBlobError, NoBlobMetadataReceivedError, NoBlobStatusReceivedError, NoVerifiedBlobStatusReceivedError, NotEnoughBlobConfirmationsError, NotEnoughSliversReceivedError, RetryableWalrusClientError, WalrusClientError } from "./error.mjs";
10
11
  import { EncodeQuiltOptions, encodeQuilt } from "./utils/quilts.mjs";
11
- export { AuthenticationError, BadRequestError, BehindCurrentEpochError, BlobBlockedError, BlobNotCertifiedError, BlobNotRegisteredError, CertifyBlobOptions, CommitteeInfo, ComputeBlobMetadataOptions, ConflictError, ConnectionError, ConnectionTimeoutError, DeletableConfirmationOptions, DeleteBlobOptions, type EncodeQuiltOptions, EncodingType, ExtendBlobOptions, type FileReader, GetBlobMetadataOptions, GetCertificationEpochOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, InconsistentBlobError, InternalServerError, LegallyUnavailableError, MAINNET_WALRUS_PACKAGE_CONFIG, NoBlobMetadataReceivedError, NoBlobStatusReceivedError, NoVerifiedBlobStatusReceivedError, NotEnoughBlobConfirmationsError, NotEnoughSliversReceivedError, NotFoundError, PermissionDeniedError, ProtocolMessageCertificate, RateLimitError, ReadBlobOptions, RegisterBlobOptions, RetryableWalrusClientError, SliversForNode, StorageNode, StorageNodeAPIError, type StorageNodeClientOptions, StorageNodeError, StorageWithSizeOptions, TESTNET_WALRUS_PACKAGE_CONFIG, TipStrategy, UnprocessableEntityError, UploadRelayConfig, UploadRelayTipConfig, UserAbortError, WalrusBlob, WalrusClient, type WalrusClientConfig, WalrusClientError, WalrusClientExtensionOptions, WalrusClientRequestOptions, WalrusFile, type WalrusOptions, type WalrusPackageConfig, WriteBlobAttributesOptions, WriteBlobFlow, WriteBlobFlowOptions, WriteBlobFlowRegisterOptions, WriteBlobFlowUploadOptions, WriteBlobOptions, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteFilesFlow, WriteFilesFlowOptions, WriteFilesFlowRegisterOptions, WriteFilesFlowUploadOptions, WriteFilesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions, blobIdFromInt, blobIdToInt, encodeQuilt, walrus };
12
+ export { AuthenticationError, BadRequestError, BehindCurrentEpochError, BlobBlockedError, BlobNotCertifiedError, BlobNotRegisteredError, CertifyBlobOptions, CommitteeInfo, ComputeBlobMetadataOptions, ConflictError, ConnectionError, ConnectionTimeoutError, DeletableConfirmationOptions, DeleteBlobOptions, type EncodeQuiltOptions, EncodingType, ExtendBlobOptions, type FileReader, GetBlobMetadataOptions, GetCertificationEpochOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, InconsistentBlobError, InternalServerError, LegallyUnavailableError, MAINNET_WALRUS_PACKAGE_CONFIG, NoBlobMetadataReceivedError, NoBlobStatusReceivedError, NoVerifiedBlobStatusReceivedError, NotEnoughBlobConfirmationsError, NotEnoughSliversReceivedError, NotFoundError, PermissionDeniedError, ProtocolMessageCertificate, RateLimitError, ReadBlobOptions, RegisterBlobOptions, RetryableWalrusClientError, SliversForNode, StorageNode, StorageNodeAPIError, type StorageNodeClientOptions, StorageNodeError, StorageWithSizeOptions, type StoredOnNodeStatus, TESTNET_WALRUS_PACKAGE_CONFIG, TipStrategy, UnprocessableEntityError, UploadRelayConfig, UploadRelayTipConfig, UserAbortError, WalrusBlob, WalrusClient, type WalrusClientConfig, WalrusClientError, WalrusClientExtensionOptions, WalrusClientRequestOptions, WalrusFile, type WalrusOptions, type WalrusPackageConfig, WriteBlobAttributesOptions, WriteBlobBaseOptions, WriteBlobFlow, WriteBlobFlowOptions, WriteBlobFlowRegisterOptions, WriteBlobFlowRunOptions, WriteBlobFlowUploadOptions, WriteBlobOptions, WriteBlobStep, WriteBlobStepCertified, WriteBlobStepEncoded, WriteBlobStepRegistered, WriteBlobStepUploaded, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteFilesFlow, WriteFilesFlowOptions, WriteFilesFlowRegisterOptions, WriteFilesFlowRunOptions, WriteFilesFlowUploadOptions, WriteFilesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions, blobIdFromInt, blobIdToInt, encodeQuilt, walrus };
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.mts","names":[],"sources":["../../src/storage-node/client.ts"],"sourcesContent":[],"mappings":";;;;KA6BY,KAAA,SAAc,oBAAoB,gBAAgB,QAAQ;KAE1D,wBAAA;EAFA;;;;;;AAEZ;EAsBY,KAAA,CAAA,EAdH,KAcG;EAGiB;;;;EACrB,OAAA,CAAA,EAAA,MAAA;;;;oBAPW;;KAGP,cAAA;;;YAGD,kBAAkB;IACzB,KAAK"}
1
+ {"version":3,"file":"client.d.mts","names":[],"sources":["../../src/storage-node/client.ts"],"sourcesContent":[],"mappings":";;;;KA+BY,KAAA,SAAc,oBAAoB,gBAAgB,QAAQ;KAE1D,wBAAA;EAFA;;;;;;AAEZ;EAsBY,KAAA,CAAA,EAdH,KAcG;EAGiB;;;;EACrB,OAAA,CAAA,EAAA,MAAA;;;;oBAPW;;KAGP,cAAA;;;YAGD,kBAAkB;IACzB,KAAK"}
@@ -98,6 +98,20 @@ var StorageNodeClient = class {
98
98
  async getPermanentBlobConfirmation({ blobId }, options) {
99
99
  return await (await this.#request(`/v1/blobs/${blobId}/confirmation/permanent`, options)).json();
100
100
  }
101
+ /**
102
+ * Gets the storage status of a sliver at this storage node.
103
+ * Returns whether the sliver is stored, buffered (pending registration), or nonexistent.
104
+ */
105
+ async getSliverStatus({ blobId, sliverPairIndex, sliverType }, options) {
106
+ return (await (await this.#request(`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}/status`, options)).json()).success.data;
107
+ }
108
+ /**
109
+ * Gets the storage status of blob metadata at this storage node.
110
+ * Returns whether the metadata is stored, buffered (pending registration), or nonexistent.
111
+ */
112
+ async getMetadataStatus({ blobId }, options) {
113
+ return (await (await this.#request(`/v1/blobs/${blobId}/metadata/status`, options)).json()).success.data;
114
+ }
101
115
  async #request(path, options) {
102
116
  const { nodeUrl, signal, timeout, ...init } = options;
103
117
  if (signal?.aborted) throw new UserAbortError();
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","names":["#fetch","#timeout","#onError","#request","error"],"sources":["../../src/storage-node/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BlobMetadata, BlobMetadataWithId, SliverData } from '../utils/bcs.js';\nimport {\n\tConnectionTimeoutError,\n\tStorageNodeAPIError,\n\tStorageNodeError,\n\tUserAbortError,\n} from './error.js';\nimport type {\n\tGetBlobMetadataRequestInput,\n\tGetBlobMetadataResponse,\n\tGetBlobStatusRequestInput,\n\tGetBlobStatusResponse,\n\tGetDeletableBlobConfirmationRequestInput,\n\tGetDeletableBlobConfirmationResponse,\n\tGetPermanentBlobConfirmationRequestInput,\n\tGetPermanentBlobConfirmationResponse,\n\tGetSliverRequestInput,\n\tGetSliverResponse,\n\tRawGetBlobStatusResponse,\n\tStoreBlobMetadataRequestInput,\n\tStoreBlobMetadataResponse,\n\tStoreSliverRequestInput,\n\tStoreSliverResponse,\n} from './types.js';\nimport { mergeHeaders } from './utils.js';\n\nexport type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nexport type StorageNodeClientOptions = {\n\t/**\n\t * An optional custom fetch function.\n\t *\n\t * If not provided, defaults to the global `fetch` function (`globalThis.fetch`).\n\t *\n\t * @default globalThis.fetch\n\t */\n\tfetch?: Fetch;\n\n\t/**\n\t * An optional timeout for requests.\n\t * @default 30_000ms (30 seconds)\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Callback for individual network errors.\n\t */\n\tonError?: (error: Error) => void;\n};\n\nexport type RequestOptions = {\n\tnodeUrl: string;\n\ttimeout?: number;\n\theaders?: ReturnType<typeof mergeHeaders>;\n} & Omit<RequestInit, 'headers'>;\n\nexport class StorageNodeClient {\n\t#fetch: Fetch;\n\t#timeout: number;\n\t#onError?: (error: Error) => void;\n\tconstructor({ fetch: overriddenFetch, timeout, onError }: StorageNodeClientOptions = {}) {\n\t\tthis.#fetch = overriddenFetch ?? globalThis.fetch;\n\t\tthis.#timeout = timeout ?? 30_000;\n\t\tthis.#onError = onError;\n\t}\n\n\t/**\n\t * Gets the metadata associated with a Walrus blob.\n\t */\n\tasync getBlobMetadata(\n\t\t{ blobId }: GetBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobMetadataResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn BlobMetadataWithId.parse(new Uint8Array(bcsBytes));\n\t}\n\n\t/**\n\t * Gets the status associated with a Walrus blob.\n\t */\n\tasync getBlobStatus(\n\t\t{ blobId }: GetBlobStatusRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobStatusResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/status`, options);\n\n\t\tconst json: RawGetBlobStatusResponse = await response.json();\n\t\tconst blobStatus = json.success.data;\n\n\t\tif (blobStatus === 'nonexistent') {\n\t\t\treturn { type: 'nonexistent' };\n\t\t}\n\n\t\tif ('invalid' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'invalid',\n\t\t\t\t...blobStatus.invalid,\n\t\t\t};\n\t\t}\n\n\t\tif ('permanent' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'permanent',\n\t\t\t\t...blobStatus.permanent,\n\t\t\t};\n\t\t}\n\n\t\tif ('deletable' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'deletable',\n\t\t\t\t...blobStatus.deletable,\n\t\t\t};\n\t\t}\n\n\t\tthrow new StorageNodeError(`Unknown blob status received: ${blobStatus}`);\n\t}\n\n\t/**\n\t * Stores the metadata associated with a registered Walrus blob at this storage\n\t * node. This is a pre-requisite for storing the encoded slivers of the blob. The\n\t * ID of the blob must first be registered on Sui, after which storing the metadata\n\t * becomes possible.\n\t *\n\t * This endpoint may return an error if the node has not yet received the\n\t * registration event from the chain.\n\t */\n\tasync storeBlobMetadata(\n\t\t{ blobId, metadata }: StoreBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoreBlobMetadataResponse> {\n\t\tconst isBcsInput = typeof metadata === 'object' && 'V1' in metadata;\n\t\tconst body = isBcsInput ? BlobMetadata.serialize(metadata).toBytes() : metadata;\n\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\tmethod: 'PUT',\n\t\t\tbody: body as Uint8Array<ArrayBuffer>,\n\t\t\theaders: mergeHeaders({ 'Content-Type': 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst json: StoreBlobMetadataResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets the primary or secondary sliver identified by the specified blob ID and\n\t * index. The index should represent a sliver that is assigned to be stored at one\n\t * of the shards managed by this storage node during this epoch.\n\t */\n\tasync getSliver(\n\t\t{ blobId, sliverPairIndex, sliverType }: GetSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetSliverResponse> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}`,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t\t},\n\t\t);\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn new Uint8Array(bcsBytes);\n\t}\n\n\t/**\n\t * Stores a primary or secondary blob sliver at the storage node.\n\t */\n\tasync storeSliver(\n\t\t{ blobId, sliverPairIndex, sliverType, sliver }: StoreSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoreSliverResponse> {\n\t\tconst isBcsInput = typeof sliver === 'object' && 'symbols' in sliver;\n\t\tconst body = isBcsInput ? SliverData.serialize(sliver).toBytes() : sliver;\n\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}`,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tmethod: 'PUT',\n\t\t\t\tbody: body as Uint8Array<ArrayBuffer>,\n\t\t\t\theaders: mergeHeaders({ 'Content-Type': 'application/octet-stream' }, options.headers),\n\t\t\t},\n\t\t);\n\n\t\tconst json: StoreSliverResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets a signed storage confirmation from this storage node, indicating that all shards\n\t * assigned to this storage node for the current epoch have stored their respective slivers.\n\t */\n\tasync getDeletableBlobConfirmation(\n\t\t{ blobId, objectId }: GetDeletableBlobConfirmationRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetDeletableBlobConfirmationResponse> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/confirmation/deletable/${objectId}`,\n\t\t\toptions,\n\t\t);\n\n\t\tconst json: GetDeletableBlobConfirmationResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets a signed storage confirmation from this storage node, indicating that all shards\n\t * assigned to this storage node for the current epoch have stored their respective slivers.\n\t */\n\tasync getPermanentBlobConfirmation(\n\t\t{ blobId }: GetPermanentBlobConfirmationRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetPermanentBlobConfirmationResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/confirmation/permanent`, options);\n\n\t\tconst json: GetPermanentBlobConfirmationResponse = await response.json();\n\t\treturn json;\n\t}\n\n\tasync #request(path: string, options: RequestOptions) {\n\t\tconst { nodeUrl, signal, timeout, ...init } = options;\n\n\t\tif (signal?.aborted) {\n\t\t\tthrow new UserAbortError();\n\t\t}\n\n\t\tconst timeoutSignal = AbortSignal.timeout(timeout ?? this.#timeout);\n\n\t\tlet response: Response | undefined;\n\n\t\ttry {\n\t\t\tconst fetch = this.#fetch;\n\t\t\tresponse = await fetch(`${nodeUrl}${path}`, {\n\t\t\t\t...init,\n\t\t\t\tsignal: signal ? AbortSignal.any([timeoutSignal, signal]) : timeoutSignal,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new UserAbortError();\n\t\t\t}\n\n\t\t\tif (error instanceof Error && error.name === 'AbortError') {\n\t\t\t\tconst error = new ConnectionTimeoutError();\n\t\t\t\tthis.#onError?.(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthis.#onError?.(error as Error);\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tconst errorText = await response.text().catch((reason) => reason);\n\t\t\tconst errorJSON = safeParseJSON(errorText);\n\t\t\tconst errorMessage = errorJSON ? undefined : errorText;\n\t\t\tconst error = StorageNodeAPIError.generate(response.status, errorJSON, errorMessage);\n\t\t\tthis.#onError?.(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn response;\n\t}\n}\n\nfunction safeParseJSON(value: string) {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;AA2DA,IAAa,oBAAb,MAA+B;CAC9B;CACA;CACA;CACA,YAAY,EAAE,OAAO,iBAAiB,SAAS,YAAsC,EAAE,EAAE;AACxF,QAAKA,QAAS,mBAAmB,WAAW;AAC5C,QAAKC,UAAW,WAAW;AAC3B,QAAKC,UAAW;;;;;CAMjB,MAAM,gBACL,EAAE,UACF,SACmC;EAMnC,MAAM,WAAW,OALA,MAAM,MAAKC,QAAS,aAAa,OAAO,YAAY;GACpE,GAAG;GACH,SAAS,aAAa,EAAE,QAAQ,4BAA4B,EAAE,QAAQ,QAAQ;GAC9E,CAAC,EAE8B,aAAa;AAC7C,SAAO,mBAAmB,MAAM,IAAI,WAAW,SAAS,CAAC;;;;;CAM1D,MAAM,cACL,EAAE,UACF,SACiC;EAIjC,MAAM,cADiC,OAFtB,MAAM,MAAKA,QAAS,aAAa,OAAO,UAAU,QAAQ,EAErB,MAAM,EACpC,QAAQ;AAEhC,MAAI,eAAe,cAClB,QAAO,EAAE,MAAM,eAAe;AAG/B,MAAI,aAAa,WAChB,QAAO;GACN,MAAM;GACN,GAAG,WAAW;GACd;AAGF,MAAI,eAAe,WAClB,QAAO;GACN,MAAM;GACN,GAAG,WAAW;GACd;AAGF,MAAI,eAAe,WAClB,QAAO;GACN,MAAM;GACN,GAAG,WAAW;GACd;AAGF,QAAM,IAAI,iBAAiB,iCAAiC,aAAa;;;;;;;;;;;CAY1E,MAAM,kBACL,EAAE,QAAQ,YACV,SACqC;EAErC,MAAM,OADa,OAAO,aAAa,YAAY,QAAQ,WACjC,aAAa,UAAU,SAAS,CAAC,SAAS,GAAG;AAUvE,SADwC,OAPvB,MAAM,MAAKA,Q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MAAKD;AACnB,cAAW,MAAM,MAAM,GAAG,UAAU,QAAQ;IAC3C,GAAG;IACH,QAAQ,SAAS,YAAY,IAAI,CAAC,eAAe,OAAO,CAAC,GAAG;IAC5D,CAAC;WACM,OAAO;AACf,OAAI,QAAQ,QACX,OAAM,IAAI,gBAAgB;AAG3B,OAAI,iBAAiB,SAAS,MAAM,SAAS,cAAc;IAC1D,MAAMI,UAAQ,IAAI,wBAAwB;AAC1C,UAAKF,UAAWE,QAAM;AACtB,UAAMA;;AAGP,SAAKF,UAAW,MAAe;AAE/B,SAAM;;AAGP,MAAI,CAAC,SAAS,IAAI;GACjB,MAAM,YAAY,MAAM,SAAS,MAAM,CAAC,OAAO,WAAW,OAAO;GACjE,MAAM,YAAY,cAAc,UAAU;GAC1C,MAAM,eAAe,YAAY,SAAY;GAC7C,MAAM,QAAQ,oBAAoB,SAAS,SAAS,QAAQ,WAAW,aAAa;AACpF,SAAKA,UAAW,MAAM;AACtB,SAAM;;AAGP,SAAO;;;AAIT,SAAS,cAAc,OAAe;AACrC,KAAI;AACH,SAAO,KAAK,MAAM,MAAM;SACjB;AACP"}
1
+ {"version":3,"file":"client.mjs","names":["#fetch","#timeout","#onError","#request","error"],"sources":["../../src/storage-node/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BlobMetadata, BlobMetadataWithId, SliverData } from '../utils/bcs.js';\nimport {\n\tConnectionTimeoutError,\n\tStorageNodeAPIError,\n\tStorageNodeError,\n\tUserAbortError,\n} from './error.js';\nimport type {\n\tGetBlobMetadataRequestInput,\n\tGetBlobMetadataResponse,\n\tGetBlobStatusRequestInput,\n\tGetBlobStatusResponse,\n\tGetDeletableBlobConfirmationRequestInput,\n\tGetDeletableBlobConfirmationResponse,\n\tGetPermanentBlobConfirmationRequestInput,\n\tGetPermanentBlobConfirmationResponse,\n\tGetSliverRequestInput,\n\tGetSliverResponse,\n\tRawGetBlobStatusResponse,\n\tStoreBlobMetadataRequestInput,\n\tStoreBlobMetadataResponse,\n\tStoreSliverRequestInput,\n\tStoreSliverResponse,\n\tStoredOnNodeStatus,\n\tStoredOnNodeStatusResponse,\n} from './types.js';\nimport { mergeHeaders } from './utils.js';\n\nexport type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nexport type StorageNodeClientOptions = {\n\t/**\n\t * An optional custom fetch function.\n\t *\n\t * If not provided, defaults to the global `fetch` function (`globalThis.fetch`).\n\t *\n\t * @default globalThis.fetch\n\t */\n\tfetch?: Fetch;\n\n\t/**\n\t * An optional timeout for requests.\n\t * @default 30_000ms (30 seconds)\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Callback for individual network errors.\n\t */\n\tonError?: (error: Error) => void;\n};\n\nexport type RequestOptions = {\n\tnodeUrl: string;\n\ttimeout?: number;\n\theaders?: ReturnType<typeof mergeHeaders>;\n} & Omit<RequestInit, 'headers'>;\n\nexport class StorageNodeClient {\n\t#fetch: Fetch;\n\t#timeout: number;\n\t#onError?: (error: Error) => void;\n\tconstructor({ fetch: overriddenFetch, timeout, onError }: StorageNodeClientOptions = {}) {\n\t\tthis.#fetch = overriddenFetch ?? globalThis.fetch;\n\t\tthis.#timeout = timeout ?? 30_000;\n\t\tthis.#onError = onError;\n\t}\n\n\t/**\n\t * Gets the metadata associated with a Walrus blob.\n\t */\n\tasync getBlobMetadata(\n\t\t{ blobId }: GetBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobMetadataResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn BlobMetadataWithId.parse(new Uint8Array(bcsBytes));\n\t}\n\n\t/**\n\t * Gets the status associated with a Walrus blob.\n\t */\n\tasync getBlobStatus(\n\t\t{ blobId }: GetBlobStatusRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobStatusResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/status`, options);\n\n\t\tconst json: RawGetBlobStatusResponse = await response.json();\n\t\tconst blobStatus = json.success.data;\n\n\t\tif (blobStatus === 'nonexistent') {\n\t\t\treturn { type: 'nonexistent' };\n\t\t}\n\n\t\tif ('invalid' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'invalid',\n\t\t\t\t...blobStatus.invalid,\n\t\t\t};\n\t\t}\n\n\t\tif ('permanent' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'permanent',\n\t\t\t\t...blobStatus.permanent,\n\t\t\t};\n\t\t}\n\n\t\tif ('deletable' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'deletable',\n\t\t\t\t...blobStatus.deletable,\n\t\t\t};\n\t\t}\n\n\t\tthrow new StorageNodeError(`Unknown blob status received: ${blobStatus}`);\n\t}\n\n\t/**\n\t * Stores the metadata associated with a registered Walrus blob at this storage\n\t * node. This is a pre-requisite for storing the encoded slivers of the blob. The\n\t * ID of the blob must first be registered on Sui, after which storing the metadata\n\t * becomes possible.\n\t *\n\t * This endpoint may return an error if the node has not yet received the\n\t * registration event from the chain.\n\t */\n\tasync storeBlobMetadata(\n\t\t{ blobId, metadata }: StoreBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoreBlobMetadataResponse> {\n\t\tconst isBcsInput = typeof metadata === 'object' && 'V1' in metadata;\n\t\tconst body = isBcsInput ? BlobMetadata.serialize(metadata).toBytes() : metadata;\n\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\tmethod: 'PUT',\n\t\t\tbody: body as Uint8Array<ArrayBuffer>,\n\t\t\theaders: mergeHeaders({ 'Content-Type': 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst json: StoreBlobMetadataResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets the primary or secondary sliver identified by the specified blob ID and\n\t * index. The index should represent a sliver that is assigned to be stored at one\n\t * of the shards managed by this storage node during this epoch.\n\t */\n\tasync getSliver(\n\t\t{ blobId, sliverPairIndex, sliverType }: GetSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetSliverResponse> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}`,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t\t},\n\t\t);\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn new Uint8Array(bcsBytes);\n\t}\n\n\t/**\n\t * Stores a primary or secondary blob sliver at the storage node.\n\t */\n\tasync storeSliver(\n\t\t{ blobId, sliverPairIndex, sliverType, sliver }: StoreSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoreSliverResponse> {\n\t\tconst isBcsInput = typeof sliver === 'object' && 'symbols' in sliver;\n\t\tconst body = isBcsInput ? SliverData.serialize(sliver).toBytes() : sliver;\n\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}`,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tmethod: 'PUT',\n\t\t\t\tbody: body as Uint8Array<ArrayBuffer>,\n\t\t\t\theaders: mergeHeaders({ 'Content-Type': 'application/octet-stream' }, options.headers),\n\t\t\t},\n\t\t);\n\n\t\tconst json: StoreSliverResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets a signed storage confirmation from this storage node, indicating that all shards\n\t * assigned to this storage node for the current epoch have stored their respective slivers.\n\t */\n\tasync getDeletableBlobConfirmation(\n\t\t{ blobId, objectId }: GetDeletableBlobConfirmationRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetDeletableBlobConfirmationResponse> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/confirmation/deletable/${objectId}`,\n\t\t\toptions,\n\t\t);\n\n\t\tconst json: GetDeletableBlobConfirmationResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets a signed storage confirmation from this storage node, indicating that all shards\n\t * assigned to this storage node for the current epoch have stored their respective slivers.\n\t */\n\tasync getPermanentBlobConfirmation(\n\t\t{ blobId }: GetPermanentBlobConfirmationRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetPermanentBlobConfirmationResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/confirmation/permanent`, options);\n\n\t\tconst json: GetPermanentBlobConfirmationResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets the storage status of a sliver at this storage node.\n\t * Returns whether the sliver is stored, buffered (pending registration), or nonexistent.\n\t */\n\tasync getSliverStatus(\n\t\t{ blobId, sliverPairIndex, sliverType }: GetSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoredOnNodeStatus> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}/status`,\n\t\t\toptions,\n\t\t);\n\n\t\tconst json: StoredOnNodeStatusResponse = await response.json();\n\t\treturn json.success.data;\n\t}\n\n\t/**\n\t * Gets the storage status of blob metadata at this storage node.\n\t * Returns whether the metadata is stored, buffered (pending registration), or nonexistent.\n\t */\n\tasync getMetadataStatus(\n\t\t{ blobId }: GetBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoredOnNodeStatus> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata/status`, options);\n\n\t\tconst json: StoredOnNodeStatusResponse = await response.json();\n\t\treturn json.success.data;\n\t}\n\n\tasync #request(path: string, options: RequestOptions) {\n\t\tconst { nodeUrl, signal, timeout, ...init } = options;\n\n\t\tif (signal?.aborted) {\n\t\t\tthrow new UserAbortError();\n\t\t}\n\n\t\tconst timeoutSignal = AbortSignal.timeout(timeout ?? this.#timeout);\n\n\t\tlet response: Response | undefined;\n\n\t\ttry {\n\t\t\tconst fetch = this.#fetch;\n\t\t\tresponse = await fetch(`${nodeUrl}${path}`, {\n\t\t\t\t...init,\n\t\t\t\tsignal: signal ? AbortSignal.any([timeoutSignal, signal]) : timeoutSignal,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new UserAbortError();\n\t\t\t}\n\n\t\t\tif (error instanceof Error && error.name === 'AbortError') {\n\t\t\t\tconst error = new ConnectionTimeoutError();\n\t\t\t\tthis.#onError?.(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthis.#onError?.(error as Error);\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tconst errorText = await response.text().catch((reason) => reason);\n\t\t\tconst errorJSON = safeParseJSON(errorText);\n\t\t\tconst errorMessage = errorJSON ? undefined : errorText;\n\t\t\tconst error = StorageNodeAPIError.generate(response.status, errorJSON, errorMessage);\n\t\t\tthis.#onError?.(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn response;\n\t}\n}\n\nfunction safeParseJSON(value: string) {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;AA6DA,IAAa,oBAAb,MAA+B;CAC9B;CACA;CACA;CACA,YAAY,EAAE,OAAO,iBAAiB,SAAS,YAAsC,EAAE,EAAE;AACxF,QAAKA,QAAS,mBAAmB,WAAW;AAC5C,QAAKC,UAAW,WAAW;AAC3B,QAAKC,UAAW;;;;;CAMjB,MAAM,gBACL,EAAE,UACF,SACmC;EAMnC,MAAM,WAAW,OALA,MAAM,MAAKC,QAAS,aAAa,OAAO,YAAY;GACpE,GAAG;GACH,SAAS,aAAa,EAAE,QAAQ,4BAA4B,EAAE,QAAQ,QAAQ;GAC9E,CAAC,EAE8B,aAAa;AAC7C,SAAO,mBAAmB,MAAM,IAAI,WAAW,SAAS,CAAC;;;;;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W,MAAe;AAE/B,SAAM;;AAGP,MAAI,CAAC,SAAS,IAAI;GACjB,MAAM,YAAY,MAAM,SAAS,MAAM,CAAC,OAAO,WAAW,OAAO;GACjE,MAAM,YAAY,cAAc,UAAU;GAC1C,MAAM,eAAe,YAAY,SAAY;GAC7C,MAAM,QAAQ,oBAAoB,SAAS,SAAS,QAAQ,WAAW,aAAa;AACpF,SAAKA,UAAW,MAAM;AACtB,SAAM;;AAGP,SAAO;;;AAIT,SAAS,cAAc,OAAe;AACrC,KAAI;AACH,SAAO,KAAK,MAAM,MAAM;SACjB;AACP"}
@@ -68,6 +68,7 @@ type StoreSliverResponse = {
68
68
  data: string;
69
69
  };
70
70
  };
71
+ type StoredOnNodeStatus = 'Nonexistent' | 'Buffered' | 'Stored';
71
72
  //#endregion
72
- export { BlobStatus, GetSliverResponse, StorageConfirmation, StoreBlobMetadataRequestInput, StoreBlobMetadataResponse, StoreSliverRequestInput, StoreSliverResponse, Uploadable };
73
+ export { BlobStatus, GetSliverResponse, StorageConfirmation, StoreBlobMetadataRequestInput, StoreBlobMetadataResponse, StoreSliverRequestInput, StoreSliverResponse, StoredOnNodeStatus, Uploadable };
73
74
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/storage-node/types.ts"],"sourcesContent":[],"mappings":";;;KAOY,UAAA;AAAA,KAEA,UAAA,GAFU,OAEU,UAAA,CAAW,UAFrB;AAEV,KAEA,UAAA,GAAa,UAFO,GAEM,WAFK,GAES,cAFC,GAEgB,IAFhB;AAEzC,KAEA,mBAAA,GAFU;EAAG,iBAAA,EAAA,MAAA;EAAa,SAAA,EAAA,MAAA;CAAc;AAe1B,KAFd,UAAA,GAEc;EACE,IAAA,EAAA,aAAA;CACA,GAAA,CAAA;EAAmB,IAAA,EAAA,SAAA;AAe/C,CAAA,GAjB0B,iBAiBd,CAAA,SAAiB,CAAA,CAAA,GAAA,CAEpB;EAIG,IAAA,EAAA,WA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