@mysten/walrus 0.0.11 → 0.0.13

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { WalrusClient } from './client.js';\nexport { type WalrusClientConfig, type WalrusPackageConfig } from './types.js';\nexport { TESTNET_WALRUS_PACKAGE_CONFIG } from './constants.js';\nexport { type StorageNodeClientOptions } from './storage-node/client.js';\nexport type * from './types.js';\nexport * from './storage-node/error.js';\nexport * from './error.js';\n\nexport { blobIdFromInt, blobIdToInt } from './utils/bcs.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAE7B,uBAA8C;AAG9C,0BAAc,oCARd;AASA,0BAAc,uBATd;AAWA,iBAA2C;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { WalrusClient } from './client.js';\nexport { type WalrusClientConfig, type WalrusPackageConfig } from './types.js';\nexport { TESTNET_WALRUS_PACKAGE_CONFIG, MAINNET_WALRUS_PACKAGE_CONFIG } from './constants.js';\nexport { type StorageNodeClientOptions } from './storage-node/client.js';\nexport type * from './types.js';\nexport * from './storage-node/error.js';\nexport * from './error.js';\n\nexport { blobIdFromInt, blobIdToInt } from './utils/bcs.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAE7B,uBAA6E;AAG7E,0BAAc,oCARd;AASA,0BAAc,uBATd;AAWA,iBAA2C;",
6
6
  "names": []
7
7
  }
