ost

package module
v0.0.0-...-491b117 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: MIT Imports: 7 Imported by: 0

README

OST Go SDK

GitHub code size in bytes GitHub go.mod Go version GitHub closed pull requests GitHub pull requests GitHub issues GitHub contributors

OST Platform SDK for Go

Introduction

OST is a complete technology solution enabling mainstream businesses to easily launch blockchain-based economies without requiring blockchain development.

At the core of OST is the concept of OST-powered Brand Tokens (BTs). BTs are white-label cryptocurrency tokens with utility representations running on highly-scalable Ethereum-based side blockchains, backed by OST tokens staked on Ethereum mainnet. Within a business’s token economy, BTs can only be transferred to whitelisted user addresses. This ensures that they stay within the token economy.

The OST technology stack is designed to give businesses everything they need to integrate, test, and deploy BTs. Within the OST suite of products, developers can use OST Platform to create, test, and launch Brand Tokens backed by OST.

OST APIs and server-side SDKs make it simple and easy for developers to integrate blockchain tokens into their apps.

Requirements

Integrating an OST SDK into your application can begin as soon as you create an account with OST Platform, requiring only three steps:

  1. Sign-up on https://platform.ost.com.
  2. Create your Brand Token in OST Platform.
  3. Obtain an API Key and API Secret from https://platform.ost.com/mainnet/developer.

Documentation

https://dev.ost.com/

Installation

> go get github.com/tsirysndr/ost-sdk-go

Getting Started

Import the package into your project.

import "github.com/tsirysndr/ost-sdk-go"

Construct a new OST client, then use the various services on the client to access different parts of the OST API. For example:

// the latest valid API endpoint is "https://api.ost.com/mainnet/v2/"
config := ost.Config{
  Endpoint:  "<API_ENDPOINT>",
  ApiKey:    "<YOUR_API_KEY>",
  ApiSecret: "<YOUR_API_SECRET>",
}
client := ost.NewClient(config)

SDK Modules

If a user's private key is lost, they could lose access to their tokens. To tackle this risk, OST promotes a mobile-first approach and provides mobile (client) and server SDKs.

  • The server SDKs enable you to register users with OST Platform.
  • The client SDKs provide the additional support required for the ownership and management of Brand Tokens by users so that they can create keys and control their tokens.
Users Module

To register users with OST Platform, you can use the services provided in the Users module.

Create a User with OST Platform:

r, _ := client.Users.Create()
res, _ := json.Marshal(r)
fmt.Println(string(res))

Get User Detail:

r, _ := client.Users.Get("b6504ca4-9263-4998-8036-c90e648c48de")
res, _ := json.Marshal(r)
fmt.Println(string(res))

Get Users List:

r, _ := client.Users.GetList()
res, _ := json.Marshal(r)
fmt.Println(string(res))

Coverage

Currently the following services are supported:

  • Create User
  • Get User
  • List Users
  • Register Device
  • Get Device
  • List Devices in the Economy
  • List Devices of a User
  • Get Session
  • List Sessions in the Economy
  • List Sessions of a User
  • List All Rules
  • Get Price Point
  • Execute Company to User Transaction
  • Get Transaction
  • List Transactions in the economy
  • List Transactions of a user
  • Get Balance
  • Get Token
  • Get Recovery Owner
  • Get Chain Information
  • Get Device Manager
  • Get Available Base Token
  • Create WebHook
  • Get WebHook
  • List WebHooks
  • Update WebHook
  • Delete WebHook

Author

👤 Tsiry Sandratraina

Show your support

Give a ⭐️ if this project helped you!

Documentation

Index

Constants

View Source
const SIGNATURE_KIND = "OST1-HMAC-SHA256"

Variables

This section is empty.

Functions

func SignQueryParams

func SignQueryParams(resource, secret string) string

Types

type AuxiliaryChain

type AuxiliaryChain struct {
	ChainID             int      `json:"chain_id,omitempty"`
	UtilityBrandedToken string   `json:"utility_branded_token,omitempty"`
	CompanyTokenHolders []string `json:"company_token_holders,omitempty"`
	CompanyUUIDs        []string `json:"company_uuids,omitempty"`
	Organization        *struct {
		Contract string `json:"contract,omitempty"`
		Owner    string `json:"owner,omitempty"`
	} `json:"organization,omitempty"`
}

type Balance

