diff --git a/examples/query/main.go b/examples/query/main.go index d9a817d..86048a3 100644 --- a/examples/query/main.go +++ b/examples/query/main.go @@ -8,6 +8,7 @@ import ( "log" "connectrpc.com/connect" + "github.com/blinklabs-io/gouroboros/ledger/common" "github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano" "github.com/utxorpc/go-codegen/utxorpc/v1alpha/query" utxorpc "github.com/utxorpc/go-sdk" @@ -34,7 +35,7 @@ func main() { case "readUtxos": readUtxos(ctx, client, "71a7498f086d378ec5e558581286629b678be1dd65d5d4e2a5d634ba6fdf8299", 0) case "searchUtxos": - searchUtxos(ctx, client, "60c0359ebb7d0688d79064bd118c99c8b87b5853e3af59245bb97e84d2") + searchUtxos(ctx, client, "addr_test1qzrkvcfvd7k5jx54xxkz87p8xn88304jd2g4jsa0hwwmg20k3c7k36lsg8rdupz6e36j5ctzs6lzjymc9vw7djrmgdnqff9z6j") default: fmt.Println("Unknown mode:", mode) } @@ -123,9 +124,14 @@ func readUtxos(ctx context.Context, client *utxorpc.UtxorpcClient, txHashStr str } func searchUtxos(ctx context.Context, client *utxorpc.UtxorpcClient, rawAddress string) { - exactAddress, err := hex.DecodeString(rawAddress) + // Use to support bech32/base58 addresses + addr, err := common.NewAddress(rawAddress) if err != nil { - log.Fatalf("failed to decode hex string address: %v", err) + log.Fatalf("failed to create address: %v", err) + } + addrCbor, err := addr.MarshalCBOR() + if err != nil { + log.Fatalf("failed to marshal address to CBOR: %v", err) } req := connect.NewRequest(&query.SearchUtxosRequest{ @@ -134,7 +140,7 @@ func searchUtxos(ctx context.Context, client *utxorpc.UtxorpcClient, rawAddress UtxoPattern: &query.AnyUtxoPattern_Cardano{ Cardano: &cardano.TxOutputPattern{ Address: &cardano.AddressPattern{ - ExactAddress: exactAddress, + ExactAddress: addrCbor, }, }, }, @@ -162,7 +168,7 @@ func searchUtxos(ctx context.Context, client *utxorpc.UtxorpcClient, rawAddress fmt.Printf(" Native Bytes: %x\n", item.NativeBytes) if cardano := item.GetCardano(); cardano != nil { fmt.Println(" Cardano UTxO:") - fmt.Printf(" Address: %s\n", cardano.Address) + fmt.Printf(" Address: %x\n", cardano.Address) fmt.Printf(" Coin: %d\n", cardano.Coin) } } diff --git a/go.mod b/go.mod index 7b0ed82..cdc424b 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,25 @@ module github.com/utxorpc/go-sdk -go 1.21 +go 1.22 + +toolchain go1.22.8 // XXX: uncomment when testing local changes to spec, after generate // replace github.com/utxorpc/go-codegen => ../go-codegen require ( connectrpc.com/connect v1.17.0 - github.com/utxorpc/go-codegen v0.11.0 + github.com/blinklabs-io/gouroboros v0.103.6 + github.com/utxorpc/go-codegen v0.12.0 golang.org/x/net v0.31.0 google.golang.org/protobuf v1.35.1 ) require ( - github.com/google/go-cmp v0.6.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/jinzhu/copier v0.4.0 // indirect + github.com/x448/float16 v0.8.4 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/sys v0.27.0 // indirect golang.org/x/text v0.20.0 // indirect ) diff --git a/go.sum b/go.sum index 6c9781c..faa820f 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,34 @@ connectrpc.com/connect v1.17.0 h1:W0ZqMhtVzn9Zhn2yATuUokDLO5N+gIuBWMOnsQrfmZk= connectrpc.com/connect v1.17.0/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/blinklabs-io/gouroboros v0.103.6 h1:UG3ZjJh7yHihZmR18/0+QQliyq0xVoWgpgXuKdULD9o= +github.com/blinklabs-io/gouroboros v0.103.6/go.mod h1:nW0/J6Zv5Oupr4MHehfJ3noSXu7VSxKWusFRNKo0nhI= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/utxorpc/go-codegen v0.11.0 h1:MxiC//jV/2xj8kadAuiW7wgtbE+4YhYrf4uxCh8NheA= -github.com/utxorpc/go-codegen v0.11.0/go.mod h1:NHXsykQWNetMMm2Kak+PfqmEY9Htgs6unJENPC4Kobs= +github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/utxorpc/go-codegen v0.12.0 h1:uSmJ4jTQpFbPaq8zCdYJi1/pnJmoCLFCcBitybjH+gQ= +github.com/utxorpc/go-codegen v0.12.0/go.mod h1:NHXsykQWNetMMm2Kak+PfqmEY9Htgs6unJENPC4Kobs= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=