Skip to content

Commit 82e5820

Browse files
committed
Putting Rinkeby back in place for Exports, added a DISABLED flag to prevent it from being used in new payments
1 parent c7d9e2d commit 82e5820

2 files changed

Lines changed: 66 additions & 4 deletions

File tree

pretix_eth/exporter.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ def payment_to_row(payment):
2727
completion_date = ''
2828

2929
currency_type = payment.info_data.get("currency_type", "")
30-
token: IToken = all_token_and_network_ids_to_tokens[currency_type]
30+
token: IToken = all_token_and_network_ids_to_tokens.get(currency_type, None)
31+
32+
if token is None:
33+
chain_id = currency_type
34+
token_address = f"Missing ERC20 contract data for {currency_type}"
35+
else:
36+
chain_id = token.CHAIN_ID
37+
token_address = token.ADDRESS
3138

3239
fiat_amount = payment.amount
3340
token_amount = payment.info_data.get("amount", "")
@@ -60,8 +67,8 @@ def payment_to_row(payment):
6067
sender_address,
6168
recipient_address,
6269
transaction_hash,
63-
token.CHAIN_ID,
64-
token.ADDRESS,
70+
chain_id,
71+
token_address,
6572
]
6673
return row
6774

pretix_eth/network/tokens.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class IToken(object):
7575
ADDRESS = None # If a token, then the smart contract address.
7676
EIP3091_EXPLORER_URL = None # if set, allows links to transactions to be generated
7777
CHAIN_ID = None
78+
DISABLED = False
7879

7980
def __init__(self):
8081
self._validate_class_variables()
@@ -112,7 +113,7 @@ def is_allowed(self, rates: dict, network_ids: set):
112113
2. Check that the network is selected."""
113114
return (self.TOKEN_SYMBOL + "_RATE" in rates) and (
114115
self.NETWORK_IDENTIFIER in network_ids
115-
)
116+
) and not self.DISABLED
116117

117118
def get_ticket_price_in_token(self, total, rates):
118119
if not (self.TOKEN_SYMBOL + "_RATE" in rates):
@@ -224,6 +225,36 @@ def payment_instructions(
224225
}
225226

226227

228+
class RinkebyL1(L1):
229+
"""
230+
Constants for Rinkeby Ethereum Testnet
231+
"""
232+
233+
NETWORK_IDENTIFIER = "Rinkeby"
234+
NETWORK_VERBOSE_NAME = "Rinkeby Ethereum Testnet"
235+
CHAIN_ID = 4
236+
EIP3091_EXPLORER_URL = "https://rinkeby.etherscan.io"
237+
DISABLED = True
238+
239+
240+
class EthRinkebyL1(RinkebyL1):
241+
"""
242+
Ethereum on Rinkeby L1 Network
243+
"""
244+
245+
TOKEN_SYMBOL = "ETH"
246+
247+
248+
class DaiRinkebyL1(RinkebyL1):
249+
"""
250+
DAI on Rinkeby L1 Network
251+
"""
252+
253+
TOKEN_SYMBOL = "DAI"
254+
IS_NATIVE_ASSET = False
255+
ADDRESS = "0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735"
256+
257+
227258
class GoerliL1(L1):
228259
"""
229260
Constants for Goerli Ethereum Testnet
@@ -416,17 +447,41 @@ class DaiArbitrum(Arbitrum):
416447
ADDRESS = "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"
417448

418449

450+
class RinkebyArbitrum(Arbitrum):
451+
"""
452+
Constants for the Optimism Mainnet
453+
"""
454+
455+
NETWORK_IDENTIFIER = "RinkebyArbitrum"
456+
NETWORK_VERBOSE_NAME = "Rinkeby Arbitrum Testnet"
457+
CHAIN_ID = 421611
458+
EIP3091_EXPLORER_URL = "https://rinkeby-explorer.arbitrum.io"
459+
DISABLED = True
460+
461+
462+
class ETHRinkebyArbitrum(RinkebyArbitrum):
463+
"""
464+
Ethereum on Arbitrum Rinkeby Network
465+
"""
466+
467+
TOKEN_SYMBOL = "ETH"
468+
469+
419470
registry = [
420471
EthL1(),
421472
DaiL1(),
473+
EthRinkebyL1(),
474+
DaiRinkebyL1(),
422475
EthGoerliL1(),
423476
DaiGoerliL1(),
477+
EthSepoliaL1(),
424478
EthOptimism(),
425479
DaiOptimism(),
426480
EthKovanOptimism(),
427481
DaiKovanOptimism(),
428482
ETHArbitrum(),
429483
DaiArbitrum(),
484+
ETHRinkebyArbitrum(),
430485
]
431486
all_network_verbose_names_to_ids = {}
432487
for token in registry:

0 commit comments

Comments
 (0)