client

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: LGPL-3.0 Imports: 70 Imported by: 18

Documentation

Overview

Package Client provides a Client for interact with greenfield storage network.

Index

Constants

This section is empty.

Variables

View Source
var DownloadSegmentHooker downloadSegmentHook = DefaultDownloadSegmentHook
View Source
var UploadSegmentHooker uploadSegmentHook = DefaultUploadSegment

Functions

func DefaultDownloadSegmentHook added in v0.2.3

func DefaultDownloadSegmentHook(seg int64) error

func DefaultUploadSegment added in v0.2.3

func DefaultUploadSegment(id int) error

func GetEd25519PrivateKeyAndPublicKey added in v1.6.0

func GetEd25519PrivateKeyAndPublicKey(seed string) (ed25519.PrivateKey, ed25519.PublicKey)

Types

type AdminAPIInfo added in v1.1.0

type AdminAPIInfo struct {
	// contains filtered or unexported fields
}

AdminAPIInfo - the admin api info

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client - The implementation for IClient, implement all Client APIs for Greenfield SDK.

func (*Client) AttestChallenge added in v0.2.6

func (c *Client) AttestChallenge(ctx context.Context, submitterAddress, challengerAddress, spOperatorAddress string, challengeId uint64, objectId math.Uint,
	voteResult challengetypes.VoteResult, voteValidatorSet []uint64, VoteAggSignature []byte, txOption gnfdsdktypes.TxOption,
) (*sdk.TxResponse, error)

AttestChallenge - Send the attestation result of a challenge.

In-turn validator can submit the attestation when enough votes are collected. The attestation can include a valid challenge or is only for heartbeat purpose. If the challenge is valid, the related storage provider will be slashed, otherwise the storage provider will not be slashed.

- ctx: Context variables for the current API call.

- submitterAddress: The address of the attestation submitter, usually it's the address of current account.

- challengerAddress: The address of the challenger.

- spOperatorAddress: The operator address of the challenged storage provider.

- challengeId: The id of the challenge to be attested.

- objectId: The id of the object being challenged.

- voteResult: The result of the off-chain votes from the majority validators.

- voteValidatorSet: The bit set of validators who vote the voteResult for the challenge.

- VoteAggSignature: The BLS aggregated signature for the attestation from validators.

- txOption: The options for sending the tx.

- ret1: The response of Greenfield transaction.

- ret2: Return error when submitting attestation tx failed, otherwise return nil.

func (*Client) BeginRedelegate added in v0.2.6

func (c *Client) BeginRedelegate(ctx context.Context, validatorSrcAddr, validatorDestAddr string, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)

BeginRedelegate - Delegate coins from a delegator and source validator to a destination validator.

- ctx: Context variables for the current API call.

- validatorSrcAddr: The address of the source validator to un-delegate from.

- validatorDestAddr: The address of the destination validator to delegate to.

- amount: The amount of re-delegation.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when re-delegation tx failed, otherwise return nil.

func (*Client) BroadcastRawTx added in v0.2.6

func (c *Client) BroadcastRawTx(ctx context.Context, txBytes []byte, sync bool) (*sdk.TxResponse, error)

BroadcastRawTx - Broadcast raw transaction bytes to a Tendermint node.

- ctx: Context variables for the current API call.

- txBytes: The transaction bytes.

- sync: A flag to specify the transaction mode. If it is true, the transaction is broadcast synchronously. If it is false, the transaction is broadcast asynchronously.

- ret1: Transaction response, it can indicate both success and failed transaction.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) BroadcastTx added in v0.2.6

func (c *Client) BroadcastTx(ctx context.Context, msgs []sdk.Msg, txOpt *types.TxOption, opts ...grpc.CallOption) (*tx.BroadcastTxResponse, error)

BroadcastTx - Broadcast a transaction containing the provided message(s) to the chain.

- ctx: Context variables for the current API call.

- msgs: Message(s) to be broadcast to blockchain.

- txOpt: txOpt contains options for customizing the transaction.

- opts: The grpc option(s) if Client is using grpc connection.

- ret1: transaction response, it can indicate both success and failed transaction.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) BroadcastVote added in v0.2.6

func (c *Client) BroadcastVote(ctx context.Context, vote votepool.Vote) error

BroadcastVote - Broadcast a vote to the Node's VotePool, it is used by Greenfield relayer and challengers by now.

- ctx: Context variables for the current API call.

- vote: Contains vote details.

- ret: Return error when the request failed, otherwise return nil.

func (*Client) BuyQuotaForBucket added in v0.2.6

func (c *Client) BuyQuotaForBucket(ctx context.Context, bucketName string, targetQuota uint64, opt types.BuyQuotaOption) (string, error)

BuyQuotaForBucket - Buy the target quota for the specific bucket.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- targetQuota: Indicates the target quota value after setting, and can only be set to a higher value than the current value.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) CancelCreateObject added in v0.2.6

func (c *Client) CancelCreateObject(ctx context.Context, bucketName, objectName string, opt types.CancelCreateOption) (string, error)

CancelCreateObject send CancelCreateObject txn to greenfield chain

func (*Client) CancelMigrateBucket added in v0.2.6

func (c *Client) CancelMigrateBucket(ctx context.Context, bucketName string, opts types.CancelMigrateBucketOptions) (string, error)

CancelMigrateBucket - Cancel migrate migration by sending the MsgCancelMigrateBucket msg.

- ctx: Context variables for the current API call.

- bucketName: The name of the migrating bucket to be canceled.

- opt: The options of the proposal meta and transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request of cancel migration failed, otherwise return nil.

func (*Client) CancelUnbondingDelegation added in v0.2.6

func (c *Client) CancelUnbondingDelegation(ctx context.Context, validatorAddr string, creationHeight int64, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)

CancelUnbondingDelegation - Cancel the unbonding delegation by the delegator.

- ctx: Context variables for the current API call.

- validatorAddr: The address of the validator to cancel the unbonding delegation.

- creationHeight: The height at which the unbonding took place.

- amount: The amount of un-delegation.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when cancel unbonding delegation tx failed, otherwise return nil.

func (*Client) CancelUpdateObjectContent added in v1.6.0

func (c *Client) CancelUpdateObjectContent(ctx context.Context, bucketName, objectName string, opts types.CancelUpdateObjectOption) (string, error)

CancelUpdateObjectContent sends CancelUpdateObjectContent tx to greenfield chain, it returns the transaction hash value and error

func (*Client) ChallengeParams added in v0.2.6

ChallengeParams - Get challenge module's parameters of Greenfield blockchain.

- ctx: Context variables for the current API call.

- req: The request to query challenge parameters.

- ret1: The parameters of challenge module.

- ret2: Return error when getting parameters failed, otherwise return nil.

func (*Client) Claims added in v0.2.6

func (c *Client) Claims(ctx context.Context, srcChainId, destChainId uint32, sequence uint64,
	timestamp uint64, payload []byte, voteAddrSet []uint64, aggSignature []byte, txOption gnfdSdkTypes.TxOption,
) (*sdk.TxResponse, error)

Claims - Claim cross-chain packages from BSC to Greenfield, used by relayers which run by validators

- ctx: Context variables for the current API call.

- srcChainId: The source chain id.

- destChainId: The destination chain id.

- sequence: The sequence of the claim.

- timestamp: The timestamp of the cross-chain packages.

- payload: The payload of the claim.

- voteAddrSet: The bitset of the voted validators.

- aggSignature: The aggregated bls signature of the claim.

- txOption: The txOption for sending transactions.

- ret1: Transaction response from Greenfield.

- ret2: Return error if transaction failed, otherwise return nil.

func (*Client) ComputeHashRoots added in v0.2.6

func (c *Client) ComputeHashRoots(reader io.Reader, isSerial bool) ([][]byte, int64, storageTypes.RedundancyType, error)

ComputeHashRoots return the integrity hash, content size and the redundancy type of the file

func (*Client) CreateBucket added in v0.2.6

func (c *Client) CreateBucket(ctx context.Context, bucketName string, primaryAddr string, opts types.CreateBucketOptions) (string, error)

CreateBucket - Create a new bucket in greenfield.

This API sends a request to the storage provider to get approval for creating bucket and sends the createBucket transaction to the Greenfield.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to be created.

- primaryAddr: The primary SP address to which the bucket will be created on.

- opts: The Options indicates the meta to construct createBucket msg and the way to send transaction

- ret1: Transaction hash return from blockchain.

- ret2: Return error if create bucket failed, otherwise return nil.

func (*Client) CreateFolder added in v0.2.6

func (c *Client) CreateFolder(ctx context.Context, bucketName, objectName string, opts types.CreateObjectOptions) (string, error)

CreateFolder send create empty object txn to greenfield chain

func (*Client) CreateGroup added in v0.2.6

func (c *Client) CreateGroup(ctx context.Context, groupName string, opt types.CreateGroupOptions) (string, error)

CreateGroup - Create a new group without group members on Greenfield blockchain, and group members can be added by UpdateGroupMember transaction.

A `Group` is a collection of accounts that share the same permissions, allowing them to be handled as a single entity.

Examples of permissions include:

Put, List, Get, Delete, Copy, and Execute data objects; Create, Delete, and List buckets Create, Delete, ListMembers, Leave groups Create, Associate payment accounts Grant, Revoke the above permissions

For more details regarding `Group`, please refer to https://docs.bnbchain.org/greenfield-docs/docs/guide/greenfield-blockchain/modules/permission

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- opt: The options for customizing a group and transaction.

- ret1: Transaction hash return from blockchain.

- ret3: Return error when the request failed, otherwise return nil.

func (*Client) CreateObject added in v0.2.6

func (c *Client) CreateObject(ctx context.Context, bucketName, objectName string,
	reader io.Reader, opts types.CreateObjectOptions,
) (string, error)

CreateObject get approval of creating object and send createObject txn to greenfield chain, it returns the transaction hash value and error

func (*Client) CreatePaymentAccount added in v0.2.6

func (c *Client) CreatePaymentAccount(ctx context.Context, address string, txOption gnfdSdkTypes.TxOption) (string, error)

CreatePaymentAccount - Create a new payment account for the given address.

The payment account is used to pay for the storage and read quota fee of objects. When you need to pay for different buckets separately, you can create different payment accounts to do so. Note that the payment account does not have a private key, and only the owner of the payment account can withdraw funds from it. Once the owner revokes permission for withdrawal, the funds in the payment account can only be utilized to cover storage and read quota fees.

- ctx: Context variables for the current API call.

- address: The owner address of the new payment account.

- txOption: The txOption for sending transactions.

- ret1: Return the transaction hash if created successfully, otherwise return empty string.

- ret2: Return error when created failed, otherwise return nil.

func (*Client) CreateStorageProvider added in v0.2.6

func (c *Client) CreateStorageProvider(ctx context.Context, fundingAddr, sealAddr, approvalAddr, gcAddr, maintenanceAddr, blsPubKey, blsProof, endpoint string, depositAmount math.Int, description spTypes.Description, opts types.CreateStorageProviderOptions) (uint64, string, error)

CreateStorageProvider - Submit a CreateStorageProvider proposal and return proposalID, TxHash and err if it has.

- ctx: Context variables for the current API call.

- fundingAddr: The HEX-encoded string of the storage provider funding address, Used to deposit staking tokens and receive earnings.

- sealAddr: The HEX-encoded string of the storage provider seal address, Used to seal the user's object.

- approvalAddr: The HEX-encoded string of the storage provider approval address, Used to approve user's requests.

- gcAddr: The HEX-encoded string of the storage provider gc address, it is a special address for sp and is used by sp to clean up local expired or unwanted storage.

- maintenanceAddr: The HEX-encoded string of the storage provider maintenance address, it is used for SP self-testing while in maintenance mode.

- blsPubKey: The HEX-encoded string of the storage provider bls public key.

- blsProof: The HEX-encoded string of the storage provider bls signature.

- endpoint: Storage Provider endpoint.

- depositAmount: The requested amount for a proposal.

- description: Description for the SP.

- opts: options to specify the SP prices, and proposal details.

- ret1: Proposal ID.

- ret2: Transaction hash return from blockchain.

- ret3: Return error when the request failed, otherwise return nil.

func (*Client) CreateValidator added in v0.2.6

func (c *Client) CreateValidator(ctx context.Context, description stakingtypes.Description, commission stakingtypes.CommissionRates,
	selfDelegation math.Int, validatorAddress string, ed25519PubKey string, selfDelAddr string, relayerAddr string, challengerAddr string, blsKey, blsProof string,
	proposalDepositAmount math.Int, proposalTitle, proposalSummary, proposalMetadata string, txOption gnfdsdktypes.TxOption,
) (uint64, string, error)

CreateValidator - Submit a proposal to Greenfield for creating a validator, and return a proposal id and tx hash.

- ctx: Context variables for the current API call.

- description: The description of the validator, including name and other information.

- commission: The initial commission rates to be used for creating a validator.

- selfDelegation: The amount of self delegation.

- validatorAddress: The address of the validator.

- ed25519PubKey: The ED25519 pubkey of the validator.

- selfDelAddr: The self delegation address.

- relayerAddr: The address for running off-chain relayers.

- challengerAddr: The address for running off-chain challenge service.

- blsKey: The BLS pubkey of the validator.

- blsProof: The proof of possession of the corresponding BLS private key.

- proposalDepositAmount: The amount to deposit to the proposal.

- proposalTitle: The title of the proposal.

- proposalSummary: The summary of the proposal.

- proposalMetadata: The metadata of the proposal.

- txOption: The options for sending the tx.

- ret1: The id of the submitted proposal.

