Documentation
¶
Overview ¶
Package types defines the shared API types for the neoaccounts service.
This package is intentionally free of HTTP/DB dependencies so it can be used by: - the account pool server implementation (`infrastructure/accountpool/marble`) - service-to-service clients (`infrastructure/accountpool/client`) - other services consuming the API (e.g. `neocompute`)
Index ¶
- Constants
- type AccountInfo
- type BatchSignInput
- type BatchSignResponse
- type ContractParam
- type DeployContractInput
- type DeployContractResponse
- type DeployMasterInput
- type DeployMasterResponse
- type FundAccountInput
- type FundAccountResponse
- type InvokeContractInput
- type InvokeContractResponse
- type InvokeMasterInput
- type ListAccountsResponse
- type MasterKeyAttestation
- type PoolInfoResponse
- type ReleaseAccountsInput
- type ReleaseAccountsResponse
- type RequestAccountsInput
- type RequestAccountsResponse
- type SignRequest
- type SignTransactionInput
- type SignTransactionResponse
- type SimulateContractInput
- type SimulateContractResponse
- type TokenBalance
- type TokenStats
- type TransferInput
- type TransferResponse
- type TransferWithDataInput
- type TransferWithDataResponse
- type UpdateBalanceInput
- type UpdateBalanceResponse
- type UpdateContractInput
- type UpdateContractResponse
Constants ¶
const ( TokenTypeNEO = "NEO" TokenTypeGAS = "GAS" )
Well-known token types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountInfo ¶
type AccountInfo struct {
ID string `json:"id"`
Address string `json:"address"`
CreatedAt time.Time `json:"created_at"`
LastUsedAt time.Time `json:"last_used_at"`
TxCount int64 `json:"tx_count"`
IsRetiring bool `json:"is_retiring"`
LockedBy string `json:"locked_by,omitempty"`
LockedAt time.Time `json:"locked_at,omitempty"`
Balances map[string]TokenBalance `json:"balances"` // key: token_type (e.g., "NEO", "GAS")
}
AccountInfo represents public account information returned to clients. Private keys are never exposed. Balances are tracked per-token.
type BatchSignInput ¶
type BatchSignInput struct {
ServiceID string `json:"service_id"`
Requests []SignRequest `json:"requests"`
}
BatchSignInput signs multiple transaction hashes.
type BatchSignResponse ¶
type BatchSignResponse struct {
Signatures []SignTransactionResponse `json:"signatures"`
Errors []string `json:"errors,omitempty"`
}
BatchSignResponse returns multiple signatures.
type ContractParam ¶
type ContractParam struct {
Type string `json:"type"` // Hash160, Integer, String, ByteArray, Array, etc.
Value any `json:"value"` // Parameter value
}
ContractParam represents a parameter for contract invocation.
type DeployContractInput ¶
type DeployContractInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"`
NEFBase64 string `json:"nef_base64"` // Base64-encoded NEF file
ManifestJSON string `json:"manifest_json"` // JSON manifest string
Data any `json:"data,omitempty"` // Optional deployment data
}
DeployContractInput deploys a new contract using a pool account. All signing happens inside TEE - private keys never leave the enclave.
type DeployContractResponse ¶
type DeployContractResponse struct {
TxHash string `json:"tx_hash"`
ContractAddress string `json:"contract_address"`
GasConsumed string `json:"gas_consumed"`
AccountID string `json:"account_id"`
}
DeployContractResponse returns the deployment result.
type DeployMasterInput ¶
type DeployMasterInput struct {
NEFBase64 string `json:"nef_base64"` // Base64-encoded NEF file
ManifestJSON string `json:"manifest_json"` // JSON manifest string
Data any `json:"data,omitempty"` // Optional deployment data
}
DeployMasterInput deploys a new contract using the master wallet (TEE_PRIVATE_KEY). This is used for deploying contracts where the master account needs to be the Admin.
type DeployMasterResponse ¶
type DeployMasterResponse struct {
TxHash string `json:"tx_hash"`
ContractAddress string `json:"contract_address"`
GasConsumed string `json:"gas_consumed"`
AccountID string `json:"account_id"` // Always "master"
}
DeployMasterResponse returns the deployment result using master wallet.
type FundAccountInput ¶
type FundAccountInput struct {
ToAddress string `json:"to_address"` // Pool account address to fund
Amount int64 `json:"amount"` // Amount in smallest units (8 decimals for GAS)
TokenAddress string `json:"token_address,omitempty"` // NEP-17 contract address (defaults to GAS)
}
FundAccountInput funds a pool account from the master wallet (TEE_PRIVATE_KEY). This is used to provide GAS to pool accounts for transaction fees.
type FundAccountResponse ¶
type FundAccountResponse struct {
TxHash string `json:"tx_hash"`
FromAddress string `json:"from_address"` // Master wallet address
ToAddress string `json:"to_address"`
Amount int64 `json:"amount"`
}
FundAccountResponse returns the funding result.
type InvokeContractInput ¶
type InvokeContractInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"`
ContractAddress string `json:"contract_address"` // Contract to invoke
Method string `json:"method"` // Method name
Params []ContractParam `json:"params"` // Method parameters
Scope string `json:"scope,omitempty"` // Transaction scope: "CalledByEntry" (default), "Global", "CustomContracts", "CustomGroups"
}
InvokeContractInput invokes a contract method using a pool account. All signing happens inside TEE - private keys never leave the enclave.
type InvokeContractResponse ¶
type InvokeContractResponse struct {
TxHash string `json:"tx_hash"`
State string `json:"state"` // HALT or FAULT
GasConsumed string `json:"gas_consumed"`
Exception string `json:"exception,omitempty"`
AccountID string `json:"account_id"`
}
InvokeContractResponse returns the invocation result.
type InvokeMasterInput ¶
type InvokeMasterInput struct {
ContractAddress string `json:"contract_address"` // Contract to invoke
Method string `json:"method"` // Method name
Params []ContractParam `json:"params"` // Method parameters
Scope string `json:"scope,omitempty"` // Transaction scope: "CalledByEntry" (default), "Global"
}
InvokeMasterInput invokes a contract method using the master wallet (TEE_PRIVATE_KEY). This is used for TEE operations like PriceFeed and RandomnessLog that require the caller to be a registered TEE signer in AppRegistry.
type ListAccountsResponse ¶
type ListAccountsResponse struct {
Accounts []AccountInfo `json:"accounts"`
}
ListAccountsResponse returns filtered accounts.
type MasterKeyAttestation ¶
type MasterKeyAttestation struct {
Hash string `json:"hash"`
PubKey string `json:"pubkey,omitempty"`
Quote string `json:"quote,omitempty"`
MRENCLAVE string `json:"mrenclave,omitempty"`
MRSIGNER string `json:"mrsigner,omitempty"`
ProdID uint16 `json:"prod_id,omitempty"`
ISVSVN uint16 `json:"isvsvn,omitempty"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
Simulated bool `json:"simulated"`
}
MasterKeyAttestation is a non-sensitive bundle proving the master key hash is bound to enclave report data. The quote is intended for off-chain verification; the account pool does not parse or validate it here.
type PoolInfoResponse ¶
type PoolInfoResponse struct {
TotalAccounts int `json:"total_accounts"`
ActiveAccounts int `json:"active_accounts"`
LockedAccounts int `json:"locked_accounts"`
RetiringAccounts int `json:"retiring_accounts"`
TokenStats map[string]TokenStats `json:"token_stats"` // key: token_type
}
PoolInfoResponse returns pool statistics with per-token breakdowns.
type ReleaseAccountsInput ¶
type ReleaseAccountsInput struct {
ServiceID string `json:"service_id"`
LockID string `json:"lock_id,omitempty"` // Release by lock ID
AccountIDs []string `json:"account_ids,omitempty"` // Or release specific accounts
}
ReleaseAccountsInput releases previously requested accounts.
type ReleaseAccountsResponse ¶
type ReleaseAccountsResponse struct {
ReleasedCount int `json:"released_count"`
}
ReleaseAccountsResponse confirms release.
type RequestAccountsInput ¶
type RequestAccountsInput struct {
ServiceID string `json:"service_id"` // ID of requesting service (e.g., "neocompute")
Count int `json:"count"` // Number of accounts needed
Purpose string `json:"purpose"` // Description of purpose (for audit)
}
RequestAccountsInput requests accounts from the pool.
type RequestAccountsResponse ¶
type RequestAccountsResponse struct {
Accounts []AccountInfo `json:"accounts"`
LockID string `json:"lock_id"` // ID to reference this lock for release/signing
}
RequestAccountsResponse returns the requested accounts.
type SignRequest ¶
type SignRequest struct {
AccountID string `json:"account_id"`
TxHash []byte `json:"tx_hash"` // base64 in JSON
}
SignRequest represents a single signing request within a batch.
type SignTransactionInput ¶
type SignTransactionInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"`
TxHash []byte `json:"tx_hash"` // Transaction hash to sign (base64 in JSON)
}
SignTransactionInput signs a transaction with an account's private key.
type SignTransactionResponse ¶
type SignTransactionResponse struct {
AccountID string `json:"account_id"`
Signature []byte `json:"signature"` // base64 in JSON
PublicKey []byte `json:"public_key"` // base64 in JSON (compressed)
}
SignTransactionResponse returns the signature.
type SimulateContractInput ¶
type SimulateContractInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"` // Account to use as signer
ContractAddress string `json:"contract_address"` // Contract to invoke
Method string `json:"method"` // Method name
Params []ContractParam `json:"params"` // Method parameters
}
SimulateContractInput simulates a contract invocation without signing.
type SimulateContractResponse ¶
type SimulateContractResponse struct {
State string `json:"state"` // HALT or FAULT
GasConsumed string `json:"gas_consumed"`
Exception string `json:"exception,omitempty"`
Stack []any `json:"stack,omitempty"` // Return values
}
SimulateContractResponse returns the simulation result.
type TokenBalance ¶
type TokenBalance struct {
TokenType string `json:"token_type"`
ScriptHash string `json:"script_hash"`
Amount int64 `json:"amount"`
Decimals int `json:"decimals"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
TokenBalance represents a balance for a specific token type.
type TokenStats ¶
type TokenStats struct {
TokenType string `json:"token_type"`
ScriptHash string `json:"script_hash"`
TotalBalance int64 `json:"total_balance"`
LockedBalance int64 `json:"locked_balance"`
AvailableBalance int64 `json:"available_balance"`
}
TokenStats represents aggregated statistics for a token type.
type TransferInput ¶
type TransferInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"`
ToAddress string `json:"to_address"`
Amount int64 `json:"amount"`
TokenAddress string `json:"token_address,omitempty"` // NEP-17 contract address (defaults to GAS)
}
TransferInput transfers tokens from a pool account.
type TransferResponse ¶
type TransferResponse struct {
TxHash string `json:"tx_hash"`
AccountID string `json:"account_id"`
ToAddress string `json:"to_address"`
Amount int64 `json:"amount"`
}
TransferResponse returns the transfer result.
type TransferWithDataInput ¶
type TransferWithDataInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"`
ToAddress string `json:"to_address"`
Amount int64 `json:"amount"`
Data string `json:"data,omitempty"` // Data passed to OnNEP17Payment callback
}
TransferWithDataInput transfers GAS from a pool account with optional data. The data parameter is passed to the OnNEP17Payment callback of the receiving contract. This is used for payments to contracts like PaymentHub that need to identify the payment source.
type TransferWithDataResponse ¶
type TransferWithDataResponse struct {
TxHash string `json:"tx_hash"`
AccountID string `json:"account_id"`
ToAddress string `json:"to_address"`
Amount int64 `json:"amount"`
Data string `json:"data,omitempty"`
}
TransferWithDataResponse returns the transfer result.
type UpdateBalanceInput ¶
type UpdateBalanceInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"`
Token string `json:"token"` // Token type: "NEO", "GAS", or custom NEP-17
Delta int64 `json:"delta"` // Positive to add, negative to subtract
Absolute *int64 `json:"absolute,omitempty"` // Or set absolute value
}
UpdateBalanceInput updates an account's token balance.
type UpdateBalanceResponse ¶
type UpdateBalanceResponse struct {
AccountID string `json:"account_id"`
Token string `json:"token"`
OldBalance int64 `json:"old_balance"`
NewBalance int64 `json:"new_balance"`
TxCount int64 `json:"tx_count"` // Updated transaction count
}
UpdateBalanceResponse confirms balance update.
type UpdateContractInput ¶
type UpdateContractInput struct {
ServiceID string `json:"service_id"`
AccountID string `json:"account_id"`
ContractAddress string `json:"contract_address"` // Existing contract address to update
NEFBase64 string `json:"nef_base64"` // Base64-encoded NEF file
ManifestJSON string `json:"manifest_json"` // JSON manifest string
Data any `json:"data,omitempty"` // Optional update data
}
UpdateContractInput updates an existing contract using a pool account.