-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
…feringRequirements(). one small test
tbdex/offering/offering.go
Outdated
@@ -47,9 +47,35 @@ type PayoutDetails struct { | |||
Methods []PayoutMethod `json:"methods,omitempty"` | |||
} | |||
|
|||
// PaymentMethod is an interface for PayinMethod and PayoutMethod. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i declared an interface for both PayinMethod and PayoutMethod to snap to, just so that i can write this:
func (r *RFQ) verifyPaymentMethod(
selectedPaymentKind string,
selectedPaymentDetailsHash string,
privateData *PrivateData,
offeringPaymentMethods []offering.PaymentMethod, // <- this part
payDirection PayDirection,
) error
without this, i would have had to resort to writing this function twice, one for verifyPayinMethod that passes in offeringPayinMethods []offering.PayinMethod
and verifyPayoutMethod that passes in offeringPayoutMethods []offering.PayoutMethod
go does not support type inheritance and this was my best attempt at it. open to other suggestions tho
tbdex/rfq/rfq.go
Outdated
payinAmount, err := strconv.ParseFloat(r.Data.Payin.Amount, 64) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse payin amount: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use this decimal lib instead of strconv.ParseFloat
tbdex/rfq/rfq.go
Outdated
maxAmount, err := strconv.ParseFloat(offering.Data.Payin.Max, 64) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse offering payin max amount: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use this decimal lib instead of strconv.ParseFloat
tbdex/rfq/rfq.go
Outdated
minAmount, err := strconv.ParseFloat(offering.Data.Payin.Min, 64) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse offering payin min amount: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use this decimal lib instead of strconv.ParseFloat
kk @jiyoontbd i think this PR is ready to review if you want to take a look! Changes
|
@@ -1,123 +0,0 @@ | |||
run: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did i delete this? we need this for linter settings right?
@@ -9,8 +9,14 @@ import ( | |||
"github.com/TBD54566975/tbdex-go/tbdex/closemsg" | |||
"github.com/TBD54566975/tbdex-go/tbdex/crypto" | |||
"github.com/TBD54566975/tbdex-go/tbdex/message" | |||
_offering "github.com/TBD54566975/tbdex-go/tbdex/offering" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to alias it like _offering
here?
} | ||
|
||
var min *decimal.Decimal | ||
maybeMins := []string{selectedPayinMethod.Min, offering.Data.Payin.Min} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh no! i see why you want to get rid of Payin.min
at the Payin level. it should be for each payment method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this wasn't what you were talking about but filed an issue
rfq.verifyOfferingRequirements
offering.create()
didn't always work because it was missing some bits like applying options, or missing a field, so I fixed those as well.