Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 66cbc35

Browse files
authored
Merge pull request #43 from oxygenpay/develop
Deprecate BUSD
2 parents 5531d39 + ce41a2f commit 66cbc35

File tree

7 files changed

+31
-11
lines changed

7 files changed

+31
-11
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ Receive crypto including stablecoins with ease. Open new opportunities for your
3939
<img src="./ui-dashboard/src/assets/icons/crypto/usdc.svg" height="64" alt="usdc">
4040
<div>USDC</div>
4141
</td>
42-
<td align="center">
43-
<img src="./ui-dashboard/src/assets/icons/crypto/busd.svg" height="64" alt="busd">
44-
<div>BUSD</div>
45-
</td>
4642
</tr>
4743
</table>
4844

internal/money/money.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type CryptoCurrency struct {
8383
TokenContractAddress string
8484
TestTokenContractAddress string
8585
Aliases []string
86+
Deprecated bool
8687
}
8788

8889
func (c CryptoCurrency) DisplayName() string {

internal/server/http/merchantapi/merchant_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestMerchantRoutes(t *testing.T) {
9191
mt, _ := tc.Must.CreateMerchant(t, user.ID)
9292

9393
// And blockchain currencies
94-
allCurrencies := tc.Services.Blockchain.ListSupportedCurrencies()
94+
allCurrencies := tc.Services.Blockchain.ListSupportedCurrencies(false)
9595

9696
// ACT 1
9797
// Get merchant

internal/server/http/paymentapi/payment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
func TestHandlers(t *testing.T) {
3131
tc := test.NewIntegrationTest(t)
3232

33-
allCurrencies := tc.Services.Blockchain.ListSupportedCurrencies()
33+
allCurrencies := tc.Services.Blockchain.ListSupportedCurrencies(false)
3434

3535
t.Run("GetSupportedMethods", func(t *testing.T) {
3636
t.Run("Returns list of supported methods", func(t *testing.T) {

internal/service/blockchain/currencies.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
type Resolver interface {
20-
ListSupportedCurrencies() []money.CryptoCurrency
20+
ListSupportedCurrencies(withDeprecated bool) []money.CryptoCurrency
2121
ListBlockchainCurrencies(blockchain money.Blockchain) []money.CryptoCurrency
2222
GetCurrencyByTicker(ticker string) (money.CryptoCurrency, error)
2323
GetNativeCoin(blockchain money.Blockchain) (money.CryptoCurrency, error)
@@ -138,12 +138,16 @@ func (r *CurrencyResolver) GetCurrencyByBlockchainAndContract(bc money.Blockchai
138138
return money.CryptoCurrency{}, ErrCurrencyNotFound
139139
}
140140

141-
func (r *CurrencyResolver) ListSupportedCurrencies() []money.CryptoCurrency {
141+
func (r *CurrencyResolver) ListSupportedCurrencies(withDeprecated bool) []money.CryptoCurrency {
142142
r.mu.RLock()
143143
defer r.mu.RUnlock()
144144

145145
results := make([]money.CryptoCurrency, 0)
146146
for i := range r.currencies {
147+
if r.currencies[i].Deprecated && !withDeprecated {
148+
continue
149+
}
150+
147151
results = append(results, r.currencies[i])
148152
}
149153

@@ -181,6 +185,10 @@ func (r *CurrencyResolver) addCurrency(currency money.CryptoCurrency) {
181185

182186
r.ensureIndices(currency.Blockchain, currency.Ticker)
183187

188+
if currency.Deprecated {
189+
return
190+
}
191+
184192
// add currency to "index"
185193
r.blockchainCurrencies[currency.Blockchain][currency.Ticker] = struct{}{}
186194

@@ -281,6 +289,11 @@ func DefaultSetup(s *CurrencyResolver) error {
281289
return err
282290
}
283291

292+
deprecated, err := parseBool(c["deprecated"])
293+
if err != nil {
294+
return err
295+
}
296+
284297
ticker := c["ticker"]
285298

286299
s.addCurrency(money.CryptoCurrency{
@@ -295,6 +308,7 @@ func DefaultSetup(s *CurrencyResolver) error {
295308
TestTokenContractAddress: testTokenAddr,
296309
Aliases: aliases,
297310
Decimals: int64(decimals),
311+
Deprecated: deprecated,
298312
})
299313

300314
s.addMinimalWithdrawal(ticker, minimalWithdrawal)
@@ -372,6 +386,14 @@ func parseUSD(raw string) (money.Money, error) {
372386
return money.FiatFromFloat64(money.USD, f)
373387
}
374388

389+
func parseBool(raw string) (bool, error) {
390+
if raw == "" {
391+
return false, nil
392+
}
393+
394+
return strconv.ParseBool(raw)
395+
}
396+
375397
func parseAliases(raw string) []string {
376398
if raw == "" {
377399
return nil

internal/service/blockchain/currencies.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"networkId": "56",
141141
"testNetworkId": "97",
142142
"minimal_withdrawal_amount_usd": "10",
143-
"minimal_instant_internal_transfer_amount_usd": "30"
143+
"minimal_instant_internal_transfer_amount_usd": "30",
144+
"deprecated": "true"
144145
}
145146
]

internal/service/merchant/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ type SupportedCurrency struct {
157157
}
158158

159159
func (s *Service) ListSupportedCurrencies(_ context.Context, merchant *Merchant) ([]SupportedCurrency, error) {
160-
all := s.blockchain.ListSupportedCurrencies()
160+
all := s.blockchain.ListSupportedCurrencies(false)
161161
enabledTickers := util.Set(merchant.Settings().PaymentMethods())
162162

163163
// if merchant didn't set this parameter yet, let's treat that as "all currencies enabled"
@@ -197,7 +197,7 @@ func (s *Service) UpdateSupportedMethods(ctx context.Context, merchant *Merchant
197197
tickersSet := util.Set(tickers)
198198
availableTickersSet := util.Set(
199199
util.MapSlice(
200-
s.blockchain.ListSupportedCurrencies(),
200+
s.blockchain.ListSupportedCurrencies(false),
201201
func(c money.CryptoCurrency) string { return c.Ticker },
202202
),
203203
)

0 commit comments

Comments
 (0)