Documentation
¶
Overview ¶
https://djr6hkgq2tjcs.cloudfront.net/docs/construction_api_introduction.html
Index ¶
- Constants
- Variables
- func DecodeSignedTransaction(raw string) (*transaction.SignedTransaction, error)
- func GetChainID(ctx context.Context, oc oasis.Client) (string, *types.Error)
- func NewAccountAPIService(oasisClient oasis.Client) server.AccountAPIServicer
- func NewBlockAPIService(oasisClient oasis.Client) server.BlockAPIServicer
- func NewConstructionAPIService(oasisClient oasis.Client) server.ConstructionAPIServicer
- func NewDetailedError(proto *types.Error, cause error) *types.Error
- func NewMempoolAPIService(oasisClient oasis.Client) server.MempoolAPIServicer
- func NewNetworkAPIService(oasisClient oasis.Client) server.NetworkAPIServicer
- func StringFromAddress(address staking.Address) string
- func ValidateNetworkIdentifier(ctx context.Context, oc oasis.Client, ni *types.NetworkIdentifier) *types.Error
- func ValidateNetworkIdentifierWithChainID(chainID string, ni *types.NetworkIdentifier) *types.Error
- type TransactionKind
- type UnsignedTransaction
Constants ¶
const ( // CauseKey is a key in an error's details map, mapping to an object with // keys ModuleKey, CodeKey (see // https://pkg.go.dev/github.com/oasisprotocol/oasis-core/go@v0.20.9/common/errors?tab=doc#Code), // and MsgKey with some information about an error // from the Oasis network. CauseKey = "cause" ModuleKey = "module" CodeKey = "code" MsgKey = "msg" )
const ( // OpTransfer is the Transfer operation. OpTransfer = "Transfer" // OpBurn is the Burn operation. OpBurn = "Burn" // OpReclaimEscrow is the Burn operation. OpReclaimEscrow = "ReclaimEscrow" )
const ( // OpStatusOK is the operation status for successful operations. OpStatusOK = "OK" // OpStatusFailed is the operation status for failed operations. OpStatusFailed = "Failed" )
const ActiveBalanceKey = "active_balance"
ActiveBalanceKey is the name of the key in the Metadata map inside the response of an account balance request for an escrow account. The value in the Metadata map specifies how many token base units are in the active escrow pool.
ActiveSharesKey is the name of the key in the Metadata map inside the response of an account balance request for an escrow account. The value in the Metadata map specifies how many shares are in the active escrow pool.
const DebondingBalanceKey = "debonding_balance"
DebondingBalanceKey is the name of the key in the Metadata map inside the response of an account balance request for an escrow account. The value in the Metadata map specifies how many token base units are in the debonding escrow pool.
const DebondingDelegationsKey = "debonding_delegations"
DebondingDelegationsKey is the name of the key in the Metadata map inside the response of an account balance request for an escrow account. The value in the Metadata map is the response from a GetDebondingDelegations call.
DebondingSharesKey is the name of the key in the Metadata map inside the response of an account balance request for an escrow account. The value in the Metadata map specifies how many shares are in the debonding escrow pool.
const DefaultGas transaction.Gas = 10000
DefaultGas is the default gas limit used in creating a transaction.
const DelegationsKey = "delegations"
DelegationsKey is the name of the key in the Metadata map inside the response of an account balance request for an escrow account. The value in the Metadata map is the response from a GetDelegations call.
const EpochKey = "epoch"
EpochKey is the name of the key in the Metadata map inside the response of a block request. The value in the map is the epoch number of the returned block.
const FeeGasKey = "fee_gas"
FeeGasKey is the name of the key in the Metadata map inside a fee operation that specifies the gas value in the transaction fee. This is optional, and we use DefaultGas if it's absent.
const NonceKey = "nonce"
NonceKey is the name of the key in the Metadata map inside a ConstructionMetadataResponse that specifies the next valid nonce.
const OasisBlockchainName = "Oasis"
OasisBlockchainName is the name of the Oasis blockchain.
const OfflineModeChainIDEnvVar = "OASIS_ROSETTA_GATEWAY_OFFLINE_MODE_CHAIN_ID"
OfflineModeChainIDEnvVar is the name of the environment variable that specifies the chain ID when running in offline mode. This is required to be able to properly sign transactions, since we can't get the chain ID from the node.
const OptionsIDKey = "id"
OptionsIDKey is the name of the key in the Options map inside a ConstructionMetadataRequest that specifies the account ID.
ReclaimEscrowSharesKey is the name of the key in the Metadata map inside a reclaim escrow operation that specifies the number of shares to reclaim.
const SubAccountEscrow = "escrow"
SubAccountEscrow specifies the name of the escrow subaccount.
Variables ¶
var ( ErrUnableToGetChainID = &types.Error{ Code: 1, Message: "unable to get chain ID", Retriable: true, } ErrInvalidBlockchain = &types.Error{ Code: 2, Message: "invalid blockchain specified in network identifier", Retriable: false, } ErrInvalidSubnetwork = &types.Error{ Code: 3, Message: "invalid sub-network identifier", Retriable: false, } ErrInvalidNetwork = &types.Error{ Code: 4, Message: "invalid network specified in network identifier", Retriable: false, } ErrMissingNID = &types.Error{ Code: 5, Message: "network identifier is missing", Retriable: false, } ErrUnableToGetLatestBlk = &types.Error{ Code: 6, Message: "unable to get latest block", Retriable: true, } ErrUnableToGetGenesisBlk = &types.Error{ Code: 7, Message: "unable to get genesis block", Retriable: true, } ErrUnableToGetAccount = &types.Error{ Code: 8, Message: "unable to get account", Retriable: true, } ErrMustQueryByIndex = &types.Error{ Code: 9, Message: "blocks must be queried by index and not hash", Retriable: false, } ErrInvalidAccountAddress = &types.Error{ Code: 10, Message: "invalid account address", Retriable: false, } ErrMustSpecifySubAccount = &types.Error{ Code: 11, Message: "a valid subaccount must be specified (absent or {\"address\": \"escrow\"})", Retriable: false, } ErrUnableToGetBlk = &types.Error{ Code: 12, Message: "unable to get block", Retriable: true, } ErrNotImplemented = &types.Error{ Code: 13, Message: "operation not implemented", Retriable: false, } ErrUnableToGetTxns = &types.Error{ Code: 14, Message: "unable to get transactions", Retriable: true, } ErrUnableToSubmitTx = &types.Error{ Code: 15, Message: "unable to submit transaction", Retriable: false, } ErrUnableToGetNextNonce = &types.Error{ Code: 16, Message: "unable to get next nonce", Retriable: true, } ErrMalformedValue = &types.Error{ Code: 17, Message: "malformed value", Retriable: false, } ErrUnableToGetNodeStatus = &types.Error{ Code: 18, Message: "unable to get node status", Retriable: true, } ErrTransactionNotFound = &types.Error{ Code: 19, Message: "transaction not found", Retriable: true, } ErrNotAvailableInOfflineMode = &types.Error{ Code: 20, Message: "not available in offline mode", Retriable: false, } ErrorList = []*types.Error{ ErrUnableToGetChainID, ErrInvalidBlockchain, ErrInvalidSubnetwork, ErrInvalidNetwork, ErrMissingNID, ErrUnableToGetLatestBlk, ErrUnableToGetGenesisBlk, ErrUnableToGetAccount, ErrMustQueryByIndex, ErrInvalidAccountAddress, ErrMustSpecifySubAccount, ErrUnableToGetBlk, ErrNotImplemented, ErrUnableToGetTxns, ErrUnableToSubmitTx, ErrUnableToGetNextNonce, ErrMalformedValue, ErrUnableToGetNodeStatus, ErrTransactionNotFound, ErrNotAvailableInOfflineMode, } )
var OasisCurrency = &types.Currency{
Symbol: "ROSE",
Decimals: 9,
}
OasisCurrency is the currency used on the Oasis blockchain.
var SupportedOperationTypes = []string{ OpTransfer, OpBurn, OpReclaimEscrow, }
SupportedOperationTypes is a list of the supported operations.
Functions ¶
func DecodeSignedTransaction ¶
func DecodeSignedTransaction(raw string) (*transaction.SignedTransaction, error)
DecodeSignedTransaction decodes a signed transaction from a Base64-encoded CBOR blob.
func GetChainID ¶
GetChainID returns the chain ID.
func NewAccountAPIService ¶
func NewAccountAPIService(oasisClient oasis.Client) server.AccountAPIServicer
NewAccountAPIService creates a new instance of an AccountAPIService.
func NewBlockAPIService ¶
func NewBlockAPIService(oasisClient oasis.Client) server.BlockAPIServicer
NewBlockAPIService creates a new instance of an AccountAPIService.
func NewConstructionAPIService ¶
func NewConstructionAPIService(oasisClient oasis.Client) server.ConstructionAPIServicer
NewConstructionAPIService creates a new instance of an ConstructionAPIService.
func NewDetailedError ¶
NewDetailedError returns a new Rosetta error Code, Message, and Retriable set from proto and Details[CauseKey] set from cause.
func NewMempoolAPIService ¶
func NewMempoolAPIService(oasisClient oasis.Client) server.MempoolAPIServicer
NewMempoolAPIService creates a new instance of a NetworkAPIService.
func NewNetworkAPIService ¶
func NewNetworkAPIService(oasisClient oasis.Client) server.NetworkAPIServicer
NewNetworkAPIService creates a new instance of a NetworkAPIService.
func StringFromAddress ¶
StringFromAddress converts a staking API address to string using MarshalText. If marshalling fails, this panics.
func ValidateNetworkIdentifier ¶
func ValidateNetworkIdentifier(ctx context.Context, oc oasis.Client, ni *types.NetworkIdentifier) *types.Error
ValidateNetworkIdentifier validates the network identifier and fetches the chain ID either from the given Client (if not nil), or from the env variable (if oc is nil).
func ValidateNetworkIdentifierWithChainID ¶
func ValidateNetworkIdentifierWithChainID(chainID string, ni *types.NetworkIdentifier) *types.Error
ValidateNetworkIdentifierWithChainID validates the network identifier and uses the given chain ID.
Types ¶
type TransactionKind ¶
type TransactionKind int
TransactionKind is the kind of Oasis transaction.
const ( KindUnknown TransactionKind = 0 KindStakingTransfer TransactionKind = 1 KindStakingBurn TransactionKind = 2 KindStakingAddEscrow TransactionKind = 3 KindStakingReclaimEscrow TransactionKind = 4 )
type UnsignedTransaction ¶
type UnsignedTransaction struct { Tx cbor.RawMessage `json:"tx"` Signer string `json:"signer"` }
UnsignedTransaction is a transaction with the account that would sign it.
func DecodeUnsignedTransaction ¶
func DecodeUnsignedTransaction(raw string) (*UnsignedTransaction, error)
DecodeUnsignedTransaction decodes an unsigned transaction from a Base64-encoded CBOR blob.