Skip to content

Commit d652a21

Browse files
authored
refactor: move and rename helpers (#125)
Split primitives and helpers to their own functions. All primitives now take only connect request objects. Many helpers were renamed to reduce confusion with their primitives counterparts. Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
1 parent c620588 commit d652a21

8 files changed

Lines changed: 581 additions & 427 deletions

File tree

examples/query/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"os"
88

9+
"connectrpc.com/connect"
910
"github.com/blinklabs-io/gouroboros/ledger/common"
1011
"github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano"
1112
"github.com/utxorpc/go-codegen/utxorpc/v1alpha/query"
@@ -63,7 +64,7 @@ func main() {
6364

6465
func readParams(client *utxorpc.UtxorpcClient) {
6566
fmt.Println("Connecting to utxorpc host:", client.URL())
66-
resp, err := client.ReadParams()
67+
resp, err := client.GetProtocolParameters()
6768
if err != nil {
6869
utxorpc.HandleError(err)
6970
}
@@ -199,7 +200,7 @@ func searchUtxos(
199200
}
200201

201202
fmt.Println("connecting to utxorpc host:", client.URL())
202-
resp, err := client.SearchUtxos(searchRequest)
203+
resp, err := client.SearchUtxos(connect.NewRequest(searchRequest))
203204
if err != nil {
204205
utxorpc.HandleError(err)
205206
}

examples/submit/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func main() {
5555
// Modified submitTx to return transaction references
5656
func submitTx(client *utxorpc.UtxorpcClient, txCbor string) (string, error) {
5757
fmt.Println("Connecting to utxorpc host:", client.URL())
58-
resp, err := client.SubmitTx(txCbor)
58+
resp, err := client.SubmitTransaction(txCbor)
5959
if err != nil {
6060
var connectErr *connect.Error
6161
if errors.As(err, &connectErr) {
@@ -89,7 +89,7 @@ func submitTx(client *utxorpc.UtxorpcClient, txCbor string) (string, error) {
8989
}
9090

9191
func readMempool(client *utxorpc.UtxorpcClient) {
92-
resp, err := client.ReadMempool()
92+
resp, err := client.GetMempoolTransactions()
9393
if err != nil {
9494
utxorpc.HandleError(err)
9595
}
@@ -105,7 +105,7 @@ func waitForTx(
105105

106106
fmt.Println("Connecting to utxorpc host:", client.URL())
107107
// Open a streaming connection to wait for transaction confirmation
108-
stream, err := client.WaitForTx(txRef)
108+
stream, err := client.WaitForTransaction(txRef)
109109
if err != nil {
110110
return fmt.Errorf("failed to open waitForTx stream: %w", err)
111111
}
@@ -136,7 +136,7 @@ func waitForTx(
136136

137137
func watchMempool(client *utxorpc.UtxorpcClient) {
138138
fmt.Println("Connecting to utxorpc host:", client.URL())
139-
stream, err := client.WatchMempool()
139+
stream, err := client.WatchMempoolTransactions()
140140
if err != nil {
141141
utxorpc.HandleError(err)
142142
}

examples/sync/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func fetchBlock(
4040
blockIndex int64,
4141
) {
4242
fmt.Println("connecting to utxorpc host:", client.URL())
43-
resp, err := client.FetchBlock(blockHash, blockIndex)
43+
resp, err := client.GetBlockByRef(blockHash, blockIndex)
4444
if err != nil {
4545
utxorpc.HandleError(err)
4646
}
@@ -58,7 +58,7 @@ func followTip(
5858
blockIndex int64,
5959
) {
6060
fmt.Println("connecting to utxorpc host:", client.URL())
61-
stream, err := client.FollowTip(blockHash, blockIndex)
61+
stream, err := client.WatchBlocksByRef(blockHash, blockIndex)
6262
if err != nil {
6363
utxorpc.HandleError(err)
6464
return

0 commit comments

Comments
 (0)