Skip to content

Commit 13ed2c0

Browse files
authored
chore: remove promotion.Service.hotWallet (#2549)
promotion.Service.hotWallet is not used after the initialization. Thus the role of the relevant initialization code is reduced to verifying the grant wallet environment. But this is done in IsUserKYC in any case. So remove the relevant code.
1 parent c84e19f commit 13ed2c0

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

services/promotion/service.go

-51
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,19 @@ package promotion
22

33
import (
44
"context"
5-
"encoding/hex"
6-
"errors"
75
"fmt"
86
"os"
97
"sync"
108
"time"
119

12-
"github.com/brave-intl/bat-go/libs/altcurrency"
1310
"github.com/brave-intl/bat-go/libs/clients/cbr"
1411
"github.com/brave-intl/bat-go/libs/clients/reputation"
1512
appctx "github.com/brave-intl/bat-go/libs/context"
16-
errorutils "github.com/brave-intl/bat-go/libs/errors"
17-
"github.com/brave-intl/bat-go/libs/httpsignature"
1813
kafkautils "github.com/brave-intl/bat-go/libs/kafka"
19-
w "github.com/brave-intl/bat-go/libs/wallet"
20-
"github.com/brave-intl/bat-go/libs/wallet/provider/uphold"
2114
"github.com/brave-intl/bat-go/services/wallet"
2215
"github.com/linkedin/goavro"
2316
"github.com/prometheus/client_golang/prometheus"
2417
"github.com/segmentio/kafka-go"
25-
"golang.org/x/crypto/ed25519"
2618
)
2719

2820
const localEnv = "local"
@@ -89,7 +81,6 @@ type Service struct {
8981
kafkaWriter *kafka.Writer
9082
kafkaDialer *kafka.Dialer
9183
kafkaAdminAttestationReader kafkautils.Consumer
92-
hotWallet *uphold.Wallet
9384
pauseSuggestionsUntil time.Time
9485
pauseSuggestionsUntilMu sync.RWMutex
9586
}
@@ -117,44 +108,6 @@ func (service *Service) InitKafka(ctx context.Context) error {
117108
return nil
118109
}
119110

120-
// InitHotWallet by reading the keypair and card id from the environment
121-
func (service *Service) InitHotWallet(ctx context.Context) error {
122-
grantWalletPublicKeyHex := os.Getenv("GRANT_WALLET_PUBLIC_KEY")
123-
grantWalletPrivateKeyHex := os.Getenv("GRANT_WALLET_PRIVATE_KEY")
124-
grantWalletCardID := os.Getenv("GRANT_WALLET_CARD_ID")
125-
126-
if len(grantWalletCardID) > 0 {
127-
var info w.Info
128-
info.Provider = "uphold"
129-
info.ProviderID = grantWalletCardID
130-
{
131-
tmp := altcurrency.BAT
132-
info.AltCurrency = &tmp
133-
}
134-
135-
var pubKey httpsignature.Ed25519PubKey
136-
var privKey ed25519.PrivateKey
137-
var err error
138-
139-
pubKey, err = hex.DecodeString(grantWalletPublicKeyHex)
140-
if err != nil {
141-
return errorutils.Wrap(err, "grantWalletPublicKeyHex is invalid")
142-
}
143-
privKey, err = hex.DecodeString(grantWalletPrivateKeyHex)
144-
if err != nil {
145-
return errorutils.Wrap(err, "grantWalletPrivateKeyHex is invalid")
146-
}
147-
148-
service.hotWallet, err = uphold.New(ctx, info, privKey, pubKey)
149-
if err != nil {
150-
return err
151-
}
152-
} else if os.Getenv("ENV") != localEnv {
153-
return errors.New("GRANT_WALLET_CARD_ID must be set in production")
154-
}
155-
return nil
156-
}
157-
158111
// InitService creates a service using the passed datastore and clients configured from the environment
159112
func InitService(
160113
ctx context.Context,
@@ -212,10 +165,6 @@ func InitService(
212165
return nil, err
213166
}
214167

215-
err = service.InitHotWallet(ctx)
216-
if err != nil {
217-
return nil, err
218-
}
219168
return service, nil
220169
}
221170

0 commit comments

Comments
 (0)