Skip to content

Commit

Permalink
Fix SuiSystemState type err
Browse files Browse the repository at this point in the history
  • Loading branch information
JaydenLink authored and JaydenLink committed Nov 15, 2024
2 parents 131c245 + 621fc57 commit 5c94dd9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

## Overview

The Sui-Go-SDK provided by BlockVision aims to offer access to all Sui RPC methods with Golang and also offers some
additional features that make the integration easier. Sui-Go-SDK is designed for [Sui](https://github.com/MystenLabs/sui) in Go programming language.

Powred by [SuiVision](https://suivision.xyz/) team.
The Sui-Go-SDK aims to offer access to all Sui RPC methods with Golang and also offers some
additional features that make the integration easier.
Powered by [SuiVision](https://suivision.xyz/) team.

### Features

Expand Down Expand Up @@ -829,11 +828,11 @@ func main() {
```

## API Documentation
The Go Client SDK API documentation is currently available at [godoc.org](https://pkg.go.dev/github.com/block-vision/sui-go-sdk).
The Go Client SDK API documentation is currently available at [pkg.go.dev](https://pkg.go.dev/github.com/block-vision/sui-go-sdk).

## Contribution

+ We welcome your suggestions, comments (including criticisms), comments and contributions.
+ We welcome your suggestions, comments (including criticisms) and contributions.
+ Please follow the PR/issue template provided to ensure that your contributions are clear and easy to understand.
+ Thank you to all the people who participate in building better infrastructure!

Expand Down
6 changes: 3 additions & 3 deletions constant/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const (
WssSuiTestnetEndpoint = "wss://fullnode.testnet.sui.io"
WssSuiMainnetEndpoint = "wss://fullnode.mainnet.sui.io"

FaucetTestnetEndpoint = "https://faucet.testnet.sui.io/gas"
FaucetDevnetEndpoint = "https://faucet.devnet.sui.io"
FaucetLocalnetEndpoint = "http://127.0.0.1:9123"
FaucetTestnetEndpoint = "https://faucet.testnet.sui.io/v1/gas"
FaucetDevnetEndpoint = "https://faucet.devnet.sui.io/v1/gas"
FaucetLocalnetEndpoint = "http://127.0.0.1:9123/gas"
)

const (
Expand Down
15 changes: 12 additions & 3 deletions examples/transaction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"encoding/json"
"fmt"

"github.com/block-vision/sui-go-sdk/constant"
Expand Down Expand Up @@ -34,6 +35,7 @@ func main() {
//BatchTransaction()
//SuiExecuteTransactionBlock()
//SuiDryRunTransactionBlock()
//SuiDevInspectTransactionBlock()
//SignAndExecuteTransactionBlock()
}

Expand Down Expand Up @@ -72,18 +74,25 @@ func SuiDryRunTransactionBlock() {
}

func SuiDevInspectTransactionBlock() {
type moveCallResult struct {
ReturnValues [2]interface{}
}
rsp, err := cli.SuiDevInspectTransactionBlock(ctx, models.SuiDevInspectTransactionBlockRequest{
Sender: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
TxBytes: "AAACAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQEAAAAAAAAAAQEAjgDW4hJZlqvw654RGR3SdndKkdjoC0pzXQLxja/NUahLowQAAAAAACBEQGwClI9RQX68dzbN7PN29/Pw/Sc1hbtZwNAny7wZ+wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMKc3VpX3N5c3RlbRZyZXF1ZXN0X3dpdGhkcmF3X3N0YWtlAAIBAAABAQC3+Y0yfxn2dDR+HkBkFAglMULW5+UJOnyW7ajN/X2btQEqzrI5x8BMQ6LjmCSgAykfjisdYCcyTfW79nyzDB/PvtZBpwAAAAAAIAm+IREDziwoZLm7lc4ZKegZ2J5viEgoss9zgrFkHLh6t/mNMn8Z9nQ0fh5AZBQIJTFC1uflCTp8lu2ozf19m7XoAwAAAAAAAFDhjyoAAAAAAA==",
GasPrice: "1000",
Epoch: "87",
TxBytes: "AAUBAFIMicbHjFZu7Q6/JPhUqMItj90GpvFq0B8Qja1/G6rqFSjPCgAAAAAgU+6E0DJf97dwaRV0MdseKxCPU97monpYtyfJSa7jKQAACKCGAQAAAAAAAAiAlpgAAAAAAAABAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYtKc8KAAAAACBhjSVWnhYSnxbZuJWgDlXi2j3pp7gqJJizx29rU/Ly+QEAy/R0ipZdRp6jo2zwzMV0O5bC0K5t7gdi7T7KZfrAf34EcG9vbBBnZXRfbGV2ZWwyX3JhbmdlAgcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgNzdWkDU1VJAAf3FSwFkwSAzXQNcxG1uLRcb0iOOlOhHD90pvrDalLg1wZEQlVTREMGREJVU0RDAAUBAAABAQABAgABAwABBAA=",
})

if err != nil {
fmt.Println(err.Error())
return
}

var moveCallReturn []moveCallResult
err = json.Unmarshal(rsp.Results, &moveCallReturn)
if err != nil {
fmt.Println("json", err.Error())
return
}
utils.PrettyPrint(rsp)
}

Expand Down
1 change: 1 addition & 0 deletions models/read_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ type SuiTransactionBlockResponse struct {
TimestampMs string `json:"timestampMs,omitempty"`
Checkpoint string `json:"checkpoint,omitempty"`
ConfirmedLocalExecution bool `json:"confirmedLocalExecution,omitempty"`
Results json.RawMessage `json:"results,omitempty"`
}

func (o ObjectChange) GetObjectChangeAddressOwner() string {
Expand Down
24 changes: 15 additions & 9 deletions sui/read_transaction_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,29 @@ func (s *suiReadTransactionFromSuiImpl) SuiDryRunTransactionBlock(ctx context.Co
// Which allows for nearly any transaction (or Move call) with any arguments.
// Detailed results are provided, including both the transaction effects and any return values.
func (s *suiReadTransactionFromSuiImpl) SuiDevInspectTransactionBlock(ctx context.Context, req models.SuiDevInspectTransactionBlockRequest) (models.SuiTransactionBlockResponse, error) {
params := []interface{}{
req.Sender,
req.TxBytes,
}
if req.GasPrice != "" {
params = append(params, req.GasPrice)
}
if req.Epoch != "" {
params = append(params, req.Epoch)
}
var rsp models.SuiTransactionBlockResponse
respBytes, err := s.conn.Request(ctx, httpconn.Operation{
Method: "sui_devInspectTransactionBlock",
Params: []interface{}{
req.Sender,
req.TxBytes,
req.GasPrice,
req.Epoch,
},
Params: params,
})
if err != nil {
return rsp, err
}
if gjson.ParseBytes(respBytes).Get("error").Exists() {
return rsp, errors.New(gjson.ParseBytes(respBytes).Get("error").String())
parsedJson := gjson.ParseBytes(respBytes)
if parsedJson.Get("error").Exists() {
return rsp, errors.New(parsedJson.Get("error").String())
}
err = json.Unmarshal([]byte(gjson.ParseBytes(respBytes).Get("result").Raw), &rsp)
err = json.Unmarshal([]byte(parsedJson.Get("result").Raw), &rsp)
if err != nil {
return rsp, err
}
Expand Down

0 comments on commit 5c94dd9

Please sign in to comment.