Skip to content

Commit b37486e

Browse files
committed
rfq: oracle rpc accept group keys
The public oracle server RPC endpoints for querying prices would only accept a specifier that sets only the asset ID. We may now accept group keys as well, so we consider any specifier to be valid. This is needed as we're later going to create a oracle rpc server harness to test out this code path.
1 parent cb8f5d3 commit b37486e

File tree

1 file changed

+8
-42
lines changed

1 file changed

+8
-42
lines changed

rfq/oracle.go

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,8 @@ func (r *RpcPriceOracle) QueryAskPrice(ctx context.Context,
195195
assetRateHint fn.Option[rfqmsg.AssetRate]) (*OracleResponse,
196196
error) {
197197

198-
// For now, we only support querying the ask price with an asset ID.
199-
if !assetSpecifier.HasId() {
200-
return nil, fmt.Errorf("asset ID is nil")
201-
}
202-
203-
var (
204-
subjectAssetId = make([]byte, 32)
205-
paymentAssetId = make([]byte, 32)
206-
)
207-
208-
// The payment asset ID is BTC, so we leave it at all zeroes. We only
209-
// set the subject asset ID.
210-
assetSpecifier.WhenId(func(assetId asset.ID) {
211-
copy(subjectAssetId, assetId[:])
212-
})
198+
// The payment asset ID is BTC, so we leave it at all zeroes.
199+
var paymentAssetId = make([]byte, 32)
213200

214201
// Marshal asset max amount.
215202
assetMaxAmount := assetMaxAmt.UnwrapOr(0)
@@ -228,12 +215,8 @@ func (r *RpcPriceOracle) QueryAskPrice(ctx context.Context,
228215
)
229216

230217
req := &oraclerpc.QueryAssetRatesRequest{
231-
TransactionType: oraclerpc.TransactionType_SALE,
232-
SubjectAsset: &oraclerpc.AssetSpecifier{
233-
Id: &oraclerpc.AssetSpecifier_AssetId{
234-
AssetId: subjectAssetId,
235-
},
236-
},
218+
TransactionType: oraclerpc.TransactionType_SALE,
219+
SubjectAsset: rpcMarshalAssetSpecifier(assetSpecifier),
237220
SubjectAssetMaxAmount: assetMaxAmount,
238221
PaymentAsset: &oraclerpc.AssetSpecifier{
239222
Id: &oraclerpc.AssetSpecifier_AssetId{
@@ -303,21 +286,8 @@ func (r *RpcPriceOracle) QueryBidPrice(ctx context.Context,
303286
assetRateHint fn.Option[rfqmsg.AssetRate]) (*OracleResponse,
304287
error) {
305288

306-
// For now, we only support querying the ask price with an asset ID.
307-
if !assetSpecifier.HasId() {
308-
return nil, fmt.Errorf("asset ID is nil")
309-
}
310-
311-
var (
312-
subjectAssetId = make([]byte, 32)
313-
paymentAssetId = make([]byte, 32)
314-
)
315-
316-
// The payment asset ID is BTC, so we leave it at all zeroes. We only
317-
// set the subject asset ID.
318-
assetSpecifier.WhenId(func(assetId asset.ID) {
319-
copy(subjectAssetId, assetId[:])
320-
})
289+
// The payment asset ID is BTC, so we leave it at all zeroes.
290+
var paymentAssetId = make([]byte, 32)
321291

322292
// Marshal asset max amount.
323293
assetMaxAmount := assetMaxAmt.UnwrapOr(0)
@@ -336,12 +306,8 @@ func (r *RpcPriceOracle) QueryBidPrice(ctx context.Context,
336306
}
337307

338308
req := &oraclerpc.QueryAssetRatesRequest{
339-
TransactionType: oraclerpc.TransactionType_PURCHASE,
340-
SubjectAsset: &oraclerpc.AssetSpecifier{
341-
Id: &oraclerpc.AssetSpecifier_AssetId{
342-
AssetId: subjectAssetId,
343-
},
344-
},
309+
TransactionType: oraclerpc.TransactionType_PURCHASE,
310+
SubjectAsset: rpcMarshalAssetSpecifier(assetSpecifier),
345311
SubjectAssetMaxAmount: assetMaxAmount,
346312
PaymentAsset: &oraclerpc.AssetSpecifier{
347313
Id: &oraclerpc.AssetSpecifier_AssetId{

0 commit comments

Comments
 (0)