fireblocks

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 16 Imported by: 0

README

fireblocks-passthrough-go

Intro

A Golang passthrough for the Fireblocks API

The reason i make this library is to make it easy to call the Fireblocks API and separate the logic for processing the response. The response is returned as interface{}

Example

Initialization
apiKey := "FIREBLOCKS_API_KEY"
privateKey, err := ReadPrivateKey("PATH_TO_PRIVATE_KEY")
if err != nil {
  panic("Failed to read private key")
}
fireblocksUrl := "https://api.fireblocks.io"
timeout := 0
sdk := NewInstance(privateKey, apiKey, fireblocksUrl, timeout)
GET Method
payload := make(map[string]interface{})
marshalled, err := json.Marshal(payload)
method := "GET"
path := "/v1/supported_assets"
result, err := sdk.Passthrough(method, path, marshalled)
POST Method
payload := make(map[string]interface{})
marshalled, err := json.Marshal(payload)
method := "POST"
path := "/v1/webhooks/resend"
result, err := sdk.Passthrough(method, path, marshalled)

To-Do

  • Example for PUT & DELETE methods
  • Improve performance
Notes

Inspired by caxqueiroz/fireblocks-sdk

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadPrivateKey

func ReadPrivateKey(path string) ([]byte, error)

Types

type FbKeyMgmt

type FbKeyMgmt struct {
	// contains filtered or unexported fields
}

func NewInstanceKeyMgmt

func NewInstanceKeyMgmt(pk *rsa.PrivateKey, apiKey string) *FbKeyMgmt

type Method

type Method string
const (
	GET    Method = "GET"
	POST   Method = "POST"
	PUT    Method = "PUT"
	DELETE Method = "DELETE"
)

type SDK

type SDK struct {
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance(pk []byte, ak string, url string, t time.Duration) *SDK

NewInstance - create new type to handle Fireblocks API requests

func (*SDK) Passthrough

func (s *SDK) Passthrough(method Method, path string, payload []byte) (interface{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL