Add voucher data handler
This commit is contained in:
parent
c834dbb8c2
commit
bc9d365fbb
25
dev/api.go
25
dev/api.go
@ -35,13 +35,18 @@ type account struct {
|
||||
}
|
||||
|
||||
type voucher struct {
|
||||
name string
|
||||
address string
|
||||
symbol string
|
||||
decimals int
|
||||
sink string
|
||||
commodity string
|
||||
location string
|
||||
}
|
||||
|
||||
var (
|
||||
vouchers = make(map[string]voucher)
|
||||
vouchersAddress = make(map[string]string)
|
||||
)
|
||||
|
||||
type DevAccountService struct {
|
||||
@ -160,3 +165,23 @@ func (das *DevAccountService) FetchTransactions(ctx context.Context, publicKey s
|
||||
}
|
||||
return lasttx, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) VoucherData(ctx context.Context, address string) (*models.VoucherDataResult, error) {
|
||||
sym, ok := vouchersAddress[address]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("voucher address %v not found", address)
|
||||
}
|
||||
voucher, ok := vouchers[sym]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("voucher address %v found but does not resolve", address)
|
||||
}
|
||||
return &models.VoucherDataResult{
|
||||
TokenName: voucher.name,
|
||||
TokenSymbol: voucher.symbol,
|
||||
TokenDecimals: voucher.decimals,
|
||||
SinkAddress: voucher.sink,
|
||||
TokenCommodity: voucher.commodity,
|
||||
TokenLocation: voucher.location,
|
||||
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user