mixin

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: MIT Imports: 33 Imported by: 130

README

mixin-sdk-go

Golang sdk for Mixin Network & Mixin Messenger

Install

go get github.com/fox-one/mixin-sdk-go

Features

  • comprehensive most of the Mixin Network & Mixin Messenger api supported
  • Security verify Response X-Request-ID & signature automatically
  • Flexible initialize Client from keystore, ed25519_oauth_token or access_token

Examples

See _examples/ for a variety of examples.

Quick Start

package main

import (
	"context"
	"log"

	"github.com/fox-one/mixin-sdk-go"
)

func main() {
	ctx := context.Background()
	s := &mixin.Keystore{
		ClientID:   "",
		SessionID:  "",
		PrivateKey: "",
		PinToken: "",
	}

	client, err := mixin.NewFromKeystore(s)
	if err != nil {
		log.Panicln(err)
	}

	user, err := client.UserMe(ctx)
	if err != nil {
		log.Printf("UserMe: %v", err)
		return
	}

	log.Println("user id", user.UserID)
}

Error handling?

check error code by mixin.IsErrorCodes

if _, err := client.UserMe(ctx); err != nil {
    switch {
    case mixin.IsErrorCodes(err,mixin.Unauthorized,mixin.EndpointNotFound):
    	// handle unauthorized error
    case mixin.IsErrorCodes(err,mixin.InsufficientBalance):
        // handle insufficient balance error
    default:
    }
}

Documentation

Index

Constants

View Source
const (
	ScopeProfileRead   = "PROFILE:READ"
	ScopePhoneRead     = "PHONE:READ"
	ScopeContactRead   = "CONTACTS:READ"
	ScopeAssetsRead    = "ASSETS:READ"
	ScopeSnapshotsRead = "SNAPSHOTS:READ"

	ScopeFull = "FULL"
)
View Source
const (
	CreateMessageAction      = "CREATE_MESSAGE"
	AcknowledgeReceiptAction = "ACKNOWLEDGE_MESSAGE_RECEIPT"
)
View Source
const (
	ConversationCategoryContact = "CONTACT"
	ConversationCategoryGroup   = "GROUP"

	ParticipantActionAdd    = "ADD"
	ParticipantActionRemove = "REMOVE"
	ParticipantActionJoin   = "JOIN"
	ParticipantActionExit   = "EXIT"
	ParticipantActionRole   = "ROLE"

	ParticipantRoleAdmin  = "ADMIN"
	ParticipantRoleMember = ""
)
View Source
const (
	DefaultApiHost   = "https://api.mixin.one"
	DefaultBlazeHost = "blaze.mixin.one"

	ZeromeshApiHost   = "https://mixin-api.zeromesh.net"
	ZeromeshBlazeHost = "mixin-blaze.zeromesh.net"

	EchoApiHost = "https://echo.yiplee.com"
)
View Source
const (
	Unauthorized        = 401
	EndpointNotFound    = 404
	InsufficientBalance = 20117
	PinIncorrect        = 20119
	InsufficientFee     = 20124
	InvalidTraceID      = 20125
)

mixin error codes https://developers.mixin.one/api/alpha-mixin-network/errors/

View Source
const (
	MessageCategoryPlainText             = "PLAIN_TEXT"
	MessageCategoryPlainPost             = "PLAIN_POST"
	MessageCategoryPlainImage            = "PLAIN_IMAGE"
	MessageCategoryPlainData             = "PLAIN_DATA"
	MessageCategoryPlainSticker          = "PLAIN_STICKER"
	MessageCategoryPlainLive             = "PLAIN_LIVE"
	MessageCategoryPlainVideo            = "PLAIN_VIDEO"
	MessageCategoryPlainContact          = "PLAIN_CONTACT"
	MessageCategoryAppCard               = "APP_CARD"
	MessageCategoryAppButtonGroup        = "APP_BUTTON_GROUP"
	MessageCategoryMessageRecall         = "MESSAGE_RECALL"
	MessageCategorySystemConversation    = "SYSTEM_CONVERSATION"
	MessageCategorySystemAccountSnapshot = "SYSTEM_ACCOUNT_SNAPSHOT"

	MessageStatusSent = "SENT"
	MessageStatusRead = "READ"
)
View Source
const (
	PaymentStatusPending = "pending"
	PaymentStatusPaid    = "paid"
)
View Source
const Scheme = "mixin"

