Documentation ¶
Index ¶
- Variables
- func CatchPanicAndMapToBasicError(errOfResult *error)
- func MapAnyToBasicError(e any) error
- func MapListConcurrent(list []interface{}, limit int, maper func(interface{}) (interface{}, error)) ([]interface{}, error)
- func MapListConcurrentStringToString(strList []string, maper func(string) (string, error)) ([]string, error)
- func MaxBigInt(x, y *big.Int) *big.Int
- type Account
- type AddressUtil
- type Balance
- type Chain
- type OptionalBool
- type OptionalString
- type SDKEnumInt
- type SDKEnumString
- type Token
- type TokenInfo
- type Transaction
- type TransactionDetail
- type TransactionStatus
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnsupportedFunction = errors.New("This chain does not support this feature.")
)
Functions ¶
func CatchPanicAndMapToBasicError ¶
func CatchPanicAndMapToBasicError(errOfResult *error)
[zh] 该方法会捕捉 panic 抛出的值,并转成一个 error 对象通过参数指针返回 * 注意: 如果想要返回它抓住的 error, 必须使用命名返回值!! * [en] This method will catch the value thrown by panic, and turn it into an error object and return it through the parameter pointer * Note: If you want to return the error it caught, you must use a named return value! ! * ``` * func actionWillThrowError(parameters...) (namedErr error, other...) { * defer CatchPanicAndMapToBasicError(&namedErr) * // action code ... * return namedErr, other... * } * ```
func MapAnyToBasicError ¶
func MapListConcurrent ¶
func MapListConcurrent(list []interface{}, limit int, maper func(interface{}) (interface{}, error)) ([]interface{}, error)
This method will traverse the array concurrently and map each object in the array. @param list: [TYPE1], a list that all item is TYPE1 @param limit: maximum number of tasks to execute, 0 means no limit @param maper: func(TYPE1) (TYPE2, error), a function that input TYPE1, return TYPE2
you can throw an error to finish task.
@return : [TYPE2], a list that all item is TYPE2 @example : ```
nums := []interface{}{1, 2, 3, 4, 5, 6} res, _ := MapListConcurrent(nums, func(i interface{}) (interface{}, error) { return strconv.Itoa(i.(int) * 100), nil }) println(res) // ["100" "200" "300" "400" "500" "600"]
```
Types ¶
type Account ¶
type Account interface { // @return privateKey data PrivateKey() ([]byte, error) // @return privateKey string that will start with 0x. PrivateKeyHex() (string, error) // @return publicKey data PublicKey() []byte // @return publicKey string that will start with 0x. PublicKeyHex() string // @return address string Address() string Sign(message []byte, password string) ([]byte, error) SignHex(messageHex string, password string) (*OptionalString, error) }
type AddressUtil ¶
type Balance ¶
func EmptyBalance ¶
func EmptyBalance() *Balance
type Chain ¶
type Chain interface { MainToken() Token BalanceOfAddress(address string) (*Balance, error) BalanceOfPublicKey(publicKey string) (*Balance, error) BalanceOfAccount(account Account) (*Balance, error) // Send the raw transaction on-chain // @return the hex hash string SendRawTransaction(signedTx string) (string, error) // Fetch transaction details through transaction hash FetchTransactionDetail(hash string) (*TransactionDetail, error) // Fetch transaction status through transaction hash FetchTransactionStatus(hash string) TransactionStatus // Batch fetch the transaction status, the hash list and the return value, // which can only be passed as strings separated by "," // @param hashListString The hash of the transactions to be queried in batches, a string concatenated with ",": "hash1,hash2,hash3" // @return Batch transaction status, its order is consistent with hashListString: "status1,status2,status3" BatchFetchTransactionStatus(hashListString string) string }
type OptionalBool ¶ added in v0.2.3
type OptionalBool struct {
Value bool
}
Optional bool for easy of writing iOS code
type OptionalString ¶ added in v0.2.3
type OptionalString struct {
Value string
}
Optional string for easy of writing iOS code
type SDKEnumInt ¶
type SDKEnumInt = int
type SDKEnumString ¶
type SDKEnumString = string
type Transaction ¶
type Transaction struct { }
type TransactionDetail ¶
type TransactionDetail struct { // hash string on chain HashString string // transaction amount Amount string EstimateFees string // sender's address FromAddress string // receiver's address ToAddress string Status TransactionStatus // transaction completion timestamp (s), 0 if Status is in Pending FinishTimestamp int64 // failure message FailureMessage string }
Transaction details that can be fetched from the chain
type TransactionStatus ¶
type TransactionStatus = SDKEnumInt
const ( TransactionStatusNone TransactionStatus = 0 TransactionStatusPending TransactionStatus = 1 TransactionStatusSuccess TransactionStatus = 2 TransactionStatusFailure TransactionStatus = 3 )