Skip to content

Commit 87b6dba

Browse files
authored
Merge pull request #86 from blocktree/mzq_dev
fix bug
2 parents 5933dff + d2abe5d commit 87b6dba

File tree

4 files changed

+58
-47
lines changed

4 files changed

+58
-47
lines changed

openwsdk/api_node_test.go

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
func init() {
20-
owtp.Debug = false
20+
owtp.Debug = true
2121
}
2222

2323
func testNewAPINode() *APINode {
@@ -220,7 +220,7 @@ func TestAPINode_CreateAccount(t *testing.T) {
220220
func TestAPINode_FindAccountByWalletID(t *testing.T) {
221221
walletID := "W1iymivnBrjxtQdbm9esyheuy3mLeJWHto"
222222
api := testNewAPINode()
223-
api.FindAccountByWalletID("ETH", walletID, 0, 0, true,
223+
api.FindAccountByWalletID("", walletID, 0, 0, true,
224224
func(status uint64, msg string, accounts []*Account) {
225225

226226
if status != owtp.StatusSuccess {
@@ -814,78 +814,85 @@ func TestAPINode_FollowSmartContractRecepit(t *testing.T) {
814814
func TestAPINode_CreateSmartContractTrade(t *testing.T) {
815815

816816
var (
817-
retRawTx *SmartContractRawTransaction
818-
retTx []*SmartContractReceipt
819-
retFailed []*FailureSmartContractLog
820-
err error
821-
key *hdkeystore.HDKey
822-
accountID = "5kTzFGuAH9UkB9yhZdmXtF8hGPh6iPt4hf8Q3DVy3Xo3"
817+
retRawTx *SmartContractRawTransaction
818+
//retTx []*SmartContractReceipt
819+
//retFailed []*FailureSmartContractLog
820+
err error
821+
//key *hdkeystore.HDKey
822+
accountID = "Eh2ALZguch6DS2JaoFz97ZspvBvv56FjB79CVVkqc1aA"
823823
sid = uuid.New().String()
824824
coin = Coin{
825-
Symbol: "QUORUM",
825+
Symbol: "MATIC",
826826
IsContract: true,
827-
ContractID: "dl8WD7bM7xk4ZxRybuHCo3JDDtZn2ugPusapoKnQEWA=",
827+
ContractID: openwallet.GenContractID("MATIC", "0x9866c45224667061f8c9e66db38d9316a8d68951"),
828828
}
829-
abiParam = []string{"transfer", "0x19a4b5d6ea319a5d5ad1d4cc00a5e2e28cac5ec3", "123"}
829+
//abiParam = []string{"transfer", "0x19a4b5d6ea319a5d5ad1d4cc00a5e2e28cac5ec3", "123"}
830+
raw = "{\"gas\":\"0x11118\",\"from\":\"0x282425dd54156902ead4a99ec7e80a21213d878d\",\"to\":\"0x9faef544a1c9a3ccab003174bb62a32e3aaab719\",\"data\":\"0xa22cb4650000000000000000000000000c58c1170f1ded633862a1166f52107490a9c5940000000000000000000000000000000000000000000000000000000000000001\"}"
830831
)
831832

832833
api := testNewAPINode()
833-
api.CreateSmartContractTrade(sid, accountID, coin, abiParam, "", 0, "", "1", true,
834+
err = api.CreateSmartContractTrade(sid, accountID, coin, nil, raw, openwallet.TxRawTypeJSON, "", "0", true,
834835
func(status uint64, msg string, rawTx *SmartContractRawTransaction) {
835836
if status != owtp.StatusSuccess {
836837
err = fmt.Errorf(msg)
837838
return
838839
}
839840
retRawTx = rawTx
840841
})
841-
log.Infof("rawTx: %+v", retRawTx)
842-
843-
key, err = testGetLocalKey()
844842
if err != nil {
845-
t.Logf("GetKey error: %v\n", err)
843+
t.Logf("CreateSmartContractTrade error: %v\n", err)
846844
return
847845
}
846+
log.Infof("rawTx: %+v", retRawTx)
848847

849-
//签名交易单
850-
signatures, signErr := SignTxHash(retRawTx.Signatures, key)
851-
if signErr != nil {
852-
t.Logf("SignRawTransaction unexpected error: %v\n", signErr)
853-
return
854-
}
855-
856-
retRawTx.Signatures = signatures
857-
retRawTx.AwaitResult = true
858-
859-
log.Infof("signed rawTx: %+v", retRawTx)
848+
/*
849+
key, err = testGetLocalKey()
850+
if err != nil {
851+
t.Logf("GetKey error: %v\n", err)
852+
return
853+
}
860854
861-
api.SubmitSmartContractTrade([]*SmartContractRawTransaction{retRawTx}, true,
862-
func(status uint64, msg string, successTx []*SmartContractReceipt, failedRawTxs []*FailureSmartContractLog) {
863-
if status != owtp.StatusSuccess {
864-
err = fmt.Errorf(msg)
855+
//签名交易单
856+
signatures, signErr := SignTxHash(retRawTx.Signatures, key)
857+
if signErr != nil {
858+
t.Logf("SignRawTransaction unexpected error: %v\n", signErr)
865859
return
866860
}
867861
868-
retTx = successTx
869-
retFailed = failedRawTxs
870-
})
862+
retRawTx.Signatures = signatures
863+
retRawTx.AwaitResult = true
871864
872-
log.Info("============== success ==============")
865+
log.Infof("signed rawTx: %+v", retRawTx)
873866
874-
for _, tx := range retTx {
875-
log.Infof("tx: %+v", tx)
867+
api.SubmitSmartContractTrade([]*SmartContractRawTransaction{retRawTx}, true,
868+
func(status uint64, msg string, successTx []*SmartContractReceipt, failedRawTxs []*FailureSmartContractLog) {
869+
if status != owtp.StatusSuccess {
870+
err = fmt.Errorf(msg)
871+
return
872+
}
876873
877-
for i, event := range tx.Events {
878-
log.Std.Notice("events[%d]: %+v", i, event)
879-
}
880-
}
874+
retTx = successTx
875+
retFailed = failedRawTxs
876+
})
881877
882-
log.Info("")
878+
log.Info("============== success ==============")
883879
884-
log.Info("============== fail ==============")
880+
for _, tx := range retTx {
881+
log.Infof("tx: %+v", tx)
885882
886-
for _, tx := range retFailed {
887-
log.Infof("tx: %+v", tx.Reason)
888-
}
883+
for i, event := range tx.Events {
884+
log.Std.Notice("events[%d]: %+v", i, event)
885+
}
886+
}
887+
888+
log.Info("")
889+
890+
log.Info("============== fail ==============")
891+
892+
for _, tx := range retFailed {
893+
log.Infof("tx: %+v", tx.Reason)
894+
}
895+
*/
889896
}
890897

891898
func TestAPINode_FindSmartContractReceiptByParams(t *testing.T) {

openwsdk/api_transmit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ func (transmit *TransmitNode) TriggerABIViaTrustNode(
676676
// @param address 必填 地址
677677
// @param symbol 可选 主链标识
678678
// @param hdPath 可选 子密钥路径
679+
// @param rsv 必填 是否rsv模式
679680
// @param sync 必填 是否同步线程
680681
// @param reqFunc 必填 回调函数处理
681682
func (transmit *TransmitNode) SignHashViaTrustNode(
@@ -687,6 +688,7 @@ func (transmit *TransmitNode) SignHashViaTrustNode(
687688
password string,
688689
symbol string,
689690
hdPath string,
691+
rsv bool,
690692
sync bool,
691693
reqFunc func(status uint64, msg string, signature string),
692694
) error {
@@ -707,6 +709,7 @@ func (transmit *TransmitNode) SignHashViaTrustNode(
707709
"password": password,
708710
"symbol": symbol,
709711
"hdPath": hdPath,
712+
"rsv": rsv,
710713
}
711714

712715
return transmit.node.Call(nodeID, "signHashViaTrustNode", params, sync, func(resp owtp.Response) {

openwsdk/api_transmit_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ func TestTransmitNode_SignHashViaTrustNode(t *testing.T) {
541541
password,
542542
symbol,
543543
hdPath,
544+
true,
544545
true, func(status uint64, msg string, signature string) {
545546
log.Infof("status: %d, msg: %s", status, msg)
546547
log.Infof("signature: %+v", signature)

openwsdk/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type Account struct {
132132
WalletID string `json:"walletID" bson:"walletID"`
133133
AccountID string `json:"accountID" bson:"accountID"`
134134
Alias string `json:"alias" bson:"alias"`
135-
Symbol string `json:"symbol" bson:"symbol"`
135+
Symbol string `json:"symbol" bson:"mainSymbol"`
136136
OtherOwnerKeys []string `json:"otherOwnerKeys" bson:"otherOwnerKeys"`
137137
ReqSigs int64 `json:"reqSigs" bson:"reqSigs"`
138138
IsTrust int64 `json:"isTrust" bson:"isTrust"`

0 commit comments

Comments
 (0)