- ret2: Transaction hash return from blockchain.

- ret3: Return error when create validator tx failed, otherwise return nil.

func (*Client) DelegateCreateFolder added in v1.6.0

func (c *Client) DelegateCreateFolder(ctx context.Context, bucketName, objectName string, opts types.PutObjectOptions) error

DelegateCreateFolder send create empty object txn to greenfield chain

func (*Client) DelegatePutObject added in v1.6.0

func (c *Client) DelegatePutObject(ctx context.Context, bucketName, objectName string, objectSize int64,
	reader io.Reader, opts types.PutObjectOptions,
) (err error)

func (*Client) DelegateUpdateObjectContent added in v1.6.0

func (c *Client) DelegateUpdateObjectContent(ctx context.Context, bucketName, objectName string, objectSize int64,
	reader io.Reader, opts types.PutObjectOptions,
) (err error)

func (*Client) DelegateValidator added in v0.2.6

func (c *Client) DelegateValidator(ctx context.Context, validatorAddr string, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)

DelegateValidator - Make a delegation to a validator by the delegator.

- ctx: Context variables for the current API call.

- validatorAddr: The address of the target validator to delegate to.

- amount: The amount of delegation.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when delegation tx failed, otherwise return nil.

func (*Client) DeleteBucket added in v0.2.6

func (c *Client) DeleteBucket(ctx context.Context, bucketName string, opt types.DeleteBucketOption) (string, error)

DeleteBucket - Send DeleteBucket msg to greenfield chain and return txn hash.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to be deleted

- opt: The Options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error if delete bucket failed, otherwise return nil.

func (*Client) DeleteBucketPolicy added in v0.2.6

func (c *Client) DeleteBucketPolicy(ctx context.Context, bucketName string, principalStr types.Principal, opt types.DeletePolicyOption) (string, error)

DeleteBucketPolicy - Delete the bucket policy of the principal.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- principalStr: Indicates the marshaled principal content of greenfield permission types, users can generate it by NewPrincipalWithAccount or NewPrincipalWithGroupId method.

- opt: The option for send delete policy transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) DeleteGroup added in v0.2.6

func (c *Client) DeleteGroup(ctx context.Context, groupName string, opt types.DeleteGroupOption) (string, error)

DeleteGroup - Delete a group on Greenfield blockchain. The sender MUST only be the group owner, group members or others would fail to send this transaction.

Note: Deleting a group will result in granted permission revoked. Members within the group will no longer have access to resources (bucket, object) which granted permission on.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- opt: The options for customizing the transaction

- ret1: Transaction hash return from blockchain.

- ret3: Return error when the request failed, otherwise return nil.

func (*Client) DeleteGroupPolicy added in v0.2.6

func (c *Client) DeleteGroupPolicy(ctx context.Context, groupName string, principalAddr string, opt types.DeletePolicyOption) (string, error)

DeleteGroupPolicy - Delete the group policy of the principal, the sender needs to be the owner of the group

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- principalAddr: The HEX-encoded string of the principal address

- opt: The options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) DeleteObject added in v0.2.6

func (c *Client) DeleteObject(ctx context.Context, bucketName, objectName string, opt types.DeleteObjectOption) (string, error)

DeleteObject - Send DeleteObject msg to greenfield chain and return txn hash.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket which contain the object.

- objectName: The name of the object to be deleted.

- opt: The Options for customizing the DeleteObject transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error if delete bucket failed, otherwise return nil.

func (*Client) DeleteObjectPolicy added in v0.2.6

func (c *Client) DeleteObjectPolicy(ctx context.Context, bucketName, objectName string, principalStr types.Principal, opt types.DeletePolicyOption) (string, error)

DeleteObjectPolicy delete the object policy of the principal

func (*Client) DeleteUserPublicKeyV2 added in v1.6.0

func (c *Client) DeleteUserPublicKeyV2(spEndpoint string, domain string, publicKeys []string) (bool, error)

DeleteUserPublicKeyV2 - Delete user public keys for off-chain-auth v2 This API will delete user public keys for off-chain-auth v2.

- spEndpoint: The sp endpoint where the delete API will send the request.

- domain: The domain that this api will delete for.

- publicKeys: The public keys that the invoker intends to delete

- ret1: Return deletion result.

- ret2: Return error when DeleteUserPublicKeyV2 runs into failure.

func (*Client) Deposit added in v0.2.6

