Skip to content

Commit

Permalink
hotfix: wIOTA contract (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
begonaalvarezd authored Apr 17, 2024
1 parent 48f934a commit 03b6a83
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/lib/withdraw/actions/add-token-to-metamask.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { get } from 'svelte/store';

import { L2_NATIVE_GAS_TOKEN_DECIMALS } from '$lib/constants';
import { appConfiguration, selectedNetwork } from '$lib/evm-toolkit';
import { NotificationType, showNotification } from '$lib/notification';
import { wIOTAContractAddress, wSMRContractAddress } from '$lib/wrap';
import { L2_NATIVE_GAS_TOKEN_DECIMALS } from '$lib/constants';
import { WTOKEN_CONTRACT_CHAIN_MAP } from '$lib/wrap';

export async function addWTokenToMetamask(): Promise<void> {
const { ethereum } = window as any;
Expand All @@ -16,7 +16,7 @@ export async function addWTokenToMetamask(): Promise<void> {
params: {
type: 'ERC20',
options: {
address: get(appConfiguration)?.ticker === 'IOTA' ? wIOTAContractAddress : wSMRContractAddress, // ERC20 token address
address: WTOKEN_CONTRACT_CHAIN_MAP[$selectedNetwork?.chainRef],
symbol: get(appConfiguration)?.wTicker,
decimals: L2_NATIVE_GAS_TOKEN_DECIMALS,
},
Expand Down
13 changes: 6 additions & 7 deletions src/lib/withdraw/actions/connect-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { defaultEvmStores, selectedAccount, web3 } from 'svelte-web3';
import { get } from 'svelte/store';
import { appConfiguration, selectedNetwork } from '$lib/evm-toolkit';
import { ISCMagic } from '$lib/iscmagic';
import { iscAbi, iscContractAddress } from '$lib/withdraw';
import { wToken } from '$lib/wrap';
import { wSMRAbi, wIOTAAbi, wSMRContractAddress, wIOTAContractAddress } from '$lib/wrap';
import { WTOKEN_CONTRACT_CHAIN_MAP, wIOTAAbi, wSMRAbi, wToken } from '$lib/wrap';
import { defaultEvmStores, selectedAccount, web3 } from 'svelte-web3';
import { get } from 'svelte/store';
import { addSelectedNetworkToMetamask, subscribeBalance } from '.';
import { updateWithdrawStateStore, withdrawStateStore } from '../stores';
import { appConfiguration } from '$lib/evm-toolkit';

export async function connectToWallet() {
updateWithdrawStateStore({ isLoading: true });
const wTokenContractAddress = get(appConfiguration)?.wTicker === 'wIOTA' ? wIOTAContractAddress : wSMRContractAddress;
const wTokenContractAddress = WTOKEN_CONTRACT_CHAIN_MAP[get(selectedNetwork)?.chainRef];
try {
await defaultEvmStores.setProvider();
await addSelectedNetworkToMetamask();
Expand All @@ -32,7 +31,7 @@ export async function connectToWallet() {
from: get(selectedAccount),
});
updateWithdrawStateStore({ contractWToken });

const wTokenContractObj = new wToken(get(withdrawStateStore)?.contractWToken);
updateWithdrawStateStore({ wTokenContractObj });

Expand Down
12 changes: 9 additions & 3 deletions src/lib/wrap/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import wSMRAbiAsText from '$lib/assets/wSMR.abi?raw';
import wIOTAAbiAsText from '$lib/assets/wIOTA.abi?raw';
import wSMRAbiAsText from '$lib/assets/wSMR.abi?raw';
import { ChainReference } from "$lib/evm-toolkit";

export const wSMRAbi = JSON.parse(wSMRAbiAsText);
export const wIOTAAbi = JSON.parse(wIOTAAbiAsText);
export const wSMRContractAddress = '0xBEb654A116aeEf764988DF0C6B4bf67CC869D01b';
export const wIOTAContractAddress = '0x6e47f8d48a01b44DF3fFF35d258A10A3AEdC114c';
export const GAS_PRICE = 0.000001; // 1000 Gwei

export const WTOKEN_CONTRACT_CHAIN_MAP = {
[ChainReference.IOTAEVM]: '0x6e47f8d48a01b44DF3fFF35d258A10A3AEdC114c',
[ChainReference.IOTAEVMTestnet]: '0xB2E0DfC4820cc55829C71529598530E177968613',
[ChainReference.ShimmerEVM]: '0xBEb654A116aeEf764988DF0C6B4bf67CC869D01b',
[ChainReference.ShimmerEVMTestnet]: '0xBEb654A116aeEf764988DF0C6B4bf67CC869D01b',
}

0 comments on commit 03b6a83

Please sign in to comment.