initial commit
initial commit
This commit is contained in:
27
sui/base_api.go
Normal file
27
sui/base_api.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package sui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/block-vision/sui-go-sdk/httpconn"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
type IBaseAPI interface {
|
||||
SuiCall(ctx context.Context, method string, params ...interface{}) (interface{}, error)
|
||||
}
|
||||
|
||||
type suiBaseImpl struct {
|
||||
conn *httpconn.HttpConn
|
||||
}
|
||||
|
||||
// SuiCall send customized request to Sui Node endpoint.
|
||||
func (s *suiBaseImpl) SuiCall(ctx context.Context, method string, params ...interface{}) (interface{}, error) {
|
||||
resp, err := s.conn.Request(ctx, httpconn.Operation{
|
||||
Method: method,
|
||||
Params: params,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return gjson.ParseBytes(resp).String(), nil
|
||||
}
|
||||
Reference in New Issue
Block a user