Skip to content

Commit

Permalink
fix(rln-db-inspector): use valueOr pattern (#2012)
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc authored Sep 8, 2023
1 parent ec42e2c commit a8095d8
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions tools/rln_db_inspector/rln_db_inspector.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,23 @@ logScope:
when isMainModule:
{.pop.}
# 1. load configuration
let conf = RlnDbInspectorConf.loadConfig().isOkOr:
error "failure while loading the configuration", error=confRes.error
let conf = RlnDbInspectorConf.loadConfig().valueOr:
error "failure while loading the configuration", error
quit(1)

trace "configuration", conf = $conf

# 2. initialize rlnInstance
let rlnInstanceRes = createRLNInstance(d=20,
tree_path = conf.rlnRelayTreePath)
if rlnInstanceRes.isErr():
error "failure while creating RLN instance", error=rlnInstanceRes.error
let rlnInstance = createRLNInstance(d=20,
tree_path = conf.rlnRelayTreePath).valueOr:
error "failure while creating RLN instance", error
quit(1)

let rlnInstance = rlnInstanceRes.get()

# 3. get metadata
let metadataGetRes = rlnInstance.getMetadata()
if metadataGetRes.isErr():
error "failure while getting RLN metadata", error=metadataGetRes.error
let metadata = rlnInstance.getMetadata().valueOr:
error "failure while getting RLN metadata", error
quit(1)

let metadata = metadataGetRes.get()

info "RLN metadata", lastProcessedBlock = metadata.lastProcessedBlock,
chainId = metadata.chainId,
contractAddress = metadata.contractAddress,
Expand Down

0 comments on commit a8095d8

Please sign in to comment.