Initial release of azimuth-client-go library
- Consolidated azimuth client implementations from zenithd and janus - Type-safe GraphQL client using genqlient code generation - Comprehensive caching with configurable TTL (1 hour default) - Full API coverage: authentication keys, ship activity, sponsorship, ownership - Enhanced functionality combining best features from both original implementations - Extensive test suite with 16 unit tests covering all functionality - Complete documentation with examples and usage patterns - Support for galaxy, star, and planet ship type classification - BigInt utility for proper GraphQL number handling - MIT licensed for open source usage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
4d7ab16549
34
.gitignore
vendored
Normal file
34
.gitignore
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
# IDE files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS generated files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Zenith Chain Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
57
Makefile
Normal file
57
Makefile
Normal file
@ -0,0 +1,57 @@
|
||||
.PHONY: build test lint generate clean help
|
||||
|
||||
# Build the library
|
||||
build:
|
||||
go build ./...
|
||||
|
||||
# Run tests
|
||||
test:
|
||||
go test -v ./...
|
||||
|
||||
# Run tests with coverage
|
||||
test-coverage:
|
||||
go test -v -coverprofile=coverage.out ./...
|
||||
go tool cover -html=coverage.out -o coverage.html
|
||||
|
||||
# Run integration tests (requires live endpoint)
|
||||
test-integration:
|
||||
go test -v ./... -run Integration
|
||||
|
||||
# Format code
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
# Run linter (requires golangci-lint)
|
||||
lint:
|
||||
golangci-lint run
|
||||
|
||||
# Generate GraphQL client code
|
||||
generate:
|
||||
go run github.com/Khan/genqlient@latest
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
go clean -testcache
|
||||
rm -f coverage.out coverage.html
|
||||
|
||||
# Tidy dependencies
|
||||
tidy:
|
||||
go mod tidy
|
||||
|
||||
# Run all checks (fmt, lint, test)
|
||||
check: fmt lint test
|
||||
|
||||
# Show help
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@echo " build - Build the library"
|
||||
@echo " test - Run all tests"
|
||||
@echo " test-coverage - Run tests with coverage report"
|
||||
@echo " test-integration - Run integration tests only"
|
||||
@echo " fmt - Format Go code"
|
||||
@echo " lint - Run linter (requires golangci-lint)"
|
||||
@echo " generate - Generate GraphQL client code"
|
||||
@echo " clean - Clean build artifacts"
|
||||
@echo " tidy - Tidy dependencies"
|
||||
@echo " check - Run fmt, lint, and test"
|
||||
@echo " help - Show this help message"
|
||||
103
README.md
Normal file
103
README.md
Normal file
@ -0,0 +1,103 @@
|
||||
# Azimuth Client Go
|
||||
|
||||
A Go client library for interacting with the Azimuth watcher GraphQL API. This library provides type-safe access to Azimuth ship data, including cryptographic keys, ownership information, and sponsorship relationships.
|
||||
|
||||
## Features
|
||||
|
||||
- Type-safe GraphQL client using genqlient
|
||||
- Automatic caching of ship keys with configurable TTL
|
||||
- Support for authentication and encryption key retrieval
|
||||
- Ship ownership and sponsorship queries
|
||||
- Ship activity status checking
|
||||
- Urbit ship type classification (galaxy, star, planet)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
go get github.com/zenithchain/azimuth-client-go
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Client Setup
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
azimuth "github.com/zenithchain/azimuth-client-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create client with default endpoint
|
||||
client := azimuth.NewClient("")
|
||||
|
||||
// Or with custom endpoint
|
||||
client = azimuth.NewClient("https://azimuth.dev.vdb.to")
|
||||
|
||||
// Get authentication key for a ship
|
||||
authKey, err := client.GetAuthenticationKey(context.Background(), 256)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Auth key: %x\n", authKey)
|
||||
}
|
||||
```
|
||||
|
||||
### Advanced Usage
|
||||
|
||||
```go
|
||||
// Check if ship is active
|
||||
active, err := client.IsShipActive(context.Background(), 256)
|
||||
|
||||
// Get ship's sponsor
|
||||
sponsor, err := client.GetSponsor(context.Background(), 1024)
|
||||
|
||||
// Get ship type
|
||||
shipType := azimuth.GetShipType(256) // "star"
|
||||
|
||||
// Validate star sponsorship
|
||||
err = azimuth.ValidateStarSponsorship(context.Background(), 256, 0, client)
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The client supports several configuration options:
|
||||
|
||||
- **Endpoint**: GraphQL endpoint URL (defaults to "https://azimuth.dev.vdb.to/graphql")
|
||||
- **Cache TTL**: Duration to cache ship keys (defaults to 1 hour)
|
||||
- **HTTP Timeout**: HTTP client timeout (defaults to 30 seconds)
|
||||
|
||||
## Development
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Go 1.23+
|
||||
- genqlient for GraphQL code generation
|
||||
|
||||
### Building
|
||||
|
||||
```bash
|
||||
go build ./...
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
go test ./...
|
||||
```
|
||||
|
||||
### Generating GraphQL Code
|
||||
|
||||
```bash
|
||||
go generate ./...
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
59
bigint.go
Normal file
59
bigint.go
Normal file
@ -0,0 +1,59 @@
|
||||
package azimuth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// BigInt is a wrapper around big.Int that implements JSON marshaling for GraphQL
|
||||
type BigInt struct {
|
||||
big.Int
|
||||
}
|
||||
|
||||
// NewBigInt creates a new BigInt from an int64
|
||||
func NewBigInt(value int64) BigInt {
|
||||
return BigInt{Int: *big.NewInt(value)}
|
||||
}
|
||||
|
||||
// NewBigIntFromUint32 creates a new BigInt from a uint32
|
||||
func NewBigIntFromUint32(value uint32) BigInt {
|
||||
return BigInt{Int: *big.NewInt(int64(value))}
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler for GraphQL serialization
|
||||
func (b BigInt) MarshalJSON() ([]byte, error) {
|
||||
return []byte(b.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements json.Unmarshaler for GraphQL deserialization
|
||||
func (b *BigInt) UnmarshalJSON(p []byte) error {
|
||||
// The output is string with escaped quotes
|
||||
cleanedStr := strings.Trim(string(p), `"`)
|
||||
if cleanedStr == "null" {
|
||||
return nil
|
||||
}
|
||||
|
||||
var z big.Int
|
||||
_, ok := z.SetString(cleanedStr, 10)
|
||||
if !ok {
|
||||
return fmt.Errorf("not a valid big integer: %s", p)
|
||||
}
|
||||
b.Int = z
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ToUint32 converts BigInt to uint32, returns error if out of range
|
||||
func (b BigInt) ToUint32() (uint32, error) {
|
||||
if !b.IsUint64() {
|
||||
return 0, fmt.Errorf("value is too large for uint32: %s", b.String())
|
||||
}
|
||||
|
||||
val := b.Uint64()
|
||||
if val > 0xFFFFFFFF {
|
||||
return 0, fmt.Errorf("value is too large for uint32: %d", val)
|
||||
}
|
||||
|
||||
return uint32(val), nil
|
||||
}
|
||||
255
bigint_test.go
Normal file
255
bigint_test.go
Normal file
@ -0,0 +1,255 @@
|
||||
package azimuth
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewBigInt(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value int64
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "zero",
|
||||
value: 0,
|
||||
expected: "0",
|
||||
},
|
||||
{
|
||||
name: "positive",
|
||||
value: 12345,
|
||||
expected: "12345",
|
||||
},
|
||||
{
|
||||
name: "negative",
|
||||
value: -12345,
|
||||
expected: "-12345",
|
||||
},
|
||||
{
|
||||
name: "large positive",
|
||||
value: 9223372036854775807, // max int64
|
||||
expected: "9223372036854775807",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
bigInt := NewBigInt(tt.value)
|
||||
assert.Equal(t, tt.expected, bigInt.String())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewBigIntFromUint32(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value uint32
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "zero",
|
||||
value: 0,
|
||||
expected: "0",
|
||||
},
|
||||
{
|
||||
name: "small value",
|
||||
value: 256,
|
||||
expected: "256",
|
||||
},
|
||||
{
|
||||
name: "max uint32",
|
||||
value: 4294967295, // max uint32
|
||||
expected: "4294967295",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
bigInt := NewBigIntFromUint32(tt.value)
|
||||
assert.Equal(t, tt.expected, bigInt.String())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBigInt_MarshalJSON(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
bigInt BigInt
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "zero",
|
||||
bigInt: NewBigInt(0),
|
||||
expected: "0",
|
||||
},
|
||||
{
|
||||
name: "positive",
|
||||
bigInt: NewBigInt(12345),
|
||||
expected: "12345",
|
||||
},
|
||||
{
|
||||
name: "negative",
|
||||
bigInt: NewBigInt(-12345),
|
||||
expected: "-12345",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
data, err := tt.bigInt.MarshalJSON()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.expected, string(data))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBigInt_UnmarshalJSON(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
expected string
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "zero",
|
||||
input: `"0"`,
|
||||
expected: "0",
|
||||
},
|
||||
{
|
||||
name: "positive",
|
||||
input: `"12345"`,
|
||||
expected: "12345",
|
||||
},
|
||||
{
|
||||
name: "negative",
|
||||
input: `"-12345"`,
|
||||
expected: "-12345",
|
||||
},
|
||||
{
|
||||
name: "large number",
|
||||
input: `"123456789012345678901234567890"`,
|
||||
expected: "123456789012345678901234567890",
|
||||
},
|
||||
{
|
||||
name: "null",
|
||||
input: `null`,
|
||||
expected: "0", // big.Int zero value
|
||||
},
|
||||
{
|
||||
name: "invalid format",
|
||||
input: `"not-a-number"`,
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid json",
|
||||
input: `invalid-json`,
|
||||
expectErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var bigInt BigInt
|
||||
err := bigInt.UnmarshalJSON([]byte(tt.input))
|
||||
|
||||
if tt.expectErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.expected, bigInt.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBigInt_ToUint32(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
bigInt BigInt
|
||||
expected uint32
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "zero",
|
||||
bigInt: NewBigInt(0),
|
||||
expected: 0,
|
||||
},
|
||||
{
|
||||
name: "small positive",
|
||||
bigInt: NewBigInt(256),
|
||||
expected: 256,
|
||||
},
|
||||
{
|
||||
name: "max uint32",
|
||||
bigInt: NewBigIntFromUint32(4294967295),
|
||||
expected: 4294967295,
|
||||
},
|
||||
{
|
||||
name: "negative",
|
||||
bigInt: NewBigInt(-1),
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "too large",
|
||||
bigInt: BigInt{Int: *big.NewInt(0).SetUint64(4294967296)}, // max uint32 + 1
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "way too large",
|
||||
bigInt: func() BigInt {
|
||||
var b BigInt
|
||||
b.SetString("123456789012345678901234567890", 10)
|
||||
return b
|
||||
}(),
|
||||
expectErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result, err := tt.bigInt.ToUint32()
|
||||
|
||||
if tt.expectErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBigInt_JSONRoundTrip(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value int64
|
||||
}{
|
||||
{"zero", 0},
|
||||
{"positive", 12345},
|
||||
{"negative", -12345},
|
||||
{"large", 9223372036854775807},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
original := NewBigInt(tt.value)
|
||||
|
||||
// Marshal to JSON
|
||||
data, err := json.Marshal(original)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Unmarshal from JSON
|
||||
var unmarshaled BigInt
|
||||
err = json.Unmarshal(data, &unmarshaled)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Check equality
|
||||
assert.Equal(t, original.String(), unmarshaled.String())
|
||||
})
|
||||
}
|
||||
}
|
||||
395
client.go
Normal file
395
client.go
Normal file
@ -0,0 +1,395 @@
|
||||
package azimuth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
)
|
||||
|
||||
// Default configuration constants
|
||||
const (
|
||||
// DefaultEndpoint is the default azimuth-watcher GraphQL endpoint
|
||||
DefaultEndpoint = "https://azimuth.dev.vdb.to/graphql"
|
||||
|
||||
// AzimuthContract is the Azimuth contract address on Ethereum mainnet
|
||||
AzimuthContract = "0x223c067F8CF28ae173EE5CafEa60cA44C335fecB"
|
||||
|
||||
// DefaultCacheTTL is the default cache duration for ship keys
|
||||
DefaultCacheTTL = 1 * time.Hour
|
||||
|
||||
// DefaultTimeout is the default HTTP client timeout
|
||||
DefaultTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
// Client provides access to the Azimuth watcher GraphQL API
|
||||
type Client struct {
|
||||
gqlClient graphql.Client
|
||||
cache *KeyCache
|
||||
contractAddress string
|
||||
}
|
||||
|
||||
// ShipKeys represents the cryptographic keys for an Urbit ship
|
||||
type ShipKeys struct {
|
||||
EncryptionKey []byte
|
||||
AuthenticationKey []byte
|
||||
CryptoSuiteVersion uint64
|
||||
KeyRevisionNumber uint64
|
||||
CachedAt time.Time
|
||||
}
|
||||
|
||||
// KeyCache caches ship keys with TTL
|
||||
type KeyCache struct {
|
||||
mu sync.RWMutex
|
||||
keys map[uint32]*ShipKeys
|
||||
ttl time.Duration
|
||||
}
|
||||
|
||||
// CachedKey represents a cached public key (for backwards compatibility)
|
||||
type CachedKey struct {
|
||||
PublicKey []byte
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
// NewClient creates a new Azimuth client with default configuration
|
||||
func NewClient(endpoint string) *Client {
|
||||
return NewClientWithOptions(ClientOptions{
|
||||
Endpoint: endpoint,
|
||||
CacheTTL: DefaultCacheTTL,
|
||||
Timeout: DefaultTimeout,
|
||||
})
|
||||
}
|
||||
|
||||
// ClientOptions configures the Azimuth client
|
||||
type ClientOptions struct {
|
||||
Endpoint string
|
||||
CacheTTL time.Duration
|
||||
ContractAddress string
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
// NewClientWithOptions creates a new Azimuth client with custom options
|
||||
func NewClientWithOptions(opts ClientOptions) *Client {
|
||||
if opts.Endpoint == "" {
|
||||
opts.Endpoint = DefaultEndpoint
|
||||
}
|
||||
if opts.CacheTTL == 0 {
|
||||
opts.CacheTTL = DefaultCacheTTL
|
||||
}
|
||||
if opts.ContractAddress == "" {
|
||||
opts.ContractAddress = AzimuthContract
|
||||
}
|
||||
if opts.Timeout == 0 {
|
||||
opts.Timeout = DefaultTimeout
|
||||
}
|
||||
|
||||
httpClient := graphql.NewClient(opts.Endpoint, nil)
|
||||
|
||||
return &Client{
|
||||
gqlClient: httpClient,
|
||||
cache: NewKeyCache(opts.CacheTTL),
|
||||
contractAddress: opts.ContractAddress,
|
||||
}
|
||||
}
|
||||
|
||||
// NewKeyCache creates a new key cache with the specified TTL
|
||||
func NewKeyCache(ttl time.Duration) *KeyCache {
|
||||
return &KeyCache{
|
||||
keys: make(map[uint32]*ShipKeys),
|
||||
ttl: ttl,
|
||||
}
|
||||
}
|
||||
|
||||
// Get retrieves ship keys from cache if valid
|
||||
func (c *KeyCache) Get(point uint32) (*ShipKeys, bool) {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
cached, exists := c.keys[point]
|
||||
if !exists {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if time.Since(cached.CachedAt) > c.ttl {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return cached, true
|
||||
}
|
||||
|
||||
// Set adds ship keys to the cache
|
||||
func (c *KeyCache) Set(point uint32, keys *ShipKeys) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
keys.CachedAt = time.Now()
|
||||
c.keys[point] = keys
|
||||
}
|
||||
|
||||
// GetShipType returns the type of ship based on its point number
|
||||
func GetShipType(point uint32) string {
|
||||
if point < 256 {
|
||||
return "galaxy"
|
||||
} else if point < 65536 {
|
||||
return "star"
|
||||
} else {
|
||||
return "planet"
|
||||
}
|
||||
}
|
||||
|
||||
// ParseShipName converts an Urbit ship name to its point number
|
||||
// Currently supports numeric IDs, TODO: implement proper @p parsing
|
||||
func ParseShipName(shipName string) (uint32, error) {
|
||||
// Remove ~ prefix if present
|
||||
if len(shipName) > 0 && shipName[0] == '~' {
|
||||
shipName = shipName[1:]
|
||||
}
|
||||
|
||||
// For numeric IDs
|
||||
if point, err := strconv.ParseUint(shipName, 10, 32); err == nil {
|
||||
return uint32(point), nil
|
||||
}
|
||||
|
||||
// TODO: Implement proper @p to point conversion
|
||||
return 0, fmt.Errorf("ship name parsing not yet implemented for: %s", shipName)
|
||||
}
|
||||
|
||||
// GetAuthenticationKey retrieves the authentication key for a ship
|
||||
func (c *Client) GetAuthenticationKey(ctx context.Context, point uint32) ([]byte, error) {
|
||||
// Check cache first
|
||||
if keys, found := c.cache.Get(point); found {
|
||||
return keys.AuthenticationKey, nil
|
||||
}
|
||||
|
||||
// Query for all keys
|
||||
keys, err := c.getShipKeys(ctx, point)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Cache the keys
|
||||
c.cache.Set(point, keys)
|
||||
|
||||
return keys.AuthenticationKey, nil
|
||||
}
|
||||
|
||||
// GetEncryptionKey retrieves the encryption key for a ship
|
||||
func (c *Client) GetEncryptionKey(ctx context.Context, point uint32) ([]byte, error) {
|
||||
// Check cache first
|
||||
if keys, found := c.cache.Get(point); found {
|
||||
return keys.EncryptionKey, nil
|
||||
}
|
||||
|
||||
// Query for all keys
|
||||
keys, err := c.getShipKeys(ctx, point)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Cache the keys
|
||||
c.cache.Set(point, keys)
|
||||
|
||||
return keys.EncryptionKey, nil
|
||||
}
|
||||
|
||||
// GetShipKeys retrieves all cryptographic keys for a ship
|
||||
func (c *Client) GetShipKeys(ctx context.Context, point uint32) (*ShipKeys, error) {
|
||||
// Check cache first
|
||||
if keys, found := c.cache.Get(point); found {
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
// Query for all keys
|
||||
keys, err := c.getShipKeys(ctx, point)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Cache the keys
|
||||
c.cache.Set(point, keys)
|
||||
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
// IsShipActive checks if a ship is active on the Azimuth network
|
||||
func (c *Client) IsShipActive(ctx context.Context, point uint32) (bool, error) {
|
||||
// Get current block hash
|
||||
blockHash, err := c.getLatestBlockHash(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get latest block hash: %w", err)
|
||||
}
|
||||
|
||||
// Convert point to BigInt
|
||||
pointBigInt := NewBigIntFromUint32(point)
|
||||
|
||||
// Use generated GraphQL client
|
||||
resp, err := IsActive(ctx, c.gqlClient, blockHash, c.contractAddress, pointBigInt)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to query ship activity: %w", err)
|
||||
}
|
||||
|
||||
return resp.AzimuthIsActive.Value, nil
|
||||
}
|
||||
|
||||
// GetSponsor retrieves the sponsor of a point
|
||||
func (c *Client) GetSponsor(ctx context.Context, point uint32) (uint32, error) {
|
||||
// Get current block hash
|
||||
blockHash, err := c.getLatestBlockHash(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to get latest block hash: %w", err)
|
||||
}
|
||||
|
||||
// Convert point to BigInt
|
||||
pointBigInt := NewBigIntFromUint32(point)
|
||||
|
||||
// Use generated GraphQL client
|
||||
resp, err := GetSponsor(ctx, c.gqlClient, pointBigInt, blockHash, c.contractAddress)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to query sponsor: %w", err)
|
||||
}
|
||||
|
||||
// Parse sponsor point number from string
|
||||
if resp.AzimuthGetSponsor.Value == "" {
|
||||
return 0, fmt.Errorf("point %d has no sponsor", point)
|
||||
}
|
||||
|
||||
sponsorPoint, err := strconv.ParseUint(resp.AzimuthGetSponsor.Value, 10, 32)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid sponsor point format: %w", err)
|
||||
}
|
||||
|
||||
return uint32(sponsorPoint), nil
|
||||
}
|
||||
|
||||
// GetOwner retrieves the owner address of a point
|
||||
func (c *Client) GetOwner(ctx context.Context, point uint32) (string, error) {
|
||||
// Get current block hash
|
||||
blockHash, err := c.getLatestBlockHash(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get latest block hash: %w", err)
|
||||
}
|
||||
|
||||
// Convert point to BigInt
|
||||
pointBigInt := NewBigIntFromUint32(point)
|
||||
|
||||
// Use generated GraphQL client
|
||||
resp, err := GetOwner(ctx, c.gqlClient, blockHash, c.contractAddress, pointBigInt)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to query owner: %w", err)
|
||||
}
|
||||
|
||||
return resp.AzimuthGetOwner.Value, nil
|
||||
}
|
||||
|
||||
// getShipKeys retrieves all keys for a ship from the API
|
||||
func (c *Client) getShipKeys(ctx context.Context, point uint32) (*ShipKeys, error) {
|
||||
// Get current block hash
|
||||
blockHash, err := c.getLatestBlockHash(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get latest block hash: %w", err)
|
||||
}
|
||||
|
||||
// Convert point to BigInt
|
||||
pointBigInt := NewBigIntFromUint32(point)
|
||||
|
||||
// Use generated GraphQL client
|
||||
resp, err := GetKeys(ctx, c.gqlClient, blockHash, c.contractAddress, pointBigInt)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query keys: %w", err)
|
||||
}
|
||||
|
||||
// Check if keys exist for this point
|
||||
if resp.AzimuthGetKeys.Value.Value1 == "" {
|
||||
return nil, fmt.Errorf("no keys found for point %d", point)
|
||||
}
|
||||
|
||||
keys := &ShipKeys{}
|
||||
|
||||
// Parse encryption key (32 bytes hex, remove 0x prefix if present)
|
||||
encKeyHex := resp.AzimuthGetKeys.Value.Value0
|
||||
if len(encKeyHex) > 2 && encKeyHex[:2] == "0x" {
|
||||
encKeyHex = encKeyHex[2:]
|
||||
}
|
||||
if encKeyHex != "" {
|
||||
encKey, err := hex.DecodeString(encKeyHex)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode encryption key: %w", err)
|
||||
}
|
||||
keys.EncryptionKey = encKey
|
||||
}
|
||||
|
||||
// Parse authentication key (32 bytes hex, remove 0x prefix if present)
|
||||
authKeyHex := resp.AzimuthGetKeys.Value.Value1
|
||||
if len(authKeyHex) > 2 && authKeyHex[:2] == "0x" {
|
||||
authKeyHex = authKeyHex[2:]
|
||||
}
|
||||
authKey, err := hex.DecodeString(authKeyHex)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode authentication key: %w", err)
|
||||
}
|
||||
if len(authKey) != 32 {
|
||||
return nil, fmt.Errorf("invalid authentication key length: expected 32 bytes, got %d", len(authKey))
|
||||
}
|
||||
keys.AuthenticationKey = authKey
|
||||
|
||||
// Parse crypto suite version
|
||||
suite, err := resp.AzimuthGetKeys.Value.Value2.ToUint32()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse crypto suite version: %w", err)
|
||||
}
|
||||
keys.CryptoSuiteVersion = uint64(suite)
|
||||
|
||||
// Parse key revision number
|
||||
revision, err := resp.AzimuthGetKeys.Value.Value3.ToUint32()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse key revision: %w", err)
|
||||
}
|
||||
keys.KeyRevisionNumber = uint64(revision)
|
||||
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
// getLatestBlockHash gets the latest processed block hash from azimuth-watcher
|
||||
func (c *Client) getLatestBlockHash(ctx context.Context) (string, error) {
|
||||
// Use generated GraphQL client
|
||||
resp, err := GetSyncStatus(ctx, c.gqlClient)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to query sync status: %w", err)
|
||||
}
|
||||
|
||||
return resp.AzimuthGetSyncStatus.LatestProcessedBlockHash, nil
|
||||
}
|
||||
|
||||
// ValidateStarSponsorship validates that a star is sponsored by the expected galaxy
|
||||
func ValidateStarSponsorship(ctx context.Context, starID uint32, expectedGalaxyID uint32, client *Client) error {
|
||||
sponsor, err := client.GetSponsor(ctx, starID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get sponsor: %w", err)
|
||||
}
|
||||
|
||||
if sponsor != expectedGalaxyID {
|
||||
return fmt.Errorf("star %d is not sponsored by galaxy %d (actual sponsor: %d)",
|
||||
starID, expectedGalaxyID, sponsor)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseStarID parses a star ID from string to uint32 with validation
|
||||
func ParseStarID(starIDStr string) (uint32, error) {
|
||||
starPoint, err := strconv.ParseUint(starIDStr, 10, 32)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid star ID format: %w", err)
|
||||
}
|
||||
|
||||
// Validate that it's actually a star (256-65535)
|
||||
if starPoint < 256 || starPoint > 65535 {
|
||||
return 0, fmt.Errorf("ID %d is not a valid star (must be 256-65535)", starPoint)
|
||||
}
|
||||
|
||||
return uint32(starPoint), nil
|
||||
}
|
||||
266
client_test.go
Normal file
266
client_test.go
Normal file
@ -0,0 +1,266 @@
|
||||
package azimuth
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewClient(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
endpoint string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "default endpoint",
|
||||
endpoint: "",
|
||||
expected: DefaultEndpoint,
|
||||
},
|
||||
{
|
||||
name: "custom endpoint",
|
||||
endpoint: "https://custom.endpoint.com/graphql",
|
||||
expected: "https://custom.endpoint.com/graphql",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
client := NewClient(tt.endpoint)
|
||||
assert.NotNil(t, client)
|
||||
assert.NotNil(t, client.gqlClient)
|
||||
assert.NotNil(t, client.cache)
|
||||
assert.Equal(t, AzimuthContract, client.contractAddress)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewClientWithOptions(t *testing.T) {
|
||||
opts := ClientOptions{
|
||||
Endpoint: "https://test.endpoint.com",
|
||||
CacheTTL: 2 * time.Hour,
|
||||
ContractAddress: "0x1234567890123456789012345678901234567890",
|
||||
Timeout: 60 * time.Second,
|
||||
}
|
||||
|
||||
client := NewClientWithOptions(opts)
|
||||
assert.NotNil(t, client)
|
||||
assert.Equal(t, opts.ContractAddress, client.contractAddress)
|
||||
assert.Equal(t, opts.CacheTTL, client.cache.ttl)
|
||||
}
|
||||
|
||||
func TestGetShipType(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
point uint32
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "galaxy",
|
||||
point: 0,
|
||||
expected: "galaxy",
|
||||
},
|
||||
{
|
||||
name: "galaxy max",
|
||||
point: 255,
|
||||
expected: "galaxy",
|
||||
},
|
||||
{
|
||||
name: "star min",
|
||||
point: 256,
|
||||
expected: "star",
|
||||
},
|
||||
{
|
||||
name: "star max",
|
||||
point: 65535,
|
||||
expected: "star",
|
||||
},
|
||||
{
|
||||
name: "planet",
|
||||
point: 65536,
|
||||
expected: "planet",
|
||||
},
|
||||
{
|
||||
name: "large planet",
|
||||
point: 1000000,
|
||||
expected: "planet",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := GetShipType(tt.point)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseShipName(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
shipName string
|
||||
expected uint32
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "numeric without tilde",
|
||||
shipName: "256",
|
||||
expected: 256,
|
||||
},
|
||||
{
|
||||
name: "numeric with tilde",
|
||||
shipName: "~256",
|
||||
expected: 256,
|
||||
},
|
||||
{
|
||||
name: "invalid patp",
|
||||
shipName: "~invalid-patp",
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "non-numeric",
|
||||
shipName: "not-a-number",
|
||||
expectErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result, err := ParseShipName(tt.shipName)
|
||||
if tt.expectErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseStarID(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
starID string
|
||||
expected uint32
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "valid star min",
|
||||
starID: "256",
|
||||
expected: 256,
|
||||
},
|
||||
{
|
||||
name: "valid star max",
|
||||
starID: "65535",
|
||||
expected: 65535,
|
||||
},
|
||||
{
|
||||
name: "galaxy (too small)",
|
||||
starID: "255",
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "planet (too large)",
|
||||
starID: "65536",
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid format",
|
||||
starID: "not-a-number",
|
||||
expectErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result, err := ParseStarID(tt.starID)
|
||||
if tt.expectErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestKeyCache(t *testing.T) {
|
||||
cache := NewKeyCache(100 * time.Millisecond)
|
||||
|
||||
// Test cache miss
|
||||
keys, found := cache.Get(256)
|
||||
assert.False(t, found)
|
||||
assert.Nil(t, keys)
|
||||
|
||||
// Test cache set and hit
|
||||
testKeys := &ShipKeys{
|
||||
AuthenticationKey: []byte("test-auth-key"),
|
||||
EncryptionKey: []byte("test-enc-key"),
|
||||
CryptoSuiteVersion: 1,
|
||||
KeyRevisionNumber: 1,
|
||||
}
|
||||
cache.Set(256, testKeys)
|
||||
|
||||
keys, found = cache.Get(256)
|
||||
assert.True(t, found)
|
||||
assert.Equal(t, testKeys.AuthenticationKey, keys.AuthenticationKey)
|
||||
assert.Equal(t, testKeys.EncryptionKey, keys.EncryptionKey)
|
||||
|
||||
// Test cache expiry
|
||||
time.Sleep(150 * time.Millisecond)
|
||||
keys, found = cache.Get(256)
|
||||
assert.False(t, found)
|
||||
assert.Nil(t, keys)
|
||||
}
|
||||
|
||||
// Note: The following tests would require a mock GraphQL server or integration test setup
|
||||
// For now, they serve as documentation of the expected API behavior
|
||||
|
||||
func TestClient_GetAuthenticationKey_Integration(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
// Test with a known active ship (this would need a real endpoint)
|
||||
// client := NewClient("")
|
||||
// ctx := context.Background()
|
||||
// authKey, err := client.GetAuthenticationKey(ctx, 0) // ~zod
|
||||
// assert.NoError(t, err)
|
||||
// assert.Len(t, authKey, 32) // 32 bytes for secp256k1 key
|
||||
|
||||
t.Skip("Integration test requires live azimuth-watcher endpoint")
|
||||
}
|
||||
|
||||
func TestClient_IsShipActive_Integration(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
// Test with a known ship
|
||||
// client := NewClient("")
|
||||
// ctx := context.Background()
|
||||
// active, err := client.IsShipActive(ctx, 0) // ~zod
|
||||
// assert.NoError(t, err)
|
||||
// assert.True(t, active) // ~zod should be active
|
||||
|
||||
t.Skip("Integration test requires live azimuth-watcher endpoint")
|
||||
}
|
||||
|
||||
func TestValidateStarSponsorship_Integration(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
// Test with known star-galaxy relationship
|
||||
// client := NewClient("")
|
||||
// ctx := context.Background()
|
||||
// err := ValidateStarSponsorship(ctx, 256, 0, client) // ~marzod sponsored by ~zod
|
||||
// assert.NoError(t, err)
|
||||
|
||||
// Test with invalid sponsorship
|
||||
// err = ValidateStarSponsorship(ctx, 256, 1, client) // ~marzod NOT sponsored by ~nec
|
||||
// assert.Error(t, err)
|
||||
|
||||
t.Skip("Integration test requires live azimuth-watcher endpoint")
|
||||
}
|
||||
167
examples_test.go
Normal file
167
examples_test.go
Normal file
@ -0,0 +1,167 @@
|
||||
package azimuth_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
azimuth "github.com/zenithchain/azimuth-client-go"
|
||||
)
|
||||
|
||||
func ExampleNewClient() {
|
||||
// Create client with default endpoint
|
||||
_ = azimuth.NewClient("")
|
||||
|
||||
// Or with custom endpoint
|
||||
_ = azimuth.NewClient("https://azimuth.dev.vdb.to")
|
||||
|
||||
fmt.Printf("Client created with contract address: %s\n", azimuth.AzimuthContract)
|
||||
// Output: Client created with contract address: 0x223c067F8CF28ae173EE5CafEa60cA44C335fecB
|
||||
}
|
||||
|
||||
func ExampleNewClientWithOptions() {
|
||||
// Create client with custom options
|
||||
_ = azimuth.NewClientWithOptions(azimuth.ClientOptions{
|
||||
Endpoint: "https://custom.azimuth.endpoint.com/graphql",
|
||||
CacheTTL: azimuth.DefaultCacheTTL * 2, // 2 hours
|
||||
ContractAddress: azimuth.AzimuthContract,
|
||||
Timeout: azimuth.DefaultTimeout,
|
||||
})
|
||||
|
||||
fmt.Printf("Custom client created\n")
|
||||
// Output: Custom client created
|
||||
}
|
||||
|
||||
func ExampleGetShipType() {
|
||||
// Classify different ship types
|
||||
fmt.Printf("Point 0 is a %s\n", azimuth.GetShipType(0)) // Galaxy
|
||||
fmt.Printf("Point 256 is a %s\n", azimuth.GetShipType(256)) // Star
|
||||
fmt.Printf("Point 65536 is a %s\n", azimuth.GetShipType(65536)) // Planet
|
||||
|
||||
// Output:
|
||||
// Point 0 is a galaxy
|
||||
// Point 256 is a star
|
||||
// Point 65536 is a planet
|
||||
}
|
||||
|
||||
func ExampleParseShipName() {
|
||||
// Parse numeric ship names
|
||||
point, err := azimuth.ParseShipName("256")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Ship name '256' -> point %d\n", point)
|
||||
|
||||
// Parse with tilde prefix
|
||||
point, err = azimuth.ParseShipName("~256")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Ship name '~256' -> point %d\n", point)
|
||||
|
||||
// Output:
|
||||
// Ship name '256' -> point 256
|
||||
// Ship name '~256' -> point 256
|
||||
}
|
||||
|
||||
func ExampleParseStarID() {
|
||||
// Parse and validate star ID
|
||||
starID, err := azimuth.ParseStarID("256")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Valid star ID: %d\n", starID)
|
||||
|
||||
// This would return an error since 255 is a galaxy
|
||||
_, err = azimuth.ParseStarID("255")
|
||||
if err != nil {
|
||||
fmt.Printf("Error for galaxy: %s\n", err.Error())
|
||||
}
|
||||
|
||||
// Output:
|
||||
// Valid star ID: 256
|
||||
// Error for galaxy: ID 255 is not a valid star (must be 256-65535)
|
||||
}
|
||||
|
||||
func ExampleClient_GetAuthenticationKey() {
|
||||
// This is a mock example - would require real azimuth-watcher endpoint
|
||||
fmt.Printf("Getting authentication key for point 256...\n")
|
||||
|
||||
// In a real scenario:
|
||||
// client := azimuth.NewClient("")
|
||||
// ctx := context.Background()
|
||||
// authKey, err := client.GetAuthenticationKey(ctx, 256)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// fmt.Printf("Authentication key: %x\n", authKey)
|
||||
|
||||
// Output: Getting authentication key for point 256...
|
||||
}
|
||||
|
||||
func ExampleClient_GetShipKeys() {
|
||||
// This is a mock example - would require real azimuth-watcher endpoint
|
||||
fmt.Printf("Getting all keys for point 256...\n")
|
||||
|
||||
// In a real scenario:
|
||||
// client := azimuth.NewClient("")
|
||||
// ctx := context.Background()
|
||||
// keys, err := client.GetShipKeys(ctx, 256)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// fmt.Printf("Encryption key: %x\n", keys.EncryptionKey)
|
||||
// fmt.Printf("Authentication key: %x\n", keys.AuthenticationKey)
|
||||
// fmt.Printf("Crypto suite version: %d\n", keys.CryptoSuiteVersion)
|
||||
// fmt.Printf("Key revision number: %d\n", keys.KeyRevisionNumber)
|
||||
|
||||
// Output: Getting all keys for point 256...
|
||||
}
|
||||
|
||||
func ExampleClient_IsShipActive() {
|
||||
// This is a mock example - would require real azimuth-watcher endpoint
|
||||
fmt.Printf("Checking if point 256 is active...\n")
|
||||
|
||||
// In a real scenario:
|
||||
// client := azimuth.NewClient("")
|
||||
// ctx := context.Background()
|
||||
// active, err := client.IsShipActive(ctx, 256)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// fmt.Printf("Point 256 is active: %t\n", active)
|
||||
|
||||
// Output: Checking if point 256 is active...
|
||||
}
|
||||
|
||||
func ExampleClient_GetSponsor() {
|
||||
// This is a mock example - would require real azimuth-watcher endpoint
|
||||
fmt.Printf("Getting sponsor for star 256...\n")
|
||||
|
||||
// In a real scenario:
|
||||
// client := azimuth.NewClient("")
|
||||
// ctx := context.Background()
|
||||
// sponsor, err := client.GetSponsor(ctx, 256)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// fmt.Printf("Star 256 is sponsored by galaxy %d\n", sponsor)
|
||||
|
||||
// Output: Getting sponsor for star 256...
|
||||
}
|
||||
|
||||
func ExampleValidateStarSponsorship() {
|
||||
// This is a mock example - would require real azimuth-watcher endpoint
|
||||
fmt.Printf("Validating star 256 is sponsored by galaxy 0...\n")
|
||||
|
||||
// In a real scenario:
|
||||
// client := azimuth.NewClient("")
|
||||
// ctx := context.Background()
|
||||
// err := azimuth.ValidateStarSponsorship(ctx, 256, 0, client)
|
||||
// if err != nil {
|
||||
// fmt.Printf("Validation failed: %s\n", err.Error())
|
||||
// } else {
|
||||
// fmt.Printf("Validation successful!\n")
|
||||
// }
|
||||
|
||||
// Output: Validating star 256 is sponsored by galaxy 0...
|
||||
}
|
||||
764
generated.go
Normal file
764
generated.go
Normal file
@ -0,0 +1,764 @@
|
||||
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
|
||||
|
||||
package azimuth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
)
|
||||
|
||||
// EventsInRangeAzimuthEventsInRangeResultEvent includes the requested fields of the GraphQL type ResultEvent.
|
||||
type EventsInRangeAzimuthEventsInRangeResultEvent struct {
|
||||
Block EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_ `json:"block"`
|
||||
Tx EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_ `json:"tx"`
|
||||
EventIndex int `json:"eventIndex"`
|
||||
Event EventsInRangeAzimuthEventsInRangeResultEventEvent `json:"-"`
|
||||
}
|
||||
|
||||
// GetBlock returns EventsInRangeAzimuthEventsInRangeResultEvent.Block, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEvent) GetBlock() EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_ {
|
||||
return v.Block
|
||||
}
|
||||
|
||||
// GetTx returns EventsInRangeAzimuthEventsInRangeResultEvent.Tx, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEvent) GetTx() EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_ {
|
||||
return v.Tx
|
||||
}
|
||||
|
||||
// GetEventIndex returns EventsInRangeAzimuthEventsInRangeResultEvent.EventIndex, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEvent) GetEventIndex() int { return v.EventIndex }
|
||||
|
||||
// GetEvent returns EventsInRangeAzimuthEventsInRangeResultEvent.Event, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEvent) GetEvent() EventsInRangeAzimuthEventsInRangeResultEventEvent {
|
||||
return v.Event
|
||||
}
|
||||
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEvent) UnmarshalJSON(b []byte) error {
|
||||
|
||||
if string(b) == "null" {
|
||||
return nil
|
||||
}
|
||||
|
||||
var firstPass struct {
|
||||
*EventsInRangeAzimuthEventsInRangeResultEvent
|
||||
Event json.RawMessage `json:"event"`
|
||||
graphql.NoUnmarshalJSON
|
||||
}
|
||||
firstPass.EventsInRangeAzimuthEventsInRangeResultEvent = v
|
||||
|
||||
err := json.Unmarshal(b, &firstPass)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
{
|
||||
dst := &v.Event
|
||||
src := firstPass.Event
|
||||
if len(src) != 0 && string(src) != "null" {
|
||||
err = __unmarshalEventsInRangeAzimuthEventsInRangeResultEventEvent(
|
||||
src, dst)
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"unable to unmarshal EventsInRangeAzimuthEventsInRangeResultEvent.Event: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type __premarshalEventsInRangeAzimuthEventsInRangeResultEvent struct {
|
||||
Block EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_ `json:"block"`
|
||||
|
||||
Tx EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_ `json:"tx"`
|
||||
|
||||
EventIndex int `json:"eventIndex"`
|
||||
|
||||
Event json.RawMessage `json:"event"`
|
||||
}
|
||||
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEvent) MarshalJSON() ([]byte, error) {
|
||||
premarshaled, err := v.__premarshalJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return json.Marshal(premarshaled)
|
||||
}
|
||||
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEvent) __premarshalJSON() (*__premarshalEventsInRangeAzimuthEventsInRangeResultEvent, error) {
|
||||
var retval __premarshalEventsInRangeAzimuthEventsInRangeResultEvent
|
||||
|
||||
retval.Block = v.Block
|
||||
retval.Tx = v.Tx
|
||||
retval.EventIndex = v.EventIndex
|
||||
{
|
||||
|
||||
dst := &retval.Event
|
||||
src := v.Event
|
||||
var err error
|
||||
*dst, err = __marshalEventsInRangeAzimuthEventsInRangeResultEventEvent(
|
||||
&src)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"unable to marshal EventsInRangeAzimuthEventsInRangeResultEvent.Event: %w", err)
|
||||
}
|
||||
}
|
||||
return &retval, nil
|
||||
}
|
||||
|
||||
// EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_ includes the requested fields of the GraphQL type _Block_.
|
||||
type EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_ struct {
|
||||
Hash string `json:"hash"`
|
||||
Number int `json:"number"`
|
||||
}
|
||||
|
||||
// GetHash returns EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_.Hash, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_) GetHash() string { return v.Hash }
|
||||
|
||||
// GetNumber returns EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_.Number, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventBlockBlock_) GetNumber() int { return v.Number }
|
||||
|
||||
// EventsInRangeAzimuthEventsInRangeResultEventEvent includes the requested fields of the GraphQL interface Event.
|
||||
//
|
||||
// EventsInRangeAzimuthEventsInRangeResultEventEvent is implemented by the following types:
|
||||
// EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent
|
||||
type EventsInRangeAzimuthEventsInRangeResultEventEvent interface {
|
||||
implementsGraphQLInterfaceEventsInRangeAzimuthEventsInRangeResultEventEvent()
|
||||
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
||||
GetTypename() string
|
||||
}
|
||||
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent) implementsGraphQLInterfaceEventsInRangeAzimuthEventsInRangeResultEventEvent() {
|
||||
}
|
||||
|
||||
func __unmarshalEventsInRangeAzimuthEventsInRangeResultEventEvent(b []byte, v *EventsInRangeAzimuthEventsInRangeResultEventEvent) error {
|
||||
if string(b) == "null" {
|
||||
return nil
|
||||
}
|
||||
|
||||
var tn struct {
|
||||
TypeName string `json:"__typename"`
|
||||
}
|
||||
err := json.Unmarshal(b, &tn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch tn.TypeName {
|
||||
case "OwnerChangedEvent":
|
||||
*v = new(EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "":
|
||||
return fmt.Errorf(
|
||||
"response was missing Event.__typename")
|
||||
default:
|
||||
return fmt.Errorf(
|
||||
`unexpected concrete type for EventsInRangeAzimuthEventsInRangeResultEventEvent: "%v"`, tn.TypeName)
|
||||
}
|
||||
}
|
||||
|
||||
func __marshalEventsInRangeAzimuthEventsInRangeResultEventEvent(v *EventsInRangeAzimuthEventsInRangeResultEventEvent) ([]byte, error) {
|
||||
|
||||
var typename string
|
||||
switch v := (*v).(type) {
|
||||
case *EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent:
|
||||
typename = "OwnerChangedEvent"
|
||||
|
||||
result := struct {
|
||||
TypeName string `json:"__typename"`
|
||||
*EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case nil:
|
||||
return []byte("null"), nil
|
||||
default:
|
||||
return nil, fmt.Errorf(
|
||||
`unexpected concrete type for EventsInRangeAzimuthEventsInRangeResultEventEvent: "%T"`, v)
|
||||
}
|
||||
}
|
||||
|
||||
// EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent includes the requested fields of the GraphQL type OwnerChangedEvent.
|
||||
type EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent struct {
|
||||
Typename string `json:"__typename"`
|
||||
Point BigInt `json:"point"`
|
||||
Owner string `json:"owner"`
|
||||
}
|
||||
|
||||
// GetTypename returns EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent.Typename, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent) GetTypename() string {
|
||||
return v.Typename
|
||||
}
|
||||
|
||||
// GetPoint returns EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent.Point, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent) GetPoint() BigInt {
|
||||
return v.Point
|
||||
}
|
||||
|
||||
// GetOwner returns EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent.Owner, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventEventOwnerChangedEvent) GetOwner() string {
|
||||
return v.Owner
|
||||
}
|
||||
|
||||
// EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_ includes the requested fields of the GraphQL type _Transaction_.
|
||||
type EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_ struct {
|
||||
Hash string `json:"hash"`
|
||||
Index int `json:"index"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
// GetHash returns EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_.Hash, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_) GetHash() string { return v.Hash }
|
||||
|
||||
// GetIndex returns EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_.Index, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_) GetIndex() int { return v.Index }
|
||||
|
||||
// GetFrom returns EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_.From, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_) GetFrom() string { return v.From }
|
||||
|
||||
// GetTo returns EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_.To, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeAzimuthEventsInRangeResultEventTxTransaction_) GetTo() string { return v.To }
|
||||
|
||||
// EventsInRangeResponse is returned by EventsInRange on success.
|
||||
type EventsInRangeResponse struct {
|
||||
AzimuthEventsInRange []EventsInRangeAzimuthEventsInRangeResultEvent `json:"azimuthEventsInRange"`
|
||||
}
|
||||
|
||||
// GetAzimuthEventsInRange returns EventsInRangeResponse.AzimuthEventsInRange, and is useful for accessing the field via an interface.
|
||||
func (v *EventsInRangeResponse) GetAzimuthEventsInRange() []EventsInRangeAzimuthEventsInRangeResultEvent {
|
||||
return v.AzimuthEventsInRange
|
||||
}
|
||||
|
||||
// GetKeysAzimuthGetKeysResultGetKeysType includes the requested fields of the GraphQL type ResultGetKeysType.
|
||||
type GetKeysAzimuthGetKeysResultGetKeysType struct {
|
||||
Value GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType `json:"value"`
|
||||
Proof GetKeysAzimuthGetKeysResultGetKeysTypeProof `json:"proof"`
|
||||
}
|
||||
|
||||
// GetValue returns GetKeysAzimuthGetKeysResultGetKeysType.Value, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysAzimuthGetKeysResultGetKeysType) GetValue() GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType {
|
||||
return v.Value
|
||||
}
|
||||
|
||||
// GetProof returns GetKeysAzimuthGetKeysResultGetKeysType.Proof, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysAzimuthGetKeysResultGetKeysType) GetProof() GetKeysAzimuthGetKeysResultGetKeysTypeProof {
|
||||
return v.Proof
|
||||
}
|
||||
|
||||
// GetKeysAzimuthGetKeysResultGetKeysTypeProof includes the requested fields of the GraphQL type Proof.
|
||||
type GetKeysAzimuthGetKeysResultGetKeysTypeProof struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// GetData returns GetKeysAzimuthGetKeysResultGetKeysTypeProof.Data, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysAzimuthGetKeysResultGetKeysTypeProof) GetData() string { return v.Data }
|
||||
|
||||
// GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType includes the requested fields of the GraphQL type GetKeysType.
|
||||
type GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType struct {
|
||||
Value0 string `json:"value0"`
|
||||
Value1 string `json:"value1"`
|
||||
Value2 BigInt `json:"value2"`
|
||||
Value3 BigInt `json:"value3"`
|
||||
}
|
||||
|
||||
// GetValue0 returns GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType.Value0, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType) GetValue0() string { return v.Value0 }
|
||||
|
||||
// GetValue1 returns GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType.Value1, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType) GetValue1() string { return v.Value1 }
|
||||
|
||||
// GetValue2 returns GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType.Value2, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType) GetValue2() BigInt { return v.Value2 }
|
||||
|
||||
// GetValue3 returns GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType.Value3, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysAzimuthGetKeysResultGetKeysTypeValueGetKeysType) GetValue3() BigInt { return v.Value3 }
|
||||
|
||||
// GetKeysResponse is returned by GetKeys on success.
|
||||
type GetKeysResponse struct {
|
||||
AzimuthGetKeys GetKeysAzimuthGetKeysResultGetKeysType `json:"azimuthGetKeys"`
|
||||
}
|
||||
|
||||
// GetAzimuthGetKeys returns GetKeysResponse.AzimuthGetKeys, and is useful for accessing the field via an interface.
|
||||
func (v *GetKeysResponse) GetAzimuthGetKeys() GetKeysAzimuthGetKeysResultGetKeysType {
|
||||
return v.AzimuthGetKeys
|
||||
}
|
||||
|
||||
// GetOwnerAzimuthGetOwnerResultString includes the requested fields of the GraphQL type ResultString.
|
||||
type GetOwnerAzimuthGetOwnerResultString struct {
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// GetValue returns GetOwnerAzimuthGetOwnerResultString.Value, and is useful for accessing the field via an interface.
|
||||
func (v *GetOwnerAzimuthGetOwnerResultString) GetValue() string { return v.Value }
|
||||
|
||||
// GetOwnerResponse is returned by GetOwner on success.
|
||||
type GetOwnerResponse struct {
|
||||
AzimuthGetOwner GetOwnerAzimuthGetOwnerResultString `json:"azimuthGetOwner"`
|
||||
}
|
||||
|
||||
// GetAzimuthGetOwner returns GetOwnerResponse.AzimuthGetOwner, and is useful for accessing the field via an interface.
|
||||
func (v *GetOwnerResponse) GetAzimuthGetOwner() GetOwnerAzimuthGetOwnerResultString {
|
||||
return v.AzimuthGetOwner
|
||||
}
|
||||
|
||||
// GetSponsorAzimuthGetSponsorResultString includes the requested fields of the GraphQL type ResultString.
|
||||
type GetSponsorAzimuthGetSponsorResultString struct {
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// GetValue returns GetSponsorAzimuthGetSponsorResultString.Value, and is useful for accessing the field via an interface.
|
||||
func (v *GetSponsorAzimuthGetSponsorResultString) GetValue() string { return v.Value }
|
||||
|
||||
// GetSponsorResponse is returned by GetSponsor on success.
|
||||
type GetSponsorResponse struct {
|
||||
AzimuthGetSponsor GetSponsorAzimuthGetSponsorResultString `json:"azimuthGetSponsor"`
|
||||
}
|
||||
|
||||
// GetAzimuthGetSponsor returns GetSponsorResponse.AzimuthGetSponsor, and is useful for accessing the field via an interface.
|
||||
func (v *GetSponsorResponse) GetAzimuthGetSponsor() GetSponsorAzimuthGetSponsorResultString {
|
||||
return v.AzimuthGetSponsor
|
||||
}
|
||||
|
||||
// GetSponsoringAzimuthGetSponsoringResultArray includes the requested fields of the GraphQL type ResultArray.
|
||||
type GetSponsoringAzimuthGetSponsoringResultArray struct {
|
||||
Value []string `json:"value"`
|
||||
}
|
||||
|
||||
// GetValue returns GetSponsoringAzimuthGetSponsoringResultArray.Value, and is useful for accessing the field via an interface.
|
||||
func (v *GetSponsoringAzimuthGetSponsoringResultArray) GetValue() []string { return v.Value }
|
||||
|
||||
// GetSponsoringResponse is returned by GetSponsoring on success.
|
||||
type GetSponsoringResponse struct {
|
||||
AzimuthGetSponsoring GetSponsoringAzimuthGetSponsoringResultArray `json:"azimuthGetSponsoring"`
|
||||
}
|
||||
|
||||
// GetAzimuthGetSponsoring returns GetSponsoringResponse.AzimuthGetSponsoring, and is useful for accessing the field via an interface.
|
||||
func (v *GetSponsoringResponse) GetAzimuthGetSponsoring() GetSponsoringAzimuthGetSponsoringResultArray {
|
||||
return v.AzimuthGetSponsoring
|
||||
}
|
||||
|
||||
// GetSyncStatusAzimuthGetSyncStatus includes the requested fields of the GraphQL type SyncStatus.
|
||||
type GetSyncStatusAzimuthGetSyncStatus struct {
|
||||
LatestProcessedBlockHash string `json:"latestProcessedBlockHash"`
|
||||
LatestProcessedBlockNumber int `json:"latestProcessedBlockNumber"`
|
||||
}
|
||||
|
||||
// GetLatestProcessedBlockHash returns GetSyncStatusAzimuthGetSyncStatus.LatestProcessedBlockHash, and is useful for accessing the field via an interface.
|
||||
func (v *GetSyncStatusAzimuthGetSyncStatus) GetLatestProcessedBlockHash() string {
|
||||
return v.LatestProcessedBlockHash
|
||||
}
|
||||
|
||||
// GetLatestProcessedBlockNumber returns GetSyncStatusAzimuthGetSyncStatus.LatestProcessedBlockNumber, and is useful for accessing the field via an interface.
|
||||
func (v *GetSyncStatusAzimuthGetSyncStatus) GetLatestProcessedBlockNumber() int {
|
||||
return v.LatestProcessedBlockNumber
|
||||
}
|
||||
|
||||
// GetSyncStatusResponse is returned by GetSyncStatus on success.
|
||||
type GetSyncStatusResponse struct {
|
||||
AzimuthGetSyncStatus GetSyncStatusAzimuthGetSyncStatus `json:"azimuthGetSyncStatus"`
|
||||
}
|
||||
|
||||
// GetAzimuthGetSyncStatus returns GetSyncStatusResponse.AzimuthGetSyncStatus, and is useful for accessing the field via an interface.
|
||||
func (v *GetSyncStatusResponse) GetAzimuthGetSyncStatus() GetSyncStatusAzimuthGetSyncStatus {
|
||||
return v.AzimuthGetSyncStatus
|
||||
}
|
||||
|
||||
// IsActiveAzimuthIsActiveResultBool includes the requested fields of the GraphQL type ResultBool.
|
||||
type IsActiveAzimuthIsActiveResultBool struct {
|
||||
Value bool `json:"value"`
|
||||
}
|
||||
|
||||
// GetValue returns IsActiveAzimuthIsActiveResultBool.Value, and is useful for accessing the field via an interface.
|
||||
func (v *IsActiveAzimuthIsActiveResultBool) GetValue() bool { return v.Value }
|
||||
|
||||
// IsActiveResponse is returned by IsActive on success.
|
||||
type IsActiveResponse struct {
|
||||
AzimuthIsActive IsActiveAzimuthIsActiveResultBool `json:"azimuthIsActive"`
|
||||
}
|
||||
|
||||
// GetAzimuthIsActive returns IsActiveResponse.AzimuthIsActive, and is useful for accessing the field via an interface.
|
||||
func (v *IsActiveResponse) GetAzimuthIsActive() IsActiveAzimuthIsActiveResultBool {
|
||||
return v.AzimuthIsActive
|
||||
}
|
||||
|
||||
// __EventsInRangeInput is used internally by genqlient
|
||||
type __EventsInRangeInput struct {
|
||||
FromBlockNumber int `json:"fromBlockNumber"`
|
||||
ToBlockNumber int `json:"toBlockNumber"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// GetFromBlockNumber returns __EventsInRangeInput.FromBlockNumber, and is useful for accessing the field via an interface.
|
||||
func (v *__EventsInRangeInput) GetFromBlockNumber() int { return v.FromBlockNumber }
|
||||
|
||||
// GetToBlockNumber returns __EventsInRangeInput.ToBlockNumber, and is useful for accessing the field via an interface.
|
||||
func (v *__EventsInRangeInput) GetToBlockNumber() int { return v.ToBlockNumber }
|
||||
|
||||
// GetName returns __EventsInRangeInput.Name, and is useful for accessing the field via an interface.
|
||||
func (v *__EventsInRangeInput) GetName() string { return v.Name }
|
||||
|
||||
// __GetKeysInput is used internally by genqlient
|
||||
type __GetKeysInput struct {
|
||||
BlockHash string `json:"blockHash"`
|
||||
ContractAddress string `json:"contractAddress"`
|
||||
Point BigInt `json:"_point"`
|
||||
}
|
||||
|
||||
// GetBlockHash returns __GetKeysInput.BlockHash, and is useful for accessing the field via an interface.
|
||||
func (v *__GetKeysInput) GetBlockHash() string { return v.BlockHash }
|
||||
|
||||
// GetContractAddress returns __GetKeysInput.ContractAddress, and is useful for accessing the field via an interface.
|
||||
func (v *__GetKeysInput) GetContractAddress() string { return v.ContractAddress }
|
||||
|
||||
// GetPoint returns __GetKeysInput.Point, and is useful for accessing the field via an interface.
|
||||
func (v *__GetKeysInput) GetPoint() BigInt { return v.Point }
|
||||
|
||||
// __GetOwnerInput is used internally by genqlient
|
||||
type __GetOwnerInput struct {
|
||||
BlockHash string `json:"blockHash"`
|
||||
ContractAddress string `json:"contractAddress"`
|
||||
Point BigInt `json:"_point"`
|
||||
}
|
||||
|
||||
// GetBlockHash returns __GetOwnerInput.BlockHash, and is useful for accessing the field via an interface.
|
||||
func (v *__GetOwnerInput) GetBlockHash() string { return v.BlockHash }
|
||||
|
||||
// GetContractAddress returns __GetOwnerInput.ContractAddress, and is useful for accessing the field via an interface.
|
||||
func (v *__GetOwnerInput) GetContractAddress() string { return v.ContractAddress }
|
||||
|
||||
// GetPoint returns __GetOwnerInput.Point, and is useful for accessing the field via an interface.
|
||||
func (v *__GetOwnerInput) GetPoint() BigInt { return v.Point }
|
||||
|
||||
// __GetSponsorInput is used internally by genqlient
|
||||
type __GetSponsorInput struct {
|
||||
Point BigInt `json:"point"`
|
||||
BlockHash string `json:"blockHash"`
|
||||
ContractAddress string `json:"contractAddress"`
|
||||
}
|
||||
|
||||
// GetPoint returns __GetSponsorInput.Point, and is useful for accessing the field via an interface.
|
||||
func (v *__GetSponsorInput) GetPoint() BigInt { return v.Point }
|
||||
|
||||
// GetBlockHash returns __GetSponsorInput.BlockHash, and is useful for accessing the field via an interface.
|
||||
func (v *__GetSponsorInput) GetBlockHash() string { return v.BlockHash }
|
||||
|
||||
// GetContractAddress returns __GetSponsorInput.ContractAddress, and is useful for accessing the field via an interface.
|
||||
func (v *__GetSponsorInput) GetContractAddress() string { return v.ContractAddress }
|
||||
|
||||
// __GetSponsoringInput is used internally by genqlient
|
||||
type __GetSponsoringInput struct {
|
||||
Sponsor BigInt `json:"sponsor"`
|
||||
BlockHash string `json:"blockHash"`
|
||||
ContractAddress string `json:"contractAddress"`
|
||||
}
|
||||
|
||||
// GetSponsor returns __GetSponsoringInput.Sponsor, and is useful for accessing the field via an interface.
|
||||
func (v *__GetSponsoringInput) GetSponsor() BigInt { return v.Sponsor }
|
||||
|
||||
// GetBlockHash returns __GetSponsoringInput.BlockHash, and is useful for accessing the field via an interface.
|
||||
func (v *__GetSponsoringInput) GetBlockHash() string { return v.BlockHash }
|
||||
|
||||
// GetContractAddress returns __GetSponsoringInput.ContractAddress, and is useful for accessing the field via an interface.
|
||||
func (v *__GetSponsoringInput) GetContractAddress() string { return v.ContractAddress }
|
||||
|
||||
// __IsActiveInput is used internally by genqlient
|
||||
type __IsActiveInput struct {
|
||||
BlockHash string `json:"blockHash"`
|
||||
ContractAddress string `json:"contractAddress"`
|
||||
Point BigInt `json:"_point"`
|
||||
}
|
||||
|
||||
// GetBlockHash returns __IsActiveInput.BlockHash, and is useful for accessing the field via an interface.
|
||||
func (v *__IsActiveInput) GetBlockHash() string { return v.BlockHash }
|
||||
|
||||
// GetContractAddress returns __IsActiveInput.ContractAddress, and is useful for accessing the field via an interface.
|
||||
func (v *__IsActiveInput) GetContractAddress() string { return v.ContractAddress }
|
||||
|
||||
// GetPoint returns __IsActiveInput.Point, and is useful for accessing the field via an interface.
|
||||
func (v *__IsActiveInput) GetPoint() BigInt { return v.Point }
|
||||
|
||||
// The query executed by EventsInRange.
|
||||
const EventsInRange_Operation = `
|
||||
query EventsInRange ($fromBlockNumber: Int!, $toBlockNumber: Int!, $name: String) {
|
||||
azimuthEventsInRange(fromBlockNumber: $fromBlockNumber, toBlockNumber: $toBlockNumber, name: $name) {
|
||||
block {
|
||||
hash
|
||||
number
|
||||
}
|
||||
tx {
|
||||
hash
|
||||
index
|
||||
from
|
||||
to
|
||||
}
|
||||
eventIndex
|
||||
event {
|
||||
__typename
|
||||
... on OwnerChangedEvent {
|
||||
point
|
||||
owner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func EventsInRange(
|
||||
ctx_ context.Context,
|
||||
client_ graphql.Client,
|
||||
fromBlockNumber int,
|
||||
toBlockNumber int,
|
||||
name string,
|
||||
) (data_ *EventsInRangeResponse, err_ error) {
|
||||
req_ := &graphql.Request{
|
||||
OpName: "EventsInRange",
|
||||
Query: EventsInRange_Operation,
|
||||
Variables: &__EventsInRangeInput{
|
||||
FromBlockNumber: fromBlockNumber,
|
||||
ToBlockNumber: toBlockNumber,
|
||||
Name: name,
|
||||
},
|
||||
}
|
||||
|
||||
data_ = &EventsInRangeResponse{}
|
||||
resp_ := &graphql.Response{Data: data_}
|
||||
|
||||
err_ = client_.MakeRequest(
|
||||
ctx_,
|
||||
req_,
|
||||
resp_,
|
||||
)
|
||||
|
||||
return data_, err_
|
||||
}
|
||||
|
||||
// The query executed by GetKeys.
|
||||
const GetKeys_Operation = `
|
||||
query GetKeys ($blockHash: String!, $contractAddress: String!, $_point: BigInt!) {
|
||||
azimuthGetKeys(blockHash: $blockHash, contractAddress: $contractAddress, _point: $_point) {
|
||||
value {
|
||||
value0
|
||||
value1
|
||||
value2
|
||||
value3
|
||||
}
|
||||
proof {
|
||||
data
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func GetKeys(
|
||||
ctx_ context.Context,
|
||||
client_ graphql.Client,
|
||||
blockHash string,
|
||||
contractAddress string,
|
||||
_point BigInt,
|
||||
) (data_ *GetKeysResponse, err_ error) {
|
||||
req_ := &graphql.Request{
|
||||
OpName: "GetKeys",
|
||||
Query: GetKeys_Operation,
|
||||
Variables: &__GetKeysInput{
|
||||
BlockHash: blockHash,
|
||||
ContractAddress: contractAddress,
|
||||
Point: _point,
|
||||
},
|
||||
}
|
||||
|
||||
data_ = &GetKeysResponse{}
|
||||
resp_ := &graphql.Response{Data: data_}
|
||||
|
||||
err_ = client_.MakeRequest(
|
||||
ctx_,
|
||||
req_,
|
||||
resp_,
|
||||
)
|
||||
|
||||
return data_, err_
|
||||
}
|
||||
|
||||
// The query executed by GetOwner.
|
||||
const GetOwner_Operation = `
|
||||
query GetOwner ($blockHash: String!, $contractAddress: String!, $_point: BigInt!) {
|
||||
azimuthGetOwner(blockHash: $blockHash, contractAddress: $contractAddress, _point: $_point) {
|
||||
value
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func GetOwner(
|
||||
ctx_ context.Context,
|
||||
client_ graphql.Client,
|
||||
blockHash string,
|
||||
contractAddress string,
|
||||
_point BigInt,
|
||||
) (data_ *GetOwnerResponse, err_ error) {
|
||||
req_ := &graphql.Request{
|
||||
OpName: "GetOwner",
|
||||
Query: GetOwner_Operation,
|
||||
Variables: &__GetOwnerInput{
|
||||
BlockHash: blockHash,
|
||||
ContractAddress: contractAddress,
|
||||
Point: _point,
|
||||
},
|
||||
}
|
||||
|
||||
data_ = &GetOwnerResponse{}
|
||||
resp_ := &graphql.Response{Data: data_}
|
||||
|
||||
err_ = client_.MakeRequest(
|
||||
ctx_,
|
||||
req_,
|
||||
resp_,
|
||||
)
|
||||
|
||||
return data_, err_
|
||||
}
|
||||
|
||||
// The query executed by GetSponsor.
|
||||
const GetSponsor_Operation = `
|
||||
query GetSponsor ($point: BigInt!, $blockHash: String!, $contractAddress: String!) {
|
||||
azimuthGetSponsor(_point: $point, blockHash: $blockHash, contractAddress: $contractAddress) {
|
||||
value
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func GetSponsor(
|
||||
ctx_ context.Context,
|
||||
client_ graphql.Client,
|
||||
point BigInt,
|
||||
blockHash string,
|
||||
contractAddress string,
|
||||
) (data_ *GetSponsorResponse, err_ error) {
|
||||
req_ := &graphql.Request{
|
||||
OpName: "GetSponsor",
|
||||
Query: GetSponsor_Operation,
|
||||
Variables: &__GetSponsorInput{
|
||||
Point: point,
|
||||
BlockHash: blockHash,
|
||||
ContractAddress: contractAddress,
|
||||
},
|
||||
}
|
||||
|
||||
data_ = &GetSponsorResponse{}
|
||||
resp_ := &graphql.Response{Data: data_}
|
||||
|
||||
err_ = client_.MakeRequest(
|
||||
ctx_,
|
||||
req_,
|
||||
resp_,
|
||||
)
|
||||
|
||||
return data_, err_
|
||||
}
|
||||
|
||||
// The query executed by GetSponsoring.
|
||||
const GetSponsoring_Operation = `
|
||||
query GetSponsoring ($sponsor: BigInt!, $blockHash: String!, $contractAddress: String!) {
|
||||
azimuthGetSponsoring(_sponsor: $sponsor, blockHash: $blockHash, contractAddress: $contractAddress) {
|
||||
value
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func GetSponsoring(
|
||||
ctx_ context.Context,
|
||||
client_ graphql.Client,
|
||||
sponsor BigInt,
|
||||
blockHash string,
|
||||
contractAddress string,
|
||||
) (data_ *GetSponsoringResponse, err_ error) {
|
||||
req_ := &graphql.Request{
|
||||
OpName: "GetSponsoring",
|
||||
Query: GetSponsoring_Operation,
|
||||
Variables: &__GetSponsoringInput{
|
||||
Sponsor: sponsor,
|
||||
BlockHash: blockHash,
|
||||
ContractAddress: contractAddress,
|
||||
},
|
||||
}
|
||||
|
||||
data_ = &GetSponsoringResponse{}
|
||||
resp_ := &graphql.Response{Data: data_}
|
||||
|
||||
err_ = client_.MakeRequest(
|
||||
ctx_,
|
||||
req_,
|
||||
resp_,
|
||||
)
|
||||
|
||||
return data_, err_
|
||||
}
|
||||
|
||||
// The query executed by GetSyncStatus.
|
||||
const GetSyncStatus_Operation = `
|
||||
query GetSyncStatus {
|
||||
azimuthGetSyncStatus {
|
||||
latestProcessedBlockHash
|
||||
latestProcessedBlockNumber
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func GetSyncStatus(
|
||||
ctx_ context.Context,
|
||||
client_ graphql.Client,
|
||||
) (data_ *GetSyncStatusResponse, err_ error) {
|
||||
req_ := &graphql.Request{
|
||||
OpName: "GetSyncStatus",
|
||||
Query: GetSyncStatus_Operation,
|
||||
}
|
||||
|
||||
data_ = &GetSyncStatusResponse{}
|
||||
resp_ := &graphql.Response{Data: data_}
|
||||
|
||||
err_ = client_.MakeRequest(
|
||||
ctx_,
|
||||
req_,
|
||||
resp_,
|
||||
)
|
||||
|
||||
return data_, err_
|
||||
}
|
||||
|
||||
// The query executed by IsActive.
|
||||
const IsActive_Operation = `
|
||||
query IsActive ($blockHash: String!, $contractAddress: String!, $_point: BigInt!) {
|
||||
azimuthIsActive(blockHash: $blockHash, contractAddress: $contractAddress, _point: $_point) {
|
||||
value
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func IsActive(
|
||||
ctx_ context.Context,
|
||||
client_ graphql.Client,
|
||||
blockHash string,
|
||||
contractAddress string,
|
||||
_point BigInt,
|
||||
) (data_ *IsActiveResponse, err_ error) {
|
||||
req_ := &graphql.Request{
|
||||
OpName: "IsActive",
|
||||
Query: IsActive_Operation,
|
||||
Variables: &__IsActiveInput{
|
||||
BlockHash: blockHash,
|
||||
ContractAddress: contractAddress,
|
||||
Point: _point,
|
||||
},
|
||||
}
|
||||
|
||||
data_ = &IsActiveResponse{}
|
||||
resp_ := &graphql.Response{Data: data_}
|
||||
|
||||
err_ = client_.MakeRequest(
|
||||
ctx_,
|
||||
req_,
|
||||
resp_,
|
||||
)
|
||||
|
||||
return data_, err_
|
||||
}
|
||||
8
genqlient.yaml
Normal file
8
genqlient.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
# genqlient configuration for azimuth-client-go
|
||||
schema: schema.graphql
|
||||
operations:
|
||||
- queries.graphql
|
||||
generated: generated.go
|
||||
bindings:
|
||||
BigInt:
|
||||
type: github.com/zenithchain/azimuth-client-go.BigInt
|
||||
16
go.mod
Normal file
16
go.mod
Normal file
@ -0,0 +1,16 @@
|
||||
module github.com/zenithchain/azimuth-client-go
|
||||
|
||||
go 1.23
|
||||
|
||||
require (
|
||||
github.com/Khan/genqlient v0.8.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.5.19 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
20
go.sum
Normal file
20
go.sum
Normal file
@ -0,0 +1,20 @@
|
||||
github.com/Khan/genqlient v0.8.0 h1:Hd1a+E1CQHYbMEKakIkvBH3zW0PWEeiX6Hp1i2kP2WE=
|
||||
github.com/Khan/genqlient v0.8.0/go.mod h1:hn70SpYjWteRGvxTwo0kfaqg4wxvndECGkfa1fdDdYI=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
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/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
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/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/vektah/gqlparser/v2 v2.5.19 h1:bhCPCX1D4WWzCDvkPl4+TP1N8/kLrWnp43egplt7iSg=
|
||||
github.com/vektah/gqlparser/v2 v2.5.19/go.mod h1:y7kvl5bBlDeuWIvLtA9849ncyvx6/lj06RsMrEjVy3U=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
69
queries.graphql
Normal file
69
queries.graphql
Normal file
@ -0,0 +1,69 @@
|
||||
# GraphQL queries for azimuth-client-go
|
||||
|
||||
query GetSyncStatus {
|
||||
azimuthGetSyncStatus {
|
||||
latestProcessedBlockHash
|
||||
latestProcessedBlockNumber
|
||||
}
|
||||
}
|
||||
|
||||
query EventsInRange($fromBlockNumber: Int!, $toBlockNumber: Int!, $name: String) {
|
||||
azimuthEventsInRange(fromBlockNumber: $fromBlockNumber, toBlockNumber: $toBlockNumber, name: $name) {
|
||||
block {
|
||||
hash
|
||||
number
|
||||
}
|
||||
tx {
|
||||
hash
|
||||
index
|
||||
from
|
||||
to
|
||||
}
|
||||
eventIndex
|
||||
event {
|
||||
__typename
|
||||
... on OwnerChangedEvent {
|
||||
point
|
||||
owner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetOwner($blockHash: String!, $contractAddress: String!, $_point: BigInt!) {
|
||||
azimuthGetOwner(blockHash: $blockHash, contractAddress: $contractAddress, _point: $_point) {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
query GetSponsoring($sponsor: BigInt!, $blockHash: String!, $contractAddress: String!) {
|
||||
azimuthGetSponsoring(_sponsor: $sponsor, blockHash: $blockHash, contractAddress: $contractAddress) {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
query GetSponsor($point: BigInt!, $blockHash: String!, $contractAddress: String!) {
|
||||
azimuthGetSponsor(_point: $point, blockHash: $blockHash, contractAddress: $contractAddress) {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
query GetKeys($blockHash: String!, $contractAddress: String!, $_point: BigInt!) {
|
||||
azimuthGetKeys(blockHash: $blockHash, contractAddress: $contractAddress, _point: $_point) {
|
||||
value {
|
||||
value0
|
||||
value1
|
||||
value2
|
||||
value3
|
||||
}
|
||||
proof {
|
||||
data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query IsActive($blockHash: String!, $contractAddress: String!, $_point: BigInt!) {
|
||||
azimuthIsActive(blockHash: $blockHash, contractAddress: $contractAddress, _point: $_point) {
|
||||
value
|
||||
}
|
||||
}
|
||||
84
schema.graphql
Normal file
84
schema.graphql
Normal file
@ -0,0 +1,84 @@
|
||||
scalar BigInt
|
||||
|
||||
type _Block_ {
|
||||
cid: String
|
||||
hash: String!
|
||||
number: Int!
|
||||
timestamp: Int!
|
||||
parentHash: String!
|
||||
}
|
||||
|
||||
type _Transaction_ {
|
||||
hash: String!
|
||||
index: Int!
|
||||
from: String!
|
||||
to: String!
|
||||
}
|
||||
|
||||
type Proof {
|
||||
data: String!
|
||||
}
|
||||
|
||||
type ResultEvent {
|
||||
block: _Block_!
|
||||
tx: _Transaction_!
|
||||
contract: String!
|
||||
eventIndex: Int!
|
||||
event: Event!
|
||||
proof: Proof
|
||||
}
|
||||
|
||||
type ResultString {
|
||||
value: String!
|
||||
proof: Proof
|
||||
}
|
||||
|
||||
type ResultArray {
|
||||
value: [String!]!
|
||||
proof: Proof
|
||||
}
|
||||
|
||||
type ResultGetKeysType {
|
||||
value: GetKeysType!
|
||||
proof: Proof
|
||||
}
|
||||
|
||||
type GetKeysType {
|
||||
value0: String!
|
||||
value1: String!
|
||||
value2: BigInt!
|
||||
value3: BigInt!
|
||||
}
|
||||
|
||||
type ResultBool {
|
||||
value: Boolean!
|
||||
proof: Proof
|
||||
}
|
||||
|
||||
union Event = OwnerChangedEvent
|
||||
|
||||
type OwnerChangedEvent {
|
||||
point: BigInt!
|
||||
owner: String!
|
||||
}
|
||||
|
||||
type SyncStatus {
|
||||
latestIndexedBlockHash: String!
|
||||
latestIndexedBlockNumber: Int!
|
||||
latestCanonicalBlockHash: String!
|
||||
latestCanonicalBlockNumber: Int!
|
||||
initialIndexedBlockHash: String!
|
||||
initialIndexedBlockNumber: Int!
|
||||
latestProcessedBlockHash: String!
|
||||
latestProcessedBlockNumber: Int!
|
||||
}
|
||||
|
||||
type Query {
|
||||
azimuthEventsInRange(fromBlockNumber: Int!, toBlockNumber: Int!, name: String): [ResultEvent!]
|
||||
azimuthGetSyncStatus: SyncStatus
|
||||
azimuthGetOwner(blockHash: String!, contractAddress: String!, _point: BigInt!): ResultString!
|
||||
azimuthGetSponsoring(_sponsor: BigInt!, blockHash: String!, contractAddress: String!): ResultArray!
|
||||
azimuthGetSponsor(_point: BigInt!, blockHash: String!, contractAddress: String!): ResultString!
|
||||
azimuthGetKeys(blockHash: String!, contractAddress: String!, _point: BigInt!): ResultGetKeysType!
|
||||
azimuthIsActive(blockHash: String!, contractAddress: String!, _point: BigInt!): ResultBool!
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user