Skip to content

Commit

Permalink
Merge pull request #71 from vegaprotocol/65-submit-transaction-v2
Browse files Browse the repository at this point in the history
Switch to SubmitTransactionV2 (#65)
  • Loading branch information
ashleyvega authored Jul 19, 2021
2 parents 7c9ebd6 + f2b8ac1 commit 9e97b48
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 203 deletions.
2 changes: 1 addition & 1 deletion bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type PricingEngine interface {
}

// New returns a new Bot instance.
func New(config config.BotConfig, pe PricingEngine, ws wallet.WalletHandler) (b Bot, err error) {
func New(config config.BotConfig, pe PricingEngine, ws *wallet.Handler) (b Bot, err error) {
switch config.Strategy {
case "normal":
b, err = normal.New(config, pe, ws)
Expand Down
8 changes: 4 additions & 4 deletions bot/normal/datarequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (b *Bot) lookupInitialValues() error {
func (b *Bot) getAccountGeneral() error {
response, err := b.node.PartyAccounts(&api.PartyAccountsRequest{
// MarketId: general account is not per market
PartyId: b.walletPubKeyHex,
PartyId: b.walletPubKey,
Asset: b.settlementAssetID,
Type: proto.AccountType_ACCOUNT_TYPE_GENERAL,
})
Expand All @@ -73,7 +73,7 @@ func (b *Bot) getAccountGeneral() error {
// getAccountMargin get this bot's margin account balance.
func (b *Bot) getAccountMargin() error {
response, err := b.node.PartyAccounts(&api.PartyAccountsRequest{
PartyId: b.walletPubKeyHex,
PartyId: b.walletPubKey,
MarketId: b.market.Id,
Asset: b.settlementAssetID,
Type: proto.AccountType_ACCOUNT_TYPE_MARGIN,
Expand All @@ -95,7 +95,7 @@ func (b *Bot) getAccountMargin() error {
func (b *Bot) getAccountBond() error {
b.balanceBond = 0
response, err := b.node.PartyAccounts(&api.PartyAccountsRequest{
PartyId: b.walletPubKeyHex,
PartyId: b.walletPubKey,
MarketId: b.market.Id,
Asset: b.settlementAssetID,
Type: proto.AccountType_ACCOUNT_TYPE_BOND,
Expand All @@ -116,7 +116,7 @@ func (b *Bot) getAccountBond() error {
// getPositions get this bot's positions.
func (b *Bot) getPositions() ([]*proto.Position, error) {
response, err := b.node.PositionsByParty(&api.PositionsByPartyRequest{
PartyId: b.walletPubKeyHex,
PartyId: b.walletPubKey,
MarketId: b.market.Id,
})
if err != nil {
Expand Down
14 changes: 0 additions & 14 deletions bot/normal/helpers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package normal

import (
"encoding/hex"
"fmt"
"math"
"time"

Expand All @@ -13,18 +11,6 @@ import (
"gonum.org/v1/gonum/stat/distuv"
)

func hexToRaw(hexBytes []byte) ([]byte, error) {
raw := make([]byte, hex.DecodedLen(len(hexBytes)))
n, err := hex.Decode(raw, hexBytes)
if err != nil {
return nil, errors.Wrap(err, "failed to decode hex")
}
if n != len(raw) {
return nil, fmt.Errorf("failed to decode hex: decoded %d bytes, expected to decode %d bytes", n, len(raw))
}
return raw, nil
}

func max(a, b uint64) uint64 {
if a > b {
return a
Expand Down
14 changes: 7 additions & 7 deletions bot/normal/mocks/node_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9e97b48

Please sign in to comment.