Skip to content

Commit

Permalink
fix: removed hardcoded Environment (#214)
Browse files Browse the repository at this point in the history
Changing Environment doesn't work on Widget

## Description

Removal of hardcoded `Testnet` in widget
  • Loading branch information
saadahmsiddiqui authored Jun 18, 2024
1 parent 9d67ca9 commit 70878dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
estimateEvmTransactionsGasCost,
estimateSubstrateGas
} from '../../utils/gas';
import type { FungibleTokenTransfer } from '../../components';
import { buildEvmFungibleTransactions, executeNextEvmTransaction } from './evm';
import {
buildSubstrateFungibleTransactions,
Expand Down Expand Up @@ -95,7 +96,7 @@ export class FungibleTokenTransferController implements ReactiveController {
protected executeSubstrateTransaction = executeNextSubstrateTransaction;

protected config: Config;
protected env: Environment = Environment.MAINNET;
protected env: Environment;
//source network chain id -> Route[]
protected routesCache: Map<number, Route[]> = new Map();

Expand Down Expand Up @@ -146,6 +147,8 @@ export class FungibleTokenTransferController implements ReactiveController {
constructor(host: ReactiveElement) {
(this.host = host).addController(this);
this.config = new Config();
this.env =
(this.host as FungibleTokenTransfer).environment ?? Environment.MAINNET;

this.walletContext = new ContextConsumer(host, {
context: walletContext,
Expand Down
4 changes: 2 additions & 2 deletions packages/widget/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SygmaProtocolWidget

connectedCallback(): void {
super.connectedCallback();
const env = import.meta.env.VITE_BRIDGE_ENV ?? Environment.MAINNET;
const env = this.environment ?? Environment.MAINNET;
if (Object.values(Environment).includes(env as Environment)) {
this.environment = env as Environment;
} else {
Expand Down Expand Up @@ -120,7 +120,7 @@ class SygmaProtocolWidget
.environment=${this.environment as Environment}
.onSourceNetworkSelected=${(domain: Domain) =>
(this.sourceNetwork = domain)}
environment=${Environment.TESTNET}
environment=${this.environment ?? Environment.MAINNET}
.whitelistedSourceNetworks=${this.whitelistedSourceNetworks}
.whitelistedDestinationNetworks=${this
.whitelistedDestinationNetworks}
Expand Down

0 comments on commit 70878dc

Please sign in to comment.