func (c *Client) Deposit(ctx context.Context, toAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (string, error)

Deposit - Deposit BNB to a payment account.

- ctx: Context variables for the current API call.

- toAddress: The address of the stream record to receive the deposit.

- amount: The amount to deposit.

- txOption: The options for sending the tx.

- ret1: The response of Greenfield transaction.

- ret2: Return error when deposit tx failed, otherwise return nil.

func (*Client) DisableRefund added in v0.2.6

func (c *Client) DisableRefund(ctx context.Context, paymentAddress string, txOption gnfdSdkTypes.TxOption) (string, error)

DisableRefund - Disable refund/withdrawal for a payment account.

After disabling withdrawal of a payment account, no more withdrawal can be executed. The action cannot be reverted.

- ctx: Context variables for the current API call.

- paymentAddress: The address of the payment account to disable refund/withdrawal.

- txOption: The options for sending the tx.

- ret1: The response of Greenfield transaction.

- ret2: Return error when disable refund tx failed, otherwise return nil.

func (*Client) EditValidator added in v0.2.6

func (c *Client) EditValidator(ctx context.Context, description stakingtypes.Description,
	newRate *sdktypes.Dec, newMinSelfDelegation *math.Int, newRelayerAddr, newChallengerAddr, newBlsKey, newBlsProof string, txOption gnfdsdktypes.TxOption,
) (string, error)

EditValidator - Edit an existing validator's info.

- ctx: Context variables for the current API call.

- description: The new description of the validator, including name and other information.

- newRate: The new commission rate of the validator.

- newMinSelfDelegation: The value for minimal self delegation amount

- newRelayerAddr: The new address for running off-chain relayers.

- newChallengerAddr: The new address for running off-chain challenge service.

- newBlsKey: The new BLS pubkey of the validator.

- newBlsProof: The new proof of possession of the corresponding BLS private key.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when edit validator tx failed, otherwise return nil.

func (*Client) EnableTrace

func (c *Client) EnableTrace(output io.Writer, onlyTraceErr bool)

EnableTrace support trace error info the request and the response

func (*Client) FGetObject added in v0.2.6

func (c *Client) FGetObject(ctx context.Context, bucketName, objectName, filePath string, opts types.GetObjectOptions) error

FGetObject download s3 object payload adn write the object content into local file specified by filePath

func (*Client) FGetObjectResumable added in v0.2.6

func (c *Client) FGetObjectResumable(ctx context.Context, bucketName, objectName, filePath string, opts types.GetObjectOptions) error

FGetObjectResumable download s3 object payload with resumable download

func (*Client) FPutObject added in v0.2.6

func (c *Client) FPutObject(ctx context.Context, bucketName, objectName, filePath string, opts types.PutObjectOptions) (err error)

FPutObject supports uploading object from local file

func (*Client) FundCommunityPool added in v0.2.6

func (c *Client) FundCommunityPool(ctx context.Context, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)

FundCommunityPool - Sends coins directly from the sender to the community pool.

- ctx: Context variables for the current API call.

- amount: The amount of BNB to send.

- txOption: The txOption for sending transactions.

- ret1: Transaction hash of the transaction.

- ret2: Return error if the transaction failed, otherwise return nil.

func (*Client) GetAccount added in v0.2.6

func (c *Client) GetAccount(ctx context.Context, address string) (authTypes.AccountI, error)

GetAccount - Retrieve on-chain account information for a given address.

- ctx: Context variables for the current API call.

- address: The given address for retrieving.

- ret1: The account interface for the given address.

- ret2: Return error when getting account failed, otherwise return nil.

func (*Client) GetAccountBalance added in v0.2.6

func (c *Client) GetAccountBalance(ctx context.Context, address string) (*sdk.Coin, error)

GetAccountBalance - Get the bank balance for the given address.

- ctx: Context variables for the current API call.

- address: The given address for retrieving.

- ret1: The balance info for the given address, in sdk.Coin format.

- ret2: Return error when getting failed, otherwise return nil.

func (*Client) GetBlockByHeight added in v0.2.6

func (c *Client) GetBlockByHeight(ctx context.Context, height int64) (*bfttypes.Block, error)

GetBlockByHeight - Retrieve the block at the given height from the chain.

- ctx: Context variables for the current API call.

- height: The block height.

- ret1: The boolean value which indicates whether the node has caught up the latest block.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetBlockResultByHeight added in v0.2.6

func (c *Client) GetBlockResultByHeight(ctx context.Context, height int64) (*ctypes.ResultBlockResults, error)

GetBlockResultByHeight - Retrieve the block result at the given height from the chain.

- ctx: Context variables for the current API call.

- height: The block height.

- ret1: The boolean value which indicates whether the node has caught up the latest block.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetBucketMigrationProgress added in v1.2.0

func (c *Client) GetBucketMigrationProgress(ctx context.Context, bucketName string, destSP uint32) (types.MigrationProgress, error)

GetBucketMigrationProgress return the status of object including the uploading progress

func (*Client) GetBucketPolicy added in v0.2.6

func (c *Client) GetBucketPolicy(ctx context.Context, bucketName string, principalAddr string) (*permTypes.Policy, error)

GetBucketPolicy - Get the bucket policy info of the user specified by principalAddr.

- bucketName: The bucket name identifies the bucket.

- principalAddr: The HEX-encoded string of the principal address.

- ret1: The bucket policy info defined on greenfield.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetBucketPolicyOfGroup added in v0.2.6

func (c *Client) GetBucketPolicyOfGroup(ctx context.Context, bucketName string, groupId uint64) (*permTypes.Policy, error)

GetBucketPolicyOfGroup - Get the bucket policy info of the group.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- groupId: The group id identity the group.

- ret1: The bucket policy.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetBucketReadQuota added in v0.2.6

func (c *Client) GetBucketReadQuota(ctx context.Context, bucketName string) (types.QuotaInfo, error)

GetBucketReadQuota - Query the quota info of the specific bucket of current month.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- ret1: The info of quota which contains the consumed quota, the charged quota and free quota info of the bucket

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetChallengeInfo added in v0.2.6

func (c *Client) GetChallengeInfo(ctx context.Context, objectID string, pieceIndex, redundancyIndex int, opts types.GetChallengeInfoOptions) (types.ChallengeResult, error)

GetChallengeInfo - Send request to storage provider, and get the integrity hash and data stored on the sp.

This api is used for validators to judge whether a challenge valid or not. A validator's challenger account should be provided when constructing the client, otherwise the authorization will fail.

- ctx: Context variables for the current API call.

- objectID: The id of object being challenged.

- pieceIndex: The index of the segment/piece of the object.

- redundancyIndex: The redundancy index of the object, actually it also stands for which storage provider is being challenged and should response to this call - -1 stands for the primary storage provider.

- opts: Options to define the storage provider address and its endpoint. If the storage provider address or endpoint is not set in the options, the storage provider endpoint will be routed by redundancyIndex.

- ret1: The challenge info includes the piece data, piece hash roots and integrity hash corresponding to the accessed storage provider.

- ret2: Return error when getting challenge info failed, otherwise return nil.

func (*Client) GetChannelReceiveSequence added in v0.2.6

func (c *Client) GetChannelReceiveSequence(ctx context.Context, destChainId sdk.ChainID, channelId uint32) (uint64, error)

GetChannelReceiveSequence - Get the next receive sequence for a channel

- ctx: Context variables for the current API call.

- destChainId: The destination chain id.

- channelId: The channel id to query.

- ret1: Send sequence of the channel.

- ret2: Return error if the query failed, otherwise return nil.

func (*Client) GetChannelSendSequence added in v0.2.6

func (c *Client) GetChannelSendSequence(ctx context.Context, destChainId sdk.ChainID, channelId uint32) (uint64, error)

GetChannelSendSequence - Get the next send sequence for a channel

- ctx: Context variables for the current API call.

- destChainId: The destination chain id.

- channelId: The channel id to query.

- ret1: Send sequence of the channel.

- ret2: Return error if the query failed, otherwise return nil.

func (*Client) GetCommit added in v0.2.6

func (c *Client) GetCommit(ctx context.Context, height int64) (*ctypes.ResultCommit, error)

GetCommit - Get the block commit detail.

- ctx: Context variables for the current API call.

- height: The block height.

- ret1: The commit result.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetCreateBucketApproval added in v0.2.6

func (c *Client) GetCreateBucketApproval(ctx context.Context, createBucketMsg *storageTypes.MsgCreateBucket) (*storageTypes.MsgCreateBucket, error)

GetCreateBucketApproval - Send create bucket approval request to SP and returns the signature info for the approval of preCreating resources.

- ctx: Context variables for the current API call.

- createBucketMsg: The msg of create bucket which defined by the greenfield chain.

- ret1: The msg of create bucket which contain the approval signature from the storage provider

- ret2: Return error when get approval failed, otherwise return nil.

func (*Client) GetCreateObjectApproval deprecated added in v0.2.6

func (c *Client) GetCreateObjectApproval(ctx context.Context, createObjectMsg *storageTypes.MsgCreateObject) (*storageTypes.MsgCreateObject, error)

Deprecated: GetCreateObjectApproval returns the signature info for the approval of preCreating resources

func (*Client) GetCrossChainPackage added in v0.2.6

func (c *Client) GetCrossChainPackage(ctx context.Context, destChainId sdk.ChainID, channelId uint32, sequence uint64) ([]byte, error)

GetCrossChainPackage - Get the cross-chain package by sequence.

- ctx: Context variables for the current API call.

- destChainId: The destination chain id.

- channelId: The channel id to query.

- sequence: The sequence of the cross-chain package.

- ret1: The bytes of the cross-chain package.

- ret2: Return error if the query failed, otherwise return nil.

func (*Client) GetDefaultAccount

func (c *Client) GetDefaultAccount() (*types.Account, error)

GetDefaultAccount - Get the default account of the Client.

- ret1: The default account of the Client.

- ret2: Return error when default account doesn't exist, otherwise return nil.

func (*Client) GetGlobalSpStorePrice added in v0.2.6

func (c *Client) GetGlobalSpStorePrice(ctx context.Context) (*spTypes.GlobalSpStorePrice, error)

GetGlobalSpStorePrice - Get the global storage price details, including update time and store price.

- ctx: Context variables for the current API call.

- ret1: The global storage provider price detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetGroupPolicy added in v0.2.6

func (c *Client) GetGroupPolicy(ctx context.Context, groupName string, principalAddr string) (*permTypes.Policy, error)

GetGroupPolicy - Get the group policy info of the user.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- principalAddr: The HEX-encoded string of the principal address.

- ret1: The group policy.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetInturnRelayer added in v0.2.6

GetInturnRelayer - Get the in-turn relayer bls public key and its relay interval

- ctx: Context variables for the current API call.

- req: The request to query in-turn relayer.

- ret1: The response of the `QueryInturnRelayerRequest` query.

- ret2: Return error if the query failed, otherwise return nil.

func (*Client) GetLatestBlock added in v0.2.6

func (c *Client) GetLatestBlock(ctx context.Context) (*bfttypes.Block, error)

GetLatestBlock - Get the latest block from the chain.

- ctx: Context variables for the current API call.

- ret1: The block result.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetLatestBlockHeight added in v0.2.6

func (c *Client) GetLatestBlockHeight(ctx context.Context) (int64, error)

GetLatestBlockHeight - Get the height of the latest block from the chain.

- ctx: Context variables for the current API call.

- ret1: The block height.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetMigrateBucketApproval added in v0.2.6

func (c *Client) GetMigrateBucketApproval(ctx context.Context, migrateBucketMsg *storageTypes.MsgMigrateBucket) (*storageTypes.MsgMigrateBucket, error)

GetMigrateBucketApproval - Send migrate get approval request to the storage provider and return the signed MsgMigrateBucket by SP.

- ctx: Context variables for the current API call.

- migrateBucketMsg: Indicates msg of migrating bucket which defined by greenfield

- ret1: The msg of migrating bucket which contain the approval signature from the storage provider.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetModuleAccountByName added in v0.2.6

func (c *Client) GetModuleAccountByName(ctx context.Context, name string) (authTypes.ModuleAccountI, error)

GetModuleAccountByName - Get module account by module name.

- ctx: Context variables for the current API call.

- name: Module name.

- ret1: The account interface for the given module name.

- ret2: Return error when getting failed, otherwise return nil.

func (*Client) GetModuleAccounts added in v0.2.6

func (c *Client) GetModuleAccounts(ctx context.Context) ([]authTypes.ModuleAccountI, error)

GetModuleAccounts - Get all module accounts.

- ctx: Context variables for the current API call.

- ret1: The account interface lists for all the module accounts.

- ret2: Return error when getting failed, otherwise return nil.

func (*Client) GetNextNonce added in v0.2.6

func (c *Client) GetNextNonce(spEndpoint string) (string, error)

GetNextNonce - Get the nonce value by giving user account and domain.

- spEndpoint: The sp endpoint where the client means to get the next nonce

- ret1: The next nonce value for the Client if it needs to register a new EdDSA public key

- ret2: Return error when getting next nonce failed, otherwise return nil.

func (*Client) GetNodeInfo added in v0.2.6

func (c *Client) GetNodeInfo(ctx context.Context) (*p2p.DefaultNodeInfo, *tmservice.VersionInfo, error)

GetNodeInfo - Get the current node info of the greenfield that the Client is connected to.

- ctx: Context variables for the current API call.

- ret1: The Node info.

- ret2: The Version info.

- ret3: Return error when the request failed, otherwise return nil.

func (*Client) GetObject added in v0.2.6

func (c *Client) GetObject(ctx context.Context, bucketName, objectName string,
	opts types.GetObjectOptions,
) (io.ReadCloser, types.ObjectStat, error)

GetObject download s3 object payload and return the related object info

func (*Client) GetObjectPolicy added in v0.2.6

func (c *Client) GetObjectPolicy(ctx context.Context, bucketName, objectName string, principalAddr string) (*permTypes.Policy, error)

GetObjectPolicy get the object policy info of the user specified by principalAddr

func (*Client) GetObjectPolicyOfGroup added in v0.2.6

func (c *Client) GetObjectPolicyOfGroup(ctx context.Context, bucketName, objectName string, groupId uint64) (*permTypes.Policy, error)

GetObjectPolicyOfGroup - Get the object policy info of the group.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- objectName: The object name identifies the object.

- groupId: The group id identity the group.

- ret1: The object policy

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetObjectUploadProgress added in v0.2.6

func (c *Client) GetObjectUploadProgress(ctx context.Context, bucketName, objectName string) (string, error)

GetObjectUploadProgress return the status of object including the uploading progress

func (*Client) GetParams added in v0.2.6

func (c *Client) GetParams() (storageTypes.Params, error)

GetParams query and return the data shards, parity shards and segment size of redundancy configuration on chain

func (*Client) GetPaymentAccount added in v0.2.6

func (c *Client) GetPaymentAccount(ctx context.Context, address string) (*paymentTypes.PaymentAccount, error)

GetPaymentAccount - Get payment account by the payment account's address.

- ctx: Context variables for the current API call.

- address: The given payment account address for retrieving.

- ret1: The payment account info for the given address.

- ret2: Return error when getting failed, otherwise return nil.

func (*Client) GetPaymentAccountFlowRateLimit added in v1.6.0

func (c *Client) GetPaymentAccountFlowRateLimit(ctx context.Context, paymentAddr, bucketOwner sdk.AccAddress, bucketName string) (*storageTypes.QueryPaymentAccountBucketFlowRateLimitResponse, error)

GetPaymentAccountFlowRateLimit - Get the flow rate limit of the bucket.

- ctx: Context variables for the current API call.

- paymentAddr: The payment address from which deduct the cost of bucket storage or quota.

- bucketOwner: The owner of the bucket.

- bucketName: The name of the bucket.

- ret1: The flow rate limit of the bucket.

- ret2: Return error if get flow rate limit failed, otherwise return nil.

func (*Client) GetPaymentAccountsByOwner added in v0.2.6

func (c *Client) GetPaymentAccountsByOwner(ctx context.Context, owner string) ([]*paymentTypes.PaymentAccount, error)

GetPaymentAccountsByOwner - Get all payment accounts owned by the given owner address.

- ctx: Context variables for the current API call.

- address: The given owner account address for retrieving.

- ret1: The payment accounts list for the given owner address.

- ret2: Return error when getting failed, otherwise return nil.

func (*Client) GetPieceHashRoots added in v0.2.6

func (c *Client) GetPieceHashRoots(reader io.Reader, segSize int64,
	dataShards, parityShards int,
) ([]byte, [][]byte, int64, storageTypes.RedundancyType, error)

GetPieceHashRoots returns primary pieces, secondary piece Hash roots list and the object size It is used for generate meta of object on the chain

func (*Client) GetProposal added in v0.2.6

func (c *Client) GetProposal(ctx context.Context, proposalID uint64) (*govTypesV1.Proposal, error)

GetProposal - Get the proposal by proposal id.

- ctx: Context variables for the current API call.

- proposalID: The proposal id to vote for.

- ret1: Proposal by the queried proposal id.

- ret2: Return error if the query failed, otherwise return nil.

func (*Client) GetQuotaUpdateTime added in v0.2.6

func (c *Client) GetQuotaUpdateTime(ctx context.Context, bucketName string) (int64, error)

GetQuotaUpdateTime - Query the update time stamp of the bucket quota info.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- ret1: The update time stamp.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetRedundancyParams added in v0.2.6

func (c *Client) GetRedundancyParams() (uint32, uint32, uint64, error)

GetRedundancyParams query and return the data shards, parity shards and segment size of redundancy configuration on chain

func (*Client) GetStatus added in v0.2.6

func (c *Client) GetStatus(ctx context.Context) (*ctypes.ResultStatus, error)

GetStatus - Get the status of connected Node.

- ctx: Context variables for the current API call.

- ret1: The detail of Node status.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetStoragePrice added in v0.2.6

func (c *Client) GetStoragePrice(ctx context.Context, spAddr string) (*spTypes.SpStoragePrice, error)

GetStoragePrice - Get the storage price details for a particular storage provider, including update time, read price, store price and .etc.

- ctx: Context variables for the current API call.

- spAddr: The HEX-encoded string of the storage provider address.

- ret1: The specified storage provider price detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetStorageProviderInfo added in v0.2.6

func (c *Client) GetStorageProviderInfo(ctx context.Context, spAddr sdk.AccAddress) (*spTypes.StorageProvider, error)

GetStorageProviderInfo - Get the specified storage providers info on chain.

- ctx: Context variables for the current API call.

- spAddr: The HEX-encoded string of the storage provider address.

- ret1: The Storage provider detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetStreamRecord added in v0.2.6

func (c *Client) GetStreamRecord(ctx context.Context, streamAddress string) (*paymentTypes.StreamRecord, error)

GetStreamRecord - Retrieve stream record information for a given stream address.

- ctx: Context variables for the current API call.

- streamAddress: The address of the stream record to be queried.

- ret1: The stream record information, including balances and net flow rate.

- ret2: Return error when getting challenge info failed, otherwise return nil.

func (*Client) GetSyncing added in v0.2.6

func (c *Client) GetSyncing(ctx context.Context) (bool, error)

GetSyncing - Retrieve the syncing status of the node.

- ctx: Context variables for the current API call.

- ret1: The boolean value which indicates whether the node has caught up the latest block.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GetValidatorSet added in v0.2.6

func (c *Client) GetValidatorSet(ctx context.Context) (int64, []*bfttypes.Validator, error)

GetValidatorSet - Retrieve the latest validator set from the chain.

- ctx: Context variables for the current API call.

- ret1: The latest height of block that validators set info retrieved from.

- ret2: The list of validators.

- ret3: Return error when the request failed, otherwise return nil.

func (*Client) GetValidatorsByHeight added in v0.2.6

func (c *Client) GetValidatorsByHeight(ctx context.Context, height int64) ([]*bfttypes.Validator, error)

GetValidatorsByHeight - Retrieve the validator set at a given block height from the chain.

- ctx: Context variables for the current API call.

- height: The block height.

- ret1: The list of validators.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) GrantAllowance added in v0.2.6

func (c *Client) GrantAllowance(ctx context.Context, granteeAddr string, allowance feegrant.FeeAllowanceI, txOption gnfdsdktypes.TxOption) (string, error)

GrantAllowance provides a generic way to grant different types of allowance(BasicAllowance, PeriodicAllowance, AllowedMsgAllowance), the user needs to construct the desired type of allowance

func (*Client) GrantBasicAllowance added in v0.2.6

func (c *Client) GrantBasicAllowance(ctx context.Context, granteeAddr string, feeAllowanceAmount math.Int, expiration *time.Time, txOption gnfdsdktypes.TxOption) (string, error)

GrantBasicAllowance grants the grantee the BasicAllowance with specified amount and expiration.

func (*Client) GrantDelegationForValidator added in v0.2.6

func (c *Client) GrantDelegationForValidator(ctx context.Context, delegationAmount math.Int, txOption gnfdsdktypes.TxOption) (string, error)

GrantDelegationForValidator - Grant the gov module for proposal execution.

- ctx: Context variables for the current API call.

- delegationAmount: The amount to grant.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when grant delegation tx failed, otherwise return nil.

func (*Client) GrantDepositForStorageProvider added in v0.2.6

func (c *Client) GrantDepositForStorageProvider(ctx context.Context, spAddr string, depositAmount math.Int, opts types.GrantDepositForStorageProviderOptions) (string, error)

GrantDepositForStorageProvider - Grant transaction to allow Gov module account to deduct the specified number of tokens.

- ctx: Context variables for the current API call.

- spAddr: The HEX-encoded string of the storage provider address.

- depositAmount: The allowance of fee that allows grantee to spend up from the account of Granter.

- opts: The options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) HeadBucket added in v0.2.6

func (c *Client) HeadBucket(ctx context.Context, bucketName string) (*storageTypes.BucketInfo, error)

HeadBucket - query the bucketInfo on chain by bucket name, return the bucket info if exists.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to query.

- ret1: The bucket specific metadata information, including Visibility, payment address, charged quota and so on.

- ret2: Return error if bucket not exist, otherwise return nil.

func (*Client) HeadBucketByID added in v0.2.6

func (c *Client) HeadBucketByID(ctx context.Context, bucketID string) (*storageTypes.BucketInfo, error)

HeadBucketByID - query the bucketInfo on chain by the bucket id, return the bucket info if exists.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to query.

- ret1: The bucket specific metadata information, including Visibility, payment address, charged quota and so on.

- ret2: Return error if bucket not exist, otherwise return nil.

func (*Client) HeadGroup added in v0.2.6

func (c *Client) HeadGroup(ctx context.Context, groupName string, groupOwnerAddr string) (*storageTypes.GroupInfo, error)

