solana-go/serum/market.go

37 lines
733 B
Go
Raw Normal View History

2020-11-06 13:40:05 -08:00
package serum
import (
"encoding/json"
"fmt"
"os"
"github.com/dfuse-io/solana-go"
)
type MarketMeta struct {
Address solana.PublicKey `json:"address"`
Name string `json:"name"`
Deprecated bool `json:"deprecated"`
ProgramID solana.PublicKey `json:"programId"`
}
func KnownMarket() ([]*MarketMeta, error) {
f, err := os.Open("serum/markets.json")
if err != nil {
return nil, fmt.Errorf("unable to retrieve known markets: %w", err)
}
defer f.Close()
dec := json.NewDecoder(f)
var markets []*MarketMeta
err = dec.Decode(&markets)
if err != nil {
return nil, fmt.Errorf("unable to decode known markets: %w", err)
}
return markets, nil
}
type Market struct {
Meta *MarketMeta
}