|
6 | 6 | package main |
7 | 7 |
|
8 | 8 | import ( |
| 9 | + "bytes" |
9 | 10 | "context" |
10 | 11 | "crypto/ecdsa" |
11 | 12 | "crypto/elliptic" |
12 | 13 | "crypto/rand" |
13 | 14 | "crypto/tls" |
14 | 15 | "crypto/x509" |
15 | 16 | "crypto/x509/pkix" |
| 17 | + "encoding/hex" |
16 | 18 | "encoding/pem" |
17 | 19 | "fmt" |
18 | 20 | "io" |
@@ -68,15 +70,35 @@ type RpcPriceOracleServer struct { |
68 | 70 | func isSupportedSubjectAsset(subjectAsset *oraclerpc.AssetSpecifier) bool { |
69 | 71 | // Ensure that the subject asset is set. |
70 | 72 | if subjectAsset == nil { |
| 73 | + logrus.Info("Subject asset is not set (nil)") |
71 | 74 | return false |
72 | 75 | } |
73 | 76 |
|
74 | | - // In this example we'll only support a single asset. |
75 | | - assetIdStr := subjectAsset.GetAssetIdStr() |
76 | | - supportedAssetId := "7b4336d33b019df9438e586f83c587ca00fa65602497b9" + |
| 77 | + supportedAssetIdStr := "7b4336d33b019df9438e586f83c587ca00fa65602497b9" + |
77 | 78 | "3ace193e9ce53b1a67" |
| 79 | + supportedAssetIdBytes, err := hex.DecodeString(supportedAssetIdStr) |
| 80 | + if err != nil { |
| 81 | + fmt.Println("Error decoding supported asset hex string:", err) |
| 82 | + return false |
| 83 | + } |
| 84 | + |
| 85 | + // Check the subject asset bytes if set. |
| 86 | + subjectAssetIdBytes := subjectAsset.GetAssetId() |
| 87 | + if len(subjectAssetIdBytes) > 0 { |
| 88 | + logrus.Infof("Subject asset ID bytes populated: %x", |
| 89 | + supportedAssetIdBytes) |
| 90 | + return bytes.Equal(supportedAssetIdBytes, subjectAssetIdBytes) |
| 91 | + } |
| 92 | + |
| 93 | + subjectAssetIdStr := subjectAsset.GetAssetIdStr() |
| 94 | + if len(subjectAssetIdStr) > 0 { |
| 95 | + logrus.Infof("Subject asset ID str populated: %s", |
| 96 | + supportedAssetIdStr) |
| 97 | + return subjectAssetIdStr == supportedAssetIdStr |
| 98 | + } |
78 | 99 |
|
79 | | - return assetIdStr == supportedAssetId |
| 100 | + logrus.Infof("Subject asset ID not set") |
| 101 | + return false |
80 | 102 | } |
81 | 103 |
|
82 | 104 | // getRateTick returns a rate tick for a given transaction type and subject |
|
0 commit comments