import { StorageNodeInfo } from "./contracts/walrus/storage_node.mjs"; import { BlobMetadata } from "./utils/bcs.mjs"; import { StorageConfirmation, StoreBlobMetadataRequestInput, StoreSliverRequestInput, Uploadable } from "./storage-node/types.mjs"; import { RequestOptions, StorageNodeClientOptions } from "./storage-node/client.mjs"; import { UploadRelayClientOptions } from "./upload-relay/client.mjs"; import { WalrusFile } from "./files/file.mjs"; import { Blob } from "./contracts/walrus/blob.mjs"; import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions"; import { ClientWithCoreApi } from "@mysten/sui/client"; import { Signer } from "@mysten/sui/cryptography"; //#region src/types.d.ts /** * Configuration for the Walrus package on sui * * This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID. */ interface WalrusPackageConfig { /** The system object ID of the Walrus package */ systemObjectId: string; /** The staking pool ID of the Walrus package */ stakingPoolId: string; exchangeIds?: string[]; } type WalrusNetworkOrPackageConfig = { network: 'mainnet' | 'testnet'; packageConfig?: WalrusPackageConfig; } | { network?: never; packageConfig: WalrusPackageConfig; }; type TipStrategy = { const: number | bigint; } | { linear: { base: number | bigint; perEncodedKib: number | bigint; }; }; type UploadRelayTipConfig = { address: string; max?: number; kind: TipStrategy; }; interface UploadRelayConfig extends UploadRelayClientOptions { sendTip?: null | UploadRelayTipConfig | { max: number; }; } interface BaseWalrusClientConfig { storageNodeClientOptions?: StorageNodeClientOptions; wasmUrl?: string; uploadRelay?: UploadRelayConfig; /** * URL scheme used when contacting storage nodes. Defaults to `'https'`. * Set to `'http'` for local development where storage nodes do not * terminate TLS. */ storageNodeUrlScheme?: 'http' | 'https'; } /** * Configuration for the Walrus client. * * This is used to configure the Walrus client to use a specific storage node client options, network, and Sui client or RPC URL. */ type WalrusClientConfig = BaseWalrusClientConfig & WalrusNetworkOrPackageConfig & { suiClient: ClientWithCoreApi; }; type WalrusOptions = BaseWalrusClientConfig & { packageConfig?: WalrusPackageConfig; name?: Name; }; type WalrusClientExtensionOptions = BaseWalrusClientConfig & { packageConfig?: WalrusPackageConfig; }; type WalrusClientRequestOptions = Pick; interface StorageNode { networkUrl: string; info: (typeof StorageNodeInfo)['$inferType']; shardIndices: number[]; nodeIndex: number; id: string; } interface CommitteeInfo { byShardIndex: Map; nodes: StorageNode[]; } interface StorageWithSizeOptions { /** The encoded size of the blob. */ size: number; /** The number of epoch the storage will be reserved for. */ epochs: number; /** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */ walCoin?: TransactionObjectArgument; } interface RegisterBlobOptions extends StorageWithSizeOptions { blobId: string; rootHash: Uint8Array; deletable: boolean; /** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */ walCoin?: TransactionObjectArgument; /** The attributes to write for the blob. */ attributes?: Record; } type CertifyBlobOptions = { blobId: string; blobObjectId: string; deletable: boolean; } & ({ /** An array of confirmations. * These confirmations must be provided in the same order as the nodes in the committee. * For nodes that have not provided a confirmation you can pass `null` */ confirmations: (StorageConfirmation | null)[]; certificate?: never; } | { /** A certificate from the upload relay or combined confirmations. * Accepts either a ProtocolMessageCertificate object or a BCS-encoded base64 string. */ certificate: ProtocolMessageCertificate | string; confirmations?: never; }); type DeletableConfirmationOptions = { deletable: false; objectId?: string; } | { deletable: true; objectId: string; }; type GetStorageConfirmationOptions = { blobId: string; nodeIndex: number; } & DeletableConfirmationOptions & WalrusClientRequestOptions; type ReadBlobOptions = { blobId: string; } & WalrusClientRequestOptions; type GetCertificationEpochOptions = ReadBlobOptions; type GetBlobMetadataOptions = ReadBlobOptions; type GetSliversOptions = ReadBlobOptions; interface GetSecondarySliverOptions extends WalrusClientRequestOptions { blobId: string; index: number; } type GetVerifiedBlobStatusOptions = ReadBlobOptions; type ComputeBlobMetadataOptions = { bytes: Uint8Array; numShards?: number; /** Provide a nonce from a prior encode to ensure deterministic resume. If omitted, a random nonce is generated. */ nonce?: Uint8Array; }; interface SliversForNode { primary: { sliverIndex: number; sliverPairIndex: number; shardIndex: number; sliver: Uint8Array; }[]; secondary: { sliverIndex: number; sliverPairIndex: number; shardIndex: number; sliver: Uint8Array; }[]; } type WriteSliversToNodeOptions = { blobId: string; nodeIndex: number; slivers: SliversForNode; } & WalrusClientRequestOptions; type WriteSliverOptions = StoreSliverRequestInput & WalrusClientRequestOptions; type WriteMetadataOptions = { nodeIndex: number; metadata: Uploadable | typeof BlobMetadata.$inferInput; } & StoreBlobMetadataRequestInput & WalrusClientRequestOptions; type WriteEncodedBlobOptions = { blobId: string; nodeIndex: number; metadata: Uploadable | typeof BlobMetadata.$inferInput; slivers: SliversForNode; } & DeletableConfirmationOptions & WalrusClientRequestOptions; type WriteEncodedBlobToNodesOptions = { blobId: string; metadata: Uploadable | typeof BlobMetadata.$inferInput; sliversByNode: SliversForNode[]; } & DeletableConfirmationOptions & WalrusClientRequestOptions; type WriteBlobToUploadRelayOptions = { blobId: string; blob: Uint8Array; nonce: Uint8Array; txDigest: string; blobObjectId: string; deletable: boolean; encodingType?: EncodingType; } & WalrusClientRequestOptions; interface WriteBlobBaseOptions { deletable: boolean; /** The number of epochs the blob should be stored for. */ epochs: number; /** Where the blob should be transferred to after it is registered. Defaults to the signer address. */ owner?: string; /** The attributes to write for the blob. */ attributes?: Record; } interface WriteBlobOptions extends WriteBlobBaseOptions, WalrusClientRequestOptions { blob: Uint8Array; signer: Signer; onStep?: (step: WriteBlobStep) => void | Promise; resume?: WriteBlobStep; } interface WriteQuiltOptions extends Omit { blobs: { contents: Uint8Array; identifier: string; tags?: Record; }[]; } interface WriteFilesOptions extends Omit { files: WalrusFile[]; } type WriteBlobStep = WriteBlobStepEncoded | WriteBlobStepRegistered | WriteBlobStepUploaded | WriteBlobStepCertified; interface WriteBlobStepEncoded { step: 'encoded'; blobId: string; rootHash: string; unencodedSize: number; nonce?: string; } interface WriteBlobStepRegistered { step: 'registered'; blobId: string; blobObjectId: string; txDigest: string; nonce?: string; } interface WriteBlobStepUploaded { step: 'uploaded'; blobId: string; blobObjectId: string; txDigest?: string; certificate: string; } interface WriteBlobStepCertified { step: 'certified'; blobId: string; blobObjectId: string; blobObject: (typeof Blob)['$inferType']; } interface WriteFilesFlowOptions { files: WalrusFile[]; resume?: WriteBlobStep; } interface WriteFilesFlowRegisterOptions extends WriteBlobBaseOptions { owner: string; } interface WriteFilesFlowUploadOptions { digest?: string; } interface WriteFilesFlowRunOptions extends WriteBlobBaseOptions, WalrusClientRequestOptions { signer: Signer; } interface WriteFilesFlow { encode: () => Promise; register: (options: WriteFilesFlowRegisterOptions) => Transaction; upload: (options?: WriteFilesFlowUploadOptions) => Promise; certify: () => Transaction; listFiles: () => Promise<{ id: string; blobId: string; blobObject: (typeof Blob)['$inferType']; }[]>; executeRegister: (options: WriteFilesFlowRegisterOptions & { signer: Signer; }) => Promise; executeCertify: (options: { signer: Signer; }) => Promise; run: (options: WriteFilesFlowRunOptions) => AsyncIterable; } interface WriteBlobFlowOptions { blob: Uint8Array; resume?: WriteBlobStep; } interface WriteBlobFlowRegisterOptions extends WriteBlobBaseOptions { owner: string; } interface WriteBlobFlowUploadOptions extends WalrusClientRequestOptions { digest?: string; /** Override the deletable flag when resuming without a prior register step. */ deletable?: boolean; } interface WriteBlobFlowRunOptions extends WriteBlobBaseOptions, WalrusClientRequestOptions { signer: Signer; } interface WriteBlobFlow { encode: () => Promise; register: (options: WriteBlobFlowRegisterOptions) => Transaction; upload: (options?: WriteBlobFlowUploadOptions) => Promise; certify: () => Transaction; getBlob: () => Promise; executeRegister: (options: WriteBlobFlowRegisterOptions & { signer: Signer; }) => Promise; executeCertify: (options: { signer: Signer; }) => Promise; run: (options: WriteBlobFlowRunOptions) => AsyncIterable; } interface DeleteBlobOptions { blobObjectId: string; } type ExtendBlobOptions = { blobObjectId: string; /** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */ walCoin?: TransactionObjectArgument; } & ({ /** The number of epochs the blob should be stored for. */epochs: number; endEpoch?: never; } | { /** The new end epoch for the storage period of the blob. */endEpoch: number; epochs?: never; }); type WriteBlobAttributesOptions = { attributes: Record; } & ({ blobObject: TransactionObjectArgument; blobObjectId?: never; } | { blobObjectId: string; blobObject?: never; }); type EncodingType = Extract; interface ProtocolMessageCertificate { signers: number[]; serializedMessage: Uint8Array; signature: Uint8Array; } //#endregion export { CertifyBlobOptions, CommitteeInfo, ComputeBlobMetadataOptions, DeletableConfirmationOptions, DeleteBlobOptions, EncodingType, ExtendBlobOptions, GetBlobMetadataOptions, GetCertificationEpochOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ProtocolMessageCertificate, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageNode, StorageWithSizeOptions, TipStrategy, UploadRelayConfig, UploadRelayTipConfig, WalrusClientConfig, WalrusClientExtensionOptions, WalrusClientRequestOptions, WalrusOptions, WalrusPackageConfig, WriteBlobAttributesOptions, WriteBlobBaseOptions, WriteBlobFlow, WriteBlobFlowOptions, WriteBlobFlowRegisterOptions, WriteBlobFlowRunOptions, WriteBlobFlowUploadOptions, WriteBlobOptions, WriteBlobStep, WriteBlobStepCertified, WriteBlobStepEncoded, WriteBlobStepRegistered, WriteBlobStepUploaded, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteFilesFlow, WriteFilesFlowOptions, WriteFilesFlowRegisterOptions, WriteFilesFlowRunOptions, WriteFilesFlowUploadOptions, WriteFilesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions }; //# sourceMappingURL=types.d.mts.map