-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[R4R]add Timelock api; add stake message types (#40)
* add stake message;support timelock message * add timelock testcase * format goimports
- Loading branch information
Showing
11 changed files
with
768 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package transaction | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/binance-chain/go-sdk/common/types" | ||
"github.com/binance-chain/go-sdk/types/msg" | ||
"github.com/binance-chain/go-sdk/types/tx" | ||
) | ||
|
||
type TimeLockResult struct { | ||
tx.TxCommitResult | ||
LockId int64 `json:"lock_id"` | ||
} | ||
|
||
func (c *client) TimeLock(description string, amount types.Coins, lockTime int64, sync bool, options ...Option) (*TimeLockResult, error) { | ||
fromAddr := c.keyManager.GetAddr() | ||
|
||
lockMsg := msg.NewTimeLockMsg(fromAddr, description, amount, lockTime) | ||
err := lockMsg.ValidateBasic() | ||
if err != nil { | ||
return nil, err | ||
} | ||
commit, err := c.broadcastMsg(lockMsg, sync, options...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var lockId int64 | ||
if commit.Ok && sync { | ||
lockId, err = strconv.ParseInt(string(commit.Data), 10, 64) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return &TimeLockResult{*commit, lockId}, err | ||
} | ||
|
||
type TimeUnLockResult struct { | ||
tx.TxCommitResult | ||
LockId int64 `json:"lock_id"` | ||
} | ||
|
||
func (c *client) TimeUnLock(id int64, sync bool, options ...Option) (*TimeUnLockResult, error) { | ||
fromAddr := c.keyManager.GetAddr() | ||
|
||
unlockMsg := msg.NewTimeUnlockMsg(fromAddr, id) | ||
err := unlockMsg.ValidateBasic() | ||
if err != nil { | ||
return nil, err | ||
} | ||
commit, err := c.broadcastMsg(unlockMsg, sync, options...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var lockId int64 | ||
if commit.Ok && sync { | ||
lockId, err = strconv.ParseInt(string(commit.Data), 10, 64) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return &TimeUnLockResult{*commit, lockId}, err | ||
} | ||
|
||
type TimeReLockResult struct { | ||
tx.TxCommitResult | ||
LockId int64 `json:"lock_id"` | ||
} | ||
|
||
func (c *client) TimeReLock(id int64, description string, amount types.Coins, lockTime int64, sync bool, options ...Option) (*TimeReLockResult, error) { | ||
fromAddr := c.keyManager.GetAddr() | ||
|
||
relockMsg := msg.NewTimeRelockMsg(fromAddr, id, description, amount, lockTime) | ||
err := relockMsg.ValidateBasic() | ||
if err != nil { | ||
return nil, err | ||
} | ||
commit, err := c.broadcastMsg(relockMsg, sync, options...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var lockId int64 | ||
if commit.Ok && sync { | ||
lockId, err = strconv.ParseInt(string(commit.Data), 10, 64) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return &TimeReLockResult{*commit, lockId}, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,6 @@ func (pt ProposalKind) String() string { | |
} | ||
} | ||
|
||
|
||
type ProposalStatus byte | ||
|
||
//nolint | ||
|
Oops, something went wrong.