type Balance struct {
	UserID           string `json:"user_id,omitempty"`
	TotalBalance     string `json:"total_balance,omitempty"`
	AvailableBalance string `json:"available_balance,omitempty"`
	UnsettledDebit   string `json:"unsettled_debit,omitempty"`
	UpdatedTimestamp int    `json:"updated_timestamp,omitempty"`
}

type BalanceResponse

type BalanceResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string   `json:"result_type,omitempty"`
		Balance    *Balance `json:"balance,omitempty"`
	} `json:"data,omitempty"`
}

type BalanceService

type BalanceService service

func (*BalanceService) Get

func (s *BalanceService) Get(userID string) (*BalanceResponse, error)

type BaseTokenResponse

type BaseTokenResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string      `json:"result_type,omitempty"`
		BaseTokens *BaseTokens `json:"base_tokens,omitempty"`
	} `json:"data,omitempty"`
}

type BaseTokenService

type BaseTokenService service

func (*BaseTokenService) Get

type BaseTokens

type BaseTokens struct {
	OST struct {
		Name                                 string `json:"name,omitempty"`
		Decimals                             int    `json:"decimals"`
		OriginChainErc20tokenContractAddress string `json:"origin_chain_erc20token_contract_address,omitempty"`
	} `json:"OST,omitempty"`
	USDC struct {
		Name                                 string `json:"name,omitempty"`
		Decimals                             int    `json:"decimals"`
		OriginChainErc20tokenContractAddress string `json:"origin_chain_erc20token_contract_address,omitempty"`
	} `json:"USDC,omitempty"`
}

type Chain

type Chain struct {
	ID               int    `json:"id,omitempty"`
	Type             string `json:"type,omitempty"`
	BlockHeight      int    `json:"block_height,omitempty"`
	BlockTime        int    `json:"block_time,omitempty"`
	UpdatedTimestamp int    `json:"updted_timestamp,omitempty"`
}

type ChainResponse

type ChainResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string `json:"result_type,omitempty"`
		Chain      *Chain `json:"chain,omitempty"`
	} `json:"data,omitempty"`
}

type ChainsService

type ChainsService service

func (*ChainsService) Get

func (s *ChainsService) Get(ID int) (*ChainResponse, error)

type Client

type Client struct {
	Balance       *BalanceService
	BaseToken     *BaseTokenService
	Chains        *ChainsService
	DeviceManager *DeviceManagerService
	Devices       *DevicesService
	PricePoint    *PricePointService
	RecoveryOwner *RecoveryOwnerService
	Rules         *RulesService
	Sessions      *SessionsService
	Token         *TokenService
	Transactions  *TransactionsService
	Users         *UsersService
	Webhooks      *WebhooksService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(o Options) *Client

type Device

type Device struct {
	UserID           string `json:"user_id,omitempty"`
	Address          string `json:"address,omitempty"`
	LinkedAddress    string `json:"linked_address,omitempty"`
	ApiSignerAddress string `json:"api_signer_address,omitempty"`
	Status           string `json:"status,omitempty"`
	UpdatedTimestamp int    `json:"updated_timestamp,omitempty"`
}

type DeviceManagerService

type DeviceManagerService service

type DeviceParams

type DeviceParams struct {
	QueryParams
	Addresses []string `url:"addresses,omitempty"`
	Limit     int      `url:"limit,omitempty"`
}

type DeviceResponse

type DeviceResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string   `json:"result_type,omitempty"`
		Device     *Device  `json:"device,omitempty"`
		Devices    []Device `json:"devices,omitempty"`
	} `json:"data,omitempty"`
}

type DevicesService

type DevicesService service

func (*DevicesService) Create

func (s *DevicesService) Create(userID string, params NewDevice) (*DeviceResponse, error)

func (*DevicesService) Get

func (s *DevicesService) Get(userID, address string) (*DeviceResponse, error)

func (*DevicesService) GetList

func (s *DevicesService) GetList(userID string, params DeviceParams) (*DeviceResponse, error)

type Empty

type Empty struct{}

type MetaProperty

type MetaProperty struct {
	Name    string `url:"name,omitempty"`
	Type    string `url:"type,omitempty"`
	Details string `url:"details,omitempty"`
}

type NewDevice

type NewDevice struct {
	QueryParams
	Address          string `json:"address,omitempty"`
	ApiSignerAddress string `json:"api_signer_address,omitempty"`
}

type Options

type Options struct {
	Endpoint  string
	ApiKey    string
	ApiSecret string
}

type OriginChain

type OriginChain struct {
	ChainID      int    `json:"chain_id,omitempty"`
	BrandedToken string `json:"branded_token,omitempty"`
	Organization *struct {
		Contract string `json:"contract,omitempty"`
		Owner    string `json:"owner,omitempty"`
	} `json:"organization,omitempty"`
}

