Skip to content

Commit

Permalink
chore: upgrade cle api
Browse files Browse the repository at this point in the history
  • Loading branch information
murongg committed Feb 22, 2024
1 parent 7d6fe45 commit d5c08e9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/cle-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@antfu/utils": "^0.7.6",
"@ora-io/cle-api": "^1.0.3-alpha.9",
"@ora-io/cle-api": "^1.0.3-alpha.11",
"api": "^6.1.1",
"assemblyscript": "^0.27.12",
"await-to-js": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cle-cli/src/commands/compile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs'
import path from 'node:path'
import * as zkgapi from '@ora-io/cle-api'
import * as cleApi from '@ora-io/cle-api'
import webjson from '@ora-io/cle-lib/test/weblib/weblib.json'
import to from 'await-to-js'
import { CLEYaml } from '@ora-io/cle-api'
Expand Down Expand Up @@ -76,7 +76,7 @@ async function compileRun(options: CompileOptions) {

const relativeYamlPath = path.relative(dirPath, yamlPath)

const [err, res] = await to(zkgapi.compile({
const [err, res] = await to(cleApi.compile({
...webjson,
...fileMap,
[relativeYamlPath]: yaml,
Expand Down
4 changes: 2 additions & 2 deletions packages/cle-cli/src/commands/deposit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as zkgapi from '@ora-io/cle-api'
import * as cleApi from '@ora-io/cle-api'
import { ethers } from 'ethers'
import type { UserConfig } from '../config'
import { loadJsonRpcProviderUrl, loadYamlFromPath, logLoadingAnimation } from '../utils'
Expand Down Expand Up @@ -32,7 +32,7 @@ export async function deposit(options: DepositOptions) {
logger.info('[*] Please wait for deposit tx... (estimated: 30 sec)')
const loading = logLoadingAnimation()

const txReceipt = await zkgapi.deposit(
const txReceipt = await cleApi.deposit(
deployedContractAddress,
signer,
{ depositAmount },
Expand Down
6 changes: 3 additions & 3 deletions packages/cle-cli/src/commands/exec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs'
import to from 'await-to-js'
import * as zkgapi from '@ora-io/cle-api'
import * as cleApi from '@ora-io/cle-api'
import ethres from 'ethers'
import { generateDspHubParams, loadJsonRpcProviderUrl, loadYamlFromPath, toHexString } from '../utils'
import { logger } from '../logger'
Expand All @@ -22,7 +22,7 @@ export async function exec(options: ExecOptions) {
logger.error('[-] ERROR: Failed to get yaml')
return
}
const dsp = zkgapi.dspHub.getDSPByYaml(cleYaml)
const dsp = cleApi.dspHub.getDSPByYaml(cleYaml)
if (!dsp) {
logger.error('[-] ERROR: Failed to get DSP')
return
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function exec(options: ExecOptions) {
cleYaml,
}

const state = await zkgapi.execute(
const state = await cleApi.execute(
cleExecutable,
execParams,
// local,
Expand Down
16 changes: 8 additions & 8 deletions packages/cle-cli/src/commands/prove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs'
import { providers } from 'ethers'
import to from 'await-to-js'
import prompts from 'prompts'
import * as zkgapi from '@ora-io/cle-api'
import * as cleApi from '@ora-io/cle-api'
import type { Input } from 'zkwasm-toolchain'
import { convertToMd5, generateDspHubParams, loadJsonRpcProviderUrl, loadYamlFromPath, logLoadingAnimation, taskPrettyPrint, validateProvider } from '../utils'
import { logger } from '../logger'
Expand Down Expand Up @@ -45,7 +45,7 @@ export async function prove(options: ProveOptions) {
logger.error('[-] ERROR: Failed to get yaml')
return
}
const dsp = zkgapi.dspHub.getDSPByYaml(yaml)
const dsp = cleApi.dspHub.getDSPByYaml(yaml)
if (!dsp) {
logger.error('[-] ERROR: Failed to get DSP')
return
Expand Down Expand Up @@ -100,10 +100,10 @@ export async function prove(options: ProveOptions) {

const cleExecutable = {
wasmUint8Array,
cleYaml: yaml as zkgapi.CLEYaml,
cleYaml: yaml as cleApi.CLEYaml,
}

const input = await zkgapi.proveInputGen(
const input = await cleApi.proveInputGen(
cleExecutable,
proveParams,
)
Expand Down Expand Up @@ -134,7 +134,7 @@ async function testMode(wasmUint8Array: Uint8Array, input: Input) {
cleYaml: null,
}

const [mockErr, mockSuccess] = await to(zkgapi.proveMock(
const [mockErr, mockSuccess] = await to(cleApi.proveMock(
cleExecutable,
input,
))
Expand All @@ -146,7 +146,7 @@ async function testMode(wasmUint8Array: Uint8Array, input: Input) {

if (mockSuccess) {
logger.info('[+] ZKWASM MOCK EXECUTION SUCCESS!')
if (zkgapi.hasDebugOnlyFunc)
if (cleApi.hasDebugOnlyFunc)
logger.warn('[+] PLEASE REMOVE DEBUG FUNCTION (e.g. console.log) BEFORE PROVE MODE')
else
logger.warn('[+] READY FOR PROVE MODE: npx cle prove <block id> <expected state> --prove')
Expand Down Expand Up @@ -194,7 +194,7 @@ async function proveMode(userPrivateKey: string, md5: string, privateInputStr: s

const [queryTaskErr, data] = await to(dispatcher.queryTask(txhash))
if (queryTaskErr) {
if (queryTaskErr instanceof zkgapi.Error.TDNoTaskFound) {
if (queryTaskErr instanceof cleApi.Error.TDNoTaskFound) {
logger.error('[-] PLEASE REQUIRE FINISH SETUP FIRST.')
return
}
Expand All @@ -212,7 +212,7 @@ async function proveMode(userPrivateKey: string, md5: string, privateInputStr: s

const loading = logLoadingAnimation()

const [err, result] = await to(zkgapi.waitProve(zkWasmProviderUrl, taskId))
const [err, result] = await to(cleApi.waitProve(zkWasmProviderUrl, taskId))

if (err) {
loading.stopAndClear()
Expand Down
6 changes: 3 additions & 3 deletions packages/cle-cli/src/commands/publish.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs'
import { ethers } from 'ethers'
import to from 'await-to-js'
import * as zkgapi from '@ora-io/cle-api'
import * as cleApi from '@ora-io/cle-api'
import { logger } from '../logger'
import { loadJsonRpcProviderUrl, loadYamlFromPath, logDivider, logLoadingAnimation } from '../utils'
import type { UserConfig } from '../config'
Expand Down Expand Up @@ -42,7 +42,7 @@ export async function publish(options: PublishOptions) {

const loading = logLoadingAnimation()

const [err, txReceipt] = await to(zkgapi.publish(
const [err, txReceipt] = await to(cleApi.publish(
{ wasmUint8Array, cleYaml },
signer,
{
Expand All @@ -53,7 +53,7 @@ export async function publish(options: PublishOptions) {
))
if (err) {
loading.stopAndClear()
if (err instanceof zkgapi.Error.GraphAlreadyExist) {
if (err instanceof cleApi.Error.GraphAlreadyExist) {
logger.error(`[-] PUBLISH FAILED. ${err.message}`)
return
}
Expand Down
14 changes: 9 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5c08e9

Please sign in to comment.