Skip to content

Commit

Permalink
add lightweight state contract, prepare querying methods for rarimo e…
Browse files Browse the repository at this point in the history
…vm core
  • Loading branch information
lukachi committed Aug 8, 2023
1 parent 8939427 commit b974b08
Show file tree
Hide file tree
Showing 11 changed files with 2,663 additions and 335 deletions.
610 changes: 610 additions & 0 deletions packages/shared-zkp-iden3/abis/lightweight-state-v2.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/shared-zkp-iden3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
},
"dependencies": {
"@distributedlab/fetcher": "^1.0.0-rc.6",
"@rarimo/client": "workspace:^",
"tslib": "^2.5.0"
},
"typedocOptions": {
Expand Down
28 changes: 27 additions & 1 deletion packages/shared-zkp-iden3/src/helpers/state-v2-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Provider } from '@ethersproject/providers'
import type { RarimoQuerier, StateInfo } from '@rarimo/client'
import type { RawProvider } from '@rarimo/provider'
import { providers } from 'ethers'

import { StateV2__factory } from '@/types'
import { LightweightStateV2__factory, StateV2__factory } from '@/types'
import type { ILightweightState } from '@/types/contracts/LightweightStateV2'

export const getGISTProof = async ({
rpcUrl,
Expand All @@ -22,3 +24,27 @@ export const getGISTProof = async ({

return contractInstance.getGISTProof(userId)
}

export const getGISTRootInfo = async ({
rpcUrl,
rawProvider,
contractAddress,
}: {
rpcUrl?: string
rawProvider?: RawProvider
contractAddress: string
}): Promise<ILightweightState.GistRootDataStructOutput> => {
const contractInstance = LightweightStateV2__factory.connect(
contractAddress,
(rawProvider || new providers.JsonRpcProvider(rpcUrl, 'any')) as Provider,
)

return contractInstance.getCurrentGISTRootInfo()
}

export const getCoreChainStateInfo = async (
querier: RarimoQuerier,
id: string,
): Promise<StateInfo> => {
return querier.getState(id)
}
Loading

0 comments on commit b974b08

Please sign in to comment.