Variables

View Source
var URL urlScheme

Functions

func AuthorizeToken

func AuthorizeToken(ctx context.Context, clientID, clientSecret string, code string, verifier string) (string, string, error)

func DecodeResponse

func DecodeResponse(resp *resty.Response) ([]byte, error)

func GenerateEd25519Key

func GenerateEd25519Key() ed25519.PrivateKey

func IsErrorCodes

func IsErrorCodes(err error, codes ...int) bool

func RandomPin

func RandomPin() string

func RandomTraceID

func RandomTraceID() string

func Request

func Request(ctx context.Context) *resty.Request

func RequestIdFromContext

func RequestIdFromContext(ctx context.Context) string

func SignRaw

func SignRaw(method, uri string, body []byte) string

func SignRequest

func SignRequest(r *http.Request) string

func SignResponse

func SignResponse(r *resty.Response) string

func UniqueConversationID

func UniqueConversationID(userID, recipientID string) string

func UnmarshalResponse

func UnmarshalResponse(resp *resty.Response, v interface{}) error

func UploadAttachment

func UploadAttachment(ctx context.Context, attachment *Attachment, file []byte) error

func UseApiHost

func UseApiHost(host string)

func UseBlazeHost

func UseBlazeHost(host string)

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID bind request id to context request id must be uuid

func WithSigner

func WithSigner(ctx context.Context, s Signer) context.Context

func WithVerifier

func WithVerifier(ctx context.Context, v Verifier) context.Context

Types

type AcknowledgementRequest

type AcknowledgementRequest struct {
	MessageID string `json:"message_id,omitempty"`
	Status    string `json:"status,omitempty"`
}

type Address

type Address struct {
	AddressID   string          `json:"address_id,omitempty"`
	AssetID     string          `json:"asset_id"`
	Label       string          `json:"label,omitempty"`
	Destination string          `json:"destination,omitempty"`
	Tag         string          `json:"tag,omitempty"`
	Fee         decimal.Decimal `json:"fee,omitempty"`
	Dust        decimal.Decimal `json:"dust,omitempty"`
}

func ReadAddress

func ReadAddress(ctx context.Context, accessToken, addressID string) (*Address, error)

func ReadAddresses

func ReadAddresses(ctx context.Context, accessToken, assetID string) ([]*Address, error)

type App

type App struct {
	UpdatedAt        time.Time `json:"updated_at,omitempty"`
	AppID            string    `json:"app_id,omitempty"`
	AppNumber        string    `json:"app_number,omitempty"`
	RedirectURL      string    `json:"redirect_url,omitempty"`
	HomeURL          string    `json:"home_url,omitempty"`
	Name             string    `json:"name,omitempty"`
	IconURL          string    `json:"icon_url,omitempty"`
	Description      string    `json:"description,omitempty"`
	Capabilities     []string  `json:"capabilities,omitempty"`
	ResourcePatterns []string  `json:"resource_patterns,omitempty"`
	Category         string    `json:"category,omitempty"`
	CreatorID        string    `json:"creator_id,omitempty"`
	AppSecret        string    `json:"app_secret,omitempty"`
}

type AppButtonGroupMessage

type AppButtonGroupMessage []AppButtonMessage

type AppButtonMessage

type AppButtonMessage struct {
	Label  string `json:"label,omitempty"`
	Action string `json:"action,omitempty"`
	Color  string `json:"color,omitempty"`
}

type AppCardMessage

