Skip to content

Commit

Permalink
feat(gui): Specify stub testnet provider via VITE_TESTNET_STUB_PROVID…
Browse files Browse the repository at this point in the history
…ER_ADDRESS environment variable (#99)
  • Loading branch information
binarybaron authored Sep 25, 2024
1 parent 97510a8 commit 21608ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src-gui/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# You can configure the address of a locally running testnet asb. It'll displayed in the GUI. This is useful for testing
# VITE_TESTNET_STUB_PROVIDER_ADDRESS=/ip4/127.0.0.1/tcp/9939/p2p/12D3KooWLaHSfwTW99GpqBZntLodmrFyzockGSVbL6grbN7HXo8x
12 changes: 8 additions & 4 deletions src-gui/src/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ export const isTestnet = () => true;
export const isDevelopment = true;

export function getStubTestnetProvider(): ExtendedProviderStatus | null {
const stubProviderAddress = process.env.TESTNET_STUB_PROVIDER_ADDRESS;
const stubProviderAddress = import.meta.env
.VITE_TESTNET_STUB_PROVIDER_ADDRESS;

if(stubProviderAddress != null) {
console.log(import.meta.env);

if (stubProviderAddress != null) {
try {
const [multiAddr, peerId] = splitPeerIdFromMultiAddress(stubProviderAddress);
const [multiAddr, peerId] =
splitPeerIdFromMultiAddress(stubProviderAddress);

return {
multiAddr,
Expand All @@ -20,7 +24,7 @@ export function getStubTestnetProvider(): ExtendedProviderStatus | null {
minSwapAmount: 0,
price: 0,
};
}catch {
} catch {
return null;
}
}
Expand Down

0 comments on commit 21608ce

Please sign in to comment.