Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertName(name string) string
- func DecodeEvent(event *parser.Event, value any) (err error)
- func DecodeFields(target, fv reflect.Value) error
- func EncodePubkey(pubkey []byte, format uint16) string
- func GetRegisteredEventIntance(eventName string) (any, bool)
- func GetRegisteredEventTypes() []string
- func ParsingPublickey(address string) ([]byte, error)
- func QueryStorage[T any](c *Client, block uint32, prefix, method string, args ...[]byte) (T, error)
- func QueryStorages[T any](c *Client, block uint32, prefix, method string) ([]T, error)
- func RegisterEventType(eventName string, eventType reflect.Type)
- func SignedSR25519WithMnemonic(mnemonic string, msg []byte) ([]byte, error)
- type AccBytes
- type AccessInfo
- type ActualWeightType
- type BloomFilter
- type BucketInfo
- type Client
- func (c *Client) Authorize(account []byte, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) CancelOssAuth(account []byte, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) CreateTerritoryOrder(account []byte, name string, orderType uint8, gibCount, days, expired uint32, ...) (string, error)
- func (c *Client) DeleteUserFile(fid FileHash, owner types.AccountID, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) DestroyOss(caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) ExecTerritoryOrder(orderId []byte, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) ExpandingTerritory(name string, gibCount uint32, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) GetCaller(caller *signature.KeyringPair) (signature.KeyringPair, error)
- func (c *Client) GetCallerNonce(caller *signature.KeyringPair) (uint64, error)
- func (c *Client) GetOssProxyAuthSign(mnemonic, oss string) ([]byte, []byte, error)
- func (c *Client) MintTerritory(name string, gibCount, days uint32, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) NewSubstrateAPI(rpcAddr string) error
- func (c *Client) ParseBlockData(hash types.Hash) (ParsedBlock, error)
- func (c *Client) ParseBlockDataWithBlockNumber(block uint32) (ParsedBlock, error)
- func (c *Client) ParseSystemEventError(t types.ModuleError) error
- func (cli *Client) ParseTxResult(caller signature.KeyringPair, events []*parser.Event, eventName string) (*parser.Event, error)
- func (c *Client) PutCaller(caller *signature.KeyringPair)
- func (c *Client) QuerPurchasedSpace(block uint32) (uint64, error)
- func (c *Client) QueryAccountInfo(account []byte, block uint32) (types.AccountInfo, error)
- func (c *Client) QueryAllBondeds(block uint32) ([]types.AccountID, error)
- func (c *Client) QueryAllErasStakersPaged(accountId []byte, era, block uint32) ([]StakingExposurePaged, error)
- func (c *Client) QueryAllMiners(block uint32) ([]types.AccountID, error)
- func (c *Client) QueryAllNominators(block uint32) ([]StakingNominations, error)
- func (c *Client) QueryAllOss(block uint32) ([]OssInfo, error)
- func (c *Client) QueryAuthList(account []byte, block uint32) ([]types.AccountID, error)
- func (c *Client) QueryBlockNumber(blockhash string) (uint32, error)
- func (c *Client) QueryCounterForMinerItems(block uint32) (uint32, error)
- func (c *Client) QueryCounterForValidators(block uint32) (uint32, error)
- func (c *Client) QueryCurrencyReward(block uint32) (types.U128, error)
- func (c *Client) QueryCurrentEra(block uint32) (uint32, error)
- func (c *Client) QueryDealMap(fid string, block uint32) (StorageOrder, error)
- func (c *Client) QueryEraReward(block uint32) (types.U128, error)
- func (c *Client) QueryEraValidatorReward(era, block uint32) (types.U128, error)
- func (c *Client) QueryErasRewardPoints(era, block uint32) (StakingEraRewardPoints, error)
- func (c *Client) QueryErasStakers(accountId []byte, era, block uint32) (StakingExposure, error)
- func (c *Client) QueryErasStakersOveriew(accountId []byte, era, block uint32) (PagedExposureMetadata, error)
- func (c *Client) QueryErasTotalStaking(era, block uint32) (types.U128, error)
- func (c *Client) QueryFileMetadata(fid string, block uint32) (FileMetadata, error)
- func (c *Client) QueryLedger(accountId []byte, block uint32) (StakingLedger, error)
- func (c *Client) QueryMinerItems(miner []byte, block uint32) (MinerInfo, error)
- func (c *Client) QueryNominators(accountId []byte, block uint32) (StakingNominations, error)
- func (c *Client) QueryOss(account []byte, block uint32) (OssInfo, error)
- func (c *Client) QueryReserveReward(block uint32) (types.U128, error)
- func (c *Client) QueryRoundReward(era, block uint32) (RoundRewardType, error)
- func (c *Client) QueryTerritory(owner []byte, name string, block uint32) (TerritoryInfo, error)
- func (c *Client) QueryTotalIdleSpace(block uint32) (uint64, error)
- func (c *Client) QueryTotalServiceSpace(block uint32) (uint64, error)
- func (c *Client) QueryUnitPrice(block uint32) (*big.Int, error)
- func (c *Client) QueryUserFileList(accountID []byte, block uint32) ([]UserFileSliceInfo, error)
- func (c *Client) QueryValidatorCommission(accountId []byte, block uint32) (StakingValidatorPrefs, error)
- func (c *Client) QueryValidators(block uint32) ([]types.AccountID, error)
- func (c *Client) ReactivateTerritory(name string, days uint32, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) RefreshSubstrateApi(r bool) error
- func (c *Client) RegisterOss(domain string, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) RenewalTerritory(name string, days uint32, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) SendEvmCall(source, target types.H160, input types.Bytes, value types.U256, ...) (string, error)
- func (c *Client) SubmitExtrinsic(caller *signature.KeyringPair, call types.Call, eventName string, event any, ...) (string, error)
- func (c *Client) TransferToken(dest string, amount string, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) UpdateCallerNonce(caller *signature.KeyringPair) error
- func (c *Client) UpdateOss(domain string, caller *signature.KeyringPair, event any) (string, error)
- func (c *Client) UploadDeclaration(fid FileHash, segment []SegmentList, user UserBrief, filesize uint64, ...) (string, error)
- type CompleteInfo
- type ElectionCompute
- type ElectionScore
- type EventAlreadyFrozen
- type EventAuthorize
- type EventBuySpace
- type EventCalculateEnd
- type EventCalculateReport
- type EventCallDone
- type EventCancelAuthorize
- type EventClaimRestoralOrder
- type EventCreatePayOrder
- type EventDeleteFile
- type EventDeposit
- type EventDrawFaucetMoney
- type EventElectionFinalized
- type EventExit
- type EventExpansionSpace
- type EventFaucetTopUpMoney
- type EventFillerDelete
- type EventFillerUpload
- type EventGenerateChallenge
- type EventGenerateRestoralOrder
- type EventIdleSpaceCert
- type EventIncreaseCollateral
- type EventIncreaseDeclarationSpace
- type EventKeyfairyAdded
- type EventLeaseExpireIn24Hours
- type EventLeaseExpired
- type EventLessThan24Hours
- type EventLocked
- type EventMasterKeyLaunched
- type EventMasterKeyRotated
- type EventMasterKeyRotationFailed
- type EventMinerClaim
- type EventMinerExit
- type EventMinerExitPrep
- type EventMinimumCesealVersionChangedTo
- type EventOssDestroy
- type EventOssRegister
- type EventOssUpdate
- type EventPaidOrder
- type EventPhaseTransitioned
- type EventReceive
- type EventRecoveryCompleted
- type EventRegisterPoisKey
- type EventRegistered
- type EventRenewalSpace
- type EventReplaceFiller
- type EventReplaceIdleSpace
- type EventServiceFeePaid
- type EventSolutionStored
- type EventStorageCompleted
- type EventSubmitIdleProof
- type EventSubmitIdleVerifyResult
- type EventSubmitProof
- type EventSubmitServiceProof
- type EventSubmitServiceVerifyResult
- type EventTerritorFileDelivery
- type EventTransferReport
- type EventUpdateBeneficiary
- type EventUploadDeclaration
- type EventValidatorPrefsSet
- type EventVerifyProof
- type EventWithdraw
- type EventWorkerAdded
- type EventWorkerUpdated
- type FileHash
- type FileMetadata
- type FragmentInfo
- type Individual
- type KeyLocker
- type KeyringManager
- type Keyrings
- func (k *Keyrings) AddKey(key signature.KeyringPair)
- func (k *Keyrings) GetKey(address string) signature.KeyringPair
- func (k *Keyrings) GetKeyInOrder() signature.KeyringPair
- func (k *Keyrings) GetKeyRandomly() signature.KeyringPair
- func (k *Keyrings) PutKey(address string)
- func (k *Keyrings) RemoveKey(address string)
- type MinerInfo
- type Option
- type OssInfo
- type OtherStakingExposure
- type PagedExposureMetadata
- type ParsedBlock
- type ParsedEvent
- type ParsedExtrinsic
- type PoISKeyInfo
- type Result
- type ResultOk
- type RoundRewardType
- type SegmentInfo
- type SegmentList
- type SignPayload
- type Signed
- type SpaceProofInfo
- type StakingEraRewardPoints
- type StakingExposure
- type StakingExposurePaged
- type StakingLedger
- type StakingNominations
- type StakingValidatorPrefs
- type StorageOrder
- type TerritoryInfo
- type UnlockChunk
- type UnsignedValue
- type Unsigneds
- type UserBrief
- type UserFileSliceInfo
- type ValidatorPrefs
Constants ¶
const ( //0: Active 1: Frozen 2: Expired 3: OnConsignment TERRITORY_ACTIVE = iota TERRITORY_FROZEN TERRITORY_EXPIRED TERRITORY_ONCONSIGNMENT )
Variables ¶
var (
ErrTxEventNotFound = errors.New("tx event not found")
)
Functions ¶
func ConvertName ¶
ConvertName converts snake_case field names to CamelCase for struct field mapping. Processes namespaces (e.g., "transaction_fee_paid" → "TransactionFeePaid"). Parameters:
name - Original field name in snake_case format
Returns:
CamelCase formatted name
func DecodeEvent ¶
DecodeEvent decodes a blockchain event into a user-provided struct. Handles reflection to map event fields to struct fields, includes error recovery for panics. Parameters:
event - Parsed event data from the blockchain value - Pointer to a struct to decode the event into
Returns:
Error if decoding fails (invalid input, type mismatch, etc.)
func DecodeFields ¶
DecodeFields recursively decodes event fields into a target struct/type. Handles structs, arrays, slices, maps, and primitive types with type conversion. Parameters:
target - Reflect value of the target to decode into fv - Reflect value of the source field data
Returns:
Error if type mismatch or decoding fails
func EncodePubkey ¶
func GetRegisteredEventIntance ¶
GetRegisteredEventInstance retrieves a new instance of registered event type.
Parameters:
- eventName: Registered event name to look up
Returns:
- interface{}: Newly created instance pointer for the event type
- bool: True if the event type was registered
func GetRegisteredEventTypes ¶
func GetRegisteredEventTypes() []string
GetRegisteredEventTypes lists all registered event type names.
Returns:
- []string: Slice of registered event names in "Module.Event" format. Note: Order is not guaranteed as it's based on map iteration.
func ParsingPublickey ¶
func QueryStorage ¶
QueryStorage retrieves a single storage entry from the blockchain. Parameters:
T - Generic type for the storage data c - Client instance for chain interaction block - Block number to query (0 for latest) prefix - Storage module prefix (e.g., "System") method - Storage function name (e.g., "Account") args - Optional arguments for storage key generation
Returns:
Decoded storage data of type T Error if key creation, storage retrieval, or decoding fails
func QueryStorages ¶
QueryStorages retrieves multiple storage entries matching a prefix. Parameters:
T - Generic type for the storage data c - Client instance for chain interaction block - Block number to query (0 for latest) prefix - Storage module prefix method - Storage function name
Returns:
Slice of decoded storage data entries Error if key retrieval, storage query, or decoding fails
func RegisterEventType ¶
RegisterEventType registers custom event type to the global registry. Allows decoding of blockchain events into concrete Go types.
Parameters:
- eventName: Full event name in format "Module.Event" (e.g. "Balances.Transfer")
- eventType: Reflect type of the target event struct
Types ¶
type BloomFilter ¶
type BucketInfo ¶
type Client ¶
type Client struct { Rpcs []string KeyringManager GenesisBlockHash types.Hash RuntimeVersion *types.RuntimeVersion *rpc.SubstrateAPI Retriever retriever.EventRetriever Timeout time.Duration Metadata *types.Metadata CallRegistery registry.CallRegistry // contains filtered or unexported fields }
func NewClient ¶
NewClient creates a full-featured CESS chain client with configurable options. Initializes RPC connection, retrieves metadata, genesis hash, and runtime version. Parameters:
opts - List of functional options for client configuration
Returns:
Configured Client instance Error if any initialization step fails
func NewLightCessClient ¶
NewLightCessClient creates a lightweight CESS client with a single account. Parameters:
mnemonic - BIP-39 mnemonic for the primary account rpcs - List of RPC endpoints to connect to
Returns:
Lightweight Client instance Error if client initialization fails
func (*Client) Authorize ¶
func (c *Client) Authorize(account []byte, caller *signature.KeyringPair, event any) (string, error)
Authorize grants authorization to a target account for OSS operations. Parameters:
account - The target account ID (byte slice) to authorize caller - Keyring pair of the account initiating the authorization (nil for temporary key) event - Event pointer, used to receive specified events
Returns:
string - Block hash of the submitted transaction error - Error if the authorization operation fails
func (*Client) CancelOssAuth ¶
func (c *Client) CancelOssAuth(account []byte, caller *signature.KeyringPair, event any) (string, error)
CancelOssAuth revokes authorization from a target account for OSS operations. Parameters:
account - The target account ID (byte slice) to revoke authorization from caller - Keyring pair of the account initiating the cancellation (nil for temporary key) event - Event pointer, used to receive specified events
Returns:
string - Block hash of the submitted transaction error - Error if the cancellation operation fails
func (*Client) CreateTerritoryOrder ¶
func (c *Client) CreateTerritoryOrder(account []byte, name string, orderType uint8, gibCount, days, expired uint32, caller *signature.KeyringPair, event any) (string, error)
CreateTerritoryOrder creates a new territory order on the blockchain. This method is used by the agent to create a territory for other users. Parameters:
account - The account ID of the owner of the territory. name - The name of the territory. orderType - The type of order (e.g., mint, expand, renew, reactivate). gibCount - The size of the territory in GiB. days - The duration of the territory in days. expired - The expiration time of the order in Unix timestamp. caller - The keyring pair of the transaction signer. If nil, the client's keyring will be used. event - A pointer to an event structure that will be populated if the transaction is successful.
Returns:
string - The block hash of the transaction. error - An error if the transaction fails, including encoding errors, key retrieval, extrinsic creation, or submission errors.
func (*Client) DeleteUserFile ¶
func (c *Client) DeleteUserFile(fid FileHash, owner types.AccountID, caller *signature.KeyringPair, event any) (string, error)
DeleteUserFile submits a file deletion transaction to remove a user's file. Signs and submits the extrinsic with file hash and owner's account ID. Parameters:
fid - FileHash struct representing the file's cryptographic hash owner - AccountID of the file owner caller - Keyring pair for transaction signing (optional, uses client's keyring if nil) event - Event pointer, used to receive FileBank.DeleteFile event
Returns:
Block hash where the transaction was included Error if signing, extrinsic creation, or submission fails
func (*Client) DestroyOss ¶
DestroyOss deletes an existing OSS service registration. Parameters:
caller - Keyring pair of the account initiating the destruction (nil for temporary key) event - Event pointer, used to receive specified events
Returns:
string - Block hash of the submitted transaction error - Error if the destruction operation fails
func (*Client) ExecTerritoryOrder ¶
func (c *Client) ExecTerritoryOrder(orderId []byte, caller *signature.KeyringPair, event any) (string, error)
ExecTerritoryOrder executes a territory order on the blockchain. This method is used by the agent to execute a territory order for other users. Parameters:
orderId - The ID of the order to execute. caller - The keyring pair of the transaction signer. If nil, the client's keyring will be used. event - A pointer to an event structure that will be populated if the transaction is successful.
Returns:
string - The block hash of the transaction. error - An error if the transaction fails, including encoding errors, key retrieval, extrinsic creation, or submission errors.
func (*Client) ExpandingTerritory ¶
func (c *Client) ExpandingTerritory(name string, gibCount uint32, caller *signature.KeyringPair, event any) (string, error)
ExpandingTerritory expands an existing territory on the blockchain. Parameters:
name - The name of the territory to expand. gibCount - The additional size to add to the territory in GiB. caller - The keyring pair of the transaction signer. If nil, the client's keyring will be used. event - A pointer to an event structure that will be populated if the transaction is successful.
Returns:
string - The block hash of the transaction. error - An error if the transaction fails, including encoding errors, key retrieval, extrinsic creation, or submission errors.
func (*Client) GetCaller ¶
func (c *Client) GetCaller(caller *signature.KeyringPair) (signature.KeyringPair, error)
GetCaller retrieves the signing keyring pair for transactions. Uses provided caller if not nil; otherwise selects from client's keyring. Parameters:
caller - Optional specific keyring pair to use
Returns:
Keyring pair for transaction signing Error if no valid caller or keyring configured
func (*Client) GetCallerNonce ¶
func (c *Client) GetCallerNonce(caller *signature.KeyringPair) (uint64, error)
func (*Client) GetOssProxyAuthSign ¶
GetOssProxyAuthSign retrieves the OSS proxy authorization sign for a given mnemonic and OSS account. Parameters:
mnemonic - The mnemonic phrase for the key pair. oss - The public key of the OSS account.
Returns:
[]byte - The public key of the key pair. []byte - The signed authorization data. error - An error if the sign operation fails.
func (*Client) MintTerritory ¶
func (c *Client) MintTerritory(name string, gibCount, days uint32, caller *signature.KeyringPair, event any) (string, error)
MintTerritory mints a new territory on the blockchain. Parameters:
name - The name of the territory. gibCount - The initial size of the territory in GiB. days - The duration of the territory in days. caller - The keyring pair of the transaction signer. If nil, the client's keyring will be used. event - A pointer to an event structure that will be populated if the transaction is successful.
Returns:
string - The block hash of the transaction. error - An error if the transaction fails, including encoding errors, key retrieval, extrinsic creation, or submission errors.
func (*Client) NewSubstrateAPI ¶
NewSubstrateAPI initializes a new Substrate RPC connection. Uses provided rpcAddr or randomly selects from client's RPC list if empty. Parameters:
rpcAddr - Specific RPC address to connect to (optional)
Returns:
Error if connection fails
func (*Client) ParseBlockData ¶
func (c *Client) ParseBlockData(hash types.Hash) (ParsedBlock, error)
ParseBlockData processes raw block data into structured format
Workflow:
- Creates call registry from metadata
- Retrieves raw block data from chain
- Processes extrinsics (transactions): - Generates call hash - Extracts signature information
- Retrieves and processes system events: - Matches events to extrinsics - Handles success/failure statuses - Captures extrinsic errors
Parameters:
- hash: Block hash identifier
Returns:
- ParsedBlock: Fully parsed block structure
- error: Wrapped error with operation context
func (*Client) ParseBlockDataWithBlockNumber ¶
func (c *Client) ParseBlockDataWithBlockNumber(block uint32) (ParsedBlock, error)
ParseBlockDataWithBlockNumber retrieves and parses block data by block number
Parameters:
- block: Target block number to parse
Returns:
- ParsedBlock: Structured block data with extrinsics and events
- error: Wrapped error containing original error context
func (*Client) ParseSystemEventError ¶
func (c *Client) ParseSystemEventError(t types.ModuleError) error
ParseSystemEventError converts a module error into a human-readable error message. Uses client metadata to resolve error index and code to error name/description. Parameters:
t - ModuleError struct containing error index and code
Returns:
Formatted error message Error if metadata lookup fails
func (*Client) ParseTxResult ¶
func (cli *Client) ParseTxResult(caller signature.KeyringPair, events []*parser.Event, eventName string) (*parser.Event, error)
ParseTxResult parses transaction events to find the target event and validate transaction status. Processes events, checks for extrinsic success/failure, and matches the specified event name. Parameters:
caller - Keyring pair of the transaction caller events - List of events from the transaction block eventName - Target event name to search for (e.g., "Balances.Transfer")
Returns:
Target event if found Error if parsing fails, event not found, or transaction failed
func (*Client) PutCaller ¶
func (c *Client) PutCaller(caller *signature.KeyringPair)
func (*Client) QuerPurchasedSpace ¶
QuerPurchasedSpace retrieves the total purchased storage space from the blockchain at the specified block height. Parameters:
block - The block number at which to query the storage.
Returns:
uint64 - The total purchased space value. error - An error if the query fails, including wrapped errors from underlying storage queries.
func (*Client) QueryAccountInfo ¶
QueryAccountInfo retrieves the account information for a specific account at the given block height. Parameters:
account - The byte slice representing the account address. block - The block number at which to query the account information.
Returns:
types.AccountInfo - The account information struct containing details like nonce, consumers, providers, etc. error - An error if the query fails, including account ID creation errors, encoding errors, or storage query failures.
func (*Client) QueryAllBondeds ¶
QueryAllBondeds lists all active bonded accounts. Accesses "Bonded" storage map under "Staking" module.
Parameters:
- block: State query block number
Returns:
- []types.AccountID: Slice of account identifier data structures
- error: Storage access error with context
func (*Client) QueryAllErasStakersPaged ¶
func (c *Client) QueryAllErasStakersPaged(accountId []byte, era, block uint32) ([]StakingExposurePaged, error)
QueryAllErasStakersPaged gets paginated validator exposure data. Iterates through 256 pages of "ErasStakersPaged" storage.
Parameters:
- accountId: Validator account identifier
- era: Target staking era
- block: Query block number
Returns:
- []StakingExposurePaged: Paginated exposure data slices
- error: Composite error during paged queries
func (*Client) QueryAllMiners ¶
QueryAllMiners retrieves the list of all registered storage miner account IDs at a given block number. Parameters:
block - The block number (uint32) at which to perform the query
Returns:
[]types.AccountID - Slice containing all storage miner account IDs error - Error if the query operation fails
func (*Client) QueryAllNominators ¶
func (c *Client) QueryAllNominators(block uint32) ([]StakingNominations, error)
QueryAllNominators lists all active nominator accounts and their preferences. Accesses "Nominators" storage map under "Staking" module.
Parameters:
- block: State query block number
Returns:
- []StakingNominations: Slice of nominator data structures
- error: Storage access error with context
func (*Client) QueryAllOss ¶
QueryAllOss retrieves OSS information for all registered accounts at a given block number. Parameters:
block - The block number (uint32) at which to perform the query
Returns:
[]OssInfo - Slice containing OSS information for all accounts error - Error if the query operation fails
func (*Client) QueryAuthList ¶
QueryAuthList retrieves the authorization list for a specific account at a given block number. Parameters:
account - The account ID (byte slice) to query authorization list for block - The block number (uint32) at which to perform the query
Returns:
[]types.AccountID - Slice of authorized account IDs error - Error if the query operation fails
func (*Client) QueryBlockNumber ¶
QueryBlockNumber retrieves the block number from the blockchain. If blockhash is provided, it queries the block number for the specified block hash. If blockhash is empty, it retrieves the latest block number. Parameters:
blockhash - The hexadecimal string of the block hash (empty for the latest block).
Returns:
uint32 - The block number. error - An error if the query fails, including decoding errors or RPC failures.
func (*Client) QueryCounterForMinerItems ¶
QueryCounterForMinerItems retrieves the counter value for storage miner items at a given block number. Parameters:
block - The block number (uint32) at which to perform the query
Returns:
uint32 - Counter value representing the number of storage miner items error - Error if the query operation fails
func (*Client) QueryCounterForValidators ¶
QueryCounterForValidators gets the current validator count from chain storage. Accesses "CounterForValidators" entry under "Staking" module.
Parameters:
- block: Target block number for state query
Returns:
- uint32: Active validator count
- error: Wrapped storage access error
func (*Client) QueryCurrencyReward ¶
QueryCurrencyReward retrieves the current currency reward allocation from treasury storage. Queries the "CurrencyReward" entry under "CessTreasury" module in chain storage.
Parameters:
- block: Target block number for historical query
Returns:
- types.U128: 128-bit unsigned integer reward value
- error: Wrapped storage access error
func (*Client) QueryCurrentEra ¶
QueryCurrentEra fetches the latest active era index. Reads "CurrentEra" entry from runtime storage.
Parameters:
- block: Block for state inspection
Returns:
- uint32: Current era number
- error: Enhanced error with operation context
func (*Client) QueryDealMap ¶
func (c *Client) QueryDealMap(fid string, block uint32) (StorageOrder, error)
QueryDealMap retrieves the storage order information for a specific file by its file ID. Validates file ID format (64-byte hex string), encodes it to file hash, and queries the FileBank storage. Parameters:
fid - 64-byte hex string representing the file ID block - Block number to query (0 for latest block)
Returns:
StorageOrder struct containing file storage details Error if file ID is invalid, encoding fails, or storage query fails
func (*Client) QueryEraReward ¶
QueryEraReward fetches the accumulated reward for the current era. Accesses "EraReward" storage entry in "CessTreasury" module.
Parameters:
- block: Block number for state query
Returns:
- types.U128: Era-specific reward amount
- error: Wrapped chain interaction error
func (*Client) QueryEraValidatorReward ¶
QueryEraValidatorReward gets validator reward for specific era. Accesses "ErasValidatorReward" storage with era parameter.
Parameters:
- era: Reward calculation era
- block: Historical block number
Returns:
- types.U128: Era-specific validator reward amount
- error: Composite error including encoding issues
func (*Client) QueryErasRewardPoints ¶
func (c *Client) QueryErasRewardPoints(era, block uint32) (StakingEraRewardPoints, error)
QueryErasRewardPoints gets reward distribution details per era. Queries "ErasRewardPoints" storage with SCALE-encoded era parameter.
Parameters:
- era: Target reward distribution era
- block: Query block number
Returns:
- StakingEraRewardPoints: Structured reward points data
- error: Wrapped chain interaction error
func (*Client) QueryErasStakers ¶
func (c *Client) QueryErasStakers(accountId []byte, era, block uint32) (StakingExposure, error)
QueryErasStakers retrieves validator exposure for specific era. Combines era parameter and account ID to query "ErasStakers".
Parameters:
- accountId: Validator account ID
- era: Target exposure era
- block: Historical block number
Returns:
- StakingExposure: Validator's era exposure details
- error: Wrapped multi-parameter query error
func (*Client) QueryErasStakersOveriew ¶
func (c *Client) QueryErasStakersOveriew(accountId []byte, era, block uint32) (PagedExposureMetadata, error)
func (*Client) QueryErasTotalStaking ¶
QueryErasTotalStaking retrieves total staked amount for a specific era. Requires SCALE-encoded era parameter to query "ErasTotalStake" storage.
Parameters:
- era: Target staking era
- block: Block number for historical data
Returns:
- types.U128: 128-bit total stake value
- error: Composite error including encoding failures
func (*Client) QueryFileMetadata ¶
func (c *Client) QueryFileMetadata(fid string, block uint32) (FileMetadata, error)
QueryFileMetadata fetches metadata (e.g., file size, creation time) for a specific file. Validates file ID format, encodes to file hash, and queries the FileBank file metadata storage. Parameters:
fid - 64-byte hex string representing the file ID block - Block number to query (0 for latest block)
Returns:
FileMetadata struct containing file metadata Error if file ID is invalid, encoding fails, or storage query fails
func (*Client) QueryLedger ¶
func (c *Client) QueryLedger(accountId []byte, block uint32) (StakingLedger, error)
QueryLedger fetches staking ledger for an account. Queries "Ledger" storage map with account ID parameter.
Parameters:
- accountId: Stash account identifier
- block: Query block number
Returns:
- StakingLedger: Complete staking ledger information
- error: Enhanced error with account context
func (*Client) QueryMinerItems ¶
QueryMinerItems retrieves the storage miner information for a specific miner account at a given block number. Parameters:
miner - The miner account ID (byte slice) to query information for block - The block number (uint32) at which to perform the query
Returns:
MinerInfo - Struct containing the queried storage miner information error - Error if the query operation fails
func (*Client) QueryNominators ¶
func (c *Client) QueryNominators(accountId []byte, block uint32) (StakingNominations, error)
QueryNominators lists all active nominator accounts and their preferences. Accesses "Nominators" storage map under "Staking" module.
Parameters:
- block: State query block number
Returns:
- []StakingNominations: Slice of nominator data structures
- error: Storage access error with context
func (*Client) QueryOss ¶
QueryOss retrieves the OSS information for a specific account at a given block number. Parameters:
account - The account ID (byte slice) to query OSS information for block - The block number (uint32) at which to perform the query
Returns:
OssInfo - Struct containing the queried OSS information error - Error if the query operation fails
func (*Client) QueryReserveReward ¶
QueryReserveReward gets the treasury's reserved reward pool balance. Reads "ReserveReward" entry from runtime storage.
Parameters:
- block: Target block for state inspection
Returns:
- types.U128: Reserve pool balance
- error: Enhanced error with operation context
func (*Client) QueryRoundReward ¶
func (c *Client) QueryRoundReward(era, block uint32) (RoundRewardType, error)
QueryRoundReward retrieves reward distribution details for a specific era. Requires SCALE-encoded era parameter to access "RoundReward" storage entry.
Parameters:
- era: Target reward distribution era
- block: Block number for state query
Returns:
- RoundRewardType: Structured reward distribution data
- error: Composite error including parameter encoding failures
func (*Client) QueryTerritory ¶
QueryTerritory retrieves detailed information about a specific territory from the blockchain at the specified block height. Parameters:
owner - The owner's account address (byte slice). name - The name of the territory. block - The block number at which to query the storage.
Returns:
TerritoryInfo - Struct containing territory details. error - An error if the query fails, including encoding errors or underlying storage query failures.
func (*Client) QueryTotalIdleSpace ¶
QueryTotalIdleSpace retrieves the total idle storage space from the blockchain at the specified block height. Parameters:
block - The block number at which to query the storage.
Returns:
uint64 - The total idle space value. error - An error if the query fails, including wrapped errors from underlying storage queries.
func (*Client) QueryTotalServiceSpace ¶
QueryTotalServiceSpace retrieves the total In-service storage space from the blockchain at the specified block height. Parameters:
block - The block number at which to query the storage.
Returns:
uint64 - The total serviceable space value. error - An error if the query fails, including wrapped errors from underlying storage queries.
func (*Client) QueryUnitPrice ¶
QueryUnitPrice retrieves the unit price for storage handling from the blockchain at the specified block height. Parameters:
block - The block number at which to query the storage.
Returns:
*big.Int - The unit price value. error - An error if the query fails, including wrapped errors from underlying storage queries.
func (*Client) QueryUserFileList ¶
func (c *Client) QueryUserFileList(accountID []byte, block uint32) ([]UserFileSliceInfo, error)
QueryUserFileList retrieves the list of files held by a specific user. Converts account ID to AccountID type, encodes it, and queries the user's file list storage. Parameters:
accountID - Raw byte slice representing the user's account ID block - Block number to query (0 for latest block)
Returns:
Slice of UserFileSliceInfo containing file slice details Error if account ID conversion fails, encoding fails, or storage query fails
func (*Client) QueryValidatorCommission ¶
func (c *Client) QueryValidatorCommission(accountId []byte, block uint32) (StakingValidatorPrefs, error)
QueryValidatorCommission retrieves validator's commission preferences. Queries "Validators" storage map with account ID parameter.
Parameters:
- accountId: Validator's account identifier (32-byte array)
- block: Target block for query
Returns:
- StakingValidatorPrefs: Commission rate and preferences
- error: Wrapped storage error
func (*Client) QueryValidators ¶
QueryValidators retrieves active validator accounts for the given block. Accesses "Validators" storage entry under "Session" module which contains the current authority set.
Parameters:
- block: Block number for state query
Returns:
- []types.AccountID: Slice of validator account identifiers
- error: Wrapped storage access error with context
func (*Client) ReactivateTerritory ¶
func (c *Client) ReactivateTerritory(name string, days uint32, caller *signature.KeyringPair, event any) (string, error)
ReactivateTerritory reactivates an existing territory on the blockchain. Parameters:
name - The name of the territory to reactivate. days - The additional duration to add to the territory in days. caller - The keyring pair of the transaction signer. If nil, the client's keyring will be used. event - A pointer to an event structure that will be populated if the transaction is successful.
Returns:
string - The block hash of the transaction. error - An error if the transaction fails, including encoding errors, key retrieval, extrinsic creation, or submission errors.
Note: This function is similar to RenewalTerritory but does not require a new name. It can be used to extend the activation period of an existing territory.
func (*Client) RefreshSubstrateApi ¶
RefreshSubstrateApi reconnects to RPC endpoints, optionally shuffling the list. Attempts to connect to all RPCs until successful connection with valid metadata. Parameters:
r - Whether to shuffle RPC list before connection attempts
Returns:
Error if all RPC connections fail
func (*Client) RegisterOss ¶
func (c *Client) RegisterOss(domain string, caller *signature.KeyringPair, event any) (string, error)
RegisterOss registers a new OSS service with the specified domain name. Parameters:
domain - The domain name (string) for the OSS service (must be 1-100 characters) caller - Keyring pair of the account initiating the registration (nil for temporary key) event - Event pointer, used to receive specified events
Returns:
string - Block hash of the submitted transaction error - Error if the registration operation fails
func (*Client) RenewalTerritory ¶
func (c *Client) RenewalTerritory(name string, days uint32, caller *signature.KeyringPair, event any) (string, error)
RenewalTerritory renews an existing territory on the blockchain. Parameters:
name - The name of the territory to renew. days - The additional duration to add to the territory in days. caller - The keyring pair of the transaction signer. If nil, the client's keyring will be used. event - A pointer to an event structure that will be populated if the transaction is successful.
Returns:
string - The block hash of the transaction. error - An error if the transaction fails, including encoding errors, key retrieval, extrinsic creation, or submission errors.
func (*Client) SendEvmCall ¶
func (*Client) SubmitExtrinsic ¶
func (c *Client) SubmitExtrinsic(caller *signature.KeyringPair, call types.Call, eventName string, event any, timeout time.Duration) (string, error)
SubmitExtrinsic signs and submits an extrinsic to the blockchain network. Monitors transaction status, decodes specified event, and handles timeout. Parameters:
keypair - Account keyring pair for signing the extrinsic call - Substrate call data to include in the extrinsic eventName - Name of event to decode (empty for no event decoding) event - Pointer to struct for decoded event data (optional) timeout - Maximum time to wait for transaction confirmation
Returns:
Block hash containing the transaction Error if signing, submission, or event decoding fails
func (*Client) TransferToken ¶
func (c *Client) TransferToken(dest string, amount string, caller *signature.KeyringPair, event any) (string, error)
TransferToken transfers tokens from the caller's account to the destination account. It ensures the caller's account remains alive (non-zero balance after transfer). Parameters:
dest - The destination account address (SS58 format string) amount - The amount of tokens to transfer, ("1000000000000000000" represents 1 CESS token). caller - The keyring pair of the transaction signer event - A pointer to an event structure that will be populated if the transaction is successful
Returns:
Block hash of the transaction Error if the transfer fails (e.g., invalid address, insufficient balance)
func (*Client) UpdateCallerNonce ¶
func (c *Client) UpdateCallerNonce(caller *signature.KeyringPair) error
func (*Client) UpdateOss ¶
UpdateOss updates the domain name of an existing OSS service. Parameters:
domain - The new domain name (string) for the OSS service (must be 1-100 characters) caller - Keyring pair of the account initiating the update (nil for temporary key) event - Event pointer, used to receive specified events
Returns:
string - Block hash of the submitted transaction error - Error if the update operation fails
func (*Client) UploadDeclaration ¶
func (c *Client) UploadDeclaration(fid FileHash, segment []SegmentList, user UserBrief, filesize uint64, caller *signature.KeyringPair, event any) (string, error)
UploadDeclaration submits a file upload declaration transaction to the blockchain. Signs and submits the extrinsic with file hash, segment info, user details, and file size. Parameters:
fid - FileHash struct representing the file's cryptographic hash segment - Slice of SegmentList containing file segment details user - UserBrief struct with user identification information filesize - Total size of the file in bytes (uint64) caller - Keyring pair for transaction signing (optional, uses client's keyring if nil) event - Event pointer, used to receive FileBank.UploadDeclaration event
Returns:
Block hash where the transaction was included Error if signing, extrinsic creation, or submission fails
type ElectionScore ¶
type ElectionScore struct { /// The minimal winner, in terms of total backing stake. /// /// This parameter should be maximized. Minimal_stake types.U128 /// The sum of the total backing of all winners. /// /// This parameter should maximized Sum_stake types.U128 /// The sum squared of the total backing of all winners, aka. the variance. /// /// Ths parameter should be minimized. Sum_stake_squared types.U128 }
*******************************************************
type EventAlreadyFrozen ¶
type EventAuthorize ¶
type EventBuySpace ¶
type EventBuySpace struct { Phase types.Phase Acc types.AccountID Storage_capacity types.U128 Spend types.U128 Topics []types.Hash }
------------------------StorageHandler--------------------------------
type EventCalculateEnd ¶
type EventCalculateReport ¶
type EventCallDone ¶
type EventCancelAuthorize ¶
type EventClaimRestoralOrder ¶
type EventCreatePayOrder ¶
type EventDeleteFile ¶
type EventDeleteFile struct { Phase types.Phase Operator types.AccountID Owner types.AccountID Filehash []FileHash Topics []types.Hash }
------------------------FileBank----------------------
type EventDeposit ¶
type EventDrawFaucetMoney ¶
type EventElectionFinalized ¶
type EventElectionFinalized struct { Phase types.Phase Compute types.U8 Score ElectionScore Topics []types.Hash }
------------------------system------------------------
type EventExpansionSpace ¶
type EventFaucetTopUpMoney ¶
type EventFillerDelete ¶
type EventFillerUpload ¶
type EventGenerateChallenge ¶
type EventIdleSpaceCert ¶
type EventIncreaseCollateral ¶
type EventKeyfairyAdded ¶
type EventLeaseExpired ¶
type EventLessThan24Hours ¶
type EventLocked ¶
type EventMasterKeyLaunched ¶
type EventMasterKeyRotated ¶
type EventMinerClaim ¶
type EventMinerExit ¶
type EventMinerExitPrep ¶
type EventOssDestroy ¶
type EventOssRegister ¶
type EventOssRegister struct { Phase types.Phase Acc types.AccountID Endpoint [38]types.U8 Topics []types.Hash }
------------------------Oss---------------------------
type EventOssUpdate ¶
type EventPaidOrder ¶
type EventPhaseTransitioned ¶
type EventReceive ¶
type EventRecoveryCompleted ¶
type EventRegisterPoisKey ¶
type EventRegistered ¶
------------------------Sminer------------------------
type EventRenewalSpace ¶
type EventReplaceFiller ¶
type EventReplaceIdleSpace ¶
type EventServiceFeePaid ¶
type EventSolutionStored ¶
type EventStorageCompleted ¶
type EventSubmitIdleProof ¶
type EventSubmitProof ¶
type EventSubmitServiceProof ¶
type EventTransferReport ¶
type EventUpdateBeneficiary ¶
type EventUploadDeclaration ¶
type EventValidatorPrefsSet ¶
type EventVerifyProof ¶
type EventVerifyProof struct { Phase types.Phase TeeWorker [32]types.U8 Miner types.AccountID Topics []types.Hash }
------------------------Audit-------------------
type EventWithdraw ¶
type EventWorkerAdded ¶
type EventWorkerUpdated ¶
type FileMetadata ¶
type FragmentInfo ¶
type KeyLocker ¶
type KeyLocker struct {
// contains filtered or unexported fields
}
func NewKeyLocker ¶
type KeyringManager ¶
type KeyringManager interface { AddKey(key signature.KeyringPair) RemoveKey(address string) GetKey(address string) signature.KeyringPair GetKeyRandomly() signature.KeyringPair GetKeyInOrder() signature.KeyringPair PutKey(address string) }
type Keyrings ¶
type Keyrings struct {
// contains filtered or unexported fields
}
func NewKeyrings ¶
func NewKeyrings(keyrings ...signature.KeyringPair) *Keyrings
func (*Keyrings) AddKey ¶
func (k *Keyrings) AddKey(key signature.KeyringPair)
func (*Keyrings) GetKeyInOrder ¶
func (k *Keyrings) GetKeyInOrder() signature.KeyringPair
func (*Keyrings) GetKeyRandomly ¶
func (k *Keyrings) GetKeyRandomly() signature.KeyringPair
type MinerInfo ¶
type MinerInfo struct { BeneficiaryAccount types.AccountID StakingAccount types.AccountID Endpoint types.Bytes Collaterals types.U128 Debt types.U128 State types.Bytes // positive, exit, frozen, lock DeclarationSpace types.U128 IdleSpace types.U128 ServiceSpace types.U128 LockSpace types.U128 SpaceProofInfo types.Option[SpaceProofInfo] ServiceBloomFilter BloomFilter TeeSig [64]types.U8 }
type Option ¶
func OptionWithAccounts ¶
OptionWithAccounts configures the client with keyring accounts from mnemonics. Parameters:
mnemonics - List of BIP-39 mnemonic phrases for account recovery
Returns:
Functional option to apply to the client
func OptionWithRpcs ¶
OptionWithRpcs configures the client with a list of RPC endpoints. Parameters:
rpcs - List of RPC server addresses (e.g., "ws://localhost:9944")
Returns:
Functional option to apply to the client
func OptionWithTimeout ¶
OptionWithTimeout sets the default timeout for chain operations. Parameters:
timeout - Timeout duration (minimum 15 seconds if <=0)
Returns:
Functional option to apply to the client
type OtherStakingExposure ¶
type PagedExposureMetadata ¶
type ParsedBlock ¶
type ParsedBlock struct { Hash types.Hash Header types.Header Extrinsics []ParsedExtrinsic SystemEvents []ParsedEvent }
type ParsedEvent ¶
type ParsedExtrinsic ¶
type PoISKeyInfo ¶
type ResultOk ¶
type ResultOk struct { ActualWeight types.Option[ActualWeightType] PaysFee types.U8 }
type RoundRewardType ¶
type SegmentInfo ¶
type SegmentInfo struct { Hash FileHash FragmentList []FragmentInfo }
type SegmentList ¶
type SignPayload ¶
func (SignPayload) EncodeSignPayload ¶
func (p SignPayload) EncodeSignPayload() ([]byte, error)
type SpaceProofInfo ¶
type StakingEraRewardPoints ¶
type StakingEraRewardPoints struct { Total types.U32 Individual []Individual }
type StakingExposure ¶
type StakingExposure struct { Total types.UCompact Own types.UCompact Others []OtherStakingExposure }
type StakingExposurePaged ¶
type StakingExposurePaged struct { PageTotal types.UCompact Others []OtherStakingExposure }
type StakingLedger ¶
type StakingNominations ¶
type StakingValidatorPrefs ¶
type StorageOrder ¶
type StorageOrder struct { FileSize types.U128 SegmentList []SegmentList User UserBrief CompleteList []CompleteInfo }
type TerritoryInfo ¶
type UnlockChunk ¶
type UnlockChunk struct { Value types.UCompact Era types.BlockNumber }
type Unsigneds ¶
type Unsigneds struct { Index types.U8 UnsignedValue []UnsignedValue }