Skip to content

Commit 686a805

Browse files
committed
update: signed state response with caught timestamp
1 parent 5151056 commit 686a805

File tree

7 files changed

+55
-44
lines changed

7 files changed

+55
-44
lines changed

docs/spec/components/schemas/Signature.yaml renamed to docs/spec/components/schemas/State.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ allOf:
88
type: object
99
required:
1010
- signature
11+
- timestamp
1112
properties:
1213
signature:
1314
example: "0xd0bf2f6c2270874d8870a1081b67fcb0280b61db000778f159ba39c38fb2595639c2e1d81d085916ba6ec77f2bd4c4a2ae6dfbdbaf8703da7d9fe629b2e1218a00"
1415
type: string
15-
pattern: '^0x([0-9a-fA-F]+)$'
16+
pattern: '^0x([0-9a-fA-F]+)$'
17+
description: Signature of root state signed by relayer private key.
18+
timestamp:
19+
example: "1733395652"
20+
type: integer
21+
format: int64
22+
description: Time indicates when the event was caught, a.k.a state transition timestamp

docs/spec/paths/integrations@proof-verification-relayer@v1@state.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ get:
3636
- data
3737
properties:
3838
data:
39-
$ref: '#/components/schemas/Signature'
39+
$ref: '#/components/schemas/State'
4040
'400':
4141
description: Bad Request Error
4242
content:

internal/service/api/handlers/get_signed_state.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ func GetSignedState(w http.ResponseWriter, r *http.Request) {
5050
return
5151
}
5252

53-
ape.Render(w, resources.Signature{
53+
ape.Render(w, resources.State{
5454
Key: resources.Key{
5555
ID: state.ID,
5656
Type: resources.STATE,
5757
},
58-
Attributes: resources.SignatureAttributes{
58+
Attributes: resources.StateAttributes{
5959
Signature: hex.EncodeToString(signature),
60+
Timestamp: state.CreatedAt.Unix(),
6061
},
6162
})
6263
}

resources/model_signature.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

resources/model_signature_attributes.go

Lines changed: 0 additions & 9 deletions
This file was deleted.

resources/model_state.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* GENERATED. Do not modify. Your changes might be overwritten!
3+
*/
4+
5+
package resources
6+
7+
type State struct {
8+
Key
9+
Attributes StateAttributes `json:"attributes"`
10+
}
11+
type StateResponse struct {
12+
Data State `json:"data"`
13+
Included Included `json:"included"`
14+
}
15+
16+
type StateListResponse struct {
17+
Data []State `json:"data"`
18+
Included Included `json:"included"`
19+
Links *Links `json:"links"`
20+
}
21+
22+
// MustState - returns State from include collection.
23+
// if entry with specified key does not exist - returns nil
24+
// if entry with specified key exists but type or ID mismatches - panics
25+
func (c *Included) MustState(key Key) *State {
26+
var state State
27+
if c.tryFindEntry(key, &state) {
28+
return &state
29+
}
30+
return nil
31+
}

resources/model_state_attributes.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* GENERATED. Do not modify. Your changes might be overwritten!
3+
*/
4+
5+
package resources
6+
7+
type StateAttributes struct {
8+
// Signature of root state signed by relayer private key.
9+
Signature string `json:"signature"`
10+
// Time indicates when the event was caught, a.k.a state transition timestamp
11+
Timestamp int64 `json:"timestamp"`
12+
}

0 commit comments

Comments
 (0)