@mysten/walrus 1.1.6 → 1.2.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 +32 -0
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +4 -2
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/utils/index.d.mts +35 -0
- package/dist/contracts/utils/index.d.mts.map +1 -1
- package/dist/contracts/utils/index.mjs +88 -4
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/types.d.mts +6 -0
- package/dist/types.d.mts.map +1 -1
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @mysten/walrus
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bbf63cb: Add `typeTag` and `resolveTypeTag` methods to the generated `MoveStruct`, `MoveEnum`, and
|
|
8
|
+
`MoveTuple` classes.
|
|
9
|
+
|
|
10
|
+
- `typeTag(options?)` builds the type tag string for a generated type. `typeArguments` is the full
|
|
11
|
+
positional list of type arguments in Move declaration order; each entry is a type tag string,
|
|
12
|
+
another `typeTag()` result, or a BCS type (its name is used). Types with unfilled phantom
|
|
13
|
+
parameters require `typeArguments` at compile time, and argument arity is validated at runtime.
|
|
14
|
+
- `resolveTypeTag({ client, ... })` builds the tag, resolves MVR names through
|
|
15
|
+
`client.core.mvr.resolveType`, and returns the normalized address-only form suitable for queries
|
|
16
|
+
and comparisons against on-chain data.
|
|
17
|
+
|
|
18
|
+
- bbf63cb: Updated dependencies
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [bbf63cb]
|
|
23
|
+
- @mysten/bcs@2.1.0
|
|
24
|
+
- @mysten/utils@0.4.0
|
|
25
|
+
- @mysten/walrus-wasm@0.3.0
|
|
26
|
+
|
|
27
|
+
## 1.1.7
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 4cdeeb2: Add `storageNodeUrlScheme` option to `WalrusClient` for configuring the URL scheme used
|
|
32
|
+
when contacting storage nodes (defaults to `'https'`). Set to `'http'` for local development
|
|
33
|
+
environments where storage nodes do not terminate TLS.
|
|
34
|
+
|
|
3
35
|
## 1.1.6
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/dist/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;;;;;;;iBAsIgB,MAAA,uBAAA,CAAA;EACf,aAAA;EACA,IAAA;EAAA,GACG;AAAA,IACD,aAAA,CAAc,IAAA;;qBAGI,iBAAA,KAAiB,YAAA;AAAA;AAAA,cAwBzB,YAAA;EAAA;
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;;;;;;;iBAsIgB,MAAA,uBAAA,CAAA;EACf,aAAA;EACA,IAAA;EAAA,GACG;AAAA,IACD,aAAA,CAAc,IAAA;;qBAGI,iBAAA,KAAiB,YAAA;AAAA;AAAA,cAwBzB,YAAA;EAAA;cAiBA,MAAA,EAAQ,kBAAA;EA5CJ;EAyGhB,WAAA,CAAA,YAAW,OAAA;;EAoBX,YAAA,CAAA,GAAY,OAAA;;;;;;EAhIZ;EAqIA,aAAA,CAAA,GAAa,OAAA;;;;;;;EAKP,WAAA,CAAA,GAAW,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6K2C;EAlKtD,YAAA,CAAA,GAAY,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAXD,YAAA,CAAA,uBAAA;;;;;;;;;EAimBhB;EA1kBD,QAAA;IAAQ,MAAA;IAAA;EAAA,GAEoC,eAAA,KAAe,OAAA,CAAA,UAAA,CAAA,eAAA;EA6BrD,mBAAA,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MAAA;IACA,WAAA,EAAa,0BAAA;EAAA;EApiCX;;;;;;;;EAwjCG,sBAAA,CAAA;IACL,SAAA;IACA,MAAA;IACA,QAAA;IACA,OAAA;IACA,MAAA;IAAA,GACG;EAAA,GACD,uBAAA,GAAuB,OAAA,CAAA,mBAAA;EA1iCvB;;;;;;;;EAuoCG,SAAA,CAAA;IACL,IAAA;IACA,SAAA;IACA,MAAA;IACA,MAAA;IACA,KAAA;IACA,UAAA;IACA,MAAA;IACA,MAAA;IACA;EAAA,GACE,gBAAA,GAAgB,OAAA;;;;;;;;;;;;;;;;;;EAoBb,UAAA,CAAA;IAAa,KAAA;IAAA,GAAU;EAAA,GAAW,iBAAA,GAAiB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BnD,WAAA,CAAA;IACL;EAAA;IAEA,KAAA;MACC,QAAA,EAAU,UAAA;MACV,UAAA;MACA,IAAA,GAAO,MAAA;IAAA;EAAA,IAER,OAAA;;;;;;;;;;;;EAhgCA;;;;;;;;EA2lCD,KAAA,CAAA;EAmBM,OAAA,CAAA;IAAU;EAAA;IAAY,MAAA;EAAA,IAAgB,OAAA,CAAA,UAAA;EAWtC,QAAA,CAAA;IAAW;EAAA;IAAS,GAAA;EAAA,IAAe,OAAA,CAAA,UAAA;EA+CnC,UAAA,CAAA;IAAa,KAAA;IAAO,MAAA;IAAQ,MAAA;IAAA,GAAW;EAAA,GAAW,iBAAA,GAAiB,OAAA;;;wBAh4DlD,IAAA;EAAA;EAuvBR;;;;;;;;;;;;;;;EAuqCf,cAAA,CAAe,OAAA,EAAS,qBAAA,GAAwB,cAAA;EAthChD;;;;;;;;;;;;;;;;;;;;;;;;;;EAojCA,aAAA,CAAc,OAAA,EAAS,oBAAA,GAAuB,aAAA;AAAA"}
|
package/dist/client.mjs
CHANGED
|
@@ -51,6 +51,7 @@ function walrus({ packageConfig, name = "walrus", ...options } = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
var WalrusClient = class {
|
|
53
53
|
#storageNodeClient;
|
|
54
|
+
#storageNodeUrlScheme;
|
|
54
55
|
#wasmUrl;
|
|
55
56
|
#packageConfig;
|
|
56
57
|
#suiClient;
|
|
@@ -76,6 +77,7 @@ var WalrusClient = class {
|
|
|
76
77
|
}
|
|
77
78
|
} else this.#packageConfig = config.packageConfig;
|
|
78
79
|
this.#wasmUrl = config.wasmUrl;
|
|
80
|
+
this.#storageNodeUrlScheme = config.storageNodeUrlScheme ?? "https";
|
|
79
81
|
this.#uploadRelayConfig = config.uploadRelay ?? null;
|
|
80
82
|
if (this.#uploadRelayConfig) this.#uploadRelayClient = new UploadRelayClient(this.#uploadRelayConfig);
|
|
81
83
|
this.#suiClient = config.suiClient;
|
|
@@ -1316,7 +1318,7 @@ var WalrusClient = class {
|
|
|
1316
1318
|
const node = {
|
|
1317
1319
|
id: node_info.node_id,
|
|
1318
1320
|
info: node_info,
|
|
1319
|
-
networkUrl:
|
|
1321
|
+
networkUrl: `${this.#storageNodeUrlScheme}://${node_info.network_address}`,
|
|
1320
1322
|
shardIndices,
|
|
1321
1323
|
nodeIndex
|
|
1322
1324
|
};
|
|
@@ -1326,7 +1328,7 @@ var WalrusClient = class {
|
|
|
1326
1328
|
};
|
|
1327
1329
|
}
|
|
1328
1330
|
#getActiveCommittee() {
|
|
1329
|
-
return this.#cache.read(["getActiveCommittee"], async () => {
|
|
1331
|
+
return this.#cache.read(["getActiveCommittee", this.#storageNodeUrlScheme], async () => {
|
|
1330
1332
|
const stakingState = await this.stakingState();
|
|
1331
1333
|
return this.#getCommittee(stakingState.committee);
|
|
1332
1334
|
});
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":["#retryOnPossibleEpochChange","#internalReadBlob","#packageConfig","#wasmUrl","#uploadRelayConfig","#uploadRelayClient","#suiClient","#storageNodeClient","#objectLoader","#cache","#getPackageId","#wasmBindings","#getReadCommittee","#blobMetadataConcurrencyLimit","#getActiveCommittee","#getNodeByShardIndex","#getCertificationEpoch","#readCommittee","#forceGetReadCommittee","#getCommittee","#storageCostFromEncodedSize","#getWalrusPackageId","#withWal","tx","#walType","#executeTransaction","#writeBlobAttributesForRef","#loadTipConfig","#getCreatedBlob","metadata._new","#writeSliversWithStatusCheck","#stakingPool","#flowContext"],"sources":["../src/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferBcsType } from '@mysten/bcs';\nimport { bcs } from '@mysten/bcs';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { ClientCache, ClientWithCoreApi } from '@mysten/sui/client';\nimport type { TransactionObjectArgument, TransactionResult } from '@mysten/sui/transactions';\nimport { coinWithBalance, Transaction } from '@mysten/sui/transactions';\nimport { normalizeStructTag, parseStructTag } from '@mysten/sui/utils';\n\nimport {\n\tMAINNET_WALRUS_PACKAGE_CONFIG,\n\tSLIVER_STATUS_CHECK_THRESHOLD,\n\tstatusLifecycleRank,\n\tTESTNET_WALRUS_PACKAGE_CONFIG,\n} from './constants.js';\nimport {\n\taddMetadata,\n\tBlob,\n\tinsertOrUpdateMetadataPair,\n\tremoveMetadataPair,\n} from './contracts/walrus/blob.js';\nimport type { Committee } from './contracts/walrus/committee.js';\nimport * as metadata from './contracts/walrus/metadata.js';\nimport { StakingInnerV1 } from './contracts/walrus/staking_inner.js';\nimport { StakingPool } from './contracts/walrus/staking_pool.js';\nimport { Staking } from './contracts/walrus/staking.js';\nimport { Storage } from './contracts/walrus/storage_resource.js';\nimport { SystemStateInnerV1 } from './contracts/walrus/system_state_inner.js';\nimport {\n\tcertifyBlob,\n\tdeleteBlob,\n\textendBlob,\n\tregisterBlob,\n\treserveSpace,\n\tSystem,\n} from './contracts/walrus/system.js';\nimport {\n\tBehindCurrentEpochError,\n\tBlobBlockedError,\n\tBlobNotCertifiedError,\n\tInconsistentBlobError,\n\tNoBlobMetadataReceivedError,\n\tNoBlobStatusReceivedError,\n\tNotEnoughBlobConfirmationsError,\n\tNotEnoughSliversReceivedError,\n\tNoVerifiedBlobStatusReceivedError,\n\tRetryableWalrusClientError,\n\tWalrusClientError,\n} from './error.js';\nimport { StorageNodeClient } from './storage-node/client.js';\nimport {\n\tBlobNotRegisteredError,\n\tLegallyUnavailableError,\n\tNotFoundError,\n\tUserAbortError,\n} from './storage-node/error.js';\nimport type {\n\tBlobMetadataWithId,\n\tBlobStatus,\n\tGetSliverResponse,\n\tStorageConfirmation as StorageConfirmationType,\n} from './storage-node/types.js';\nimport type {\n\tCertifyBlobOptions,\n\tCommitteeInfo,\n\tComputeBlobMetadataOptions,\n\tDeleteBlobOptions,\n\tExtendBlobOptions,\n\tUploadRelayConfig,\n\tGetBlobMetadataOptions,\n\tGetCertificationEpochOptions,\n\tGetSecondarySliverOptions,\n\tGetSliversOptions,\n\tGetStorageConfirmationOptions,\n\tGetVerifiedBlobStatusOptions,\n\tProtocolMessageCertificate,\n\tReadBlobOptions,\n\tRegisterBlobOptions,\n\tSliversForNode,\n\tStorageNode,\n\tStorageWithSizeOptions,\n\tWalrusClientConfig,\n\tWalrusPackageConfig,\n\tWriteBlobAttributesOptions,\n\tWriteBlobOptions,\n\tWriteBlobToUploadRelayOptions,\n\tWriteEncodedBlobOptions,\n\tWriteEncodedBlobToNodesOptions,\n\tWriteMetadataOptions,\n\tWriteQuiltOptions,\n\tWriteSliverOptions,\n\tWriteSliversToNodeOptions,\n\tWriteFilesOptions,\n\tWriteFilesFlowOptions,\n\tWriteFilesFlow,\n\tWriteBlobFlow,\n\tWriteBlobFlowOptions,\n\tWalrusOptions,\n} from './types.js';\nimport {\n\tblobIdToInt,\n\tIntentType,\n\tparseCertificateFromBase64,\n\tStorageConfirmation,\n} from './utils/bcs.js';\nimport {\n\tencodedBlobLength,\n\tgetShardIndicesByNodeId,\n\tgetSourceSymbols,\n\tisAboveValidity,\n\tisQuorum,\n\tsignersToBitmap,\n\tsliverPairIndexFromSecondarySliverIndex,\n\tstorageUnitsFromSize,\n\ttoPairIndex,\n\ttoShardIndex,\n} from './utils/index.js';\nimport { SuiObjectDataLoader } from './utils/object-loader.js';\nimport { shuffle, weightedShuffle } from './utils/randomness.js';\nimport { getWasmBindings } from './wasm.js';\nimport { chunk } from '@mysten/utils';\nimport { UploadRelayClient } from './upload-relay/client.js';\nimport { encodeQuilt, encodeQuiltPatchId, parseWalrusId } from './utils/quilts.js';\nimport { BlobReader } from './files/readers/blob.js';\nimport { WalrusBlob } from './files/blob.js';\nimport { WalrusFile } from './files/file.js';\nimport { QuiltFileReader } from './files/readers/quilt-file.js';\nimport { QuiltReader } from './files/readers/quilt.js';\nimport { retry } from './utils/retry.js';\nimport { createWriteBlobFlow, type WriteBlobFlowContext } from './flows/write-blob.js';\nimport { createWriteFilesFlow } from './flows/write-files.js';\n\nexport function walrus<const Name = 'walrus'>({\n\tpackageConfig,\n\tname = 'walrus' as Name,\n\t...options\n}: WalrusOptions<Name> = {}) {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi) => {\n\t\t\tconst walrusNetwork = client.network;\n\n\t\t\tif (walrusNetwork !== 'mainnet' && walrusNetwork !== 'testnet') {\n\t\t\t\tthrow new WalrusClientError('Walrus client only supports mainnet and testnet');\n\t\t\t}\n\n\t\t\treturn new WalrusClient(\n\t\t\t\tpackageConfig\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpackageConfig,\n\t\t\t\t\t\t\tsuiClient: client,\n\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tnetwork: walrusNetwork as 'mainnet' | 'testnet',\n\t\t\t\t\t\t\tsuiClient: client,\n\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t},\n\t\t\t);\n\t\t},\n\t};\n}\n\nexport class WalrusClient {\n\t#storageNodeClient: StorageNodeClient;\n\t#wasmUrl: string | undefined;\n\n\t#packageConfig: WalrusPackageConfig;\n\t#suiClient: ClientWithCoreApi;\n\t#objectLoader: SuiObjectDataLoader;\n\n\t#blobMetadataConcurrencyLimit = 10;\n\t#readCommittee?: CommitteeInfo | Promise<CommitteeInfo> | null;\n\n\t#cache: ClientCache;\n\n\t#uploadRelayConfig: UploadRelayConfig | null = null;\n\t#uploadRelayClient: UploadRelayClient | null = null;\n\n\tconstructor(config: WalrusClientConfig) {\n\t\tif (config.network && !config.packageConfig) {\n\t\t\tconst network = config.network;\n\t\t\tswitch (network) {\n\t\t\t\tcase 'testnet':\n\t\t\t\t\tthis.#packageConfig = TESTNET_WALRUS_PACKAGE_CONFIG;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'mainnet':\n\t\t\t\t\tthis.#packageConfig = MAINNET_WALRUS_PACKAGE_CONFIG;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new WalrusClientError(`Unsupported network: ${network}`);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.#packageConfig = config.packageConfig!;\n\t\t}\n\n\t\tthis.#wasmUrl = config.wasmUrl;\n\t\tthis.#uploadRelayConfig = config.uploadRelay ?? null;\n\t\tif (this.#uploadRelayConfig) {\n\t\t\tthis.#uploadRelayClient = new UploadRelayClient(this.#uploadRelayConfig);\n\t\t}\n\n\t\tthis.#suiClient = config.suiClient;\n\n\t\tthis.#storageNodeClient = new StorageNodeClient(config.storageNodeClientOptions);\n\t\tthis.#objectLoader = new SuiObjectDataLoader(this.#suiClient);\n\t\tthis.#cache = this.#suiClient.cache.scope('@mysten/walrus');\n\t}\n\n\t/** The Move type for a WAL coin */\n\t#walType() {\n\t\treturn this.#cache.read(['walType'], async () => {\n\t\t\tconst stakeWithPool = await this.#suiClient.core.getMoveFunction({\n\t\t\t\tpackageId: await this.#getPackageId(),\n\t\t\t\tmoduleName: 'staking',\n\t\t\t\tname: 'stake_with_pool',\n\t\t\t});\n\n\t\t\tconst toStake = stakeWithPool.function.parameters[1];\n\t\t\tconst toStakeCoin = toStake.body.$kind === 'datatype' ? toStake.body.datatype : null;\n\t\t\tconst toStakeCoinType =\n\t\t\t\ttoStakeCoin?.typeParameters[0]?.$kind === 'datatype' ? toStakeCoin.typeParameters[0] : null;\n\n\t\t\tif (toStakeCoinType?.$kind !== 'datatype') {\n\t\t\t\tthrow new WalrusClientError('WAL type not found');\n\t\t\t}\n\n\t\t\treturn normalizeStructTag(toStakeCoinType.datatype.typeName);\n\t\t});\n\t}\n\n\t#getPackageId() {\n\t\treturn this.#cache.read(['getPackageId'], async () => {\n\t\t\tconst system = await this.#objectLoader.load(this.#packageConfig.systemObjectId);\n\t\t\treturn parseStructTag(system.type!).address;\n\t\t});\n\t}\n\n\t/** The Move type for a Blob object */\n\tgetBlobType() {\n\t\treturn this.#cache.read(['getBlobType'], async () => {\n\t\t\treturn `${await this.#getPackageId()}::blob::Blob`;\n\t\t});\n\t}\n\n\t#getWalrusPackageId() {\n\t\treturn this.#cache.read(['getSystemPackageId'], async () => {\n\t\t\tconst { package_id } = await this.systemObject();\n\t\t\treturn package_id;\n\t\t});\n\t}\n\n\t#wasmBindings() {\n\t\treturn this.#cache.read(['wasmBindings'], async () => {\n\t\t\treturn getWasmBindings(this.#wasmUrl);\n\t\t});\n\t}\n\n\t/** The cached system object for the walrus package */\n\tsystemObject() {\n\t\treturn this.#objectLoader.load(this.#packageConfig.systemObjectId, System);\n\t}\n\n\t/** The cached staking pool object for the walrus package */\n\tstakingObject() {\n\t\treturn this.#objectLoader.load(this.#packageConfig.stakingPoolId, Staking);\n\t}\n\n\t/** The system state for the current version of walrus contract */\n\tasync systemState() {\n\t\tconst systemState = await this.#objectLoader.loadFieldObject(\n\t\t\tthis.#packageConfig.systemObjectId,\n\t\t\t{ type: 'u64', value: (await this.systemObject()).version },\n\t\t\tSystemStateInnerV1,\n\t\t);\n\n\t\treturn systemState;\n\t}\n\n\t/** The staking state for the current version of walrus contract */\n\tasync stakingState() {\n\t\treturn this.#objectLoader.loadFieldObject(\n\t\t\tthis.#packageConfig.stakingPoolId,\n\t\t\t{\n\t\t\t\ttype: 'u64',\n\t\t\t\tvalue: (await this.stakingObject()).version,\n\t\t\t},\n\t\t\tStakingInnerV1,\n\t\t);\n\t}\n\n\t/** Read a blob from the storage nodes */\n\treadBlob = this.#retryOnPossibleEpochChange(this.#internalReadBlob);\n\n\tasync #internalReadBlob({ blobId, signal }: ReadBlobOptions) {\n\t\tconst systemState = await this.systemState();\n\t\tconst numShards = systemState.committee.n_shards;\n\n\t\tconst blobMetadata = await this.getBlobMetadata({ blobId, signal });\n\n\t\tconst slivers = await this.getSlivers({ blobId, signal });\n\n\t\tconst bindings = await this.#wasmBindings();\n\n\t\tconst blobBytes = bindings.decodePrimarySlivers(\n\t\t\tblobId,\n\t\t\tnumShards,\n\t\t\tblobMetadata.metadata.V1.unencoded_length,\n\t\t\tslivers,\n\t\t);\n\n\t\tconst reconstructedBlobMetadata = bindings.computeMetadata(\n\t\t\tsystemState.committee.n_shards,\n\t\t\tblobBytes,\n\t\t);\n\n\t\tif (reconstructedBlobMetadata.blobId !== blobId) {\n\t\t\tthrow new InconsistentBlobError('The specified blob was encoded incorrectly.');\n\t\t}\n\n\t\treturn blobBytes;\n\t}\n\n\tasync computeBlobMetadata({\n\t\tbytes,\n\t\tnumShards,\n\t\tnonce: providedNonce,\n\t}: ComputeBlobMetadataOptions) {\n\t\tlet shardCount: number | undefined;\n\t\tif (typeof numShards === 'number') {\n\t\t\tshardCount = numShards;\n\t\t} else {\n\t\t\tconst systemState = await this.systemState();\n\t\t\tshardCount = systemState.committee.n_shards;\n\t\t}\n\n\t\tconst bindings = await this.#wasmBindings();\n\t\tconst { blobId, rootHash, unencodedLength, encodingType } = bindings.computeMetadata(\n\t\t\tshardCount,\n\t\t\tbytes,\n\t\t);\n\t\tlet sha256Hash: Promise<Uint8Array> | undefined;\n\t\tconst nonce = providedNonce ?? crypto.getRandomValues(new Uint8Array(32));\n\n\t\treturn {\n\t\t\trootHash,\n\t\t\tblobId,\n\t\t\tmetadata: {\n\t\t\t\tencodingType,\n\t\t\t\tunencodedLength,\n\t\t\t},\n\t\t\tnonce,\n\t\t\tblobDigest: () => {\n\t\t\t\tif (!sha256Hash) {\n\t\t\t\t\tsha256Hash = crypto.subtle\n\t\t\t\t\t\t.digest('SHA-256', bytes as BufferSource)\n\t\t\t\t\t\t.then((hash) => new Uint8Array(hash));\n\t\t\t\t}\n\n\t\t\t\treturn sha256Hash;\n\t\t\t},\n\t\t};\n\t}\n\n\tasync getBlobMetadata({ blobId, signal }: GetBlobMetadataOptions) {\n\t\tconst committee = await this.#getReadCommittee({ blobId, signal });\n\t\tconst randomizedNodes = shuffle(committee.nodes);\n\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\n\t\tlet numNotFoundWeight = 0;\n\t\tlet numBlockedWeight = 0;\n\t\tlet totalErrorCount = 0;\n\t\tconst controller = new AbortController();\n\n\t\tconst metadataExecutors = randomizedNodes.map((node) => async () => {\n\t\t\ttry {\n\t\t\t\treturn await this.#storageNodeClient.getBlobMetadata(\n\t\t\t\t\t{ blobId },\n\t\t\t\t\t{\n\t\t\t\t\t\tnodeUrl: node.networkUrl,\n\t\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof NotFoundError) {\n\t\t\t\t\tnumNotFoundWeight += node.shardIndices.length;\n\t\t\t\t} else if (error instanceof LegallyUnavailableError) {\n\t\t\t\t\tnumBlockedWeight += node.shardIndices.length;\n\t\t\t\t}\n\n\t\t\t\ttotalErrorCount += 1;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\n\t\ttry {\n\t\t\tconst attemptGetMetadata = metadataExecutors.shift()!;\n\t\t\treturn await attemptGetMetadata();\n\t\t} catch {\n\t\t\tconst chunkSize = Math.floor(metadataExecutors.length / this.#blobMetadataConcurrencyLimit);\n\t\t\tconst chunkedExecutors = chunk(metadataExecutors, chunkSize);\n\n\t\t\treturn await new Promise<BlobMetadataWithId>((resolve, reject) => {\n\t\t\t\tchunkedExecutors.forEach(async (executors) => {\n\t\t\t\t\tfor (const executor of executors) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await executor();\n\t\t\t\t\t\t\tcontroller.abort('Blob metadata successfully retrieved.');\n\t\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tif (error instanceof UserAbortError) {\n\t\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t} else if (isQuorum(numBlockedWeight + numNotFoundWeight, numShards)) {\n\t\t\t\t\t\t\t\tconst abortError =\n\t\t\t\t\t\t\t\t\tnumNotFoundWeight > numBlockedWeight\n\t\t\t\t\t\t\t\t\t\t? new BlobNotCertifiedError(`The specified blob ${blobId} is not certified.`)\n\t\t\t\t\t\t\t\t\t\t: new BlobBlockedError(`The specified blob ${blobId} is blocked.`);\n\n\t\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (totalErrorCount === metadataExecutors.length) {\n\t\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\t\tnew NoBlobMetadataReceivedError(\n\t\t\t\t\t\t\t\t\t\t'No valid blob metadata could be retrieved from any storage node.',\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t}\n\n\tgetSecondarySliver = this.#retryOnPossibleEpochChange(this.internalGetSecondarySliver);\n\n\tasync internalGetSecondarySliver({ blobId, index, signal }: GetSecondarySliverOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\t\tconst sliverPairIndex = sliverPairIndexFromSecondarySliverIndex(index, numShards);\n\t\tconst shardIndex = toShardIndex(sliverPairIndex, blobId, numShards);\n\t\tconst node = await this.#getNodeByShardIndex(committee, shardIndex);\n\n\t\tif (!node) {\n\t\t\tthrow new Error(`No node found for shard index ${shardIndex}`);\n\t\t}\n\n\t\tconst sliver = await this.#storageNodeClient.getSliver(\n\t\t\t{ blobId, sliverPairIndex, sliverType: 'secondary' },\n\t\t\t{\n\t\t\t\tnodeUrl: node.networkUrl,\n\t\t\t\tsignal,\n\t\t\t},\n\t\t);\n\n\t\treturn sliver;\n\t}\n\n\tasync getSlivers({ blobId, signal }: GetSliversOptions) {\n\t\tconst committee = await this.#getReadCommittee({ blobId, signal });\n\t\tconst randomizedNodes = weightedShuffle(\n\t\t\tcommittee.nodes.map((node) => ({\n\t\t\t\tvalue: node,\n\t\t\t\tweight: node.shardIndices.length,\n\t\t\t})),\n\t\t);\n\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\t\tconst { primarySymbols: minSymbols } = getSourceSymbols(numShards);\n\n\t\tconst sliverPairIndices = randomizedNodes.flatMap((node) =>\n\t\t\tnode.shardIndices.map((shardIndex) => ({\n\t\t\t\turl: node.networkUrl,\n\t\t\t\tsliverPairIndex: toPairIndex(shardIndex, blobId, numShards),\n\t\t\t})),\n\t\t);\n\n\t\tconst controller = new AbortController();\n\t\tconst chunkedSliverPairIndices = chunk(sliverPairIndices, minSymbols);\n\t\tconst slivers: GetSliverResponse[] = [];\n\t\tconst failedNodes = new Set<string>();\n\t\tlet numNotFoundWeight = 0;\n\t\tlet numBlockedWeight = 0;\n\t\tlet totalErrorCount = 0;\n\n\t\treturn new Promise<GetSliverResponse[]>((resolve, reject) => {\n\t\t\tchunkedSliverPairIndices[0].forEach(async (_, colIndex) => {\n\t\t\t\tfor (let rowIndex = 0; rowIndex < chunkedSliverPairIndices.length; rowIndex += 1) {\n\t\t\t\t\tconst value = chunkedSliverPairIndices.at(rowIndex)?.at(colIndex);\n\t\t\t\t\tif (!value) break;\n\n\t\t\t\t\tconst { url, sliverPairIndex } = value;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (failedNodes.has(url)) {\n\t\t\t\t\t\t\tthrow new Error(`Skipping node at ${url} due to previous failure.`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sliver = await this.#storageNodeClient.getSliver(\n\t\t\t\t\t\t\t{ blobId, sliverPairIndex, sliverType: 'primary' },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnodeUrl: url,\n\t\t\t\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (slivers.length === minSymbols) {\n\t\t\t\t\t\t\tcontroller.abort('Enough slivers successfully retrieved.');\n\t\t\t\t\t\t\tresolve(slivers);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tslivers.push(sliver);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof NotFoundError) {\n\t\t\t\t\t\t\tnumNotFoundWeight += 1;\n\t\t\t\t\t\t} else if (error instanceof LegallyUnavailableError) {\n\t\t\t\t\t\t\tnumBlockedWeight += 1;\n\t\t\t\t\t\t} else if (error instanceof UserAbortError) {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isQuorum(numBlockedWeight + numNotFoundWeight, numShards)) {\n\t\t\t\t\t\t\tconst abortError =\n\t\t\t\t\t\t\t\tnumNotFoundWeight > numBlockedWeight\n\t\t\t\t\t\t\t\t\t? new BlobNotCertifiedError(`The specified blob ${blobId} is not certified.`)\n\t\t\t\t\t\t\t\t\t: new BlobBlockedError(`The specified blob ${blobId} is blocked.`);\n\n\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfailedNodes.add(url);\n\t\t\t\t\t\ttotalErrorCount += 1;\n\n\t\t\t\t\t\tconst remainingTasks = sliverPairIndices.length - (slivers.length + totalErrorCount);\n\t\t\t\t\t\tconst tooManyFailures = slivers.length + remainingTasks < minSymbols;\n\n\t\t\t\t\t\tif (tooManyFailures) {\n\t\t\t\t\t\t\tconst abortError = new NotEnoughSliversReceivedError(\n\t\t\t\t\t\t\t\t`Unable to retrieve enough slivers to decode blob ${blobId}.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Gets the blob status from multiple storage nodes and returns the latest status that can be verified.\n\t */\n\tasync getVerifiedBlobStatus({ blobId, signal }: GetVerifiedBlobStatusOptions) {\n\t\t// Read from the latest committee because, during epoch change, it is the committee\n\t\t// that will have the most up-to-date information on old and newly certified blobs:\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\t\tconst controller = new AbortController();\n\n\t\tconst statuses = await new Promise<{ status: BlobStatus; weight: number }[]>(\n\t\t\t(resolve, reject) => {\n\t\t\t\tconst results: { status: BlobStatus; weight: number }[] = [];\n\t\t\t\tlet successWeight = 0;\n\t\t\t\tlet numNotFoundWeight = 0;\n\t\t\t\tlet settledCount = 0;\n\n\t\t\t\tcommittee.nodes.forEach(async (node) => {\n\t\t\t\t\tconst weight = node.shardIndices.length;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst status = await this.#storageNodeClient.getBlobStatus(\n\t\t\t\t\t\t\t{ blobId },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnodeUrl: node.networkUrl,\n\t\t\t\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (isQuorum(successWeight, numShards)) {\n\t\t\t\t\t\t\tcontroller.abort('Quorum of blob statuses retrieved successfully.');\n\t\t\t\t\t\t\tresolve(results);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsuccessWeight += weight;\n\t\t\t\t\t\t\tresults.push({ status, weight });\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof NotFoundError) {\n\t\t\t\t\t\t\tnumNotFoundWeight += weight;\n\t\t\t\t\t\t} else if (error instanceof UserAbortError) {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isQuorum(numNotFoundWeight, numShards)) {\n\t\t\t\t\t\t\tconst abortError = new BlobNotCertifiedError('The blob does not exist.');\n\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t}\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tsettledCount += 1;\n\t\t\t\t\t\tif (settledCount === committee.nodes.length) {\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew NoBlobStatusReceivedError(\n\t\t\t\t\t\t\t\t\t'Not enough statuses were retrieved to achieve quorum.',\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\n\t\tconst aggregatedStatuses = statuses.reduce((accumulator, value) => {\n\t\t\tconst { status, weight } = value;\n\t\t\tconst key = JSON.stringify(status);\n\n\t\t\tconst existing = accumulator.get(key);\n\t\t\tif (existing) {\n\t\t\t\texisting.totalWeight += weight;\n\t\t\t} else {\n\t\t\t\taccumulator.set(key, { status, totalWeight: weight });\n\t\t\t}\n\n\t\t\treturn accumulator;\n\t\t}, new Map<string, { status: BlobStatus; totalWeight: number }>());\n\n\t\tconst uniqueStatuses = [...aggregatedStatuses.values()];\n\t\tconst sortedStatuses = uniqueStatuses.toSorted(\n\t\t\t(a, b) => statusLifecycleRank[b.status.type] - statusLifecycleRank[a.status.type],\n\t\t);\n\n\t\tfor (const value of sortedStatuses) {\n\t\t\t// TODO: We can check the chain via the `event` field as a fallback here.\n\t\t\tif (isAboveValidity(value.totalWeight, numShards)) {\n\t\t\t\treturn value.status;\n\t\t\t}\n\t\t}\n\n\t\tthrow new NoVerifiedBlobStatusReceivedError(\n\t\t\t`The blob status could not be verified for blob ${blobId},`,\n\t\t);\n\t}\n\n\tasync #getCertificationEpoch({ blobId, signal }: GetCertificationEpochOptions) {\n\t\tconst stakingState = await this.stakingState();\n\t\tconst currentEpoch = stakingState.epoch;\n\n\t\tif (stakingState.epoch_state.$kind === 'EpochChangeSync') {\n\t\t\tconst status = await this.getVerifiedBlobStatus({ blobId, signal });\n\t\t\tif (status.type === 'nonexistent' || status.type === 'invalid') {\n\t\t\t\tthrow new BlobNotCertifiedError(`The specified blob ${blobId} is ${status.type}.`);\n\t\t\t}\n\n\t\t\tif (typeof status.initialCertifiedEpoch !== 'number') {\n\t\t\t\tthrow new BlobNotCertifiedError(`The specified blob ${blobId} is not certified.`);\n\t\t\t}\n\n\t\t\tif (status.initialCertifiedEpoch > currentEpoch) {\n\t\t\t\tthrow new BehindCurrentEpochError(\n\t\t\t\t\t`The client is at epoch ${currentEpoch} while the specified blob was certified at epoch ${status.initialCertifiedEpoch}.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn status.initialCertifiedEpoch;\n\t\t}\n\n\t\treturn currentEpoch;\n\t}\n\n\t/**\n\t * Retrieves the node committee responsible for serving reads.\n\t *\n\t * During an epoch change, reads should be served by the previous committee if the blob was\n\t * certified in an earlier epoch. This ensures that we read from nodes with the most accurate\n\t * information as nodes from the current committee might still be receiving transferred shards\n\t * from the previous committee.\n\t */\n\tasync #getReadCommittee(options: ReadBlobOptions) {\n\t\tif (!this.#readCommittee) {\n\t\t\tthis.#readCommittee = this.#forceGetReadCommittee(options);\n\t\t}\n\t\treturn this.#readCommittee;\n\t}\n\n\tasync #forceGetReadCommittee({ blobId, signal }: ReadBlobOptions) {\n\t\tconst stakingState = await this.stakingState();\n\t\tconst isTransitioning = stakingState.epoch_state.$kind === 'EpochChangeSync';\n\t\tconst certificationEpoch = await this.#getCertificationEpoch({ blobId, signal });\n\n\t\tif (isTransitioning && certificationEpoch < stakingState.epoch) {\n\t\t\treturn await this.#getCommittee(stakingState.previous_committee);\n\t\t}\n\t\treturn await this.#getActiveCommittee();\n\t}\n\n\t/**\n\t * Calculate the cost of storing a blob for a given a size and number of epochs.\n\t */\n\tasync storageCost(size: number, epochs: number) {\n\t\tconst systemState = await this.systemState();\n\t\tconst encodedSize = encodedBlobLength(size, systemState.committee.n_shards);\n\t\treturn this.#storageCostFromEncodedSize(encodedSize, epochs);\n\t}\n\n\tasync #storageCostFromEncodedSize(encodedSize: number, epochs: number) {\n\t\tconst systemState = await this.systemState();\n\t\tconst storageUnits = storageUnitsFromSize(encodedSize);\n\t\tconst storageCost =\n\t\t\tBigInt(storageUnits) * BigInt(systemState.storage_price_per_unit_size) * BigInt(epochs);\n\n\t\tconst writeCost = BigInt(storageUnits) * BigInt(systemState.write_price_per_unit_size);\n\n\t\treturn { storageCost, writeCost, totalCost: storageCost + writeCost };\n\t}\n\n\t/**\n\t * A utility for creating a storage object in a transaction.\n\t *\n\t * @example\n\t * ```ts\n\t * tx.transferObjects([client.createStorage({ size: 1000, epochs: 3 })], owner);\n\t * ```\n\t */\n\tcreateStorage({ size, epochs, walCoin }: StorageWithSizeOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst systemObject = await this.systemObject();\n\t\t\tconst systemState = await this.systemState();\n\t\t\tconst encodedSize = encodedBlobLength(size, systemState.committee.n_shards);\n\t\t\tconst [{ storageCost }, walrusPackageId] = await Promise.all([\n\t\t\t\tthis.storageCost(size, epochs),\n\t\t\t\tthis.#getWalrusPackageId(),\n\t\t\t]);\n\n\t\t\treturn tx.add(\n\t\t\t\tthis.#withWal(storageCost, walCoin ?? null, (coin, tx) => {\n\t\t\t\t\treturn tx.add(\n\t\t\t\t\t\treserveSpace({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: systemObject.id,\n\t\t\t\t\t\t\t\tstorageAmount: encodedSize,\n\t\t\t\t\t\t\t\tepochsAhead: epochs,\n\t\t\t\t\t\t\t\tpayment: coin,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t#withWal<T extends TransactionResult | void>(\n\t\tamount: bigint,\n\t\tsource: TransactionObjectArgument | null,\n\t\tfn: (coin: TransactionObjectArgument, tx: Transaction) => T | Promise<T>,\n\t) {\n\t\treturn async (tx: Transaction): Promise<T> => {\n\t\t\tconst walType = await this.#walType();\n\t\t\tconst coin = source\n\t\t\t\t? tx.splitCoins(source, [amount])[0]\n\t\t\t\t: tx.add(\n\t\t\t\t\t\tcoinWithBalance({\n\t\t\t\t\t\t\tbalance: amount,\n\t\t\t\t\t\t\ttype: walType,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\tconst result = await fn(coin, tx);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: '0x2::coin::destroy_zero',\n\t\t\t\ttypeArguments: [walType],\n\t\t\t\targuments: [coin],\n\t\t\t});\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that creates a storage object\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.createStorageTransaction({ size: 1000, epochs: 3, owner: signer.toSuiAddress() });\n\t * ```\n\t */\n\tcreateStorageTransaction({\n\t\ttransaction = new Transaction(),\n\t\tsize,\n\t\tepochs,\n\t\towner,\n\t}: StorageWithSizeOptions & {\n\t\ttransaction?: Transaction;\n\t\t/** Address the storage resource should be transferred to */\n\t\towner: string;\n\t}) {\n\t\ttransaction.transferObjects([this.createStorage({ size, epochs })], owner);\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that creates a storage object\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest, storage } = await client.executeCreateStorageTransaction({ size: 1000, epochs: 3, signer });\n\t * ```\n\t */\n\tasync executeCreateStorageTransaction({\n\t\tsigner,\n\t\t...options\n\t}: StorageWithSizeOptions & { transaction?: Transaction; signer: Signer }) {\n\t\tconst transaction = this.createStorageTransaction({\n\t\t\t...options,\n\t\t\towner: options.transaction?.getData().sender ?? signer.toSuiAddress(),\n\t\t});\n\t\tconst blobType = await this.getBlobType();\n\n\t\tconst { digest, effects } = await this.#executeTransaction(\n\t\t\ttransaction,\n\t\t\tsigner,\n\t\t\t'create storage',\n\t\t);\n\n\t\tconst createdObjectIds = effects?.changedObjects\n\t\t\t.filter((object) => object.idOperation === 'Created')\n\t\t\t.map((object) => object.objectId);\n\n\t\tconst createdObjects = await this.#suiClient.core.getObjects({\n\t\t\tobjectIds: createdObjectIds,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tconst suiBlobObject = createdObjects.objects.find(\n\t\t\t(object) => !(object instanceof Error) && object.type === blobType,\n\t\t);\n\n\t\tif (suiBlobObject instanceof Error || !suiBlobObject) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Storage object not found in transaction effects for transaction (${digest})`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tdigest,\n\t\t\tstorage: Storage.parse(suiBlobObject.content),\n\t\t};\n\t}\n\n\t/**\n\t * Register a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * tx.transferObjects([client.registerBlob({ size: 1000, epochs: 3, blobId, rootHash, deletable: true })], owner);\n\t * ```\n\t */\n\tregisterBlob({\n\t\tsize,\n\t\tepochs,\n\t\tblobId,\n\t\trootHash,\n\t\tdeletable,\n\t\twalCoin,\n\t\tattributes,\n\t}: RegisterBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst { writeCost } = await this.storageCost(size, epochs);\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\treturn tx.add(\n\t\t\t\tthis.#withWal(writeCost, walCoin ?? null, async (writeCoin, tx) => {\n\t\t\t\t\tconst blob = tx.add(\n\t\t\t\t\t\tregisterBlob({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: tx.object(this.#packageConfig.systemObjectId),\n\t\t\t\t\t\t\t\tstorage: this.createStorage({ size, epochs, walCoin }),\n\t\t\t\t\t\t\t\tblobId: blobIdToInt(blobId),\n\t\t\t\t\t\t\t\trootHash: BigInt(bcs.u256().parse(rootHash)),\n\t\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\t\tencodingType: 1,\n\t\t\t\t\t\t\t\tdeletable,\n\t\t\t\t\t\t\t\twritePayment: writeCoin,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (attributes) {\n\t\t\t\t\t\ttx.add(\n\t\t\t\t\t\t\tthis.#writeBlobAttributesForRef({\n\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\texistingAttributes: null,\n\t\t\t\t\t\t\t\tblob,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn blob;\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\taddAuthPayload({\n\t\tsize,\n\t\tblobDigest,\n\t\tnonce,\n\t}: {\n\t\tsize: number;\n\t\tblobDigest: Uint8Array | (() => Promise<Uint8Array>);\n\t\tnonce: Uint8Array;\n\t}) {\n\t\treturn async (transaction: Transaction) => {\n\t\t\tconst nonceDigest = await crypto.subtle.digest('SHA-256', nonce as BufferSource);\n\t\t\tconst lengthBytes = bcs.u64().serialize(size).toBytes();\n\t\t\tconst digest = typeof blobDigest === 'function' ? await blobDigest() : blobDigest;\n\t\t\tconst authPayload = new Uint8Array(\n\t\t\t\tnonceDigest.byteLength + digest.byteLength + lengthBytes.byteLength,\n\t\t\t);\n\n\t\t\tauthPayload.set(digest, 0);\n\t\t\tauthPayload.set(new Uint8Array(nonceDigest), digest.byteLength);\n\t\t\tauthPayload.set(lengthBytes, nonceDigest.byteLength + digest.byteLength);\n\t\t\ttransaction.pure(authPayload);\n\t\t};\n\t}\n\n\t#loadTipConfig() {\n\t\treturn this.#cache.read(['upload-relay-tip-config'], async () => {\n\t\t\tif (!this.#uploadRelayConfig?.sendTip || !this.#uploadRelayClient) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif ('kind' in this.#uploadRelayConfig.sendTip) {\n\t\t\t\treturn this.#uploadRelayConfig.sendTip;\n\t\t\t}\n\n\t\t\tconst tipConfig = await this.#uploadRelayClient.tipConfig();\n\n\t\t\tif (!tipConfig) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...tipConfig,\n\t\t\t\tmax: this.#uploadRelayConfig.sendTip.max,\n\t\t\t};\n\t\t});\n\t}\n\n\tasync calculateUploadRelayTip(options: { size: number }) {\n\t\tconst systemState = await this.systemState();\n\t\tconst encodedSize = encodedBlobLength(options.size, systemState.committee.n_shards);\n\t\tconst tipConfig = await this.#loadTipConfig();\n\n\t\tif (!tipConfig) {\n\t\t\treturn 0n;\n\t\t}\n\n\t\tconst { max, kind } = tipConfig;\n\n\t\tconst amount =\n\t\t\t'const' in kind\n\t\t\t\t? kind.const\n\t\t\t\t: BigInt(kind.linear.base) +\n\t\t\t\t\tBigInt(kind.linear.perEncodedKib) * ((BigInt(encodedSize) + 1023n) / 1024n); // Compute the ceiling of the division.\n\n\t\tif (max != null && amount > max) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Tip amount (${amount}) exceeds the maximum allowed tip (${max})`,\n\t\t\t);\n\t\t}\n\n\t\treturn amount;\n\t}\n\n\tsendUploadRelayTip({\n\t\tsize,\n\t\tblobDigest,\n\t\tnonce,\n\t}: {\n\t\tsize: number;\n\t\tblobDigest: Uint8Array | (() => Promise<Uint8Array>);\n\t\tnonce: Uint8Array;\n\t}) {\n\t\treturn async (transaction: Transaction) => {\n\t\t\tconst tipConfig = await this.#loadTipConfig();\n\n\t\t\tif (tipConfig) {\n\t\t\t\ttransaction.add(this.addAuthPayload({ size, blobDigest, nonce }));\n\t\t\t\tconst amount = await this.calculateUploadRelayTip({ size });\n\t\t\t\tconst { address } = tipConfig;\n\t\t\t\ttransaction.transferObjects(\n\t\t\t\t\t[\n\t\t\t\t\t\tcoinWithBalance({\n\t\t\t\t\t\t\tbalance: amount,\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t\taddress,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that registers a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.registerBlobTransaction({ size: 1000, epochs: 3, blobId, rootHash, deletable: true });\n\t * ```\n\t */\n\tregisterBlobTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: RegisterBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\t/** Address the blob should be transferred to */\n\t\towner: string;\n\t}) {\n\t\tconst registration = transaction.add(this.registerBlob(options));\n\n\t\ttransaction.transferObjects([registration], options.owner);\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that registers a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest, blob } = await client.executeRegisterBlobTransaction({ size: 1000, epochs: 3, signer });\n\t * ```\n\t */\n\tasync executeRegisterBlobTransaction({\n\t\tsigner,\n\t\t...options\n\t}: RegisterBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\tsigner: Signer;\n\t\t/** Address the blob should be transferred to */\n\t\towner?: string;\n\t}): Promise<{\n\t\tblob: (typeof Blob)['$inferType'];\n\t\tdigest: string;\n\t}> {\n\t\tconst transaction = this.registerBlobTransaction({\n\t\t\t...options,\n\t\t\towner: options.owner ?? options.transaction?.getData().sender ?? signer.toSuiAddress(),\n\t\t});\n\t\tconst blobType = await this.getBlobType();\n\t\tconst { digest, effects } = await this.#executeTransaction(\n\t\t\ttransaction,\n\t\t\tsigner,\n\t\t\t'register blob',\n\t\t);\n\n\t\tconst createdObjectIds = effects?.changedObjects\n\t\t\t.filter((object) => object.idOperation === 'Created')\n\t\t\t.map((object) => object.objectId);\n\n\t\tconst createdObjects = await this.#suiClient.core.getObjects({\n\t\t\tobjectIds: createdObjectIds,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tconst suiBlobObject = createdObjects.objects.find(\n\t\t\t(object) => !(object instanceof Error) && object.type === blobType,\n\t\t);\n\n\t\tif (suiBlobObject instanceof Error || !suiBlobObject) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Blob object not found in transaction effects for transaction (${digest})`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tdigest,\n\t\t\tblob: Blob.parse(suiBlobObject.content),\n\t\t};\n\t}\n\n\tasync #getCreatedBlob(digest: string) {\n\t\tconst blobType = await this.getBlobType();\n\t\tconst result = await this.#suiClient.core.waitForTransaction({\n\t\t\tdigest,\n\t\t\tinclude: { effects: true },\n\t\t});\n\n\t\tconst tx = result.Transaction ?? result.FailedTransaction;\n\t\tconst createdObjectIds = tx.effects?.changedObjects\n\t\t\t.filter((object: { idOperation: string }) => object.idOperation === 'Created')\n\t\t\t.map((object: { objectId: string }) => object.objectId);\n\n\t\tconst createdObjects = await this.#suiClient.core.getObjects({\n\t\t\tobjectIds: createdObjectIds,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tconst suiBlobObject = createdObjects.objects.find(\n\t\t\t(object) => !(object instanceof Error) && object.type === blobType,\n\t\t);\n\n\t\tif (suiBlobObject instanceof Error || !suiBlobObject) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Blob object not found in transaction effects for transaction (${digest})`,\n\t\t\t);\n\t\t}\n\n\t\treturn Blob.parse(suiBlobObject.content);\n\t}\n\n\tasync certificateFromConfirmations({\n\t\tconfirmations,\n\t\tblobId,\n\t\tdeletable,\n\t\tblobObjectId,\n\t}: Extract<\n\t\tCertifyBlobOptions,\n\t\t{ confirmations: unknown[] }\n\t>): Promise<ProtocolMessageCertificate> {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tif (confirmations.length !== systemState.committee.members.length) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t'Invalid number of confirmations. Confirmations array must contain an entry for each node',\n\t\t\t);\n\t\t}\n\n\t\tconst confirmationMessage = StorageConfirmation.serialize({\n\t\t\tintent: IntentType.BLOB_CERT_MSG,\n\t\t\tepoch: systemState.committee.epoch,\n\t\t\tmessageContents: {\n\t\t\t\tblobId,\n\t\t\t\tblobType: deletable\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tDeletable: {\n\t\t\t\t\t\t\t\tobjectId: blobObjectId,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tPermanent: null,\n\t\t\t\t\t\t},\n\t\t\t},\n\t\t}).toBase64();\n\n\t\tconst bindings = await this.#wasmBindings();\n\t\tconst verifySignature = bindings.getVerifySignature();\n\n\t\tconst filteredConfirmations = confirmations\n\t\t\t.map((confirmation, index) => {\n\t\t\t\tconst isValid =\n\t\t\t\t\tconfirmation?.serializedMessage === confirmationMessage &&\n\t\t\t\t\tverifySignature(\n\t\t\t\t\t\tconfirmation,\n\t\t\t\t\t\tnew Uint8Array(committee.nodes[index].info.public_key.bytes),\n\t\t\t\t\t);\n\n\t\t\t\treturn isValid\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t...confirmation,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null;\n\t\t\t})\n\t\t\t.filter((confirmation) => confirmation !== null);\n\n\t\tif (!isQuorum(filteredConfirmations.length, systemState.committee.members.length)) {\n\t\t\tthrow new NotEnoughBlobConfirmationsError(\n\t\t\t\t`Too many invalid confirmations received for blob (${filteredConfirmations.length} of ${systemState.committee.members.length})`,\n\t\t\t);\n\t\t}\n\n\t\treturn bindings.combineSignatures(\n\t\t\tfilteredConfirmations,\n\t\t\tfilteredConfirmations.map(({ index }) => index),\n\t\t);\n\t}\n\n\t/**\n\t * Certify a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * tx.add(client.certifyBlob({ blobId, blobObjectId, confirmations }));\n\t * ```\n\t */\n\tcertifyBlob({ blobId, blobObjectId, confirmations, certificate, deletable }: CertifyBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst systemState = await this.systemState();\n\t\t\tconst combinedSignature =\n\t\t\t\t(typeof certificate === 'string' ? parseCertificateFromBase64(certificate) : certificate) ??\n\t\t\t\t(await this.certificateFromConfirmations({\n\t\t\t\t\tconfirmations: confirmations!,\n\t\t\t\t\tblobId,\n\t\t\t\t\tdeletable,\n\t\t\t\t\tblobObjectId,\n\t\t\t\t}));\n\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\ttx.add(\n\t\t\t\tcertifyBlob({\n\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: this.#packageConfig.systemObjectId,\n\t\t\t\t\t\tblob: blobObjectId,\n\t\t\t\t\t\tsignature: tx.pure.vector('u8', combinedSignature.signature),\n\t\t\t\t\t\tsignersBitmap: tx.pure.vector(\n\t\t\t\t\t\t\t'u8',\n\t\t\t\t\t\t\tsignersToBitmap(combinedSignature.signers, systemState.committee.members.length),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmessage: tx.pure.vector('u8', combinedSignature.serializedMessage),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that certifies a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.certifyBlobTransaction({ blobId, blobObjectId, confirmations });\n\t * ```\n\t */\n\tcertifyBlobTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: CertifyBlobOptions & {\n\t\ttransaction?: Transaction;\n\t}) {\n\t\ttransaction.add(this.certifyBlob(options));\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that certifies a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeCertifyBlobTransaction({ blobId, blobObjectId, confirmations, signer });\n\t * ```\n\t */\n\tasync executeCertifyBlobTransaction({\n\t\tsigner,\n\t\t...options\n\t}: CertifyBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\tsigner: Signer;\n\t}) {\n\t\tconst transaction = this.certifyBlobTransaction(options);\n\n\t\tconst { digest } = await this.#executeTransaction(transaction, signer, 'certify blob');\n\n\t\treturn { digest };\n\t}\n\n\t/**\n\t * Delete a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const storage = await client.deleteBlob({ blobObjectId });\n\t * tx.transferObjects([storage], owner);\n\t * ```\n\t */\n\tdeleteBlob({ blobObjectId }: DeleteBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\t\t\tconst storage = tx.add(\n\t\t\t\tdeleteBlob({\n\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: this.#packageConfig.systemObjectId,\n\t\t\t\t\t\tblob: blobObjectId,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\treturn storage;\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that deletes a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.deleteBlobTransaction({ blobObjectId, owner });\n\t * ```\n\t */\n\tdeleteBlobTransaction({\n\t\towner,\n\t\tblobObjectId,\n\t\ttransaction = new Transaction(),\n\t}: DeleteBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\t/** Address the storage resource should be returned to */\n\t\towner: string;\n\t}) {\n\t\tconst storage = transaction.add(this.deleteBlob({ blobObjectId }));\n\t\ttransaction.transferObjects([storage], owner);\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that deletes a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeDeleteBlobTransaction({ blobObjectId, signer });\n\t * ```\n\t */\n\tasync executeDeleteBlobTransaction({\n\t\tsigner,\n\t\ttransaction = new Transaction(),\n\t\tblobObjectId,\n\t}: DeleteBlobOptions & { signer: Signer; transaction?: Transaction }) {\n\t\tconst { digest } = await this.#executeTransaction(\n\t\t\tthis.deleteBlobTransaction({\n\t\t\t\tblobObjectId,\n\t\t\t\ttransaction,\n\t\t\t\towner: transaction.getData().sender ?? signer.toSuiAddress(),\n\t\t\t}),\n\t\t\tsigner,\n\t\t\t'delete blob',\n\t\t);\n\n\t\treturn { digest };\n\t}\n\n\t/**\n\t * Extend a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.extendBlobTransaction({ blobObjectId, epochs });\n\t * ```\n\t */\n\textendBlob({ blobObjectId, epochs, endEpoch, walCoin }: ExtendBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst blob = await this.#objectLoader.load(blobObjectId, Blob);\n\t\t\tconst numEpochs = typeof epochs === 'number' ? epochs : endEpoch - blob.storage.end_epoch;\n\n\t\t\tif (numEpochs <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { storageCost } = await this.#storageCostFromEncodedSize(\n\t\t\t\tNumber(blob.storage.storage_size),\n\t\t\t\tnumEpochs,\n\t\t\t);\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\treturn tx.add(\n\t\t\t\tthis.#withWal(storageCost, walCoin ?? null, async (coin, tx) => {\n\t\t\t\t\ttx.add(\n\t\t\t\t\t\textendBlob({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: this.#packageConfig.systemObjectId,\n\t\t\t\t\t\t\t\tblob: blobObjectId,\n\t\t\t\t\t\t\t\textendedEpochs: numEpochs,\n\t\t\t\t\t\t\t\tpayment: coin,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that extends a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.extendBlobTransaction({ blobObjectId, epochs });\n\t * ```\n\t */\n\tasync extendBlobTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: ExtendBlobOptions & { transaction?: Transaction }) {\n\t\ttransaction.add(this.extendBlob(options));\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that extends a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeExtendBlobTransaction({ blobObjectId, signer });\n\t * ```\n\t */\n\tasync executeExtendBlobTransaction({\n\t\tsigner,\n\t\t...options\n\t}: ExtendBlobOptions & { signer: Signer; transaction?: Transaction }) {\n\t\tconst { digest } = await this.#executeTransaction(\n\t\t\tawait this.extendBlobTransaction(options),\n\t\t\tsigner,\n\t\t\t'extend blob',\n\t\t);\n\n\t\treturn { digest };\n\t}\n\n\tasync readBlobAttributes({\n\t\tblobObjectId,\n\t}: {\n\t\tblobObjectId: string;\n\t}): Promise<Record<string, string> | null> {\n\t\tconst response = await this.#suiClient.core.getDynamicField({\n\t\t\tparentId: blobObjectId,\n\t\t\tname: {\n\t\t\t\ttype: 'vector<u8>',\n\t\t\t\tbcs: bcs.string().serialize('metadata').toBytes(),\n\t\t\t},\n\t\t});\n\n\t\tconst parsedMetadata = metadata.Metadata.parse(response.dynamicField.value.bcs);\n\n\t\treturn Object.fromEntries(\n\t\t\tparsedMetadata.metadata.contents.map(({ key, value }) => [key, value]),\n\t\t);\n\t}\n\n\t#writeBlobAttributesForRef({\n\t\tattributes,\n\t\texistingAttributes,\n\t\tblob,\n\t}: {\n\t\tattributes: Record<string, string | null>;\n\t\texistingAttributes: Record<string, string> | null;\n\t\tblob: TransactionObjectArgument;\n\t}) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\tif (!existingAttributes) {\n\t\t\t\ttx.add(\n\t\t\t\t\taddMetadata({\n\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\tself: blob,\n\t\t\t\t\t\t\tmetadata: metadata._new({\n\t\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tObject.keys(attributes).forEach((key) => {\n\t\t\t\tconst value = attributes[key];\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\tif (existingAttributes && key in existingAttributes) {\n\t\t\t\t\t\ttx.add(\n\t\t\t\t\t\t\tremoveMetadataPair({\n\t\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\t\tself: blob,\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttx.add(\n\t\t\t\t\t\tinsertOrUpdateMetadataPair({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: blob,\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t}\n\n\t/**\n\t * Write attributes to a blob\n\t *\n\t * If attributes already exists, their previous values will be overwritten\n\t * If an attribute is set to `null`, it will be removed from the blob\n\t *\n\t * @example\n\t * ```ts\n\t * tx.add(client.writeBlobAttributes({ blobObjectId, attributes: { key: 'value', keyToRemove: null } }));\n\t * ```\n\t */\n\twriteBlobAttributes({ blobObject, blobObjectId, attributes }: WriteBlobAttributesOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst existingAttributes = blobObjectId\n\t\t\t\t? await this.readBlobAttributes({ blobObjectId })\n\t\t\t\t: null;\n\t\t\tconst blob = blobObject ?? tx.object(blobObjectId);\n\n\t\t\ttx.add(\n\t\t\t\tthis.#writeBlobAttributesForRef({\n\t\t\t\t\tattributes,\n\t\t\t\t\texistingAttributes,\n\t\t\t\t\tblob,\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that writes attributes to a blob\n\t *\n\t * If attributes already exists, their previous values will be overwritten\n\t * If an attribute is set to `null`, it will be removed from the blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.writeBlobAttributesTransaction({ blobObjectId, attributes: { key: 'value', keyToRemove: null } });\n\t * ```\n\t */\n\tasync writeBlobAttributesTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: WriteBlobAttributesOptions & { transaction?: Transaction }) {\n\t\ttransaction.add(await this.writeBlobAttributes(options));\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that writes attributes to a blob\n\t *\n\t * If attributes already exists, their previous values will be overwritten\n\t * If an attribute is set to `null`, it will be removed from the blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeWriteBlobAttributesTransaction({ blobObjectId, signer });\n\t * ```\n\t */\n\tasync executeWriteBlobAttributesTransaction({\n\t\tsigner,\n\t\t...options\n\t}: WriteBlobAttributesOptions & { signer: Signer; transaction?: Transaction }) {\n\t\tconst { digest } = await this.#executeTransaction(\n\t\t\tawait this.writeBlobAttributesTransaction(options),\n\t\t\tsigner,\n\t\t\t'write blob attributes',\n\t\t);\n\t\treturn { digest };\n\t}\n\n\t/**\n\t * Write a sliver to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const res = await client.writeSliver({ blobId, sliverPairIndex, sliverType, sliver });\n\t * ```\n\t */\n\tasync writeSliver({ blobId, sliverPairIndex, sliverType, sliver, signal }: WriteSliverOptions) {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tconst shardIndex = toShardIndex(sliverPairIndex, blobId, systemState.committee.n_shards);\n\t\tconst node = await this.#getNodeByShardIndex(committee, shardIndex);\n\n\t\treturn this.#storageNodeClient.storeSliver(\n\t\t\t{ blobId, sliverPairIndex, sliverType, sliver },\n\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t);\n\t}\n\n\t/**\n\t * Write metadata to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const res = await client.writeMetadataToNode({ nodeIndex, blobId, metadata });\n\t * ```\n\t */\n\tasync writeMetadataToNode({ nodeIndex, blobId, metadata, signal }: WriteMetadataOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\n\t\treturn retry(\n\t\t\t() =>\n\t\t\t\tthis.#storageNodeClient.storeBlobMetadata(\n\t\t\t\t\t{ blobId, metadata },\n\t\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t\t),\n\t\t\t{\n\t\t\t\tcount: 3,\n\t\t\t\tdelay: 1000,\n\t\t\t\tcondition: (error) => error instanceof BlobNotRegisteredError,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Get a storage confirmation from a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const confirmation = await client.getStorageConfirmationFromNode({ nodeIndex, blobId, deletable, objectId });\n\t * ```\n\t */\n\tasync getStorageConfirmationFromNode({\n\t\tnodeIndex,\n\t\tblobId,\n\t\tdeletable,\n\t\tobjectId,\n\t\tsignal,\n\t}: GetStorageConfirmationOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\n\t\tconst result = deletable\n\t\t\t? await this.#storageNodeClient.getDeletableBlobConfirmation(\n\t\t\t\t\t{ blobId, objectId },\n\t\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t\t)\n\t\t\t: await this.#storageNodeClient.getPermanentBlobConfirmation(\n\t\t\t\t\t{ blobId },\n\t\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t\t);\n\n\t\treturn result?.success?.data?.signed ?? null;\n\t}\n\n\t/**\n\t * Get storage confirmations from all active committee nodes for a blob.\n\t *\n\t * @example\n\t * ```ts\n\t * const confirmations = await client.getStorageConfirmations({\n\t * blobId: savedState.blobId,\n\t * deletable: true,\n\t * objectId: savedState.blobObjectId,\n\t * });\n\t * const tx = client.certifyBlobTransaction({ blobId, blobObjectId, confirmations, deletable: true });\n\t * ```\n\t */\n\tasync getStorageConfirmations({\n\t\tblobId,\n\t\tdeletable,\n\t\tobjectId,\n\t\tsignal,\n\t}: {\n\t\tblobId: string;\n\t\tdeletable: boolean;\n\t\tobjectId?: string;\n\t\tsignal?: AbortSignal;\n\t}): Promise<(StorageConfirmationType | null)[]> {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\treturn Promise.all(\n\t\t\tcommittee.nodes.map((_, nodeIndex) =>\n\t\t\t\tthis.getStorageConfirmationFromNode({\n\t\t\t\t\tnodeIndex,\n\t\t\t\t\tblobId,\n\t\t\t\t\t...(deletable\n\t\t\t\t\t\t? { deletable: true as const, objectId: objectId! }\n\t\t\t\t\t\t: { deletable: false as const }),\n\t\t\t\t\tsignal,\n\t\t\t\t}).catch(() => null),\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * Load a parsed Blob object from chain by its Sui object ID.\n\t *\n\t * @example\n\t * ```ts\n\t * const blobObject = await client.getBlobObject('0x...');\n\t * console.log(blobObject.id, blobObject.blob_id);\n\t * ```\n\t */\n\tasync getBlobObject(blobObjectId: string) {\n\t\treturn this.#objectLoader.load(blobObjectId, Blob);\n\t}\n\n\t/**\n\t * Encode a blob into slivers for each node\n\t *\n\t * @example\n\t * ```ts\n\t * const { blobId, metadata, sliversByNode, rootHash } = await client.encodeBlob(blob);\n\t * ```\n\t */\n\tasync encodeBlob(blob: Uint8Array) {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tconst numShards = systemState.committee.n_shards;\n\t\tconst bindings = await this.#wasmBindings();\n\t\tconst { blobId, metadata, primarySlivers, secondarySlivers, rootHash } = bindings.encodeBlob(\n\t\t\tnumShards,\n\t\t\tblob,\n\t\t);\n\n\t\tconst sliversByNodeMap = new Map<number, SliversForNode>();\n\n\t\t// Process each sliver pair (already BCS-encoded)\n\t\tfor (let sliverPairIndex = 0; sliverPairIndex < primarySlivers.length; sliverPairIndex++) {\n\t\t\tconst primarySliver = primarySlivers[sliverPairIndex];\n\t\t\tconst secondarySliver = secondarySlivers[sliverPairIndex];\n\n\t\t\tconst shardIndex = toShardIndex(sliverPairIndex, blobId, numShards);\n\t\t\tconst node = await this.#getNodeByShardIndex(committee, shardIndex);\n\n\t\t\tif (!sliversByNodeMap.has(node.nodeIndex)) {\n\t\t\t\tsliversByNodeMap.set(node.nodeIndex, { primary: [], secondary: [] });\n\t\t\t}\n\n\t\t\tsliversByNodeMap.get(node.nodeIndex)!.primary.push({\n\t\t\t\tsliverIndex: sliverPairIndex,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tshardIndex,\n\t\t\t\tsliver: primarySliver,\n\t\t\t});\n\n\t\t\tsliversByNodeMap.get(node.nodeIndex)!.secondary.push({\n\t\t\t\tsliverIndex: sliverPairIndex,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tshardIndex,\n\t\t\t\tsliver: secondarySliver,\n\t\t\t});\n\t\t}\n\n\t\tconst sliversByNode = new Array<SliversForNode>();\n\n\t\tfor (let i = 0; i < systemState.committee.members.length; i++) {\n\t\t\tsliversByNode.push(sliversByNodeMap.get(i) ?? { primary: [], secondary: [] });\n\t\t}\n\n\t\treturn { blobId, metadata, rootHash, sliversByNode };\n\t}\n\n\t/**\n\t * Write slivers to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * await client.writeSliversToNode({ blobId, slivers, signal });\n\t * ```\n\t */\n\tasync writeSliversToNode({ blobId, slivers, signal }: WriteSliversToNodeOptions) {\n\t\tconst controller = new AbortController();\n\t\tconst combinedSignal = signal\n\t\t\t? AbortSignal.any([controller.signal, signal])\n\t\t\t: controller.signal;\n\n\t\tconst primarySliverWrites = slivers.primary.map(({ sliverPairIndex, sliver }) => {\n\t\t\treturn this.writeSliver({\n\t\t\t\tblobId,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tsliverType: 'primary',\n\t\t\t\tsliver,\n\t\t\t\tsignal: combinedSignal,\n\t\t\t});\n\t\t});\n\n\t\tconst secondarySliverWrites = slivers.secondary.map(({ sliverPairIndex, sliver }) => {\n\t\t\treturn this.writeSliver({\n\t\t\t\tblobId,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tsliverType: 'secondary',\n\t\t\t\tsliver,\n\t\t\t\tsignal: combinedSignal,\n\t\t\t});\n\t\t});\n\n\t\tawait Promise.all([...primarySliverWrites, ...secondarySliverWrites]).catch((error) => {\n\t\t\tcontroller.abort(error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\t/**\n\t * Write a blob to all storage nodes\n\t *\n\t * @example\n\t * ```ts\n\t * await client.writeEncodedBlobToNodes({ blob, deletable, epochs, signer });\n\t * ```\n\t */\n\tasync writeEncodedBlobToNodes({\n\t\tblobId,\n\t\tmetadata,\n\t\tsliversByNode,\n\t\tsignal,\n\t\t...options\n\t}: WriteEncodedBlobToNodesOptions) {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tconst controller = new AbortController();\n\t\tlet failures = 0;\n\n\t\tconst confirmations = await Promise.all(\n\t\t\tsliversByNode.map((slivers, nodeIndex) => {\n\t\t\t\treturn this.writeEncodedBlobToNode({\n\t\t\t\t\tblobId,\n\t\t\t\t\tnodeIndex,\n\t\t\t\t\tmetadata,\n\t\t\t\t\tslivers,\n\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t...options,\n\t\t\t\t}).catch(() => {\n\t\t\t\t\tfailures += committee.nodes[nodeIndex].shardIndices.length;\n\n\t\t\t\t\tif (isAboveValidity(failures, systemState.committee.n_shards)) {\n\t\t\t\t\t\tconst error = new NotEnoughBlobConfirmationsError(\n\t\t\t\t\t\t\t`Too many failures while writing blob ${blobId} to nodes`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontroller.abort(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\n\t\treturn confirmations;\n\t}\n\n\t/**\n\t * Writes a blob to to an upload relay\n\t *\n\t * @example\n\t * ```ts\n\t * await client.writeBlobToUploadRelay({ blob, deletable, epochs, signer });\n\t * ```\n\t */\n\tasync writeBlobToUploadRelay(options: WriteBlobToUploadRelayOptions): Promise<{\n\t\tblobId: string;\n\t\tcertificate: ProtocolMessageCertificate;\n\t}> {\n\t\tif (!this.#uploadRelayClient) {\n\t\t\tthrow new WalrusClientError('Upload relay not configured');\n\t\t}\n\n\t\treturn this.#uploadRelayClient.writeBlob({\n\t\t\t...options,\n\t\t\trequiresTip: !!this.#uploadRelayConfig?.sendTip,\n\t\t});\n\t}\n\n\t/**\n\t * Write encoded blob to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const res = await client.writeEncodedBlobToNode({ nodeIndex, blobId, metadata, slivers });\n\t * ```\n\t */\n\tasync writeEncodedBlobToNode({\n\t\tnodeIndex,\n\t\tblobId,\n\t\tmetadata,\n\t\tslivers,\n\t\tsignal,\n\t\t...options\n\t}: WriteEncodedBlobOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\n\t\tlet metaDataExists = false;\n\t\ttry {\n\t\t\tconst metadataStatus = await this.#storageNodeClient.getMetadataStatus(\n\t\t\t\t{ blobId },\n\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t);\n\t\t\tif (metadataStatus === 'Stored' || metadataStatus === 'Buffered') {\n\t\t\t\tmetaDataExists = true;\n\t\t\t}\n\t\t} catch {\n\t\t\t// If status check fails, fall through to writing metadata\n\t\t}\n\n\t\tif (!metaDataExists) {\n\t\t\tawait this.writeMetadataToNode({\n\t\t\t\tnodeIndex,\n\t\t\t\tblobId,\n\t\t\t\tmetadata,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t}\n\n\t\tif (!metaDataExists) {\n\t\t\tawait this.writeSliversToNode({ blobId, slivers, signal, nodeIndex });\n\t\t} else {\n\t\t\tawait this.#writeSliversWithStatusCheck({ blobId, slivers, signal, nodeIndex });\n\t\t}\n\n\t\treturn this.getStorageConfirmationFromNode({\n\t\t\tnodeIndex,\n\t\t\tblobId,\n\t\t\t...options,\n\t\t});\n\t}\n\n\tasync #writeSliversWithStatusCheck({\n\t\tblobId,\n\t\tslivers,\n\t\tsignal,\n\t\tnodeIndex,\n\t}: WriteSliversToNodeOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\t\tconst controller = new AbortController();\n\t\tconst combinedSignal = signal\n\t\t\t? AbortSignal.any([controller.signal, signal])\n\t\t\t: controller.signal;\n\n\t\tconst sliverWrites = [\n\t\t\t...slivers.primary.map((s) => ({ ...s, sliverType: 'primary' as const })),\n\t\t\t...slivers.secondary.map((s) => ({ ...s, sliverType: 'secondary' as const })),\n\t\t].map(async ({ sliverPairIndex, sliver, sliverType }) => {\n\t\t\tif (sliver.byteLength >= SLIVER_STATUS_CHECK_THRESHOLD) {\n\t\t\t\ttry {\n\t\t\t\t\tconst status = await this.#storageNodeClient.getSliverStatus(\n\t\t\t\t\t\t{ blobId, sliverPairIndex, sliverType },\n\t\t\t\t\t\t{ nodeUrl: node.networkUrl, signal: combinedSignal },\n\t\t\t\t\t);\n\t\t\t\t\tif (status === 'Stored' || status === 'Buffered') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// If status check fails, fall through to writing\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this.writeSliver({\n\t\t\t\tblobId,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tsliverType,\n\t\t\t\tsliver,\n\t\t\t\tsignal: combinedSignal,\n\t\t\t});\n\t\t});\n\n\t\tawait Promise.all(sliverWrites).catch((error) => {\n\t\t\tcontroller.abort(error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\t/**\n\t * Write a blob to all storage nodes\n\t *\n\t * @example\n\t * ```ts\n\t * const { blobId, blobObject } = await client.writeBlob({ blob, deletable, epochs, signer });\n\t * ```\n\t */\n\tasync writeBlob({\n\t\tblob,\n\t\tdeletable,\n\t\tepochs,\n\t\tsigner,\n\t\towner,\n\t\tattributes,\n\t\tonStep,\n\t\tresume,\n\t\tsignal,\n\t}: WriteBlobOptions) {\n\t\tconst flow = this.writeBlobFlow({ blob, resume });\n\t\tfor await (const step of flow.run({\n\t\t\tsigner,\n\t\t\tepochs,\n\t\t\tdeletable,\n\t\t\towner: owner ?? signer.toSuiAddress(),\n\t\t\tattributes,\n\t\t\tsignal,\n\t\t})) {\n\t\t\tawait onStep?.(step);\n\t\t}\n\n\t\tconst result = await flow.getBlob();\n\t\treturn {\n\t\t\tblobId: result.blobId,\n\t\t\tblobObject: result.blobObject,\n\t\t};\n\t}\n\n\tasync writeQuilt({ blobs, ...options }: WriteQuiltOptions) {\n\t\tconst encoded = await this.encodeQuilt({ blobs });\n\t\tconst result = await this.writeBlob({\n\t\t\t...options,\n\t\t\tblob: encoded.quilt,\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\n\t\treturn {\n\t\t\t...result,\n\t\t\tindex: {\n\t\t\t\t...encoded.index,\n\t\t\t\tpatches: encoded.index.patches.map((patch) => ({\n\t\t\t\t\t...patch,\n\t\t\t\t\tpatchId: encodeQuiltPatchId({\n\t\t\t\t\t\tquiltId: result.blobId,\n\t\t\t\t\t\tpatchId: {\n\t\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\t\tstartIndex: patch.startIndex,\n\t\t\t\t\t\t\tendIndex: patch.endIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t})),\n\t\t\t},\n\t\t};\n\t}\n\n\tasync encodeQuilt({\n\t\tblobs,\n\t}: {\n\t\tblobs: {\n\t\t\tcontents: Uint8Array;\n\t\t\tidentifier: string;\n\t\t\ttags?: Record<string, string>;\n\t\t}[];\n\t}) {\n\t\tconst systemState = await this.systemState();\n\t\tconst encoded = encodeQuilt({\n\t\t\tblobs,\n\t\t\tnumShards: systemState.committee.n_shards,\n\t\t});\n\n\t\treturn encoded;\n\t}\n\n\tasync #executeTransaction(transaction: Transaction, signer: Signer, action: string) {\n\t\ttransaction.setSenderIfNotSet(signer.toSuiAddress());\n\n\t\tconst result = await signer.signAndExecuteTransaction({\n\t\t\ttransaction,\n\t\t\tclient: this.#suiClient,\n\t\t});\n\n\t\tif (result.FailedTransaction) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Failed to ${action} (${result.FailedTransaction.digest}): ${result.FailedTransaction.status.error?.message}`,\n\t\t\t);\n\t\t}\n\n\t\tconst { digest, effects } = result.Transaction;\n\n\t\tawait this.#suiClient.core.waitForTransaction({\n\t\t\tdigest,\n\t\t});\n\n\t\treturn { digest, effects };\n\t}\n\n\tasync #getCommittee(committee: InferBcsType<typeof Committee>) {\n\t\tconst stakingPool = await this.#stakingPool(committee);\n\t\tconst shardIndicesByNodeId = getShardIndicesByNodeId(committee);\n\n\t\tconst byShardIndex = new Map<number, StorageNode>();\n\t\tconst nodes = stakingPool.map(({ node_info }, nodeIndex) => {\n\t\t\tconst shardIndices = shardIndicesByNodeId.get(node_info.node_id) ?? [];\n\t\t\tconst node: StorageNode = {\n\t\t\t\tid: node_info.node_id,\n\t\t\t\tinfo: node_info,\n\t\t\t\tnetworkUrl: `https://${node_info.network_address}`,\n\t\t\t\tshardIndices,\n\t\t\t\tnodeIndex,\n\t\t\t};\n\n\t\t\tfor (const shardIndex of shardIndices) {\n\t\t\t\tbyShardIndex.set(shardIndex, node);\n\t\t\t}\n\n\t\t\treturn node;\n\t\t});\n\n\t\treturn {\n\t\t\tbyShardIndex,\n\t\t\tnodes,\n\t\t};\n\t}\n\n\t#getActiveCommittee() {\n\t\treturn this.#cache.read(['getActiveCommittee'], async () => {\n\t\t\tconst stakingState = await this.stakingState();\n\t\t\treturn this.#getCommittee(stakingState.committee);\n\t\t});\n\t}\n\n\tasync #stakingPool(committee: InferBcsType<typeof Committee>) {\n\t\tconst nodeIds = committee[0].contents.map((node) => node.key);\n\t\treturn this.#objectLoader.loadManyOrThrow(nodeIds, StakingPool);\n\t}\n\n\tasync #getNodeByShardIndex(committeeInfo: CommitteeInfo, index: number) {\n\t\tconst node = committeeInfo.byShardIndex.get(index);\n\t\tif (!node) {\n\t\t\tthrow new WalrusClientError(`Node for shard index ${index} not found`);\n\t\t}\n\t\treturn node;\n\t}\n\n\t/**\n\t * Reset cached data in the client\n\t *\n\t * @example\n\t * ```ts\n\t * client.reset();\n\t * ```\n\t */\n\treset() {\n\t\tthis.#objectLoader.clearAll();\n\t\tthis.#cache.clear();\n\t}\n\n\t#retryOnPossibleEpochChange<T extends (...args: any[]) => Promise<any>>(fn: T): T {\n\t\treturn (async (...args: Parameters<T>) => {\n\t\t\ttry {\n\t\t\t\treturn await fn.apply(this, args);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof RetryableWalrusClientError) {\n\t\t\t\t\tthis.reset();\n\t\t\t\t\treturn await fn.apply(this, args);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}) as T;\n\t}\n\n\tasync getBlob({ blobId }: { blobId: string }) {\n\t\treturn new WalrusBlob({\n\t\t\treader: new BlobReader({\n\t\t\t\tclient: this,\n\t\t\t\tblobId,\n\t\t\t\tnumShards: (await this.systemState()).committee.n_shards,\n\t\t\t}),\n\t\t\tclient: this,\n\t\t});\n\t}\n\n\tasync getFiles({ ids }: { ids: string[] }) {\n\t\tconst readersByBlobId = new Map<string, BlobReader>();\n\t\tconst quiltReadersByBlobId = new Map<string, QuiltReader>();\n\t\tconst parsedIds = ids.map((id) => parseWalrusId(id));\n\t\tconst numShards = (await this.systemState()).committee.n_shards;\n\n\t\tfor (const id of parsedIds) {\n\t\t\tconst blobId = id.kind === 'blob' ? id.id : id.id.quiltId;\n\t\t\tif (!readersByBlobId.has(blobId)) {\n\t\t\t\treadersByBlobId.set(\n\t\t\t\t\tblobId,\n\t\t\t\t\tnew BlobReader({\n\t\t\t\t\t\tclient: this,\n\t\t\t\t\t\tblobId,\n\t\t\t\t\t\tnumShards,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (id.kind === 'quiltPatch') {\n\t\t\t\tif (!quiltReadersByBlobId.has(blobId)) {\n\t\t\t\t\tquiltReadersByBlobId.set(\n\t\t\t\t\t\tblobId,\n\t\t\t\t\t\tnew QuiltReader({\n\t\t\t\t\t\t\tblob: readersByBlobId.get(blobId)!,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn parsedIds.map((id) => {\n\t\t\tif (id.kind === 'blob') {\n\t\t\t\treturn new WalrusFile({\n\t\t\t\t\treader: readersByBlobId.get(id.id)!,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn new WalrusFile({\n\t\t\t\treader: new QuiltFileReader({\n\t\t\t\t\tquilt: quiltReadersByBlobId.get(id.id.quiltId)!,\n\t\t\t\t\tsliverIndex: id.id.patchId.startIndex,\n\t\t\t\t}),\n\t\t\t});\n\t\t});\n\t}\n\n\tasync writeFiles({ files, onStep, resume, ...options }: WriteFilesOptions) {\n\t\tconst flow = this.writeFilesFlow({ files, resume });\n\t\tfor await (const step of flow.run({\n\t\t\tsigner: options.signer,\n\t\t\tepochs: options.epochs,\n\t\t\tdeletable: options.deletable,\n\t\t\towner: options.owner ?? options.signer.toSuiAddress(),\n\t\t\tattributes: options.attributes,\n\t\t})) {\n\t\t\tawait onStep?.(step);\n\t\t}\n\n\t\treturn flow.listFiles();\n\t}\n\n\t/**\n\t * Create a step-by-step files upload flow with resume support.\n\t *\n\t * Encodes files into a quilt blob and delegates to `writeBlobFlow()` internally.\n\t * Supports the same resume, step methods, and `run()` async iterator as `writeBlobFlow()`.\n\t *\n\t * @example\n\t * ```ts\n\t * const flow = client.writeFilesFlow({ files });\n\t * for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {\n\t * await db.save(fileId, step);\n\t * }\n\t * const fileRefs = await flow.listFiles();\n\t * ```\n\t */\n\twriteFilesFlow(options: WriteFilesFlowOptions): WriteFilesFlow {\n\t\treturn createWriteFilesFlow(this, options);\n\t}\n\n\t/**\n\t * Create a step-by-step blob upload flow with resume support.\n\t *\n\t * Returns an object with individual step methods (`encode`, `register`, `upload`, `certify`)\n\t * for manual control, convenience methods (`executeRegister`, `executeCertify`) that handle\n\t * signing, and a `run()` async iterator that executes the full pipeline.\n\t *\n\t * Each step returns a `WriteBlobStep` result that can be persisted and passed as `resume`\n\t * to recover from crashes.\n\t *\n\t * @example\n\t * ```ts\n\t * // Async iterator with checkpoints:\n\t * const flow = client.writeBlobFlow({ blob });\n\t * for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {\n\t * await db.save(fileId, step);\n\t * }\n\t *\n\t * // Resume from saved state:\n\t * const saved = await db.load(fileId);\n\t * const flow = client.writeBlobFlow({ blob, resume: saved });\n\t * for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {\n\t * await db.save(fileId, step);\n\t * }\n\t * ```\n\t */\n\twriteBlobFlow(options: WriteBlobFlowOptions): WriteBlobFlow {\n\t\treturn createWriteBlobFlow(this, this.#flowContext(), options);\n\t}\n\n\t#flowContext(): WriteBlobFlowContext {\n\t\treturn {\n\t\t\thasUploadRelay: () => !!this.#uploadRelayClient,\n\t\t\texecuteTransaction: (transaction, signer, action) =>\n\t\t\t\tthis.#executeTransaction(transaction, signer, action),\n\t\t\tgetCreatedBlob: (digest) => this.#getCreatedBlob(digest),\n\t\t\tloadBlobObject: (objectId) => this.#objectLoader.load(objectId, Blob),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIA,SAAgB,OAA8B,EAC7C,eACA,OAAO,UACP,GAAG,YACqB,EAAE,EAAE;AAC5B,QAAO;EACN;EACA,WAAW,WAA8B;GACxC,MAAM,gBAAgB,OAAO;AAE7B,OAAI,kBAAkB,aAAa,kBAAkB,UACpD,OAAM,IAAI,kBAAkB,kDAAkD;AAG/E,UAAO,IAAI,aACV,gBACG;IACA;IACA,WAAW;IACX,GAAG;IACH,GACA;IACA,SAAS;IACT,WAAW;IACX,GAAG;IACH,CACH;;EAEF;;AAGF,IAAa,eAAb,MAA0B;CACzB;CACA;CAEA;CACA;CACA;CAEA,gCAAgC;CAChC;CAEA;CAEA,qBAA+C;CAC/C,qBAA+C;CAE/C,YAAY,QAA4B;kBAiH7B,MAAKA,2BAA4B,MAAKC,iBAAkB;4BAoJ9C,MAAKD,2BAA4B,KAAK,2BAA2B;AApQrF,MAAI,OAAO,WAAW,CAAC,OAAO,eAAe;GAC5C,MAAM,UAAU,OAAO;AACvB,WAAQ,SAAR;IACC,KAAK;AACJ,WAAKE,gBAAiB;AACtB;IACD,KAAK;AACJ,WAAKA,gBAAiB;AACtB;IACD,QACC,OAAM,IAAI,kBAAkB,wBAAwB,UAAU;;QAGhE,OAAKA,gBAAiB,OAAO;AAG9B,QAAKC,UAAW,OAAO;AACvB,QAAKC,oBAAqB,OAAO,eAAe;AAChD,MAAI,MAAKA,kBACR,OAAKC,oBAAqB,IAA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AAS,KAAK;AAGrB,SAAO,KAAK,WAAW;;;;;;;;;;;;;;;;;CAkBxB,eAAe,SAAgD;AAC9D,SAAO,qBAAqB,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B3C,cAAc,SAA8C;AAC3D,SAAO,oBAAoB,MAAM,MAAKuB,aAAc,EAAE,QAAQ;;CAG/D,eAAqC;AACpC,SAAO;GACN,sBAAsB,CAAC,CAAC,MAAK3B;GAC7B,qBAAqB,aAAa,QAAQ,WACzC,MAAKoB,mBAAoB,aAAa,QAAQ,OAAO;GACtD,iBAAiB,WAAW,MAAKG,eAAgB,OAAO;GACxD,iBAAiB,aAAa,MAAKpB,aAAc,KAAK,UAAU,KAAK;GACrE"}
|
|
1
|
+
{"version":3,"file":"client.mjs","names":["#retryOnPossibleEpochChange","#internalReadBlob","#packageConfig","#wasmUrl","#storageNodeUrlScheme","#uploadRelayConfig","#uploadRelayClient","#suiClient","#storageNodeClient","#objectLoader","#cache","#getPackageId","#wasmBindings","#getReadCommittee","#blobMetadataConcurrencyLimit","#getActiveCommittee","#getNodeByShardIndex","#getCertificationEpoch","#readCommittee","#forceGetReadCommittee","#getCommittee","#storageCostFromEncodedSize","#getWalrusPackageId","#withWal","tx","#walType","#executeTransaction","#writeBlobAttributesForRef","#loadTipConfig","#getCreatedBlob","metadata._new","#writeSliversWithStatusCheck","#stakingPool","#flowContext"],"sources":["../src/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferBcsType } from '@mysten/bcs';\nimport { bcs } from '@mysten/bcs';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { ClientCache, ClientWithCoreApi } from '@mysten/sui/client';\nimport type { TransactionObjectArgument, TransactionResult } from '@mysten/sui/transactions';\nimport { coinWithBalance, Transaction } from '@mysten/sui/transactions';\nimport { normalizeStructTag, parseStructTag } from '@mysten/sui/utils';\n\nimport {\n\tMAINNET_WALRUS_PACKAGE_CONFIG,\n\tSLIVER_STATUS_CHECK_THRESHOLD,\n\tstatusLifecycleRank,\n\tTESTNET_WALRUS_PACKAGE_CONFIG,\n} from './constants.js';\nimport {\n\taddMetadata,\n\tBlob,\n\tinsertOrUpdateMetadataPair,\n\tremoveMetadataPair,\n} from './contracts/walrus/blob.js';\nimport type { Committee } from './contracts/walrus/committee.js';\nimport * as metadata from './contracts/walrus/metadata.js';\nimport { StakingInnerV1 } from './contracts/walrus/staking_inner.js';\nimport { StakingPool } from './contracts/walrus/staking_pool.js';\nimport { Staking } from './contracts/walrus/staking.js';\nimport { Storage } from './contracts/walrus/storage_resource.js';\nimport { SystemStateInnerV1 } from './contracts/walrus/system_state_inner.js';\nimport {\n\tcertifyBlob,\n\tdeleteBlob,\n\textendBlob,\n\tregisterBlob,\n\treserveSpace,\n\tSystem,\n} from './contracts/walrus/system.js';\nimport {\n\tBehindCurrentEpochError,\n\tBlobBlockedError,\n\tBlobNotCertifiedError,\n\tInconsistentBlobError,\n\tNoBlobMetadataReceivedError,\n\tNoBlobStatusReceivedError,\n\tNotEnoughBlobConfirmationsError,\n\tNotEnoughSliversReceivedError,\n\tNoVerifiedBlobStatusReceivedError,\n\tRetryableWalrusClientError,\n\tWalrusClientError,\n} from './error.js';\nimport { StorageNodeClient } from './storage-node/client.js';\nimport {\n\tBlobNotRegisteredError,\n\tLegallyUnavailableError,\n\tNotFoundError,\n\tUserAbortError,\n} from './storage-node/error.js';\nimport type {\n\tBlobMetadataWithId,\n\tBlobStatus,\n\tGetSliverResponse,\n\tStorageConfirmation as StorageConfirmationType,\n} from './storage-node/types.js';\nimport type {\n\tCertifyBlobOptions,\n\tCommitteeInfo,\n\tComputeBlobMetadataOptions,\n\tDeleteBlobOptions,\n\tExtendBlobOptions,\n\tUploadRelayConfig,\n\tGetBlobMetadataOptions,\n\tGetCertificationEpochOptions,\n\tGetSecondarySliverOptions,\n\tGetSliversOptions,\n\tGetStorageConfirmationOptions,\n\tGetVerifiedBlobStatusOptions,\n\tProtocolMessageCertificate,\n\tReadBlobOptions,\n\tRegisterBlobOptions,\n\tSliversForNode,\n\tStorageNode,\n\tStorageWithSizeOptions,\n\tWalrusClientConfig,\n\tWalrusPackageConfig,\n\tWriteBlobAttributesOptions,\n\tWriteBlobOptions,\n\tWriteBlobToUploadRelayOptions,\n\tWriteEncodedBlobOptions,\n\tWriteEncodedBlobToNodesOptions,\n\tWriteMetadataOptions,\n\tWriteQuiltOptions,\n\tWriteSliverOptions,\n\tWriteSliversToNodeOptions,\n\tWriteFilesOptions,\n\tWriteFilesFlowOptions,\n\tWriteFilesFlow,\n\tWriteBlobFlow,\n\tWriteBlobFlowOptions,\n\tWalrusOptions,\n} from './types.js';\nimport {\n\tblobIdToInt,\n\tIntentType,\n\tparseCertificateFromBase64,\n\tStorageConfirmation,\n} from './utils/bcs.js';\nimport {\n\tencodedBlobLength,\n\tgetShardIndicesByNodeId,\n\tgetSourceSymbols,\n\tisAboveValidity,\n\tisQuorum,\n\tsignersToBitmap,\n\tsliverPairIndexFromSecondarySliverIndex,\n\tstorageUnitsFromSize,\n\ttoPairIndex,\n\ttoShardIndex,\n} from './utils/index.js';\nimport { SuiObjectDataLoader } from './utils/object-loader.js';\nimport { shuffle, weightedShuffle } from './utils/randomness.js';\nimport { getWasmBindings } from './wasm.js';\nimport { chunk } from '@mysten/utils';\nimport { UploadRelayClient } from './upload-relay/client.js';\nimport { encodeQuilt, encodeQuiltPatchId, parseWalrusId } from './utils/quilts.js';\nimport { BlobReader } from './files/readers/blob.js';\nimport { WalrusBlob } from './files/blob.js';\nimport { WalrusFile } from './files/file.js';\nimport { QuiltFileReader } from './files/readers/quilt-file.js';\nimport { QuiltReader } from './files/readers/quilt.js';\nimport { retry } from './utils/retry.js';\nimport { createWriteBlobFlow, type WriteBlobFlowContext } from './flows/write-blob.js';\nimport { createWriteFilesFlow } from './flows/write-files.js';\n\nexport function walrus<const Name = 'walrus'>({\n\tpackageConfig,\n\tname = 'walrus' as Name,\n\t...options\n}: WalrusOptions<Name> = {}) {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi) => {\n\t\t\tconst walrusNetwork = client.network;\n\n\t\t\tif (walrusNetwork !== 'mainnet' && walrusNetwork !== 'testnet') {\n\t\t\t\tthrow new WalrusClientError('Walrus client only supports mainnet and testnet');\n\t\t\t}\n\n\t\t\treturn new WalrusClient(\n\t\t\t\tpackageConfig\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpackageConfig,\n\t\t\t\t\t\t\tsuiClient: client,\n\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tnetwork: walrusNetwork as 'mainnet' | 'testnet',\n\t\t\t\t\t\t\tsuiClient: client,\n\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t},\n\t\t\t);\n\t\t},\n\t};\n}\n\nexport class WalrusClient {\n\t#storageNodeClient: StorageNodeClient;\n\t#storageNodeUrlScheme: 'http' | 'https';\n\t#wasmUrl: string | undefined;\n\n\t#packageConfig: WalrusPackageConfig;\n\t#suiClient: ClientWithCoreApi;\n\t#objectLoader: SuiObjectDataLoader;\n\n\t#blobMetadataConcurrencyLimit = 10;\n\t#readCommittee?: CommitteeInfo | Promise<CommitteeInfo> | null;\n\n\t#cache: ClientCache;\n\n\t#uploadRelayConfig: UploadRelayConfig | null = null;\n\t#uploadRelayClient: UploadRelayClient | null = null;\n\n\tconstructor(config: WalrusClientConfig) {\n\t\tif (config.network && !config.packageConfig) {\n\t\t\tconst network = config.network;\n\t\t\tswitch (network) {\n\t\t\t\tcase 'testnet':\n\t\t\t\t\tthis.#packageConfig = TESTNET_WALRUS_PACKAGE_CONFIG;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'mainnet':\n\t\t\t\t\tthis.#packageConfig = MAINNET_WALRUS_PACKAGE_CONFIG;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new WalrusClientError(`Unsupported network: ${network}`);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.#packageConfig = config.packageConfig!;\n\t\t}\n\n\t\tthis.#wasmUrl = config.wasmUrl;\n\t\tthis.#storageNodeUrlScheme = config.storageNodeUrlScheme ?? 'https';\n\t\tthis.#uploadRelayConfig = config.uploadRelay ?? null;\n\t\tif (this.#uploadRelayConfig) {\n\t\t\tthis.#uploadRelayClient = new UploadRelayClient(this.#uploadRelayConfig);\n\t\t}\n\n\t\tthis.#suiClient = config.suiClient;\n\n\t\tthis.#storageNodeClient = new StorageNodeClient(config.storageNodeClientOptions);\n\t\tthis.#objectLoader = new SuiObjectDataLoader(this.#suiClient);\n\t\tthis.#cache = this.#suiClient.cache.scope('@mysten/walrus');\n\t}\n\n\t/** The Move type for a WAL coin */\n\t#walType() {\n\t\treturn this.#cache.read(['walType'], async () => {\n\t\t\tconst stakeWithPool = await this.#suiClient.core.getMoveFunction({\n\t\t\t\tpackageId: await this.#getPackageId(),\n\t\t\t\tmoduleName: 'staking',\n\t\t\t\tname: 'stake_with_pool',\n\t\t\t});\n\n\t\t\tconst toStake = stakeWithPool.function.parameters[1];\n\t\t\tconst toStakeCoin = toStake.body.$kind === 'datatype' ? toStake.body.datatype : null;\n\t\t\tconst toStakeCoinType =\n\t\t\t\ttoStakeCoin?.typeParameters[0]?.$kind === 'datatype' ? toStakeCoin.typeParameters[0] : null;\n\n\t\t\tif (toStakeCoinType?.$kind !== 'datatype') {\n\t\t\t\tthrow new WalrusClientError('WAL type not found');\n\t\t\t}\n\n\t\t\treturn normalizeStructTag(toStakeCoinType.datatype.typeName);\n\t\t});\n\t}\n\n\t#getPackageId() {\n\t\treturn this.#cache.read(['getPackageId'], async () => {\n\t\t\tconst system = await this.#objectLoader.load(this.#packageConfig.systemObjectId);\n\t\t\treturn parseStructTag(system.type!).address;\n\t\t});\n\t}\n\n\t/** The Move type for a Blob object */\n\tgetBlobType() {\n\t\treturn this.#cache.read(['getBlobType'], async () => {\n\t\t\treturn `${await this.#getPackageId()}::blob::Blob`;\n\t\t});\n\t}\n\n\t#getWalrusPackageId() {\n\t\treturn this.#cache.read(['getSystemPackageId'], async () => {\n\t\t\tconst { package_id } = await this.systemObject();\n\t\t\treturn package_id;\n\t\t});\n\t}\n\n\t#wasmBindings() {\n\t\treturn this.#cache.read(['wasmBindings'], async () => {\n\t\t\treturn getWasmBindings(this.#wasmUrl);\n\t\t});\n\t}\n\n\t/** The cached system object for the walrus package */\n\tsystemObject() {\n\t\treturn this.#objectLoader.load(this.#packageConfig.systemObjectId, System);\n\t}\n\n\t/** The cached staking pool object for the walrus package */\n\tstakingObject() {\n\t\treturn this.#objectLoader.load(this.#packageConfig.stakingPoolId, Staking);\n\t}\n\n\t/** The system state for the current version of walrus contract */\n\tasync systemState() {\n\t\tconst systemState = await this.#objectLoader.loadFieldObject(\n\t\t\tthis.#packageConfig.systemObjectId,\n\t\t\t{ type: 'u64', value: (await this.systemObject()).version },\n\t\t\tSystemStateInnerV1,\n\t\t);\n\n\t\treturn systemState;\n\t}\n\n\t/** The staking state for the current version of walrus contract */\n\tasync stakingState() {\n\t\treturn this.#objectLoader.loadFieldObject(\n\t\t\tthis.#packageConfig.stakingPoolId,\n\t\t\t{\n\t\t\t\ttype: 'u64',\n\t\t\t\tvalue: (await this.stakingObject()).version,\n\t\t\t},\n\t\t\tStakingInnerV1,\n\t\t);\n\t}\n\n\t/** Read a blob from the storage nodes */\n\treadBlob = this.#retryOnPossibleEpochChange(this.#internalReadBlob);\n\n\tasync #internalReadBlob({ blobId, signal }: ReadBlobOptions) {\n\t\tconst systemState = await this.systemState();\n\t\tconst numShards = systemState.committee.n_shards;\n\n\t\tconst blobMetadata = await this.getBlobMetadata({ blobId, signal });\n\n\t\tconst slivers = await this.getSlivers({ blobId, signal });\n\n\t\tconst bindings = await this.#wasmBindings();\n\n\t\tconst blobBytes = bindings.decodePrimarySlivers(\n\t\t\tblobId,\n\t\t\tnumShards,\n\t\t\tblobMetadata.metadata.V1.unencoded_length,\n\t\t\tslivers,\n\t\t);\n\n\t\tconst reconstructedBlobMetadata = bindings.computeMetadata(\n\t\t\tsystemState.committee.n_shards,\n\t\t\tblobBytes,\n\t\t);\n\n\t\tif (reconstructedBlobMetadata.blobId !== blobId) {\n\t\t\tthrow new InconsistentBlobError('The specified blob was encoded incorrectly.');\n\t\t}\n\n\t\treturn blobBytes;\n\t}\n\n\tasync computeBlobMetadata({\n\t\tbytes,\n\t\tnumShards,\n\t\tnonce: providedNonce,\n\t}: ComputeBlobMetadataOptions) {\n\t\tlet shardCount: number | undefined;\n\t\tif (typeof numShards === 'number') {\n\t\t\tshardCount = numShards;\n\t\t} else {\n\t\t\tconst systemState = await this.systemState();\n\t\t\tshardCount = systemState.committee.n_shards;\n\t\t}\n\n\t\tconst bindings = await this.#wasmBindings();\n\t\tconst { blobId, rootHash, unencodedLength, encodingType } = bindings.computeMetadata(\n\t\t\tshardCount,\n\t\t\tbytes,\n\t\t);\n\t\tlet sha256Hash: Promise<Uint8Array> | undefined;\n\t\tconst nonce = providedNonce ?? crypto.getRandomValues(new Uint8Array(32));\n\n\t\treturn {\n\t\t\trootHash,\n\t\t\tblobId,\n\t\t\tmetadata: {\n\t\t\t\tencodingType,\n\t\t\t\tunencodedLength,\n\t\t\t},\n\t\t\tnonce,\n\t\t\tblobDigest: () => {\n\t\t\t\tif (!sha256Hash) {\n\t\t\t\t\tsha256Hash = crypto.subtle\n\t\t\t\t\t\t.digest('SHA-256', bytes as BufferSource)\n\t\t\t\t\t\t.then((hash) => new Uint8Array(hash));\n\t\t\t\t}\n\n\t\t\t\treturn sha256Hash;\n\t\t\t},\n\t\t};\n\t}\n\n\tasync getBlobMetadata({ blobId, signal }: GetBlobMetadataOptions) {\n\t\tconst committee = await this.#getReadCommittee({ blobId, signal });\n\t\tconst randomizedNodes = shuffle(committee.nodes);\n\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\n\t\tlet numNotFoundWeight = 0;\n\t\tlet numBlockedWeight = 0;\n\t\tlet totalErrorCount = 0;\n\t\tconst controller = new AbortController();\n\n\t\tconst metadataExecutors = randomizedNodes.map((node) => async () => {\n\t\t\ttry {\n\t\t\t\treturn await this.#storageNodeClient.getBlobMetadata(\n\t\t\t\t\t{ blobId },\n\t\t\t\t\t{\n\t\t\t\t\t\tnodeUrl: node.networkUrl,\n\t\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof NotFoundError) {\n\t\t\t\t\tnumNotFoundWeight += node.shardIndices.length;\n\t\t\t\t} else if (error instanceof LegallyUnavailableError) {\n\t\t\t\t\tnumBlockedWeight += node.shardIndices.length;\n\t\t\t\t}\n\n\t\t\t\ttotalErrorCount += 1;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\n\t\ttry {\n\t\t\tconst attemptGetMetadata = metadataExecutors.shift()!;\n\t\t\treturn await attemptGetMetadata();\n\t\t} catch {\n\t\t\tconst chunkSize = Math.floor(metadataExecutors.length / this.#blobMetadataConcurrencyLimit);\n\t\t\tconst chunkedExecutors = chunk(metadataExecutors, chunkSize);\n\n\t\t\treturn await new Promise<BlobMetadataWithId>((resolve, reject) => {\n\t\t\t\tchunkedExecutors.forEach(async (executors) => {\n\t\t\t\t\tfor (const executor of executors) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await executor();\n\t\t\t\t\t\t\tcontroller.abort('Blob metadata successfully retrieved.');\n\t\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tif (error instanceof UserAbortError) {\n\t\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t} else if (isQuorum(numBlockedWeight + numNotFoundWeight, numShards)) {\n\t\t\t\t\t\t\t\tconst abortError =\n\t\t\t\t\t\t\t\t\tnumNotFoundWeight > numBlockedWeight\n\t\t\t\t\t\t\t\t\t\t? new BlobNotCertifiedError(`The specified blob ${blobId} is not certified.`)\n\t\t\t\t\t\t\t\t\t\t: new BlobBlockedError(`The specified blob ${blobId} is blocked.`);\n\n\t\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (totalErrorCount === metadataExecutors.length) {\n\t\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\t\tnew NoBlobMetadataReceivedError(\n\t\t\t\t\t\t\t\t\t\t'No valid blob metadata could be retrieved from any storage node.',\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t}\n\n\tgetSecondarySliver = this.#retryOnPossibleEpochChange(this.internalGetSecondarySliver);\n\n\tasync internalGetSecondarySliver({ blobId, index, signal }: GetSecondarySliverOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\t\tconst sliverPairIndex = sliverPairIndexFromSecondarySliverIndex(index, numShards);\n\t\tconst shardIndex = toShardIndex(sliverPairIndex, blobId, numShards);\n\t\tconst node = await this.#getNodeByShardIndex(committee, shardIndex);\n\n\t\tif (!node) {\n\t\t\tthrow new Error(`No node found for shard index ${shardIndex}`);\n\t\t}\n\n\t\tconst sliver = await this.#storageNodeClient.getSliver(\n\t\t\t{ blobId, sliverPairIndex, sliverType: 'secondary' },\n\t\t\t{\n\t\t\t\tnodeUrl: node.networkUrl,\n\t\t\t\tsignal,\n\t\t\t},\n\t\t);\n\n\t\treturn sliver;\n\t}\n\n\tasync getSlivers({ blobId, signal }: GetSliversOptions) {\n\t\tconst committee = await this.#getReadCommittee({ blobId, signal });\n\t\tconst randomizedNodes = weightedShuffle(\n\t\t\tcommittee.nodes.map((node) => ({\n\t\t\t\tvalue: node,\n\t\t\t\tweight: node.shardIndices.length,\n\t\t\t})),\n\t\t);\n\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\t\tconst { primarySymbols: minSymbols } = getSourceSymbols(numShards);\n\n\t\tconst sliverPairIndices = randomizedNodes.flatMap((node) =>\n\t\t\tnode.shardIndices.map((shardIndex) => ({\n\t\t\t\turl: node.networkUrl,\n\t\t\t\tsliverPairIndex: toPairIndex(shardIndex, blobId, numShards),\n\t\t\t})),\n\t\t);\n\n\t\tconst controller = new AbortController();\n\t\tconst chunkedSliverPairIndices = chunk(sliverPairIndices, minSymbols);\n\t\tconst slivers: GetSliverResponse[] = [];\n\t\tconst failedNodes = new Set<string>();\n\t\tlet numNotFoundWeight = 0;\n\t\tlet numBlockedWeight = 0;\n\t\tlet totalErrorCount = 0;\n\n\t\treturn new Promise<GetSliverResponse[]>((resolve, reject) => {\n\t\t\tchunkedSliverPairIndices[0].forEach(async (_, colIndex) => {\n\t\t\t\tfor (let rowIndex = 0; rowIndex < chunkedSliverPairIndices.length; rowIndex += 1) {\n\t\t\t\t\tconst value = chunkedSliverPairIndices.at(rowIndex)?.at(colIndex);\n\t\t\t\t\tif (!value) break;\n\n\t\t\t\t\tconst { url, sliverPairIndex } = value;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (failedNodes.has(url)) {\n\t\t\t\t\t\t\tthrow new Error(`Skipping node at ${url} due to previous failure.`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sliver = await this.#storageNodeClient.getSliver(\n\t\t\t\t\t\t\t{ blobId, sliverPairIndex, sliverType: 'primary' },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnodeUrl: url,\n\t\t\t\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (slivers.length === minSymbols) {\n\t\t\t\t\t\t\tcontroller.abort('Enough slivers successfully retrieved.');\n\t\t\t\t\t\t\tresolve(slivers);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tslivers.push(sliver);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof NotFoundError) {\n\t\t\t\t\t\t\tnumNotFoundWeight += 1;\n\t\t\t\t\t\t} else if (error instanceof LegallyUnavailableError) {\n\t\t\t\t\t\t\tnumBlockedWeight += 1;\n\t\t\t\t\t\t} else if (error instanceof UserAbortError) {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isQuorum(numBlockedWeight + numNotFoundWeight, numShards)) {\n\t\t\t\t\t\t\tconst abortError =\n\t\t\t\t\t\t\t\tnumNotFoundWeight > numBlockedWeight\n\t\t\t\t\t\t\t\t\t? new BlobNotCertifiedError(`The specified blob ${blobId} is not certified.`)\n\t\t\t\t\t\t\t\t\t: new BlobBlockedError(`The specified blob ${blobId} is blocked.`);\n\n\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfailedNodes.add(url);\n\t\t\t\t\t\ttotalErrorCount += 1;\n\n\t\t\t\t\t\tconst remainingTasks = sliverPairIndices.length - (slivers.length + totalErrorCount);\n\t\t\t\t\t\tconst tooManyFailures = slivers.length + remainingTasks < minSymbols;\n\n\t\t\t\t\t\tif (tooManyFailures) {\n\t\t\t\t\t\t\tconst abortError = new NotEnoughSliversReceivedError(\n\t\t\t\t\t\t\t\t`Unable to retrieve enough slivers to decode blob ${blobId}.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Gets the blob status from multiple storage nodes and returns the latest status that can be verified.\n\t */\n\tasync getVerifiedBlobStatus({ blobId, signal }: GetVerifiedBlobStatusOptions) {\n\t\t// Read from the latest committee because, during epoch change, it is the committee\n\t\t// that will have the most up-to-date information on old and newly certified blobs:\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst stakingState = await this.stakingState();\n\t\tconst numShards = stakingState.n_shards;\n\t\tconst controller = new AbortController();\n\n\t\tconst statuses = await new Promise<{ status: BlobStatus; weight: number }[]>(\n\t\t\t(resolve, reject) => {\n\t\t\t\tconst results: { status: BlobStatus; weight: number }[] = [];\n\t\t\t\tlet successWeight = 0;\n\t\t\t\tlet numNotFoundWeight = 0;\n\t\t\t\tlet settledCount = 0;\n\n\t\t\t\tcommittee.nodes.forEach(async (node) => {\n\t\t\t\t\tconst weight = node.shardIndices.length;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst status = await this.#storageNodeClient.getBlobStatus(\n\t\t\t\t\t\t\t{ blobId },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnodeUrl: node.networkUrl,\n\t\t\t\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (isQuorum(successWeight, numShards)) {\n\t\t\t\t\t\t\tcontroller.abort('Quorum of blob statuses retrieved successfully.');\n\t\t\t\t\t\t\tresolve(results);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsuccessWeight += weight;\n\t\t\t\t\t\t\tresults.push({ status, weight });\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof NotFoundError) {\n\t\t\t\t\t\t\tnumNotFoundWeight += weight;\n\t\t\t\t\t\t} else if (error instanceof UserAbortError) {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isQuorum(numNotFoundWeight, numShards)) {\n\t\t\t\t\t\t\tconst abortError = new BlobNotCertifiedError('The blob does not exist.');\n\t\t\t\t\t\t\tcontroller.abort(abortError);\n\t\t\t\t\t\t\treject(abortError);\n\t\t\t\t\t\t}\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tsettledCount += 1;\n\t\t\t\t\t\tif (settledCount === committee.nodes.length) {\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew NoBlobStatusReceivedError(\n\t\t\t\t\t\t\t\t\t'Not enough statuses were retrieved to achieve quorum.',\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\n\t\tconst aggregatedStatuses = statuses.reduce((accumulator, value) => {\n\t\t\tconst { status, weight } = value;\n\t\t\tconst key = JSON.stringify(status);\n\n\t\t\tconst existing = accumulator.get(key);\n\t\t\tif (existing) {\n\t\t\t\texisting.totalWeight += weight;\n\t\t\t} else {\n\t\t\t\taccumulator.set(key, { status, totalWeight: weight });\n\t\t\t}\n\n\t\t\treturn accumulator;\n\t\t}, new Map<string, { status: BlobStatus; totalWeight: number }>());\n\n\t\tconst uniqueStatuses = [...aggregatedStatuses.values()];\n\t\tconst sortedStatuses = uniqueStatuses.toSorted(\n\t\t\t(a, b) => statusLifecycleRank[b.status.type] - statusLifecycleRank[a.status.type],\n\t\t);\n\n\t\tfor (const value of sortedStatuses) {\n\t\t\t// TODO: We can check the chain via the `event` field as a fallback here.\n\t\t\tif (isAboveValidity(value.totalWeight, numShards)) {\n\t\t\t\treturn value.status;\n\t\t\t}\n\t\t}\n\n\t\tthrow new NoVerifiedBlobStatusReceivedError(\n\t\t\t`The blob status could not be verified for blob ${blobId},`,\n\t\t);\n\t}\n\n\tasync #getCertificationEpoch({ blobId, signal }: GetCertificationEpochOptions) {\n\t\tconst stakingState = await this.stakingState();\n\t\tconst currentEpoch = stakingState.epoch;\n\n\t\tif (stakingState.epoch_state.$kind === 'EpochChangeSync') {\n\t\t\tconst status = await this.getVerifiedBlobStatus({ blobId, signal });\n\t\t\tif (status.type === 'nonexistent' || status.type === 'invalid') {\n\t\t\t\tthrow new BlobNotCertifiedError(`The specified blob ${blobId} is ${status.type}.`);\n\t\t\t}\n\n\t\t\tif (typeof status.initialCertifiedEpoch !== 'number') {\n\t\t\t\tthrow new BlobNotCertifiedError(`The specified blob ${blobId} is not certified.`);\n\t\t\t}\n\n\t\t\tif (status.initialCertifiedEpoch > currentEpoch) {\n\t\t\t\tthrow new BehindCurrentEpochError(\n\t\t\t\t\t`The client is at epoch ${currentEpoch} while the specified blob was certified at epoch ${status.initialCertifiedEpoch}.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn status.initialCertifiedEpoch;\n\t\t}\n\n\t\treturn currentEpoch;\n\t}\n\n\t/**\n\t * Retrieves the node committee responsible for serving reads.\n\t *\n\t * During an epoch change, reads should be served by the previous committee if the blob was\n\t * certified in an earlier epoch. This ensures that we read from nodes with the most accurate\n\t * information as nodes from the current committee might still be receiving transferred shards\n\t * from the previous committee.\n\t */\n\tasync #getReadCommittee(options: ReadBlobOptions) {\n\t\tif (!this.#readCommittee) {\n\t\t\tthis.#readCommittee = this.#forceGetReadCommittee(options);\n\t\t}\n\t\treturn this.#readCommittee;\n\t}\n\n\tasync #forceGetReadCommittee({ blobId, signal }: ReadBlobOptions) {\n\t\tconst stakingState = await this.stakingState();\n\t\tconst isTransitioning = stakingState.epoch_state.$kind === 'EpochChangeSync';\n\t\tconst certificationEpoch = await this.#getCertificationEpoch({ blobId, signal });\n\n\t\tif (isTransitioning && certificationEpoch < stakingState.epoch) {\n\t\t\treturn await this.#getCommittee(stakingState.previous_committee);\n\t\t}\n\t\treturn await this.#getActiveCommittee();\n\t}\n\n\t/**\n\t * Calculate the cost of storing a blob for a given a size and number of epochs.\n\t */\n\tasync storageCost(size: number, epochs: number) {\n\t\tconst systemState = await this.systemState();\n\t\tconst encodedSize = encodedBlobLength(size, systemState.committee.n_shards);\n\t\treturn this.#storageCostFromEncodedSize(encodedSize, epochs);\n\t}\n\n\tasync #storageCostFromEncodedSize(encodedSize: number, epochs: number) {\n\t\tconst systemState = await this.systemState();\n\t\tconst storageUnits = storageUnitsFromSize(encodedSize);\n\t\tconst storageCost =\n\t\t\tBigInt(storageUnits) * BigInt(systemState.storage_price_per_unit_size) * BigInt(epochs);\n\n\t\tconst writeCost = BigInt(storageUnits) * BigInt(systemState.write_price_per_unit_size);\n\n\t\treturn { storageCost, writeCost, totalCost: storageCost + writeCost };\n\t}\n\n\t/**\n\t * A utility for creating a storage object in a transaction.\n\t *\n\t * @example\n\t * ```ts\n\t * tx.transferObjects([client.createStorage({ size: 1000, epochs: 3 })], owner);\n\t * ```\n\t */\n\tcreateStorage({ size, epochs, walCoin }: StorageWithSizeOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst systemObject = await this.systemObject();\n\t\t\tconst systemState = await this.systemState();\n\t\t\tconst encodedSize = encodedBlobLength(size, systemState.committee.n_shards);\n\t\t\tconst [{ storageCost }, walrusPackageId] = await Promise.all([\n\t\t\t\tthis.storageCost(size, epochs),\n\t\t\t\tthis.#getWalrusPackageId(),\n\t\t\t]);\n\n\t\t\treturn tx.add(\n\t\t\t\tthis.#withWal(storageCost, walCoin ?? null, (coin, tx) => {\n\t\t\t\t\treturn tx.add(\n\t\t\t\t\t\treserveSpace({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: systemObject.id,\n\t\t\t\t\t\t\t\tstorageAmount: encodedSize,\n\t\t\t\t\t\t\t\tepochsAhead: epochs,\n\t\t\t\t\t\t\t\tpayment: coin,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t#withWal<T extends TransactionResult | void>(\n\t\tamount: bigint,\n\t\tsource: TransactionObjectArgument | null,\n\t\tfn: (coin: TransactionObjectArgument, tx: Transaction) => T | Promise<T>,\n\t) {\n\t\treturn async (tx: Transaction): Promise<T> => {\n\t\t\tconst walType = await this.#walType();\n\t\t\tconst coin = source\n\t\t\t\t? tx.splitCoins(source, [amount])[0]\n\t\t\t\t: tx.add(\n\t\t\t\t\t\tcoinWithBalance({\n\t\t\t\t\t\t\tbalance: amount,\n\t\t\t\t\t\t\ttype: walType,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\tconst result = await fn(coin, tx);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: '0x2::coin::destroy_zero',\n\t\t\t\ttypeArguments: [walType],\n\t\t\t\targuments: [coin],\n\t\t\t});\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that creates a storage object\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.createStorageTransaction({ size: 1000, epochs: 3, owner: signer.toSuiAddress() });\n\t * ```\n\t */\n\tcreateStorageTransaction({\n\t\ttransaction = new Transaction(),\n\t\tsize,\n\t\tepochs,\n\t\towner,\n\t}: StorageWithSizeOptions & {\n\t\ttransaction?: Transaction;\n\t\t/** Address the storage resource should be transferred to */\n\t\towner: string;\n\t}) {\n\t\ttransaction.transferObjects([this.createStorage({ size, epochs })], owner);\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that creates a storage object\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest, storage } = await client.executeCreateStorageTransaction({ size: 1000, epochs: 3, signer });\n\t * ```\n\t */\n\tasync executeCreateStorageTransaction({\n\t\tsigner,\n\t\t...options\n\t}: StorageWithSizeOptions & { transaction?: Transaction; signer: Signer }) {\n\t\tconst transaction = this.createStorageTransaction({\n\t\t\t...options,\n\t\t\towner: options.transaction?.getData().sender ?? signer.toSuiAddress(),\n\t\t});\n\t\tconst blobType = await this.getBlobType();\n\n\t\tconst { digest, effects } = await this.#executeTransaction(\n\t\t\ttransaction,\n\t\t\tsigner,\n\t\t\t'create storage',\n\t\t);\n\n\t\tconst createdObjectIds = effects?.changedObjects\n\t\t\t.filter((object) => object.idOperation === 'Created')\n\t\t\t.map((object) => object.objectId);\n\n\t\tconst createdObjects = await this.#suiClient.core.getObjects({\n\t\t\tobjectIds: createdObjectIds,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tconst suiBlobObject = createdObjects.objects.find(\n\t\t\t(object) => !(object instanceof Error) && object.type === blobType,\n\t\t);\n\n\t\tif (suiBlobObject instanceof Error || !suiBlobObject) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Storage object not found in transaction effects for transaction (${digest})`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tdigest,\n\t\t\tstorage: Storage.parse(suiBlobObject.content),\n\t\t};\n\t}\n\n\t/**\n\t * Register a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * tx.transferObjects([client.registerBlob({ size: 1000, epochs: 3, blobId, rootHash, deletable: true })], owner);\n\t * ```\n\t */\n\tregisterBlob({\n\t\tsize,\n\t\tepochs,\n\t\tblobId,\n\t\trootHash,\n\t\tdeletable,\n\t\twalCoin,\n\t\tattributes,\n\t}: RegisterBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst { writeCost } = await this.storageCost(size, epochs);\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\treturn tx.add(\n\t\t\t\tthis.#withWal(writeCost, walCoin ?? null, async (writeCoin, tx) => {\n\t\t\t\t\tconst blob = tx.add(\n\t\t\t\t\t\tregisterBlob({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: tx.object(this.#packageConfig.systemObjectId),\n\t\t\t\t\t\t\t\tstorage: this.createStorage({ size, epochs, walCoin }),\n\t\t\t\t\t\t\t\tblobId: blobIdToInt(blobId),\n\t\t\t\t\t\t\t\trootHash: BigInt(bcs.u256().parse(rootHash)),\n\t\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\t\tencodingType: 1,\n\t\t\t\t\t\t\t\tdeletable,\n\t\t\t\t\t\t\t\twritePayment: writeCoin,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (attributes) {\n\t\t\t\t\t\ttx.add(\n\t\t\t\t\t\t\tthis.#writeBlobAttributesForRef({\n\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\texistingAttributes: null,\n\t\t\t\t\t\t\t\tblob,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn blob;\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\taddAuthPayload({\n\t\tsize,\n\t\tblobDigest,\n\t\tnonce,\n\t}: {\n\t\tsize: number;\n\t\tblobDigest: Uint8Array | (() => Promise<Uint8Array>);\n\t\tnonce: Uint8Array;\n\t}) {\n\t\treturn async (transaction: Transaction) => {\n\t\t\tconst nonceDigest = await crypto.subtle.digest('SHA-256', nonce as BufferSource);\n\t\t\tconst lengthBytes = bcs.u64().serialize(size).toBytes();\n\t\t\tconst digest = typeof blobDigest === 'function' ? await blobDigest() : blobDigest;\n\t\t\tconst authPayload = new Uint8Array(\n\t\t\t\tnonceDigest.byteLength + digest.byteLength + lengthBytes.byteLength,\n\t\t\t);\n\n\t\t\tauthPayload.set(digest, 0);\n\t\t\tauthPayload.set(new Uint8Array(nonceDigest), digest.byteLength);\n\t\t\tauthPayload.set(lengthBytes, nonceDigest.byteLength + digest.byteLength);\n\t\t\ttransaction.pure(authPayload);\n\t\t};\n\t}\n\n\t#loadTipConfig() {\n\t\treturn this.#cache.read(['upload-relay-tip-config'], async () => {\n\t\t\tif (!this.#uploadRelayConfig?.sendTip || !this.#uploadRelayClient) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif ('kind' in this.#uploadRelayConfig.sendTip) {\n\t\t\t\treturn this.#uploadRelayConfig.sendTip;\n\t\t\t}\n\n\t\t\tconst tipConfig = await this.#uploadRelayClient.tipConfig();\n\n\t\t\tif (!tipConfig) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...tipConfig,\n\t\t\t\tmax: this.#uploadRelayConfig.sendTip.max,\n\t\t\t};\n\t\t});\n\t}\n\n\tasync calculateUploadRelayTip(options: { size: number }) {\n\t\tconst systemState = await this.systemState();\n\t\tconst encodedSize = encodedBlobLength(options.size, systemState.committee.n_shards);\n\t\tconst tipConfig = await this.#loadTipConfig();\n\n\t\tif (!tipConfig) {\n\t\t\treturn 0n;\n\t\t}\n\n\t\tconst { max, kind } = tipConfig;\n\n\t\tconst amount =\n\t\t\t'const' in kind\n\t\t\t\t? kind.const\n\t\t\t\t: BigInt(kind.linear.base) +\n\t\t\t\t\tBigInt(kind.linear.perEncodedKib) * ((BigInt(encodedSize) + 1023n) / 1024n); // Compute the ceiling of the division.\n\n\t\tif (max != null && amount > max) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Tip amount (${amount}) exceeds the maximum allowed tip (${max})`,\n\t\t\t);\n\t\t}\n\n\t\treturn amount;\n\t}\n\n\tsendUploadRelayTip({\n\t\tsize,\n\t\tblobDigest,\n\t\tnonce,\n\t}: {\n\t\tsize: number;\n\t\tblobDigest: Uint8Array | (() => Promise<Uint8Array>);\n\t\tnonce: Uint8Array;\n\t}) {\n\t\treturn async (transaction: Transaction) => {\n\t\t\tconst tipConfig = await this.#loadTipConfig();\n\n\t\t\tif (tipConfig) {\n\t\t\t\ttransaction.add(this.addAuthPayload({ size, blobDigest, nonce }));\n\t\t\t\tconst amount = await this.calculateUploadRelayTip({ size });\n\t\t\t\tconst { address } = tipConfig;\n\t\t\t\ttransaction.transferObjects(\n\t\t\t\t\t[\n\t\t\t\t\t\tcoinWithBalance({\n\t\t\t\t\t\t\tbalance: amount,\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t\taddress,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that registers a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.registerBlobTransaction({ size: 1000, epochs: 3, blobId, rootHash, deletable: true });\n\t * ```\n\t */\n\tregisterBlobTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: RegisterBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\t/** Address the blob should be transferred to */\n\t\towner: string;\n\t}) {\n\t\tconst registration = transaction.add(this.registerBlob(options));\n\n\t\ttransaction.transferObjects([registration], options.owner);\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that registers a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest, blob } = await client.executeRegisterBlobTransaction({ size: 1000, epochs: 3, signer });\n\t * ```\n\t */\n\tasync executeRegisterBlobTransaction({\n\t\tsigner,\n\t\t...options\n\t}: RegisterBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\tsigner: Signer;\n\t\t/** Address the blob should be transferred to */\n\t\towner?: string;\n\t}): Promise<{\n\t\tblob: (typeof Blob)['$inferType'];\n\t\tdigest: string;\n\t}> {\n\t\tconst transaction = this.registerBlobTransaction({\n\t\t\t...options,\n\t\t\towner: options.owner ?? options.transaction?.getData().sender ?? signer.toSuiAddress(),\n\t\t});\n\t\tconst blobType = await this.getBlobType();\n\t\tconst { digest, effects } = await this.#executeTransaction(\n\t\t\ttransaction,\n\t\t\tsigner,\n\t\t\t'register blob',\n\t\t);\n\n\t\tconst createdObjectIds = effects?.changedObjects\n\t\t\t.filter((object) => object.idOperation === 'Created')\n\t\t\t.map((object) => object.objectId);\n\n\t\tconst createdObjects = await this.#suiClient.core.getObjects({\n\t\t\tobjectIds: createdObjectIds,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tconst suiBlobObject = createdObjects.objects.find(\n\t\t\t(object) => !(object instanceof Error) && object.type === blobType,\n\t\t);\n\n\t\tif (suiBlobObject instanceof Error || !suiBlobObject) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Blob object not found in transaction effects for transaction (${digest})`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tdigest,\n\t\t\tblob: Blob.parse(suiBlobObject.content),\n\t\t};\n\t}\n\n\tasync #getCreatedBlob(digest: string) {\n\t\tconst blobType = await this.getBlobType();\n\t\tconst result = await this.#suiClient.core.waitForTransaction({\n\t\t\tdigest,\n\t\t\tinclude: { effects: true },\n\t\t});\n\n\t\tconst tx = result.Transaction ?? result.FailedTransaction;\n\t\tconst createdObjectIds = tx.effects?.changedObjects\n\t\t\t.filter((object: { idOperation: string }) => object.idOperation === 'Created')\n\t\t\t.map((object: { objectId: string }) => object.objectId);\n\n\t\tconst createdObjects = await this.#suiClient.core.getObjects({\n\t\t\tobjectIds: createdObjectIds,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tconst suiBlobObject = createdObjects.objects.find(\n\t\t\t(object) => !(object instanceof Error) && object.type === blobType,\n\t\t);\n\n\t\tif (suiBlobObject instanceof Error || !suiBlobObject) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Blob object not found in transaction effects for transaction (${digest})`,\n\t\t\t);\n\t\t}\n\n\t\treturn Blob.parse(suiBlobObject.content);\n\t}\n\n\tasync certificateFromConfirmations({\n\t\tconfirmations,\n\t\tblobId,\n\t\tdeletable,\n\t\tblobObjectId,\n\t}: Extract<\n\t\tCertifyBlobOptions,\n\t\t{ confirmations: unknown[] }\n\t>): Promise<ProtocolMessageCertificate> {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tif (confirmations.length !== systemState.committee.members.length) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t'Invalid number of confirmations. Confirmations array must contain an entry for each node',\n\t\t\t);\n\t\t}\n\n\t\tconst confirmationMessage = StorageConfirmation.serialize({\n\t\t\tintent: IntentType.BLOB_CERT_MSG,\n\t\t\tepoch: systemState.committee.epoch,\n\t\t\tmessageContents: {\n\t\t\t\tblobId,\n\t\t\t\tblobType: deletable\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tDeletable: {\n\t\t\t\t\t\t\t\tobjectId: blobObjectId,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tPermanent: null,\n\t\t\t\t\t\t},\n\t\t\t},\n\t\t}).toBase64();\n\n\t\tconst bindings = await this.#wasmBindings();\n\t\tconst verifySignature = bindings.getVerifySignature();\n\n\t\tconst filteredConfirmations = confirmations\n\t\t\t.map((confirmation, index) => {\n\t\t\t\tconst isValid =\n\t\t\t\t\tconfirmation?.serializedMessage === confirmationMessage &&\n\t\t\t\t\tverifySignature(\n\t\t\t\t\t\tconfirmation,\n\t\t\t\t\t\tnew Uint8Array(committee.nodes[index].info.public_key.bytes),\n\t\t\t\t\t);\n\n\t\t\t\treturn isValid\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t...confirmation,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null;\n\t\t\t})\n\t\t\t.filter((confirmation) => confirmation !== null);\n\n\t\tif (!isQuorum(filteredConfirmations.length, systemState.committee.members.length)) {\n\t\t\tthrow new NotEnoughBlobConfirmationsError(\n\t\t\t\t`Too many invalid confirmations received for blob (${filteredConfirmations.length} of ${systemState.committee.members.length})`,\n\t\t\t);\n\t\t}\n\n\t\treturn bindings.combineSignatures(\n\t\t\tfilteredConfirmations,\n\t\t\tfilteredConfirmations.map(({ index }) => index),\n\t\t);\n\t}\n\n\t/**\n\t * Certify a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * tx.add(client.certifyBlob({ blobId, blobObjectId, confirmations }));\n\t * ```\n\t */\n\tcertifyBlob({ blobId, blobObjectId, confirmations, certificate, deletable }: CertifyBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst systemState = await this.systemState();\n\t\t\tconst combinedSignature =\n\t\t\t\t(typeof certificate === 'string' ? parseCertificateFromBase64(certificate) : certificate) ??\n\t\t\t\t(await this.certificateFromConfirmations({\n\t\t\t\t\tconfirmations: confirmations!,\n\t\t\t\t\tblobId,\n\t\t\t\t\tdeletable,\n\t\t\t\t\tblobObjectId,\n\t\t\t\t}));\n\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\ttx.add(\n\t\t\t\tcertifyBlob({\n\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: this.#packageConfig.systemObjectId,\n\t\t\t\t\t\tblob: blobObjectId,\n\t\t\t\t\t\tsignature: tx.pure.vector('u8', combinedSignature.signature),\n\t\t\t\t\t\tsignersBitmap: tx.pure.vector(\n\t\t\t\t\t\t\t'u8',\n\t\t\t\t\t\t\tsignersToBitmap(combinedSignature.signers, systemState.committee.members.length),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmessage: tx.pure.vector('u8', combinedSignature.serializedMessage),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that certifies a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.certifyBlobTransaction({ blobId, blobObjectId, confirmations });\n\t * ```\n\t */\n\tcertifyBlobTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: CertifyBlobOptions & {\n\t\ttransaction?: Transaction;\n\t}) {\n\t\ttransaction.add(this.certifyBlob(options));\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that certifies a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeCertifyBlobTransaction({ blobId, blobObjectId, confirmations, signer });\n\t * ```\n\t */\n\tasync executeCertifyBlobTransaction({\n\t\tsigner,\n\t\t...options\n\t}: CertifyBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\tsigner: Signer;\n\t}) {\n\t\tconst transaction = this.certifyBlobTransaction(options);\n\n\t\tconst { digest } = await this.#executeTransaction(transaction, signer, 'certify blob');\n\n\t\treturn { digest };\n\t}\n\n\t/**\n\t * Delete a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const storage = await client.deleteBlob({ blobObjectId });\n\t * tx.transferObjects([storage], owner);\n\t * ```\n\t */\n\tdeleteBlob({ blobObjectId }: DeleteBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\t\t\tconst storage = tx.add(\n\t\t\t\tdeleteBlob({\n\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: this.#packageConfig.systemObjectId,\n\t\t\t\t\t\tblob: blobObjectId,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\treturn storage;\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that deletes a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.deleteBlobTransaction({ blobObjectId, owner });\n\t * ```\n\t */\n\tdeleteBlobTransaction({\n\t\towner,\n\t\tblobObjectId,\n\t\ttransaction = new Transaction(),\n\t}: DeleteBlobOptions & {\n\t\ttransaction?: Transaction;\n\t\t/** Address the storage resource should be returned to */\n\t\towner: string;\n\t}) {\n\t\tconst storage = transaction.add(this.deleteBlob({ blobObjectId }));\n\t\ttransaction.transferObjects([storage], owner);\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that deletes a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeDeleteBlobTransaction({ blobObjectId, signer });\n\t * ```\n\t */\n\tasync executeDeleteBlobTransaction({\n\t\tsigner,\n\t\ttransaction = new Transaction(),\n\t\tblobObjectId,\n\t}: DeleteBlobOptions & { signer: Signer; transaction?: Transaction }) {\n\t\tconst { digest } = await this.#executeTransaction(\n\t\t\tthis.deleteBlobTransaction({\n\t\t\t\tblobObjectId,\n\t\t\t\ttransaction,\n\t\t\t\towner: transaction.getData().sender ?? signer.toSuiAddress(),\n\t\t\t}),\n\t\t\tsigner,\n\t\t\t'delete blob',\n\t\t);\n\n\t\treturn { digest };\n\t}\n\n\t/**\n\t * Extend a blob in a transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.extendBlobTransaction({ blobObjectId, epochs });\n\t * ```\n\t */\n\textendBlob({ blobObjectId, epochs, endEpoch, walCoin }: ExtendBlobOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst blob = await this.#objectLoader.load(blobObjectId, Blob);\n\t\t\tconst numEpochs = typeof epochs === 'number' ? epochs : endEpoch - blob.storage.end_epoch;\n\n\t\t\tif (numEpochs <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { storageCost } = await this.#storageCostFromEncodedSize(\n\t\t\t\tNumber(blob.storage.storage_size),\n\t\t\t\tnumEpochs,\n\t\t\t);\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\treturn tx.add(\n\t\t\t\tthis.#withWal(storageCost, walCoin ?? null, async (coin, tx) => {\n\t\t\t\t\ttx.add(\n\t\t\t\t\t\textendBlob({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: this.#packageConfig.systemObjectId,\n\t\t\t\t\t\t\t\tblob: blobObjectId,\n\t\t\t\t\t\t\t\textendedEpochs: numEpochs,\n\t\t\t\t\t\t\t\tpayment: coin,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that extends a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.extendBlobTransaction({ blobObjectId, epochs });\n\t * ```\n\t */\n\tasync extendBlobTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: ExtendBlobOptions & { transaction?: Transaction }) {\n\t\ttransaction.add(this.extendBlob(options));\n\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that extends a blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeExtendBlobTransaction({ blobObjectId, signer });\n\t * ```\n\t */\n\tasync executeExtendBlobTransaction({\n\t\tsigner,\n\t\t...options\n\t}: ExtendBlobOptions & { signer: Signer; transaction?: Transaction }) {\n\t\tconst { digest } = await this.#executeTransaction(\n\t\t\tawait this.extendBlobTransaction(options),\n\t\t\tsigner,\n\t\t\t'extend blob',\n\t\t);\n\n\t\treturn { digest };\n\t}\n\n\tasync readBlobAttributes({\n\t\tblobObjectId,\n\t}: {\n\t\tblobObjectId: string;\n\t}): Promise<Record<string, string> | null> {\n\t\tconst response = await this.#suiClient.core.getDynamicField({\n\t\t\tparentId: blobObjectId,\n\t\t\tname: {\n\t\t\t\ttype: 'vector<u8>',\n\t\t\t\tbcs: bcs.string().serialize('metadata').toBytes(),\n\t\t\t},\n\t\t});\n\n\t\tconst parsedMetadata = metadata.Metadata.parse(response.dynamicField.value.bcs);\n\n\t\treturn Object.fromEntries(\n\t\t\tparsedMetadata.metadata.contents.map(({ key, value }) => [key, value]),\n\t\t);\n\t}\n\n\t#writeBlobAttributesForRef({\n\t\tattributes,\n\t\texistingAttributes,\n\t\tblob,\n\t}: {\n\t\tattributes: Record<string, string | null>;\n\t\texistingAttributes: Record<string, string> | null;\n\t\tblob: TransactionObjectArgument;\n\t}) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst walrusPackageId = await this.#getWalrusPackageId();\n\n\t\t\tif (!existingAttributes) {\n\t\t\t\ttx.add(\n\t\t\t\t\taddMetadata({\n\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\tself: blob,\n\t\t\t\t\t\t\tmetadata: metadata._new({\n\t\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tObject.keys(attributes).forEach((key) => {\n\t\t\t\tconst value = attributes[key];\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\tif (existingAttributes && key in existingAttributes) {\n\t\t\t\t\t\ttx.add(\n\t\t\t\t\t\t\tremoveMetadataPair({\n\t\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\t\tself: blob,\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttx.add(\n\t\t\t\t\t\tinsertOrUpdateMetadataPair({\n\t\t\t\t\t\t\tpackage: walrusPackageId,\n\t\t\t\t\t\t\targuments: {\n\t\t\t\t\t\t\t\tself: blob,\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t}\n\n\t/**\n\t * Write attributes to a blob\n\t *\n\t * If attributes already exists, their previous values will be overwritten\n\t * If an attribute is set to `null`, it will be removed from the blob\n\t *\n\t * @example\n\t * ```ts\n\t * tx.add(client.writeBlobAttributes({ blobObjectId, attributes: { key: 'value', keyToRemove: null } }));\n\t * ```\n\t */\n\twriteBlobAttributes({ blobObject, blobObjectId, attributes }: WriteBlobAttributesOptions) {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst existingAttributes = blobObjectId\n\t\t\t\t? await this.readBlobAttributes({ blobObjectId })\n\t\t\t\t: null;\n\t\t\tconst blob = blobObject ?? tx.object(blobObjectId);\n\n\t\t\ttx.add(\n\t\t\t\tthis.#writeBlobAttributesForRef({\n\t\t\t\t\tattributes,\n\t\t\t\t\texistingAttributes,\n\t\t\t\t\tblob,\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Create a transaction that writes attributes to a blob\n\t *\n\t * If attributes already exists, their previous values will be overwritten\n\t * If an attribute is set to `null`, it will be removed from the blob\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.writeBlobAttributesTransaction({ blobObjectId, attributes: { key: 'value', keyToRemove: null } });\n\t * ```\n\t */\n\tasync writeBlobAttributesTransaction({\n\t\ttransaction = new Transaction(),\n\t\t...options\n\t}: WriteBlobAttributesOptions & { transaction?: Transaction }) {\n\t\ttransaction.add(await this.writeBlobAttributes(options));\n\t\treturn transaction;\n\t}\n\n\t/**\n\t * Execute a transaction that writes attributes to a blob\n\t *\n\t * If attributes already exists, their previous values will be overwritten\n\t * If an attribute is set to `null`, it will be removed from the blob\n\t *\n\t * @example\n\t * ```ts\n\t * const { digest } = await client.executeWriteBlobAttributesTransaction({ blobObjectId, signer });\n\t * ```\n\t */\n\tasync executeWriteBlobAttributesTransaction({\n\t\tsigner,\n\t\t...options\n\t}: WriteBlobAttributesOptions & { signer: Signer; transaction?: Transaction }) {\n\t\tconst { digest } = await this.#executeTransaction(\n\t\t\tawait this.writeBlobAttributesTransaction(options),\n\t\t\tsigner,\n\t\t\t'write blob attributes',\n\t\t);\n\t\treturn { digest };\n\t}\n\n\t/**\n\t * Write a sliver to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const res = await client.writeSliver({ blobId, sliverPairIndex, sliverType, sliver });\n\t * ```\n\t */\n\tasync writeSliver({ blobId, sliverPairIndex, sliverType, sliver, signal }: WriteSliverOptions) {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tconst shardIndex = toShardIndex(sliverPairIndex, blobId, systemState.committee.n_shards);\n\t\tconst node = await this.#getNodeByShardIndex(committee, shardIndex);\n\n\t\treturn this.#storageNodeClient.storeSliver(\n\t\t\t{ blobId, sliverPairIndex, sliverType, sliver },\n\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t);\n\t}\n\n\t/**\n\t * Write metadata to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const res = await client.writeMetadataToNode({ nodeIndex, blobId, metadata });\n\t * ```\n\t */\n\tasync writeMetadataToNode({ nodeIndex, blobId, metadata, signal }: WriteMetadataOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\n\t\treturn retry(\n\t\t\t() =>\n\t\t\t\tthis.#storageNodeClient.storeBlobMetadata(\n\t\t\t\t\t{ blobId, metadata },\n\t\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t\t),\n\t\t\t{\n\t\t\t\tcount: 3,\n\t\t\t\tdelay: 1000,\n\t\t\t\tcondition: (error) => error instanceof BlobNotRegisteredError,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Get a storage confirmation from a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const confirmation = await client.getStorageConfirmationFromNode({ nodeIndex, blobId, deletable, objectId });\n\t * ```\n\t */\n\tasync getStorageConfirmationFromNode({\n\t\tnodeIndex,\n\t\tblobId,\n\t\tdeletable,\n\t\tobjectId,\n\t\tsignal,\n\t}: GetStorageConfirmationOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\n\t\tconst result = deletable\n\t\t\t? await this.#storageNodeClient.getDeletableBlobConfirmation(\n\t\t\t\t\t{ blobId, objectId },\n\t\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t\t)\n\t\t\t: await this.#storageNodeClient.getPermanentBlobConfirmation(\n\t\t\t\t\t{ blobId },\n\t\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t\t);\n\n\t\treturn result?.success?.data?.signed ?? null;\n\t}\n\n\t/**\n\t * Get storage confirmations from all active committee nodes for a blob.\n\t *\n\t * @example\n\t * ```ts\n\t * const confirmations = await client.getStorageConfirmations({\n\t * blobId: savedState.blobId,\n\t * deletable: true,\n\t * objectId: savedState.blobObjectId,\n\t * });\n\t * const tx = client.certifyBlobTransaction({ blobId, blobObjectId, confirmations, deletable: true });\n\t * ```\n\t */\n\tasync getStorageConfirmations({\n\t\tblobId,\n\t\tdeletable,\n\t\tobjectId,\n\t\tsignal,\n\t}: {\n\t\tblobId: string;\n\t\tdeletable: boolean;\n\t\tobjectId?: string;\n\t\tsignal?: AbortSignal;\n\t}): Promise<(StorageConfirmationType | null)[]> {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\treturn Promise.all(\n\t\t\tcommittee.nodes.map((_, nodeIndex) =>\n\t\t\t\tthis.getStorageConfirmationFromNode({\n\t\t\t\t\tnodeIndex,\n\t\t\t\t\tblobId,\n\t\t\t\t\t...(deletable\n\t\t\t\t\t\t? { deletable: true as const, objectId: objectId! }\n\t\t\t\t\t\t: { deletable: false as const }),\n\t\t\t\t\tsignal,\n\t\t\t\t}).catch(() => null),\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * Load a parsed Blob object from chain by its Sui object ID.\n\t *\n\t * @example\n\t * ```ts\n\t * const blobObject = await client.getBlobObject('0x...');\n\t * console.log(blobObject.id, blobObject.blob_id);\n\t * ```\n\t */\n\tasync getBlobObject(blobObjectId: string) {\n\t\treturn this.#objectLoader.load(blobObjectId, Blob);\n\t}\n\n\t/**\n\t * Encode a blob into slivers for each node\n\t *\n\t * @example\n\t * ```ts\n\t * const { blobId, metadata, sliversByNode, rootHash } = await client.encodeBlob(blob);\n\t * ```\n\t */\n\tasync encodeBlob(blob: Uint8Array) {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tconst numShards = systemState.committee.n_shards;\n\t\tconst bindings = await this.#wasmBindings();\n\t\tconst { blobId, metadata, primarySlivers, secondarySlivers, rootHash } = bindings.encodeBlob(\n\t\t\tnumShards,\n\t\t\tblob,\n\t\t);\n\n\t\tconst sliversByNodeMap = new Map<number, SliversForNode>();\n\n\t\t// Process each sliver pair (already BCS-encoded)\n\t\tfor (let sliverPairIndex = 0; sliverPairIndex < primarySlivers.length; sliverPairIndex++) {\n\t\t\tconst primarySliver = primarySlivers[sliverPairIndex];\n\t\t\tconst secondarySliver = secondarySlivers[sliverPairIndex];\n\n\t\t\tconst shardIndex = toShardIndex(sliverPairIndex, blobId, numShards);\n\t\t\tconst node = await this.#getNodeByShardIndex(committee, shardIndex);\n\n\t\t\tif (!sliversByNodeMap.has(node.nodeIndex)) {\n\t\t\t\tsliversByNodeMap.set(node.nodeIndex, { primary: [], secondary: [] });\n\t\t\t}\n\n\t\t\tsliversByNodeMap.get(node.nodeIndex)!.primary.push({\n\t\t\t\tsliverIndex: sliverPairIndex,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tshardIndex,\n\t\t\t\tsliver: primarySliver,\n\t\t\t});\n\n\t\t\tsliversByNodeMap.get(node.nodeIndex)!.secondary.push({\n\t\t\t\tsliverIndex: sliverPairIndex,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tshardIndex,\n\t\t\t\tsliver: secondarySliver,\n\t\t\t});\n\t\t}\n\n\t\tconst sliversByNode = new Array<SliversForNode>();\n\n\t\tfor (let i = 0; i < systemState.committee.members.length; i++) {\n\t\t\tsliversByNode.push(sliversByNodeMap.get(i) ?? { primary: [], secondary: [] });\n\t\t}\n\n\t\treturn { blobId, metadata, rootHash, sliversByNode };\n\t}\n\n\t/**\n\t * Write slivers to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * await client.writeSliversToNode({ blobId, slivers, signal });\n\t * ```\n\t */\n\tasync writeSliversToNode({ blobId, slivers, signal }: WriteSliversToNodeOptions) {\n\t\tconst controller = new AbortController();\n\t\tconst combinedSignal = signal\n\t\t\t? AbortSignal.any([controller.signal, signal])\n\t\t\t: controller.signal;\n\n\t\tconst primarySliverWrites = slivers.primary.map(({ sliverPairIndex, sliver }) => {\n\t\t\treturn this.writeSliver({\n\t\t\t\tblobId,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tsliverType: 'primary',\n\t\t\t\tsliver,\n\t\t\t\tsignal: combinedSignal,\n\t\t\t});\n\t\t});\n\n\t\tconst secondarySliverWrites = slivers.secondary.map(({ sliverPairIndex, sliver }) => {\n\t\t\treturn this.writeSliver({\n\t\t\t\tblobId,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tsliverType: 'secondary',\n\t\t\t\tsliver,\n\t\t\t\tsignal: combinedSignal,\n\t\t\t});\n\t\t});\n\n\t\tawait Promise.all([...primarySliverWrites, ...secondarySliverWrites]).catch((error) => {\n\t\t\tcontroller.abort(error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\t/**\n\t * Write a blob to all storage nodes\n\t *\n\t * @example\n\t * ```ts\n\t * await client.writeEncodedBlobToNodes({ blob, deletable, epochs, signer });\n\t * ```\n\t */\n\tasync writeEncodedBlobToNodes({\n\t\tblobId,\n\t\tmetadata,\n\t\tsliversByNode,\n\t\tsignal,\n\t\t...options\n\t}: WriteEncodedBlobToNodesOptions) {\n\t\tconst systemState = await this.systemState();\n\t\tconst committee = await this.#getActiveCommittee();\n\n\t\tconst controller = new AbortController();\n\t\tlet failures = 0;\n\n\t\tconst confirmations = await Promise.all(\n\t\t\tsliversByNode.map((slivers, nodeIndex) => {\n\t\t\t\treturn this.writeEncodedBlobToNode({\n\t\t\t\t\tblobId,\n\t\t\t\t\tnodeIndex,\n\t\t\t\t\tmetadata,\n\t\t\t\t\tslivers,\n\t\t\t\t\tsignal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,\n\t\t\t\t\t...options,\n\t\t\t\t}).catch(() => {\n\t\t\t\t\tfailures += committee.nodes[nodeIndex].shardIndices.length;\n\n\t\t\t\t\tif (isAboveValidity(failures, systemState.committee.n_shards)) {\n\t\t\t\t\t\tconst error = new NotEnoughBlobConfirmationsError(\n\t\t\t\t\t\t\t`Too many failures while writing blob ${blobId} to nodes`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontroller.abort(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\n\t\treturn confirmations;\n\t}\n\n\t/**\n\t * Writes a blob to to an upload relay\n\t *\n\t * @example\n\t * ```ts\n\t * await client.writeBlobToUploadRelay({ blob, deletable, epochs, signer });\n\t * ```\n\t */\n\tasync writeBlobToUploadRelay(options: WriteBlobToUploadRelayOptions): Promise<{\n\t\tblobId: string;\n\t\tcertificate: ProtocolMessageCertificate;\n\t}> {\n\t\tif (!this.#uploadRelayClient) {\n\t\t\tthrow new WalrusClientError('Upload relay not configured');\n\t\t}\n\n\t\treturn this.#uploadRelayClient.writeBlob({\n\t\t\t...options,\n\t\t\trequiresTip: !!this.#uploadRelayConfig?.sendTip,\n\t\t});\n\t}\n\n\t/**\n\t * Write encoded blob to a storage node\n\t *\n\t * @example\n\t * ```ts\n\t * const res = await client.writeEncodedBlobToNode({ nodeIndex, blobId, metadata, slivers });\n\t * ```\n\t */\n\tasync writeEncodedBlobToNode({\n\t\tnodeIndex,\n\t\tblobId,\n\t\tmetadata,\n\t\tslivers,\n\t\tsignal,\n\t\t...options\n\t}: WriteEncodedBlobOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\n\t\tlet metaDataExists = false;\n\t\ttry {\n\t\t\tconst metadataStatus = await this.#storageNodeClient.getMetadataStatus(\n\t\t\t\t{ blobId },\n\t\t\t\t{ nodeUrl: node.networkUrl, signal },\n\t\t\t);\n\t\t\tif (metadataStatus === 'Stored' || metadataStatus === 'Buffered') {\n\t\t\t\tmetaDataExists = true;\n\t\t\t}\n\t\t} catch {\n\t\t\t// If status check fails, fall through to writing metadata\n\t\t}\n\n\t\tif (!metaDataExists) {\n\t\t\tawait this.writeMetadataToNode({\n\t\t\t\tnodeIndex,\n\t\t\t\tblobId,\n\t\t\t\tmetadata,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t}\n\n\t\tif (!metaDataExists) {\n\t\t\tawait this.writeSliversToNode({ blobId, slivers, signal, nodeIndex });\n\t\t} else {\n\t\t\tawait this.#writeSliversWithStatusCheck({ blobId, slivers, signal, nodeIndex });\n\t\t}\n\n\t\treturn this.getStorageConfirmationFromNode({\n\t\t\tnodeIndex,\n\t\t\tblobId,\n\t\t\t...options,\n\t\t});\n\t}\n\n\tasync #writeSliversWithStatusCheck({\n\t\tblobId,\n\t\tslivers,\n\t\tsignal,\n\t\tnodeIndex,\n\t}: WriteSliversToNodeOptions) {\n\t\tconst committee = await this.#getActiveCommittee();\n\t\tconst node = committee.nodes[nodeIndex];\n\t\tconst controller = new AbortController();\n\t\tconst combinedSignal = signal\n\t\t\t? AbortSignal.any([controller.signal, signal])\n\t\t\t: controller.signal;\n\n\t\tconst sliverWrites = [\n\t\t\t...slivers.primary.map((s) => ({ ...s, sliverType: 'primary' as const })),\n\t\t\t...slivers.secondary.map((s) => ({ ...s, sliverType: 'secondary' as const })),\n\t\t].map(async ({ sliverPairIndex, sliver, sliverType }) => {\n\t\t\tif (sliver.byteLength >= SLIVER_STATUS_CHECK_THRESHOLD) {\n\t\t\t\ttry {\n\t\t\t\t\tconst status = await this.#storageNodeClient.getSliverStatus(\n\t\t\t\t\t\t{ blobId, sliverPairIndex, sliverType },\n\t\t\t\t\t\t{ nodeUrl: node.networkUrl, signal: combinedSignal },\n\t\t\t\t\t);\n\t\t\t\t\tif (status === 'Stored' || status === 'Buffered') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// If status check fails, fall through to writing\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this.writeSliver({\n\t\t\t\tblobId,\n\t\t\t\tsliverPairIndex,\n\t\t\t\tsliverType,\n\t\t\t\tsliver,\n\t\t\t\tsignal: combinedSignal,\n\t\t\t});\n\t\t});\n\n\t\tawait Promise.all(sliverWrites).catch((error) => {\n\t\t\tcontroller.abort(error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\t/**\n\t * Write a blob to all storage nodes\n\t *\n\t * @example\n\t * ```ts\n\t * const { blobId, blobObject } = await client.writeBlob({ blob, deletable, epochs, signer });\n\t * ```\n\t */\n\tasync writeBlob({\n\t\tblob,\n\t\tdeletable,\n\t\tepochs,\n\t\tsigner,\n\t\towner,\n\t\tattributes,\n\t\tonStep,\n\t\tresume,\n\t\tsignal,\n\t}: WriteBlobOptions) {\n\t\tconst flow = this.writeBlobFlow({ blob, resume });\n\t\tfor await (const step of flow.run({\n\t\t\tsigner,\n\t\t\tepochs,\n\t\t\tdeletable,\n\t\t\towner: owner ?? signer.toSuiAddress(),\n\t\t\tattributes,\n\t\t\tsignal,\n\t\t})) {\n\t\t\tawait onStep?.(step);\n\t\t}\n\n\t\tconst result = await flow.getBlob();\n\t\treturn {\n\t\t\tblobId: result.blobId,\n\t\t\tblobObject: result.blobObject,\n\t\t};\n\t}\n\n\tasync writeQuilt({ blobs, ...options }: WriteQuiltOptions) {\n\t\tconst encoded = await this.encodeQuilt({ blobs });\n\t\tconst result = await this.writeBlob({\n\t\t\t...options,\n\t\t\tblob: encoded.quilt,\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\n\t\treturn {\n\t\t\t...result,\n\t\t\tindex: {\n\t\t\t\t...encoded.index,\n\t\t\t\tpatches: encoded.index.patches.map((patch) => ({\n\t\t\t\t\t...patch,\n\t\t\t\t\tpatchId: encodeQuiltPatchId({\n\t\t\t\t\t\tquiltId: result.blobId,\n\t\t\t\t\t\tpatchId: {\n\t\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\t\tstartIndex: patch.startIndex,\n\t\t\t\t\t\t\tendIndex: patch.endIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t})),\n\t\t\t},\n\t\t};\n\t}\n\n\tasync encodeQuilt({\n\t\tblobs,\n\t}: {\n\t\tblobs: {\n\t\t\tcontents: Uint8Array;\n\t\t\tidentifier: string;\n\t\t\ttags?: Record<string, string>;\n\t\t}[];\n\t}) {\n\t\tconst systemState = await this.systemState();\n\t\tconst encoded = encodeQuilt({\n\t\t\tblobs,\n\t\t\tnumShards: systemState.committee.n_shards,\n\t\t});\n\n\t\treturn encoded;\n\t}\n\n\tasync #executeTransaction(transaction: Transaction, signer: Signer, action: string) {\n\t\ttransaction.setSenderIfNotSet(signer.toSuiAddress());\n\n\t\tconst result = await signer.signAndExecuteTransaction({\n\t\t\ttransaction,\n\t\t\tclient: this.#suiClient,\n\t\t});\n\n\t\tif (result.FailedTransaction) {\n\t\t\tthrow new WalrusClientError(\n\t\t\t\t`Failed to ${action} (${result.FailedTransaction.digest}): ${result.FailedTransaction.status.error?.message}`,\n\t\t\t);\n\t\t}\n\n\t\tconst { digest, effects } = result.Transaction;\n\n\t\tawait this.#suiClient.core.waitForTransaction({\n\t\t\tdigest,\n\t\t});\n\n\t\treturn { digest, effects };\n\t}\n\n\tasync #getCommittee(committee: InferBcsType<typeof Committee>) {\n\t\tconst stakingPool = await this.#stakingPool(committee);\n\t\tconst shardIndicesByNodeId = getShardIndicesByNodeId(committee);\n\n\t\tconst byShardIndex = new Map<number, StorageNode>();\n\t\tconst nodes = stakingPool.map(({ node_info }, nodeIndex) => {\n\t\t\tconst shardIndices = shardIndicesByNodeId.get(node_info.node_id) ?? [];\n\t\t\tconst node: StorageNode = {\n\t\t\t\tid: node_info.node_id,\n\t\t\t\tinfo: node_info,\n\t\t\t\tnetworkUrl: `${this.#storageNodeUrlScheme}://${node_info.network_address}`,\n\t\t\t\tshardIndices,\n\t\t\t\tnodeIndex,\n\t\t\t};\n\n\t\t\tfor (const shardIndex of shardIndices) {\n\t\t\t\tbyShardIndex.set(shardIndex, node);\n\t\t\t}\n\n\t\t\treturn node;\n\t\t});\n\n\t\treturn {\n\t\t\tbyShardIndex,\n\t\t\tnodes,\n\t\t};\n\t}\n\n\t#getActiveCommittee() {\n\t\t// Scoped by scheme — `#cache` is shared across clients on the same\n\t\t// `SuiClient`, so a mixed-scheme caller mustn't see another's URLs.\n\t\treturn this.#cache.read(['getActiveCommittee', this.#storageNodeUrlScheme], async () => {\n\t\t\tconst stakingState = await this.stakingState();\n\t\t\treturn this.#getCommittee(stakingState.committee);\n\t\t});\n\t}\n\n\tasync #stakingPool(committee: InferBcsType<typeof Committee>) {\n\t\tconst nodeIds = committee[0].contents.map((node) => node.key);\n\t\treturn this.#objectLoader.loadManyOrThrow(nodeIds, StakingPool);\n\t}\n\n\tasync #getNodeByShardIndex(committeeInfo: CommitteeInfo, index: number) {\n\t\tconst node = committeeInfo.byShardIndex.get(index);\n\t\tif (!node) {\n\t\t\tthrow new WalrusClientError(`Node for shard index ${index} not found`);\n\t\t}\n\t\treturn node;\n\t}\n\n\t/**\n\t * Reset cached data in the client\n\t *\n\t * @example\n\t * ```ts\n\t * client.reset();\n\t * ```\n\t */\n\treset() {\n\t\tthis.#objectLoader.clearAll();\n\t\tthis.#cache.clear();\n\t}\n\n\t#retryOnPossibleEpochChange<T extends (...args: any[]) => Promise<any>>(fn: T): T {\n\t\treturn (async (...args: Parameters<T>) => {\n\t\t\ttry {\n\t\t\t\treturn await fn.apply(this, args);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof RetryableWalrusClientError) {\n\t\t\t\t\tthis.reset();\n\t\t\t\t\treturn await fn.apply(this, args);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}) as T;\n\t}\n\n\tasync getBlob({ blobId }: { blobId: string }) {\n\t\treturn new WalrusBlob({\n\t\t\treader: new BlobReader({\n\t\t\t\tclient: this,\n\t\t\t\tblobId,\n\t\t\t\tnumShards: (await this.systemState()).committee.n_shards,\n\t\t\t}),\n\t\t\tclient: this,\n\t\t});\n\t}\n\n\tasync getFiles({ ids }: { ids: string[] }) {\n\t\tconst readersByBlobId = new Map<string, BlobReader>();\n\t\tconst quiltReadersByBlobId = new Map<string, QuiltReader>();\n\t\tconst parsedIds = ids.map((id) => parseWalrusId(id));\n\t\tconst numShards = (await this.systemState()).committee.n_shards;\n\n\t\tfor (const id of parsedIds) {\n\t\t\tconst blobId = id.kind === 'blob' ? id.id : id.id.quiltId;\n\t\t\tif (!readersByBlobId.has(blobId)) {\n\t\t\t\treadersByBlobId.set(\n\t\t\t\t\tblobId,\n\t\t\t\t\tnew BlobReader({\n\t\t\t\t\t\tclient: this,\n\t\t\t\t\t\tblobId,\n\t\t\t\t\t\tnumShards,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (id.kind === 'quiltPatch') {\n\t\t\t\tif (!quiltReadersByBlobId.has(blobId)) {\n\t\t\t\t\tquiltReadersByBlobId.set(\n\t\t\t\t\t\tblobId,\n\t\t\t\t\t\tnew QuiltReader({\n\t\t\t\t\t\t\tblob: readersByBlobId.get(blobId)!,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn parsedIds.map((id) => {\n\t\t\tif (id.kind === 'blob') {\n\t\t\t\treturn new WalrusFile({\n\t\t\t\t\treader: readersByBlobId.get(id.id)!,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn new WalrusFile({\n\t\t\t\treader: new QuiltFileReader({\n\t\t\t\t\tquilt: quiltReadersByBlobId.get(id.id.quiltId)!,\n\t\t\t\t\tsliverIndex: id.id.patchId.startIndex,\n\t\t\t\t}),\n\t\t\t});\n\t\t});\n\t}\n\n\tasync writeFiles({ files, onStep, resume, ...options }: WriteFilesOptions) {\n\t\tconst flow = this.writeFilesFlow({ files, resume });\n\t\tfor await (const step of flow.run({\n\t\t\tsigner: options.signer,\n\t\t\tepochs: options.epochs,\n\t\t\tdeletable: options.deletable,\n\t\t\towner: options.owner ?? options.signer.toSuiAddress(),\n\t\t\tattributes: options.attributes,\n\t\t})) {\n\t\t\tawait onStep?.(step);\n\t\t}\n\n\t\treturn flow.listFiles();\n\t}\n\n\t/**\n\t * Create a step-by-step files upload flow with resume support.\n\t *\n\t * Encodes files into a quilt blob and delegates to `writeBlobFlow()` internally.\n\t * Supports the same resume, step methods, and `run()` async iterator as `writeBlobFlow()`.\n\t *\n\t * @example\n\t * ```ts\n\t * const flow = client.writeFilesFlow({ files });\n\t * for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {\n\t * await db.save(fileId, step);\n\t * }\n\t * const fileRefs = await flow.listFiles();\n\t * ```\n\t */\n\twriteFilesFlow(options: WriteFilesFlowOptions): WriteFilesFlow {\n\t\treturn createWriteFilesFlow(this, options);\n\t}\n\n\t/**\n\t * Create a step-by-step blob upload flow with resume support.\n\t *\n\t * Returns an object with individual step methods (`encode`, `register`, `upload`, `certify`)\n\t * for manual control, convenience methods (`executeRegister`, `executeCertify`) that handle\n\t * signing, and a `run()` async iterator that executes the full pipeline.\n\t *\n\t * Each step returns a `WriteBlobStep` result that can be persisted and passed as `resume`\n\t * to recover from crashes.\n\t *\n\t * @example\n\t * ```ts\n\t * // Async iterator with checkpoints:\n\t * const flow = client.writeBlobFlow({ blob });\n\t * for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {\n\t * await db.save(fileId, step);\n\t * }\n\t *\n\t * // Resume from saved state:\n\t * const saved = await db.load(fileId);\n\t * const flow = client.writeBlobFlow({ blob, resume: saved });\n\t * for await (const step of flow.run({ signer, epochs: 3, deletable: true })) {\n\t * await db.save(fileId, step);\n\t * }\n\t * ```\n\t */\n\twriteBlobFlow(options: WriteBlobFlowOptions): WriteBlobFlow {\n\t\treturn createWriteBlobFlow(this, this.#flowContext(), options);\n\t}\n\n\t#flowContext(): WriteBlobFlowContext {\n\t\treturn {\n\t\t\thasUploadRelay: () => !!this.#uploadRelayClient,\n\t\t\texecuteTransaction: (transaction, signer, action) =>\n\t\t\t\tthis.#executeTransaction(transaction, signer, action),\n\t\t\tgetCreatedBlob: (digest) => this.#getCreatedBlob(digest),\n\t\t\tloadBlobObject: (objectId) => this.#objectLoader.load(objectId, Blob),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAK3B;GAC7B,qBAAqB,aAAa,QAAQ,WACzC,MAAKoB,mBAAoB,aAAa,QAAQ,OAAO;GACtD,iBAAiB,WAAW,MAAKG,eAAgB,OAAO;GACxD,iBAAiB,aAAa,MAAKpB,aAAc,KAAK,UAAU,KAAK;GACrE"}
|
|
@@ -9,7 +9,42 @@ type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> =
|
|
|
9
9
|
type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectsOptions<Include> & {
|
|
10
10
|
client: ClientWithCoreApi;
|
|
11
11
|
};
|
|
12
|
+
/** A type argument: a type tag string, or a BCS type whose name is a Move type. */
|
|
13
|
+
type TypeArgument = string | BcsType<any>;
|
|
14
|
+
interface TypeTagOptions {
|
|
15
|
+
package?: string;
|
|
16
|
+
typeArguments?: readonly TypeArgument[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `typeArguments` is required when the type's name contains unfilled
|
|
20
|
+
* `phantom X` parameters (at any depth). Everything else — argument arity,
|
|
21
|
+
* position contents, and tag validity — is validated at runtime.
|
|
22
|
+
*/
|
|
23
|
+
type TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}` ? [options: TypeTagOptions & {
|
|
24
|
+
typeArguments: readonly TypeArgument[];
|
|
25
|
+
}] : [options?: TypeTagOptions];
|
|
26
|
+
type ResolveTypeTagOptions<Name extends string> = {
|
|
27
|
+
client: ClientWithCoreApi;
|
|
28
|
+
} & (Name extends `${string}phantom ${string}` ? TypeTagOptions & {
|
|
29
|
+
typeArguments: readonly TypeArgument[];
|
|
30
|
+
} : TypeTagOptions);
|
|
12
31
|
declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
32
|
+
/**
|
|
33
|
+
* Build the type tag for this struct.
|
|
34
|
+
*
|
|
35
|
+
* `typeArguments` is the full positional list, in Move declaration order, and
|
|
36
|
+
* is required when the struct has unfilled phantom parameters. The result may
|
|
37
|
+
* contain MVR names: those are valid in transaction `typeArguments`, but for
|
|
38
|
+
* queries or comparisons against on-chain data use `resolveTypeTag` instead.
|
|
39
|
+
*/
|
|
40
|
+
typeTag(...args: TypeTagParams<Name>): string;
|
|
41
|
+
/**
|
|
42
|
+
* Build the type tag for this struct, then resolve any MVR names through the
|
|
43
|
+
* client (using its configured overrides and the MVR API) and return the
|
|
44
|
+
* normalized, address-only form suitable for queries and comparisons against
|
|
45
|
+
* on-chain data.
|
|
46
|
+
*/
|
|
47
|
+
resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string>;
|
|
13
48
|
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({
|
|
14
49
|
objectId,
|
|
15
50
|
...options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/contracts/utils/index.ts"],"mappings":";;;;;KAkBY,UAAA,iBAA2B,IAAA,CAAK,cAAA,CAAe,aAAA,qBAC1D,cAAA,CAAe,gBAAA,CAAiB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;AAAA,KAE1C,cAAA,iBAA+B,IAAA,CAAK,cAAA,CAAe,aAAA,qBAC9D,cAAA,CAAe,iBAAA,CAAkB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/contracts/utils/index.ts"],"mappings":";;;;;KAkBY,UAAA,iBAA2B,IAAA,CAAK,cAAA,CAAe,aAAA,qBAC1D,cAAA,CAAe,gBAAA,CAAiB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;AAAA,KAE1C,cAAA,iBAA+B,IAAA,CAAK,cAAA,CAAe,aAAA,qBAC9D,cAAA,CAAe,iBAAA,CAAkB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;;KA4I3C,YAAA,YAAwB,OAAA;AAAA,UAEnB,cAAA;EAChB,OAAA;EACA,aAAA,YAAyB,YAAA;AAAA;;;;;;KAQrB,aAAA,wBAAqC,IAAA,yCACtC,OAAA,EAAS,cAAA;EAAmB,aAAA,WAAwB,YAAA;AAAA,MACpD,OAAA,GAAU,cAAA;AAAA,KAET,qBAAA;EACJ,MAAA,EAAQ,iBAAA;AAAA,KACJ,IAAA,wCACF,cAAA;EAAmB,aAAA,WAAwB,YAAA;AAAA,IAC3C,cAAA;AAAA,cAqFU,UAAA,WACF,MAAA,SAAe,OAAA,oDAEhB,SAAA,CAAU,CAAA,EAAG,IAAA;EAxPtB;;;;;;;;EAiQA,OAAA,CAAA,GAAW,IAAA,EAAM,aAAA,CAAc,IAAA;EAjQhB;;;;;;EA2QT,cAAA,CAAe,OAAA,EAAS,qBAAA,CAAsB,IAAA,IAAQ,OAAA;EAOtD,GAAA,iBAAoB,IAAA,CAAK,cAAA,CAAe,aAAA,2BAAA,CAAA;IAC7C,QAAA;IAAA,GACG;EAAA,GACD,UAAA,CAAW,OAAA,IAAW,OAAA,CACxB,cAAA,CAAe,MAAA,CAAO,OAAA;IAAY,OAAA;IAAe,IAAA;EAAA;IAChD,IAAA,EAAM,SAAA,CAAU,CAAA;EAAA;EAeZ,OAAA,iBAAwB,IAAA,CAAK,cAAA,CAAe,aAAA,2BAAA,CAAA;IACjD,MAAA;IAAA,GACG;EAAA,GACD,cAAA,CAAe,OAAA,IAAW,OAAA,CAC5B,KAAA,CACC,cAAA,CAAe,MAAA,CAAO,OAAA;IAAY,OAAA;IAAe,IAAA;EAAA;IAChD,IAAA,EAAM,SAAA,CAAU,CAAA;EAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isArgument } from "@mysten/sui/transactions";
|
|
2
|
-
import { normalizeSuiAddress } from "@mysten/sui/utils";
|
|
2
|
+
import { normalizeStructTag, normalizeSuiAddress } from "@mysten/sui/utils";
|
|
3
3
|
import { BcsEnum, BcsStruct, BcsTuple, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
|
|
4
4
|
|
|
5
5
|
//#region src/contracts/utils/index.ts
|
|
@@ -84,7 +84,73 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
84
84
|
}
|
|
85
85
|
return normalizedArgs;
|
|
86
86
|
}
|
|
87
|
+
const HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;
|
|
88
|
+
function splitTopLevelTypeArgs(inner) {
|
|
89
|
+
const parts = [];
|
|
90
|
+
let depth = 0;
|
|
91
|
+
let current = "";
|
|
92
|
+
for (const char of inner) {
|
|
93
|
+
if (char === "," && depth === 0) {
|
|
94
|
+
parts.push(current.trim());
|
|
95
|
+
current = "";
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (char === "<") depth++;
|
|
99
|
+
if (char === ">") depth--;
|
|
100
|
+
current += char;
|
|
101
|
+
}
|
|
102
|
+
if (current) parts.push(current.trim());
|
|
103
|
+
return parts;
|
|
104
|
+
}
|
|
105
|
+
function buildTypeTag(name, options) {
|
|
106
|
+
const lt = name.indexOf("<");
|
|
107
|
+
const base = lt === -1 ? name : name.slice(0, lt);
|
|
108
|
+
if (base.split("::").length !== 3) throw new Error(`${name} is not a top-level Move type`);
|
|
109
|
+
let result = name;
|
|
110
|
+
if (options?.typeArguments) {
|
|
111
|
+
const baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));
|
|
112
|
+
const supplied = options.typeArguments.map((arg) => {
|
|
113
|
+
if (typeof arg === "string") return arg;
|
|
114
|
+
if (arg && typeof arg.serialize === "function" && typeof arg.name === "string") return arg.name;
|
|
115
|
+
throw new Error(`Invalid type argument ${stringify(arg)}`);
|
|
116
|
+
});
|
|
117
|
+
if (supplied.length !== baked.length) throw new Error(`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`);
|
|
118
|
+
result = supplied.length === 0 ? base : `${base}<${supplied.join(", ")}>`;
|
|
119
|
+
}
|
|
120
|
+
if (HAS_PHANTOM_REGEX.test(result)) throw new Error(options?.typeArguments ? `A type argument contains an unfilled phantom parameter in ${result}` : `Missing type arguments for ${result}`);
|
|
121
|
+
if (options?.package) {
|
|
122
|
+
const [, ...rest] = result.split("::");
|
|
123
|
+
result = [options.package, ...rest].join("::");
|
|
124
|
+
}
|
|
125
|
+
if (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) TypeTagSerializer.parseFromStr(result);
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
async function resolveBuiltTypeTag(name, options) {
|
|
129
|
+
const { client, ...rest } = options;
|
|
130
|
+
const { type } = await client.core.mvr.resolveType({ type: buildTypeTag(name, rest) });
|
|
131
|
+
return normalizeStructTag(type);
|
|
132
|
+
}
|
|
87
133
|
var MoveStruct = class extends BcsStruct {
|
|
134
|
+
/**
|
|
135
|
+
* Build the type tag for this struct.
|
|
136
|
+
*
|
|
137
|
+
* `typeArguments` is the full positional list, in Move declaration order, and
|
|
138
|
+
* is required when the struct has unfilled phantom parameters. The result may
|
|
139
|
+
* contain MVR names: those are valid in transaction `typeArguments`, but for
|
|
140
|
+
* queries or comparisons against on-chain data use `resolveTypeTag` instead.
|
|
141
|
+
*/
|
|
142
|
+
typeTag(...args) {
|
|
143
|
+
return buildTypeTag(this.name, args[0]);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Build the type tag for this struct, then resolve any MVR names through the
|
|
147
|
+
* client (using its configured overrides and the MVR API) and return the
|
|
148
|
+
* normalized, address-only form suitable for queries and comparisons against
|
|
149
|
+
* on-chain data.
|
|
150
|
+
*/
|
|
151
|
+
async resolveTypeTag(options) {
|
|
152
|
+
return resolveBuiltTypeTag(this.name, options);
|
|
153
|
+
}
|
|
88
154
|
async get({ objectId, ...options }) {
|
|
89
155
|
const [res] = await this.getMany({
|
|
90
156
|
...options,
|
|
@@ -109,10 +175,28 @@ var MoveStruct = class extends BcsStruct {
|
|
|
109
175
|
});
|
|
110
176
|
}
|
|
111
177
|
};
|
|
112
|
-
var MoveEnum = class extends BcsEnum {
|
|
113
|
-
|
|
178
|
+
var MoveEnum = class extends BcsEnum {
|
|
179
|
+
/** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */
|
|
180
|
+
typeTag(...args) {
|
|
181
|
+
return buildTypeTag(this.name, args[0]);
|
|
182
|
+
}
|
|
183
|
+
/** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */
|
|
184
|
+
async resolveTypeTag(options) {
|
|
185
|
+
return resolveBuiltTypeTag(this.name, options);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var MoveTuple = class extends BcsTuple {
|
|
189
|
+
/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */
|
|
190
|
+
typeTag(...args) {
|
|
191
|
+
return buildTypeTag(this.name, args[0]);
|
|
192
|
+
}
|
|
193
|
+
/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */
|
|
194
|
+
async resolveTypeTag(options) {
|
|
195
|
+
return resolveBuiltTypeTag(this.name, options);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
114
198
|
function stringify(val) {
|
|
115
|
-
if (typeof val === "object") return JSON.stringify(val, (
|
|
199
|
+
if (typeof val === "object") return JSON.stringify(val, (_key, value) => typeof value === "bigint" ? value.toString() : value);
|
|
116
200
|
if (typeof val === "bigint") return val.toString();
|
|
117
201
|
return val;
|
|
118
202
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["val"],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":";;;;;AAaA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAM,wBAAwB,oBAAoB,MAAM;AAUxD,SAAgB,iBAAiB,SAAgD;CAChF,MAAM,YAAY,OAAO,YAAY,WAAW,kBAAkB,aAAa,QAAQ,GAAG;AAE1F,KAAI,QAAQ,UACX,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,aAAa,UACvB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,YAAY,WAAW;EACjC,MAAM,OAAO,iBAAiB,UAAU,OAAO;AAC/C,SAAO,OAAO,IAAI,OAAO,KAAK,GAAG;YACvB,YAAY,WAAW;EACjC,MAAM,YAAY,UAAU;EAC5B,MAAM,MAAM,oBAAoB,UAAU,QAAQ;AAElD,MAAI,QAAQ,qBAAqB;AAChC,QACE,UAAU,WAAW,WAAW,UAAU,WAAW,aACtD,UAAU,SAAS,SAEnB,QAAO,I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import {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\n/* -------------------------- Move type tags -------------------------- */\n\n/** A type argument: a type tag string, or a BCS type whose name is a Move type. */\nexport type TypeArgument = string | BcsType<any>;\n\nexport interface TypeTagOptions {\n\tpackage?: string;\n\ttypeArguments?: readonly TypeArgument[];\n}\n\n/**\n * `typeArguments` is required when the type's name contains unfilled\n * `phantom X` parameters (at any depth). Everything else — argument arity,\n * position contents, and tag validity — is validated at runtime.\n */\ntype TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}`\n\t? [options: TypeTagOptions & { typeArguments: readonly TypeArgument[] }]\n\t: [options?: TypeTagOptions];\n\ntype ResolveTypeTagOptions<Name extends string> = {\n\tclient: ClientWithCoreApi;\n} & (Name extends `${string}phantom ${string}`\n\t? TypeTagOptions & { typeArguments: readonly TypeArgument[] }\n\t: TypeTagOptions);\n\nconst HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;\n\nfunction splitTopLevelTypeArgs(inner: string): string[] {\n\tconst parts: string[] = [];\n\tlet depth = 0;\n\tlet current = '';\n\tfor (const char of inner) {\n\t\tif (char === ',' && depth === 0) {\n\t\t\tparts.push(current.trim());\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '<') depth++;\n\t\tif (char === '>') depth--;\n\t\tcurrent += char;\n\t}\n\tif (current) parts.push(current.trim());\n\treturn parts;\n}\n\nfunction buildTypeTag(name: string, options: TypeTagOptions | undefined): string {\n\tconst lt = name.indexOf('<');\n\tconst base = lt === -1 ? name : name.slice(0, lt);\n\n\tif (base.split('::').length !== 3) {\n\t\tthrow new Error(`${name} is not a top-level Move type`);\n\t}\n\n\tlet result = name;\n\n\tif (options?.typeArguments) {\n\t\tconst baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));\n\t\tconst supplied = options.typeArguments.map((arg) => {\n\t\t\tif (typeof arg === 'string') {\n\t\t\t\treturn arg;\n\t\t\t}\n\t\t\tif (arg && typeof arg.serialize === 'function' && typeof arg.name === 'string') {\n\t\t\t\treturn arg.name;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid type argument ${stringify(arg)}`);\n\t\t});\n\n\t\tif (supplied.length !== baked.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`,\n\t\t\t);\n\t\t}\n\n\t\tresult = supplied.length === 0 ? base : `${base}<${supplied.join(', ')}>`;\n\t}\n\n\tif (HAS_PHANTOM_REGEX.test(result)) {\n\t\tthrow new Error(\n\t\t\toptions?.typeArguments\n\t\t\t\t? `A type argument contains an unfilled phantom parameter in ${result}`\n\t\t\t\t: `Missing type arguments for ${result}`,\n\t\t);\n\t}\n\n\tif (options?.package) {\n\t\tconst [, ...rest] = result.split('::');\n\t\tresult = [options.package, ...rest].join('::');\n\t}\n\n\t// fully validate address-only tags (MVR names can't be parsed as type tags)\n\tif (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) {\n\t\tTypeTagSerializer.parseFromStr(result);\n\t}\n\n\treturn result;\n}\n\nasync function resolveBuiltTypeTag(\n\tname: string,\n\toptions: { client: ClientWithCoreApi } & TypeTagOptions,\n): Promise<string> {\n\tconst { client, ...rest } = options;\n\tconst { type } = await client.core.mvr.resolveType({\n\t\ttype: buildTypeTag(name, rest),\n\t});\n\treturn normalizeStructTag(type);\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\t/**\n\t * Build the type tag for this struct.\n\t *\n\t * `typeArguments` is the full positional list, in Move declaration order, and\n\t * is required when the struct has unfilled phantom parameters. The result may\n\t * contain MVR names: those are valid in transaction `typeArguments`, but for\n\t * queries or comparisons against on-chain data use `resolveTypeTag` instead.\n\t */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/**\n\t * Build the type tag for this struct, then resolve any MVR names through the\n\t * client (using its configured overrides and the MVR API) and return the\n\t * normalized, address-only form suitable for queries and comparisons against\n\t * on-chain data.\n\t */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {\n\t/** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {\n\t/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (_key, value) =>\n\t\t\ttypeof value === 'bigint' ? value.toString() : value,\n\t\t);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":";;;;;AAaA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAM,wBAAwB,oBAAoB,MAAM;AAUxD,SAAgB,iBAAiB,SAAgD;CAChF,MAAM,YAAY,OAAO,YAAY,WAAW,kBAAkB,aAAa,QAAQ,GAAG;AAE1F,KAAI,QAAQ,UACX,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,aAAa,UACvB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,YAAY,WAAW;EACjC,MAAM,OAAO,iBAAiB,UAAU,OAAO;AAC/C,SAAO,OAAO,IAAI,OAAO,KAAK,GAAG;YACvB,YAAY,WAAW;EACjC,MAAM,YAAY,UAAU;EAC5B,MAAM,MAAM,oBAAoB,UAAU,QAAQ;AAElD,MAAI,QAAQ,qBAAqB;AAChC,QACE,UAAU,WAAW,WAAW,UAAU,WAAW,aACtD,UAAU,SAAS,SAEnB,QAAO,IAAI;AAGZ,OAAI,UAAU,WAAW,YAAY,UAAU,SAAS,UAAU;IACjE,MAAM,QAAQ,UAAU,WAAW;IACnC,MAAM,OAAO,QAAQ,iBAAiB,MAAM,GA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IACT;GACD,CAAC,EAEc,QAAQ,KAAK,QAAQ;AACpC,OAAI,eAAe,MAClB,OAAM;AAGP,UAAO;IACN,GAAG;IACH,MAAM,KAAK,MAAM,IAAI,QAAQ;IAC7B;IACA;;;AAIJ,IAAa,WAAb,cAGU,QAAiB;;CAE1B,QAAQ,GAAG,MAAmC;AAC7C,SAAO,aAAa,KAAK,MAAM,KAAK,GAAiC;;;CAItE,MAAM,eAAe,SAAuD;AAC3E,SAAO,oBACN,KAAK,MACL,QACA;;;AAIH,IAAa,YAAb,cAGU,SAAkB;;CAE3B,QAAQ,GAAG,MAAmC;AAC7C,SAAO,aAAa,KAAK,MAAM,KAAK,GAAiC;;;CAItE,MAAM,eAAe,SAAuD;AAC3E,SAAO,oBACN,KAAK,MACL,QACA;;;AAIH,SAAS,UAAU,KAAc;AAChC,KAAI,OAAO,QAAQ,SAClB,QAAO,KAAK,UAAU,MAAM,MAAM,UACjC,OAAO,UAAU,WAAW,MAAM,UAAU,GAAG,MAC/C;AAEF,KAAI,OAAO,QAAQ,SAClB,QAAO,IAAI,UAAU;AAGtB,QAAO"}
|
package/dist/types.d.mts
CHANGED
|
@@ -51,6 +51,12 @@ interface BaseWalrusClientConfig {
|
|
|
51
51
|
storageNodeClientOptions?: StorageNodeClientOptions;
|
|
52
52
|
wasmUrl?: string;
|
|
53
53
|
uploadRelay?: UploadRelayConfig;
|
|
54
|
+
/**
|
|
55
|
+
* URL scheme used when contacting storage nodes. Defaults to `'https'`.
|
|
56
|
+
* Set to `'http'` for local development where storage nodes do not
|
|
57
|
+
* terminate TLS.
|
|
58
|
+
*/
|
|
59
|
+
storageNodeUrlScheme?: 'http' | 'https';
|
|
54
60
|
}
|
|
55
61
|
/**
|
|
56
62
|
* Configuration for the Walrus client.
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;;;;;AAyBA;;;UAAiB,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AAA;EACnB,SAAA,EAAW,UAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysten/walrus",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Walrus SDK",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,28 +30,28 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://sdk.mystenlabs.com/walrus",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@hono/node-server": "^
|
|
34
|
-
"@tanstack/react-query": "^5.
|
|
35
|
-
"@types/node": "^25.
|
|
36
|
-
"@types/react": "^19.2.
|
|
33
|
+
"@hono/node-server": "^2.0.4",
|
|
34
|
+
"@tanstack/react-query": "^5.101.0",
|
|
35
|
+
"@types/node": "^25.9.3",
|
|
36
|
+
"@types/react": "^19.2.17",
|
|
37
37
|
"@types/react-dom": "^19.2.3",
|
|
38
|
-
"@vitejs/plugin-react": "^
|
|
39
|
-
"hono": "
|
|
40
|
-
"react": "^19.2.
|
|
41
|
-
"react-dom": "^19.2.
|
|
42
|
-
"typescript": "^
|
|
43
|
-
"undici": "^
|
|
44
|
-
"vite": "^8.0.
|
|
45
|
-
"vitest": "^4.
|
|
38
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
39
|
+
"hono": ">=4.12.18",
|
|
40
|
+
"react": "^19.2.7",
|
|
41
|
+
"react-dom": "^19.2.7",
|
|
42
|
+
"typescript": "^6.0.3",
|
|
43
|
+
"undici": "^8.4.1",
|
|
44
|
+
"vite": "^8.0.16",
|
|
45
|
+
"vitest": "^4.1.8"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"dataloader": "^2.2.3",
|
|
49
|
-
"@mysten/bcs": "^2.0
|
|
50
|
-
"@mysten/
|
|
51
|
-
"@mysten/
|
|
49
|
+
"@mysten/bcs": "^2.1.0",
|
|
50
|
+
"@mysten/walrus-wasm": "^0.3.0",
|
|
51
|
+
"@mysten/utils": "^0.4.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@mysten/sui": "^2.
|
|
54
|
+
"@mysten/sui": "^2.18.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|