HeadGroup - Query the groupInfo on chain, return the group info if exists otherwise error.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- groupOwnerAddr: The HEX-encoded string of the group owner address.

- ret1: The group info details

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) HeadGroupMember added in v0.2.6

func (c *Client) HeadGroupMember(ctx context.Context, groupName string, groupOwnerAddr, headMemberAddr string) bool

HeadGroupMember - Query the group member info on chain.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- groupOwnerAddr: The HEX-encoded string of the group owner address.

- eadMemberAddr: The HEX-encoded string of the group member address

- ret: The boolean value indicates whether the group member exists

func (*Client) HeadObject added in v0.2.6

func (c *Client) HeadObject(ctx context.Context, bucketName, objectName string) (*types.ObjectDetail, error)

HeadObject query the objectInfo on chain to check th object id, return the object info if exists return err info if object not exist

func (*Client) HeadObjectByID added in v0.2.6

func (c *Client) HeadObjectByID(ctx context.Context, objID string) (*types.ObjectDetail, error)

HeadObjectByID query the objectInfo on chain by object id, return the object info if exists return err info if object not exist

func (*Client) ImpeachValidator added in v0.2.6

func (c *Client) ImpeachValidator(ctx context.Context, validatorAddr string, proposalDepositAmount math.Int, proposalTitle, proposalSummary, proposalMetadata string, txOption gnfdsdktypes.TxOption) (uint64, string, error)

ImpeachValidator - Impeach a validator.

- ctx: Context variables for the current API call.

- validatorAddr: The address of the validator to impeach.

- proposalDepositAmount: The amount of BNB to deposit to the proposal.

- proposalTitle: The title of the proposal.

- proposalSummary: The summary of the proposal.

- proposalMetadata: The metadata of the proposal.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when unjail validator tx failed, otherwise return nil.

func (*Client) InturnAttestationSubmitter added in v0.2.6

InturnAttestationSubmitter - Query the in-turn validator to submit challenge attestation.

Greenfield will only allow the in-turn validator to submit challenge attestations.

- ctx: Context variables for the current API call.

- req: The request to query in-turn attestation submitter.

- ret1: The in-turn validator information, including BLS pubkey of the validator and timeframe to submit attestations.

- ret2: Return error when getting in-turn attestation submitter failed, otherwise return nil.

func (*Client) IsBucketPermissionAllowed added in v0.2.6

func (c *Client) IsBucketPermissionAllowed(ctx context.Context, userAddr string,
	bucketName string, action permTypes.ActionType,
) (permTypes.Effect, error)

IsBucketPermissionAllowed - Check if the permission of bucket is allowed to the user.

- ctx: Context variables for the current API call.

- userAddr: The HEX-encoded string of the user address

- bucketName: The bucket name identifies the bucket.

- action: Indicates the permission corresponding to which type of action needs to be verified

- ret1: Return EFFECT_ALLOW if the permission is allowed and EFFECT_DENY if the permission is denied

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) IsObjectPermissionAllowed added in v0.2.6

func (c *Client) IsObjectPermissionAllowed(ctx context.Context, userAddr string,
	bucketName, objectName string, action permTypes.ActionType,
) (permTypes.Effect, error)

IsObjectPermissionAllowed check if the permission of the object is allowed to the user

func (*Client) LatestAttestedChallenges added in v0.2.6

LatestAttestedChallenges - Query the latest attested challenges (including heartbeat challenges).

Greenfield will not keep the results of all challenges, only the latest ones will be kept and old ones will be pruned.

- ctx: Context variables for the current API call.

- req: The request to query latest attested challenges.

- ret1: The latest attested challenges, including challenge id and attestation result.

- ret2: Return error when getting latest attested challenges failed, otherwise return nil.

func (*Client) LeaveGroup added in v0.2.6

func (c *Client) LeaveGroup(ctx context.Context, groupName string, groupOwnerAddr string, opt types.LeaveGroupOption) (string, error)

LeaveGroup - Leave a group. A group member initially leaves a group.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- groupOwnerAddr: The HEX-encoded string of the group owner address.

- opt: The options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListBucketReadRecord added in v0.2.6

func (c *Client) ListBucketReadRecord(ctx context.Context, bucketName string, opts types.ListReadRecordOptions) (types.QuotaRecordInfo, error)

ListBucketReadRecord - List the download record info of the specific bucket of the current month.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- opts: Indicates the start timestamp of return read records and the max number of return items

- ret1: The read record info of the bucket returned by SP.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListBuckets added in v0.2.6

ListBuckets - Lists the bucket info of the user.

If the opts.Account is not set, the user is default set as the sender.

- ctx: Context variables for the current API call.

- opts: The options to set the meta to list the bucket

- ret1: The result of list bucket under specific user address

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListBucketsByBucketID added in v0.2.6

func (c *Client) ListBucketsByBucketID(ctx context.Context, bucketIds []uint64, opts types.EndPointOptions) (types.ListBucketsByBucketIDResponse, error)

ListBucketsByBucketID - List buckets by bucket ids.

By inputting a collection of bucket IDs, we can retrieve the corresponding bucket data. If the bucket is nonexistent or has been deleted, a null value will be returned

- ctx: Context variables for the current API call.

- bucketIds: The list of bucket ids.

- opts: The options to set the meta to list buckets by bucket id.

- ret1: The result of bucket info map by given bucket ids.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListBucketsByPaymentAccount added in v0.2.6

func (c *Client) ListBucketsByPaymentAccount(ctx context.Context, paymentAccount string, opts types.ListBucketsByPaymentAccountOptions) (types.ListBucketsByPaymentAccountResult, error)

ListBucketsByPaymentAccount - List bucket info by payment account.

By inputting a collection of bucket IDs, we can retrieve the corresponding bucket data. If the bucket is nonexistent or has been deleted, a null value will be returned

- ctx: Context variables for the current API call.

- paymentAccount: Payment account defines the address of payment account.

- opts: The options to set the meta to list buckets by payment account.

- ret1: The result of bucket info under specific payment account.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListGroup added in v0.2.6

func (c *Client) ListGroup(ctx context.Context, name, prefix string, opts types.ListGroupsOptions) (types.ListGroupsResult, error)

ListGroup - Get the group list by name and prefix. It provides fuzzy searches by inputting a specific name and prefix.

- prefix: The start of the search pattern. The system will only return groups that start with this prefix.

- name: The ending of the search pattern.

- ret1: The groups response.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListGroupMembers added in v0.2.6

func (c *Client) ListGroupMembers(ctx context.Context, groupID int64, opts types.GroupMembersPaginationOptions) (*types.GroupMembersResult, error)

ListGroupMembers - List members within a group, including those for which the user's expiration time has already elapsed.

- groupId: The group id identifies a group.

- ret1: Group members detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListGroupsByAccount added in v0.2.6

func (c *Client) ListGroupsByAccount(ctx context.Context, opts types.GroupsPaginationOptions) (*types.GroupsResult, error)

ListGroupsByAccount - List groups that a user has joined, including those which the user's expiration time has already elapsed

- ctx: Context variables for the current API call.

- opts: The query option, By default, the user is the sender. Other users can be set using the option

- ret1: Groups details.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListGroupsByGroupID added in v0.2.6

func (c *Client) ListGroupsByGroupID(ctx context.Context, groupIDs []uint64, opts types.EndPointOptions) (types.ListGroupsByGroupIDResponse, error)

ListGroupsByGroupID - List groups by group ids.

By inputting a collection of group IDs, we can retrieve the corresponding object data. If the group is nonexistent or has been deleted, a null value will be returned

- ctx: Context variables for the current API call.

- groupIDs: The list of group ids.

- opts: The options to set the meta to list groups by group id.

- ret1: The result of group info map by given group ids.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListGroupsByOwner added in v0.2.6

func (c *Client) ListGroupsByOwner(ctx context.Context, opts types.GroupsOwnerPaginationOptions) (*types.GroupsResult, error)

ListGroupsByOwner - List groups owned by the specified user, including those for which the user's expiration time has already elapsed

- ctx: Context variables for the current API call.

- opts: The query option, By default, the user is the sender. Other users can be set using the option

- ret1: Groups details.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListObjectPolicies added in v0.2.6

func (c *Client) ListObjectPolicies(ctx context.Context, objectName, bucketName string, actionType uint32, opts types.ListObjectPoliciesOptions) (types.ListObjectPoliciesResponse, error)

ListObjectPolicies - List object policies by object info and action type.

If the limit is set to 0, it will default to 50. If the limit exceeds 1000, only 1000 records will be returned.

- ctx: Context variables for the current API call.

- objectName: The object name identifies the object.

- bucketName: The bucket name identifies the bucket.

  • actionType: The action type defines the requested action type of permission. | Value | Description | | ----- | -------------------------- | | 0 | ACTION_UNSPECIFIED |89 | 1 | ACTION_UPDATE_BUCKET_INFO | | 2 | ACTION_DELETE_BUCKET | | 3 | ACTION_CREATE_OBJECT | | 4 | ACTION_DELETE_OBJECT | | 5 | ACTION_COPY_OBJECT | | 6 | ACTION_GET_OBJECT | | 7 | ACTION_EXECUTE_OBJECT | | 8 | ACTION_LIST_OBJECT | | 9 | ACTION_UPDATE_GROUP_MEMBER | | 10 | ACTION_DELETE_GROUP | | 11 | ACTION_UPDATE_OBJECT_INFO | | 12 | ACTION_UPDATE_GROUP_EXTRA | | 99 | ACTION_TYPE_ALL |

- opts: The options to set the meta to list object policies

- ret1: The result of object policy meta

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListObjects added in v0.2.6

func (c *Client) ListObjects(ctx context.Context, bucketName string, opts types.ListObjectsOptions) (types.ListObjectsResult, error)

ListObjects - Lists the object info of the bucket. If opts.ShowRemovedObject set to false, these objects will be skipped.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- opts: The options to set the meta to list the objects

- ret1: The result of list objects under specific bucket

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListObjectsByObjectID added in v0.2.6

func (c *Client) ListObjectsByObjectID(ctx context.Context, objectIds []uint64, opts types.EndPointOptions) (types.ListObjectsByObjectIDResponse, error)

ListObjectsByObjectID - List objects by object ids. If opts.ShowRemovedObject set to false, these objects will be skipped.

By inputting a collection of object IDs, we can retrieve the corresponding object data. If the object is nonexistent or has been deleted, a null value will be returned

- ctx: Context variables for the current API call.

- objectIds: The list of object ids.

- opts: The options to set the meta to list objects by object id.

- ret1: The result of object info map by given object ids.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListStorageProviders added in v0.2.6

func (c *Client) ListStorageProviders(ctx context.Context, isInService bool) ([]spTypes.StorageProvider, error)

ListStorageProviders - List the storage providers info on chain.

- ctx: Context variables for the current API call.

- isInService: The boolean value indicates if only display the sp with STATUS_IN_SERVICE status.

- ret1: The global storage provider price detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) ListUserPaymentAccounts added in v0.2.6

ListUserPaymentAccounts - List payment info by a user address.

- ctx: Context variables for the current API call.

- opts: The options to define the user address for querying.

- ret1: The response of streams records for the user address.

- ret2: Return error when querying payment accounts failed, otherwise return nil.

func (*Client) ListUserPublicKeyV2 added in v1.6.0

func (c *Client) ListUserPublicKeyV2(spEndpoint string, domain string) ([]string, error)

ListUserPublicKeyV2 - List user public keys for off-chain-auth v2 This API will list user public keys for off-chain-auth v2. So that users/dapp can know what public keys have already been registered in a given sp.

- spEndpoint: The sp endpoint where the list API will send the request.

- domain: The domain that this list api will query for.

- ret1: The public key list for the given sp/account/domain. The account will be the client's defaultAccount.

- ret2: Return error when ListUserPublicKeyV2 runs into failure.

func (*Client) ListValidators added in v0.2.6

func (c *Client) ListValidators(ctx context.Context, status string) (*stakingtypes.QueryValidatorsResponse, error)

ListValidators - List all validators (if status is empty string) or validators filtered by status.

- ctx: Context variables for the current API call.

- status: The status for filtering validators. It can be "BOND_STATUS_UNBONDED", "BOND_STATUS_UNBONDING" or "BOND_STATUS_BONDED".

- ret1: The information of validators.

- ret2: Return error when getting validators failed, otherwise return nil.

func (*Client) MigrateBucket added in v0.2.6

func (c *Client) MigrateBucket(ctx context.Context, bucketName string, dstPrimarySPID uint32, opts types.MigrateBucketOptions) (string, error)

MigrateBucket - Get approval of migrating from SP, send the signed migrate bucket msg to greenfield chain and return the txn hash.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to be migrated.

- dstPrimarySPID: The sp id of the migration target SP.

- opt: The options of send transaction of migration bucket

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request of getting approval or sending transaction failed, otherwise return nil.

func (*Client) MirrorBucket added in v0.2.6

func (c *Client) MirrorBucket(ctx context.Context, destChainId sdk.ChainID, bucketId math.Uint, bucketName string, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)

MirrorBucket - Mirror the bucket to BSC as an NFT

- ctx: Context variables for the current API call.

- destChainId: The destination chain id.

- bucketId: The bucket id to mirror.

- bucketName: The bucket name.

- txOption: The txOption for sending transactions.

- ret1: Transaction response from Greenfield.

- ret2: Return error if the transaction failed, otherwise return nil.

func (*Client) MirrorGroup added in v0.2.6

