From f8a8794f92449092b0e02feae01e9182dfc7fac0 Mon Sep 17 00:00:00 2001 From: wuaoxiang Date: Mon, 14 Oct 2024 11:46:08 +0800 Subject: [PATCH 1/5] Fix: SuiDevInspectTransactionBlock example and parse results in rsp --- examples/transaction/main.go | 15 ++++++++++++--- models/read_transaction.go | 1 + sui/read_transaction_api.go | 24 +++++++++++++++--------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/examples/transaction/main.go b/examples/transaction/main.go index 2a977d3..d9fadc7 100644 --- a/examples/transaction/main.go +++ b/examples/transaction/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "encoding/json" "fmt" "github.com/block-vision/sui-go-sdk/constant" @@ -34,6 +35,7 @@ func main() { //BatchTransaction() //SuiExecuteTransactionBlock() //SuiDryRunTransactionBlock() + //SuiDevInspectTransactionBlock() //SignAndExecuteTransactionBlock() } @@ -72,11 +74,12 @@ 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 { @@ -84,6 +87,12 @@ func SuiDevInspectTransactionBlock() { return } + var moveCallReturn []moveCallResult + err = json.Unmarshal(rsp.Results, &moveCallReturn) + if err != nil { + fmt.Println("json", err.Error()) + return + } utils.PrettyPrint(rsp) } diff --git a/models/read_transaction.go b/models/read_transaction.go index ec8a35a..45bf03d 100644 --- a/models/read_transaction.go +++ b/models/read_transaction.go @@ -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 { diff --git a/sui/read_transaction_api.go b/sui/read_transaction_api.go index 0205405..d0e849d 100644 --- a/sui/read_transaction_api.go +++ b/sui/read_transaction_api.go @@ -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 } From de9721d2efaa423adcf43e0a25ad0d8a06754fed Mon Sep 17 00:00:00 2001 From: Zoro Date: Mon, 21 Oct 2024 17:40:49 +0800 Subject: [PATCH 2/5] docs: remove duplicate `comments` --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf7ad02..3b26911 100644 --- a/README.md +++ b/README.md @@ -829,11 +829,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! From 1c00a409d1c4f05c8ecf117b10ac9d567458f9dd Mon Sep 17 00:00:00 2001 From: levisyin Date: Mon, 21 Oct 2024 21:29:44 +0800 Subject: [PATCH 3/5] fix: update faucet endpoint to latest --- constant/rpc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/constant/rpc.go b/constant/rpc.go index c74aa25..dd9430f 100644 --- a/constant/rpc.go +++ b/constant/rpc.go @@ -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 ( From b955d05328c758606f4ca5ed524dff825bd82578 Mon Sep 17 00:00:00 2001 From: testnode <51869602+netquery@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:16:52 +0800 Subject: [PATCH 4/5] Update README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b26911..e69a804 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,8 @@ ## 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. - +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. Powred by [SuiVision](https://suivision.xyz/) team. ### Features From 621fc57b56d71478525aabc05232a8a0d827d3d9 Mon Sep 17 00:00:00 2001 From: testnode <51869602+netquery@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:17:17 +0800 Subject: [PATCH 5/5] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e69a804..b88af96 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ 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. -Powred by [SuiVision](https://suivision.xyz/) team. +Powered by [SuiVision](https://suivision.xyz/) team. ### Features