Repository navigation
Expand file tree
/
Copy pathstate.ts
More file actions
81 lines (76 loc) · 2.39 KB
/
Copy pathstate.ts
File metadata and controls
81 lines (76 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { ZKProof } from '@iden3/js-jwz';
import { JsonRpcProvider, Signer } from 'ethers';
import { RootInfo, StateInfo, StateProof } from '../entities/state';
import { Id } from '@iden3/js-iden3-core';
import { Hash } from '@iden3/js-merkletree';
export interface UserStateTransitionInfo {
userId: Id; // Identity id
oldUserState: Hash; // Previous identity state
newUserState: Hash; // New identity state
isOldStateGenesis: boolean; // Is the previous state genesis?
methodId: bigint; // State transition method id
methodParams: string; // State transition method-specific params
}
/**
* Interface that defines methods for state storage
*
* @public
* @interface IStateStorage
*/
export interface IStateStorage {
/**
* gets latest state of identity
*
* @param {bigint} id - id to check
* @returns `Promise<StateInfo>`
*/
getLatestStateById(id: bigint): Promise<StateInfo>;
/**
* gets state info of identity by id and state
*
* @param {bigint} id - id to check
* @param {bigint} state - state to check
* @returns `Promise<StateInfo>`
*/
getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo>;
/**
* method to publish state onchain
*
* @param {ZKProof} proof - proof to publish
* @param {Signer} signer - signer of transaction
* @returns `Promise<string>` - transaction identifier
*/
publishState(proof: ZKProof | undefined, signer: Signer): Promise<string>;
/**
* method to publish state onchain
*
* @param {Signer} signer - signer of transaction
* @param {UserStateTransitionInfo} userStateTransitionInfo - user state transition information
* @returns `Promise<string>` - transaction identifier
*/
publishStateGeneric(
signer: Signer,
userStateTransitionInfo?: UserStateTransitionInfo
): Promise<string>;
/**
* generates proof of inclusion / non-inclusion to global identity state for given identity
*
* @param {bigint} id - id to check
* @returns `Promise<StateProof>`
*/
getGISTProof(id: bigint): Promise<StateProof>;
/**
* gets root info of global identity state tree
*
* @param {bigint} root - root to check
* @param {bigint} userId - user id
* @returns `Promise<RootInfo>`
*/
getGISTRootInfo(root: bigint, userId: bigint): Promise<RootInfo>;
/**
* gets RPC provider
*
* @returns `Promise<JsonRpcProvider>`
*/
getRpcProvider(): JsonRpcProvider;
}