Skip to content

Commit

Permalink
adjusted kyc handling logic to try to reset kyc steps if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-ares committed Nov 17, 2023
1 parent 866da11 commit ff6470b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cmd/freezer-refrigerant:
jwtSecret: bogus
tokenomics: &tokenomics
kyc:
get-eskimo-user-state-url: https://something.example.com
try-reset-kyc-steps-url: https://something.example.com
config-json-url: https://ice-staging.b-cdn.net/something/somebogus.json
liveness-delay: 5m
bookkeeper/storage: &bookkeeperStorage
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1
github.com/goccy/go-json v0.10.2
github.com/hashicorp/go-multierror v1.1.1
github.com/ice-blockchain/eskimo v1.177.0
github.com/ice-blockchain/eskimo v1.180.0
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb
github.com/ice-blockchain/wintr v1.125.0
github.com/imroc/req/v3 v3.42.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ice-blockchain/eskimo v1.177.0 h1:Asx8JtlbxC/G4qw8RX+NbXA6mg6mc7Qk22KtFHFZcgs=
github.com/ice-blockchain/eskimo v1.177.0/go.mod h1:ef73dtR1bff40EugXbhRtRScPyUuqQ8oult0QbciMLc=
github.com/ice-blockchain/eskimo v1.180.0 h1:fhg0elXwuhJq1jYyFkTbGZeO/OhtU9rS2+oPtUJLe9o=
github.com/ice-blockchain/eskimo v1.180.0/go.mod h1:oXuuEPPEB4UMqyACv8LnTogIn4uU0tFCd2Y6ci7T+g4=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb h1:8TnFP3mc7O+tc44kv2e0/TpZKnEVUaKH+UstwfBwRkk=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb/go.mod h1:ZsQU7i3mxhgBBu43Oev7WPFbIjP4TniN/b1UPNGbrq8=
github.com/ice-blockchain/wintr v1.125.0 h1:pk/SVyztstUF19+JDCufJRMXJeNpchVA4O26xp47l3Y=
Expand Down
6 changes: 3 additions & 3 deletions tokenomics/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ type (
disableAdvancedTeam *atomic.Pointer[[]string]
kycConfigJSON *atomic.Pointer[kycConfigJSON]
KYC struct {
GetEskimoUserStateURL string `yaml:"get-eskimo-user-state-url" mapstructure:"get-eskimo-user-state-url"`
ConfigJSONURL string `yaml:"config-json-url" mapstructure:"config-json-url"`
LivenessDelay stdlibtime.Duration `yaml:"liveness-delay" mapstructure:"liveness-delay"`
TryResetKYCStepsURL string `yaml:"try-reset-kyc-steps-url" mapstructure:"try-reset-kyc-steps-url"`
ConfigJSONURL string `yaml:"config-json-url" mapstructure:"config-json-url"`
LivenessDelay stdlibtime.Duration `yaml:"liveness-delay" mapstructure:"liveness-delay"`
} `yaml:"kyc" mapstructure:"kyc"`
AdoptionMilestoneSwitch struct {
ActiveUserMilestones []struct {
Expand Down
5 changes: 3 additions & 2 deletions tokenomics/kyc.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func (r *repository) isKYCEnabled(ctx context.Context, _ users.KYCStep) bool {

/*
Because existing users have empty KYCState in dragonfly cuz usersTableSource might not have updated it yet.
So we need to query Eskimo for the valid kyc state of the user to be sure.
And because we might need to reset any kyc steps for the user prior to starting to mine.
So we need to call Eskimo for that, to be sure we have the valid kyc state for the user before starting to mine.
*/
func (r *repository) overrideKYCStateWithEskimoKYCState(ctx context.Context, userID string, state *KYCState) error {
if resp, err := req.
Expand All @@ -187,7 +188,7 @@ func (r *repository) overrideKYCStateWithEskimoKYCState(ctx context.Context, use
SetHeader("Cache-Control", "no-cache, no-store, must-revalidate").
SetHeader("Pragma", "no-cache").
SetHeader("Expires", "0").
Get(fmt.Sprintf("%v/users/%v", r.cfg.KYC.GetEskimoUserStateURL, userID)); err != nil {
Post(fmt.Sprintf("%v/users/%v", r.cfg.KYC.TryResetKYCStepsURL, userID)); err != nil {
return errors.Wrapf(err, "failed to fetch eskimo user state for userID:%v", userID)
} else if data, err2 := resp.ToBytes(); err2 != nil {
return errors.Wrapf(err2, "failed to read body of eskimo user state request for userID:%v", userID)
Expand Down

0 comments on commit ff6470b

Please sign in to comment.