Skip to content

Commit

Permalink
chore: publish throw GraphAlreadyExist error
Browse files Browse the repository at this point in the history
  • Loading branch information
murongg committed Dec 7, 2023
1 parent ec53264 commit 3e7b984
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/zkgraph-cli/src/commands/publish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs'
import { ethers } from 'ethers'
import to from 'await-to-js'
import * as zkgapi from '@hyperoracle/zkgraph-api'
import { logger } from '../logger'
import { loadJsonRpcProviderUrl, logDivider } from '../utils'
Expand Down Expand Up @@ -37,15 +38,24 @@ export async function publish(options: PublishOptions) {
const wasm = fs.readFileSync(wasmPath)
const wasmUint8Array = new Uint8Array(wasm)

const publishTxHash = await zkgapi.publish(
const [err, publishTxHash] = await to(zkgapi.publish(
{ wasmUint8Array, zkgraphYaml },
zkWasmProviderUrl,
provider,
ipfsHash,
newBountyRewardPerTrigger,
signer,
true,
)
))
if (err) {
if (err instanceof zkgapi.Error.GraphAlreadyExist) {
logger.error(`[-] PUBLISH FAILED. ${err.message}`)
return publishTxHash
}
else {
throw err
}
}

if (publishTxHash === '')
logger.error('[-] PUBLISH FAILED.')
Expand Down

0 comments on commit 3e7b984

Please sign in to comment.