Skip to main content

LocalCloud

LocalCloud is a cloud that runs on the local machine for testing and development It uses LocalStorage to store jobs, tasks, transactions, and data It uses a localWorker to execute the tasks It can be used to test the cloud functionality without deploying to the cloud

@param

the worker to execute the tasks

Hierarchy

Index

Constructors

constructor

  • Constructor for LocalCloud


    Parameters

    • params: { cache?: string; chain: blockchain; job: JobData; localWorker: (cloud: Cloud) => Promise<zkCloudWorker>; stepId?: string }

      the parameters to create the LocalCloud

      • optionalcache: string

        the cache folder

      • chain: blockchain

        the blockchain to execute the job on, can be any blockchain, not only local

      • job: JobData

        the job data

      • localWorker: (cloud: Cloud) => Promise<zkCloudWorker>

        the worker to execute the tasks

      • optionalstepId: string

        the step id

    Returns LocalCloud

Properties

optionalreadonlyargs

args?: string

readonlycache

cache: string

readonlychain

chain: blockchain

readonlydeveloper

developer: string

readonlyid

id: string

readonlyisLocalCloud

isLocalCloud: boolean

readonlyjobId

jobId: string

readonlylocalWorker

localWorker: (cloud: Cloud) => Promise<zkCloudWorker>

Type declaration

optionalreadonlymetadata

metadata?: string

readonlyrepo

repo: string

readonlystepId

stepId: string

optionalreadonlytask

task?: string

readonlytaskId

taskId: string

optionalreadonlyuserId

userId?: string

Methods

publicaddTask

  • addTask(data: { args?: string; metadata?: string; startTime?: number; task: string; userId?: string }): Promise<string>
  • Adds a task to the local cloud


    Parameters

    • data: { args?: string; metadata?: string; startTime?: number; task: string; userId?: string }

      the data to use

      • optionalargs: string

        the arguments for the job

      • optionalmetadata: string

        the metadata for the job

      • optionalstartTime: number

        the start time for the task

      • task: string

        the task to execute

      • optionaluserId: string

        the user id

    Returns Promise<string>

    the task id

publicdecrypt

  • decrypt(params: { context: string; data: string; keyId?: string }): Promise<undefined | string>
  • Decrypts the data


    Parameters

    • params: { context: string; data: string; keyId?: string }
      • context: string

        the context

      • data: string

        the data

      • optionalkeyId: string

        the key id, optional

    Returns Promise<undefined | string>

publicdeleteTask

  • deleteTask(taskId: string): Promise<void>
  • Deletes a task from the local cloud


    Parameters

    • taskId: string

      the task id to delete

    Returns Promise<void>

publicdeleteTransaction

  • deleteTransaction(txId: string): Promise<void>
  • Deletes a transaction from the local cloud


    Parameters

    • txId: string

      the transaction id to delete

    Returns Promise<void>

publicencrypt

  • encrypt(params: { context: string; data: string; keyId?: string }): Promise<undefined | string>
  • Encrypts the data


    Parameters

    • params: { context: string; data: string; keyId?: string }
      • context: string

        the context

      • data: string

        the data

      • optionalkeyId: string

        the key id, optional

    Returns Promise<undefined | string>

    encrypted data

publicexecute

  • execute(data: { args?: string; metadata?: string; task: string; transactions: string[]; userId?: string }): Promise<string>
  • Executes the task in the local cloud


    Parameters

    • data: { args?: string; metadata?: string; task: string; transactions: string[]; userId?: string }

      the data to use

      • optionalargs: string

        the arguments for the job

      • optionalmetadata: string

        the metadata for the job

      • task: string

        the task to execute

      • transactions: string[]

        the transactions to process

      • optionaluserId: string

        the user id

    Returns Promise<string>

    the job id

forceWorkerRestart

  • forceWorkerRestart(): Promise<void>
  • forces the worker to restart


    Returns Promise<void>

publicgetDataByKey

  • getDataByKey(key: string): Promise<undefined | string>
  • Gets the data by key


    Parameters

    • key: string

      the key to get the data

    Returns Promise<undefined | string>

    the data

publicgetDeployer

  • Provides the deployer key pair for testing and development


    Returns Promise<undefined | DeployerKeyPair>

    the deployer key pair

publicgetTransactions

  • Abstract method to get the transactions Used to get the transactions


    Returns Promise<CloudTransaction[]>

    the transactions

publicjobResult

  • jobResult(jobId: string): Promise<undefined | JobData>
  • Gets the job result


    Parameters

    • jobId: string

      the job id

    Returns Promise<undefined | JobData>

    the job data

