-
Notifications
You must be signed in to change notification settings - Fork 36
/
types.go
58 lines (52 loc) · 1.79 KB
/
types.go
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
package rpc
import "github.com/ten-protocol/go-ten/go/common/viewingkey"
// EncRPC - the RPC method through which all encypted calls get routed
const EncRPC = "ten_encryptedRPC"
// encryptedMethods for which the RPC requests and responses should be encrypted
// these are names of virtual RPC methods exposed by a TEN node
// they all get routed through "ten_encryptedRPC"
const (
ERPCCall = "ten_call"
ERPCGetBalance = "ten_getBalance"
ERPCGetTransactionByHash = "ten_getTransactionByHash"
ERPCGetRawTransactionByHash = "ten_getRawTransactionByHash"
ERPCGetTransactionCount = "ten_getTransactionCount"
ERPCGetTransactionReceipt = "ten_getTransactionReceipt"
ERPCSendRawTransaction = "ten_sendRawTransaction"
ERPCResend = "ten_resend"
ERPCEstimateGas = "ten_estimateGas"
ERPCGetLogs = "ten_getLogs"
ERPCGetStorageAt = "ten_getStorageAt"
ERPCDebugLogs = "debug_eventLogRelevancy"
ERPCGetPersonalTransactions = "scan_getPersonalTransactions"
)
var encryptedMethods = []string{
ERPCCall,
ERPCGetBalance,
ERPCGetTransactionByHash,
ERPCGetRawTransactionByHash,
ERPCGetTransactionCount,
ERPCGetTransactionReceipt,
ERPCSendRawTransaction,
ERPCResend,
ERPCEstimateGas,
ERPCGetLogs,
ERPCGetStorageAt,
ERPCDebugLogs,
ERPCGetPersonalTransactions,
}
// IsEncryptedMethod indicates whether the RPC method's requests and responses should be encrypted.
func IsEncryptedMethod(method string) bool {
for _, m := range encryptedMethods {
if m == method {
return true
}
}
return false
}
// RequestWithVk - wraps the eth parameters with a viewing key
type RequestWithVk struct {
VK *viewingkey.RPCSignedViewingKey
Method string // can be only one of the encrypted methods above
Params []any
}