func (c *Client) MirrorGroup(ctx context.Context, destChainId sdk.ChainID, groupId math.Uint, groupName string, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)

MirrorGroup - Mirror the group to BSC as an NFT

- ctx: Context variables for the current API call.

- destChainId: The destination chain id.

- groupId: The group id to mirror.

- groupName: The group name.

- txOption: The txOption for sending transactions.

- ret1: Transaction response from Greenfield.

- ret2: Return error if the transaction failed, otherwise return nil.

func (*Client) MirrorObject added in v0.2.6

func (c *Client) MirrorObject(ctx context.Context, destChainId sdk.ChainID, objectId math.Uint, bucketName, objectName string, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)

MirrorObject - Mirror the object to BSC as an NFT

- ctx: Context variables for the current API call.

- destChainId: The destination chain id.

- objectId: The object id to mirror.

- bucketName: The bucket name.

- objectName: The object name.

- txOption: The txOption for sending transactions.

- ret1: Transaction response from Greenfield.

- ret2: Return error if the transaction failed, otherwise return nil.

func (*Client) MultiTransfer added in v0.2.6

func (c *Client) MultiTransfer(ctx context.Context, details []types.TransferDetail, txOption gnfdSdkTypes.TxOption) (string, error)

MultiTransfer - Transfer BNB from sender to multiple receivers.

- ctx: Context variables for the current API call.

- details: The receiver address and transfer amount list.

- txOption: The txOption for sending transactions.

- ret1: Return the transaction hash if transferred successfully, otherwise return empty string.

- ret2: Return error if transferred failed, otherwise return nil.

func (*Client) MustGetDefaultAccount added in v0.2.6

func (c *Client) MustGetDefaultAccount() *types.Account

MustGetDefaultAccount - Get the default account of the Client, panic when account not found.

- ret1: The default account of the Client.

func (*Client) OffChainAuthSign added in v0.2.6

func (c *Client) OffChainAuthSign(unsignedBytes []byte) string

OffChainAuthSign - Generate EdDSA private key according to a preconfigured seed and then make the signature for given input.

- unsignedBytes: The content which needs to be signed by client's EdDSA private key

- ret1: The signature made by EdDSA private key of the Client.

func (*Client) OffChainAuthSignV2 added in v1.6.0

func (c *Client) OffChainAuthSignV2(unsignedBytes []byte) string

OffChainAuthSignV2 - Generate EdDSA private key according to a preconfigured seed and then make the signature for given input. OffChainAuthSignV2 use ed25519 curve.

- unsignedBytes: The content which needs to be signed by client's EdDSA private key

- ret1: The signature made by EdDSA private key of the Client.

func (*Client) PutBucketPolicy added in v0.2.6

func (c *Client) PutBucketPolicy(ctx context.Context, bucketName string, principalStr types.Principal,
	statements []*permTypes.Statement, opt types.PutPolicyOption,
) (string, error)

PutBucketPolicy - Apply bucket policy to the principal, return the txn hash.

- ctx: Context variables for the current API call.

- bucketName: The bucket name identifies the bucket.

- principalStr: Indicates the marshaled principal content of greenfield permission types, users can generate it by NewPrincipalWithAccount or NewPrincipalWithGroupId method.

- statements: Policies outline the specific details of permissions, including the Effect, ActionList, and Resources.

- opt: The options for customizing the policy expiration time and transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) PutGroupPolicy added in v0.2.6

func (c *Client) PutGroupPolicy(ctx context.Context, groupName string, principalAddr string,
	statements []*permTypes.Statement, opt types.PutPolicyOption,
) (string, error)

PutGroupPolicy - Apply group policy to user specified by principalAddr, the sender needs to be the owner of the group.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- principalAddr: The HEX-encoded string of the principal address.

- statements: Policies outline the specific details of permissions, including the Effect, ActionList, and Resources.

- opt: The options for customizing the policy expiration time and transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) PutObject added in v0.2.6

func (c *Client) PutObject(ctx context.Context, bucketName, objectName string, objectSize int64,
	reader io.Reader, opts types.PutObjectOptions,
) (err error)

PutObject supports the second stage of uploading the object to bucket. txnHash should be the str which hex.encoding from txn hash bytes

func (*Client) PutObjectPolicy added in v0.2.6

func (c *Client) PutObjectPolicy(ctx context.Context, bucketName, objectName string, principalStr types.Principal,
	statements []*permTypes.Statement, opt types.PutPolicyOption,
) (string, error)

PutObjectPolicy apply object policy to the principal, return the txn hash

func (*Client) QueryAllowance added in v0.2.6

func (c *Client) QueryAllowance(ctx context.Context, granterAddr, granteeAddr string) (*feegrant.Grant, error)

func (*Client) QueryAllowances added in v0.2.6

func (c *Client) QueryAllowances(ctx context.Context, granteeAddr string) ([]*feegrant.Grant, error)

func (*Client) QueryBasicAllowance added in v0.2.6

func (c *Client) QueryBasicAllowance(ctx context.Context, granterAddr, granteeAddr string) (*feegrant.BasicAllowance, error)

QueryBasicAllowance queries the BasicAllowance

func (*Client) QueryGranterAllowances added in v0.2.6

func (c *Client) QueryGranterAllowances(ctx context.Context, granterAddr string) ([]*feegrant.Grant, error)

func (*Client) QuerySpAvailableGlobalVirtualGroupFamilies added in v1.6.0

func (c *Client) QuerySpAvailableGlobalVirtualGroupFamilies(ctx context.Context, spID uint32) ([]uint32, error)

QuerySpAvailableGlobalVirtualGroupFamilies - Query the virtual group family IDs by SP ID.

Virtual group family(VGF) serve as a means of grouping global virtual groups. Each bucket must be associated with a unique global virtual group family and cannot cross families.

- ctx: Context variables for the current API call.

- spID: Identify the storage provider.

- ret1: The virtual group family detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) QuerySpOptimalGlobalVirtualGroupFamily added in v1.6.0

func (c *Client) QuerySpOptimalGlobalVirtualGroupFamily(ctx context.Context, spID uint32, strategy types.PickVGFStrategy) (uint32, error)

QuerySpOptimalGlobalVirtualGroupFamily - Query the optimal virtual group family ID through SP ID and PickVGFStrategy.

Virtual group family(VGF) serve as a means of grouping global virtual groups. Each bucket must be associated with a unique global virtual group family and cannot cross families.

- ctx: Context variables for the current API call.

- spID: Identify the storage provider.

- ret1: The virtual group family detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) QueryVirtualGroupFamily added in v0.2.6

func (c *Client) QueryVirtualGroupFamily(ctx context.Context, globalVirtualGroupFamilyID uint32) (*types.GlobalVirtualGroupFamily, error)

QueryVirtualGroupFamily - Query the virtual group family by ID.

Virtual group family(VGF) serve as a means of grouping global virtual groups. Each bucket must be associated with a unique global virtual group family and cannot cross families.

- ctx: Context variables for the current API call.

- globalVirtualGroupFamilyID: Identify the virtual group family.

- ret1: The virtual group family detail.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) QueryVirtualGroupParams added in v1.6.0

func (c *Client) QueryVirtualGroupParams(ctx context.Context) (*types.Params, error)

QueryVirtualGroupParams - Query the virtual group family param.

Virtual group family(VGF) serve as a means of grouping global virtual groups. Each bucket must be associated with a unique global virtual group family and cannot cross families.

- ctx: Context variables for the current API call.

- ret1: Params holds all the parameters of this module..

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) QueryVote added in v0.2.6

func (c *Client) QueryVote(ctx context.Context, eventType int, eventHash []byte) (*ctypes.ResultQueryVote, error)

QueryVote - Query a vote from the Node's VotePool, it is used by Greenfield relayer and challengers by now.

- ctx: Context variables for the current API call.

- eventType: The type of vote to be queried.

- eventHash: The hash bytes of vote

- ret1: The vote result

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) RegisterEDDSAPublicKey added in v0.2.6

func (c *Client) RegisterEDDSAPublicKey(spAddress string, spEndpoint string) (string, error)

RegisterEDDSAPublicKey - Register EdDSA public key of this client for the given sp address and spEndpoint.

To enable EdDSA authentication, you need to config OffChainAuthOption for the client. The overall register process could be referred to https://docs.bnbchain.org/greenfield-docs/docs/guide/storage-provider/modules/authenticator#workflow.

The EdDSA registering process is typically used in a website, e.g. https://dcellar.io, which obtains a user's signature via a wallet and then posts the user's EdDSA public key to a sp.

Here we also provide an SDK method to implement this process, because sometimes you might want to test if a given SP provides correct EdDSA authentication or not. It also helps if you want implement it on a non-browser environment.

- spAddress: The sp operator address, to which this API will register client's EdDSA public key. It can be found via https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/storage-providers .

- spEndpoint: The sp endpoint, to which this API will register client's EdDSA public key. It can be found via https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/storage-providers .

- ret1: The register result when invoking SP UpdateUserPublicKey API.

- ret2: Return error when registering failed, otherwise return nil.

func (*Client) RegisterEDDSAPublicKeyV2 added in v1.6.0

func (c *Client) RegisterEDDSAPublicKeyV2(spEndpoint string) (string, error)

RegisterEDDSAPublicKeyV2 - Register EdDSA public key of this client for the given sp address and spEndpoint.

To enable EdDSA authentication, you need to config OffChainAuthOptionV2 for the client. The overall register process could be referred to https://docs.bnbchain.org/greenfield-docs/docs/guide/storage-provider/modules/authenticator#workflow.

The EdDSA registering process is typically used in a website, e.g. https://dcellar.io, which obtains a user's signature via a wallet and then posts the user's EdDSA public key to a sp.

Here we also provide an SDK method to implement this process, because sometimes you might want to test if a given SP provides correct EdDSA authentication or not. It also helps if you want implement it on a non-browser environment.

- spEndpoint: The sp endpoint, to which this API will register client's EdDSA public key. It can be found via https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/storage-providers .

- ret1: The register result when invoking SP UpdateUserPublicKey API.

- ret2: Return error when registering failed, otherwise return nil.

func (*Client) RenewGroupMember added in v0.2.6

func (c *Client) RenewGroupMember(ctx context.Context, groupOwnerAddr, groupName string,
	memberAddresses []string, opts types.RenewGroupMemberOption,
) (string, error)

RenewGroupMember - Renew a list group members and their expiration time.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- groupOwnerAddr: The HEX-encoded string of the group owner address.

- memberAddresses: The HEX-encoded string list of the member addresses to be renewed.

- opts: The options for customizing the transaction and each group member's expiration time.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) RevokeAllowance added in v0.2.6

func (c *Client) RevokeAllowance(ctx context.Context, granteeAddr string, txOption gnfdsdktypes.TxOption) (string, error)

RevokeAllowance revokes allowance on a grantee by the granter

func (*Client) SetBucketFlowRateLimit added in v1.6.0

func (c *Client) SetBucketFlowRateLimit(ctx context.Context, bucketName string,
	paymentAddr, bucketOwner sdk.AccAddress, flowRateLimit sdkmath.Int, opt types.SetBucketFlowRateLimitOption,
) (string, error)

SetBucketFlowRateLimit - Set the flow rate limit of the bucket. It will send the MsgSetBucketFlowRateLimit msg to greenfield to update the meta.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to be updated.

- paymentAddr: The payment address from which deduct the cost of bucket storage or quota.

- bucketOwner: The owner of the bucket.

- flowRateLimit: The flow rate limit of the bucket.

- opt: The Options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error if update flow rate limit failed, otherwise return nil.

func (*Client) SetDefaultAccount

func (c *Client) SetDefaultAccount(account *types.Account)

SetDefaultAccount - Set the default account of the Client.

If you call other APIs without specifying the account, it will be assumed that you are operating on the default account. This includes sending transactions and other actions.

- account: The account to be set as the default account, should be created using a private key or a mnemonic phrase.

func (*Client) SetTag added in v1.2.0

func (c *Client) SetTag(ctx context.Context, resourceGRN string, tags storageTypes.ResourceTags, opts gosdktypes.SetTagsOptions) (string, error)

SetTag - Set tag for a given existing resource GRN (a bucket, a object or a group)

This API sends a request to the greenfield chain to set tags for the given resource.

- ctx: Context variables for the current API call.

- resourceGRN: The GRN of resource that needs to set tags

- tags: the tags to be set for the given resource

- opts: The Options indicates the meta to construct setTag msg and the way to send transaction

- ret1: Transaction hash return from blockchain.

- ret2: Return error if SetTag failed, otherwise return nil.

func (*Client) SetWithdrawAddress added in v0.2.6

func (c *Client) SetWithdrawAddress(ctx context.Context, withdrawAddr string, txOption gnfdsdktypes.TxOption) (string, error)

SetWithdrawAddress - Set the withdrawal address for a delegator (or validator self-delegation).

- ctx: Context variables for the current API call.

- withdrawAddr: The withdrawal address to set.

- txOption: The txOption for sending transactions.

- ret1: Transaction hash of the transaction.

- ret2: Return error if the transaction failed, otherwise return nil.

func (*Client) SimulateRawTx added in v0.2.6

func (c *Client) SimulateRawTx(ctx context.Context, txBytes []byte, opts ...grpc.CallOption) (*tx.SimulateResponse, error)

SimulateRawTx - Simulate the execution of a raw transaction on the blockchain without broadcasting it to the network.

- ctx: Context variables for the current API call.

- txBytes: The transaction bytes.

- opts: The grpc option(s) if Client is using grpc connection.

- ret1: The simulation result.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) SimulateTx added in v0.2.6