publicloadFile

  • loadFile(filename: string): Promise<undefined | Buffer>
  • Loads the file


    Parameters

    • filename: string

    Returns Promise<undefined | Buffer>

    the file data

publicprocessTasks

  • processTasks(): Promise<void>
  • Processes the tasks in the local cloud


    Returns Promise<void>

publicpublishTransactionMetadata

  • publishTransactionMetadata(params: { metadata: TransactionMetadata; txId: string }): Promise<void>
  • Publish the transaction metadata in human-readable format


    Parameters

    Returns Promise<void>

publicrecursiveProof

  • recursiveProof(data: { args?: string; metadata?: string; task?: string; transactions: string[]; userId?: string }): Promise<string>
  • Runs the recursive proof in the local cloud


    Parameters

    • data: { args?: string; metadata?: string; task?: string; transactions: string[]; userId?: string }

      the data to use

      • optionalargs: string

        the arguments for the job

      • optionalmetadata: string

        the metadata for the job

      • optionaltask: string

        the task to execute

      • transactions: string[]

        the transactions to process

      • optionaluserId: string

        the user id

    Returns Promise<string>

    the job id

publicreleaseDeployer

  • releaseDeployer(params: { publicKey: string; txsHashes: string[] }): Promise<void>
  • Releases the deployer key pair


    Parameters

    • params: { publicKey: string; txsHashes: string[] }
      • publicKey: string
      • txsHashes: string[]

    Returns Promise<void>

publicsaveDataByKey

  • saveDataByKey(key: string, value: undefined | string): Promise<void>
  • Saves the data by key


    Parameters

    • key: string

      the key to save the data

    • value: undefined | string

      the value to save

    Returns Promise<void>

publicsaveFile

  • saveFile(filename: string, value: Buffer): Promise<void>
  • Saves the file


    Parameters

    • filename: string

      the filename to save

    • value: Buffer

      the value to save

    Returns Promise<void>

publicsendTransactions

  • Send transactions to the local cloud


    Parameters

    • transactions: string[]

      the transactions to add

    Returns Promise<CloudTransaction[]>

    the transaction ids

publicstaticaddTransactions

  • Adds transactions to the local cloud


    Parameters

    Returns Promise<CloudTransaction[]>

    the transaction ids

staticprocessLocalTasks

  • processLocalTasks(params: { chain: blockchain; developer: string; localWorker: (cloud: Cloud) => Promise<zkCloudWorker>; repo: string }): Promise<number>
  • Processes the local tasks


    Parameters

    • params: { chain: blockchain; developer: string; localWorker: (cloud: Cloud) => Promise<zkCloudWorker>; repo: string }

      the parameters to process the local tasks

      • chain: blockchain

        the blockchain to execute the job on

      • developer: string

        the developer of the repo

      • localWorker: (cloud: Cloud) => Promise<zkCloudWorker>

        the worker to execute the tasks

      • repo: string

        the repo

    Returns Promise<number>

publicstaticrun

  • run(params: { chain: blockchain; command: ApiCommand; data: { args?: string; developer: string; metadata?: string; repo: string; task: string; transactions: string[]; userId?: string }; localWorker: (cloud: Cloud) => Promise<zkCloudWorker> }): Promise<string>
  • Runs the worker in the local cloud


    Parameters

    • params: { chain: blockchain; command: ApiCommand; data: { args?: string; developer: string; metadata?: string; repo: string; task: string; transactions: string[]; userId?: string }; localWorker: (cloud: Cloud) => Promise<zkCloudWorker> }

      the parameters to run the worker

      • chain: blockchain

        the blockchain to execute the job on

      • command: ApiCommand

        the command to run

      • data: { args?: string; developer: string; metadata?: string; repo: string; task: string; transactions: string[]; userId?: string }

        the data to use

      • localWorker: (cloud: Cloud) => Promise<zkCloudWorker>

        the worker to execute the tasks

    Returns Promise<string>

    the job id

staticsequencer

  • sequencer(params: { data: { args?: string; developer: string; metadata?: string; repo: string; task?: string; transactions: string[]; userId?: string }; worker: zkCloudWorker }): Promise<string>
  • Runs the sequencer in the local cloud


    Parameters

    • params: { data: { args?: string; developer: string; metadata?: string; repo: string; task?: string; transactions: string[]; userId?: string }; worker: zkCloudWorker }

      the parameters to run the sequencer

      • data: { args?: string; developer: string; metadata?: string; repo: string; task?: string; transactions: string[]; userId?: string }

        the data to use

      • worker: zkCloudWorker

        the worker to execute the tasks

    Returns Promise<string>

    the proof