Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 70878dc

Browse files
fix: removed hardcoded Environment (#214)
Changing Environment doesn't work on Widget ## Description Removal of hardcoded `Testnet` in widget
1 parent 9d67ca9 commit 70878dc

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/widget/src/controllers/transfers/fungible-token-transfer.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
estimateEvmTransactionsGasCost,
3838
estimateSubstrateGas
3939
} from '../../utils/gas';
40+
import type { FungibleTokenTransfer } from '../../components';
4041
import { buildEvmFungibleTransactions, executeNextEvmTransaction } from './evm';
4142
import {
4243
buildSubstrateFungibleTransactions,
@@ -95,7 +96,7 @@ export class FungibleTokenTransferController implements ReactiveController {
9596
protected executeSubstrateTransaction = executeNextSubstrateTransaction;
9697

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

@@ -146,6 +147,8 @@ export class FungibleTokenTransferController implements ReactiveController {
146147
constructor(host: ReactiveElement) {
147148
(this.host = host).addController(this);
148149
this.config = new Config();
150+
this.env =
151+
(this.host as FungibleTokenTransfer).environment ?? Environment.MAINNET;
149152

150153
this.walletContext = new ContextConsumer(host, {
151154
context: walletContext,

packages/widget/src/widget.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class SygmaProtocolWidget
8484

8585
connectedCallback(): void {
8686
super.connectedCallback();
87-
const env = import.meta.env.VITE_BRIDGE_ENV ?? Environment.MAINNET;
87+
const env = this.environment ?? Environment.MAINNET;
8888
if (Object.values(Environment).includes(env as Environment)) {
8989
this.environment = env as Environment;
9090
} else {
@@ -120,7 +120,7 @@ class SygmaProtocolWidget
120120
.environment=${this.environment as Environment}
121121
.onSourceNetworkSelected=${(domain: Domain) =>
122122
(this.sourceNetwork = domain)}
123-
environment=${Environment.TESTNET}
123+
environment=${this.environment ?? Environment.MAINNET}
124124
.whitelistedSourceNetworks=${this.whitelistedSourceNetworks}
125125
.whitelistedDestinationNetworks=${this
126126
.whitelistedDestinationNetworks}

0 commit comments

Comments
 (0)