Skip to content

Commit 1d179c5

Browse files
Merge pull request #32 from rarimo/feat/root-v2
Return state root in get-state-v2
2 parents 67829e5 + 70df043 commit 1d179c5

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

docs/spec/components/schemas/StateV2.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ allOf:
77
attributes:
88
type: object
99
required:
10+
- root
1011
- signature
1112
- timestamp
1213
properties:
14+
root:
15+
example: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
16+
type: string
17+
pattern: '^0x[0-9a-fA-F]{64}$'
18+
description: Root hash of the state tree
1319
signature:
1420
example: "0xd0bf2f6c2270874d8870a1081b67fcb0280b61db000778f159ba39c38fb2595639c2e1d81d085916ba6ec77f2bd4c4a2ae6dfbdbaf8703da7d9fe629b2e1218a00"
1521
type: string

docs/spec/components/schemas/StateV2Key.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ required:
55
properties:
66
id:
77
type: string
8+
description: Unique ID of the state record in db
89
type:
910
type: string
1011
enum:

internal/service/api/handlers/get_signed_state_v2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func GetSignedStateV2(w http.ResponseWriter, r *http.Request) {
5959
Type: resources.STATE_V2,
6060
},
6161
Attributes: resources.StateV2Attributes{
62+
Root: state.Root,
6263
Signature: hex.EncodeToString(signature),
6364
Timestamp: int64(state.Timestamp),
6465
},

resources/model_state_v2_attributes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package resources
66

77
type StateV2Attributes struct {
8+
// Root hash of the state tree
9+
Root string `json:"root"`
810
// Signature of root state signed by relayer private key, with the last byte of the signature set to 27/28.
911
Signature string `json:"signature"`
1012
// Time indicates when the event was caught, a.k.a state transition timestamp

0 commit comments

Comments
 (0)