Skip to content

Commit

Permalink
Merge pull request #6 from blocktree/mzq_dev
Browse files Browse the repository at this point in the history
修改汇总任务结构
  • Loading branch information
zhiquan911 committed Apr 25, 2019
2 parents 016e3ea + 02d9aa7 commit d13ba3a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 4 deletions.
51 changes: 51 additions & 0 deletions openwsdk/model_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package openwsdk

import (
"encoding/json"
"github.com/blocktree/openwallet/common/file"
"github.com/blocktree/openwallet/hdkeystore"
"github.com/blocktree/openwallet/log"
Expand Down Expand Up @@ -49,3 +50,53 @@ func TestWallet_CreateAccount(t *testing.T) {
}
log.Infof("account:%+v", account)
}

func TestSummaryTaskUnmarshal(t *testing.T) {
plain := `
{
"wallets": [{
"walletID": "WN84dVZXpgVixsvXnU8jkFWD1qWHp15LpA",
"password": "12345678",
"accounts": [
{
"accountID": "A3Mxhqm65kTgS2ybHLenNrZzZNtLGVobDFYdpc1ge4eK",
"threshold": "1000",
"minTransfer": "1000",
"retainedBalance": "0",
"confirms": 1,
"feeRate": "0.0001",
"onlyContracts": false,
"contracts": {
"all": {
"threshold": "1000",
"minTransfer": "1000",
"retainedBalance": "0"
},
"3qoe2ll2=": {
"threshold": "1000",
"minTransfer": "1000",
"retainedBalance": "0"
}
},
"feesSupportAccount": {
"accountID": "12323",
"lowBalanceWarning": "0.1"
}
},
{
"accountID": "3i26MQmtuWVVnw8GnRCVopG3pi8MaYU6RqWVV2E1hwJx",
"feeRate": "0.001"
}
]
}]
}
`
var summaryTask SummaryTask
err := json.Unmarshal([]byte(plain), &summaryTask)
if err != nil {
log.Error("json.Unmarshal error:", err)
return
}
}
20 changes: 16 additions & 4 deletions openwsdk/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,16 @@ func NewSummaryTask(result gjson.Result) *SummaryTask {
}

type SummaryAccountTask struct {
AccountID string `json:"accountID"`
Contracts []string `json:"contracts"`
FeeRate string `json:"feeRate"`
SummarySetting *SummarySetting `json:"summarySetting"`
AccountID string `json:"accountID"`
Contracts map[string]*SummaryContractTask `json:"contracts"`
FeeRate string `json:"feeRate"`
OnlyContracts bool `json:"onlyContracts"`
FeesSupportAccount *FeesSupportAccount `json:"feesSupportAccount"`
*SummarySetting
}

type SummaryContractTask struct {
*SummarySetting
}

type SummaryWalletTask struct {
Expand Down Expand Up @@ -358,3 +364,9 @@ func NewTokenBalance(result gjson.Result) *TokenBalance {
}
return &b
}

// FeesSupportAccount 主币余额不足时,可选择一个账户提供手续费
type FeesSupportAccount struct {
AccountID string `json:"accountID"`
LowBalanceWarning string `json:"lowBalanceWarning"`
}

0 comments on commit d13ba3a

Please sign in to comment.