Skip to content

Commit

Permalink
refactor: make RSK log scan endpoint optional
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Dec 3, 2024
1 parent 811e7e2 commit 76c6d16
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# RSK RPC URL for logs scanning which is not supported by the public RPCs
VITE_RSK_LOG_SCAN_ENDPOINT=

# Token for the Chatwoot website inbox
# The chat widget will not be loaded if not set
VITE_CHATWOOT_TOKEN=
24 changes: 12 additions & 12 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

def handle_coop_disabled():
print("Cooperative signatures are disabled in config")
sys.exit(1)

with open("./src/config.ts", "r") as f:
for line in f:
Expand All @@ -28,14 +27,15 @@ def handle_coop_disabled():

# .env file is not required on regtest
if network != "regtest":
with open(".env", "r") as f:
data = f.read()

for var in ["VITE_RSK_LOG_SCAN_ENDPOINT"]:
if var not in data:
print(f"{var} not in .env file")
sys.exit(1)

for var in ["VITE_CHATWOOT_TOKEN"]:
if var not in data:
print(f"WARN: {var} not in .env file")
try:
with open(".env", "r") as f:
data = f.read()

for var in [
"VITE_RSK_LOG_SCAN_ENDPOINT",
"VITE_CHATWOOT_TOKEN"
]:
if var not in data:
print(f"WARN: {var} not in .env file")
except Exception as e:
print("WARN: could not open .env file:", e)
2 changes: 2 additions & 0 deletions src/pages/Refund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ const Refund = () => {
/>
<Show
when={
import.meta.env.VITE_RSK_LOG_SCAN_ENDPOINT !==
undefined &&
Object.keys(providers()).length > 0 &&
(refundJson() === null ||
refundJson().assetSend === RBTC)
Expand Down
5 changes: 5 additions & 0 deletions src/utils/contractLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ async function* scanLogsForPossibleRefunds(
);

const scanProviderUrl = import.meta.env.VITE_RSK_LOG_SCAN_ENDPOINT;
if (scanProviderUrl === undefined) {
return;
}

console.log(scanProviderUrl);
const etherSwapScan =
scanProviderUrl !== undefined
? (new Contract(
Expand Down

0 comments on commit 76c6d16

Please sign in to comment.