func (c *Client) SimulateTx(ctx context.Context, msgs []sdk.Msg, txOpt types.TxOption, opts ...grpc.CallOption) (*tx.SimulateResponse, error)

SimulateTx - Simulate a transaction containing the provided message(s) on the chain.

- ctx: Context variables for the current API call.

- msgs: Message(s) to be broadcast to blockchain.

- txOpt: TxOpt contains options for customizing the transaction.

- opts: The grpc option(s) if Client is using grpc connection.

- ret1: The simulation result.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) SplitPartInfo added in v0.2.6

func (c *Client) SplitPartInfo(objectSize int64, configuredPartSize uint64) (totalPartsCount int, partSize int64, lastPartSize int64, err error)

func (*Client) SubmitChallenge added in v0.2.6

func (c *Client) SubmitChallenge(ctx context.Context, challengerAddress, spOperatorAddress, bucketName, objectName string, randomIndex bool, segmentIndex uint32, txOption gnfdsdktypes.TxOption) (*sdk.TxResponse, error)

SubmitChallenge - Challenge a storage provider's data integrity for a specific data object.

User can submit a challenge when he/she find his/her data is lost or tampered. A successful challenge will punish the storage provider and reward the challenge submitter.

- ctx: Context variables for the current API call.

- challengerAddress: The address of the challenger, usually it's the address of current account.

- spOperatorAddress: The operator address of the storage provider to be challenged.

- bucketName: The bucket name of the object to be challenged.

- objectName: The name of the object to be challenged.

- randomIndex: Whether the segment/piece to be challenged will be randomly generated or not.

- segmentIndex: The index of the segment/piece to be challenged. If randomIndex is true, then segmentIndex will be ignored.

- txOption: The options for sending the tx.

- ret1: The response of Greenfield transaction.

- ret2: Return error when submitting challenge tx failed, otherwise return nil.

func (*Client) SubmitProposal added in v0.2.6

func (c *Client) SubmitProposal(ctx context.Context, msgs []sdk.Msg, depositAmount math.Int, title, summary string, opts types.SubmitProposalOptions) (uint64, string, error)

SubmitProposal - Submit a proposal to Greenfield.

- ctx: Context variables for the current API call.

- msgs: The messages to be executed when the proposal is passed.

- depositAmount: The amount of BNB to deposit to the proposal.

- title: The title of the proposal.

- summary: The summary of the proposal.

- opts: The options of the proposal.

- ret1: Proposal id of the submitted proposal.

- ret2: Transaction hash of the transaction.

- ret3: Return error if the transaction failed, otherwise return nil.

func (*Client) ToggleSPAsDelegatedAgent added in v1.6.0

func (c *Client) ToggleSPAsDelegatedAgent(ctx context.Context, bucketName string, opt types.UpdateBucketOptions,
) (string, error)

func (*Client) Transfer added in v0.2.6

func (c *Client) Transfer(ctx context.Context, toAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (string, error)

Transfer - Transfer BNB from sender to receiver.

- ctx: Context variables for the current API call.

- toAddress: The address who will receive the BNB.

- amount: The BNB amount to transfer, 1e18 denotes 1BNB.

- txOption: The txOption for sending transactions.

- ret1: Return the transaction hash if transferred successfully, otherwise return empty string.

- ret2: Return error if transferred failed, otherwise return nil.

func (*Client) TransferOut added in v0.2.6

func (c *Client) TransferOut(ctx context.Context, toAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)

TransferOut - Make a transfer from Greenfield to BSC

- ctx: Context variables for the current API call.

- toAddress: The destination address in BSC.

- amount: The amount of BNB to transfer.

- txOption: The txOption for sending transactions.

- ret1: Transaction response from Greenfield.

- ret2: Return error if transaction failed, otherwise return nil.

func (*Client) UnJailValidator added in v0.2.6

func (c *Client) UnJailValidator(ctx context.Context, txOption gnfdsdktypes.TxOption) (string, error)

UnJailValidator - Unjail a validator.

The default account's address will be treated the validator address to unjail.

- ctx: Context variables for the current API call.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when unjail validator tx failed, otherwise return nil.

func (*Client) Undelegate added in v0.2.6

func (c *Client) Undelegate(ctx context.Context, validatorAddr string, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)

Undelegate - Undelegate tokens from a validator by the delegator.

- ctx: Context variables for the current API call.

- validatorAddr: The address of the target validator to un-delegate from.

- amount: The amount of un-delegation.

- txOption: The options for sending the tx.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when un-delegation tx failed, otherwise return nil.

func (*Client) UpdateBucketInfo added in v0.2.6

func (c *Client) UpdateBucketInfo(ctx context.Context, bucketName string, opts types.UpdateBucketOptions) (string, error)

UpdateBucketInfo - Update the bucket meta on chain, including read quota, payment address or visibility. It will send the MsgUpdateBucketInfo msg to greenfield to update the meta.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to be updated.

- paymentAddr: The payment address from which deduct the cost of bucket storage or quota.

- opts: The Options used to specify which metas need to be updated and the option to send transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error if update bucket meta failed, otherwise return nil.

func (*Client) UpdateBucketPaymentAddr added in v0.2.6

func (c *Client) UpdateBucketPaymentAddr(ctx context.Context, bucketName string,
	paymentAddr sdk.AccAddress, opt types.UpdatePaymentOption,
) (string, error)

UpdateBucketPaymentAddr - Update the payment address of bucket. It will send the MsgUpdateBucketInfo msg to greenfield to update the meta.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to be updated.

- paymentAddr: The payment address from which deduct the cost of bucket storage or quota.

- opt: The Options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error if update payment address failed, otherwise return nil.

func (*Client) UpdateBucketVisibility added in v0.2.6

func (c *Client) UpdateBucketVisibility(ctx context.Context, bucketName string,
	visibility storageTypes.VisibilityType, opt types.UpdateVisibilityOption,
) (string, error)

UpdateBucketVisibility - Update the visibilityType of bucket.

- ctx: Context variables for the current API call.

- bucketName: The name of the bucket to be updated.

- visibility: The VisibilityType defines on greenfield which can be PUBLIC_READ, PRIVATE or INHERIT

- opt: The Options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error if update visibility failed, otherwise return nil.

func (*Client) UpdateGroupMember added in v0.2.6

func (c *Client) UpdateGroupMember(ctx context.Context, groupName string, groupOwnerAddr string,
	addAddresses, removeAddresses []string, opts types.UpdateGroupMemberOption,
) (string, error)

UpdateGroupMember - Update a group by adding or removing members. The sender can be the group owner or any individual account(Principle) that has been granted permission by the group owner.

Note: The group owner can only grant ACTION_UPDATE_GROUP_MEMBER permission to an individual account, there is no way to grant permission to a group to allow members within such group to manipulate another group or the group itself.

- ctx: Context variables for the current API call.

- groupName: The group name identifies the group.

- groupOwnerAddr: The HEX-encoded string of the group owner address.

- addAddresses: The HEX-encoded string list of the member addresses to be added.

- removeAddresses: The HEX-encoded string list of the member addresses to be removed.

- opt: The options for customizing the group members expiration time and transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) UpdateObjectContent added in v1.6.0

func (c *Client) UpdateObjectContent(ctx context.Context, bucketName, objectName string,
	reader io.Reader, opts types.UpdateObjectOptions,
) (string, error)

UpdateObjectContent sends updateObjectContent tx to greenfield chain, it returns the transaction hash value and error

func (*Client) UpdateObjectVisibility added in v0.2.6

func (c *Client) UpdateObjectVisibility(ctx context.Context, bucketName, objectName string,
	visibility storageTypes.VisibilityType, opt types.UpdateObjectOption,
) (string, error)

func (*Client) UpdateSpStatus added in v0.2.6

func (c *Client) UpdateSpStatus(ctx context.Context, spAddr string, status spTypes.Status, duration int64, TxOption gnfdSdkTypes.TxOption) (string, error)

UpdateSpStatus - Set an SP status between STATUS_IN_SERVICE and STATUS_IN_MAINTENANCE. The sender must be the Storage provider's operator address.

- ctx: Context variables for the current API call.

- spAddr: The HEX-encoded string of the storage provider address.

- status: The desired status.

- duration: duration is requested time(in second) an SP wish to stay in maintenance mode, for setting to STATUS_IN_SERVICE, duration is set to 0.

- TxOption: The options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) UpdateSpStoragePrice added in v0.2.6

func (c *Client) UpdateSpStoragePrice(ctx context.Context, spAddr string, readPrice, storePrice sdk.Dec, freeReadQuota uint64, TxOption gnfdSdkTypes.TxOption) (string, error)

UpdateSpStoragePrice - Update the read price, storage price and free read quota for a particular storage provider. The sender must be the Storage provider's operator address, and SP must be STATUS_IN_SERVICE.

- ctx: Context variables for the current API call.

- spAddr: The HEX-encoded string of the storage provider address.

- readPrice: The read price of the SP, in bnb wei per charge byte.

- storePrice: The store price of the SP, in bnb wei per charge byte.

- freeReadQuota: The free read quota of the SP.

- TxOption: The options for customizing the transaction.

- ret1: Transaction hash return from blockchain.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) VoteProposal added in v0.2.6

func (c *Client) VoteProposal(ctx context.Context, proposalID uint64, voteOption govTypesV1.VoteOption, opts types.VoteProposalOptions) (string, error)

VoteProposal - Vote for the proposal.

- ctx: Context variables for the current API call.

- proposalID: The proposal id to vote for.

- voteOption: The vote option for the vote.

- opts: The options of the transaction.

- ret1: Transaction hash of the transaction.

- ret2: Return error if the transaction failed, otherwise return nil.

func (*Client) WaitForBlockHeight added in v0.2.6

func (c *Client) WaitForBlockHeight(ctx context.Context, h int64) error

WaitForBlockHeight - Wait until a specified block height is committed.

- ctx: Context variables for the current API call.

- ret: Return error when the request failed, otherwise return nil.

func (*Client) WaitForNBlocks added in v0.2.6

func (c *Client) WaitForNBlocks(ctx context.Context, n int64) error

WaitForNBlocks - Wait for another n blocks to be committed since current block.

- ctx: Context variables for the current API call.

- n: number of blocks to be waited.

- ret: Return error when the request failed, otherwise return nil.

func (*Client) WaitForNextBlock added in v0.2.6

func (c *Client) WaitForNextBlock(ctx context.Context) error

WaitForNextBlock - Wait until the next block is committed since current block.

- ctx: Context variables for the current API call.

- ret: Return error when the request failed, otherwise return nil.

func (*Client) WaitForTx added in v0.2.6

func (c *Client) WaitForTx(ctx context.Context, hash string) (*ctypes.ResultTx, error)

WaitForTx - Wait for a transaction to be confirmed onchian, if transaction not found in current block, wait for the next block. API ends when a transaction is found or context is canceled.

- ctx: Context variables for the current API call.

- hash: The hex representation of transaction hash.

- ret1: The transaction result details.

- ret2: Return error when the request failed, otherwise return nil.

func (*Client) Withdraw added in v0.2.6

