@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.
- package/CHANGELOG.md +22 -0
- package/README.md +52 -0
- package/dist/client.d.mts +102 -26
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +177 -345
- package/dist/client.mjs.map +1 -1
- package/dist/constants.mjs +2 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/contracts/walrus/blob.d.mts +12 -12
- package/dist/contracts/walrus/storage_node.d.mts +8 -8
- package/dist/flows/write-blob.mjs +227 -0
- package/dist/flows/write-blob.mjs.map +1 -0
- package/dist/flows/write-files.mjs +112 -0
- package/dist/flows/write-files.mjs.map +1 -0
- package/dist/index.d.mts +3 -2
- package/dist/storage-node/client.d.mts.map +1 -1
- package/dist/storage-node/client.mjs +14 -0
- package/dist/storage-node/client.mjs.map +1 -1
- package/dist/storage-node/types.d.mts +2 -1
- package/dist/storage-node/types.d.mts.map +1 -1
- package/dist/types.d.mts +79 -22
- package/dist/types.d.mts.map +1 -1
- package/dist/utils/bcs.mjs +14 -1
- package/dist/utils/bcs.mjs.map +1 -1
- package/docs/index.md +52 -0
- package/package.json +8 -8
package/dist/types.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { StorageNodeInfo } from "./contracts/walrus/storage_node.mjs";
|
|
1
2
|
import { BlobMetadata } from "./utils/bcs.mjs";
|
|
2
3
|
import { StorageConfirmation, StoreBlobMetadataRequestInput, StoreSliverRequestInput, Uploadable } from "./storage-node/types.mjs";
|
|
3
|
-
import { Blob } from "./contracts/walrus/blob.mjs";
|
|
4
|
-
import { StorageNodeInfo } from "./contracts/walrus/storage_node.mjs";
|
|
5
4
|
import { RequestOptions, StorageNodeClientOptions } from "./storage-node/client.mjs";
|
|
6
5
|
import { UploadRelayClientOptions } from "./upload-relay/client.mjs";
|
|
7
6
|
import { WalrusFile } from "./files/file.mjs";
|
|
7
|
+
import { Blob } from "./contracts/walrus/blob.mjs";
|
|
8
8
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
9
9
|
import { ClientWithCoreApi } from "@mysten/sui/client";
|
|
10
10
|
import { Signer } from "@mysten/sui/cryptography";
|
|
@@ -108,7 +108,9 @@ type CertifyBlobOptions = {
|
|
|
108
108
|
confirmations: (StorageConfirmation | null)[];
|
|
109
109
|
certificate?: never;
|
|
110
110
|
} | {
|
|
111
|
-
certificate
|
|
111
|
+
/** A certificate from the upload relay or combined confirmations.
|
|
112
|
+
* Accepts either a ProtocolMessageCertificate object or a BCS-encoded base64 string. */
|
|
113
|
+
certificate: ProtocolMessageCertificate | string;
|
|
112
114
|
confirmations?: never;
|
|
113
115
|
});
|
|
114
116
|
type DeletableConfirmationOptions = {
|
|
@@ -136,6 +138,8 @@ type GetVerifiedBlobStatusOptions = ReadBlobOptions;
|
|
|
136
138
|
type ComputeBlobMetadataOptions = {
|
|
137
139
|
bytes: Uint8Array;
|
|
138
140
|
numShards?: number;
|
|
141
|
+
/** Provide a nonce from a prior encode to ensure deterministic resume. If omitted, a random nonce is generated. */
|
|
142
|
+
nonce?: Uint8Array;
|
|
139
143
|
};
|
|
140
144
|
interface SliversForNode {
|
|
141
145
|
primary: {
|
|
@@ -181,17 +185,21 @@ type WriteBlobToUploadRelayOptions = {
|
|
|
181
185
|
deletable: boolean;
|
|
182
186
|
encodingType?: EncodingType;
|
|
183
187
|
} & WalrusClientRequestOptions;
|
|
184
|
-
|
|
185
|
-
blob: Uint8Array;
|
|
188
|
+
interface WriteBlobBaseOptions {
|
|
186
189
|
deletable: boolean;
|
|
187
190
|
/** The number of epochs the blob should be stored for. */
|
|
188
191
|
epochs: number;
|
|
189
|
-
signer
|
|
190
|
-
/** Where the blob should be transferred to after it is registered. Defaults to the signer address. */
|
|
192
|
+
/** Where the blob should be transferred to after it is registered. Defaults to the signer address. */
|
|
191
193
|
owner?: string;
|
|
192
194
|
/** The attributes to write for the blob. */
|
|
193
195
|
attributes?: Record<string, string | null>;
|
|
194
|
-
}
|
|
196
|
+
}
|
|
197
|
+
interface WriteBlobOptions extends WriteBlobBaseOptions, WalrusClientRequestOptions {
|
|
198
|
+
blob: Uint8Array;
|
|
199
|
+
signer: Signer;
|
|
200
|
+
onStep?: (step: WriteBlobStep) => void | Promise<void>;
|
|
201
|
+
resume?: WriteBlobStep;
|
|
202
|
+
}
|
|
195
203
|
interface WriteQuiltOptions extends Omit<WriteBlobOptions, 'blob'> {
|
|
196
204
|
blobs: {
|
|
197
205
|
contents: Uint8Array;
|
|
@@ -202,44 +210,93 @@ interface WriteQuiltOptions extends Omit<WriteBlobOptions, 'blob'> {
|
|
|
202
210
|
interface WriteFilesOptions extends Omit<WriteBlobOptions, 'blob'> {
|
|
203
211
|
files: WalrusFile[];
|
|
204
212
|
}
|
|
213
|
+
type WriteBlobStep = WriteBlobStepEncoded | WriteBlobStepRegistered | WriteBlobStepUploaded | WriteBlobStepCertified;
|
|
214
|
+
interface WriteBlobStepEncoded {
|
|
215
|
+
step: 'encoded';
|
|
216
|
+
blobId: string;
|
|
217
|
+
rootHash: string;
|
|
218
|
+
unencodedSize: number;
|
|
219
|
+
nonce?: string;
|
|
220
|
+
}
|
|
221
|
+
interface WriteBlobStepRegistered {
|
|
222
|
+
step: 'registered';
|
|
223
|
+
blobId: string;
|
|
224
|
+
blobObjectId: string;
|
|
225
|
+
txDigest: string;
|
|
226
|
+
nonce?: string;
|
|
227
|
+
}
|
|
228
|
+
interface WriteBlobStepUploaded {
|
|
229
|
+
step: 'uploaded';
|
|
230
|
+
blobId: string;
|
|
231
|
+
blobObjectId: string;
|
|
232
|
+
txDigest?: string;
|
|
233
|
+
certificate: string;
|
|
234
|
+
}
|
|
235
|
+
interface WriteBlobStepCertified {
|
|
236
|
+
step: 'certified';
|
|
237
|
+
blobId: string;
|
|
238
|
+
blobObjectId: string;
|
|
239
|
+
blobObject: (typeof Blob)['$inferType'];
|
|
240
|
+
}
|
|
205
241
|
interface WriteFilesFlowOptions {
|
|
206
242
|
files: WalrusFile[];
|
|
243
|
+
resume?: WriteBlobStep;
|
|
207
244
|
}
|
|
208
|
-
interface WriteFilesFlowRegisterOptions extends
|
|
245
|
+
interface WriteFilesFlowRegisterOptions extends WriteBlobBaseOptions {
|
|
209
246
|
owner: string;
|
|
210
247
|
}
|
|
211
248
|
interface WriteFilesFlowUploadOptions {
|
|
212
|
-
digest
|
|
249
|
+
digest?: string;
|
|
250
|
+
}
|
|
251
|
+
interface WriteFilesFlowRunOptions extends WriteBlobBaseOptions, WalrusClientRequestOptions {
|
|
252
|
+
signer: Signer;
|
|
213
253
|
}
|
|
214
254
|
interface WriteFilesFlow {
|
|
215
|
-
encode: () => Promise<
|
|
255
|
+
encode: () => Promise<WriteBlobStepEncoded>;
|
|
216
256
|
register: (options: WriteFilesFlowRegisterOptions) => Transaction;
|
|
217
|
-
upload: (options
|
|
257
|
+
upload: (options?: WriteFilesFlowUploadOptions) => Promise<WriteBlobStepUploaded>;
|
|
218
258
|
certify: () => Transaction;
|
|
219
259
|
listFiles: () => Promise<{
|
|
220
260
|
id: string;
|
|
221
261
|
blobId: string;
|
|
222
262
|
blobObject: (typeof Blob)['$inferType'];
|
|
223
263
|
}[]>;
|
|
264
|
+
executeRegister: (options: WriteFilesFlowRegisterOptions & {
|
|
265
|
+
signer: Signer;
|
|
266
|
+
}) => Promise<WriteBlobStepRegistered>;
|
|
267
|
+
executeCertify: (options: {
|
|
268
|
+
signer: Signer;
|
|
269
|
+
}) => Promise<WriteBlobStepCertified>;
|
|
270
|
+
run: (options: WriteFilesFlowRunOptions) => AsyncIterable<WriteBlobStep>;
|
|
224
271
|
}
|
|
225
272
|
interface WriteBlobFlowOptions {
|
|
226
273
|
blob: Uint8Array;
|
|
274
|
+
resume?: WriteBlobStep;
|
|
227
275
|
}
|
|
228
|
-
interface WriteBlobFlowRegisterOptions extends
|
|
276
|
+
interface WriteBlobFlowRegisterOptions extends WriteBlobBaseOptions {
|
|
229
277
|
owner: string;
|
|
230
278
|
}
|
|
231
|
-
interface WriteBlobFlowUploadOptions {
|
|
232
|
-
digest
|
|
279
|
+
interface WriteBlobFlowUploadOptions extends WalrusClientRequestOptions {
|
|
280
|
+
digest?: string;
|
|
281
|
+
/** Override the deletable flag when resuming without a prior register step. */
|
|
282
|
+
deletable?: boolean;
|
|
283
|
+
}
|
|
284
|
+
interface WriteBlobFlowRunOptions extends WriteBlobBaseOptions, WalrusClientRequestOptions {
|
|
285
|
+
signer: Signer;
|
|
233
286
|
}
|
|
234
287
|
interface WriteBlobFlow {
|
|
235
|
-
encode: () => Promise<
|
|
288
|
+
encode: () => Promise<WriteBlobStepEncoded>;
|
|
236
289
|
register: (options: WriteBlobFlowRegisterOptions) => Transaction;
|
|
237
|
-
upload: (options
|
|
290
|
+
upload: (options?: WriteBlobFlowUploadOptions) => Promise<WriteBlobStepUploaded>;
|
|
238
291
|
certify: () => Transaction;
|
|
239
|
-
getBlob: () => Promise<
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}>;
|
|
292
|
+
getBlob: () => Promise<WriteBlobStepCertified>;
|
|
293
|
+
executeRegister: (options: WriteBlobFlowRegisterOptions & {
|
|
294
|
+
signer: Signer;
|
|
295
|
+
}) => Promise<WriteBlobStepRegistered>;
|
|
296
|
+
executeCertify: (options: {
|
|
297
|
+
signer: Signer;
|
|
298
|
+
}) => Promise<WriteBlobStepCertified>;
|
|
299
|
+
run: (options: WriteBlobFlowRunOptions) => AsyncIterable<WriteBlobStep>;
|
|
243
300
|
}
|
|
244
301
|
interface DeleteBlobOptions {
|
|
245
302
|
blobObjectId: string;
|
|
@@ -273,5 +330,5 @@ interface ProtocolMessageCertificate {
|
|
|
273
330
|
signature: Uint8Array;
|
|
274
331
|
}
|
|
275
332
|
//#endregion
|
|
276
|
-
export { 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 };
|
|
333
|
+
export { 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 };
|
|
277
334
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AAyBA;AAMC;AAYD;AAWY,UA7BK,mBAAA,CA6Be;EAMf;EASP,cAAA,EAAA,MAAA;EAWE;EAAqB,aAAA,EAAA,MAAA;EAChC,WAAA,CAAA,EAAA,MAAA,EAAA;;KAhDI,4BAAA,GAiDyB;EAGlB,OAAA,EAAA,SAAa,GAAA,SAAA;EAAoB,aAAA,CAAA,EAjD1B,mBAiD0B;CAC5B,GAAA;EACT,OAAA,CAAA,EAAA,KAAA;EAAI,aAAA,EA/CM,mBA+CN;AAGZ,CAAA;AAIY,KAnDA,WAAA,GAmDA;EAEK,KAAA,EAAA,MAAA,GAAW,MAAA;AAQ5B,CAAA,GAAiB;EACU,MAAA,EAAA;IAAZ,IAAA,EAAA,MAAA,GAAA,MAAA;IACP,aAAA,EAAA,MAAA,GAAA,MAAA;EAAW,CAAA;AAGnB,CAAA;AASiB,KAhEL,oBAAA,GAgEyB;EAE1B,OAAA,EAAA,MAAA;EAGA,GAAA,CAAA,EAAA,MAAA;EAEG,IAAA,EApEP,WAoEO;CAP+B;AAAsB,UA1DlD,iBAAA,SAA0B,wBA0DwB,CAAA;EAUvD,OAAA,CAAA,EAAA,IAAA,GAjER,oBA0Ee,GAAA;
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AAyBA;AAMC;AAYD;AAWY,UA7BK,mBAAA,CA6Be;EAMf;EASP,cAAA,EAAA,MAAA;EAWE;EAAqB,aAAA,EAAA,MAAA;EAChC,WAAA,CAAA,EAAA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QAAQ;iBAE1C,4BAA4B,cAAc;;UAGzC,iBAAA;;;KAIL,iBAAA;;;YAGD;;;;;;;;;;KAcC,0BAAA;cACC;;cAGE;;;;;;KASH,YAAA,GAAe,eAAe,YAAA,CAAa;UAEtC,0BAAA;;qBAEG;aACR"}
|
package/dist/utils/bcs.mjs
CHANGED
|
@@ -123,7 +123,20 @@ const QuiltPatchBlobHeader = bcs.struct("QuiltPatchBlobHeader", {
|
|
|
123
123
|
length: bcs.u32(),
|
|
124
124
|
mask: bcs.u8()
|
|
125
125
|
});
|
|
126
|
+
const CertificateBcs = bcs.struct("Certificate", {
|
|
127
|
+
signers: bcs.vector(bcs.u16()),
|
|
128
|
+
serializedMessage: bcs.byteVector(),
|
|
129
|
+
signature: bcs.byteVector()
|
|
130
|
+
});
|
|
131
|
+
function parseCertificateFromBase64(base64) {
|
|
132
|
+
const cert = CertificateBcs.fromBase64(base64);
|
|
133
|
+
return {
|
|
134
|
+
signers: cert.signers,
|
|
135
|
+
serializedMessage: new Uint8Array(cert.serializedMessage),
|
|
136
|
+
signature: new Uint8Array(cert.signature)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
126
139
|
|
|
127
140
|
//#endregion
|
|
128
|
-
export { BlobId, BlobMetadata, BlobMetadataWithId, Field, IntentType, QuiltIndexV1, QuiltPatchBlobHeader, QuiltPatchId, QuiltPatchTags, SliverData, StorageConfirmation, blobIdFromBytes, blobIdFromInt, blobIdToInt };
|
|
141
|
+
export { BlobId, BlobMetadata, BlobMetadataWithId, CertificateBcs, Field, IntentType, QuiltIndexV1, QuiltPatchBlobHeader, QuiltPatchId, QuiltPatchTags, SliverData, StorageConfirmation, blobIdFromBytes, blobIdFromInt, blobIdToInt, parseCertificateFromBase64 };
|
|
129
142
|
//# sourceMappingURL=bcs.mjs.map
|
package/dist/utils/bcs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bcs.mjs","names":[],"sources":["../../src/utils/bcs.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/sui/bcs';\nimport { bcs } from '@mysten/sui/bcs';\n\nconst MerkleNode = bcs.enum('MerkleNode', {\n\tEmpty: null,\n\tDigest: bcs.bytes(32),\n});\n\nconst SliverPairMetadata = bcs.struct('SliverPairMetadata', {\n\tprimary_hash: MerkleNode,\n\tsecondary_hash: MerkleNode,\n});\n\nexport const EncodingType = bcs\n\t.enum('EncodingType', {\n\t\tRedStuff: null,\n\t\tRS2: null,\n\t})\n\t.transform({\n\t\tinput: (\n\t\t\tencodingType:\n\t\t\t\t| { RedStuff: boolean | object | null }\n\t\t\t\t| { RS2: boolean | object | null }\n\t\t\t\t| 'RedStuff'\n\t\t\t\t| 'RS2',\n\t\t) =>\n\t\t\ttypeof encodingType === 'string'\n\t\t\t\t? ({ [encodingType]: null } as Exclude<typeof encodingType, string>)\n\t\t\t\t: encodingType,\n\t\toutput: (encodingType) => encodingType,\n\t});\n\nexport const BlobMetadataV1 = bcs.struct('BlobMetadataV1', {\n\tencoding_type: EncodingType,\n\tunencoded_length: bcs.u64(),\n\thashes: bcs.vector(SliverPairMetadata),\n});\n\nexport const BlobMetadata = bcs.enum('BlobMetadata', {\n\tV1: BlobMetadataV1,\n});\n\nexport const BlobId = bcs.u256().transform({\n\tinput: (blobId: string | bigint) => (typeof blobId === 'string' ? blobIdToInt(blobId) : blobId),\n\toutput: (id: string) => blobIdFromInt(id),\n});\n\nexport function blobIdFromInt(blobId: bigint | string): string {\n\treturn bcs\n\t\t.u256()\n\t\t.serialize(blobId)\n\t\t.toBase64()\n\t\t.replace(/=*$/, '')\n\t\t.replaceAll('+', '-')\n\t\t.replaceAll('/', '_');\n}\n\nexport function blobIdFromBytes(blobId: Uint8Array): string {\n\treturn blobIdFromInt(bcs.u256().parse(blobId));\n}\n\nexport function blobIdToInt(blobId: string): bigint {\n\treturn BigInt(bcs.u256().fromBase64(blobId.replaceAll('-', '+').replaceAll('_', '/')));\n}\n\nexport const BlobMetadataWithId = bcs.struct('BlobMetadataWithId', {\n\tblobId: BlobId,\n\tmetadata: BlobMetadata,\n});\n\nconst Symbols = bcs.struct('Symbols', {\n\tdata: bcs.byteVector(),\n\tsymbol_size: bcs.u16(),\n});\n\nexport const SliverData = bcs.struct('SliverData', {\n\tsymbols: Symbols,\n\tindex: bcs.u16(),\n});\n\nexport const Sliver = bcs.enum('Sliver', {\n\tPrimary: SliverData,\n\tSecondary: SliverData,\n});\n\nexport const SliverPair = bcs.struct('SliverPair', {\n\tprimary: SliverData,\n\tsecondary: SliverData,\n});\n\nexport enum IntentType {\n\tPROOF_OF_POSSESSION_MSG = 0,\n\tBLOB_CERT_MSG = 1,\n\tINVALID_BLOB_ID_MSG = 2,\n\tSYNC_SHARD_MSG = 3,\n}\n\nexport const Intent = bcs\n\t.struct('Intent', {\n\t\ttype: bcs.u8().transform({\n\t\t\tinput: (type: IntentType) => type,\n\t\t\toutput: (type: number) => type as IntentType,\n\t\t}),\n\t\tversion: bcs.u8(),\n\t\tappId: bcs.u8(),\n\t})\n\t.transform({\n\t\tinput: (intent: IntentType) => ({\n\t\t\ttype: intent,\n\t\t\tversion: 0,\n\t\t\tappId: 3,\n\t\t}),\n\t\toutput: (intent) => intent.type,\n\t});\n\nexport function ProtocolMessage<T extends BcsType<any>>(messageContents: T) {\n\treturn bcs.struct(`ProtocolMessage<${messageContents.name}>`, {\n\t\tintent: Intent,\n\t\tepoch: bcs.u32(),\n\t\tmessageContents,\n\t});\n}\n\nexport const BlobPersistenceType = bcs.enum('BlobPersistenceType', {\n\tPermanent: null,\n\tDeletable: bcs.struct('Deletable', {\n\t\tobjectId: bcs.Address,\n\t}),\n});\nexport const StorageConfirmationBody = bcs.struct('StorageConfirmationBody', {\n\tblobId: BlobId,\n\tblobType: BlobPersistenceType,\n});\n\nexport const StorageConfirmation = ProtocolMessage(StorageConfirmationBody);\n\nexport function Field<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn bcs.struct('Field', {\n\t\tid: bcs.Address,\n\t\tname: typeParameters[0],\n\t\tvalue: typeParameters[1],\n\t});\n}\n\nexport const QuiltPatchTags = bcs.map(bcs.string(), bcs.string()).transform({\n\t// Accept both Record and Map as input, bcs.map() handles sorting automatically\n\tinput: (tags: Record<string, string> | Map<string, string>) =>\n\t\ttags instanceof Map ? tags : new Map(Object.entries(tags)),\n\toutput: (tags: Map<string, string>) => Object.fromEntries(tags),\n});\n\nexport const QuiltPatchV1 = bcs.struct('QuiltPatchV1', {\n\tendIndex: bcs.u16(),\n\tidentifier: bcs.string(),\n\ttags: QuiltPatchTags,\n});\n\nexport const QuiltIndexV1 = bcs.struct('QuiltIndexV1', {\n\tpatches: bcs.vector(QuiltPatchV1),\n});\n\nexport const QuiltPatchId = bcs.struct('QuiltPatchId', {\n\tquiltId: BlobId,\n\tpatchId: bcs.struct('InternalQuiltPatchId', {\n\t\tversion: bcs.u8(),\n\t\tstartIndex: bcs.u16(),\n\t\tendIndex: bcs.u16(),\n\t}),\n});\n\nexport const QuiltPatchBlobHeader = bcs.struct('QuiltPatchBlobHeader', {\n\tversion: bcs.u8(),\n\tlength: bcs.u32(),\n\tmask: bcs.u8(),\n});\n"],"mappings":";;;AAMA,MAAM,aAAa,IAAI,KAAK,cAAc;CACzC,OAAO;CACP,QAAQ,IAAI,MAAM,GAAG;CACrB,CAAC;AAEF,MAAM,qBAAqB,IAAI,OAAO,sBAAsB;CAC3D,cAAc;CACd,gBAAgB;CAChB,CAAC;AAEF,MAAa,eAAe,IAC1B,KAAK,gBAAgB;CACrB,UAAU;CACV,KAAK;CACL,CAAC,CACD,UAAU;CACV,QACC,iBAMA,OAAO,iBAAiB,WACpB,GAAG,eAAe,MAAM,GACzB;CACJ,SAAS,iBAAiB;CAC1B,CAAC;AAEH,MAAa,iBAAiB,IAAI,OAAO,kBAAkB;CAC1D,eAAe;CACf,kBAAkB,IAAI,KAAK;CAC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AAwB;CACtE,SAAS,IAAI,IAAI;CACjB,QAAQ,IAAI,KAAK;CACjB,MAAM,IAAI,IAAI;CACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"bcs.mjs","names":[],"sources":["../../src/utils/bcs.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/sui/bcs';\nimport { bcs } from '@mysten/sui/bcs';\n\nconst MerkleNode = bcs.enum('MerkleNode', {\n\tEmpty: null,\n\tDigest: bcs.bytes(32),\n});\n\nconst SliverPairMetadata = bcs.struct('SliverPairMetadata', {\n\tprimary_hash: MerkleNode,\n\tsecondary_hash: MerkleNode,\n});\n\nexport const EncodingType = bcs\n\t.enum('EncodingType', {\n\t\tRedStuff: null,\n\t\tRS2: null,\n\t})\n\t.transform({\n\t\tinput: (\n\t\t\tencodingType:\n\t\t\t\t| { RedStuff: boolean | object | null }\n\t\t\t\t| { RS2: boolean | object | null }\n\t\t\t\t| 'RedStuff'\n\t\t\t\t| 'RS2',\n\t\t) =>\n\t\t\ttypeof encodingType === 'string'\n\t\t\t\t? ({ [encodingType]: null } as Exclude<typeof encodingType, string>)\n\t\t\t\t: encodingType,\n\t\toutput: (encodingType) => encodingType,\n\t});\n\nexport const BlobMetadataV1 = bcs.struct('BlobMetadataV1', {\n\tencoding_type: EncodingType,\n\tunencoded_length: bcs.u64(),\n\thashes: bcs.vector(SliverPairMetadata),\n});\n\nexport const BlobMetadata = bcs.enum('BlobMetadata', {\n\tV1: BlobMetadataV1,\n});\n\nexport const BlobId = bcs.u256().transform({\n\tinput: (blobId: string | bigint) => (typeof blobId === 'string' ? blobIdToInt(blobId) : blobId),\n\toutput: (id: string) => blobIdFromInt(id),\n});\n\nexport function blobIdFromInt(blobId: bigint | string): string {\n\treturn bcs\n\t\t.u256()\n\t\t.serialize(blobId)\n\t\t.toBase64()\n\t\t.replace(/=*$/, '')\n\t\t.replaceAll('+', '-')\n\t\t.replaceAll('/', '_');\n}\n\nexport function blobIdFromBytes(blobId: Uint8Array): string {\n\treturn blobIdFromInt(bcs.u256().parse(blobId));\n}\n\nexport function blobIdToInt(blobId: string): bigint {\n\treturn BigInt(bcs.u256().fromBase64(blobId.replaceAll('-', '+').replaceAll('_', '/')));\n}\n\nexport const BlobMetadataWithId = bcs.struct('BlobMetadataWithId', {\n\tblobId: BlobId,\n\tmetadata: BlobMetadata,\n});\n\nconst Symbols = bcs.struct('Symbols', {\n\tdata: bcs.byteVector(),\n\tsymbol_size: bcs.u16(),\n});\n\nexport const SliverData = bcs.struct('SliverData', {\n\tsymbols: Symbols,\n\tindex: bcs.u16(),\n});\n\nexport const Sliver = bcs.enum('Sliver', {\n\tPrimary: SliverData,\n\tSecondary: SliverData,\n});\n\nexport const SliverPair = bcs.struct('SliverPair', {\n\tprimary: SliverData,\n\tsecondary: SliverData,\n});\n\nexport enum IntentType {\n\tPROOF_OF_POSSESSION_MSG = 0,\n\tBLOB_CERT_MSG = 1,\n\tINVALID_BLOB_ID_MSG = 2,\n\tSYNC_SHARD_MSG = 3,\n}\n\nexport const Intent = bcs\n\t.struct('Intent', {\n\t\ttype: bcs.u8().transform({\n\t\t\tinput: (type: IntentType) => type,\n\t\t\toutput: (type: number) => type as IntentType,\n\t\t}),\n\t\tversion: bcs.u8(),\n\t\tappId: bcs.u8(),\n\t})\n\t.transform({\n\t\tinput: (intent: IntentType) => ({\n\t\t\ttype: intent,\n\t\t\tversion: 0,\n\t\t\tappId: 3,\n\t\t}),\n\t\toutput: (intent) => intent.type,\n\t});\n\nexport function ProtocolMessage<T extends BcsType<any>>(messageContents: T) {\n\treturn bcs.struct(`ProtocolMessage<${messageContents.name}>`, {\n\t\tintent: Intent,\n\t\tepoch: bcs.u32(),\n\t\tmessageContents,\n\t});\n}\n\nexport const BlobPersistenceType = bcs.enum('BlobPersistenceType', {\n\tPermanent: null,\n\tDeletable: bcs.struct('Deletable', {\n\t\tobjectId: bcs.Address,\n\t}),\n});\nexport const StorageConfirmationBody = bcs.struct('StorageConfirmationBody', {\n\tblobId: BlobId,\n\tblobType: BlobPersistenceType,\n});\n\nexport const StorageConfirmation = ProtocolMessage(StorageConfirmationBody);\n\nexport function Field<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn bcs.struct('Field', {\n\t\tid: bcs.Address,\n\t\tname: typeParameters[0],\n\t\tvalue: typeParameters[1],\n\t});\n}\n\nexport const QuiltPatchTags = bcs.map(bcs.string(), bcs.string()).transform({\n\t// Accept both Record and Map as input, bcs.map() handles sorting automatically\n\tinput: (tags: Record<string, string> | Map<string, string>) =>\n\t\ttags instanceof Map ? tags : new Map(Object.entries(tags)),\n\toutput: (tags: Map<string, string>) => Object.fromEntries(tags),\n});\n\nexport const QuiltPatchV1 = bcs.struct('QuiltPatchV1', {\n\tendIndex: bcs.u16(),\n\tidentifier: bcs.string(),\n\ttags: QuiltPatchTags,\n});\n\nexport const QuiltIndexV1 = bcs.struct('QuiltIndexV1', {\n\tpatches: bcs.vector(QuiltPatchV1),\n});\n\nexport const QuiltPatchId = bcs.struct('QuiltPatchId', {\n\tquiltId: BlobId,\n\tpatchId: bcs.struct('InternalQuiltPatchId', {\n\t\tversion: bcs.u8(),\n\t\tstartIndex: bcs.u16(),\n\t\tendIndex: bcs.u16(),\n\t}),\n});\n\nexport const QuiltPatchBlobHeader = bcs.struct('QuiltPatchBlobHeader', {\n\tversion: bcs.u8(),\n\tlength: bcs.u32(),\n\tmask: bcs.u8(),\n});\n\nexport const CertificateBcs = bcs.struct('Certificate', {\n\tsigners: bcs.vector(bcs.u16()),\n\tserializedMessage: bcs.byteVector(),\n\tsignature: bcs.byteVector(),\n});\n\nexport function parseCertificateFromBase64(base64: string) {\n\tconst cert = CertificateBcs.fromBase64(base64);\n\treturn {\n\t\tsigners: cert.signers,\n\t\tserializedMessage: new Uint8Array(cert.serializedMessage),\n\t\tsignature: new Uint8Array(cert.signature),\n\t};\n}\n"],"mapp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B,OAAO,YAAY,KAAK;CAC/D,CAAC;AAEF,MAAa,eAAe,IAAI,OAAO,gBAAgB;CACtD,UAAU,IAAI,KAAK;CACnB,YAAY,IAAI,QAAQ;CACxB,MAAM;CACN,CAAC;AAEF,MAAa,eAAe,IAAI,OAAO,gBAAgB,EACtD,SAAS,IAAI,OAAO,aAAa,EACjC,CAAC;AAEF,MAAa,eAAe,IAAI,OAAO,gBAAgB;CACtD,SAAS;CACT,SAAS,IAAI,OAAO,wBAAwB;EAC3C,SAAS,IAAI,IAAI;EACjB,YAAY,IAAI,KAAK;EACrB,UAAU,IAAI,KAAK;EACnB,CAAC;CACF,CAAC;AAEF,MAAa,uBAAuB,IAAI,OAAO,wBAAwB;CACtE,SAAS,IAAI,IAAI;CACjB,QAAQ,IAAI,KAAK;CACjB,MAAM,IAAI,IAAI;CACd,CAAC;AAEF,MAAa,iBAAiB,IAAI,OAAO,eAAe;CACvD,SAAS,IAAI,OAAO,IAAI,KAAK,CAAC;CAC9B,mBAAmB,IAAI,YAAY;CACnC,WAAW,IAAI,YAAY;CAC3B,CAAC;AAEF,SAAgB,2BAA2B,QAAgB;CAC1D,MAAM,OAAO,eAAe,WAAW,OAAO;AAC9C,QAAO;EACN,SAAS,KAAK;EACd,mBAAmB,IAAI,WAAW,KAAK,kBAAkB;EACzD,WAAW,IAAI,WAAW,KAAK,UAAU;EACzC"}
|
package/docs/index.md
CHANGED
|
@@ -258,6 +258,45 @@ async function handleCertify() {
|
|
|
258
258
|
This approach ensures that each transaction signing step is separated into different user
|
|
259
259
|
interactions, allowing wallet popups to work properly without being blocked by the browser.
|
|
260
260
|
|
|
261
|
+
### Running the full flow
|
|
262
|
+
|
|
263
|
+
If you don't need separate user interactions for each step, you can use `run()` to execute the full
|
|
264
|
+
pipeline as an async iterator. Each step yields a `WriteBlobStep` that you can persist for crash
|
|
265
|
+
recovery:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
const flow = client.walrus.writeBlobFlow({ blob });
|
|
269
|
+
|
|
270
|
+
for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {
|
|
271
|
+
await db.save(fileId, step); // persist for crash recovery
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
The flow also provides `executeRegister` and `executeCertify` methods that handle signing and return
|
|
276
|
+
typed step results:
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
const flow = client.walrus.writeBlobFlow({ blob });
|
|
280
|
+
const enc = await flow.encode();
|
|
281
|
+
const reg = await flow.executeRegister({ signer, epochs: 3, deletable: true, owner: address });
|
|
282
|
+
const up = await flow.upload({ digest: reg.txDigest });
|
|
283
|
+
const cert = await flow.executeCertify({ signer });
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Resuming uploads
|
|
287
|
+
|
|
288
|
+
To resume an upload after a crash, pass a saved `WriteBlobStep` as `resume`. The flow will skip
|
|
289
|
+
completed steps, validate the blobId, and only upload slivers that aren't already stored:
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
const saved = await db.load(fileId);
|
|
293
|
+
const flow = client.walrus.writeBlobFlow({ blob, resume: saved });
|
|
294
|
+
|
|
295
|
+
for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {
|
|
296
|
+
await db.save(fileId, step);
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
261
300
|
## Writing blobs with an upload relay
|
|
262
301
|
|
|
263
302
|
Writing blobs directly from a client requires a lot of requests to write data to all the storage
|
|
@@ -371,6 +410,19 @@ const { blobId } = await client.walrus.writeBlob({
|
|
|
371
410
|
});
|
|
372
411
|
```
|
|
373
412
|
|
|
413
|
+
`writeBlob` and `writeFiles` also support `onStep` and `resume` for crash-recoverable uploads:
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
const { blobId } = await client.walrus.writeBlob({
|
|
417
|
+
blob: file,
|
|
418
|
+
deletable: true,
|
|
419
|
+
epochs: 3,
|
|
420
|
+
signer: keypair,
|
|
421
|
+
onStep: (step) => db.save(fileId, step),
|
|
422
|
+
resume: await db.load(fileId), // pass a previously saved step to resume
|
|
423
|
+
});
|
|
424
|
+
```
|
|
425
|
+
|
|
374
426
|
## Full API
|
|
375
427
|
|
|
376
428
|
For a complete overview of the available methods on the `WalrusClient` you can reference type
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysten/walrus",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Walrus SDK",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,32 +30,32 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://sdk.mystenlabs.com/walrus",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@hono/node-server": "^1.19.
|
|
33
|
+
"@hono/node-server": "^1.19.11",
|
|
34
34
|
"@tanstack/react-query": "^5.90.16",
|
|
35
35
|
"@types/node": "^25.0.8",
|
|
36
36
|
"@types/react": "^19.2.8",
|
|
37
37
|
"@types/react-dom": "^19.2.3",
|
|
38
38
|
"@vitejs/plugin-react": "^5.1.2",
|
|
39
|
-
"hono": "^4.12.
|
|
39
|
+
"hono": "^4.12.8",
|
|
40
40
|
"react": "^19.2.3",
|
|
41
41
|
"react-dom": "^19.2.3",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
|
-
"undici": "^7.
|
|
43
|
+
"undici": "^7.24.4",
|
|
44
44
|
"vite": "^7.3.1",
|
|
45
45
|
"vitest": "^4.0.17",
|
|
46
46
|
"@mysten/codegen": "^0.8.3",
|
|
47
|
-
"@mysten/dapp-kit-core": "^1.2.0",
|
|
48
47
|
"@mysten/dapp-kit-react": "^2.0.1",
|
|
49
|
-
"@mysten/
|
|
48
|
+
"@mysten/dapp-kit-core": "^1.2.0",
|
|
49
|
+
"@mysten/sui": "^2.9.1"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"dataloader": "^2.2.3",
|
|
53
|
-
"@mysten/bcs": "^2.0.3",
|
|
54
53
|
"@mysten/utils": "^0.3.1",
|
|
54
|
+
"@mysten/bcs": "^2.0.3",
|
|
55
55
|
"@mysten/walrus-wasm": "^0.2.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@mysten/sui": "^2.
|
|
58
|
+
"@mysten/sui": "^2.9.1"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|