Skip to content
This repository was archived by the owner on May 31, 2023. It is now read-only.

Commit 5b2b616

Browse files
author
Richard Patel
committed
query: add more ProductAccount examples
1 parent c55145b commit 5b2b616

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

query_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,43 @@ var (
3434
testWS = "wss://api.devnet.solana.com"
3535
)
3636

37+
func ExampleClient_GetProductAccount() {
38+
client := NewClient(Devnet, testRPC, testWS)
39+
productPubkey := solana.MustPublicKeyFromBase58("EWxGfxoPQSNA2744AYdAKmsQZ8F9o9M7oKkvL3VM1dko")
40+
product, _ := client.GetProductAccount(context.TODO(), productPubkey)
41+
// Print first product as JSON.
42+
jsonData, _ := json.MarshalIndent(product, "", " ")
43+
fmt.Println(string(jsonData))
44+
// Output:
45+
// {
46+
// "first_price": "E36MyBbavhYKHVLWR79GiReNNnBDiHj6nWA7htbkNZbh",
47+
// "attrs": {
48+
// "asset_type": "FX",
49+
// "base": "EUR",
50+
// "description": "EUR/USD",
51+
// "generic_symbol": "EURUSD",
52+
// "quote_currency": "USD",
53+
// "symbol": "FX.EUR/USD",
54+
// "tenor": "Spot"
55+
// }
56+
// }
57+
}
58+
59+
func ExampleClient_GetAllProductKeys() {
60+
client := NewClient(Devnet, testRPC, testWS)
61+
products, _ := client.GetAllProductKeys(context.TODO())
62+
// Print first 5 product account pubkeys.
63+
for _, key := range products[:5] {
64+
fmt.Println(key)
65+
}
66+
// Output:
67+
// 89GseEmvNkzAMMEXcW9oTYzqRPXTsJ3BmNerXmgA1osV
68+
// JCnD5WiurZfoeVPEi2AXVgacg73Wd2iRDDjZDbSwdr9D
69+
// G89jkM5wFLpmnbvRbeePUumxsJyzoXaRfgBVjyx2CPzQ
70+
// GaBJpKtnyUbyKe34XuyegR7W98a9PT5cg985G974NY8R
71+
// Fwosgw2ikRvdzgKcQJwMacyczk3nXgoW3AtVtyVvXSAb
72+
}
73+
3774
func ExampleClient_GetAllProducts() {
3875
client := NewClient(Devnet, testRPC, testWS)
3976
products, _ := client.GetAllProducts(context.TODO())

0 commit comments

Comments
 (0)