1
1
package types
2
2
3
3
import (
4
+ sdkmath "cosmossdk.io/math"
4
5
sdk "github.com/cosmos/cosmos-sdk/types"
5
6
)
6
7
@@ -25,13 +26,17 @@ var (
25
26
EventIdKey = []byte {0x04 } // key for event id
26
27
AttestationIdKey = []byte {0x05 } // key for attestation id
27
28
28
- OracleKeyPrefix = []byte {0x10 } // prefix for each key to an oracle
29
- OracleByPubKeyKeyPrefix = []byte {0x11 } // prefix for each key to an oracle by public key
30
- AgencyKeyPrefix = []byte {0x12 } // prefix for each key to an agency
31
- NonceIndexKeyPrefix = []byte {0x13 } // key prefix for the nonce index
32
- NonceKeyPrefix = []byte {0x14 } // prefix for each key to a nonce
33
- EventKeyPrefix = []byte {0x15 } // prefix for each key to an event
34
- AttestationKeyPrefix = []byte {0x16 } // prefix for each key to an attestation
29
+ OracleKeyPrefix = []byte {0x10 } // prefix for each key to an oracle
30
+ OracleByPubKeyKeyPrefix = []byte {0x11 } // prefix for each key to an oracle by public key
31
+ PendingOraclePubKeyKeyPrefix = []byte {0x12 } // key prefix for the pending oracle public key
32
+ AgencyKeyPrefix = []byte {0x13 } // prefix for each key to an agency
33
+ PendingAgencyPubKeyKeyPrefix = []byte {0x14 } // key prefix for the pending agency public key
34
+ NonceIndexKeyPrefix = []byte {0x15 } // key prefix for the nonce index
35
+ NonceKeyPrefix = []byte {0x16 } // prefix for each key to a nonce
36
+ EventKeyPrefix = []byte {0x17 } // prefix for each key to an event
37
+ EventByPriceKeyPrefix = []byte {0x18 } // prefix for each key to an event by triggering price
38
+ CurrentEventPriceKeyPrefix = []byte {0x19 } // key prefix for the current event price
39
+ AttestationKeyPrefix = []byte {0x20 } // prefix for each key to an attestation
35
40
36
41
PriceKeyPrefix = []byte {0x20 } // key prefix for the price
37
42
)
@@ -44,10 +49,24 @@ func OracleByPubKeyKey(pubKey []byte) []byte {
44
49
return append (OracleByPubKeyKeyPrefix , pubKey ... )
45
50
}
46
51
52
+ func PendingOraclePubKeyKey (id uint64 , sender string , pubKey []byte ) []byte {
53
+ key := append (PendingOraclePubKeyKeyPrefix , sdk .Uint64ToBigEndian (id )... )
54
+ key = append (key , []byte (sender )... )
55
+
56
+ return append (key , pubKey ... )
57
+ }
58
+
47
59
func AgencyKey (id uint64 ) []byte {
48
60
return append (AgencyKeyPrefix , sdk .Uint64ToBigEndian (id )... )
49
61
}
50
62
63
+ func PendingAgencyPubKeyKey (id uint64 , sender string , pubKey []byte ) []byte {
64
+ key := append (PendingAgencyPubKeyKeyPrefix , sdk .Uint64ToBigEndian (id )... )
65
+ key = append (key , []byte (sender )... )
66
+
67
+ return append (key , pubKey ... )
68
+ }
69
+
51
70
func NonceIndexKey (oracleId uint64 ) []byte {
52
71
return append (NonceIndexKeyPrefix , sdk .Uint64ToBigEndian (oracleId )... )
53
72
}
@@ -60,6 +79,14 @@ func EventKey(id uint64) []byte {
60
79
return append (EventKeyPrefix , sdk .Uint64ToBigEndian (id )... )
61
80
}
62
81
82
+ func EventByPriceKey (price sdkmath.Int ) []byte {
83
+ return append (EventByPriceKeyPrefix , price .BigInt ().Bytes ()... )
84
+ }
85
+
86
+ func CurrentEventPriceKey (pair string ) []byte {
87
+ return append (CurrentEventPriceKeyPrefix , []byte (pair )... )
88
+ }
89
+
63
90
func AttestationKey (id uint64 ) []byte {
64
91
return append (AttestationKeyPrefix , sdk .Uint64ToBigEndian (id )... )
65
92
}
0 commit comments