@zerochain/sdk
Version:
The Züs JS SDK is a JavaScript client library that provides a convenient interface for interacting with the Züs Network. It allows developers to perform various operations such as creating and managing allocations, uploading and downloading files, executi
1,275 lines (1,265 loc) • 72.8 kB
text/typescript
import { b as bulkUpload, s as setWallet, B as Bridge, G as GoInstance, C as Config, S as SetIsWasmLoaded, W as WasmType, a as WasmLoaderOptions, I as InitializeWasm, c as awaitWasmLoad, d as checkIfWasmLoaded, g as getDesiredMode, i as isDesiredWasmInitialized, u as updateWasmMode } from './createWasmLoader-BULNC82S.mjs';
export { O as OnLog } from './createWasmLoader-BULNC82S.mjs';
type ListResult = {
consensus: any;
deleteMask: string;
} & FileRef;
type FileRef = {
client_id: string;
name: string;
path?: string;
type: string;
size: number;
hash?: string;
file_meta_hash?: string;
num_blocks: number;
lookup_hash: string;
encryption_key: string;
actual_size: number;
actual_num_blocks: number;
thumbnail_hash?: string;
thumbnail_size: number;
actual_thumbnail_hash?: string;
actual_thumbnail_size: number;
num_files: number;
created_at: number;
updated_at: number;
list: ListResult[] | null;
storage_version: number;
mimetype?: string;
parent_path?: string;
};
/** Collaborator information. */
interface Collaborator {
ref_id: number;
client_id: string;
created_at: string;
}
type GolangFileRefByName = {
Name: string;
Type: string;
Path: string;
LookupHash: string;
Hash: string;
MimeType: string;
Size: number;
NumBlocks: number;
ActualFileSize: number;
ActualNumBlocks: number;
EncryptedKey: string;
FileMetaHash: string;
ThumbnailHash: string;
ActualThumbnailSize: number;
ActualThumbnailHash: string;
Collaborators: Collaborator[];
CreatedAt: number;
UpdatedAt: number;
};
type FileRefByName = {
name: string;
type: string;
path: string;
lookup_hash: string;
hash: string;
mimetype: string;
size: number;
num_blocks: number;
actual_size: number;
actual_num_blocks: number;
encryption_key: string;
file_meta_hash: string;
thumbnail_hash: string;
actual_thumbnail_size: number;
actual_thumbnail_hash: string;
collaborators: Collaborator[];
created_at: number;
updated_at: number;
fromSearch?: boolean;
};
type Blobber = {
/** ID of the blobber */
id: string;
/** BaseURL of the blobber */
url: string;
/** Terms of the blobber */
terms: Terms;
/** Capacity of the blobber */
capacity: number;
/** Allocated size of the blobber */
allocated: number;
/** LastHealthCheck of the blobber */
last_health_check: string;
/** PublicKey of the blobber */
public_key: string;
/** StakePoolSettings settings of the blobber staking */
stake_pool_settings: StakePoolSettings$1;
/** TotalStake of the blobber in SAS */
total_stake: number;
/** UsedAllocation of the blobber in SAS */
used_allocation: number;
/** TotalOffers of the blobber in SAS */
total_offers: number;
/** TotalServiceCharge of the blobber in SAS */
total_service_charge: number;
/** UncollectedServiceCharge of the blobber in SAS */
uncollected_service_charge: number;
/** IsKilled flag of the blobber, if true then the blobber is killed */
is_killed: boolean;
/** IsShutdown flag of the blobber, if true then the blobber is shutdown */
is_shutdown: boolean;
/** NotAvailable flag of the blobber, if true then the blobber is not available */
not_available: boolean;
/** IsRestricted flag of the blobber, if true then the blobber is restricted */
is_restricted: boolean;
};
type StakePoolSettings$1 = {
delegate_wallet?: string;
num_delegates?: number;
service_charge?: number;
};
/** Terms represents Blobber terms. A Blobber can update its terms, but any existing offer will use terms of offer signing time. */
type Terms = {
max_offer_duration: number;
/** SAS tokens / GB */
read_price: number;
/** SAS tokens / GB */
write_price: number;
};
type Allocation = {
/** ID is the unique identifier of the allocation. */
id: string;
/** Tx is the transaction hash of the latest transaction related to the allocation. */
tx: string;
/** DataShards is the number of data shards. */
data_shards: number;
/** ParityShards is the number of parity shards. */
parity_shards: number;
/** Size is the size of the allocation. */
size: number;
/** Expiration is the expiration date of the allocation. */
expiration_date: number;
/** Owner is the id of the owner of the allocation. */
owner_id: string;
/** OwnerPublicKey is the public key of the owner of the allocation. */
owner_public_key: string;
/** Payer is the id of the payer of the allocation. */
payer_id: string;
/** Blobbers is the list of blobbers that store the data of the allocation. */
blobbers: StorageNode[];
/** Stats contains the statistics of the allocation. */
stats: AllocationStats;
/** TimeUnit is the time unit of the allocation. */
time_unit: number;
/** WritePool is the write pool of the allocation. */
write_pool: number;
/**
* BlobberDetails contains real terms used for the allocation.
*
* If the allocation has updated, then terms are calculated using weighted average values.
*/
blobber_details: BlobberDetails[];
/** ReadPriceRange is requested reading prices range. */
read_price_range: PriceRange;
/** WritePriceRange is requested writing prices range. */
write_price_range: PriceRange;
/** MinLockDemand is the minimum lock demand of the allocation. */
min_lock_demand: number;
/** ChallengeCompletionTime is the time taken to complete a challenge. */
challenge_completion_time: number;
/** StartTime is the start time of the allocation. */
start_time: number;
/** Finalized is the flag to indicate if the allocation is finalized. */
finalized?: boolean;
/** Cancelled is the flag to indicate if the allocation is cancelled. */
canceled?: boolean;
/** MovedToChallenge is the amount moved to challenge pool related to the allocation. */
moved_to_challenge?: number;
/** MovedBack is the amount moved back from the challenge pool related to the allocation. */
moved_back?: number;
/** MovedToValidators is the amount moved to validators related to the allocation. */
moved_to_validators?: number;
/** Owner ECDSA public key */
owner_signing_public_key: string;
/**
* setThirdPartyExtendable is a flag that determines whether third-parties are allowed to update the allocation's size and expiration property.
*
* When set to `true`, third-parties / a non-owner client (e.g., 0box) can update or modify the allocation
*/
third_party_extendable: boolean;
/**
* FileOptions is a bitmask of file options, which represents the permissions of the allocation.
*
* Default value is `00000000`, suggesting that owner has abilities to perform all crud operations like upload, delete, update, move, copy, rename
* Bitmask options are:
* - `00000001` - 1 - upload
* - `00000010` - 2 - delete
* - `00000100` - 4 - update
* - `00001000` - 8 - move
* - `00010000` - 16 - copy
* - `00100000` - 32 - rename
*/
file_options: number;
/** IsEnterprise is a flag to indicate if the allocation is an enterprise allocation. */
is_enterprise: boolean;
/** StorageVersion is the storage version of the allocation. */
storage_version: number;
};
/** StorageNode represents a storage node (blobber) */
type StorageNode = {
id: string;
url: string;
LatestWM: WriteMarker | null;
};
type WriteMarker = {
allocation_root: string;
prev_allocation_root: string;
file_meta_root: string;
allocation_id: string;
size: number;
chain_size: number;
chain_hash: string;
chain_length: number;
blobber_id: string;
timestamp: number;
client_id: string;
signature: string;
};
type AllocationStats = {
used_size: number;
num_of_writes: number;
num_of_reads: number;
total_challenges: number;
num_open_challenges: number;
num_success_challenges: number;
num_failed_challenges: number;
latest_closed_challenge: string;
};
/** BlobberAllocation represents the blobber in the context of an allocation */
type BlobberDetails = {
blobber_id: string;
size: number;
terms: Terms;
min_lock_demand: number;
spent: number;
penalty: number;
read_reward: number;
returned: number;
challenge_reward: number;
final_reward: number;
};
/** PriceRange represents a price range allowed by user to filter blobbers. */
type PriceRange = {
min: number;
max: number;
};
type Domain = 'mainnet.zus.network' | 'devnet.zus.network';
type NetworkDomain = Domain | (string & {});
type NetworkConfig = {
/** Chain ID */
chainId?: string;
/** signatureScheme is the Signature scheme used for signing transactions */
signatureScheme?: string;
/** minConfirmation is the minimum number of confirmations required for a transaction to be considered final */
minConfirmation?: number;
/** minSubmit is the minimum number of times a transaction must be submitted to the network */
minSubmit?: number;
/** confirmationChainLength is the number of blocks to wait for a transaction to be confirmed */
confirmationChainLength?: number;
/** sharderConsensus is the number of sharders to reach consensus */
sharderConsensus?: number;
/** zboxHost is the url of the 0box service */
zboxHost?: `https://0box.${Domain}` | (string & {});
/** blockWorker is the block worker url */
blockWorker?: `https://${Domain}/dns` | (string & {});
};
type BasicWallet = {
id: string;
name: string;
mnemonic: string;
version: '1.0';
creationDate: number;
keys: {
walletId: string;
publicKey: string;
privateKey: string;
publicEncryptionKey: string;
walletMnemonic: string;
};
};
type ActiveWallet = {
id?: string;
temp_id?: string;
name?: string;
source_client_id?: string | null;
client_key?: string;
public_key?: string;
mnemonic?: string;
keys?: {
privateKey: string;
publicKey: string;
walletMnemonic?: string;
};
is_split?: boolean;
peer_public_key?: string;
zauth_host?: `https://zauth.${Domain}` | (string & {});
};
type Transaction = {
hash?: string;
version?: string;
client_id?: string;
public_key?: string;
to_client_id?: string;
chain_id?: string;
transaction_data: string;
transaction_value: number;
signature?: string;
creation_date?: number;
transaction_type: number;
transaction_output?: string;
transaction_fee: number;
transaction_nonce: number;
txn_output_hash: string;
transaction_status: number;
};
declare const providerTypes: {
readonly miner: 1;
readonly sharder: 2;
readonly blobber: 3;
readonly validator: 4;
readonly authorizer: 5;
};
type ProviderType = keyof typeof providerTypes;
declare const getProviderTypeId: (providerType: ProviderType) => number;
/** StakePoolInfo is the information of stake pool of a provider */
type StakePoolInfo = {
pool_id: string;
balance: number;
stake_total: number;
delegate: StakePoolDelegatePoolInfo[];
rewards: number;
total_rewards: number;
settings: StakePoolSettings;
};
/** StakePoolDelegatePoolInfo represents delegate pool of a stake pool info */
type StakePoolDelegatePoolInfo = {
id: string;
balance: number;
delegate_id: string;
rewards: number;
unstake: boolean;
total_reward: number;
total_penalty: number;
status: string;
round_created: number;
staked_at: number;
};
type StakePoolSettings = {
delegate_wallet: string;
num_delegates: number;
service_charge: number;
};
declare const createSdkProxyObject: (go: GoInstance) => any;
declare const createJsProxyObject: () => any;
type GoWasmProxy = {
/** @deprecated */
bulkUpload: typeof bulkUpload;
setWallet: typeof setWallet;
getWalletId: () => Bridge['walletId'];
getPrivateKey: () => Bridge['secretKey'];
getPeerPublicKey: () => Bridge['peerPublicKey'];
sdk: ReturnType<typeof createSdkProxyObject>;
jsProxy: ReturnType<typeof createJsProxyObject>;
};
/**
* Creates a WebAssembly (Wasm) instance and returns a proxy object for accessing SDK methods.
* @returns The proxy object for accessing SDK methods.
*/
declare function createWasm(config: Config, setIsWasmLoaded: SetIsWasmLoaded): Promise<GoWasmProxy>;
declare const resetGoWasm: () => void;
type ZboxAppType = 'vult' | 'blimp' | 'chalk' | 'chimney' | 'bolt' | 'atlus';
/** Set the wallet details and return the goWasm instance to call SDK methods. */
declare const getWasm: ({ domain, wallet, zboxAppType, networkConfig, }: {
domain: NetworkDomain;
wallet?: ActiveWallet;
zboxAppType?: ZboxAppType;
networkConfig?: NetworkConfig;
}) => Promise<GoWasmProxy>;
/** Creates wallet keys including wallet ID, public key, and private key using BLS (Boneh-Lynn-Shacham) cryptography. */
declare const createWalletKeys: (
/** Optional 24 word [bip39](https://iancoleman.io/bip39/) mnemonic phrase. */
customBip39Mnemonic?: string) => Promise<{
keys: {
walletId: string;
/** BLS public key */
publicKey: string;
/** BLS private key */
privateKey: string;
walletMnemonic: string;
};
mnemonic: string;
}>;
/** Retrieves the public encryption key for a wallet. */
declare const getPublicEncryptionKey: ({ keys, domain, }: {
keys: {
walletId: string;
/** BLS public key */
publicKey: string;
/** BLS private key */
privateKey: string;
walletMnemonic: string;
};
domain: NetworkDomain;
}) => Promise<string>;
/** Create a new wallet. Also, helps to recover a wallet using its mnemonic phrase. */
declare const createWallet: ({ domain, walletName, customBip39Mnemonic, }: {
domain: NetworkDomain;
walletName?: string;
/**
* Optional 24 word [bip39](https://iancoleman.io/bip39/) mnemonic phrase for wallet recovery.
* If `customBip39Mnemonic` is not provided, a new mnemonic will be generated.
*/
customBip39Mnemonic?: string;
}) => Promise<BasicWallet>;
declare const isWalletId: (walletId: string) => boolean;
declare const getGosdkVersion: (domain: string) => Promise<string>;
declare const getLookupHash: ({ domain, allocationId, filePath, wallet, }: {
domain: NetworkDomain;
allocationId: string;
filePath: string;
wallet: ActiveWallet;
}) => Promise<string>;
/** makeSCRestAPICall issues a request to the public API of one of the smart contracts
* @returns Response in JSON string
*/
declare const makeSCRestAPICall: ({ domain, scType, endpoint: relativePath, params, }: {
domain: NetworkDomain;
/** Smart contract type */
scType: "sharders" | "miners";
/** Relative path of the endpoint */
endpoint: string;
/** Parameters in JSON format */
params?: Record<string, string>;
}) => Promise<string>;
/** @returns Wasm type. If SDK is not initialized, `returns undefined` */
declare const getWasmType: () => WasmType | undefined;
/**
* send tokens to a client ID / wallet ID
*
* @returns The transaction hash.
*/
declare const send: ({ wallet, domain, toClientId, tokens, fee, desc, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
/** Client ID / Wallet ID to send tokens to */
toClientId: string;
/** Number of tokens to send */
tokens: number;
/** Transaction fee */
fee: number;
/** Description of the transaction */
desc: string;
}) => Promise<string>;
/** Deletes a file from an allocation. Only the owner of the allocation can delete a file.
*
* To perform multiple deletions in a single call, use the `multiOperation` method instead.
*/
declare const deleteFile: ({ wallet, domain, allocationId, remotePath, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** remote path of the file to be deleted*/
remotePath: string;
}) => Promise<{
commandSuccess: boolean;
error: string;
}>;
/** Generates an `authTicket` that provides authorization to the holder to the specified file on the remotepath. */
declare const share: ({ wallet, domain, allocationId, remotePath, clientId, encryptionPublicKey, expiration, revoke, availableAfter, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** Remote path of the file to be shared */
remotePath: string;
/** Client ID / wallet ID of the recipient (for public sharing) */
clientId?: string;
/** Encryption public key of the recipient (for private sharing) */
encryptionPublicKey?: string;
/**
* Expiration time of the auth ticket (in Unix timestamp seconds. e.g. `1647858200`)
* @default 0 (no expiration)
*/
expiration?: number;
/** Whether to revoke the share. Only applicable for private sharing */
revoke?: boolean;
/** Time after which the share becomes available */
availableAfter?: string;
}) => Promise<string>;
/** Options for a single file download, usually as part of a multi-download request. */
type MultiDownloadOption = {
/** Remote path of the file to be downloaded */
remotePath: string;
/** Local path where the file should be stored (optional) */
localPath?: string;
/** Download operation type */
downloadType: 'file' | 'thumbnail';
/** Number of blocks to download per request @default 100 */
numBlocks?: number;
/** @optional Required only for file download with an auth ticket */
remoteFileName: string;
/** @optional Lookup hash for remote file, required for auth ticket downloads */
remoteLookupHash?: string;
/** Whether to download the file directly to disk - This uses FileSytem API. This is not supported on Safari browser. Check: https://developer.mozilla.org/en-US/docs/Web/API/Window/showSaveFilePicker */
downloadToDisk: boolean;
/** Suggested name for the file when downloading to disk (optional) */
suggestedName?: string;
};
/** Response format for each downloaded file in a multi-download operation */
type DownloadCommandResponse = {
commandSuccess: boolean;
error?: string;
/** Name of the downloaded file */
fileName?: string;
/** Blob URL of the downloaded file */
url?: string;
};
/** Downloads multiple files in parallel in a batch. This method supports downloading files directly to disk (if supported by the browser) and provides progress updates via a callback function. */
declare const multiDownload: ({ wallet, domain, allocationId, multiDownloadOptions, authTicket, callback, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** @optional Required only for download of a shared files (non-owner) */
authTicket?: string;
/** Array of download options for each file */
multiDownloadOptions: MultiDownloadOption[];
/** Callback function will be invoked with progress updates */
callback?: (totalBytes: number, completedBytes: number, fileName: string, blobURL: string, error?: string) => void;
}) => Promise<DownloadCommandResponse[]>;
/** Sets the upload mode for modifying the upload speed and CPU usage . Possible upload modes:
* - 0 = Slow uploads (Consumes less CPU & Memory)
* - 1 = Standard (Default)
* - 2 = High Speed uploads (Consumes more CPU & Memory)
*/
declare const setUploadMode: ({ wallet, domain, mode, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Upload mode:
* - 0 = low
* - 1 = medium (default)
* - 2 = high */
mode: 0 | 1 | 2;
}) => Promise<void>;
type BulkUploadOption = {
allocationId: string;
webstreaming: boolean;
isUpdate: boolean;
isRepair: boolean;
/** Number of blocks to upload per request @default 100 */
numBlocks: number;
file: File;
remotePath: string;
/** Whether to encrypt the file */
encrypt: boolean;
/** Use `fileToByteString` to generate the thumbnail byte string, or assign an empty string if unavailable. */
thumbnailBytes: string;
/** Callback function will be invoked with progress updates */
callback?: (totalBytes: number, completedBytes: number, fileName: string, blobURL: string, error: string) => void;
/** @optional */
uploadId?: string;
/** @deprecated */
webStreaming?: boolean;
};
/** Upload multiple files in a batch. Also, used to resume a paused upload.
*
* NOTE: Keep the batch size under 50 files. */
declare const multiUpload: ({ wallet, domain, bulkUploadOptions: options, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
bulkUploadOptions: BulkUploadOption[];
}) => Promise<{
success?: boolean;
error?: string;
}>;
type MultiOperationOption = {
/** Type of operation: 'copy', 'move', 'delete', or 'createdir' */
operationType: 'copy' | 'move' | 'delete' | 'createdir';
/** Remote path of the file/directory */
remotePath: string;
/** Destination name (only for rename operation) */
destName?: string;
/** Destination path (required for copy and move operations) */
destPath?: string;
};
/** Perform multiple operations (copy, move, delete, create directory) together */
declare const multiOperation: ({ wallet, domain, allocationId, operations, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
operations: MultiOperationOption[];
}) => Promise<void>;
/** List the files for a given allocation ID and remote path */
declare const listObjects: ({ wallet, domain, allocationId, remotePath, offset, pageLimit, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** The remote path of the file */
remotePath: string;
/** The pagination offset for the list. @default 0 (turn off pagination)*/
offset: number;
/** The number of items per page. @default -1 (turn off pagination) */
pageLimit: number;
}) => Promise<ListResult>;
/** List objects from an auth ticket. It's useful for accessing a shared source by a non-owner */
declare const listObjectsFromAuthTicket: ({ wallet, domain, allocationId, authTicket, lookupHash, offset, pageLimit, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** The auth ticket, provided by a non-owner to access a shared source */
authTicket: string;
/** The lookup hash for the file */
lookupHash: string;
/** The pagination offset for the list. @default 0 (turn off pagination)*/
offset: number;
/** The number of items per page. @default -1 (turn off pagination) */
pageLimit: number;
}) => Promise<ListResult>;
/** Create a directory on blobbers */
declare const createDir: ({ wallet, domain, allocationId, remotePath, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** The remote path where the directory will be created */
remotePath: string;
}) => Promise<void>;
/** Downloads a specified range of blocks from a file. */
declare const downloadBlocks: ({ wallet, domain, allocationId, remotePath, authTicket, lookupHash, writeChunkFunc, startBlock, endBlock, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
remotePath: string;
/** @optional Required only for download of a shared file (non-owner) */
authTicket?: string;
/** Lookup hash of the file, which is used to locate the file if remotepath and allocation id are not provided */
lookupHash?: string;
writeChunkFunc: (lookupHash: string, chunk: Uint8Array, offset: number) => void;
startBlock: number;
endBlock: number;
}) => Promise<Uint8Array>;
type FileStats = {
CreatedAt: string;
blobber_id: string;
blobber_url: string;
blockchain_aware: boolean;
file_id: string;
last_challenge_txn: string;
name: string;
num_of_block_downloads: number;
num_of_blocks: number;
num_of_challenges: number;
num_of_failed_challenges: number;
num_of_updates: number;
path: string;
path_hash: string;
size: number;
write_marker_txn: string;
};
/** Fetches the file details */
declare const getFileStats: ({ wallet, domain, allocationId, remotePath, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
remotePath: string;
}) => Promise<FileStats[]>;
/** Updates the settings for a blobber. */
declare const updateBlobberSettings: ({ wallet, domain, blobberSettings, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** The new settings to apply to the blobber */
blobberSettings: Blobber;
}) => Promise<Transaction>;
type FileInfo = {
actual_size: number;
created_at: string;
encrypted_key: string;
hash: string;
lookup_hash: string;
mimetype: string;
size: number;
type: string;
updated_at: string;
name: string;
path: string;
};
/** Lists all files in an allocation from the blobbers.
* @deprecated This will consume too much memory and time if there are many nested folders with many files. Prefer using `listObjects` instead.
*/
declare const getRemoteFileMap: ({ wallet, domain, allocationId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
}) => Promise<FileInfo[]>;
/** Get list of active blobbers */
declare const getBlobbers: ({ wallet, domain, stakable, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** flag to get only stakable blobbers */
stakable: boolean;
}) => Promise<Blobber[]>;
/** Retrieves blobber IDs for the given list of blobber URLs. */
declare const getBlobberIds: ({ wallet, domain, blobberUrls, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** List of blobber URLs for which IDs need to be retrieved */
blobberUrls: string[];
}) => Promise<string[]>;
/**
* GetContainers returns all the running containers in a given domain exposing the `{requestDomain}/endpoints/{endpointID}/docker/containers/json` endpoint
*
* The request should be authenticated with the given username and password, by first creating an auth token then issuing the request.
*
* @returns List of containers
*/
declare const getContainers: ({ wallet, domain, username, password, requestDomain, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
/** Username to authenticate with */
username: string;
/** Password to authenticate with */
password: string;
/** Domain to issue the request to */
requestDomain: string;
}) => Promise<Array<Record<string, any>>>;
/**
* UpdateContainer updates the given container ID with a new image ID in a given domain.
* The domain should expose the docker API endpoints under `{requestDomain}/endpoints/{endpointID}/docker`.
* The request should be authenticated with the given username and password, by first creating an auth token then issuing the request.
*
* @returns A map containing the response from the update operation.
*/
declare const updateContainer: ({ wallet, domain, username, password, containerID, newImageID, requestDomain, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
/** Username to authenticate with */
username: string;
/** Password to authenticate with */
password: string;
/** Domain to issue the request to */
requestDomain: string;
/** Container ID to update */
containerID: string;
/** New Image ID to update the container with */
newImageID: string;
}) => Promise<Record<string, any>>;
/**
* searchContainer searches for a container with a given name in a given domain exposing the `{requestDomain}/endpoints/{endpointID}/docker/containers/json` endpoint.
* The request should be authenticated with the given username and password, by first creating an auth token then issuing the request.
* The response is a list of containers in JSON format that match the given name.
*
* @returns List of containers matching the name
*/
declare const searchContainer: ({ wallet, domain, username, password, name, requestDomain, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
/** Username to authenticate with */
username: string;
/** Password to authenticate with */
password: string;
/** Domain to issue the request to */
requestDomain: string;
/** Name of the container to search for */
name: string;
}) => Promise<Array<Record<string, any>>>;
/** Cancel the upload operation of the file. */
declare const cancelUpload: ({ wallet, domain, allocationId, remotePath, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
/** Remote path of the file */
remotePath: string;
}) => Promise<void>;
/** Pause the upload operation of the file. */
declare const pauseUpload: ({ wallet, domain, allocationId, remotePath, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
/** Remote path of the file */
remotePath: string;
}) => Promise<void>;
/** Get file metadata by name. (File Search) */
declare const getFileMetaByName: <T extends FileRefByName>({ wallet, domain, allocationId, fileName, modifyFileRef, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
fileName: string;
modifyFileRef?: (file: FileRefByName) => T;
}) => Promise<T[] | FileRefByName[]>;
/** Download files in a directory recursively. */
declare const downloadDirectory: ({ wallet, domain, allocationId, remotePath, authTicket, callback, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** @optional Required only for download of a shared directory (non-owner) */
authTicket?: string;
/** Remote path of the directory to download */
remotePath: string;
/** Callback function will be invoked with progress updates */
callback?: (totalBytes: number, completedBytes: number, fileName: string, blobURL: string, error?: string) => void;
}) => Promise<void>;
/** Cancel the download of a directory. */
declare const cancelDownloadDirectory: ({ wallet, domain, remotePath, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Remote path of the directory */
remotePath: string;
}) => Promise<void>;
/** Cancels the download of a specified range of blocks from a file. */
declare const cancelDownloadBlocks: ({ wallet, domain, allocationId, remotePath, start, end, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** The allocation ID associated with the file */
allocationId: string;
/** The remote path where the file is located */
remotePath: string;
/** The start block previously used in the downloadBlocks call */
start: number;
/** The endi block previously used in the downloadBlocks call */
end: number;
}) => Promise<void>;
/**
* Creates an allocation with the specified allocation terms and preferred blobber IDs.
*
* To determine `minReadPrice`, `maxReadPrice`, `minWritePrice`, and `maxWritePrice`, use the `makeSCRestAPICall` SDK method to call the `/storage-config` endpoint of the sharder smart contract.
*/
declare const createAllocation: ({ wallet, domain, dataShards, parityShards, size, minReadPrice, maxReadPrice, minWritePrice, maxWritePrice, lock, blobberIds, blobberAuthTickets, setThirdPartyExtendable, isEnterprise, force, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Number of data shards. Data uploaded to the allocation will be split and distributed across these shards. */
dataShards: number;
/** Number of parity shards. Parity shards are used to replicate datashards for redundancy. */
parityShards: number;
/** Size of the allocation in bytes */
size: number;
/** Minimum read price */
minReadPrice: number;
/** Maximum read price */
maxReadPrice: number;
/** Minimum write price */
minWritePrice: number;
/** Maximum write price */
maxWritePrice: number;
/** Lock value to add to the allocation */
lock: number;
/** List of blobber IDs of your preferred blobbers for the allocation */
blobberIds?: string[];
/** List of blobber auth tickets in case of using restricted blobbers */
blobberAuthTickets: string[];
/**
* setThirdPartyExtendable is a flag that determines whether third-parties are allowed to update the allocation's size and expiration property.
*
* When set to `true`, third-parties / a non-owner client (e.g., 0box) can update or modify the allocation
*/
setThirdPartyExtendable: boolean;
/** Whether it's an enterprise allocation */
isEnterprise: boolean;
/**
* The `force` parameter determines whether the allocation creation should proceed even if the available blobbers are insufficient to meet the required data + parity conditions.
*
* By default, when `force` is `false`, the API will return a "Not enough blobbers" error if the number of available blobbers is less than the required data + parity. This ensures that the allocation meets the necessary redundancy and reliability conditions.
*
* When `force` is set to `true`, the API will bypass this check and proceed with the allocation creation using the available blobbers, even if they are fewer than the required data + parity shards. This can be useful in scenarios where you want to proceed with the allocation despite the reduced redundancy.
*
* Use this parameter with caution, as it may result in allocations with lower fault tolerance and reliability.
*/
force: boolean;
}) => Promise<Transaction>;
/**
* Retrieves list of blobber IDs of blobber which match your allocation terms
*
* To determine `minReadPrice`, `maxReadPrice`, `minWritePrice`, and `maxWritePrice`, use the `makeSCRestAPICall` SDK method to call the `/storage-config` endpoint of the sharder smart contract.
*/
declare const getAllocationBlobbers: ({ wallet, domain, preferredBlobberURLs, dataShards, parityShards, size, minReadPrice, maxReadPrice, minWritePrice, maxWritePrice, restrictedLevel, force, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** List of preferred blobber URLs */
preferredBlobberURLs?: string[];
/** Number of data shards */
dataShards: number;
/** Number of parity shards */
parityShards: number;
/** Size of the allocation in bytes */
size: number;
/** Minimum read price */
minReadPrice: number;
/** Maximum read price */
maxReadPrice: number;
/** Minimum write price */
minWritePrice: number;
/** Maximum write price */
maxWritePrice: number;
/**
* Specifies the type of blobbers to query.
*
* - `0`: Use all blobbers (both restricted and non-restricted).
* - `1`: Use only restricted blobbers (require permission for allocation creation).
* - `2`: Use only non-restricted blobbers (do not require permission for allocation creation).
*/
restrictedLevel: number;
/**
* @deprecated For internal use only
* @default false
*/
force: boolean;
}) => Promise<string[]>;
/** List all the allocations */
declare const listAllocations: ({ wallet, domain, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
}) => Promise<Allocation[]>;
/** getAllocation gets allocation details using `allocationId` from cache
* - if not found in cache, fetch from blockchain and store in cache */
declare const getAllocation: ({ wallet, domain, allocationId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
}) => Promise<Allocation>;
/** reloadAllocation reload allocation details using `allocationId` from blockchain and updates cache */
declare const reloadAllocation: ({ wallet, domain, allocationId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
}) => Promise<Allocation>;
/**
* transferAllocation transfers the ownership of an allocation to a new owner
* @deprecated
*/
declare const transferAllocation: ({ wallet, domain, allocationId, newOwnerId, newOwnerPublicKey, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** New owner ID */
newOwnerId: string;
/** New owner public key */
newOwnerPublicKey: string;
}) => Promise<void>;
/**
* freezeAllocation freezes one of the client's allocations, given its ID
*
* Freezing the allocation will forbid all the operations on the files in the allocation.
*
* @returns the hash of the transaction
*/
declare const freezeAllocation: ({ wallet, domain, allocationId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Allocation ID to freeze */
allocationId: string;
}) => Promise<string>;
/**
* cancelAllocation cancels an allocation using `allocationId`
*
* @returns the hash of the transaction
*/
declare const cancelAllocation: ({ wallet, domain, allocationId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Allocation ID to cancel */
allocationId: string;
}) => Promise<string>;
/** updateAllocation updates the allocation settings */
declare const updateAllocation: ({ wallet, domain, allocationId, size, extend, lock, addBlobberId, addBlobberAuthTicket, removeBlobberId, ownerSigningPublicKey, setThirdPartyExtendable, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Allocation ID to update */
allocationId: string;
/** New size of the allocation in bytes */
size: number;
/** Extend flag, whether to extend the allocation's expiration date */
extend: boolean;
/** Lock value to add to the allocation */
lock: number;
/** Blobber ID to add to the allocation */
addBlobberId?: string;
/** Blobber auth ticket to add to the allocation, in case of restricted blobbers */
addBlobberAuthTicket?: string;
/** Blobber ID to remove from the allocation */
removeBlobberId?: string;
/** Optional ECDSA Public key of the user who created that allocation. It’s used for signature verification. If not provided, GoSDK will generate one */
ownerSigningPublicKey?: string;
/**
* setThirdPartyExtendable is a flag that determines whether third-parties are allowed to update the allocation's size and expiration property.
*
* When set to `true`, third-parties / a non-owner client (e.g., 0box) can update or modify the allocation
*/
setThirdPartyExtendable: boolean;
}) => Promise<string>;
/** Updates your allocation settings and repairs the allocation if any blobber was replaced or added to the allocation */
declare const updateAllocationWithRepair: ({ wallet, domain, allocationId, size, extend, lock, addBlobberId, addBlobberAuthTicket, removeBlobberId, ownerSigningPublicKey, updateAllocTicket, callback, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Allocation ID to update */
allocationId: string;
/** New size of the allocation in bytes */
size: number;
/**
* Extend flag, whether to extend the allocation's expiration date
* @default false
*/
extend: boolean;
/** Lock value to add to the allocation */
lock: number;
/** Blobber ID to add to the allocation */
addBlobberId?: string;
/** Blobber auth ticket to add to the allocation, in case of restricted blobbers */
addBlobberAuthTicket?: string;
/** Blobber ID to remove from the allocation */
removeBlobberId?: string;
/** Optional ECDSA Public key of the user who created that allocation. It’s used for signature verification. If not provided, GoSDK will generate one */
ownerSigningPublicKey?: string;
/** Update allocation ticket */
updateAllocTicket?: string;
/** Callback function will be invoked with repair progress updates */
callback?: (totalBytes: number, completedBytes: number, fileName: string, blobURL: string, error: string) => void;
}) => Promise<string>;
/**
* getAllocationMinLock retrieves the minimum lock value for the allocation creation
*
* Lock value is the amount of tokens that the client needs to lock in the allocation's write pool to be able to pay for the write operations.
*
* To determine `maxWritePrice`, use the `makeSCRestAPICall` SDK method to call the `/storage-config` endpoint of the sharder smart contract.
*
* @returns the minimum lock value (in SAS)
*/
declare const getAllocationMinLock: ({ domain, wallet, dataShards, parityShards, size, maxWritePrice, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Number of data shards */
dataShards: number;
/** Number of parity shards */
parityShards: number;
/** Size of the allocation in bytes */
size: number;
/** Maximum write price */
maxWritePrice: number;
}) => Promise<number>;
/**
* getUpdateAllocationMinLock retrieves the minimum lock value for the allocation after update, as calculated by the network based on the update parameters.
*
* Lock value is the amount of tokens that the client needs to lock in the allocation's write pool to be able to pay for the write operations.
*
* @returns the minimum lock value (in SAS)
*/
declare const getUpdateAllocationMinLock: ({ domain, wallet, allocationId, size, extend, addBlobberId, removeBlobberId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Allocation ID to update */
allocationId: string;
/** New size of the allocation in bytes */
size: number;
/** Extend flag, whether to extend the allocation's expiration date */
extend: boolean;
/** Blobber ID to add to the allocation */
addBlobberId?: string;
/** Blobber ID to remove from the allocation */
removeBlobberId?: string;
}) => Promise<number>;
/**
* UpdateForbidAllocation updates the permissions of an allocation.
*
* @returns The transaction hash
*/
declare const updateForbidAllocation: ({ wallet, domain, allocationId, forbidUpload, forbidDelete, forbidUpdate, forbidMove, forbidCopy, forbidRename, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
/** Allocation ID to update */
allocationId: string;
/** If true, uploading files to the allocation is forbidden */
forbidUpload: boolean;
/** If true, deleting files from the allocation is forbidden */
forbidDelete: boolean;
/** If true, updating files in the allocation is forbidden */
forbidUpdate: boolean;
/** If true, moving files in the allocation is forbidden */
forbidMove: boolean;
/** If true, copying files in the allocation is forbidden */
forbidCopy: boolean;
/** If true, renaming files in the allocation is forbidden */
forbidRename: boolean;
}) => Promise<string>;
/**
* getAllocationWith retrieves the information of a free or a shared allocation given the auth ticket.
* - **Free allocation** is an allocation that is created to the user using Vult app for the first time with no fees.
* - **Shared allocation** is an allocation that has some shared files. The user who needs to access those files first needs to read the information of this allocation using an auth ticket.
*/
declare const getAllocationWith: ({ domain, wallet, authTicket, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
/** Auth ticket, used by a non-owner to access a shared allocation */
authTicket: string;
}) => Promise<Allocation>;
/** createFreeAllocation creates a free allocation */
declare const createFreeAllocation: ({ domain, wallet, freeStorageMarker, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
freeStorageMarker: string;
}) => Promise<string>;
/**
* Generates and signs an "Update Allocation ticket", which authorizes the "add blobber" or "replace blobber" operation from other wallets. This ticket must be signed by the allocation owner.
*/
declare const getUpdateAllocTicket: ({ domain, wallet, allocationId, userId, operationType, roundExpiry, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** UserID is the wallet ID which will be allowed to update your allocation */
userId: string;
operationType: "replace_blobber" | "add_blobber";
/** Round expiry is the round after which the auth ticket will no longer be valid. */
roundExpiry: number;
}) => Promise<string>;
/**
* CollectRewards collect all rewards which are available for delegate & provider pair. (txn: `storagesc.collect_reward`)
*
* @returns the hash of the transaction
*/
declare const collectRewards: ({ domain, wallet, providerType, providerId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
providerType: ProviderType;
providerId: string;
}) => Promise<string>;
/** getSkatePoolInfo is to get information about the stake pool for the allocation */
declare const getStakePoolInfo: ({ domain, wallet, providerType, providerId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
providerType: ProviderType;
providerId: string;
}) => Promise<StakePoolInfo>;
/**
* Stake number of tokens for a given provider given its type and ID
* @returns the hash of the transaction
*/
declare const lockStakePool: ({ domain, wallet, providerType, tokens, fee, providerId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
providerType: ProviderType;
/** Number of tokens to lock (in SAS) */
tokens: number;
/** Transaction fee (in SAS) */
fee: number;
providerId: string;
}) => Promise<string>;
/**
* unlockStakePool unlocks the write pool
* @returns the hash of the transaction
*/
declare const unlockStakePool: ({ domain, wallet, providerType, fee, providerId, clientId, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
providerType: ProviderType;
/** Transaction fee (in SAS) */
fee: number;
providerId: string;
/** Wallet ID */
clientId: string;
}) => Promise<string>;
/**
* lockWritePool locks given number of tokes for given duration in write pool
* @returns the hash of the transaction
*/
declare const lockWritePool: ({ domain, wallet, allocationId, tokens, fee, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
/** Number of tokens to lock (in SAS) */
tokens: number;
/** Transaction fee (in SAS) */
fee: number;
}) => Promise<string>;
/**
* Issues the repair process for an allocation, *starting from a specific path*.
*
* Repair synchronizes the user's data within the allocation across all blobbers and restores any missing data on blobbers where it is incomplete.
*
* @deprecated
*/
declare const allocationRepair: ({ domain, wallet, allocationId, remotePath, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
remotePath: string;
}) => Promise<void>;
/** Repairs the allocation.
*
* Allocation repair is a process to repair the allocation files on its blobbers by re-uploading the missing blocks. */
declare const repairAllocation: ({ wallet, domain, allocationId, callback, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
/** Callback function will be invoked with repair progress updates */
callback?: (totalBytes: number, completedBytes: number, fileName: string, blobURL: string, error: string) => void;
}) => Promise<void>;
/**
* repairSize retrieves the repair size for a specific path in an allocation
*
* Repair size is the size of the data that needs to be repaired in the allocation.
*/
declare const repairSize: ({ domain, wallet, allocationId, remotePath, }: {
domain: NetworkDomain;
wallet: ActiveWallet;
allocationId: string;
remotePath: string;
}) => Promise<{
upload_size: number;
download_size: number;
}>;
type AllocStatus = {
/**
* The health `status` of the allocation has one of the following values:
* - `ok`: The allocation is healthy and fully functional.
* - `repair`: The allocation needs to be repaired. Repair using the `repairAllocation` method.
* - `broken`: The allocation is irreparably broken. This occurs when critical data blocks are missing or when blobbers are offline, making recovery impossible.
*/
status: 'ok' | 'repair' | 'broken';
blobberStatus: {
ID: string;
Status: 'available' | 'unavailable';
}[];
error: string;
};
/** Check the health status of the allocation. */
declare const checkAllocStatus: ({ wallet, domain, allocationId, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
}) => Promise<AllocStatus>;
/** Skip the health status check of the allocation. */
declare const skipStatusCheck: ({ wallet, domain, allocationId, checkStatus, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
/** Flag to enable or disable status check */
checkStatus: boolean;
}) => Promise<void>;
/** Remove local workers for a particular allocation. This is useful when switching between allocations and we don't need workers for the old allocation. */
declare const terminateWorkers: ({ wallet, domain, allocationId, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
}) => Promise<void>;
/** Create local workers for an allocation. Terminate workers if the allocation is no longer needed using `terminateWorkers`. */
declare const createWorkers: ({ wallet, domain, allocationId, }: {
wallet: ActiveWallet;
domain: NetworkDomain;
allocationId: string;
}) => Promise<void>;
type TokenSymbol = 'zcn' | 'eth' | (string & {});
/** Retrieves the USD rate for a given token symbol. */
declare const getUSDRate: ({ domain, symbol, }: {
domain: NetworkDomain;
/** Token symbol for which the USD rate is fetched. */
symbol?: TokenSymbol;
}) => Promise<number>;
type Balance = {
zcn: number;
usd: number;
nonce: number;
};
/** getWalletBalance retrieves the wallet balance