Skip to content

Commit

Permalink
Fix: atomex tezos storage
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Sep 30, 2021
1 parent ec59293 commit 120f323
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
20 changes: 10 additions & 10 deletions internal/chain/tezos/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (t *Tezos) parseContractValueUpdate(bigMapUpdate BigMapUpdate) error {

switch bigMapUpdate.Action {
case BigMapActionAddKey:
refundTime, err := time.Parse(time.RFC3339, value.Settings.RefundTime)
refundTime, err := time.Parse(time.RFC3339, value.RefundTime)
if err != nil {
return err
}
Expand All @@ -405,20 +405,20 @@ func (t *Tezos) parseContractValueUpdate(bigMapUpdate BigMapUpdate) error {
Chain: chain.ChainTypeTezos,
Contract: bigMapUpdate.Contract.Address,
},
Initiator: value.Recipients.Initiator,
Participant: value.Recipients.Participant,
Initiator: value.Initiator,
Participant: value.Participant,
RefundTime: refundTime,
}

if err := event.SetPayOff(value.Settings.Payoff, t.minPayoff); err != nil {
if err := event.SetPayOff(value.Payoff, t.minPayoff); err != nil {
if errors.Is(err, chain.ErrMinPayoff) {
log.Warn().Str("hashed_secret", event.HashedSecret.String()).Msg("skip because of small pay off")
return nil
}
return err
}

if err := event.SetAmountFromString(value.Settings.Amount); err != nil {
if err := event.SetAmountFromString(value.Amount); err != nil {
return err
}

Expand Down Expand Up @@ -576,7 +576,7 @@ func (t *Tezos) parseContractValueKeys(key api.BigMapKey, contract string) error
return err
}

refundTime, err := time.Parse(time.RFC3339, value.Settings.RefundTime)
refundTime, err := time.Parse(time.RFC3339, value.RefundTime)
if err != nil {
return err
}
Expand All @@ -587,20 +587,20 @@ func (t *Tezos) parseContractValueKeys(key api.BigMapKey, contract string) error
Chain: chain.ChainTypeTezos,
Contract: contract,
},
Initiator: value.Recipients.Initiator,
Participant: value.Recipients.Participant,
Initiator: value.Initiator,
Participant: value.Participant,
RefundTime: refundTime,
}

if err := event.SetPayOff(value.Settings.Payoff, t.minPayoff); err != nil {
if err := event.SetPayOff(value.Payoff, t.minPayoff); err != nil {
if errors.Is(err, chain.ErrMinPayoff) {
log.Warn().Str("hashed_secret", event.HashedSecret.String()).Msg("skip because of small pay off")
return nil
}
return err
}

if err := event.SetAmountFromString(value.Settings.Amount); err != nil {
if err := event.SetAmountFromString(value.Amount); err != nil {
return err
}

Expand Down
14 changes: 5 additions & 9 deletions internal/chain/tezos/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ const (

// AtomexValue -
type AtomexValue struct {
Settings struct {
Amount string `json:"amount" mapstructure:"amount"`
Payoff string `json:"payoff" mapstructure:"payoff"`
RefundTime string `json:"refund_time" mapstructure:"refund_time"`
} `json:"settings" mapstructure:"settings"`
Recipients struct {
Initiator string `json:"initiator" mapstructure:"initiator"`
Participant string `json:"participant" mapstructure:"participant"`
} `json:"recipients" mapstructure:"recipients"`
Amount string `json:"amount" mapstructure:"amount"`
Payoff string `json:"payoff" mapstructure:"payoff"`
RefundTime string `json:"refund_time" mapstructure:"refund_time"`
Initiator string `json:"initiator" mapstructure:"initiator"`
Participant string `json:"participant" mapstructure:"participant"`
}

// AtomexTokenValue -
Expand Down

0 comments on commit 120f323

Please sign in to comment.