Skip to content

Commit

Permalink
Merge pull request #15 from maestro-org/release-please--branches--mai…
Browse files Browse the repository at this point in the history
…n--changes--next

release: 0.1.0-alpha.4
  • Loading branch information
Vardominator authored Oct 8, 2024
2 parents f3d944b + 86d4ba5 commit 51040fc
Show file tree
Hide file tree
Showing 51 changed files with 145 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.3"
".": "0.1.0-alpha.4"
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.0-alpha.4 (2024-10-08)

Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/maestro-org/maestro-bitcoin-go-sdk/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)

### Features

* **api:** update via SDK Studio ([#11](https://github.com/maestro-org/maestro-bitcoin-go-sdk/issues/11)) ([11a3e7b](https://github.com/maestro-org/maestro-bitcoin-go-sdk/commit/11a3e7bd6a5512e946140cded8806a5b95ea8894))
* **api:** update via SDK Studio ([#13](https://github.com/maestro-org/maestro-bitcoin-go-sdk/issues/13)) ([636420e](https://github.com/maestro-org/maestro-bitcoin-go-sdk/commit/636420ea7e5c57129bf846858df2bf1f72614634))

## 0.1.0-alpha.3 (2024-10-08)

Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/maestro-org/maestro-bitcoin-go-sdk/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)
Expand Down
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Maestro Bitcoin Go SDK
# Maestro Bitcoin Go API Library

<a href="https://pkg.go.dev/github.com/maestro-org/maestro-bitcoin-go-sdk"><img src="https://pkg.go.dev/badge/github.com/maestro-org/maestro-bitcoin-go-sdk.svg" alt="Go Reference"></a>

The Maestro Bitcoin Go SDK provides convenient access to [the Maestro Bitcoin REST
The Maestro Bitcoin Go library provides convenient access to [the Maestro REST
API](https://docs.gomaestro.org/) from applications written in Go. The full API of this library can be found in [api.md](api.md).

## Installation
Expand All @@ -22,7 +22,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/maestro-org/[email protected].3'
go get -u 'github.com/maestro-org/[email protected].4'
```

<!-- x-release-please-end -->
Expand All @@ -49,13 +49,17 @@ import (
func main() {
client := maestrobitcoingosdk.NewClient(
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("API_KEY")
option.WithEnvironmentMainnet(), // defaults to option.WithEnvironmentMainnet()
option.WithEnvironmentMainnet(), // or option.WithEnvironmentTestnet() | option.WithEnvironmentDefault(); defaults to option.WithEnvironmentTestnet()
)
paginatedUtxo, err := client.Addresses.Utxos.List(
context.TODO(),
"REPLACE_ME",
maestrobitcoingosdk.AddressUtxoListParams{},
)
timestampedBlock, err := client.Blocks.Latest.Get(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", timestampedBlock.Data)
fmt.Printf("%+v\n", paginatedUtxo.Data)
}

```
Expand Down Expand Up @@ -144,7 +148,7 @@ client := maestrobitcoingosdk.NewClient(
option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Blocks.Latest.Get(context.TODO(), ...,
client.Addresses.Utxos.List(context.TODO(), ...,
// Override the header
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
// Add an undocumented field to the request body, using sjson syntax
Expand Down Expand Up @@ -173,14 +177,18 @@ When the API returns a non-success status code, we return an error with type
To handle errors, we recommend that you use the `errors.As` pattern:

```go
_, err := client.Blocks.Latest.Get(context.TODO())
_, err := client.Addresses.Utxos.List(
context.TODO(),
"REPLACE_ME",
maestrobitcoingosdk.AddressUtxoListParams{},
)
if err != nil {
var apierr *maestrobitcoingosdk.Error
if errors.As(err, &apierr) {
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
}
panic(err.Error()) // GET "/blocks/latest": 400 Bad Request { ... }
panic(err.Error()) // GET "/addresses/{address}/utxos": 400 Bad Request { ... }
}
```

Expand All @@ -198,8 +206,10 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Blocks.Latest.Get(
client.Addresses.Utxos.List(
ctx,
"REPLACE_ME",
maestrobitcoingosdk.AddressUtxoListParams{},
// This sets the per-retry timeout
option.WithRequestTimeout(20*time.Second),
)
Expand Down Expand Up @@ -233,7 +243,12 @@ client := maestrobitcoingosdk.NewClient(
)

// Override per-request:
client.Blocks.Latest.Get(context.TODO(), option.WithMaxRetries(5))
client.Addresses.Utxos.List(
context.TODO(),
"REPLACE_ME",
maestrobitcoingosdk.AddressUtxoListParams{},
option.WithMaxRetries(5),
)
```

### Making custom/undocumented requests
Expand Down
2 changes: 1 addition & 1 deletion address.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// AddressService contains methods and other services that help with interacting
// with the maestro API.
// with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
2 changes: 1 addition & 1 deletion addressbrc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// AddressBrc20Service contains methods and other services that help with
// interacting with the maestro API.
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions addressbrc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAddressBrc20List(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion addressrune.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AddressRuneService contains methods and other services that help with
// interacting with the maestro API.
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
2 changes: 2 additions & 0 deletions addressrune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAddressRuneGetWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down Expand Up @@ -47,6 +48,7 @@ func TestAddressRuneGetWithOptionalParams(t *testing.T) {
}

func TestAddressRuneList(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion addresstx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AddressTxService contains methods and other services that help with interacting
// with the maestro API.
// with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions addresstx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAddressTxListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion addressutxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AddressUtxoService contains methods and other services that help with
// interacting with the maestro API.
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions addressutxo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAddressUtxoListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// AssetService contains methods and other services that help with interacting with
// the maestro API.
// the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
2 changes: 1 addition & 1 deletion assetbrc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AssetBrc20Service contains methods and other services that help with interacting
// with the maestro API.
// with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
2 changes: 2 additions & 0 deletions assetbrc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAssetBrc20Get(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand All @@ -36,6 +37,7 @@ func TestAssetBrc20Get(t *testing.T) {
}

func TestAssetBrc20ListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion assetbrc20holder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AssetBrc20HolderService contains methods and other services that help with
// interacting with the maestro API.
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions assetbrc20holder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAssetBrc20HolderListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion assetrune.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AssetRuneService contains methods and other services that help with interacting
// with the maestro API.
// with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
2 changes: 2 additions & 0 deletions assetrune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAssetRuneGet(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand All @@ -36,6 +37,7 @@ func TestAssetRuneGet(t *testing.T) {
}

func TestAssetRuneListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion assetruneholder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AssetRuneHolderService contains methods and other services that help with
// interacting with the maestro API.
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions assetruneholder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAssetRuneHolderListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion assetruneutxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// AssetRuneUtxoService contains methods and other services that help with
// interacting with the maestro API.
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions assetruneutxo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestAssetRuneUtxoListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion block.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// BlockService contains methods and other services that help with interacting with
// the maestro API.
// the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestBlockGet(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
2 changes: 1 addition & 1 deletion blocklatest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// BlockLatestService contains methods and other services that help with
// interacting with the maestro API.
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
Expand Down
1 change: 1 addition & 0 deletions blocklatest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestBlockLatestGet(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// Client creates a struct with services and top level methods that help with
// interacting with the maestro API. You should not instantiate this client
// interacting with the Maestro API. You should not instantiate this client
// directly, and instead use the [NewClient] method instead.
type Client struct {
Options []option.RequestOption
Expand All @@ -30,7 +30,7 @@ type Client struct {
// default arguments, and all option will be passed down to the services and
// requests that this client makes.
func NewClient(opts ...option.RequestOption) (r *Client) {
defaults := []option.RequestOption{option.WithEnvironmentMainnet()}
defaults := []option.RequestOption{option.WithEnvironmentTestnet()}
if o, ok := os.LookupEnv("API_KEY"); ok {
defaults = append(defaults, option.WithAPIKey(o))
}
Expand Down
Loading

0 comments on commit 51040fc

Please sign in to comment.