func (c *Client) Withdraw(ctx context.Context, fromAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (string, error)

Withdraw - Withdraws BNB from a payment account.

Withdrawal will trigger settlement, i.e., updating static balance and buffer balance. If the withdrawal amount is greater than the static balance after settlement it will fail. If the withdrawal amount is equal to or greater than 100BNB, it will be timelock-ed for 1 day duration. And after the duration, a message without `from` field should be sent to get the funds.

- ctx: Context variables for the current API call.

- fromAddress: The address of the stream record to withdraw from.

- amount: The amount to withdraw.

- txOption: The options for sending the tx.

- ret1: The response of Greenfield transaction.

- ret2: Return error when withdrawal tx failed, otherwise return nil.

func (*Client) WithdrawDelegatorReward added in v0.2.6

func (c *Client) WithdrawDelegatorReward(ctx context.Context, validatorAddr string, txOption gnfdsdktypes.TxOption) (string, error)

WithdrawDelegatorReward - Withdraw rewards by a delegator.

- ctx: Context variables for the current API call.

- validatorAddr: The validator address to withdraw from.

- txOption: The txOption for sending transactions.

- ret1: Transaction hash of the transaction.

- ret2: Return error if the transaction failed, otherwise return nil.

func (*Client) WithdrawValidatorCommission added in v0.2.6

func (c *Client) WithdrawValidatorCommission(ctx context.Context, txOption gnfdsdktypes.TxOption) (string, error)

WithdrawValidatorCommission - Withdraw accumulated commission by validator.

- ctx: Context variables for the current API call.

- txOption: The txOption for sending transactions.

- ret1: Transaction hash of the transaction.

- ret2: Return error if the transaction failed, otherwise return nil.

type DeleteUserPublicKeyV2Resp added in v1.6.0

type DeleteUserPublicKeyV2Resp struct {
	Result bool `xml:"Result"`
}

DeleteUserPublicKeyV2Resp is the structure for off chain auth v2 DeleteUserPublicKeyV2 response.

type IAccountClient added in v0.2.6

type IAccountClient interface {
	SetDefaultAccount(account *types.Account)
	GetDefaultAccount() (*types.Account, error)
	MustGetDefaultAccount() *types.Account

	GetAccount(ctx context.Context, address string) (authTypes.AccountI, error)
	GetAccountBalance(ctx context.Context, address string) (*sdk.Coin, error)
	GetPaymentAccount(ctx context.Context, address string) (*paymentTypes.PaymentAccount, error)
	GetModuleAccounts(ctx context.Context) ([]authTypes.ModuleAccountI, error)
	GetModuleAccountByName(ctx context.Context, name string) (authTypes.ModuleAccountI, error)
	GetPaymentAccountsByOwner(ctx context.Context, owner string) ([]*paymentTypes.PaymentAccount, error)

	CreatePaymentAccount(ctx context.Context, address string, txOption gnfdSdkTypes.TxOption) (string, error)
	Transfer(ctx context.Context, toAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (string, error)
	MultiTransfer(ctx context.Context, details []types.TransferDetail, txOption gnfdSdkTypes.TxOption) (string, error)
}

IAccountClient - Client APIs for operating Greenfield accounts.

type IAuthClient added in v0.2.6

type IAuthClient interface {
	RegisterEDDSAPublicKey(spAddress string, spEndpoint string) (string, error)
	GetNextNonce(spEndpoint string) (string, error)
	OffChainAuthSign(unsignedBytes []byte) string

	RegisterEDDSAPublicKeyV2(spEndpoint string) (string, error)
	OffChainAuthSignV2(unsignedBytes []byte) string

	ListUserPublicKeyV2(spEndpoint string, domain string) ([]string, error)
	DeleteUserPublicKeyV2(spEndpoint string, domain string, publicKeys []string) (bool, error)
}

IAuthClient - Client APIs for register Greenfield off chain auth keys and make signatures.

type IBasicClient added in v0.2.6

type IBasicClient interface {
	EnableTrace(outputStream io.Writer, onlyTraceErr bool)

	GetNodeInfo(ctx context.Context) (*p2p.DefaultNodeInfo, *tmservice.VersionInfo, error)
	GetStatus(ctx context.Context) (*ctypes.ResultStatus, error)
	GetCommit(ctx context.Context, height int64) (*ctypes.ResultCommit, error)
	GetLatestBlockHeight(ctx context.Context) (int64, error)
	GetLatestBlock(ctx context.Context) (*bfttypes.Block, error)
	GetSyncing(ctx context.Context) (bool, error)
	GetBlockByHeight(ctx context.Context, height int64) (*bfttypes.Block, error)
	GetBlockResultByHeight(ctx context.Context, height int64) (*ctypes.ResultBlockResults, error)

	GetValidatorSet(ctx context.Context) (int64, []*bfttypes.Validator, error)
	GetValidatorsByHeight(ctx context.Context, height int64) ([]*bfttypes.Validator, error)

	WaitForBlockHeight(ctx context.Context, height int64) error
	WaitForTx(ctx context.Context, hash string) (*ctypes.ResultTx, error)
	WaitForNBlocks(ctx context.Context, n int64) error
	WaitForNextBlock(ctx context.Context) error

	SimulateTx(ctx context.Context, msgs []sdk.Msg, txOpt types.TxOption, opts ...grpc.CallOption) (*tx.SimulateResponse, error)
	SimulateRawTx(ctx context.Context, txBytes []byte, opts ...grpc.CallOption) (*tx.SimulateResponse, error)
	BroadcastTx(ctx context.Context, msgs []sdk.Msg, txOpt *types.TxOption, opts ...grpc.CallOption) (*tx.BroadcastTxResponse, error)
	BroadcastRawTx(ctx context.Context, txBytes []byte, sync bool) (*sdk.TxResponse, error)

	BroadcastVote(ctx context.Context, vote votepool.Vote) error
	QueryVote(ctx context.Context, eventType int, eventHash []byte) (*ctypes.ResultQueryVote, error)
	SetTag(ctx context.Context, resourceGRN string, tags storageTypes.ResourceTags, opts gosdktypes.SetTagsOptions) (string, error)
}

IBasicClient interface defines basic functions of greenfield Client.

type IBucketClient added in v0.2.6

type IBucketClient interface {
	GetCreateBucketApproval(ctx context.Context, createBucketMsg *storageTypes.MsgCreateBucket) (*storageTypes.MsgCreateBucket, error)
	CreateBucket(ctx context.Context, bucketName string, primaryAddr string, opts types.CreateBucketOptions) (string, error)
	DeleteBucket(ctx context.Context, bucketName string, opt types.DeleteBucketOption) (string, error)
	UpdateBucketVisibility(ctx context.Context, bucketName string, visibility storageTypes.VisibilityType, opt types.UpdateVisibilityOption) (string, error)
	UpdateBucketInfo(ctx context.Context, bucketName string, opts types.UpdateBucketOptions) (string, error)
	UpdateBucketPaymentAddr(ctx context.Context, bucketName string, paymentAddr sdk.AccAddress, opt types.UpdatePaymentOption) (string, error)
	ToggleSPAsDelegatedAgent(ctx context.Context, bucketName string, opt types.UpdateBucketOptions) (string, error)
	HeadBucket(ctx context.Context, bucketName string) (*storageTypes.BucketInfo, error)
	HeadBucketByID(ctx context.Context, bucketID string) (*storageTypes.BucketInfo, error)
	PutBucketPolicy(ctx context.Context, bucketName string, principal types.Principal, statements []*permTypes.Statement, opt types.PutPolicyOption) (string, error)
	DeleteBucketPolicy(ctx context.Context, bucketName string, principal types.Principal, opt types.DeletePolicyOption) (string, error)
	GetBucketPolicy(ctx context.Context, bucketName string, principalAddr string) (*permTypes.Policy, error)
	IsBucketPermissionAllowed(ctx context.Context, userAddr string, bucketName string, action permTypes.ActionType) (permTypes.Effect, error)
	ListBuckets(ctx context.Context, opts types.ListBucketsOptions) (types.ListBucketsResult, error)
	ListBucketReadRecord(ctx context.Context, bucketName string, opts types.ListReadRecordOptions) (types.QuotaRecordInfo, error)
	GetQuotaUpdateTime(ctx context.Context, bucketName string) (int64, error)
	BuyQuotaForBucket(ctx context.Context, bucketName string, targetQuota uint64, opt types.BuyQuotaOption) (string, error)
	GetBucketReadQuota(ctx context.Context, bucketName string) (types.QuotaInfo, error)
	ListBucketsByBucketID(ctx context.Context, bucketIds []uint64, opts types.EndPointOptions) (types.ListBucketsByBucketIDResponse, error)
	GetMigrateBucketApproval(ctx context.Context, migrateBucketMsg *storageTypes.MsgMigrateBucket) (*storageTypes.MsgMigrateBucket, error)
	MigrateBucket(ctx context.Context, bucketName string, dstPrimarySPID uint32, opts types.MigrateBucketOptions) (string, error)
	CancelMigrateBucket(ctx context.Context, bucketName string, opts types.CancelMigrateBucketOptions) (string, error)
	GetBucketMigrationProgress(ctx context.Context, bucketName string, destSP uint32) (types.MigrationProgress, error)
	ListBucketsByPaymentAccount(ctx context.Context, paymentAccount string, opts types.ListBucketsByPaymentAccountOptions) (types.ListBucketsByPaymentAccountResult, error)
	SetBucketFlowRateLimit(ctx context.Context, bucketName string, paymentAddr, bucketOwner sdk.AccAddress, flowRateLimit sdkmath.Int, opt types.SetBucketFlowRateLimitOption) (string, error)
	GetPaymentAccountFlowRateLimit(ctx context.Context, paymentAddr, bucketOwner sdk.AccAddress, bucketName string) (*storageTypes.QueryPaymentAccountBucketFlowRateLimitResponse, error)
}

IBucketClient interface defines functions related to bucket. The concept of "bucket" is the same as the concept of a bucket in AWS S3 storage.

type IChallengeClient added in v0.2.6

type IChallengeClient interface {
	GetChallengeInfo(ctx context.Context, objectID string, pieceIndex, redundancyIndex int, opts types.GetChallengeInfoOptions) (types.ChallengeResult, error)
	SubmitChallenge(ctx context.Context, challengerAddress, spOperatorAddress, bucketName, objectName string, randomIndex bool, segmentIndex uint32, txOption gnfdsdktypes.TxOption) (*sdk.TxResponse, error)
	AttestChallenge(ctx context.Context, submitterAddress, challengerAddress, spOperatorAddress string, challengeId uint64, objectId math.Uint, voteResult challengetypes.VoteResult, voteValidatorSet []uint64, VoteAggSignature []byte, txOption gnfdsdktypes.TxOption) (*sdk.TxResponse, error)
	LatestAttestedChallenges(ctx context.Context, req *challengetypes.QueryLatestAttestedChallengesRequest) (*challengetypes.QueryLatestAttestedChallengesResponse, error)
	InturnAttestationSubmitter(ctx context.Context, req *challengetypes.QueryInturnAttestationSubmitterRequest) (*challengetypes.QueryInturnAttestationSubmitterResponse, error)
	ChallengeParams(ctx context.Context, req *challengetypes.QueryParamsRequest) (*challengetypes.QueryParamsResponse, error)
}

IChallengeClient - Client APIs for operating and querying Greenfield challenges.

type IClient added in v0.2.6

IClient - Declare all Greenfield SDK Client APIs, including APIs for interacting with Greenfield Blockchain and SPs.

func New

func New(chainID string, endpoint string, option Option) (IClient, error)

New - New Greenfield Go SDK Client.

- chainID: The Greenfield Blockchain's chainID that the Client would interact with.

- endpoint: The Greenfield Blockchain's RPC URL that the Client would interact with.

- option: The optional configurations for the Client.

- ret1: The new client that created, in IClient format.

- ret2: Return error when new Client failed, otherwise return nil.

type ICrossChainClient added in v0.2.6

type ICrossChainClient interface {
	TransferOut(ctx context.Context, toAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)

	Claims(ctx context.Context, srcShainId, destChainId uint32, sequence uint64, timestamp uint64, payload []byte, voteAddrSet []uint64, aggSignature []byte, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)
	GetChannelSendSequence(ctx context.Context, destChainId sdk.ChainID, channelId uint32) (uint64, error)
	GetChannelReceiveSequence(ctx context.Context, destChainId sdk.ChainID, channelId uint32) (uint64, error)
	GetInturnRelayer(ctx context.Context, req *oracletypes.QueryInturnRelayerRequest) (*oracletypes.QueryInturnRelayerResponse, error)
	GetCrossChainPackage(ctx context.Context, destChainId sdk.ChainID, channelId uint32, sequence uint64) ([]byte, error)

	MirrorGroup(ctx context.Context, destChainId sdk.ChainID, groupId math.Uint, groupName string, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)
	MirrorBucket(ctx context.Context, destChainId sdk.ChainID, bucketId math.Uint, bucketName string, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)
	MirrorObject(ctx context.Context, destChainId sdk.ChainID, objectId math.Uint, bucketName, objectName string, txOption gnfdSdkTypes.TxOption) (*sdk.TxResponse, error)
}

type IDistributionClient added in v0.2.6

type IDistributionClient interface {
	SetWithdrawAddress(ctx context.Context, withdrawAddr string, txOption gnfdsdktypes.TxOption) (string, error)
	WithdrawValidatorCommission(ctx context.Context, txOption gnfdsdktypes.TxOption) (string, error)
	WithdrawDelegatorReward(ctx context.Context, validatorAddr string, txOption gnfdsdktypes.TxOption) (string, error)
	FundCommunityPool(ctx context.Context, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)
}

type IFeeGrantClient added in v0.2.6

type IFeeGrantClient interface {
	GrantBasicAllowance(ctx context.Context, granteeAddr string, feeAllowanceAmount math.Int, expiration *time.Time, txOption gnfdsdktypes.TxOption) (string, error)
	QueryBasicAllowance(ctx context.Context, granterAddr, granteeAddr string) (*feegrant.BasicAllowance, error)

	// for generic allowance(BasicAllowance, PeriodicAllowance, AllowedMsgAllowance)
	GrantAllowance(ctx context.Context, granteeAddr string, allowance feegrant.FeeAllowanceI, txOption gnfdsdktypes.TxOption) (string, error)
	QueryAllowance(ctx context.Context, granterAddr, granteeAddr string) (*feegrant.Grant, error)
	QueryAllowances(ctx context.Context, granteeAddr string) ([]*feegrant.Grant, error)

	RevokeAllowance(ctx context.Context, granteeAddr string, txOption gnfdsdktypes.TxOption) (string, error)
}

type IGroupClient added in v0.2.6

type IGroupClient interface {
	CreateGroup(ctx context.Context, groupName string, opt types.CreateGroupOptions) (string, error)
	DeleteGroup(ctx context.Context, groupName string, opt types.DeleteGroupOption) (string, error)
	UpdateGroupMember(ctx context.Context, groupName string, groupOwnerAddr string,
		addAddresses, removeAddresses []string, opts types.UpdateGroupMemberOption) (string, error)
	LeaveGroup(ctx context.Context, groupName string, groupOwnerAddr string, opt types.LeaveGroupOption) (string, error)
	HeadGroup(ctx context.Context, groupName string, groupOwnerAddr string) (*storageTypes.GroupInfo, error)
	HeadGroupMember(ctx context.Context, groupName string, groupOwner, headMember string) bool
	PutGroupPolicy(ctx context.Context, groupName string, principalAddr string, statements []*permTypes.Statement, opt types.PutPolicyOption) (string, error)
	DeleteGroupPolicy(ctx context.Context, groupName string, principalAddr string, opt types.DeletePolicyOption) (string, error)
	GetBucketPolicyOfGroup(ctx context.Context, bucketName string, groupId uint64) (*permTypes.Policy, error)
	GetObjectPolicyOfGroup(ctx context.Context, bucketName, objectName string, groupId uint64) (*permTypes.Policy, error)
	GetGroupPolicy(ctx context.Context, groupName string, principalAddr string) (*permTypes.Policy, error)
	ListGroup(ctx context.Context, name, prefix string, opts types.ListGroupsOptions) (types.ListGroupsResult, error)
	RenewGroupMember(ctx context.Context, groupOwnerAddr, groupName string, memberAddresses []string, opts types.RenewGroupMemberOption) (string, error)
	ListGroupMembers(ctx context.Context, groupID int64, opts types.GroupMembersPaginationOptions) (*types.GroupMembersResult, error)
	ListGroupsByAccount(ctx context.Context, opts types.GroupsPaginationOptions) (*types.GroupsResult, error)
	ListGroupsByOwner(ctx context.Context, opts types.GroupsOwnerPaginationOptions) (*types.GroupsResult, error)
	ListGroupsByGroupID(ctx context.Context, groupIDs []uint64, opts types.EndPointOptions) (types.ListGroupsByGroupIDResponse, error)
}

IGroupClient interface defines functions related to Group.

type IObjectClient added in v0.2.6

type IObjectClient interface {
	GetCreateObjectApproval(ctx context.Context, createObjectMsg *storageTypes.MsgCreateObject) (*storageTypes.MsgCreateObject, error)
	CreateObject(ctx context.Context, bucketName, objectName string, reader io.Reader, opts types.CreateObjectOptions) (string, error)
	UpdateObjectContent(ctx context.Context, bucketName, objectName string, reader io.Reader, opts types.UpdateObjectOptions) (string, error)
	CancelUpdateObjectContent(ctx context.Context, bucketName, objectName string, opts types.CancelUpdateObjectOption) (string, error)
	PutObject(ctx context.Context, bucketName, objectName string, objectSize int64, reader io.Reader, opts types.PutObjectOptions) error

	DelegatePutObject(ctx context.Context, bucketName, objectName string, objectSize int64, reader io.Reader, opts types.PutObjectOptions) error
	DelegateUpdateObjectContent(ctx context.Context, bucketName, objectName string, objectSize int64, reader io.Reader, opts types.PutObjectOptions) error
	FPutObject(ctx context.Context, bucketName, objectName, filePath string, opts types.PutObjectOptions) (err error)
	CancelCreateObject(ctx context.Context, bucketName, objectName string, opt types.CancelCreateOption) (string, error)
	DeleteObject(ctx context.Context, bucketName, objectName string, opt types.DeleteObjectOption) (string, error)
	GetObject(ctx context.Context, bucketName, objectName string, opts types.GetObjectOptions) (io.ReadCloser, types.ObjectStat, error)
	FGetObject(ctx context.Context, bucketName, objectName, filePath string, opts types.GetObjectOptions) error
	FGetObjectResumable(ctx context.Context, bucketName, objectName, filePath string, opts types.GetObjectOptions) error
	HeadObject(ctx context.Context, bucketName, objectName string) (*types.ObjectDetail, error)
	HeadObjectByID(ctx context.Context, objID string) (*types.ObjectDetail, error)
	UpdateObjectVisibility(ctx context.Context, bucketName, objectName string, visibility storageTypes.VisibilityType, opt types.UpdateObjectOption) (string, error)
	PutObjectPolicy(ctx context.Context, bucketName, objectName string, principal types.Principal,
		statements []*permTypes.Statement, opt types.PutPolicyOption) (string, error)
	DeleteObjectPolicy(ctx context.Context, bucketName, objectName string, principal types.Principal, opt types.DeletePolicyOption) (string, error)
	GetObjectPolicy(ctx context.Context, bucketName, objectName string, principalAddr string) (*permTypes.Policy, error)
	IsObjectPermissionAllowed(ctx context.Context, userAddr string, bucketName, objectName string, action permTypes.ActionType) (permTypes.Effect, error)
	ListObjects(ctx context.Context, bucketName string, opts types.ListObjectsOptions) (types.ListObjectsResult, error)
	ComputeHashRoots(reader io.Reader, isSerial bool) ([][]byte, int64, storageTypes.RedundancyType, error)
	CreateFolder(ctx context.Context, bucketName, objectName string, opts types.CreateObjectOptions) (string, error)
	DelegateCreateFolder(ctx context.Context, bucketName, objectName string, opts types.PutObjectOptions) error
	GetObjectUploadProgress(ctx context.Context, bucketName, objectName string) (string, error)
	ListObjectsByObjectID(ctx context.Context, objectIds []uint64, opts types.EndPointOptions) (types.ListObjectsByObjectIDResponse, error)
	ListObjectPolicies(ctx context.Context, objectName, bucketName string, actionType uint32, opts types.ListObjectPoliciesOptions) (types.ListObjectPoliciesResponse, error)
	// contains filtered or unexported methods
}

IObjectClient interface defines functions related to object operations. The concept of "object" is the same as the concept of the object in AWS S3 storage.

type IPaymentClient added in v0.2.6

type IPaymentClient interface {
	GetStreamRecord(ctx context.Context, streamAddress string) (*paymentTypes.StreamRecord, error)
	Deposit(ctx context.Context, toAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (string, error)
	Withdraw(ctx context.Context, fromAddress string, amount math.Int, txOption gnfdSdkTypes.TxOption) (string, error)
	DisableRefund(ctx context.Context, paymentAddress string, txOption gnfdSdkTypes.TxOption) (string, error)
	ListUserPaymentAccounts(ctx context.Context, opts types.ListUserPaymentAccountsOptions) (types.ListUserPaymentAccountsResult, error)
}

IPaymentClient - Client APIs for operating and querying Greenfield payment accounts and stream records.

type IProposalClient added in v0.2.6

type IProposalClient interface {
	SubmitProposal(ctx context.Context, msgs []sdk.Msg, depositAmount math.Int, title, summary string, opts types.SubmitProposalOptions) (uint64, string, error)
	VoteProposal(ctx context.Context, proposalID uint64, voteOption govTypesV1.VoteOption, opts types.VoteProposalOptions) (string, error)
	GetProposal(ctx context.Context, proposalID uint64) (*govTypesV1.Proposal, error)
}

type ISPClient added in v0.2.6

type ISPClient interface {
	ListStorageProviders(ctx context.Context, isInService bool) ([]spTypes.StorageProvider, error)
	GetStorageProviderInfo(ctx context.Context, SPAddr sdk.AccAddress) (*spTypes.StorageProvider, error)
	GetStoragePrice(ctx context.Context, SPAddr string) (*spTypes.SpStoragePrice, error)
	GetGlobalSpStorePrice(ctx context.Context) (*spTypes.GlobalSpStorePrice, error)
	GrantDepositForStorageProvider(ctx context.Context, spAddr string, depositAmount math.Int, opts types.GrantDepositForStorageProviderOptions) (string, error)
	CreateStorageProvider(ctx context.Context, fundingAddr, sealAddr, approvalAddr, gcAddr, maintenanceAddr, blsPubKey, blsProof, endpoint string, depositAmount math.Int, description spTypes.Description, opts types.CreateStorageProviderOptions) (uint64, string, error)
	UpdateSpStoragePrice(ctx context.Context, spAddr string, readPrice, storePrice sdk.Dec, freeReadQuota uint64, txOption gnfdSdkTypes.TxOption) (string, error)
	UpdateSpStatus(ctx context.Context, spAddr string, status spTypes.Status, duration int64, txOption gnfdSdkTypes.TxOption) (string, error)
}

ISPClient interface defines basic functions related to Storage Provider.

type IValidatorClient added in v0.2.6

type IValidatorClient interface {
	ListValidators(ctx context.Context, status string) (*stakingtypes.QueryValidatorsResponse, error)
	CreateValidator(ctx context.Context, description stakingtypes.Description, commission stakingtypes.CommissionRates,
		selfDelegation math.Int, validatorAddress string, ed25519PubKey string, selfDelAddr string, relayerAddr string, challengerAddr string, blsKey, blsProof string,
		proposalDepositAmount math.Int, proposalTitle, proposalSummary, proposalMetadata string, txOption gnfdsdktypes.TxOption) (uint64, string, error)
	EditValidator(ctx context.Context, description stakingtypes.Description, newRate *sdktypes.Dec,
		newMinSelfDelegation *math.Int, newRelayerAddr, newChallengerAddr, newBlsKey, blsProof string, txOption gnfdsdktypes.TxOption) (string, error)
	DelegateValidator(ctx context.Context, validatorAddr string, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)
	BeginRedelegate(ctx context.Context, validatorSrcAddr, validatorDestAddr string, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)
	Undelegate(ctx context.Context, validatorAddr string, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)
	CancelUnbondingDelegation(ctx context.Context, validatorAddr string, creationHeight int64, amount math.Int, txOption gnfdsdktypes.TxOption) (string, error)
	GrantDelegationForValidator(ctx context.Context, delegationAmount math.Int, txOption gnfdsdktypes.TxOption) (string, error)

	UnJailValidator(ctx context.Context, txOption gnfdsdktypes.TxOption) (string, error)
	ImpeachValidator(ctx context.Context, validatorAddr string, proposalDepositAmount math.Int, proposalTitle, proposalSummary, proposalMetadata string, txOption gnfdsdktypes.TxOption) (uint64, string, error)
}

IValidatorClient - Client APIs for operating Greenfield validators and delegations.

type IVirtualGroupClient added in v0.2.6

type IVirtualGroupClient interface {
	QueryVirtualGroupFamily(ctx context.Context, globalVirtualGroupFamilyID uint32) (*types.GlobalVirtualGroupFamily, error)
	QuerySpAvailableGlobalVirtualGroupFamilies(ctx context.Context, spID uint32) ([]uint32, error)
	QuerySpOptimalGlobalVirtualGroupFamily(ctx context.Context, spID uint32, strategy types.PickVGFStrategy) (uint32, error)
	QueryVirtualGroupParams(ctx context.Context) (*types.Params, error)
}

IVirtualGroupClient interface defines basic functions related to Virtual Group.

type ListUserPublicKeyV2Resp added in v1.6.0

type ListUserPublicKeyV2Resp struct {
	PublicKeys []string `xml:"Result"`
}

ListUserPublicKeyV2Resp is the structure for off chain auth v2 ListUserPublicKeyV2 response.

type OffChainAuthOption added in v0.2.3

type OffChainAuthOption struct {
	// Seed is a EdDSA private key used for off-chain-auth.
	Seed string
	// Domain is the domain where the EdDSA keys will be registered for.
	Domain string
	// ShouldRegisterPubKey This should be set as true for the first time and could be set as false if the pubkey have been already been registered already.
	ShouldRegisterPubKey bool
}

OffChainAuthOption - The optional configurations for off-chain-auth.

The OffChainAuthOption consists of a EdDSA private key and the domain where the EdDSA keys will be registered for.

This auth mechanism is usually used in browser-based application. That we support OffChainAuth configuration in go-sdk is to make the tests on off-chain-auth be convenient.

type OffChainAuthOptionV2 added in v1.6.0

type OffChainAuthOptionV2 struct {
	// Seed is a EdDSA private key used for off-chain-auth.
	Seed string
	// Domain is the domain where the EdDSA keys will be registered for.
	Domain string
	// ShouldRegisterPubKey This should be set as true for the first time and could be set as false if the pubkey have been already been registered already.
	ShouldRegisterPubKey bool
	// PublicKey This will be set automatically once the public key is registered.
	PublicKey string
}

OffChainAuthOptionV2 - The optional configurations for off-chain-auth-v2.

The OffChainAuthOptionV2 consists of a EdDSA private key and the domain where the EdDSA keys will be registered for.

This auth mechanism is usually used in browser-based application. That we support OffChainAuth configuration in go-sdk is to make the tests on off-chain-auth-v2 be convenient.

type Option

type Option struct {
	// GrpcDialOption is the list of gRPC dial options used to configure the connection to the blockchain node.
	GrpcDialOption grpc.DialOption
	// DefaultAccount is the default account of Client.
	DefaultAccount *types.Account
	// Secure is a flag that specifies whether the Client should use HTTPS or not.
	Secure bool
	// Transport is the HTTP transport used to send requests to the storage provider endpoint.
	Transport http.RoundTripper
	// Host is the target sp server hostname.
	Host string
	// OffChainAuthOption consists of a EdDSA private key and the domain where the EdDSA keys will be registered for.
	//
	// This property should not be set in most cases unless you want to use go-sdk to test if the SP support off-chain-auth feature.
	// Once this property is set, the request will be signed in "GNFD1-EDDSA" way rather than GNFD1-ECDSA.
	OffChainAuthOption *OffChainAuthOption
	// OffChainAuthOptionV2 consists of a EdDSA private key and the domain where the EdDSA keys will be registered for.
	// It uses ed25519 curve.
	// This property should not be set in most cases unless you want to use go-sdk to test if the SP support off-chain-auth-v2 feature.
	// Once this property is set, the request will be signed in "GNFD2-EDDSA" way rather than GNFD2-ECDSA.
	OffChainAuthOptionV2 *OffChainAuthOptionV2
	// UseWebSocketConn specifies that connection to Chain is via websocket.
	UseWebSocketConn bool
	// ExpireSeconds indicates the number of seconds after which the authentication of the request sent to the SP will become invalid,the default value is 1000.
	ExpireSeconds uint64
	// ForceToUseSpecifiedSpEndpointForDownloadOnly indicates a fixed SP endpoint to which to send the download request
	// If this option is set, the client can only make download requests, and can only download from the fixed endpoint
	ForceToUseSpecifiedSpEndpointForDownloadOnly string
}

Option - Configurations for providing optional parameters for the Greenfield SDK Client.

Jump to

Keyboard shortcuts

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