@mysten/walrus 0.7.4 → 0.8.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.
@@ -1,6 +1,5 @@
1
- import type { SuiClient } from '@mysten/sui/client';
2
1
  import type { Signer } from '@mysten/sui/cryptography';
3
- import type { ClientWithExtensions } from '@mysten/sui/experimental';
2
+ import type { ClientWithCoreApi } from '@mysten/sui/experimental';
4
3
  import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
4
  import type { StorageNodeInfo } from './contracts/walrus/storage_node.js';
6
5
  import type { RequestOptions, StorageNodeClientOptions } from './storage-node/client.js';
@@ -22,9 +21,7 @@ export interface WalrusPackageConfig {
22
21
  exchangeIds?: string[];
23
22
  }
24
23
  type SuiClientOrRpcUrl = {
25
- suiClient: ClientWithExtensions<{
26
- jsonRpc: SuiClient;
27
- }>;
24
+ suiClient: ClientWithCoreApi;
28
25
  suiRpcUrl?: never;
29
26
  } | {
30
27
  suiRpcUrl: string;
@@ -66,6 +63,11 @@ interface BaseWalrusClientConfig {
66
63
  * This is used to configure the Walrus client to use a specific storage node client options, network, and Sui client or RPC URL.
67
64
  */
68
65
  export type WalrusClientConfig = BaseWalrusClientConfig & WalrusNetworkOrPackageConfig & SuiClientOrRpcUrl;
66
+ export type WalrusOptions<Name = 'walrus'> = BaseWalrusClientConfig & {
67
+ packageConfig?: WalrusPackageConfig;
68
+ network?: 'mainnet' | 'testnet';
69
+ name?: Name;
70
+ };
69
71
  export type WalrusClientExtensionOptions = BaseWalrusClientConfig & {
70
72
  packageConfig?: WalrusPackageConfig;
71
73
  network?: 'mainnet' | 'testnet';
@@ -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 { ClientWithExtensions } from '@mysten/sui/experimental';\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/walrus/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';\nimport type { UploadRelayClientOptions } from './upload-relay/client.js';\nimport type { WalrusFile } from './files/file.js';\nimport type { Blob } from './contracts/walrus/blob.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\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\nexport type TipStrategy =\n\t| {\n\t\t\tconst: number | bigint;\n\t }\n\t| {\n\t\t\tlinear: {\n\t\t\t\tbase: number | bigint;\n\t\t\t\tperEncodedKib: number | bigint;\n\t\t\t};\n\t };\n\nexport type UploadRelayTipConfig = {\n\taddress: string;\n\tmax?: number;\n\tkind: TipStrategy;\n};\n\nexport interface UploadRelayConfig extends UploadRelayClientOptions {\n\tsendTip?:\n\t\t| null\n\t\t| UploadRelayTipConfig\n\t\t| {\n\t\t\t\tmax: number;\n\t\t };\n}\n\ninterface BaseWalrusClientConfig {\n\tstorageNodeClientOptions?: StorageNodeClientOptions;\n\twasmUrl?: string;\n\tuploadRelay?: UploadRelayConfig;\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: (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/** 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 type CertifyBlobOptions = {\n\tblobId: string;\n\tblobObjectId: string;\n\tdeletable: boolean;\n} & (\n\t| {\n\t\t\t/** An array of confirmations.\n\t\t\t * These confirmations must be provided in the same order as the nodes in the committee.\n\t\t\t * For nodes that have not provided a confirmation you can pass `null` */\n\t\t\tconfirmations: (StorageConfirmation | null)[];\n\t\t\tcertificate?: never;\n\t }\n\t| {\n\t\t\tcertificate: ProtocolMessageCertificate;\n\t\t\tconfirmations?: never;\n\t }\n);\n\nexport type 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 interface GetSecondarySliverOptions extends WalrusClientRequestOptions {\n\tblobId: string;\n\tindex: number;\n}\n\nexport type GetVerifiedBlobStatusOptions = ReadBlobOptions;\n\nexport type ComputeBlobMetadataOptions = {\n\tbytes: Uint8Array;\n\tnumShards?: number;\n};\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 WriteBlobToUploadRelayOptions = {\n\tblobId: string;\n\tblob: Uint8Array;\n\tnonce: Uint8Array;\n\ttxDigest: string;\n\tblobObjectId: string;\n\tdeletable: boolean;\n\tencodingType?: EncodingType;\n} & WalrusClientRequestOptions;\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 WriteQuiltOptions extends Omit<WriteBlobOptions, 'blob'> {\n\tblobs: {\n\t\tcontents: Uint8Array;\n\t\tidentifier: string;\n\t\ttags?: Record<string, string>;\n\t}[];\n}\n\nexport interface WriteFilesOptions extends Omit<WriteBlobOptions, 'blob'> {\n\tfiles: WalrusFile[];\n}\n\nexport interface WriteFilesFlowOptions {\n\tfiles: WalrusFile[];\n}\n\nexport interface WriteFilesFlowRegisterOptions extends Omit<WriteBlobOptions, 'blob' | 'signer'> {\n\towner: string;\n}\n\nexport interface WriteFilesFlowUploadOptions {\n\tdigest: string;\n}\n\nexport interface WriteFilesFlow {\n\tencode: () => Promise<void>;\n\tregister: (options: WriteFilesFlowRegisterOptions) => Transaction;\n\tupload: (options: WriteFilesFlowUploadOptions) => Promise<void>;\n\tcertify: () => Transaction;\n\tlistFiles: () => Promise<\n\t\t{\n\t\t\tid: string;\n\t\t\tblobId: string;\n\t\t\tblobObject: (typeof Blob)['$inferType'];\n\t\t}[]\n\t>;\n}\n\nexport interface WriteBlobFlowOptions {\n\tblob: Uint8Array;\n}\n\nexport interface WriteBlobFlowRegisterOptions extends Omit<WriteBlobOptions, 'blob' | 'signer'> {\n\towner: string;\n}\n\nexport interface WriteBlobFlowUploadOptions {\n\tdigest: string;\n}\n\nexport interface WriteBlobFlow {\n\tencode: () => Promise<void>;\n\tregister: (options: WriteBlobFlowRegisterOptions) => Transaction;\n\tupload: (options: WriteBlobFlowUploadOptions) => Promise<void>;\n\tcertify: () => Transaction;\n\tgetBlob: () => Promise<{\n\t\tblobId: string;\n\t\tblobObject: (typeof Blob)['$inferType'];\n\t}>;\n}\n\nexport interface DeleteBlobOptions {\n\tblobObjectId: string;\n}\n\nexport type ExtendBlobOptions = {\n\tblobObjectId: 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\nexport interface ProtocolMessageCertificate {\n\tsigners: number[];\n\tserializedMessage: Uint8Array;\n\tsignature: Uint8Array;\n}\n"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { ClientWithCoreApi } from '@mysten/sui/experimental';\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/walrus/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';\nimport type { UploadRelayClientOptions } from './upload-relay/client.js';\nimport type { WalrusFile } from './files/file.js';\nimport type { Blob } from './contracts/walrus/blob.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\texchangeIds?: string[];\n}\n\ntype SuiClientOrRpcUrl =\n\t| {\n\t\t\tsuiClient: ClientWithCoreApi;\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\nexport type TipStrategy =\n\t| {\n\t\t\tconst: number | bigint;\n\t }\n\t| {\n\t\t\tlinear: {\n\t\t\t\tbase: number | bigint;\n\t\t\t\tperEncodedKib: number | bigint;\n\t\t\t};\n\t };\n\nexport type UploadRelayTipConfig = {\n\taddress: string;\n\tmax?: number;\n\tkind: TipStrategy;\n};\n\nexport interface UploadRelayConfig extends UploadRelayClientOptions {\n\tsendTip?:\n\t\t| null\n\t\t| UploadRelayTipConfig\n\t\t| {\n\t\t\t\tmax: number;\n\t\t };\n}\n\ninterface BaseWalrusClientConfig {\n\tstorageNodeClientOptions?: StorageNodeClientOptions;\n\twasmUrl?: string;\n\tuploadRelay?: UploadRelayConfig;\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 WalrusOptions<Name = 'walrus'> = BaseWalrusClientConfig & {\n\tpackageConfig?: WalrusPackageConfig;\n\tnetwork?: 'mainnet' | 'testnet';\n\tname?: Name;\n};\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: (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/** 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 type CertifyBlobOptions = {\n\tblobId: string;\n\tblobObjectId: string;\n\tdeletable: boolean;\n} & (\n\t| {\n\t\t\t/** An array of confirmations.\n\t\t\t * These confirmations must be provided in the same order as the nodes in the committee.\n\t\t\t * For nodes that have not provided a confirmation you can pass `null` */\n\t\t\tconfirmations: (StorageConfirmation | null)[];\n\t\t\tcertificate?: never;\n\t }\n\t| {\n\t\t\tcertificate: ProtocolMessageCertificate;\n\t\t\tconfirmations?: never;\n\t }\n);\n\nexport type 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 interface GetSecondarySliverOptions extends WalrusClientRequestOptions {\n\tblobId: string;\n\tindex: number;\n}\n\nexport type GetVerifiedBlobStatusOptions = ReadBlobOptions;\n\nexport type ComputeBlobMetadataOptions = {\n\tbytes: Uint8Array;\n\tnumShards?: number;\n};\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 WriteBlobToUploadRelayOptions = {\n\tblobId: string;\n\tblob: Uint8Array;\n\tnonce: Uint8Array;\n\ttxDigest: string;\n\tblobObjectId: string;\n\tdeletable: boolean;\n\tencodingType?: EncodingType;\n} & WalrusClientRequestOptions;\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 WriteQuiltOptions extends Omit<WriteBlobOptions, 'blob'> {\n\tblobs: {\n\t\tcontents: Uint8Array;\n\t\tidentifier: string;\n\t\ttags?: Record<string, string>;\n\t}[];\n}\n\nexport interface WriteFilesOptions extends Omit<WriteBlobOptions, 'blob'> {\n\tfiles: WalrusFile[];\n}\n\nexport interface WriteFilesFlowOptions {\n\tfiles: WalrusFile[];\n}\n\nexport interface WriteFilesFlowRegisterOptions extends Omit<WriteBlobOptions, 'blob' | 'signer'> {\n\towner: string;\n}\n\nexport interface WriteFilesFlowUploadOptions {\n\tdigest: string;\n}\n\nexport interface WriteFilesFlow {\n\tencode: () => Promise<void>;\n\tregister: (options: WriteFilesFlowRegisterOptions) => Transaction;\n\tupload: (options: WriteFilesFlowUploadOptions) => Promise<void>;\n\tcertify: () => Transaction;\n\tlistFiles: () => Promise<\n\t\t{\n\t\t\tid: string;\n\t\t\tblobId: string;\n\t\t\tblobObject: (typeof Blob)['$inferType'];\n\t\t}[]\n\t>;\n}\n\nexport interface WriteBlobFlowOptions {\n\tblob: Uint8Array;\n}\n\nexport interface WriteBlobFlowRegisterOptions extends Omit<WriteBlobOptions, 'blob' | 'signer'> {\n\towner: string;\n}\n\nexport interface WriteBlobFlowUploadOptions {\n\tdigest: string;\n}\n\nexport interface WriteBlobFlow {\n\tencode: () => Promise<void>;\n\tregister: (options: WriteBlobFlowRegisterOptions) => Transaction;\n\tupload: (options: WriteBlobFlowUploadOptions) => Promise<void>;\n\tcertify: () => Transaction;\n\tgetBlob: () => Promise<{\n\t\tblobId: string;\n\t\tblobObject: (typeof Blob)['$inferType'];\n\t}>;\n}\n\nexport interface DeleteBlobOptions {\n\tblobObjectId: string;\n}\n\nexport type ExtendBlobOptions = {\n\tblobObjectId: 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\nexport interface ProtocolMessageCertificate {\n\tsigners: number[];\n\tserializedMessage: Uint8Array;\n\tsignature: Uint8Array;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -116,9 +116,7 @@ export declare const BlobMetadataWithId: import("@mysten/sui/bcs").BcsStruct<{
116
116
  }, string>;
117
117
  export declare const SliverData: import("@mysten/sui/bcs").BcsStruct<{
118
118
  symbols: import("@mysten/sui/bcs").BcsStruct<{
119
- data: BcsType<number[], Iterable<number> & {
120
- length: number;
121
- }, string>;
119
+ data: BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
122
120
  symbol_size: BcsType<number, number, "u16">;
123
121
  }, string>;
124
122
  index: BcsType<number, number, "u16">;
@@ -126,18 +124,14 @@ export declare const SliverData: import("@mysten/sui/bcs").BcsStruct<{
126
124
  export declare const Sliver: import("@mysten/sui/bcs").BcsEnum<{
127
125
  Primary: import("@mysten/sui/bcs").BcsStruct<{
128
126
  symbols: import("@mysten/sui/bcs").BcsStruct<{
129
- data: BcsType<number[], Iterable<number> & {
130
- length: number;
131
- }, string>;
127
+ data: BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
132
128
  symbol_size: BcsType<number, number, "u16">;
133
129
  }, string>;
134
130
  index: BcsType<number, number, "u16">;
135
131
  }, string>;
136
132
  Secondary: import("@mysten/sui/bcs").BcsStruct<{
137
133
  symbols: import("@mysten/sui/bcs").BcsStruct<{
138
- data: BcsType<number[], Iterable<number> & {
139
- length: number;
140
- }, string>;
134
+ data: BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
141
135
  symbol_size: BcsType<number, number, "u16">;
142
136
  }, string>;
143
137
  index: BcsType<number, number, "u16">;
@@ -146,18 +140,14 @@ export declare const Sliver: import("@mysten/sui/bcs").BcsEnum<{
146
140
  export declare const SliverPair: import("@mysten/sui/bcs").BcsStruct<{
147
141
  primary: import("@mysten/sui/bcs").BcsStruct<{
148
142
  symbols: import("@mysten/sui/bcs").BcsStruct<{
149
- data: BcsType<number[], Iterable<number> & {
150
- length: number;
151
- }, string>;
143
+ data: BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
152
144
  symbol_size: BcsType<number, number, "u16">;
153
145
  }, string>;
154
146
  index: BcsType<number, number, "u16">;
155
147
  }, string>;
156
148
  secondary: import("@mysten/sui/bcs").BcsStruct<{
157
149
  symbols: import("@mysten/sui/bcs").BcsStruct<{
158
- data: BcsType<number[], Iterable<number> & {
159
- length: number;
160
- }, string>;
150
+ data: BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
161
151
  symbol_size: BcsType<number, number, "u16">;
162
152
  }, string>;
163
153
  index: BcsType<number, number, "u16">;
@@ -85,7 +85,7 @@ const BlobMetadataWithId = import_bcs.bcs.struct("BlobMetadataWithId", {
85
85
  metadata: BlobMetadata
86
86
  });
87
87
  const Symbols = import_bcs.bcs.struct("Symbols", {
88
- data: import_bcs.bcs.vector(import_bcs.bcs.u8()),
88
+ data: import_bcs.bcs.byteVector(),
89
89
  symbol_size: import_bcs.bcs.u16()
90
90
  });
91
91
  const SliverData = import_bcs.bcs.struct("SliverData", {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/bcs.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/sui/bcs';\nimport { bcs } from '@mysten/sui/bcs';\n\nconst MerkleNode = bcs.enum('MerkleNode', {\n\tEmpty: null,\n\tDigest: bcs.bytes(32),\n});\n\nconst SliverPairMetadata = bcs.struct('SliverPairMetadata', {\n\tprimary_hash: MerkleNode,\n\tsecondary_hash: MerkleNode,\n});\n\nexport const EncodingType = bcs\n\t.enum('EncodingType', {\n\t\tRedStuff: null,\n\t\tRS2: null,\n\t})\n\t.transform({\n\t\tinput: (\n\t\t\tencodingType:\n\t\t\t\t| { RedStuff: boolean | object | null }\n\t\t\t\t| { RS2: boolean | object | null }\n\t\t\t\t| 'RedStuff'\n\t\t\t\t| 'RS2',\n\t\t) =>\n\t\t\ttypeof encodingType === 'string'\n\t\t\t\t? ({ [encodingType]: null } as Exclude<typeof encodingType, string>)\n\t\t\t\t: encodingType,\n\t\toutput: (encodingType) => encodingType,\n\t});\n\nexport const BlobMetadataV1 = bcs.struct('BlobMetadataV1', {\n\tencoding_type: EncodingType,\n\tunencoded_length: bcs.u64(),\n\thashes: bcs.vector(SliverPairMetadata),\n});\n\nexport const BlobMetadata = bcs.enum('BlobMetadata', {\n\tV1: BlobMetadataV1,\n});\n\nexport const BlobId = bcs.u256().transform({\n\tinput: (blobId: string | bigint) => (typeof blobId === 'string' ? blobIdToInt(blobId) : blobId),\n\toutput: (id: string) => blobIdFromInt(id),\n});\n\nexport function blobIdFromInt(blobId: bigint | string): string {\n\treturn bcs\n\t\t.u256()\n\t\t.serialize(blobId)\n\t\t.toBase64()\n\t\t.replace(/=*$/, '')\n\t\t.replaceAll('+', '-')\n\t\t.replaceAll('/', '_');\n}\n\nexport function blobIdFromBytes(blobId: Uint8Array): string {\n\treturn blobIdFromInt(bcs.u256().parse(blobId));\n}\n\nexport function blobIdToInt(blobId: string): bigint {\n\treturn BigInt(bcs.u256().fromBase64(blobId.replaceAll('-', '+').replaceAll('_', '/')));\n}\n\nexport const BlobMetadataWithId = bcs.struct('BlobMetadataWithId', {\n\tblobId: BlobId,\n\tmetadata: BlobMetadata,\n});\n\nconst Symbols = bcs.struct('Symbols', {\n\tdata: bcs.vector(bcs.u8()),\n\tsymbol_size: bcs.u16(),\n});\n\nexport const SliverData = bcs.struct('SliverData', {\n\tsymbols: Symbols,\n\tindex: bcs.u16(),\n});\n\nexport const Sliver = bcs.enum('Sliver', {\n\tPrimary: SliverData,\n\tSecondary: SliverData,\n});\n\nexport const SliverPair = bcs.struct('SliverPair', {\n\tprimary: SliverData,\n\tsecondary: SliverData,\n});\n\nexport enum IntentType {\n\tPROOF_OF_POSSESSION_MSG = 0,\n\tBLOB_CERT_MSG = 1,\n\tINVALID_BLOB_ID_MSG = 2,\n\tSYNC_SHARD_MSG = 3,\n}\n\nexport const Intent = bcs\n\t.struct('Intent', {\n\t\ttype: bcs.u8().transform({\n\t\t\tinput: (type: IntentType) => type,\n\t\t\toutput: (type: number) => type as IntentType,\n\t\t}),\n\t\tversion: bcs.u8(),\n\t\tappId: bcs.u8(),\n\t})\n\t.transform({\n\t\tinput: (intent: IntentType) => ({\n\t\t\ttype: intent,\n\t\t\tversion: 0,\n\t\t\tappId: 3,\n\t\t}),\n\t\toutput: (intent) => intent.type,\n\t});\n\nexport function ProtocolMessage<T extends BcsType<any>>(messageContents: T) {\n\treturn bcs.struct(`ProtocolMessage<${messageContents.name}>`, {\n\t\tintent: Intent,\n\t\tepoch: bcs.u32(),\n\t\tmessageContents,\n\t});\n}\n\nexport const BlobPersistenceType = bcs.enum('BlobPersistenceType', {\n\tPermanent: null,\n\tDeletable: bcs.struct('Deletable', {\n\t\tobjectId: bcs.Address,\n\t}),\n});\nexport const StorageConfirmationBody = bcs.struct('StorageConfirmationBody', {\n\tblobId: BlobId,\n\tblobType: BlobPersistenceType,\n});\n\nexport const StorageConfirmation = ProtocolMessage(StorageConfirmationBody);\n\nexport function Field<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn bcs.struct('Field', {\n\t\tid: bcs.Address,\n\t\tname: typeParameters[0],\n\t\tvalue: typeParameters[1],\n\t});\n}\n\nexport const QuiltPatchTags = bcs.map(bcs.string(), bcs.string()).transform({\n\t// tags is a BTreeMap, so we need to sort entries before serializing\n\tinput: (tags: Record<string, string> | Map<string, string>) =>\n\t\tnew Map(\n\t\t\t[...(tags instanceof Map ? tags : Object.entries(tags))].sort(([a], [b]) =>\n\t\t\t\t// TODO: sorting for map keys should be moved into @mysten/bcs\n\t\t\t\tcompareBcsBytes(bcs.string().serialize(a).toBytes(), bcs.string().serialize(b).toBytes()),\n\t\t\t),\n\t\t),\n\toutput: (tags: Map<string, string>) => Object.fromEntries(tags),\n});\n\nexport const QuiltPatchV1 = bcs.struct('QuiltPatchV1', {\n\tendIndex: bcs.u16(),\n\tidentifier: bcs.string(),\n\ttags: QuiltPatchTags,\n});\n\nfunction compareBcsBytes(a: Uint8Array, b: Uint8Array) {\n\t// sort by length first, because bcs bytes prefix length\n\tif (a.length !== b.length) {\n\t\treturn a.length - b.length;\n\t}\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) {\n\t\t\treturn a[i] - b[i];\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nexport const QuiltIndexV1 = bcs.struct('QuiltIndexV1', {\n\tpatches: bcs.vector(QuiltPatchV1),\n});\n\nexport const QuiltPatchId = bcs.struct('QuiltPatchId', {\n\tquiltId: BlobId,\n\tpatchId: bcs.struct('InternalQuiltPatchId', {\n\t\tversion: bcs.u8(),\n\t\tstartIndex: bcs.u16(),\n\t\tendIndex: bcs.u16(),\n\t}),\n});\n\nexport const QuiltPatchBlobHeader = bcs.struct('QuiltPatchBlobHeader', {\n\tversion: bcs.u8(),\n\tlength: bcs.u32(),\n\tmask: bcs.u8(),\n});\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAoB;AAEpB,MAAM,aAAa,eAAI,KAAK,cAAc;AAAA,EACzC,OAAO;AAAA,EACP,QAAQ,eAAI,MAAM,EAAE;AACrB,CAAC;AAED,MAAM,qBAAqB,eAAI,OAAO,sBAAsB;AAAA,EAC3D,cAAc;AAAA,EACd,gBAAgB;AACjB,CAAC;AAEM,MAAM,eAAe,eAC1B,KAAK,gBAAgB;AAAA,EACrB,UAAU;AAAA,EACV,KAAK;AACN,CAAC,EACA,UAAU;AAAA,EACV,OAAO,CACN,iBAMA,OAAO,iBAAiB,WACpB,EAAE,CAAC,YAAY,GAAG,KAAK,IACxB;AAAA,EACJ,QAAQ,CAAC,iBAAiB;AAC3B,CAAC;AAEK,MAAM,iBAAiB,eAAI,OAAO,kBAAkB;AAAA,EAC1D,eAAe;AAAA,EACf,kBAAkB,eAAI,IAAI;AAAA,EAC1B,QAAQ,eAAI,OAAO,kBAAkB;AACtC,CAAC;AAEM,MAAM,eAAe,eAAI,KAAK,gBAAgB;AAAA,EACpD,IAAI;AACL,CAAC;AAEM,MAAM,SAAS,eAAI,KAAK,EAAE,UAAU;AAAA,EAC1C,OAAO,CAAC,WAA6B,OAAO,WAAW,WAAW,YA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QAAQ,CAAC;AAAA;AAAA,IACzF;AAAA,EACD;AAAA,EACD,QAAQ,CAAC,SAA8B,OAAO,YAAY,IAAI;AAC/D,CAAC;AAEM,MAAM,eAAe,eAAI,OAAO,gBAAgB;AAAA,EACtD,UAAU,eAAI,IAAI;AAAA,EAClB,YAAY,eAAI,OAAO;AAAA,EACvB,MAAM;AACP,CAAC;AAED,SAAS,gBAAgB,GAAe,GAAe;AAEtD,MAAI,EAAE,WAAW,EAAE,QAAQ;AAC1B,WAAO,EAAE,SAAS,EAAE;AAAA,EACrB;AAEA,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AAClC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG;AAClB,aAAO,EAAE,CAAC,IAAI,EAAE,CAAC;AAAA,IAClB;AAAA,EACD;AAEA,SAAO;AACR;AAEO,MAAM,eAAe,eAAI,OAAO,gBAAgB;AAAA,EACtD,SAAS,eAAI,OAAO,YAAY;AACjC,CAAC;AAEM,MAAM,eAAe,eAAI,OAAO,gBAAgB;AAAA,EACtD,SAAS;AAAA,EACT,SAAS,eAAI,OAAO,wBAAwB;AAAA,IAC3C,SAAS,eAAI,GAAG;AAAA,IAChB,YAAY,eAAI,IAAI;AAAA,IACpB,UAAU,eAAI,IAAI;AAAA,EACnB,CAAC;AACF,CAAC;AAEM,MAAM,uBAAuB,eAAI,OAAO,wBAAwB;AAAA,EACtE,SAAS,eAAI,GAAG;AAAA,EAChB,QAAQ,eAAI,IAAI;AAAA,EAChB,MAAM,eAAI,GAAG;AACd,CAAC;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/sui/bcs';\nimport { bcs } from '@mysten/sui/bcs';\n\nconst MerkleNode = bcs.enum('MerkleNode', {\n\tEmpty: null,\n\tDigest: bcs.bytes(32),\n});\n\nconst SliverPairMetadata = bcs.struct('SliverPairMetadata', {\n\tprimary_hash: MerkleNode,\n\tsecondary_hash: MerkleNode,\n});\n\nexport const EncodingType = bcs\n\t.enum('EncodingType', {\n\t\tRedStuff: null,\n\t\tRS2: null,\n\t})\n\t.transform({\n\t\tinput: (\n\t\t\tencodingType:\n\t\t\t\t| { RedStuff: boolean | object | null }\n\t\t\t\t| { RS2: boolean | object | null }\n\t\t\t\t| 'RedStuff'\n\t\t\t\t| 'RS2',\n\t\t) =>\n\t\t\ttypeof encodingType === 'string'\n\t\t\t\t? ({ [encodingType]: null } as Exclude<typeof encodingType, string>)\n\t\t\t\t: encodingType,\n\t\toutput: (encodingType) => encodingType,\n\t});\n\nexport const BlobMetadataV1 = bcs.struct('BlobMetadataV1', {\n\tencoding_type: EncodingType,\n\tunencoded_length: bcs.u64(),\n\thashes: bcs.vector(SliverPairMetadata),\n});\n\nexport const BlobMetadata = bcs.enum('BlobMetadata', {\n\tV1: BlobMetadataV1,\n});\n\nexport const BlobId = bcs.u256().transform({\n\tinput: (blobId: string | bigint) => (typeof blobId === 'string' ? blobIdToInt(blobId) : blobId),\n\toutput: (id: string) => blobIdFromInt(id),\n});\n\nexport function blobIdFromInt(blobId: bigint | string): string {\n\treturn bcs\n\t\t.u256()\n\t\t.serialize(blobId)\n\t\t.toBase64()\n\t\t.replace(/=*$/, '')\n\t\t.replaceAll('+', '-')\n\t\t.replaceAll('/', '_');\n}\n\nexport function blobIdFromBytes(blobId: Uint8Array): string {\n\treturn blobIdFromInt(bcs.u256().parse(blobId));\n}\n\nexport function blobIdToInt(blobId: string): bigint {\n\treturn BigInt(bcs.u256().fromBase64(blobId.replaceAll('-', '+').replaceAll('_', '/')));\n}\n\nexport const BlobMetadataWithId = bcs.struct('BlobMetadataWithId', {\n\tblobId: BlobId,\n\tmetadata: BlobMetadata,\n});\n\nconst Symbols = bcs.struct('Symbols', {\n\tdata: bcs.byteVector(),\n\tsymbol_size: bcs.u16(),\n});\n\nexport const SliverData = bcs.struct('SliverData', {\n\tsymbols: Symbols,\n\tindex: bcs.u16(),\n});\n\nexport const Sliver = bcs.enum('Sliver', {\n\tPrimary: SliverData,\n\tSecondary: SliverData,\n});\n\nexport const SliverPair = bcs.struct('SliverPair', {\n\tprimary: SliverData,\n\tsecondary: SliverData,\n});\n\nexport enum IntentType {\n\tPROOF_OF_POSSESSION_MSG = 0,\n\tBLOB_CERT_MSG = 1,\n\tINVALID_BLOB_ID_MSG = 2,\n\tSYNC_SHARD_MSG = 3,\n}\n\nexport const Intent = bcs\n\t.struct('Intent', {\n\t\ttype: bcs.u8().transform({\n\t\t\tinput: (type: IntentType) => type,\n\t\t\toutput: (type: number) => type as IntentType,\n\t\t}),\n\t\tversion: bcs.u8(),\n\t\tappId: bcs.u8(),\n\t})\n\t.transform({\n\t\tinput: (intent: IntentType) => ({\n\t\t\ttype: intent,\n\t\t\tversion: 0,\n\t\t\tappId: 3,\n\t\t}),\n\t\toutput: (intent) => intent.type,\n\t});\n\nexport function ProtocolMessage<T extends BcsType<any>>(messageContents: T) {\n\treturn bcs.struct(`ProtocolMessage<${messageContents.name}>`, {\n\t\tintent: Intent,\n\t\tepoch: bcs.u32(),\n\t\tmessageContents,\n\t});\n}\n\nexport const BlobPersistenceType = bcs.enum('BlobPersistenceType', {\n\tPermanent: null,\n\tDeletable: bcs.struct('Deletable', {\n\t\tobjectId: bcs.Address,\n\t}),\n});\nexport const StorageConfirmationBody = bcs.struct('StorageConfirmationBody', {\n\tblobId: BlobId,\n\tblobType: BlobPersistenceType,\n});\n\nexport const StorageConfirmation = ProtocolMessage(StorageConfirmationBody);\n\nexport function Field<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn bcs.struct('Field', {\n\t\tid: bcs.Address,\n\t\tname: typeParameters[0],\n\t\tvalue: typeParameters[1],\n\t});\n}\n\nexport const QuiltPatchTags = bcs.map(bcs.string(), bcs.string()).transform({\n\t// tags is a BTreeMap, so we need to sort entries before serializing\n\tinput: (tags: Record<string, string> | Map<string, string>) =>\n\t\tnew Map(\n\t\t\t[...(tags instanceof Map ? tags : Object.entries(tags))].sort(([a], [b]) =>\n\t\t\t\t// TODO: sorting for map keys should be moved into @mysten/bcs\n\t\t\t\tcompareBcsBytes(bcs.string().serialize(a).toBytes(), bcs.string().serialize(b).toBytes()),\n\t\t\t),\n\t\t),\n\toutput: (tags: Map<string, string>) => Object.fromEntries(tags),\n});\n\nexport const QuiltPatchV1 = bcs.struct('QuiltPatchV1', {\n\tendIndex: bcs.u16(),\n\tidentifier: bcs.string(),\n\ttags: QuiltPatchTags,\n});\n\nfunction compareBcsBytes(a: Uint8Array, b: Uint8Array) {\n\t// sort by length first, because bcs bytes prefix length\n\tif (a.length !== b.length) {\n\t\treturn a.length - b.length;\n\t}\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) {\n\t\t\treturn a[i] - b[i];\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nexport const QuiltIndexV1 = bcs.struct('QuiltIndexV1', {\n\tpatches: bcs.vector(QuiltPatchV1),\n});\n\nexport const QuiltPatchId = bcs.struct('QuiltPatchId', {\n\tquiltId: BlobId,\n\tpatchId: bcs.struct('InternalQuiltPatchId', {\n\t\tversion: bcs.u8(),\n\t\tstartIndex: bcs.u16(),\n\t\tendIndex: bcs.u16(),\n\t}),\n});\n\nexport const QuiltPatchBlobHeader = bcs.struct('QuiltPatchBlobHeader', {\n\tversion: bcs.u8(),\n\tlength: bcs.u32(),\n\tmask: bcs.u8(),\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAoB;AAEpB,MAAM,aAAa,eAAI,KAAK,cAAc;AAAA,EACzC,OAAO;AAAA,EACP,QAAQ,eAAI,MAAM,EAAE;AACrB,CAAC;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AAe,eAAI,OAAO,gBAAgB;AAAA,EACtD,SAAS;AAAA,EACT,SAAS,eAAI,OAAO,wBAAwB;AAAA,IAC3C,SAAS,eAAI,GAAG;AAAA,IAChB,YAAY,eAAI,IAAI;AAAA,IACpB,UAAU,eAAI,IAAI;AAAA,EACnB,CAAC;AACF,CAAC;AAEM,MAAM,uBAAuB,eAAI,OAAO,wBAAwB;AAAA,EACtE,SAAS,eAAI,GAAG;AAAA,EAChB,QAAQ,eAAI,IAAI;AAAA,EAChB,MAAM,eAAI,GAAG;AACd,CAAC;",
6
6
  "names": ["IntentType"]
7
7
  }
@@ -1,21 +1,23 @@
1
- import { SuiClient } from '@mysten/sui/client';
2
1
  import type { Signer } from '@mysten/sui/cryptography';
3
- import type { ClientWithExtensions } from '@mysten/sui/experimental';
2
+ import type { ClientWithCoreApi } from '@mysten/sui/experimental';
4
3
  import type { TransactionResult } from '@mysten/sui/transactions';
5
4
  import { Transaction } from '@mysten/sui/transactions';
6
5
  import { Blob } from './contracts/walrus/blob.js';
7
6
  import type { BlobStatus } from './storage-node/types.js';
8
- import type { CertifyBlobOptions, ComputeBlobMetadataOptions, DeleteBlobOptions, ExtendBlobOptions, GetBlobMetadataOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ProtocolMessageCertificate, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageWithSizeOptions, WalrusClientConfig, WalrusClientExtensionOptions, WriteBlobAttributesOptions, WriteBlobOptions, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions, WriteFilesOptions, WriteFilesFlowOptions, WriteFilesFlow, WriteBlobFlow, WriteBlobFlowOptions } from './types.js';
7
+ import type { CertifyBlobOptions, ComputeBlobMetadataOptions, DeleteBlobOptions, ExtendBlobOptions, GetBlobMetadataOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ProtocolMessageCertificate, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageWithSizeOptions, WalrusClientConfig, WalrusClientExtensionOptions, WriteBlobAttributesOptions, WriteBlobOptions, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions, WriteFilesOptions, WriteFilesFlowOptions, WriteFilesFlow, WriteBlobFlow, WriteBlobFlowOptions, WalrusOptions } from './types.js';
9
8
  import { WalrusBlob } from './files/blob.js';
10
9
  import { WalrusFile } from './files/file.js';
10
+ export declare function walrus<const Name = 'walrus'>({ packageConfig, network, name, ...options }?: WalrusOptions<Name>): {
11
+ name: Name;
12
+ register: (client: ClientWithCoreApi) => WalrusClient;
13
+ };
11
14
  export declare class WalrusClient {
12
15
  #private;
13
16
  constructor(config: WalrusClientConfig);
17
+ /** @deprecated use `walrus()` instead */
14
18
  static experimental_asClientExtension({ packageConfig, network, ...options }?: WalrusClientExtensionOptions): {
15
19
  name: "walrus";
16
- register: (client: ClientWithExtensions<{
17
- jsonRpc: SuiClient;
18
- }>) => WalrusClient;
20
+ register: (client: ClientWithCoreApi) => WalrusClient;
19
21
  };
20
22
  /** The Move type for a Blob object */
21
23
  getBlobType(): string | Promise<string>;
@@ -191,21 +193,21 @@ export declare class WalrusClient {
191
193
  }>;
192
194
  getSecondarySliver: ({ blobId, index, signal }: GetSecondarySliverOptions) => Promise<{
193
195
  symbols: {
194
- data: number[];
196
+ data: Uint8Array<ArrayBufferLike>;
195
197
  symbol_size: number;
196
198
  };
197
199
  index: number;
198
200
  }>;
199
201
  internalGetSecondarySliver({ blobId, index, signal }: GetSecondarySliverOptions): Promise<{
200
202
  symbols: {
201
- data: number[];
203
+ data: Uint8Array<ArrayBufferLike>;
202
204
  symbol_size: number;
203
205
  };
204
206
  index: number;
205
207
  }>;
206
208
  getSlivers({ blobId, signal }: GetSliversOptions): Promise<{
207
209
  symbols: {
208
- data: number[];
210
+ data: Uint8Array<ArrayBufferLike>;
209
211
  symbol_size: number;
210
212
  };
211
213
  index: number;
@@ -67,8 +67,7 @@ import {
67
67
  sliverPairIndexFromSecondarySliverIndex,
68
68
  storageUnitsFromSize,
69
69
  toPairIndex,
70
- toShardIndex,
71
- toTypeString
70
+ toShardIndex
72
71
  } from "./utils/index.js";
73
72
  import { SuiObjectDataLoader } from "./utils/object-loader.js";
74
73
  import { shuffle, weightedShuffle } from "./utils/randomness.js";
@@ -82,6 +81,33 @@ import { WalrusFile } from "./files/file.js";
82
81
  import { QuiltFileReader } from "./files/readers/quilt-file.js";
83
82
  import { QuiltReader } from "./files/readers/quilt.js";
84
83
  import { retry } from "./utils/retry.js";
84
+ function walrus({
85
+ packageConfig,
86
+ network,
87
+ name = "walrus",
88
+ ...options
89
+ } = {}) {
90
+ return {
91
+ name,
92
+ register: (client) => {
93
+ const walrusNetwork = network || client.network;
94
+ if (walrusNetwork !== "mainnet" && walrusNetwork !== "testnet") {
95
+ throw new WalrusClientError("Walrus client only supports mainnet and testnet");
96
+ }
97
+ return new WalrusClient(
98
+ packageConfig ? {
99
+ packageConfig,
100
+ suiClient: client,
101
+ ...options
102
+ } : {
103
+ network: walrusNetwork,
104
+ suiClient: client,
105
+ ...options
106
+ }
107
+ );
108
+ }
109
+ };
110
+ }
85
111
  const _WalrusClient = class _WalrusClient {
86
112
  constructor(config) {
87
113
  __privateAdd(this, _WalrusClient_instances);
@@ -125,6 +151,7 @@ const _WalrusClient = class _WalrusClient {
125
151
  __privateSet(this, _objectLoader, new SuiObjectDataLoader(__privateGet(this, _suiClient)));
126
152
  __privateSet(this, _cache, __privateGet(this, _suiClient).cache.scope("@mysten/walrus"));
127
153
  }
154
+ /** @deprecated use `walrus()` instead */
128
155
  static experimental_asClientExtension({
129
156
  packageConfig,
130
157
  network,
@@ -1366,8 +1393,12 @@ const _WalrusClient = class _WalrusClient {
1366
1393
  async writeQuilt({ blobs, ...options }) {
1367
1394
  const encoded = await this.encodeQuilt({ blobs });
1368
1395
  const result = await this.writeBlob({
1396
+ ...options,
1369
1397
  blob: encoded.quilt,
1370
- ...options
1398
+ attributes: {
1399
+ _walrusBlobType: "quilt",
1400
+ ...options.attributes
1401
+ }
1371
1402
  });
1372
1403
  return {
1373
1404
  ...result,
@@ -1520,7 +1551,10 @@ const _WalrusClient = class _WalrusClient {
1520
1551
  blobId: metadata2.blobId,
1521
1552
  rootHash: metadata2.rootHash,
1522
1553
  deletable,
1523
- attributes
1554
+ attributes: {
1555
+ _walrusBlobType: "quilt",
1556
+ ...attributes
1557
+ }
1524
1558
  })
1525
1559
  ],
1526
1560
  owner
@@ -1786,21 +1820,18 @@ _WalrusClient_instances = new WeakSet();
1786
1820
  /** The Move type for a WAL coin */
1787
1821
  walType_fn = function() {
1788
1822
  return __privateGet(this, _cache).read(["walType"], async () => {
1789
- const stakedWal = await __privateGet(this, _suiClient).jsonRpc.getNormalizedMoveStruct({
1790
- package: await __privateMethod(this, _WalrusClient_instances, getPackageId_fn).call(this),
1791
- module: "staked_wal",
1792
- struct: "StakedWal"
1823
+ const stakeWithPool = await __privateGet(this, _suiClient).core.getMoveFunction({
1824
+ packageId: await __privateMethod(this, _WalrusClient_instances, getPackageId_fn).call(this),
1825
+ moduleName: "staking",
1826
+ name: "stake_with_pool"
1793
1827
  });
1794
- const balanceType = stakedWal.fields.find((field) => field.name === "principal")?.type;
1795
- if (!balanceType) {
1796
- throw new WalrusClientError("WAL type not found");
1797
- }
1798
- const parsed = parseStructTag(toTypeString(balanceType));
1799
- const coinType = parsed.typeParams[0];
1800
- if (!coinType) {
1828
+ const toStake = stakeWithPool.function.parameters[1];
1829
+ const toStakeCoin = toStake.body.$kind === "datatype" ? toStake.body.datatype : null;
1830
+ const toStakeCoinType = toStakeCoin?.typeParameters[0]?.$kind === "datatype" ? toStakeCoin.typeParameters[0] : null;
1831
+ if (toStakeCoinType?.$kind !== "datatype") {
1801
1832
  throw new WalrusClientError("WAL type not found");
1802
1833
  }
1803
- return normalizeStructTag(coinType);
1834
+ return normalizeStructTag(toStakeCoinType.datatype.typeName);
1804
1835
  });
1805
1836
  };
1806
1837
  getPackageId_fn = function() {
@@ -2051,6 +2082,7 @@ retryOnPossibleEpochChange_fn = function(fn) {
2051
2082
  };
2052
2083
  let WalrusClient = _WalrusClient;
2053
2084
  export {
2054
- WalrusClient
2085
+ WalrusClient,
2086
+ walrus
2055
2087
  };
2056
2088
  //# sourceMappingURL=client.js.map