initial commit

initial commit
This commit is contained in:
jiang
2022-09-06 11:03:29 +08:00
parent fa1097d391
commit ecff7d8ec1
38 changed files with 2945 additions and 1 deletions

27
sui/base_api.go Normal file
View 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
}