type PricePoint

type PricePoint struct {
	OST *struct {
		USD       float64 `json:"USD,omitempty"`
		EUR       float64 `json:"EUR,omitempty"`
		GBP       float64 `json:"GBP,omitempty"`
		Decimals  int     `json:"decimals,omitempty"`
		UpdatedAt int     `json:"updated_at,omitempty"`
	} `json:"OST,omitempty"`
	USDC *struct {
		USD       float64 `json:"USD,omitempty"`
		EUR       float64 `json:"EUR,omitempty"`
		GBP       float64 `json:"GBP,omitempty"`
		Decimals  int     `json:"decimals,omitempty"`
		UpdatedAt int     `json:"updated_at,omitempty"`
	} `json:"USDC,omitempty"`
}

type PricePointResponse

type PricePointResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string      `json:"result_type,omitempty"`
		PricePoint *PricePoint `json:"price_point,omitempty"`
	} `json:"data,omitempty"`
}

type PricePointService

type PricePointService service

func (*PricePointService) Get

func (s *PricePointService) Get(chainID int) (*PricePointResponse, error)

type QueryParams

type QueryParams struct {
	ApiKey              string `url:"api_key,omitempty"`
	ApiRequestTimestamp int64  `url:"api_request_timestamp,omitempty"`
	ApiSignature        string `url:"api_signature,omitempty"`
	ApiSignatureKind    string `url:"api_signature_kind,omitempty"`
}

type RecoveryOwner

type RecoveryOwner struct {
	UserID           string `json:"user_id,omitempty"`
	Address          string `json:"address,omitempty"`
	Status           string `json:"status,omitempty"`
	UpdatedTimestamp int    `json:"updated_timestamp,omitempty"`
}

type RecoveryOwnerResponse

type RecoveryOwnerResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType    string        `json:"result_type,omitempty"`
		RecoveryOwner RecoveryOwner `json:"rules,omitempty"`
	} `json:"data,omitempty"`
}

type RecoveryOwnerService

type RecoveryOwnerService service

func (*RecoveryOwnerService) Get

func (s *RecoveryOwnerService) Get(userID, recoveryOwnerAddress string) (*RecoveryOwnerResponse, error)

type Rule

type Rule struct {
	ID      int         `json:"id,omitempty"`
	TokenID int         `json:"token_id,omitempty"`
	Name    string      `json:"name,omitempty"`
	Address string      `json:"address,omitempty"`
	ABI     interface{} `json:"abi,omitempty"`
}

type RuleResponse

type RuleResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string `json:"result_type,omitempty"`
		Rules      []Rule `json:"rules,omitempty"`
	} `json:"data,omitempty"`
}

type RulesService

type RulesService service

func (*RulesService) GetList

func (s *RulesService) GetList() (*RuleResponse, error)

type Session

type Session struct {
	UserID                    string `json:"user_id,omitempty"`
	Address                   string `json:"address,omitempty"`
	ExpirationHeight          int    `json:"expiration_height,omitempty"`
	ApproxExpirationTimestamp int    `json:"approx_expiration_timestamp,omitempty"`
	SpendingLimit             string `json:"spending_limit,omitempty"`
	Nonce                     int    `json:"nonce,omitempty"`
	Status                    string `json:"status,omitempty"`
	UpdatedTimestamp          int    `json:"updated_timestamp,omitempty"`
}

type SessionParams

type SessionParams struct {
	QueryParams
	Addresses []string `url:"addresses,omitempty"`
	Limit     int      `url:"limit,omitempty"`
}

type SessionsResponse

type SessionsResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string    `json:"result_type,omitempty"`
		Session    *Session  `json:"session,omitempty"`
		Sessions   []Session `json:"sessions,omitempty"`
	} `json:"data,omitempty"`
}

type SessionsService

type SessionsService service

func (*SessionsService) Get

func (s *SessionsService) Get(userID, sessionAddress string) (*SessionsResponse, error)

func (*SessionsService) GetList

func (s *SessionsService) GetList(userID string, params SessionParams) (*SessionsResponse, error)

type Token

