diff --git a/casper/rpc.go b/casper/rpc.go index caf4145..775fc9a 100644 --- a/casper/rpc.go +++ b/casper/rpc.go @@ -9,8 +9,10 @@ type ( RpcHandler = rpc.Handler RpcInformationalClient = rpc.ClientInformational InfoGetDeployResult = rpc.InfoGetDeployResult + InfoGetTransactionResult = rpc.InfoGetTransactionResult ChainGetBlockResult = rpc.ChainGetBlockResult ChainGetEraInfoResult = rpc.ChainGetEraInfoResult + StateGetEntity = rpc.StateGetEntityResult StateGetAuctionInfoResult = rpc.StateGetAuctionInfoResult StateGetItemResult = rpc.StateGetItemResult InfoGetStatusResult = rpc.InfoGetStatusResult diff --git a/rpc/client.go b/rpc/client.go index 5402622..11aff6c 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -96,11 +96,11 @@ type ClientInformational interface { GetAccountInfo(ctx context.Context, blockIdentifier *ParamBlockIdentifier, accountIdentifier AccountIdentifier) (StateGetAccountInfo, error) // GetLatestEntity returns latest AddressableEntity from the network. - GetLatestEntity(ctx context.Context, entityIdentifier EntityIdentifier) (StateGetEntity, error) + GetLatestEntity(ctx context.Context, entityIdentifier EntityIdentifier) (StateGetEntityResult, error) // GetEntityByBlockHash returns an AddressableEntity by block hash from the network. - GetEntityByBlockHash(ctx context.Context, entityIdentifier EntityIdentifier, hash string) (StateGetEntity, error) + GetEntityByBlockHash(ctx context.Context, entityIdentifier EntityIdentifier, hash string) (StateGetEntityResult, error) // GetEntityByBlockHeight returns an AddressableEntity by block height from the network. - GetEntityByBlockHeight(ctx context.Context, entityIdentifier EntityIdentifier, height uint64) (StateGetEntity, error) + GetEntityByBlockHeight(ctx context.Context, entityIdentifier EntityIdentifier, height uint64) (StateGetEntityResult, error) // GetLatestBlock returns the latest types.Block from the network. GetLatestBlock(ctx context.Context) (ChainGetBlockResult, error) diff --git a/rpc/response.go b/rpc/response.go index 5a4bc17..e04c07f 100644 --- a/rpc/response.go +++ b/rpc/response.go @@ -68,7 +68,7 @@ type AddressableEntity struct { EntryPoints []types.EntryPointValue `json:"entry_points,omitempty"` } -type StateGetEntity struct { +type StateGetEntityResult struct { ApiVersion string `json:"api_version"` // The addressable entity or a legacy account. Entity EntityOrAccount `json:"entity"` @@ -217,6 +217,19 @@ type InfoGetTransactionResult struct { rawJSON json.RawMessage } +func NewInfoGetTransactionResult( + apiVersion string, + transaction types.Transaction, + executionInfo *types.ExecutionInfo, + rawJSON json.RawMessage) InfoGetTransactionResult { + return InfoGetTransactionResult{ + APIVersion: apiVersion, + Transaction: transaction, + ExecutionInfo: executionInfo, + rawJSON: rawJSON, + } +} + func (b InfoGetTransactionResult) GetRawJSON() json.RawMessage { return b.rawJSON } diff --git a/rpc/rpc_client.go b/rpc/rpc_client.go index cdaaefe..a7ce034 100644 --- a/rpc/rpc_client.go +++ b/rpc/rpc_client.go @@ -217,36 +217,36 @@ func (c *client) QueryGlobalStateByStateHash(ctx context.Context, stateRootHash return result, nil } -func (c *client) GetLatestEntity(ctx context.Context, entityIdentifier EntityIdentifier) (StateGetEntity, error) { - var result StateGetEntity +func (c *client) GetLatestEntity(ctx context.Context, entityIdentifier EntityIdentifier) (StateGetEntityResult, error) { + var result StateGetEntityResult resp, err := c.processRequest(ctx, MethodGetStateEntity, ParamGetStateEntity{EntityIdentifier: entityIdentifier}, &result) if err != nil { - return StateGetEntity{}, err + return StateGetEntityResult{}, err } result.rawJSON = resp.Result return result, nil } -func (c *client) GetEntityByBlockHash(ctx context.Context, entityIdentifier EntityIdentifier, hash string) (StateGetEntity, error) { - var result StateGetEntity +func (c *client) GetEntityByBlockHash(ctx context.Context, entityIdentifier EntityIdentifier, hash string) (StateGetEntityResult, error) { + var result StateGetEntityResult resp, err := c.processRequest(ctx, MethodGetStateEntity, ParamGetStateEntity{EntityIdentifier: entityIdentifier, BlockIdentifier: &BlockIdentifier{Hash: &hash}}, &result) if err != nil { - return StateGetEntity{}, err + return StateGetEntityResult{}, err } result.rawJSON = resp.Result return result, nil } -func (c *client) GetEntityByBlockHeight(ctx context.Context, entityIdentifier EntityIdentifier, height uint64) (StateGetEntity, error) { - var result StateGetEntity +func (c *client) GetEntityByBlockHeight(ctx context.Context, entityIdentifier EntityIdentifier, height uint64) (StateGetEntityResult, error) { + var result StateGetEntityResult resp, err := c.processRequest(ctx, MethodGetStateEntity, ParamGetStateEntity{EntityIdentifier: entityIdentifier, BlockIdentifier: &BlockIdentifier{Height: &height}}, &result) if err != nil { - return StateGetEntity{}, err + return StateGetEntityResult{}, err } result.rawJSON = resp.Result