From ed49ce5965824c3aacdddba62e93c38c31f07562 Mon Sep 17 00:00:00 2001 From: Saad Ahmed Siddiqui <saadahm.siddiqui@gmail.com> Date: Tue, 18 Jun 2024 16:19:10 +0200 Subject: [PATCH 1/2] fix: removed hardcoded Environment --- .../src/controllers/transfers/fungible-token-transfer.ts | 4 +++- packages/widget/src/widget.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts index 7c978847..2a3fc5b0 100644 --- a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts +++ b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts @@ -34,6 +34,7 @@ import { executeNextSubstrateTransaction } from './substrate'; import { estimateEvmTransactionsGasCost } from './evm/gas-estimate'; +import { FungibleTokenTransfer } from '../../components'; export type SubstrateTransaction = SubmittableExtrinsic< 'promise', @@ -88,7 +89,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(); @@ -136,6 +137,7 @@ 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, diff --git a/packages/widget/src/widget.ts b/packages/widget/src/widget.ts index 11c7c057..133a297e 100644 --- a/packages/widget/src/widget.ts +++ b/packages/widget/src/widget.ts @@ -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 { @@ -120,7 +120,7 @@ class SygmaProtocolWidget .environment=${this.environment as Environment} .onSourceNetworkSelected=${(domain: Domain) => (this.sourceNetwork = domain)} - environment=${Environment.TESTNET} + environment=${this.environment} .whitelistedSourceNetworks=${this.whitelistedSourceNetworks} .whitelistedDestinationNetworks=${this .whitelistedDestinationNetworks} From a339623576d2381c21210b40c9b13b01aa2d52b9 Mon Sep 17 00:00:00 2001 From: Saad Ahmed Siddiqui <saadahm.siddiqui@gmail.com> Date: Tue, 18 Jun 2024 16:33:37 +0200 Subject: [PATCH 2/2] chore: fix lint --- .../src/controllers/transfers/fungible-token-transfer.ts | 5 +++-- packages/widget/src/widget.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts index 31b0d25c..b43b72cf 100644 --- a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts +++ b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts @@ -37,12 +37,12 @@ import { estimateEvmTransactionsGasCost, estimateSubstrateGas } from '../../utils/gas'; +import type { FungibleTokenTransfer } from '../../components'; import { buildEvmFungibleTransactions, executeNextEvmTransaction } from './evm'; import { buildSubstrateFungibleTransactions, executeNextSubstrateTransaction } from './substrate'; -import { FungibleTokenTransfer } from '../../components'; export type SubstrateTransaction = SubmittableExtrinsic< 'promise', @@ -147,7 +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.env = + (this.host as FungibleTokenTransfer).environment ?? Environment.MAINNET; this.walletContext = new ContextConsumer(host, { context: walletContext, diff --git a/packages/widget/src/widget.ts b/packages/widget/src/widget.ts index 133a297e..f6c7f1d6 100644 --- a/packages/widget/src/widget.ts +++ b/packages/widget/src/widget.ts @@ -120,7 +120,7 @@ class SygmaProtocolWidget .environment=${this.environment as Environment} .onSourceNetworkSelected=${(domain: Domain) => (this.sourceNetwork = domain)} - environment=${this.environment} + environment=${this.environment ?? Environment.MAINNET} .whitelistedSourceNetworks=${this.whitelistedSourceNetworks} .whitelistedDestinationNetworks=${this .whitelistedDestinationNetworks}