@@ -39,6 +39,7 @@ type WalrusNetworkOrPackageConfig = {
39
39
  */
40
40
  export type WalrusClientConfig = {
41
41
  storageNodeClientOptions?: StorageNodeClientOptions;
42
+ wasmUrl?: string;
42
43
  } & WalrusNetworkOrPackageConfig & SuiClientOrRpcUrl;
43
44
  export type WalrusClientRequestOptions = Pick<RequestOptions, 'signal'>;
44
45
  export interface StorageNode {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/storage_node.js';\nimport type { RequestOptions, StorageNodeClientOptions } from './storage-node/client.js';\nimport type {\n\tStorageConfirmation,\n\tStoreBlobMetadataRequestInput,\n\tStoreSliverRequestInput,\n\tUploadable,\n} from './storage-node/types.js';\nimport type { BlobMetadata, EncodingType } from './utils/bcs.js';\n\n/**\n * Configuration for the Walrus package on sui\n *\n * This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID.\n */\nexport interface WalrusPackageConfig {\n\t/** The system object ID of the Walrus package */\n\tsystemObjectId: string;\n\t/** The staking pool ID of the Walrus package */\n\tstakingPoolId: string;\n\tsubsidiesObjectId?: string;\n\texchangeIds?: string[];\n}\n\ntype SuiClientOrRpcUrl =\n\t| {\n\t\t\tsuiClient: SuiClient;\n\t\t\tsuiRpcUrl?: never;\n\t }\n\t| {\n\t\t\tsuiRpcUrl: string;\n\t\t\tsuiClient?: never;\n\t };\n\ntype WalrusNetworkOrPackageConfig =\n\t| {\n\t\t\tnetwork: 'mainnet' | 'testnet';\n\t\t\tpackageConfig?: WalrusPackageConfig;\n\t }\n\t| {\n\t\t\tnetwork?: never;\n\t\t\tpackageConfig: WalrusPackageConfig;\n\t };\n\n/**\n * Configuration for the Walrus client.\n *\n * This is used to configure the Walrus client to use a specific storage node client options, network, and Sui client or RPC URL.\n */\nexport type WalrusClientConfig = {\n\tstorageNodeClientOptions?: StorageNodeClientOptions;\n} & WalrusNetworkOrPackageConfig &\n\tSuiClientOrRpcUrl;\n\nexport type WalrusClientRequestOptions = Pick<RequestOptions, 'signal'>;\n\nexport interface StorageNode {\n\tnetworkUrl: string;\n\tinfo: ReturnType<typeof StorageNodeInfo>['$inferType'];\n\tshardIndices: number[];\n\tnodeIndex: number;\n\tid: string;\n}\n\nexport interface CommitteeInfo {\n\tbyShardIndex: Map<number, StorageNode>;\n\tnodes: StorageNode[];\n}\n\nexport interface StorageWithSizeOptions {\n\t/** The encoded size of the blob. */\n\tsize: number;\n\t/** The number of epoch the storage will be reserved for. */\n\tepochs: number;\n\t/** Owner of the storage object. */\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n}\n\nexport interface RegisterBlobOptions extends StorageWithSizeOptions {\n\tblobId: string;\n\trootHash: Uint8Array;\n\tdeletable: boolean;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n}\n\nexport interface CertifyBlobOptions {\n\tblobId: string;\n\tblobObjectId: string;\n\t/** An array of confirmations.\n\t * These confirmations must be provided in the same order as the nodes in the committee.\n\t * For nodes that have not provided a confirmation you can pass `null` */\n\tconfirmations: (StorageConfirmation | null)[];\n\tdeletable: boolean;\n}\n\ntype DeletableConfirmationOptions =\n\t| { deletable: false; objectId?: string }\n\t| { deletable: true; objectId: string };\n\nexport type GetStorageConfirmationOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type ReadBlobOptions = {\n\tblobId: string;\n} & WalrusClientRequestOptions;\n\nexport type GetCertificationEpochOptions = ReadBlobOptions;\n\nexport type GetBlobMetadataOptions = ReadBlobOptions;\n\nexport type GetSliversOptions = ReadBlobOptions;\n\nexport type GetVerifiedBlobStatusOptions = ReadBlobOptions;\n\nexport interface SliversForNode {\n\tprimary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n\tsecondary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n}\n\nexport type WriteSliversToNodeOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tslivers: SliversForNode;\n} & WalrusClientRequestOptions;\n\nexport type WriteSliverOptions = StoreSliverRequestInput & WalrusClientRequestOptions;\n\nexport type WriteMetadataOptions = {\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n} & StoreBlobMetadataRequestInput &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tslivers: SliversForNode;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobToNodesOptions = {\n\tblobId: string;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tsliversByNode: SliversForNode[];\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteBlobOptions = {\n\tblob: Uint8Array;\n\tdeletable: boolean;\n\t/** The number of epochs the blob should be stored for. */\n\tepochs: number;\n\tsigner: Signer;\n\t/** Where the blob should be transferred to after it is registered. Defaults to the signer address. */\n\towner?: string;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n} & WalrusClientRequestOptions;\n\nexport interface DeleteBlobOptions {\n\tblobObjectId: string;\n}\n\nexport type ExtendBlobOptions = {\n\tblobObjectId: string;\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n} & (\n\t| {\n\t\t\t/** The number of epochs the blob should be stored for. */\n\t\t\tepochs: number;\n\t\t\tendEpoch?: never;\n\t }\n\t| {\n\t\t\t/** The new end epoch for the storage period of the blob. */\n\t\t\tendEpoch: number;\n\t\t\tepochs?: never;\n\t }\n);\n\nexport type WriteBlobAttributesOptions = {\n\tattributes: Record<string, string | null>;\n} & (\n\t| {\n\t\t\tblobObject: TransactionObjectArgument;\n\t\t\tblobObjectId?: never;\n\t }\n\t| {\n\t\t\tblobObjectId: string;\n\t\t\tblobObject?: never;\n\t }\n);\n\nexport type EncodingType = Extract<typeof EncodingType.$inferInput, string>;\n"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/storage_node.js';\nimport type { RequestOptions, StorageNodeClientOptions } from './storage-node/client.js';\nimport type {\n\tStorageConfirmation,\n\tStoreBlobMetadataRequestInput,\n\tStoreSliverRequestInput,\n\tUploadable,\n} from './storage-node/types.js';\nimport type { BlobMetadata, EncodingType } from './utils/bcs.js';\n\n/**\n * Configuration for the Walrus package on sui\n *\n * This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID.\n */\nexport interface WalrusPackageConfig {\n\t/** The system object ID of the Walrus package */\n\tsystemObjectId: string;\n\t/** The staking pool ID of the Walrus package */\n\tstakingPoolId: string;\n\tsubsidiesObjectId?: string;\n\texchangeIds?: string[];\n}\n\ntype SuiClientOrRpcUrl =\n\t| {\n\t\t\tsuiClient: SuiClient;\n\t\t\tsuiRpcUrl?: never;\n\t }\n\t| {\n\t\t\tsuiRpcUrl: string;\n\t\t\tsuiClient?: never;\n\t };\n\ntype WalrusNetworkOrPackageConfig =\n\t| {\n\t\t\tnetwork: 'mainnet' | 'testnet';\n\t\t\tpackageConfig?: WalrusPackageConfig;\n\t }\n\t| {\n\t\t\tnetwork?: never;\n\t\t\tpackageConfig: WalrusPackageConfig;\n\t };\n\n/**\n * Configuration for the Walrus client.\n *\n * This is used to configure the Walrus client to use a specific storage node client options, network, and Sui client or RPC URL.\n */\nexport type WalrusClientConfig = {\n\tstorageNodeClientOptions?: StorageNodeClientOptions;\n\twasmUrl?: string;\n} & WalrusNetworkOrPackageConfig &\n\tSuiClientOrRpcUrl;\n\nexport type WalrusClientRequestOptions = Pick<RequestOptions, 'signal'>;\n\nexport interface StorageNode {\n\tnetworkUrl: string;\n\tinfo: ReturnType<typeof StorageNodeInfo>['$inferType'];\n\tshardIndices: number[];\n\tnodeIndex: number;\n\tid: string;\n}\n\nexport interface CommitteeInfo {\n\tbyShardIndex: Map<number, StorageNode>;\n\tnodes: StorageNode[];\n}\n\nexport interface StorageWithSizeOptions {\n\t/** The encoded size of the blob. */\n\tsize: number;\n\t/** The number of epoch the storage will be reserved for. */\n\tepochs: number;\n\t/** Owner of the storage object. */\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n}\n\nexport interface RegisterBlobOptions extends StorageWithSizeOptions {\n\tblobId: string;\n\trootHash: Uint8Array;\n\tdeletable: boolean;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n}\n\nexport interface CertifyBlobOptions {\n\tblobId: string;\n\tblobObjectId: string;\n\t/** An array of confirmations.\n\t * These confirmations must be provided in the same order as the nodes in the committee.\n\t * For nodes that have not provided a confirmation you can pass `null` */\n\tconfirmations: (StorageConfirmation | null)[];\n\tdeletable: boolean;\n}\n\ntype DeletableConfirmationOptions =\n\t| { deletable: false; objectId?: string }\n\t| { deletable: true; objectId: string };\n\nexport type GetStorageConfirmationOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type ReadBlobOptions = {\n\tblobId: string;\n} & WalrusClientRequestOptions;\n\nexport type GetCertificationEpochOptions = ReadBlobOptions;\n\nexport type GetBlobMetadataOptions = ReadBlobOptions;\n\nexport type GetSliversOptions = ReadBlobOptions;\n\nexport type GetVerifiedBlobStatusOptions = ReadBlobOptions;\n\nexport interface SliversForNode {\n\tprimary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n\tsecondary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n}\n\nexport type WriteSliversToNodeOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tslivers: SliversForNode;\n} & WalrusClientRequestOptions;\n\nexport type WriteSliverOptions = StoreSliverRequestInput & WalrusClientRequestOptions;\n\nexport type WriteMetadataOptions = {\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n} & StoreBlobMetadataRequestInput &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tslivers: SliversForNode;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobToNodesOptions = {\n\tblobId: string;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tsliversByNode: SliversForNode[];\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteBlobOptions = {\n\tblob: Uint8Array;\n\tdeletable: boolean;\n\t/** The number of epochs the blob should be stored for. */\n\tepochs: number;\n\tsigner: Signer;\n\t/** Where the blob should be transferred to after it is registered. Defaults to the signer address. */\n\towner?: string;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n} & WalrusClientRequestOptions;\n\nexport interface DeleteBlobOptions {\n\tblobObjectId: string;\n}\n\nexport type ExtendBlobOptions = {\n\tblobObjectId: string;\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n} & (\n\t| {\n\t\t\t/** The number of epochs the blob should be stored for. */\n\t\t\tepochs: number;\n\t\t\tendEpoch?: never;\n\t }\n\t| {\n\t\t\t/** The new end epoch for the storage period of the blob. */\n\t\t\tendEpoch: number;\n\t\t\tepochs?: never;\n\t }\n);\n\nexport type WriteBlobAttributesOptions = {\n\tattributes: Record<string, string | null>;\n} & (\n\t| {\n\t\t\tblobObject: TransactionObjectArgument;\n\t\t\tblobObjectId?: never;\n\t }\n\t| {\n\t\t\tblobObjectId: string;\n\t\t\tblobObject?: never;\n\t }\n);\n\nexport type EncodingType = Extract<typeof EncodingType.$inferInput, string>;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -7,15 +7,17 @@ export interface EncodedBlob {
7
7
  metadata: typeof BlobMetadata.$inferInput;
8
8
  rootHash: Uint8Array;
9
9
  }
10
- export declare function encodeBlob(nShards: number, bytes: Uint8Array, encodingType?: EncodingType): Promise<EncodedBlob>;
11
10
  export interface CombinedSignature {
12
11
  signers: number[];
13
12
  serializedMessage: Uint8Array;
14
13
  signature: Uint8Array;
15
14
  }
16
- export declare function combineSignatures(confirmations: StorageConfirmation[], signerIndices: number[]): Promise<CombinedSignature>;
17
- export declare function decodePrimarySlivers(blobId: string, nShards: number, size: number | bigint | string, slivers: (typeof SliverData.$inferInput)[], encodingType?: EncodingType): Uint8Array;
18
- export declare function getVerifySignature(): Promise<(confirmation: StorageConfirmation, publicKey: Uint8Array) => boolean>;
19
- export declare function computeMetadata(nShards: number, bytes: Uint8Array, encodingType?: EncodingType): typeof BlobMetadataWithId.$inferInput & {
20
- blob_id: string;
21
- };
15
+ export declare function getWasmBindings(url?: string): Promise<{
16
+ encodeBlob: (nShards: number, bytes: Uint8Array, encodingType?: EncodingType) => EncodedBlob;
17
+ combineSignatures: (confirmations: StorageConfirmation[], signerIndices: number[]) => CombinedSignature;
18
+ decodePrimarySlivers: (blobId: string, nShards: number, size: number | bigint | string, slivers: (typeof SliverData.$inferInput)[], encodingType?: EncodingType) => Uint8Array;
19
+ getVerifySignature: () => (confirmation: StorageConfirmation, publicKey: Uint8Array) => boolean;
20
+ computeMetadata: (nShards: number, bytes: Uint8Array, encodingType?: EncodingType) => typeof BlobMetadataWithId.$inferInput & {
21
+ blob_id: string;
22
+ };
23
+ }>;
package/dist/cjs/wasm.js CHANGED
@@ -28,73 +28,76 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var wasm_exports = {};
30
30
  __export(wasm_exports, {
31
- combineSignatures: () => combineSignatures,
32
- computeMetadata: () => computeMetadata,
33
- decodePrimarySlivers: () => decodePrimarySlivers,
34
- encodeBlob: () => encodeBlob,
35
- getVerifySignature: () => getVerifySignature
31
+ getWasmBindings: () => getWasmBindings
36
32
  });
37
33
  module.exports = __toCommonJS(wasm_exports);
38
34
  var import_bcs = require("@mysten/bcs");
39
35
  var import_walrus_wasm = __toESM(require("@mysten/walrus-wasm"));
40
36
  var import_bcs2 = require("./utils/bcs.js");
41
- async function encodeBlob(nShards, bytes, encodingType = "RS2") {
42
- await (0, import_walrus_wasm.default)();
43
- const encoder = new import_walrus_wasm.BlobEncoder(nShards);
44
- if (encodingType !== "RS2") {
45
- throw new Error(`Unsupported encoding type: ${encodingType}`);
37
+ async function getWasmBindings(url) {
38
+ await (0, import_walrus_wasm.default)({ module_or_path: url });
39
+ function encodeBlob(nShards, bytes, encodingType = "RS2") {
40
+ const encoder = new import_walrus_wasm.BlobEncoder(nShards);
41
+ if (encodingType !== "RS2") {
42
+ throw new Error(`Unsupported encoding type: ${encodingType}`);
43
+ }
44
+ const [sliverPairs, metadata, rootHash] = encoder.encode_with_metadata(bytes);
45
+ return {
46
+ sliverPairs,
47
+ blobId: (0, import_bcs2.blobIdFromBytes)(new Uint8Array(metadata.blob_id)),
48
+ metadata: metadata.metadata,
49
+ rootHash: new Uint8Array(rootHash.Digest)
50
+ };
46
51
  }
47
- const [sliverPairs, metadata, rootHash] = encoder.encode_with_metadata(bytes);
48
- return {
49
- sliverPairs,
50
- blobId: (0, import_bcs2.blobIdFromBytes)(new Uint8Array(metadata.blob_id)),
51
- metadata: metadata.metadata,
52
- rootHash: new Uint8Array(rootHash.Digest)
53
- };
54
- }
55
- async function combineSignatures(confirmations, signerIndices) {
56
- await (0, import_walrus_wasm.default)();
57
- const signature = (0, import_walrus_wasm.bls12381_min_pk_aggregate)(
58
- confirmations.map((confirmation) => (0, import_bcs.fromBase64)(confirmation.signature))
59
- );
60
- return {
61
- signers: signerIndices,
62
- serializedMessage: (0, import_bcs.fromBase64)(confirmations[0].serializedMessage),
63
- signature
64
- };
65
- }
66
- function decodePrimarySlivers(blobId, nShards, size, slivers, encodingType = "RS2") {
67
- const encoder = new import_walrus_wasm.BlobEncoder(nShards);
68
- if (encodingType !== "RS2") {
69
- throw new Error(`Unsupported encoding type: ${encodingType}`);
52
+ function combineSignatures(confirmations, signerIndices) {
53
+ const signature = (0, import_walrus_wasm.bls12381_min_pk_aggregate)(
54
+ confirmations.map((confirmation) => (0, import_bcs.fromBase64)(confirmation.signature))
55
+ );
56
+ return {
57
+ signers: signerIndices,
58
+ serializedMessage: (0, import_bcs.fromBase64)(confirmations[0].serializedMessage),
59
+ signature
60
+ };
70
61
  }
71
- const [bytes] = encoder.decode(
72
- import_bcs2.BlobId.serialize(blobId).toBytes(),
73
- BigInt(size),
74
- slivers.map((sliver) => ({
75
- ...sliver,
76
- _sliver_type: void 0
77
- }))
78
- );
79
- return new Uint8Array(bytes);
80
- }
81
- async function getVerifySignature() {
82
- await (0, import_walrus_wasm.default)();
83
- return (confirmation, publicKey) => (0, import_walrus_wasm.bls12381_min_pk_verify)(
84
- (0, import_bcs.fromBase64)(confirmation.signature),
85
- publicKey,
86
- (0, import_bcs.fromBase64)(confirmation.serializedMessage)
87
- );
88
- }
89
- function computeMetadata(nShards, bytes, encodingType = "RS2") {
90
- const encoder = new import_walrus_wasm.BlobEncoder(nShards);
91
- const metadata = encoder.compute_metadata(bytes);
92
- if (encodingType !== "RS2") {
93
- throw new Error(`Unsupported encoding type: ${encodingType}`);
62
+ function decodePrimarySlivers(blobId, nShards, size, slivers, encodingType = "RS2") {
63
+ const encoder = new import_walrus_wasm.BlobEncoder(nShards);
64
+ if (encodingType !== "RS2") {
65
+ throw new Error(`Unsupported encoding type: ${encodingType}`);
66
+ }
67
+ const [bytes] = encoder.decode(
68
+ import_bcs2.BlobId.serialize(blobId).toBytes(),
69
+ BigInt(size),
70
+ slivers.map((sliver) => ({
71
+ ...sliver,
72
+ _sliver_type: void 0
73
+ }))
74
+ );
75
+ return new Uint8Array(bytes);
76
+ }
77
+ function getVerifySignature() {
78
+ return (confirmation, publicKey) => (0, import_walrus_wasm.bls12381_min_pk_verify)(
79
+ (0, import_bcs.fromBase64)(confirmation.signature),
80
+ publicKey,
81
+ (0, import_bcs.fromBase64)(confirmation.serializedMessage)
82
+ );
83
+ }
84
+ function computeMetadata(nShards, bytes, encodingType = "RS2") {
85
+ const encoder = new import_walrus_wasm.BlobEncoder(nShards);
86
+ const metadata = encoder.compute_metadata(bytes);
87
+ if (encodingType !== "RS2") {
88
+ throw new Error(`Unsupported encoding type: ${encodingType}`);
89
+ }
90
+ return {
91
+ ...metadata,
92
+ blob_id: (0, import_bcs2.blobIdFromBytes)(new Uint8Array(metadata.blob_id))
93
+ };
94
94
  }
95
95
  return {
96
- ...metadata,
97
- blob_id: (0, import_bcs2.blobIdFromBytes)(new Uint8Array(metadata.blob_id))
96
+ encodeBlob,
97
+ combineSignatures,
98
+ decodePrimarySlivers,
99
+ getVerifySignature,
100
+ computeMetadata
98
101
  };
99
102
  }
100
103
  //# sourceMappingURL=wasm.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/wasm.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@mysten/bcs';\nimport init, {\n\tBlobEncoder,\n\tbls12381_min_pk_aggregate,\n\tbls12381_min_pk_verify,\n} from '@mysten/walrus-wasm';\n\nimport type { StorageConfirmation } from './storage-node/types.js';\nimport type { EncodingType } from './types.js';\nimport type { BlobMetadata, BlobMetadataWithId, SliverData, SliverPair } from './utils/bcs.js';\nimport { BlobId, blobIdFromBytes } from './utils/bcs.js';\n\nexport interface EncodedBlob {\n\tsliverPairs: (typeof SliverPair.$inferInput)[];\n\tblobId: string;\n\tmetadata: typeof BlobMetadata.$inferInput;\n\trootHash: Uint8Array;\n}\n\nexport async function encodeBlob(\n\tnShards: number,\n\tbytes: Uint8Array,\n\tencodingType: EncodingType = 'RS2',\n): Promise<EncodedBlob> {\n\tawait init();\n\n\tconst encoder = new BlobEncoder(nShards);\n\n\tif (encodingType !== 'RS2') {\n\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t}\n\n\tconst [sliverPairs, metadata, rootHash] = encoder.encode_with_metadata(bytes);\n\n\treturn {\n\t\tsliverPairs,\n\t\tblobId: blobIdFromBytes(new Uint8Array(metadata.blob_id)),\n\t\tmetadata: metadata.metadata,\n\t\trootHash: new Uint8Array(rootHash.Digest),\n\t};\n}\n\nexport interface CombinedSignature {\n\tsigners: number[];\n\tserializedMessage: Uint8Array;\n\tsignature: Uint8Array;\n}\n\nexport async function combineSignatures(\n\tconfirmations: StorageConfirmation[],\n\tsignerIndices: number[],\n): Promise<CombinedSignature> {\n\tawait init();\n\n\tconst signature = bls12381_min_pk_aggregate(\n\t\tconfirmations.map((confirmation) => fromBase64(confirmation.signature)),\n\t);\n\n\treturn {\n\t\tsigners: signerIndices,\n\t\tserializedMessage: fromBase64(confirmations[0].serializedMessage),\n\t\tsignature,\n\t};\n}\n\nexport function decodePrimarySlivers(\n\tblobId: string,\n\tnShards: number,\n\tsize: number | bigint | string,\n\tslivers: (typeof SliverData.$inferInput)[],\n\tencodingType: EncodingType = 'RS2',\n): Uint8Array {\n\tconst encoder = new BlobEncoder(nShards);\n\n\tif (encodingType !== 'RS2') {\n\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t}\n\n\tconst [bytes] = encoder.decode(\n\t\tBlobId.serialize(blobId).toBytes(),\n\t\tBigInt(size),\n\t\tslivers.map((sliver) => ({\n\t\t\t...sliver,\n\t\t\t_sliver_type: undefined,\n\t\t})),\n\t);\n\n\treturn new Uint8Array(bytes);\n}\n\nexport async function getVerifySignature() {\n\tawait init();\n\treturn (confirmation: StorageConfirmation, publicKey: Uint8Array) =>\n\t\tbls12381_min_pk_verify(\n\t\t\tfromBase64(confirmation.signature),\n\t\t\tpublicKey,\n\t\t\tfromBase64(confirmation.serializedMessage),\n\t\t);\n}\n\nexport function computeMetadata(\n\tnShards: number,\n\tbytes: Uint8Array,\n\tencodingType: EncodingType = 'RS2',\n): typeof BlobMetadataWithId.$inferInput & { blob_id: string } {\n\tconst encoder = new BlobEncoder(nShards);\n\tconst metadata = encoder.compute_metadata(bytes);\n\n\tif (encodingType !== 'RS2') {\n\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t}\n\n\treturn {\n\t\t...metadata,\n\t\tblob_id: blobIdFromBytes(new Uint8Array(metadata.blob_id)),\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA2B;AAC3B,yBAIO;AAKP,IAAAA,cAAwC;AASxC,eAAsB,WACrB,SACA,OACA,eAA6B,OACN;AACvB,YAAM,mBAAAC,SAAK;AAEX,QAAM,UAAU,IAAI,+BAAY,OAAO;AAEvC,MAAI,iBAAiB,OAAO;AAC3B,UAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,EAC7D;AAEA,QAAM,CAAC,aAAa,UAAU,QAAQ,IAAI,QAAQ,qBAAqB,KAAK;AAE5E,SAAO;AAAA,IACN;AAAA,IACA,YAAQ,6BAAgB,IAAI,WAAW,SAAS,OAAO,CAAC;AAAA,IACxD,UAAU,SAAS;AAAA,IACnB,UAAU,IAAI,WAAW,SAAS,MAAM;AAAA,EACzC;AACD;AAQA,eAAsB,kBACrB,eACA,eAC6B;AAC7B,YAAM,mBAAAA,SAAK;AAEX,QAAM,gBAAY;AAAA,IACjB,cAAc,IAAI,CAAC,qBAAiB,uBAAW,aAAa,SAAS,CAAC;AAAA,EACvE;AAEA,SAAO;AAAA,IACN,SAAS;AAAA,IACT,uBAAmB,uBAAW,cAAc,CAAC,EAAE,iBAAiB;AAAA,IAChE;AAAA,EACD;AACD;AAEO,SAAS,qBACf,QACA,SACA,MACA,SACA,eAA6B,OAChB;AACb,QAAM,UAAU,IAAI,+BAAY,OAAO;AAEvC,MAAI,iBAAiB,OAAO;AAC3B,UAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,EAC7D;AAEA,QAAM,CAAC,KAAK,IAAI,QAAQ;AAAA,IACvB,mBAAO,UAAU,MAAM,EAAE,QAAQ;AAAA,IACjC,OAAO,IAAI;AAAA,IACX,QAAQ,IAAI,CAAC,YAAY;AAAA,MACxB,GAAG;AAAA,MACH,cAAc;AAAA,IACf,EAAE;AAAA,EACH;AAEA,SAAO,IAAI,WAAW,KAAK;AAC5B;AAEA,eAAsB,qBAAqB;AAC1C,YAAM,mBAAAA,SAAK;AACX,SAAO,CAAC,cAAmC,kBAC1C;AAAA,QACC,uBAAW,aAAa,SAAS;AAAA,IACjC;AAAA,QACA,uBAAW,aAAa,iBAAiB;AAAA,EAC1C;AACF;AAEO,SAAS,gBACf,SACA,OACA,eAA6B,OACiC;AAC9D,QAAM,UAAU,IAAI,+BAAY,OAAO;AACvC,QAAM,WAAW,QAAQ,iBAAiB,KAAK;AAE/C,MAAI,iBAAiB,OAAO;AAC3B,UAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,EAC7D;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,aAAS,6BAAgB,IAAI,WAAW,SAAS,OAAO,CAAC;AAAA,EAC1D;AACD;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@mysten/bcs';\nimport init, {\n\tBlobEncoder,\n\tbls12381_min_pk_aggregate,\n\tbls12381_min_pk_verify,\n} from '@mysten/walrus-wasm';\n\nimport type { StorageConfirmation } from './storage-node/types.js';\nimport type { EncodingType } from './types.js';\nimport type { BlobMetadata, BlobMetadataWithId, SliverData, SliverPair } from './utils/bcs.js';\nimport { BlobId, blobIdFromBytes } from './utils/bcs.js';\n\nexport interface EncodedBlob {\n\tsliverPairs: (typeof SliverPair.$inferInput)[];\n\tblobId: string;\n\tmetadata: typeof BlobMetadata.$inferInput;\n\trootHash: Uint8Array;\n}\n\nexport interface CombinedSignature {\n\tsigners: number[];\n\tserializedMessage: Uint8Array;\n\tsignature: Uint8Array;\n}\n\nexport async function getWasmBindings(url?: string) {\n\tawait init({ module_or_path: url });\n\n\tfunction encodeBlob(\n\t\tnShards: number,\n\t\tbytes: Uint8Array,\n\t\tencodingType: EncodingType = 'RS2',\n\t): EncodedBlob {\n\t\tconst encoder = new BlobEncoder(nShards);\n\n\t\tif (encodingType !== 'RS2') {\n\t\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t\t}\n\n\t\tconst [sliverPairs, metadata, rootHash] = encoder.encode_with_metadata(bytes);\n\n\t\treturn {\n\t\t\tsliverPairs,\n\t\t\tblobId: blobIdFromBytes(new Uint8Array(metadata.blob_id)),\n\t\t\tmetadata: metadata.metadata,\n\t\t\trootHash: new Uint8Array(rootHash.Digest),\n\t\t};\n\t}\n\n\tfunction combineSignatures(\n\t\tconfirmations: StorageConfirmation[],\n\t\tsignerIndices: number[],\n\t): CombinedSignature {\n\t\tconst signature = bls12381_min_pk_aggregate(\n\t\t\tconfirmations.map((confirmation) => fromBase64(confirmation.signature)),\n\t\t);\n\n\t\treturn {\n\t\t\tsigners: signerIndices,\n\t\t\tserializedMessage: fromBase64(confirmations[0].serializedMessage),\n\t\t\tsignature,\n\t\t};\n\t}\n\n\tfunction decodePrimarySlivers(\n\t\tblobId: string,\n\t\tnShards: number,\n\t\tsize: number | bigint | string,\n\t\tslivers: (typeof SliverData.$inferInput)[],\n\t\tencodingType: EncodingType = 'RS2',\n\t): Uint8Array {\n\t\tconst encoder = new BlobEncoder(nShards);\n\n\t\tif (encodingType !== 'RS2') {\n\t\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t\t}\n\n\t\tconst [bytes] = encoder.decode(\n\t\t\tBlobId.serialize(blobId).toBytes(),\n\t\t\tBigInt(size),\n\t\t\tslivers.map((sliver) => ({\n\t\t\t\t...sliver,\n\t\t\t\t_sliver_type: undefined,\n\t\t\t})),\n\t\t);\n\n\t\treturn new Uint8Array(bytes);\n\t}\n\n\tfunction getVerifySignature() {\n\t\treturn (confirmation: StorageConfirmation, publicKey: Uint8Array) =>\n\t\t\tbls12381_min_pk_verify(\n\t\t\t\tfromBase64(confirmation.signature),\n\t\t\t\tpublicKey,\n\t\t\t\tfromBase64(confirmation.serializedMessage),\n\t\t\t);\n\t}\n\n\tfunction computeMetadata(\n\t\tnShards: number,\n\t\tbytes: Uint8Array,\n\t\tencodingType: EncodingType = 'RS2',\n\t): typeof BlobMetadataWithId.$inferInput & { blob_id: string } {\n\t\tconst encoder = new BlobEncoder(nShards);\n\t\tconst metadata = encoder.compute_metadata(bytes);\n\n\t\tif (encodingType !== 'RS2') {\n\t\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t\t}\n\n\t\treturn {\n\t\t\t...metadata,\n\t\t\tblob_id: blobIdFromBytes(new Uint8Array(metadata.blob_id)),\n\t\t};\n\t}\n\n\treturn {\n\t\tencodeBlob,\n\t\tcombineSignatures,\n\t\tdecodePrimarySlivers,\n\t\tgetVerifySignature,\n\t\tcomputeMetadata,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA2B;AAC3B,yBAIO;AAKP,IAAAA,cAAwC;AAexC,eAAsB,gBAAgB,KAAc;AACnD,YAAM,mBAAAC,SAAK,EAAE,gBAAgB,IAAI,CAAC;AAElC,WAAS,WACR,SACA,OACA,eAA6B,OACf;AACd,UAAM,UAAU,IAAI,+BAAY,OAAO;AAEvC,QAAI,iBAAiB,OAAO;AAC3B,YAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,IAC7D;AAEA,UAAM,CAAC,aAAa,UAAU,QAAQ,IAAI,QAAQ,qBAAqB,KAAK;AAE5E,WAAO;AAAA,MACN;AAAA,MACA,YAAQ,6BAAgB,IAAI,WAAW,SAAS,OAAO,CAAC;AAAA,MACxD,UAAU,SAAS;AAAA,MACnB,UAAU,IAAI,WAAW,SAAS,MAAM;AAAA,IACzC;AAAA,EACD;AAEA,WAAS,kBACR,eACA,eACoB;AACpB,UAAM,gBAAY;AAAA,MACjB,cAAc,IAAI,CAAC,qBAAiB,uBAAW,aAAa,SAAS,CAAC;AAAA,IACvE;AAEA,WAAO;AAAA,MACN,SAAS;AAAA,MACT,uBAAmB,uBAAW,cAAc,CAAC,EAAE,iBAAiB;AAAA,MAChE;AAAA,IACD;AAAA,EACD;AAEA,WAAS,qBACR,QACA,SACA,MACA,SACA,eAA6B,OAChB;AACb,UAAM,UAAU,IAAI,+BAAY,OAAO;AAEvC,QAAI,iBAAiB,OAAO;AAC3B,YAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,IAC7D;AAEA,UAAM,CAAC,KAAK,IAAI,QAAQ;AAAA,MACvB,mBAAO,UAAU,MAAM,EAAE,QAAQ;AAAA,MACjC,OAAO,IAAI;AAAA,MACX,QAAQ,IAAI,CAAC,YAAY;AAAA,QACxB,GAAG;AAAA,QACH,cAAc;AAAA,MACf,EAAE;AAAA,IACH;AAEA,WAAO,IAAI,WAAW,KAAK;AAAA,EAC5B;AAEA,WAAS,qBAAqB;AAC7B,WAAO,CAAC,cAAmC,kBAC1C;AAAA,UACC,uBAAW,aAAa,SAAS;AAAA,MACjC;AAAA,UACA,uBAAW,aAAa,iBAAiB;AAAA,IAC1C;AAAA,EACF;AAEA,WAAS,gBACR,SACA,OACA,eAA6B,OACiC;AAC9D,UAAM,UAAU,IAAI,+BAAY,OAAO;AACvC,UAAM,WAAW,QAAQ,iBAAiB,KAAK;AAE/C,QAAI,iBAAiB,OAAO;AAC3B,YAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,IAC7D;AAEA,WAAO;AAAA,MACN,GAAG;AAAA,MACH,aAAS,6BAAgB,IAAI,WAAW,SAAS,OAAO,CAAC;AAAA,IAC1D;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": ["import_bcs", "init"]
7
7
  }
@@ -299,7 +299,7 @@ export declare class WalrusClient {
299
299
  * tx.transferObjects([storage], owner);
300
300
  * ```
301
301
  */
302
- deleteBlob({ blobObjectId }: DeleteBlobOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
302
+ deleteBlob({ blobObjectId }: DeleteBlobOptions): Promise<(tx: Transaction) => import("@mysten/sui/transactions").TransactionResult>;
303
303
  /**
304
304
  * Create a transaction that deletes a blob
305
305
  *
@@ -311,7 +311,7 @@ export declare class WalrusClient {
311
311
  deleteBlobTransaction({ owner, blobObjectId, transaction, }: DeleteBlobOptions & {
312
312
  transaction?: Transaction;
313
313
  owner: string;
314
- }): Transaction;
314
+ }): Promise<Transaction>;
315
315
  /**
316
316
  * Execute a transaction that deletes a blob
317
317
  *
@@ -6,7 +6,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
6
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
7
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
8
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
- var _storageNodeClient, _packageConfig, _suiClient, _objectLoader, _blobMetadataConcurrencyLimit, _readCommittee, _memo, _walType, _getPackageId, _getSystemContract, _getSubsidiesContract, _getBlobContract, _getMetadataContract, _WalrusClient_instances, internalReadBlob_fn, getCertificationEpoch_fn, getReadCommittee_fn, forceGetReadCommittee_fn, withWal_fn, writeBlobAttributesForRef_fn, executeTransaction_fn, getCommittee_fn, _getActiveCommittee, stakingPool_fn, getNodeByShardIndex_fn, retryOnPossibleEpochChange_fn;
9
+ var _storageNodeClient, _wasmUrl, _packageConfig, _suiClient, _objectLoader, _blobMetadataConcurrencyLimit, _readCommittee, _memo, _walType, _getPackageId, _getSystemContract, _getSubsidiesContract, _getBlobContract, _getMetadataContract, _wasmBindings, _WalrusClient_instances, internalReadBlob_fn, getCertificationEpoch_fn, getReadCommittee_fn, forceGetReadCommittee_fn, withWal_fn, writeBlobAttributesForRef_fn, executeTransaction_fn, getCommittee_fn, _getActiveCommittee, stakingPool_fn, getNodeByShardIndex_fn, retryOnPossibleEpochChange_fn;
10
10
  import { bcs } from "@mysten/bcs";
11
11
  import { SuiClient } from "@mysten/sui/client";
12
12
  import { coinWithBalance, Transaction } from "@mysten/sui/transactions";
@@ -57,17 +57,12 @@ import {
57
57
  import { MemoCache } from "./utils/memo.js";
58
58
  import { SuiObjectDataLoader } from "./utils/object-loader.js";
59
59
  import { shuffle, weightedShuffle } from "./utils/randomness.js";
60
- import {
61
- combineSignatures,
62
- computeMetadata,
63
- decodePrimarySlivers,
64
- encodeBlob,
65
- getVerifySignature
66
- } from "./wasm.js";
60
+ import { getWasmBindings } from "./wasm.js";
67
61
  class WalrusClient {
68
62
  constructor(config) {
69
63
  __privateAdd(this, _WalrusClient_instances);
70
64
  __privateAdd(this, _storageNodeClient);
65
+ __privateAdd(this, _wasmUrl);
71
66
  __privateAdd(this, _packageConfig);
72
67
  __privateAdd(this, _suiClient);
73
68
  __privateAdd(this, _objectLoader);
@@ -120,6 +115,9 @@ class WalrusClient {
120
115
  const { package_id } = await this.systemObject();
121
116
  return initMetadataContract(package_id);
122
117
  }));
118
+ __privateAdd(this, _wasmBindings, __privateGet(this, _memo).create("wasmBindings", async () => {
119
+ return getWasmBindings(__privateGet(this, _wasmUrl));
120
+ }));
123
121
  /** Read a blob from the storage nodes */
124
122
  this.readBlob = __privateMethod(this, _WalrusClient_instances, retryOnPossibleEpochChange_fn).call(this, __privateMethod(this, _WalrusClient_instances, internalReadBlob_fn));
125
123
  __privateAdd(this, _getActiveCommittee, __privateGet(this, _memo).create("getActiveCommittee", async () => {
@@ -141,6 +139,7 @@ class WalrusClient {
141
139
  } else {
142
140
  __privateSet(this, _packageConfig, config.packageConfig);
143
141
  }
142
+ __privateSet(this, _wasmUrl, config.wasmUrl);
144
143
  __privateSet(this, _suiClient, config.suiClient ?? new SuiClient({
145
144
  url: config.suiRpcUrl
146
145
  }));
@@ -618,7 +617,8 @@ class WalrusClient {
618
617
  }
619
618
  }
620
619
  }).toBase64();
621
- const verifySignature = await getVerifySignature();
620
+ const bindings = await __privateGet(this, _wasmBindings).call(this);
621
+ const verifySignature = bindings.getVerifySignature();
622
622
  const filteredConfirmations = confirmations.map((confirmation, index) => {
623
623
  const isValid = confirmation?.serializedMessage === confirmationMessage && verifySignature(
624
624
  confirmation,
@@ -634,7 +634,7 @@ class WalrusClient {
634
634
  `Too many invalid confirmations received for blob (${filteredConfirmations.length} of ${systemState.committee.members.length})`
635
635
  );
636
636
  }
637
- const combinedSignature = await combineSignatures(
637
+ const combinedSignature = bindings.combineSignatures(
638
638
  filteredConfirmations,
639
639
  filteredConfirmations.map(({ index }) => index)
640
640
  );
@@ -699,13 +699,16 @@ class WalrusClient {
699
699
  * tx.transferObjects([storage], owner);
700
700
  * ```
701
701
  */
702
- deleteBlob({ blobObjectId }) {
703
- return (tx) => tx.moveCall({
704
- package: __privateGet(this, _packageConfig).systemObjectId,
705
- module: "system",
706
- function: "delete_blob",
707
- arguments: [tx.object(__privateGet(this, _packageConfig).systemObjectId), tx.object(blobObjectId)]
708
- });
702
+ async deleteBlob({ blobObjectId }) {
703
+ const systemContract = await __privateGet(this, _getSystemContract).call(this);
704
+ return (tx) => {
705
+ const storage = tx.add(
706
+ systemContract.delete_blob({
707
+ arguments: [tx.object(__privateGet(this, _packageConfig).systemObjectId), tx.object(blobObjectId)]
708
+ })
709
+ );
710
+ return storage;
711
+ };
709
712
  }
710
713
  /**
711
714
  * Create a transaction that deletes a blob
@@ -715,12 +718,13 @@ class WalrusClient {
715
718
  * const tx = await client.deleteBlobTransaction({ blobObjectId, owner });
716
719
  * ```
717
720
  */
718
- deleteBlobTransaction({
721
+ async deleteBlobTransaction({
719
722
  owner,
720
723
  blobObjectId,
721
724
  transaction = new Transaction()
722
725
  }) {
723
- transaction.transferObjects([this.deleteBlob({ blobObjectId })], owner);
726
+ const storage = transaction.add(await this.deleteBlob({ blobObjectId }));
727
+ transaction.transferObjects([storage], owner);
724
728
  return transaction;
725
729
  }
726
730
  /**
@@ -736,7 +740,7 @@ class WalrusClient {
736
740
  transaction = new Transaction(),
737
741
  blobObjectId
738
742
  }) {
739
- const { digest } = await __privateMethod(this, _WalrusClient_instances, executeTransaction_fn).call(this, this.deleteBlobTransaction({
743
+ const { digest } = await __privateMethod(this, _WalrusClient_instances, executeTransaction_fn).call(this, await this.deleteBlobTransaction({
740
744
  blobObjectId,
741
745
  transaction,
742
746
  owner: transaction.getData().sender ?? signer.toSuiAddress()
@@ -958,7 +962,8 @@ class WalrusClient {
958
962
  const systemState = await this.systemState();
959
963
  const committee = await __privateGet(this, _getActiveCommittee).call(this);
960
964
  const numShards = systemState.committee.n_shards;
961
- const { blobId, metadata, sliverPairs, rootHash } = await encodeBlob(numShards, blob);
965
+ const bindings = await __privateGet(this, _wasmBindings).call(this);
966
+ const { blobId, metadata, sliverPairs, rootHash } = bindings.encodeBlob(numShards, blob);
962
967
  const sliversByNodeMap = /* @__PURE__ */ new Map();
963
968
  while (sliverPairs.length > 0) {
964
969
  const { primary, secondary } = sliverPairs.pop();
@@ -1156,6 +1161,7 @@ class WalrusClient {
1156
1161
  }
1157
1162
  }
1158
1163
  _storageNodeClient = new WeakMap();
1164
+ _wasmUrl = new WeakMap();
1159
1165
  _packageConfig = new WeakMap();
1160
1166
  _suiClient = new WeakMap();
1161
1167
  _objectLoader = new WeakMap();
@@ -1168,19 +1174,24 @@ _getSystemContract = new WeakMap();
1168
1174
  _getSubsidiesContract = new WeakMap();
1169
1175
  _getBlobContract = new WeakMap();
1170
1176
  _getMetadataContract = new WeakMap();
1177
+ _wasmBindings = new WeakMap();
1171
1178
  _WalrusClient_instances = new WeakSet();
1172
1179
  internalReadBlob_fn = async function({ blobId, signal }) {
1173
1180
  const systemState = await this.systemState();
1174
1181
  const numShards = systemState.committee.n_shards;
1175
1182
  const blobMetadata = await this.getBlobMetadata({ blobId, signal });
1176
1183
  const slivers = await this.getSlivers({ blobId, signal });
1177
- const blobBytes = decodePrimarySlivers(
1184
+ const bindings = await __privateGet(this, _wasmBindings).call(this);
1185
+ const blobBytes = bindings.decodePrimarySlivers(
1178
1186
  blobId,
1179
1187
  numShards,
1180
1188
  blobMetadata.metadata.V1.unencoded_length,
1181
1189
  slivers
1182
1190
  );
1183
- const reconstructedBlobMetadata = computeMetadata(systemState.committee.n_shards, blobBytes);
1191
+ const reconstructedBlobMetadata = bindings.computeMetadata(
1192
+ systemState.committee.n_shards,
1193
+ blobBytes
1194
+ );
1184
1195
  if (reconstructedBlobMetadata.blob_id !== blobId) {
1185
1196
  throw new InconsistentBlobError("The specified blob was encoded incorrectly.");
1186
1197
  }