type AppCardMessage struct {
	IconURL     string `json:"icon_url,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Action      string `json:"action,omitempty"`
}

type Asset

type Asset struct {
	AssetID        string          `json:"asset_id"`
	ChainID        string          `json:"chain_id"`
	AssetKey       string          `json:"asset_key,omitempty"`
	MixinID        string          `json:"mixin_id,omitempty"`
	Symbol         string          `json:"symbol,omitempty"`
	Name           string          `json:"name,omitempty"`
	IconURL        string          `json:"icon_url,omitempty"`
	PriceBTC       decimal.Decimal `json:"price_btc,omitempty"`
	ChangeBTC      decimal.Decimal `json:"change_btc,omitempty"`
	PriceUSD       decimal.Decimal `json:"price_usd,omitempty"`
	ChangeUsd      decimal.Decimal `json:"change_usd,omitempty"`
	Balance        decimal.Decimal `json:"balance,omitempty"`
	Destination    string          `json:"destination,omitempty"`
	Tag            string          `json:"tag,omitempty"`
	Confirmations  int             `json:"confirmations,omitempty"`
	Capitalization float64         `json:"capitalization,omitempty"`
}

func ReadAsset

func ReadAsset(ctx context.Context, accessToken, assetID string) (*Asset, error)

func ReadAssets

func ReadAssets(ctx context.Context, accessToken string) ([]*Asset, error)

func ReadTopNetworkAssets

func ReadTopNetworkAssets(ctx context.Context) ([]*Asset, error)

type Attachment

type Attachment struct {
	AttachmentID string `json:"attachment_id"`
	UploadURL    string `json:"upload_url"`
	ViewURL      string `json:"view_url"`
}

type AudioMessage

type AudioMessage struct {
	AttachmentID string `json:"attachment_id,omitempty"`
	MimeType     string `json:"mime_type,omitempty"`
	WaveForm     string `json:"wave_form,omitempty"`
	Size         int    `json:"size,omitempty"`
	Duration     int    `json:"duration,omitempty"`
}

type BlazeListenFunc

type BlazeListenFunc func(ctx context.Context, msg *MessageView, userID string) error

func (BlazeListenFunc) OnAckReceipt

func (f BlazeListenFunc) OnAckReceipt(ctx context.Context, msg *MessageView, userID string) error

func (BlazeListenFunc) OnMessage

func (f BlazeListenFunc) OnMessage(ctx context.Context, msg *MessageView, userID string) error

type BlazeListener

type BlazeListener interface {
	OnAckReceipt(ctx context.Context, msg *MessageView, userID string) error
	OnMessage(ctx context.Context, msg *MessageView, userID string) error
}

type BlazeMessage

type BlazeMessage struct {
	Id     string                 `json:"id"`
	Action string                 `json:"action"`
	Params map[string]interface{} `json:"params,omitempty"`
	Data   json.RawMessage        `json:"data,omitempty"`
	Error  *Error                 `json:"error,omitempty"`
}

type Client

type Client struct {
	Signer
	Verifier

	ClientID string
}

func NewFromAccessToken

func NewFromAccessToken(accessToken string) *Client

func NewFromKeystore

func NewFromKeystore(keystore *Keystore) (*Client, error)

func NewFromOauthKeystore

func NewFromOauthKeystore(keystore *OauthKeystore) (*Client, error)

func (*Client) AddParticipants

func (c *Client) AddParticipants(ctx context.Context, conversationID string, users ...string) (*Conversation, error)

func (*Client) AdminParticipants

func (c *Client) AdminParticipants(ctx context.Context, conversationID string, users ...string) (*Conversation, error)

func (*Client) CreateAddress

func (c *Client) CreateAddress(ctx context.Context, input CreateAddressInput, pin string) (*Address, error)

func (*Client) CreateAttachment

func (c *Client) CreateAttachment(ctx context.Context) (*Attachment, error)

func (*Client) CreateContactConversation

func (c *Client) CreateContactConversation(ctx context.Context, userID string) (*Conversation, error)

CreateContactConversation create a conversation with a mixin messenger user

func (*Client) CreateConversation

func (c *Client) CreateConversation(ctx context.Context, input *CreateConversationInput) (*Conversation, error)

CreateConversation crate conversation

func (*Client) CreateGroupConversation

func (c *Client) CreateGroupConversation(ctx context.Context, conversationID, name string, participants []*Participant) (*Conversation, error)

CreateGroupConversation create a group in mixin messenger with given participants

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, key *rsa.PrivateKey, fullname string) (*User, *Keystore, error)

func (*Client) DeleteAddress

func (c *Client) DeleteAddress(ctx context.Context, addressID, pin string) error

func (*Client) FavoriteApp added in v1.0.3

func (c *Client) FavoriteApp(ctx context.Context, appID string) (*FavoriteApp, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, uri string, params map[string]string, resp interface{}) error

func (*Client) LoopBlaze

func (c *Client) LoopBlaze(ctx context.Context, listener BlazeListener) error

func (*Client) MakeTransactionOutput

func (c *Client) MakeTransactionOutput(ctx context.Context, ids ...string) (*TransactionOutput, error)

func (*Client) ManageConversation

func (c *Client) ManageConversation(ctx context.Context, conversationID, action string, participants []*Participant) (*Conversation, error)

func (*Client) ModifyPin

func (c *Client) ModifyPin(ctx context.Context, pin, newPin string) error

func (*Client) ModifyProfile

func (c *Client) ModifyProfile(ctx context.Context, fullname, avatarBase64 string) (*User, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, uri string, body interface{}, resp interface{}) error

func (*Client) ReadAddress

func (c *Client) ReadAddress(ctx context.Context, addressID string) (*Address, error)

func (*Client) ReadAddresses

func (c *Client) ReadAddresses(ctx context.Context, assetID string) ([]*Address, error)

func (*Client) ReadApp

func (c *Client) ReadApp(ctx context.Context, appID string) (*App, error)

func (*Client) ReadAsset

func (c *Client) ReadAsset(ctx context.Context, assetID string) (*Asset, error)

func (*Client) ReadAssetFee

func (c *Client) ReadAssetFee(ctx context.Context, assetID string) (decimal.Decimal, error)

func (*Client) ReadAssets

func (c *Client) ReadAssets(ctx context.Context) ([]*Asset, error)

func (*Client) ReadConversation

func (c *Client) ReadConversation(ctx context.Context, conversationID string) (*Conversation, error)

ReadConversation read conversation

func (*Client) ReadExchangeRates

func (c *Client) ReadExchangeRates(ctx context.Context) ([]ExchangeRate, error)

func (*Client) ReadFavoriteApps

func (c *Client) ReadFavoriteApps(ctx context.Context, userID string) ([]*FavoriteApp, error)

func (*Client) ReadFriends

func (c *Client) ReadFriends(ctx context.Context) ([]*User, error)

func (*Client) ReadNetworkSnapshot

func (c *Client) ReadNetworkSnapshot(ctx context.Context, snapshotID string) (*Snapshot, error)

func (*Client) ReadNetworkSnapshots

func (c *Client) ReadNetworkSnapshots(ctx context.Context, assetID string, offset time.Time, order string, limit int) ([]*Snapshot, error)

func (*Client) ReadSnapshot

func (c *Client) ReadSnapshot(ctx context.Context, snapshotID string) (*Snapshot, error)

func (*Client) ReadSnapshots

func (c *Client) ReadSnapshots(ctx context.Context, assetID string, offset time.Time, order string, limit int) ([]*Snapshot, error)

ReadSnapshots return a list of snapshots order must be `ASC` or `DESC`

func (*Client) ReadTransfer

func (c *Client) ReadTransfer(ctx context.Context, traceID string) (*Snapshot, error)

func (*Client) ReadTurnServers

func (c *Client) ReadTurnServers(ctx context.Context) ([]*Turn, error)

func (*Client) ReadUser

func (c *Client) ReadUser(ctx context.Context, userIdOrIdentityNumber string) (*User, error)

func (*Client) ReadUsers

func (c *Client) ReadUsers(ctx context.Context, ids ...string) ([]*User, error)

func (*Client) RemoveParticipants

func (c *Client) RemoveParticipants(ctx context.Context, conversationID string, users ...string) (*Conversation, error)

func (*Client) Request

func (c *Client) Request(ctx context.Context) *resty.Request

func (*Client) RotateConversation

func (c *Client) RotateConversation(ctx context.Context, conversationID string) (*Conversation, error)

func (*Client) SearchUser

func (c *Client) SearchUser(ctx context.Context, identityNumber string) (*User, error)

deprecated. Use ReadUser() instead

func (*Client) SendAcknowledgement

func (c *Client) SendAcknowledgement(ctx context.Context, request *AcknowledgementRequest) error

func (*Client) SendAcknowledgements

func (c *Client) SendAcknowledgements(ctx context.Context, requests []*AcknowledgementRequest) error

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, message *MessageRequest) error

func (*Client) SendMessages

func (c *Client) SendMessages(ctx context.Context, messages []*MessageRequest) error

func (*Client) SendRawMessages

func (c *Client) SendRawMessages(ctx context.Context, messages []json.RawMessage) error

func (*Client) ShowAttachment

func (c *Client) ShowAttachment(ctx context.Context, id string) (*Attachment, error)

func (*Client) Transaction

func (c *Client) Transaction(ctx context.Context, in *TransferInput, pin string) (*RawTransaction, error)

func (*Client) Transfer

func (c *Client) Transfer(ctx context.Context, input *TransferInput, pin string) (*Snapshot, error)

func (*Client) UserMe

func (c *Client) UserMe(ctx context.Context) (*User, error)

func (*Client) VerifyPayment

func (c *Client) VerifyPayment(ctx context.Context, input TransferInput) (*Payment, error)

func (*Client) VerifyPin

func (c *Client) VerifyPin(ctx context.Context, pin string) error

func (*Client) Withdraw

func (c *Client) Withdraw(ctx context.Context, input WithdrawInput, pin string) (*Snapshot, error)

type ContactMessage

type ContactMessage struct {
	UserID string `json:"user_id,omitempty"`
}

type Conversation

type Conversation struct {
	ConversationID string `json:"conversation_id,omitempty"`
	CreatorID      string `json:"creator_id,omitempty"`
	Category       string `json:"category,omitempty"`
	Name           string `json:"name,omitempty"`
	IconURL        string `json:"icon_url,omitempty"`
	Announcement   string `json:"announcement,omitempty"`
	CreatedAt      string `json:"created_at,omitempty"`
	CodeID         string `json:"code_id,omitempty"`
	CodeURL        string `json:"code_url,omitempty"`

	Participants []*Participant `json:"participants,omitempty"`
}

Conversation conversation

type CreateAddressInput

type CreateAddressInput struct {
	AssetID     string `json:"asset_id"`
	Destination string `json:"destination,omitempty"`
	Tag         string `json:"tag,omitempty"`
	Label       string `json:"label,omitempty"`
}

type CreateConversationInput

type CreateConversationInput struct {
	Category       string         `json:"category,omitempty"`
	ConversationID string         `json:"conversation_id,omitempty"`
	Name           string         `json:"name,omitempty"`
	Participants   []*Participant `json:"participants,omitempty"`
}

type DataMessage

type DataMessage struct {
	AttachmentID string `json:"attachment_id,omitempty"`
	MimeType     string `json:"mime_type,omitempty"`
	Size         int    `json:"size,omitempty"`
	Name         string `json:"name,omitempty"`
}

type EdDSASigningMethod

type EdDSASigningMethod struct{}
var Ed25519SigningMethod *EdDSASigningMethod

func (*EdDSASigningMethod) Alg

func (sm *EdDSASigningMethod) Alg() string

func (*EdDSASigningMethod) Sign

func (sm *EdDSASigningMethod) Sign(signingString string, key interface{}) (string, error)

func (*EdDSASigningMethod) Verify

func (sm *EdDSASigningMethod) Verify(signingString, signature string, key interface{}) error

type Error

type Error struct {
	Status      int                    `json:"status"`
	Code        int                    `json:"code"`
	Description string                 `json:"description"`
	Extra       map[string]interface{} `json:"extra,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type ExchangeRate

type ExchangeRate struct {
	Code string          `json:"code,omitempty"`
	Rate decimal.Decimal `json:"rate,omitempty"`
}

type ExternalTransaction

type ExternalTransaction struct {
	TransactionID   string          `json:"transaction_id"`
	CreatedAt       time.Time       `json:"created_at"`
	TransactionHash string          `json:"transaction_hash"`
	Sender          string          `json:"sender"`
	ChainId         string          `json:"chain_id"`
	AssetId         string          `json:"asset_id"`
	Amount          decimal.Decimal `json:"amount"`
	Destination     string          `json:"destination"`
	Tag             string          `json:"tag"`
	Confirmations   int64           `json:"confirmations"`
	Threshold       int64           `json:"threshold"`
}

func ReadExternalTransactions

func ReadExternalTransactions(ctx context.Context, assetID, destination, tag string) ([]*ExternalTransaction, error)

type FavoriteApp

type FavoriteApp struct {
	UserID    string    `json:"user_id,omitempty"`
	AppID     string    `json:"app_id,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
}

type ImageMessage

type ImageMessage struct {
	AttachmentID string `json:"attachment_id,omitempty"`
	MimeType     string `json:"mime_type,omitempty"`
	Width        int    `json:"width,omitempty"`
	Height       int    `json:"height,omitempty"`
	Size         int    `json:"size,omitempty"`
	Thumbnail    []byte `json:"thumbnail,omitempty"`
}

type Keystore

type Keystore struct {
	ClientID   string `json:"client_id"`
	SessionID  string `json:"session_id"`
	PrivateKey string `json:"private_key"`
	PinToken   string `json:"pin_token"`
	Scope      string `json:"scope"`
}

type KeystoreAuth

type KeystoreAuth struct {
	*Keystore
	// contains filtered or unexported fields
}

func AuthFromKeystore

func AuthFromKeystore(store *Keystore) (*KeystoreAuth, error)

func (*KeystoreAuth) EncryptPin

func (k *KeystoreAuth) EncryptPin(pin string) string

func (*KeystoreAuth) SignToken

func (k *KeystoreAuth) SignToken(signature, requestID string, exp time.Duration) string

type LiveMessage

type LiveMessage struct {
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	ThumbUrl string `json:"thumb_url"`
	URL      string `json:"url"`
}

type LocationMessage

type LocationMessage struct {
	Name      string  `json:"name,omitempty"`
	Address   string  `json:"address,omitempty"`
	Longitude float64 `json:"longitude,omitempty"`
	Latitude  float64 `json:"latitude,omitempty"`
}

type MessageRequest

type MessageRequest struct {
	ConversationID   string `json:"conversation_id"`
	RecipientID      string `json:"recipient_id"`
	MessageID        string `json:"message_id"`
	Category         string `json:"category"`
	Data             string `json:"data"`
	RepresentativeID string `json:"representative_id,omitempty"`
	QuoteMessageID   string `json:"quote_message_id,omitempty"`
}

type MessageView

type MessageView struct {
	ConversationID   string    `json:"conversation_id"`
	UserID           string    `json:"user_id"`
	MessageID        string    `json:"message_id"`
	Category         string    `json:"category"`
	Data             string    `json:"data"`
	RepresentativeID string    `json:"representative_id"`
	QuoteMessageID   string    `json:"quote_message_id"`
	Status           string    `json:"status"`
	Source           string    `json:"source"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
	// contains filtered or unexported fields
}

func (*MessageView) Ack

func (m *MessageView) Ack()

Ack mark messageView as acked otherwise sdk will ack this message

type NetworkAsset

type NetworkAsset struct {
	Amount  decimal.Decimal `json:"amount"`
	AssetID string          `json:"asset_id"`
	IconURL string          `json:"icon_url"`
	Symbol  string          `json:"symbol"`

	// populated only at ReadNetworkAsset
	ChainID       string `json:"chain_id,omitempty"`
	MixinID       string `json:"mixin_id,omitempty"`
	Name          string `json:"name,omitempty"`
	SnapshotCount int64  `json:"snapshot_count,omitempty"`
}

func ReadNetworkAsset

func ReadNetworkAsset(ctx context.Context, assetID string) (*NetworkAsset, error)

type NetworkChain

type NetworkChain struct {
	ChainID              string          `json:"chain_id"`
	IconURL              string          `json:"icon_url"`
	Name                 string          `json:"name"`
	Type                 string          `json:"type"`
	WithdrawFee          decimal.Decimal `json:"withdrawal_fee"`
	WithdrawTimestamp    time.Time       `json:"withdrawal_timestamp"`
	WithdrawPendingCount int64           `json:"withdrawal_pending_count"`
	DepositBlockHeight   int64           `json:"deposit_block_height"`
	ExternalBlockHeight  int64           `json:"external_block_height"`
	ManagedBlockHeight   int64           `json:"managed_block_height"`
	IsSynchronized       bool            `json:"is_synchronized"`
}

type NetworkInfo

type NetworkInfo struct {
	Assets         []*NetworkAsset `json:"assets"`
	Chains         []*NetworkChain `json:"chains"`
	AssetsCount    decimal.Decimal `json:"assets_count"`
	PeakThroughput decimal.Decimal `json:"peak_throughput"`
	SnapshotsCount decimal.Decimal `json:"snapshots_count"`
	Type           string          `json:"type"`
}

NetworkInfo mixin network info

func ReadNetworkInfo

func ReadNetworkInfo(ctx context.Context) (*NetworkInfo, error)

ReadNetworkInfo read mixin network

type OauthKeystore

type OauthKeystore struct {
	ClientID   string `json:"client_id,omitempty"`
	AuthID     string `json:"authorization_id,omitempty"`
	Scope      string `json:"scope,omitempty"`
	PrivateKey string `json:"private_key,omitempty"`
	VerifyKey  string `json:"ed25519,omitempty"`
}

func AuthorizeEd25519

func AuthorizeEd25519(ctx context.Context, clientID, clientSecret string, code string, verifier string, privateKey ed25519.PrivateKey) (*OauthKeystore, error)

type OauthKeystoreAuth

type OauthKeystoreAuth struct {
	*OauthKeystore
	// contains filtered or unexported fields
}

func AuthFromOauthKeystore

func AuthFromOauthKeystore(store *OauthKeystore) (*OauthKeystoreAuth, error)

func (*OauthKeystoreAuth) EncryptPin

func (o *OauthKeystoreAuth) EncryptPin(pin string) string

func (*OauthKeystoreAuth) SignToken

func (o *OauthKeystoreAuth) SignToken(signature, requestID string, exp time.Duration) string

func (*OauthKeystoreAuth) Verify

func (o *OauthKeystoreAuth) Verify(resp *resty.Response) error

type Participant

type Participant struct {
	Action    string    `json:"action,omitempty"`
	Type      string    `json:"type,omitempty"`
	UserID    string    `json:"user_id,omitempty"`
	Role      string    `json:"role,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
}

Participant conversation participant

type Payment

type Payment struct {
	Recipient *User  `json:"recipient,omitempty"`
	Asset     *Asset `json:"asset,omitempty"`
	Amount    string `json:"amount,omitempty"`
	Status    string `json:"status,omitempty"`
}

type RawTransaction

type RawTransaction struct {
	Type            string    `json:"type"`
	SnapshotID      string    `json:"snapshot"`
	OpponentKey     string    `json:"opponent_key"`
	AssetID         string    `json:"asset_id"`
	Amount          string    `json:"amount"`
	TraceID         string    `json:"trace_id"`
	Memo            string    `json:"memo"`
	State           string    `json:"state"`
	CreatedAt       time.Time `json:"created_at"`
	TransactionHash string    `json:"transaction_hash"`
	SnapshotHash    string    `json:"snapshot_hash"`
	SnapshotAt      time.Time `json:"snapshot_at"`
}

RawTransaction raw transaction

type RecallMessage

type RecallMessage struct {
	MessageID string `json:"message_id"`
}

type Signer

type Signer interface {
	SignToken(signature, requestID string, exp time.Duration) string
	EncryptPin(pin string) string
}

type Snapshot

type Snapshot struct {
	SnapshotID      string          `json:"snapshot_id"`
	CreatedAt       time.Time       `json:"created_at,omitempty"`
	TraceID         string          `json:"trace_id,omitempty"`
	UserID          string          `json:"user_id,omitempty"`
	AssetID         string          `json:"asset_id,omitempty"`
	ChainID         string          `json:"chain_id,omitempty"`
	OpponentID      string          `json:"opponent_id,omitempty"`
	Source          string          `json:"source,omitempty"`
	Amount          decimal.Decimal `json:"amount,omitempty"`
	OpeningBalance  decimal.Decimal `json:"opening_balance,omitempty"`
	ClosingBalance  decimal.Decimal `json:"closing_balance,omitempty"`
	Memo            string          `json:"memo,omitempty"`
	Type            string          `json:"type,omitempty"`
	Sender          string          `json:"sender,omitempty"`
	Receiver        string          `json:"receiver,omitempty"`
	TransactionHash string          `json:"transaction_hash,omitempty"`

	Asset *Asset `json:"asset,omitempty"`
}

func ReadSnapshot

func ReadSnapshot(ctx context.Context, accessToken, snapshotID string) (*Snapshot, error)

ReadSnapshot by accessToken, scope SNAPSHOTS:READ required

func ReadSnapshots

func ReadSnapshots(ctx context.Context, accessToken string, assetID string, offset time.Time, order string, limit int) ([]*Snapshot, error)

ReadSnapshots by accessToken, scope SNAPSHOTS:READ required

func (*Snapshot) UnmarshalJSON

func (s *Snapshot) UnmarshalJSON(b []byte) error

type StickerMessage

type StickerMessage struct {
	Name    string `json:"name,omitempty"`
	AlbumID string `json:"album_id,omitempty"`
}

type SystemConversationPayload

type SystemConversationPayload struct {
	Action        string `json:"action"`
	ParticipantID string `json:"participant_id"`
	UserID        string `json:"user_id,omitempty"`
	Role          string `json:"role,omitempty"`
}

type TransactionOutput

type TransactionOutput struct {
	Mask string   `json:"mask"`
	Keys []string `json:"keys"`
}

TransactionOutput transaction output

type TransferInput

type TransferInput struct {
	AssetID    string          `json:"asset_id,omitempty"`
	OpponentID string          `json:"opponent_id,omitempty"`
	Amount     decimal.Decimal `json:"amount,omitempty"`
	TraceID    string          `json:"trace_id,omitempty"`
	Memo       string          `json:"memo,omitempty"`

	// OpponentKey used for raw transaction
	OpponentKey string `json:"opponent_key,omitempty"`
}

TransferInput input for transfer/verify payment request

type TransferView

type TransferView struct {
	Type          string    `json:"type"`
	SnapshotID    string    `json:"snapshot_id"`
	CounterUserID string    `json:"counter_user_id"`
	AssetID       string    `json:"asset_id"`
	Amount        string    `json:"amount"`
	TraceID       string    `json:"trace_id"`
	Memo          string    `json:"memo"`
	CreatedAt     time.Time `json:"created_at"`
}

type Turn

type Turn struct {
	URL        string `json:"url"`
	Username   string `json:"username"`
	Credential string `json:"credential"`
}

type User

type User struct {
	UserID         string    `json:"user_id,omitempty"`
	IdentityNumber string    `json:"identity_number,omitempty"`
	Phone          string    `json:"phone,omitempty"`
	FullName       string    `json:"full_name,omitempty"`
	Biography      string    `json:"biography,omitempty"`
	AvatarURL      string    `json:"avatar_url,omitempty"`
	Relationship   string    `json:"relationship,omitempty"`
	MuteUntil      time.Time `json:"mute_until,omitempty"`
	CreatedAt      time.Time `json:"created_at,omitempty"`
	IsVerified     bool      `json:"is_verified,omitempty"`
	SessionID      string    `json:"session_id,omitempty"`
	PinToken       string    `json:"pin_token,omitempty"`
	CodeID         string    `json:"code_id,omitempty"`
	CodeURL        string    `json:"code_url,omitempty"`
	HasPin         bool      `json:"has_pin,omitempty"`

	App *App `json:"app,omitempty"`
}

func UserMe

func UserMe(ctx context.Context, accessToken string) (*User, error)

type Verifier

type Verifier interface {
	Verify(resp *resty.Response) error
}

func NopVerifier

func NopVerifier() Verifier

type VideoMessage

type VideoMessage struct {
	AttachmentID string `json:"attachment_id,omitempty"`
	MimeType     string `json:"mime_type,omitempty"`
	WaveForm     string `json:"wave_form,omitempty"`
	Width        int    `json:"width,omitempty"`
	Height       int    `json:"height,omitempty"`
	Size         int    `json:"size,omitempty"`
	Duration     int    `json:"duration,omitempty"`
	Thumbnail    []byte `json:"thumbnail,omitempty"`
}

type WithdrawInput

type WithdrawInput struct {
	AddressID string          `json:"address_id,omitempty"`
	Amount    decimal.Decimal `json:"amount,omitempty"`
	TraceID   string          `json:"trace_id,omitempty"`
	Memo      string          `json:"memo,omitempty"`
}

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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