Skip to content

Commit

Permalink
fixed: use chain id as var in template
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafabarmshory committed Jan 11, 2023
1 parent 7051a99 commit 60fe2e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/pages/polygon/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ export class MaticStaking extends Component {
value: 0,
});

testnetChainId: string;
mainnetChainId: string;

/**
* Stake the amount value from the input
*
* @returns promise | undefinde
*/
async stakeit() {
this.testnetChainId = testnetChainId;
this.mainnetChainId = mainnetChainId;
if (this.state.staking || !this._checkChainId()) {
await switchChain(mainnetChainId, 'Polygon', 'https://mainnet.infura.io/v3/')
return;
Expand Down
32 changes: 16 additions & 16 deletions src/pages/polygon/polygon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="row justify-content-center align-items-center">
<img class="figure-img img-fluid p-3"
style="width:128px;"
src="./img/matic.jpg" />
src="./img/networks-logo/polygon.svg" />
</div>
<div class="row p-5 justify-content-center align-items-center nav-justified ">
<!-- Nav tabs -->
Expand Down Expand Up @@ -35,9 +35,9 @@
style="width: 800px; border: none;">
<div class="card-body">
<h2 class="text-center">
<t t-if="wallet.chainId === '${mainnetChainId}'">Stake Matic</t>
<t t-if="wallet.chainId === '${testnetChainId}'">Stake Matic TestNet</t>
<t t-if="wallet.chainId !== '${mainnetChainId}' and wallet.chainId !== '${testnetChainId}'">Not Connected/Unsupported Network !!</t>
<t t-if="wallet.chainId === mainnetChainId">Stake Matic</t>
<t t-if="wallet.chainId === testnetChainId">Stake Matic TestNet</t>
<t t-if="wallet.chainId !== mainnetChainId and wallet.chainId !== testnetChainId">Not Connected/Unsupported Network !!</t>
</h2>
<div class="p-2">
<div class="input-group justify-content-center align-items-center">
Expand All @@ -50,7 +50,7 @@
<button class="btn btn-outline-secondary text-center"
type="button">
<img class=""
src="./img/matic.jpg"
src="./img/networks-logo/polygon.svg"
style="width: 16px" />
</button>
</div>
Expand All @@ -61,12 +61,12 @@
<button class="btn text-white m-2"
style="background-color:#8247e5"
t-on-click="stakeit"
t-if="wallet.chainId === '${mainnetChainId}' or wallet.chainId === '${testnetChainId}'"
t-if="wallet.chainId === mainnetChainId or wallet.chainId === testnetChainId"
id="stakeBtn">
<span t-if="wallet.isConnected and wallet.chainId === '${mainnetChainId}'">Stake
<span t-if="wallet.isConnected and wallet.chainId === mainnetChainId">Stake
<t t-esc="state.value" /> Matic
</span>
<span t-if="wallet.isConnected and wallet.chainId === '${testnetChainId}'">Stake
<span t-if="wallet.isConnected and wallet.chainId === testnetChainId">Stake
<t t-esc="state.value" /> Matic Test
</span>
<span t-if="state.staking">
Expand All @@ -78,7 +78,7 @@
<button class="btn text-white m-2"
style="background-color:#8247e5"
t-on-click="stakeit"
t-if="wallet.chainId !== '${mainnetChainId}' and wallet.chainId !== '${testnetChainId}'"
t-if="wallet.chainId !== mainnetChainId and wallet.chainId !== testnetChainId"
id="switch-to-Matic-network">
<span>Switch Network</span>
</button>
Expand All @@ -90,20 +90,20 @@
<div class="tab-pane" id="unstake" role="tabpanel" aria-labelledby="unstake-tab">
<div class="row justify-content-center align-items-center p-2 ml-5">
<h2 class="text-center">
<t t-if="wallet.chainId === '${mainnetChainId}'">Un-stake Matic</t>
<t t-if="wallet.chainId === '${testnetChainId}'">Un-stake Matic Test Net</t>
<t t-if="wallet.chainId !== '${mainnetChainId}' and wallet.chainId !== '${testnetChainId}'">Not Connected/Unsupported Network !!</t>
<t t-if="wallet.chainId === mainnetChainId">Un-stake Matic</t>
<t t-if="wallet.chainId === testnetChainId">Un-stake Matic Test Net</t>
<t t-if="wallet.chainId !== mainnetChainId and wallet.chainId !== testnetChainId">Not Connected/Unsupported Network !!</t>
</h2>
<div class="card mb-3 " style="width: 700px; border: none;">
<div class="card-body ">
<div id="actions" class="d-flex flex-row justify-content-center align-items-center">
<button class="btn btn-outline"
t-on-click="unstakeit"
style="border-color:#8247e5; color:#8247e5;"
t-if="wallet.chainId === '${mainnetChainId}' or wallet.chainId === '${testnetChainId}'"
t-if="wallet.chainId === mainnetChainId or wallet.chainId === testnetChainId"
id="unstakeBtn">
<span t-if="wallet.isConnected and wallet.chainId === '${mainnetChainId}'">Un-stake Matic</span>
<span t-if="wallet.isConnected and wallet.chainId === '${testnetChainId}'">Un-stake Matic Test</span>
<span t-if="wallet.isConnected and wallet.chainId === mainnetChainId">Un-stake Matic</span>
<span t-if="wallet.isConnected and wallet.chainId === testnetChainId">Un-stake Matic Test</span>
<span t-if="state.unstaking">
<span class="spinner-border spinner-grow spinner-grow-sm"
role="status"
Expand All @@ -112,7 +112,7 @@
<button class="btn text-white m-2"
t-on-click="stakeit"
style="background-color:#8247e5"
t-if="wallet.chainId !== '${mainnetChainId}' and wallet.chainId !== '${testnetChainId}'"
t-if="wallet.chainId !== mainnetChainId and wallet.chainId !== testnetChainId"
id="switch-to-Matic-network">
<span>Switch Network</span>
</button>
Expand Down

0 comments on commit 60fe2e5

Please sign in to comment.