feat(gui): Specify stub testnet provider via VITE_TESTNET_STUB_PROVIDER_ADDRESS environment variable (#99)

This commit is contained in:
binarybaron 2024-09-26 00:16:38 +06:00 committed by GitHub
parent 97510a8619
commit 21608ce4f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

2
src-gui/.env.development Normal file
View file

@ -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

View file

@ -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,
@ -20,7 +24,7 @@ export function getStubTestnetProvider(): ExtendedProviderStatus | null {
minSwapAmount: 0,
price: 0,
};
}catch {
} catch {
return null;
}
}