@mysten/walrus 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/storage_node.js';\nimport type { RequestOptions, StorageNodeClientOptions } from './storage-node/client.js';\nimport type {\n\tStorageConfirmation,\n\tStoreBlobMetadataRequestInput,\n\tStoreSliverRequestInput,\n\tUploadable,\n} from './storage-node/types.js';\nimport type { BlobMetadata, EncodingType } from './utils/bcs.js';\n\n/**\n * Configuration for the Walrus package on sui\n *\n * This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID.\n */\nexport interface WalrusPackageConfig {\n\t/** The system object ID of the Walrus package */\n\tsystemObjectId: string;\n\t/** The staking pool ID of the Walrus package */\n\tstakingPoolId: string;\n\tsubsidiesObjectId?: string;\n\texchangeIds?: string[];\n}\n\ntype SuiClientOrRpcUrl =\n\t| {\n\t\t\tsuiClient: SuiClient;\n\t\t\tsuiRpcUrl?: never;\n\t }\n\t| {\n\t\t\tsuiRpcUrl: string;\n\t\t\tsuiClient?: never;\n\t };\n\ntype WalrusNetworkOrPackageConfig =\n\t| {\n\t\t\tnetwork: 'mainnet' | 'testnet';\n\t\t\tpackageConfig?: WalrusPackageConfig;\n\t }\n\t| {\n\t\t\tnetwork?: never;\n\t\t\tpackageConfig: WalrusPackageConfig;\n\t };\n\n/**\n * Configuration for the Walrus client.\n *\n * This is used to configure the Walrus client to use a specific storage node client options, network, and Sui client or RPC URL.\n */\nexport type WalrusClientConfig = {\n\tstorageNodeClientOptions?: StorageNodeClientOptions;\n\twasmUrl?: string;\n} & WalrusNetworkOrPackageConfig &\n\tSuiClientOrRpcUrl;\n\nexport type WalrusClientRequestOptions = Pick<RequestOptions, 'signal'>;\n\nexport interface StorageNode {\n\tnetworkUrl: string;\n\tinfo: ReturnType<typeof StorageNodeInfo>['$inferType'];\n\tshardIndices: number[];\n\tnodeIndex: number;\n\tid: string;\n}\n\nexport interface CommitteeInfo {\n\tbyShardIndex: Map<number, StorageNode>;\n\tnodes: StorageNode[];\n}\n\nexport interface StorageWithSizeOptions {\n\t/** The encoded size of the blob. */\n\tsize: number;\n\t/** The number of epoch the storage will be reserved for. */\n\tepochs: number;\n\t/** Owner of the storage object. */\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n}\n\nexport interface RegisterBlobOptions extends StorageWithSizeOptions {\n\tblobId: string;\n\trootHash: Uint8Array;\n\tdeletable: boolean;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n}\n\nexport interface CertifyBlobOptions {\n\tblobId: string;\n\tblobObjectId: string;\n\t/** An array of confirmations.\n\t * These confirmations must be provided in the same order as the nodes in the committee.\n\t * For nodes that have not provided a confirmation you can pass `null` */\n\tconfirmations: (StorageConfirmation | null)[];\n\tdeletable: boolean;\n}\n\ntype DeletableConfirmationOptions =\n\t| { deletable: false; objectId?: string }\n\t| { deletable: true; objectId: string };\n\nexport type GetStorageConfirmationOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type ReadBlobOptions = {\n\tblobId: string;\n} & WalrusClientRequestOptions;\n\nexport type GetCertificationEpochOptions = ReadBlobOptions;\n\nexport type GetBlobMetadataOptions = ReadBlobOptions;\n\nexport type GetSliversOptions = ReadBlobOptions;\n\nexport type GetVerifiedBlobStatusOptions = ReadBlobOptions;\n\nexport interface SliversForNode {\n\tprimary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n\tsecondary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n}\n\nexport type WriteSliversToNodeOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tslivers: SliversForNode;\n} & WalrusClientRequestOptions;\n\nexport type WriteSliverOptions = StoreSliverRequestInput & WalrusClientRequestOptions;\n\nexport type WriteMetadataOptions = {\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n} & StoreBlobMetadataRequestInput &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tslivers: SliversForNode;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobToNodesOptions = {\n\tblobId: string;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tsliversByNode: SliversForNode[];\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteBlobOptions = {\n\tblob: Uint8Array;\n\tdeletable: boolean;\n\t/** The number of epochs the blob should be stored for. */\n\tepochs: number;\n\tsigner: Signer;\n\t/** Where the blob should be transferred to after it is registered. Defaults to the signer address. */\n\towner?: string;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n} & WalrusClientRequestOptions;\n\nexport interface DeleteBlobOptions {\n\tblobObjectId: string;\n}\n\nexport type ExtendBlobOptions = {\n\tblobObjectId: string;\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n} & (\n\t| {\n\t\t\t/** The number of epochs the blob should be stored for. */\n\t\t\tepochs: number;\n\t\t\tendEpoch?: never;\n\t }\n\t| {\n\t\t\t/** The new end epoch for the storage period of the blob. */\n\t\t\tendEpoch: number;\n\t\t\tepochs?: never;\n\t }\n);\n\nexport type WriteBlobAttributesOptions = {\n\tattributes: Record<string, string | null>;\n} & (\n\t| {\n\t\t\tblobObject: TransactionObjectArgument;\n\t\t\tblobObjectId?: never;\n\t }\n\t| {\n\t\t\tblobObjectId: string;\n\t\t\tblobObject?: never;\n\t }\n);\n\nexport type EncodingType = Extract<typeof EncodingType.$inferInput, string>;\n"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { ClientWithExtensions } from '@mysten/sui/experimental';\nimport type { TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/storage_node.js';\nimport type { RequestOptions, StorageNodeClientOptions } from './storage-node/client.js';\nimport type {\n\tStorageConfirmation,\n\tStoreBlobMetadataRequestInput,\n\tStoreSliverRequestInput,\n\tUploadable,\n} from './storage-node/types.js';\nimport type { BlobMetadata, EncodingType } from './utils/bcs.js';\n\n/**\n * Configuration for the Walrus package on sui\n *\n * This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID.\n */\nexport interface WalrusPackageConfig {\n\t/** The system object ID of the Walrus package */\n\tsystemObjectId: string;\n\t/** The staking pool ID of the Walrus package */\n\tstakingPoolId: string;\n\tsubsidiesObjectId?: string;\n\texchangeIds?: string[];\n}\n\ntype SuiClientOrRpcUrl =\n\t| {\n\t\t\tsuiClient: ClientWithExtensions<{\n\t\t\t\tjsonRpc: SuiClient;\n\t\t\t}>;\n\t\t\tsuiRpcUrl?: never;\n\t }\n\t| {\n\t\t\tsuiRpcUrl: string;\n\t\t\tsuiClient?: never;\n\t };\n\ntype WalrusNetworkOrPackageConfig =\n\t| {\n\t\t\tnetwork: 'mainnet' | 'testnet';\n\t\t\tpackageConfig?: WalrusPackageConfig;\n\t }\n\t| {\n\t\t\tnetwork?: never;\n\t\t\tpackageConfig: WalrusPackageConfig;\n\t };\n\ninterface BaseWalrusClientConfig {\n\tstorageNodeClientOptions?: StorageNodeClientOptions;\n\twasmUrl?: string;\n}\n\n/**\n * Configuration for the Walrus client.\n *\n * This is used to configure the Walrus client to use a specific storage node client options, network, and Sui client or RPC URL.\n */\nexport type WalrusClientConfig = BaseWalrusClientConfig &\n\tWalrusNetworkOrPackageConfig &\n\tSuiClientOrRpcUrl;\n\nexport type WalrusClientExtensionOptions = BaseWalrusClientConfig & {\n\tpackageConfig?: WalrusPackageConfig;\n\tnetwork?: 'mainnet' | 'testnet';\n};\n\nexport type WalrusClientRequestOptions = Pick<RequestOptions, 'signal'>;\n\nexport interface StorageNode {\n\tnetworkUrl: string;\n\tinfo: ReturnType<typeof StorageNodeInfo>['$inferType'];\n\tshardIndices: number[];\n\tnodeIndex: number;\n\tid: string;\n}\n\nexport interface CommitteeInfo {\n\tbyShardIndex: Map<number, StorageNode>;\n\tnodes: StorageNode[];\n}\n\nexport interface StorageWithSizeOptions {\n\t/** The encoded size of the blob. */\n\tsize: number;\n\t/** The number of epoch the storage will be reserved for. */\n\tepochs: number;\n\t/** Owner of the storage object. */\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n}\n\nexport interface RegisterBlobOptions extends StorageWithSizeOptions {\n\tblobId: string;\n\trootHash: Uint8Array;\n\tdeletable: boolean;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n}\n\nexport interface CertifyBlobOptions {\n\tblobId: string;\n\tblobObjectId: string;\n\t/** An array of confirmations.\n\t * These confirmations must be provided in the same order as the nodes in the committee.\n\t * For nodes that have not provided a confirmation you can pass `null` */\n\tconfirmations: (StorageConfirmation | null)[];\n\tdeletable: boolean;\n}\n\ntype DeletableConfirmationOptions =\n\t| { deletable: false; objectId?: string }\n\t| { deletable: true; objectId: string };\n\nexport type GetStorageConfirmationOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type ReadBlobOptions = {\n\tblobId: string;\n} & WalrusClientRequestOptions;\n\nexport type GetCertificationEpochOptions = ReadBlobOptions;\n\nexport type GetBlobMetadataOptions = ReadBlobOptions;\n\nexport type GetSliversOptions = ReadBlobOptions;\n\nexport type GetVerifiedBlobStatusOptions = ReadBlobOptions;\n\nexport interface SliversForNode {\n\tprimary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n\tsecondary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n}\n\nexport type WriteSliversToNodeOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tslivers: SliversForNode;\n} & WalrusClientRequestOptions;\n\nexport type WriteSliverOptions = StoreSliverRequestInput & WalrusClientRequestOptions;\n\nexport type WriteMetadataOptions = {\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n} & StoreBlobMetadataRequestInput &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tslivers: SliversForNode;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobToNodesOptions = {\n\tblobId: string;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tsliversByNode: SliversForNode[];\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteBlobOptions = {\n\tblob: Uint8Array;\n\tdeletable: boolean;\n\t/** The number of epochs the blob should be stored for. */\n\tepochs: number;\n\tsigner: Signer;\n\t/** Where the blob should be transferred to after it is registered. Defaults to the signer address. */\n\towner?: string;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n} & WalrusClientRequestOptions;\n\nexport interface DeleteBlobOptions {\n\tblobObjectId: string;\n}\n\nexport type ExtendBlobOptions = {\n\tblobObjectId: string;\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n} & (\n\t| {\n\t\t\t/** The number of epochs the blob should be stored for. */\n\t\t\tepochs: number;\n\t\t\tendEpoch?: never;\n\t }\n\t| {\n\t\t\t/** The new end epoch for the storage period of the blob. */\n\t\t\tendEpoch: number;\n\t\t\tepochs?: never;\n\t }\n);\n\nexport type WriteBlobAttributesOptions = {\n\tattributes: Record<string, string | null>;\n} & (\n\t| {\n\t\t\tblobObject: TransactionObjectArgument;\n\t\t\tblobObjectId?: never;\n\t }\n\t| {\n\t\t\tblobObjectId: string;\n\t\t\tblobObject?: never;\n\t }\n);\n\nexport type EncodingType = Extract<typeof EncodingType.$inferInput, string>;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,11 @@
1
1
  import type { BcsType } from '@mysten/bcs';
2
2
  import type { PureTypeName, ShapeFromPureTypeName } from '@mysten/sui/bcs';
3
- import type { SuiClient, SuiObjectData } from '@mysten/sui/client';
3
+ import type { SuiObjectData } from '@mysten/sui/client';
4
+ import type { Experimental_BaseClient, Experimental_SuiClientTypes } from '@mysten/sui/experimental';
4
5
  import DataLoader from 'dataloader';
5
- export declare class SuiObjectDataLoader extends DataLoader<string, SuiObjectData> {
6
+ export declare class SuiObjectDataLoader extends DataLoader<string, Experimental_SuiClientTypes.ObjectResponse> {
6
7
  #private;
7
- constructor(suiClient: SuiClient);
8
+ constructor(suiClient: Experimental_BaseClient);
8
9
  load<T = SuiObjectData>(id: string, schema?: BcsType<T, any>): Promise<T>;
9
10
  loadMany<T = SuiObjectData>(ids: string[], schema?: BcsType<T, any>): Promise<(T | Error)[]>;
10
11
  loadManyOrThrow<T>(ids: string[], schema: BcsType<T, any>): Promise<T[]>;
@@ -32,7 +32,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
33
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
34
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
36
35
  var object_loader_exports = {};
37
36
  __export(object_loader_exports, {
38
37
  SuiObjectDataLoader: () => SuiObjectDataLoader
@@ -42,36 +41,21 @@ var import_bcs = require("@mysten/sui/bcs");
42
41
  var import_utils = require("@mysten/sui/utils");
43
42
  var import_dataloader = __toESM(require("dataloader"));
44
43
  var import_dynamic_field = require("../contracts/deps/0x0000000000000000000000000000000000000000000000000000000000000002/dynamic_field.js");
45
- var _dynamicFieldCache, _SuiObjectDataLoader_instances, getObjectFromResponse_fn;
44
+ var _dynamicFieldCache;
46
45
  class SuiObjectDataLoader extends import_dataloader.default {
47
46
  constructor(suiClient) {
48
- super(
49
- async (ids) => {
50
- const objects = await suiClient.multiGetObjects({
51
- ids,
52
- options: {
53
- showType: true,
54
- showBcs: true
55
- }
56
- });
57
- return objects.map((object, i) => {
58
- return __privateMethod(this, _SuiObjectDataLoader_instances, getObjectFromResponse_fn).call(this, ids[i], object);
59
- });
60
- },
61
- {
62
- maxBatchSize: 50
63
- }
64
- );
65
- __privateAdd(this, _SuiObjectDataLoader_instances);
47
+ super(async (ids) => {
48
+ const { objects } = await suiClient.core.getObjects({
49
+ objectIds: ids
50
+ });
51
+ return objects;
52
+ });
66
53
  __privateAdd(this, _dynamicFieldCache, /* @__PURE__ */ new Map());
67
54
  }
68
55
  async load(id, schema) {
69
56
  const data = await super.load(id);
70
57
  if (schema) {
71
- if (data.bcs?.dataType !== "moveObject") {
72
- throw new Error(`Object ${id} is not a move object`);
73
- }
74
- return schema.fromBase64(data.bcs.bcsBytes);
58
+ return schema.parse(data.content);
75
59
  }
76
60
  return data;
77
61
  }
@@ -80,14 +64,11 @@ class SuiObjectDataLoader extends import_dataloader.default {
80
64
  if (!schema) {
81
65
  return data;
82
66
  }
83
- return data.map((d, i) => {
67
+ return data.map((d) => {
84
68
  if (d instanceof Error) {
85
69
  return d;
86
70
  }
87
- if (d.bcs?.dataType !== "moveObject") {
88
- return new Error(`Object ${ids[i]} is not a move object`);
89
- }
90
- return schema.fromBase64(d.bcs.bcsBytes);
71
+ return schema.parse(d.content);
91
72
  });
92
73
  }
93
74
  async loadManyOrThrow(ids, schema) {
@@ -114,11 +95,4 @@ class SuiObjectDataLoader extends import_dataloader.default {
114
95
  }
115
96
  }
116
97
  _dynamicFieldCache = new WeakMap();
117
- _SuiObjectDataLoader_instances = new WeakSet();
118
- getObjectFromResponse_fn = function(id, response) {
119
- if (response.error || !response.data) {
120
- throw new Error(`Failed to fetch object ${id}: ${response.error}`);
121
- }
122
- return response.data;
123
- };
124
98
  //# sourceMappingURL=object-loader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/object-loader.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/bcs';\nimport { pureBcsSchemaFromTypeName } from '@mysten/sui/bcs';\nimport type { PureTypeName, ShapeFromPureTypeName } from '@mysten/sui/bcs';\nimport type { SuiClient, SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';\nimport { deriveDynamicFieldID } from '@mysten/sui/utils';\nimport DataLoader from 'dataloader';\n\nimport { Field } from '../contracts/deps/0x0000000000000000000000000000000000000000000000000000000000000002/dynamic_field.js';\n\nexport class SuiObjectDataLoader extends DataLoader<string, SuiObjectData> {\n\t#dynamicFieldCache = new Map<string, Map<string, SuiObjectData>>();\n\tconstructor(suiClient: SuiClient) {\n\t\tsuper(\n\t\t\tasync (ids: readonly string[]) => {\n\t\t\t\tconst objects = await suiClient.multiGetObjects({\n\t\t\t\t\tids: ids as string[],\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tshowType: true,\n\t\t\t\t\t\tshowBcs: true,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\treturn objects.map((object, i) => {\n\t\t\t\t\treturn this.#getObjectFromResponse(ids[i], object);\n\t\t\t\t});\n\t\t\t},\n\t\t\t{\n\t\t\t\tmaxBatchSize: 50,\n\t\t\t},\n\t\t);\n\t}\n\n\toverride async load<T = SuiObjectData>(id: string, schema?: BcsType<T, any>): Promise<T> {\n\t\tconst data = await super.load(id);\n\n\t\tif (schema) {\n\t\t\tif (data.bcs?.dataType !== 'moveObject') {\n\t\t\t\tthrow new Error(`Object ${id} is not a move object`);\n\t\t\t}\n\n\t\t\treturn schema.fromBase64(data.bcs.bcsBytes);\n\t\t}\n\n\t\treturn data as T;\n\t}\n\n\toverride async loadMany<T = SuiObjectData>(\n\t\tids: string[],\n\t\tschema?: BcsType<T, any>,\n\t): Promise<(T | Error)[]> {\n\t\tconst data = await super.loadMany(ids);\n\n\t\tif (!schema) {\n\t\t\treturn data as (T | Error)[];\n\t\t}\n\n\t\treturn data.map((d, i) => {\n\t\t\tif (d instanceof Error) {\n\t\t\t\treturn d;\n\t\t\t}\n\n\t\t\tif (d.bcs?.dataType !== 'moveObject') {\n\t\t\t\treturn new Error(`Object ${ids[i]} is not a move object`);\n\t\t\t}\n\n\t\t\treturn schema.fromBase64(d.bcs.bcsBytes);\n\t\t});\n\t}\n\n\tasync loadManyOrThrow<T>(ids: string[], schema: BcsType<T, any>): Promise<T[]> {\n\t\tconst data = await this.loadMany(ids, schema);\n\n\t\tfor (const d of data) {\n\t\t\tif (d instanceof Error) {\n\t\t\t\tthrow d;\n\t\t\t}\n\t\t}\n\n\t\treturn data as T[];\n\t}\n\n\toverride clearAll() {\n\t\tthis.#dynamicFieldCache.clear();\n\t\treturn super.clearAll();\n\t}\n\n\toverride clear(key: string) {\n\t\tthis.#dynamicFieldCache.delete(key);\n\t\treturn super.clear(key);\n\t}\n\n\t#getObjectFromResponse(id: string, response: SuiObjectResponse) {\n\t\tif (response.error || !response.data) {\n\t\t\tthrow new Error(`Failed to fetch object ${id}: ${response.error}`);\n\t\t}\n\n\t\treturn response.data;\n\t}\n\n\tasync loadFieldObject<K extends PureTypeName, T>(\n\t\tparent: string,\n\t\tname: {\n\t\t\ttype: K;\n\t\t\tvalue: ShapeFromPureTypeName<K>;\n\t\t},\n\t\ttype: BcsType<T, any>,\n\t): Promise<T> {\n\t\tconst schema = pureBcsSchemaFromTypeName<K>(name.type as never);\n\t\tconst id = deriveDynamicFieldID(parent, 'u64', schema.serialize(name.value).toBytes());\n\n\t\treturn (await this.load(id, Field(schema, type))).value;\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAA0C;AAG1C,mBAAqC;AACrC,wBAAuB;AAEvB,2BAAsB;AAVtB;AAYO,MAAM,4BAA4B,kBAAAA,QAAkC;AAAA,EAE1E,YAAY,WAAsB;AACjC;AAAA,MACC,OAAO,QAA2B;AACjC,cAAM,UAAU,MAAM,UAAU,gBAAgB;AAAA,UAC/C;AAAA,UACA,SAAS;AAAA,YACR,UAAU;AAAA,YACV,SAAS;AAAA,UACV;AAAA,QACD,CAAC;AAED,eAAO,QAAQ,IAAI,CAAC,QAAQ,MAAM;AACjC,iBAAO,sBAAK,0DAAL,WAA4B,IAAI,CAAC,GAAG;AAAA,QAC5C,CAAC;AAAA,MACF;AAAA,MACA;A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Q,OAAO,OAAO,UAAU,KAAK,KAAK,EAAE,QAAQ,CAAC;AAErF,YAAQ,MAAM,KAAK,KAAK,QAAI,4BAAM,QAAQ,IAAI,CAAC,GAAG;AAAA,EACnD;AACD;AAtGC;AADM;AAkFN,2BAAsB,SAAC,IAAY,UAA6B;AAC/D,MAAI,SAAS,SAAS,CAAC,SAAS,MAAM;AACrC,UAAM,IAAI,MAAM,0BAA0B,EAAE,KAAK,SAAS,KAAK,EAAE;AAAA,EAClE;AAEA,SAAO,SAAS;AACjB;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/bcs';\nimport { pureBcsSchemaFromTypeName } from '@mysten/sui/bcs';\nimport type { PureTypeName, ShapeFromPureTypeName } from '@mysten/sui/bcs';\nimport type { SuiObjectData } from '@mysten/sui/client';\nimport type {\n\tExperimental_BaseClient,\n\tExperimental_SuiClientTypes,\n} from '@mysten/sui/experimental';\nimport { deriveDynamicFieldID } from '@mysten/sui/utils';\nimport DataLoader from 'dataloader';\n\nimport { Field } from '../contracts/deps/0x0000000000000000000000000000000000000000000000000000000000000002/dynamic_field.js';\n\nexport class SuiObjectDataLoader extends DataLoader<\n\tstring,\n\tExperimental_SuiClientTypes.ObjectResponse\n> {\n\t#dynamicFieldCache = new Map<string, Map<string, Experimental_SuiClientTypes.ObjectResponse>>();\n\tconstructor(suiClient: Experimental_BaseClient) {\n\t\tsuper(async (ids: readonly string[]) => {\n\t\t\tconst { objects } = await suiClient.core.getObjects({\n\t\t\t\tobjectIds: ids as string[],\n\t\t\t});\n\n\t\t\treturn objects;\n\t\t});\n\t}\n\n\toverride async load<T = SuiObjectData>(id: string, schema?: BcsType<T, any>): Promise<T> {\n\t\tconst data = await super.load(id);\n\n\t\tif (schema) {\n\t\t\treturn schema.parse(data.content);\n\t\t}\n\n\t\treturn data as T;\n\t}\n\n\toverride async loadMany<T = SuiObjectData>(\n\t\tids: string[],\n\t\tschema?: BcsType<T, any>,\n\t): Promise<(T | Error)[]> {\n\t\tconst data = await super.loadMany(ids);\n\n\t\tif (!schema) {\n\t\t\treturn data as (T | Error)[];\n\t\t}\n\n\t\treturn data.map((d) => {\n\t\t\tif (d instanceof Error) {\n\t\t\t\treturn d;\n\t\t\t}\n\n\t\t\treturn schema.parse(d.content);\n\t\t});\n\t}\n\n\tasync loadManyOrThrow<T>(ids: string[], schema: BcsType<T, any>): Promise<T[]> {\n\t\tconst data = await this.loadMany(ids, schema);\n\n\t\tfor (const d of data) {\n\t\t\tif (d instanceof Error) {\n\t\t\t\tthrow d;\n\t\t\t}\n\t\t}\n\n\t\treturn data as T[];\n\t}\n\n\toverride clearAll() {\n\t\tthis.#dynamicFieldCache.clear();\n\t\treturn super.clearAll();\n\t}\n\n\toverride clear(key: string) {\n\t\tthis.#dynamicFieldCache.delete(key);\n\t\treturn super.clear(key);\n\t}\n\n\tasync loadFieldObject<K extends PureTypeName, T>(\n\t\tparent: string,\n\t\tname: {\n\t\t\ttype: K;\n\t\t\tvalue: ShapeFromPureTypeName<K>;\n\t\t},\n\t\ttype: BcsType<T, any>,\n\t): Promise<T> {\n\t\tconst schema = pureBcsSchemaFromTypeName<K>(name.type as never);\n\t\tconst id = deriveDynamicFieldID(parent, 'u64', schema.serialize(name.value).toBytes());\n\n\t\treturn (await this.load(id, Field(schema, type))).value;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAA0C;AAO1C,mBAAqC;AACrC,wBAAuB;AAEvB,2BAAsB;AAdtB;AAgBO,MAAM,4BAA4B,kBAAAA,QAGvC;AAAA,EAED,YAAY,WAAoC;AAC/C,UAAM,OAAO,QAA2B;AACvC,YAAM,EAAE,QAAQ,IAAI,MAAM,UAAU,KAAK,WAAW;AAAA,QACnD,WAAW;AAAA,MACZ,CAAC;AAED,aAAO;AAAA,IACR,CAAC;AARF,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import type { ClientWithExtensions } from '@mysten/sui/experimental';
2
4
  import { Transaction } from '@mysten/sui/transactions';
3
5
  import { Blob } from './contracts/blob.js';
4
6
  import type { BlobStatus } from './storage-node/types.js';
5
- import type { CertifyBlobOptions, DeleteBlobOptions, ExtendBlobOptions, GetBlobMetadataOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageWithSizeOptions, WalrusClientConfig, WriteBlobAttributesOptions, WriteBlobOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteMetadataOptions, WriteSliverOptions, WriteSliversToNodeOptions } from './types.js';
7
+ import type { CertifyBlobOptions, DeleteBlobOptions, ExtendBlobOptions, GetBlobMetadataOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageWithSizeOptions, WalrusClientConfig, WalrusClientExtensionOptions, WriteBlobAttributesOptions, WriteBlobOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteMetadataOptions, WriteSliverOptions, WriteSliversToNodeOptions } from './types.js';
6
8
  export declare class WalrusClient {
7
9
  #private;
8
10
  constructor(config: WalrusClientConfig);
11
+ static experimental_asClientExtension({ packageConfig, network, ...options }?: WalrusClientExtensionOptions): {
12
+ name: "walrus";
13
+ register: (client: ClientWithExtensions<{
14
+ jsonRpc: SuiClient;
15
+ }>) => WalrusClient;
16
+ };
9
17
  /** The Move type for a Blob object */
10
- getBlobType: () => string | Promise<string>;
18
+ getBlobType(): string | Promise<string>;
11
19
  /** The cached system object for the walrus package */
12
20
  systemObject(): Promise<{
13
21
  id: {