Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a98d707e48 |
@ -280,7 +280,7 @@ func (c *Client) StartContractByYPK(isPrivate bool, path string, script string)
|
||||
func (c *Client) ExecuteContract(
|
||||
contractID string,
|
||||
operation string,
|
||||
arg string,
|
||||
arg any,
|
||||
withDynamicAnalysis bool,
|
||||
withSignature bool,
|
||||
) (*HttpResponse[ExecuteContractResponse[any]], error) {
|
||||
@ -293,7 +293,18 @@ func (c *Client) ExecuteContract(
|
||||
}
|
||||
|
||||
if withSignature {
|
||||
body["signature"] = c.Sign(contractID+"|"+operation+"|"+arg+"|"+c.pubHex, nil, nil)
|
||||
argStr := ""
|
||||
if v, ok := arg.(string); ok {
|
||||
argStr = v
|
||||
} else {
|
||||
v, err := json.Marshal(arg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("arg %v marshal err", arg)
|
||||
}
|
||||
argStr = string(v)
|
||||
}
|
||||
|
||||
body["signature"] = c.Sign(contractID+"|"+operation+"|"+argStr+"|"+c.pubHex, nil, nil)
|
||||
body["pubkey"] = c.pubHex
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,14 @@ func TestStruct(t *testing.T) {
|
||||
}
|
||||
|
||||
func genClient() (*Client, error) {
|
||||
url := "http://021.node.internetapi.cn:43030/SCIDE"
|
||||
url := "http://127.0.0.1:21030/SCIDE"
|
||||
|
||||
pub, err := sm2util.ParsePublicKey("04153ad2d70e67741e0fc33e0c92c702e2afba2480dbea73d23fd02a3ce3a1b69979a7006a8e045f8836ae4797a8fe426823d7ad3450817e794948c8e47b60b711")
|
||||
pub, err := sm2util.ParsePublicKey("04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
priv, err := sm2util.ParsePrivateKey("31672b434458fdb6b854e64ededeb51305bc4d0bd258a5276ccb9bc86f7c03f6", pub)
|
||||
priv, err := sm2util.ParsePrivateKey("1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b", pub)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -86,7 +86,7 @@ func TestClient_ExecuteContract(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
resp, err := client.ExecuteContract("GlobalRouter", "resolveDoIdTest", "{\"doId\":\"bdtest021/ControlProxy\"}", false, true)
|
||||
resp, err := client.ExecuteContract("GlobalRouter", "listID", map[string]any{"offset": 0, "count": 12, "queryByCreateTime": "true", "filter": "prefixId"}, false, true)
|
||||
|
||||
if err != nil {
|
||||
t.Log(resp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user