type Token struct {
	ID               int              `json:"id,omitempty"`
	Name             string           `json:"name,omitempty"`
	Symbol           string           `json:"symbol,omitempty"`
	BaseToken        string           `json:"base_token,omitempty"`
	ConversionFactor int              `json:"conversion_factor,omitempty"`
	TotalSupply      string           `json:"total_supply,omitempty"`
	Decimals         int              `json:"decimals,omitempty"`
	OriginChain      *OriginChain     `json:"origin_chain,omitempty"`
	Stakers          []string         `json:"stakers,omitempty"`
	AuxiliaryChain   []AuxiliaryChain `json:"auxiliary_chains,omitempty"`
	UpdatedTimestamp int              `json:"updated_timestamp,omitempty"`
}

type TokenResponse

type TokenResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string `json:"result_type,omitempty"`
		Token      *Token `json:"token,omitempty"`
	} `json:"data,omitempty"`
}

type TokenService

type TokenService service

func (*TokenService) Get

func (s *TokenService) Get() (*TokenResponse, error)

type Transaction

type Transaction struct {
	ID                string        `json:"id,omitempty"`
	TransactionHash   string        `json:"transaction_hash,omitempty"`
	From              string        `json:"from,omitempty"`
	To                string        `json:"to,omitempty"`
	Nonce             int           `json:"nonce,omitempty"`
	Value             string        `json:"value,omitempty"`
	GasPrice          string        `json:"gas_price,omitempty"`
	GasUsed           int           `json:"gas_used,omitempty"`
	TransactionFee    string        `json:"transaction_fee,omitempty"`
	BlockConfirmation int           `json:"block_confirmation,omitempty"`
	Status            string        `json:"status,omitempty"`
	UpdatedTimestamp  int           `json:"updated_timestamp,omitempty"`
	BlockNumber       int           `json:"block_number,omitempty"`
	RuleName          string        `json:"rule_name,omitempty"`
	Transfers         []Transfer    `json:"transfers,omitempty"`
	MetaProperty      *MetaProperty `json:"meta_property,omitempty"`
}

type TransactionParams

type TransactionParams struct {
	QueryParams
	To           string        `url:"to,omitempty"`
	RawCallData  string        `url:"raw_call_data,omitempty"`
	MetaProperty *MetaProperty `url:"meta_property,omitempty"`
}

type TransactionResponse

type TransactionResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType   string        `json:"result_type,omitempty"`
		Transaction  *Transaction  `json:"transaction,omitempty"`
		Transactions []Transaction `json:"transactions,omitempty"`
	} `json:"data,omitempty"`
}

type TransactionsService

type TransactionsService service

func (*TransactionsService) Execute

func (s *TransactionsService) Execute(userID string, params TransactionParams) (*TransactionResponse, error)

func (*TransactionsService) Get

func (s *TransactionsService) Get(userID, transactionID string) (*TransactionResponse, error)

func (*TransactionsService) GetList

func (s *TransactionsService) GetList(userID string) (*TransactionResponse, error)

type Transfer

type Transfer struct {
	From       string `json:"from,omitempty"`
	FromUserID string `json:"from_user_id,omitempty"`
	To         string `json:"to,omitempty"`
	ToUserID   string `json:"to_user_id,omitempty"`
	Amount     string `json:"amount,omitempty"`
	Kind       string `json:"kind,omitempty"`
}

type User

type User struct {
	ID                   string `json:"id,omitempty"`
	TokenID              int    `json:"token_id,omitempty"`
	TokenHolderAddress   string `json:"token_holder_address,omitempty"`
	DeviceManagerAddress string `json:"device_manager_address,omitempty"`
	RecoveryAddress      string `json:"recovery_address,omitempty"`
	RecoveryOwnerAddress string `json:"recovery_owner_address,omitempty"`
	Type                 string `json:"type,omitempty"`
	Status               string `json:"status,omitempty"`
	UpdatedTimestamp     int    `json:"updated_timestamp,omitempty"`
}

type UserResponse

type UserResponse struct {
	Success bool `json:"success,omitempty"`
	Data    *struct {
		ResultType string `json:"result_type,omitempty"`
		User       *User  `json:"user,omitempty"`
		Users      []User `json:"users,omitempty"`
	} `json:"data,omitempty"`
}

type UsersService

type UsersService service

func (*UsersService) Create

func (s *UsersService) Create() (*UserResponse, error)

func (*UsersService) Get

func (s *UsersService) Get(ID string) (*UserResponse, error)

func (*UsersService) GetList

func (s *UsersService) GetList() (*UserResponse, error)

type WebhooksService

type WebhooksService service

Directories

Path Synopsis
example
balance command
base_token command
chains command
price_point command
recovery_owner command
rules command
token command
users/get_user command

Jump to

Keyboard shortcuts

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