npgsdk

package module
v0.0.0-...-9206383 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 14 Imported by: 0

README

sdk

NPG SDK

invoke a new SDK instance for each request

func (app *App) AuthenticatedUser(c *gin.Context) (*UserSession, error) {
	ctx := context.Background()

	token := c.Request.Header["Authorization"][0]

	doc, err := app.firestoreClient.Collection("sessions").Doc(
		hex.EncodeToString(app.Hash([]byte(token))),
	).Get(ctx)
	if err != nil {
		return nil, err
	}

	session := &UserSession{}
	if err := doc.DataTo(session); err != nil {
		return nil, err
	}
	session.sdk = npgsdk.InitSDK(CONST_PROJECT, token)

	return session, nil
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTokenRequest

func BuildTokenRequest(name, description, image, symbol string, supply int) *relysia.IssueRequest

BuildTokenRequest is a helper constructor for valid input to the Issue endpoint

Types

type SDK

type SDK struct {
	Relysia *relysia.Client
	Storage *storage.Client
	// contains filtered or unexported fields
}

func InitSDK

func InitSDK(gcpProjectID, authToken string) *SDK

InitSDK constructs the context for the user's interactions

func (*SDK) AcceptSwapOffer

func (sdk *SDK) AcceptSwapOffer(walletID, swapHex string) (*relysia.SwapResponse, error)

func (*SDK) CreateSwapOffer

func (sdk *SDK) CreateSwapOffer(walletID, tokenID, receiveType string, amount float64) (*relysia.OfferResponse, error)

func (*SDK) CreateWallet

func (sdk *SDK) CreateWallet(title string) (string, error)

CreateWallet makes a wallet for the user that has the given title

func (*SDK) GetHTTP

func (sdk *SDK) GetHTTP(url string, dst interface{}) error

func (*SDK) GetWalletByTitle

func (sdk *SDK) GetWalletByTitle(title string) (string, error)

func (*SDK) HashSHA1

func (sdk *SDK) HashSHA1(b []byte) []byte

func (*SDK) Insecure

func (self *SDK) Insecure()

func (*SDK) MintToken

func (sdk *SDK) MintToken(walletID string, issueRequest *relysia.IssueRequest) (*relysia.IssueResponse, error)

func (*SDK) UploadToChain

func (sdk *SDK) UploadToChain(walletID, bucketName, filename string, objectBytes []byte) (*relysia.UploadResponse, error)

UploadToChain makes the given file available on the blockchain via the cloud storage

func (*SDK) WalletBalanceBSV

func (sdk *SDK) WalletBalanceBSV(walletID, symbol string) (*relysia.BalanceResponse, error)

WalletBalanceBSV gives you the BSV balance

func (*SDK) WalletBalanceSTAS

func (sdk *SDK) WalletBalanceSTAS(walletID, symbol string) ([]*relysia.BalanceCoin, error)

WalletBalanceSTAS gives you the stas tokens in a slice

Directories

Path Synopsis
e2e module

Jump to

Keyboard shortcuts

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