Skip to content

Commit 99dcae4

Browse files
committed
change chain Api
1 parent 11345c6 commit 99dcae4

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

service/common/bean/bean.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ type CoreBaseReturn struct {
3131
Result interface{} `json:"result"`
3232
}
3333

34-
// QueryObjectResult struct
35-
type QueryObjectResult struct {
34+
// GetKeyValueResult struct
35+
type GetKeyValueResult struct {
3636
Contract string `json:"contract"`
3737
Object string `json:"object"`
3838
Key string `json:"key"`

service/common/data/chain.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ const (
3737
// BASE_URL BASE_URL
3838
BASE_URL = config.BASE_RPC
3939
// TX_PARAMS TX_PARAMS
40-
TX_PARAMS = "service=bottos&method=CoreApi.PushTrx&request=%s"
40+
TX_PARAMS = "service=bottos&method=Chain.SendTransaction&request=%s"
4141
)
4242

4343
// BlockHeader get block header
4444
func BlockHeader() (*user_proto.BlockHeader, error) {
45-
params := `service=bottos&method=CoreApi.QueryChainInfo&request={}`
45+
params := `service=bottos&method=Chain.GetInfo&request={}`
4646
resp, err := http.Post(BASE_URL, "application/x-www-form-urlencoded",
4747
strings.NewReader(params))
4848
if err != nil {
@@ -135,7 +135,7 @@ func PushTransaction(i interface{}) (*bean.CoreCommonReturn, error) {
135135

136136
// AccountInfo get account info
137137
func AccountInfo(account string) (*user_proto.AccountInfoData, error) {
138-
params := `service=bottos&method=CoreApi.QueryAccount&request={"account_name":"%s"}`
138+
params := `service=bottos&method=Chain.GetAccount&request={"account_name":"%s"}`
139139
resp, err := http.Post(BASE_URL, "application/x-www-form-urlencoded",
140140
strings.NewReader(fmt.Sprintf(params, string(account))))
141141
if err != nil {
@@ -197,10 +197,10 @@ func AccountInfo(account string) (*user_proto.AccountInfoData, error) {
197197
}
198198
}
199199

200-
// QueryObject get Object
201-
func QueryObject(contract, object, key string) ([]byte, error) {
202-
log.Info("Start QueryObject.")
203-
params := `service=bottos&method=CoreApi.QueryObject&request={"contract":"%s","object":"%s","key":"%s"}`
200+
// GetKeyValue get Object
201+
func GetKeyValue(contract, object, key string) ([]byte, error) {
202+
log.Info("Start GetKeyValue.")
203+
params := `service=bottos&method=Chain.GetKeyValue&request={"contract":"%s","object":"%s","key":"%s"}`
204204
resp, err := http.Post(BASE_URL, "application/x-www-form-urlencoded",
205205
strings.NewReader(fmt.Sprintf(params, contract, object, key)))
206206
//strings.NewReader(fmt.Sprintf(params, "bottoscontract", "DTO", "bbb")))
@@ -237,7 +237,7 @@ func QueryObject(contract, object, key string) ([]byte, error) {
237237
return nil, err
238238
}
239239

240-
var queryObjectRes = &bean.QueryObjectResult{}
240+
var queryObjectRes = &bean.GetKeyValueResult{}
241241
err = json.Unmarshal(resultBuf, queryObjectRes)
242242
if err != nil {
243243
log.Error(err)

service/contract/conApi/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*Copyright 2017~2022 The Bottos Authors
1+
/*Copyright 2017~2022 The Bottos Authors
22
This file is part of the Bottos Service Layer
33
Created by Developers Team of Bottos.
44
@@ -55,7 +55,7 @@ func (s *Contract) Query(ctx context.Context, req *api.Request, rsp *api.Respons
5555
return err
5656
}
5757

58-
params := `service=bottos&method=CoreApi.QueryAbi&request={"contract":"` + queryRequest.Contract + `"}`
58+
params := `service=bottos&method=Chain.GetAbi&request={"contract":"` + queryRequest.Contract + `"}`
5959
resp, err := http.Post(data.BASE_URL, "application/x-www-form-urlencoded",
6060
strings.NewReader(params))
6161
if err != nil {

service/user/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,13 @@ func (u *User) GetBalance(ctx context.Context, req *user_proto.GetBalanceRequest
393393
log.Info("GetBalance src Start!")
394394
btoToken := "BTO"
395395
dtoToken := "DTO"
396-
396+
//get BTO Amount
397397
accountInfo, err := data.AccountInfo(req.Username)
398398
if err != nil {
399399
log.Error(err)
400400
rsp.Code = 1100
401401
rsp.Msg = err.Error()
402+
return nil
402403
}
403404
log.Info(accountInfo.Balance)
404405
if accountInfo != nil {
@@ -412,7 +413,8 @@ func (u *User) GetBalance(ctx context.Context, req *user_proto.GetBalanceRequest
412413
})
413414
}
414415

415-
dtoAmountByte, err := data.QueryObject("bottostoken", dtoToken, req.Username)
416+
//get DTO Amount
417+
dtoAmountByte, err := data.GetKeyValue("bottostoken", dtoToken, req.Username)
416418

417419
if err != nil && !(strings.Contains(err.Error(), "10205")) {
418420
log.Error(err)

0 commit comments

Comments
 (0)