Skip to content

Commit

Permalink
Merge pull request #90 from eosnetworkfoundation/yarkin/add_bram
Browse files Browse the repository at this point in the history
Add new tokens and fix related bugs
  • Loading branch information
yarkinwho authored Jan 12, 2024
2 parents 3520916 + 6004c4f commit 93cf957
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 54 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "evm-bridge-frontend",
"version": "0.10.1",
"version": "0.11.0",
"private": true,
"scripts": {
"dev": "vite",
Expand Down
Binary file added public/images/banana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/bram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/zeos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ const messages = {
'home.netWarning.desc': 'Please confirm that your wallet is connected to the correct network before making a transfer. Using the wrong network may result in loss of tokens.',
'home.eos2evmDesc.p1': 'Please use a wallet that supports the EOS Network, such as Anchor, Wombat, TokenPocket or a centralized exchange such as OKX, Coinbase, etc.',
'home.eos2evmDesc.p2': 'To transfer funds to the following EOS Contract Address, please fill in the Destination EOS EVM Address in the memo to complete the deposit to EOS EVM.',
'home.eos2evmDesc.p3.testnet': 'Officially supported tokens include EOS and JUNGLE at this time.',
'home.eos2evmDesc.p3.mainnet': 'Officially supported tokens include EOS, USDT, SEOS, BOX and USN at this time.',
'home.eos2evmDesc.p3.testnet': 'Officially supported tokens include',
'home.eos2evmDesc.p3.mainnet': 'Officially supported tokens include',
'home.eos2evmDesc.p4.testnet': 'A full list of tokens and their ingress fees can be accessed here: <a href="https://jungle4.eosq.eosnation.io/account/eosio.erc2o/tables?scope=eosio.erc2o&tableName=tokens" rel="nofollow">https://jungle4.eosq.eosnation.io</a>',
'home.eos2evmDesc.p4.mainnet': 'A full list of tokens and their ingress fees can be accessed here: <a href="https://eos.eosq.eosnation.io/account/eosio.erc2o/tables?scope=eosio.erc2o&tableName=tokens" rel="nofollow">https://eos.eosq.eosnation.io</a>',

'home.addressCheck.invalidAddress': 'Address includes an illegal character',
'home.addressCheck.invalid13Char': 'Invalid 13th character',
Expand Down Expand Up @@ -136,8 +138,11 @@ const messages = {
'home.netWarning.desc': '전송하기 전에 지갑이 올바른 네트워크에 연결되어 있는지 확인하시기 바랍니다. 잘못된 네트워크를 사용하면 토큰이 손실될 수 있습니다.',
'home.eos2evmDesc.p1': 'Anchor, Wombat, TokenPocket 등 EOS 네트워크를 지원하는 지갑 또는 OKX, Coinbase 등과 같은 중앙화 거래소를 사용해 주세요.',
'home.eos2evmDesc.p2': '다음 EOS 컨트랙트 주소로 자금을 이체하려면 메모에 목적지 EOS EVM 주소를 입력하여 EOS EVM에 입금을 완료하세요.',
'home.eos2evmDesc.p3.testnet': '현재 공식적으로 지원되는 토큰은 EOS와 JUNGLE 입니다.',
'home.eos2evmDesc.p3.mainnet': '현재 공식적으로 지원되는 토큰은 EOS, USDT, SEOS, BOX와 USN입니다.',
'home.eos2evmDesc.p3.testnet': '현재 공식적으로 지원되는 토큰은',
'home.eos2evmDesc.p3.mainnet': '현재 공식적으로 지원되는 토큰은',
'home.eos2evmDesc.p4.testnet': '전체 토큰 목록 및 브릿징 수수료는 여기에서 확인하실 수 있습니다: <a href="https://jungle4.eosq.eosnation.io/account/eosio.erc2o/tables?scope=eosio.erc2o&tableName=tokens" rel="nofollow">https://jungle4.eosq.eosnation.io</a>',
'home.eos2evmDesc.p4.mainnet': '전체 토큰 목록 및 브릿징 수수료는 여기에서 확인하실 수 있습니다: <a href="https://eos.eosq.eosnation.io/account/eosio.erc2o/tables?scope=eosio.erc2o&tableName=tokens" rel="nofollow">https://eos.eosq.eosnation.io</a>',


'home.addressCheck.invalidAddress': '주소에 잘못된 문자가 포함되어 있습니다.',
'home.addressCheck.invalid13Char': '최대 문자 초과, 13개 이상을 넘을 수 없습니다.',
Expand Down Expand Up @@ -226,8 +231,11 @@ const messages = {
'home.netWarning.desc':'在进行交易之前,请确认您的钱包已连接到正确的网络。使用错误的网络可能会导致代币丢失。',
'home.eos2evmDesc.p1':'请使用支持 EOS 网络的钱包,如 Anchor、Wombat、TokenPocket 或中心化交易所如 OKX、Coinbase 等。',
'home.eos2evmDesc.p2': '如需转账至以下 EOS 合约地址,请在 memo 中填写目标 EOS EVM 地址,以完成向 EOS EVM 的充值。',
'home.eos2evmDesc.p3.testnet': '目前官方支持的代币包括 EOS 和 JUNGLE。',
'home.eos2evmDesc.p3.mainnet': '目前官方支持的代币包括 EOS, USDT, SEOS, BOX 和 USN。',
'home.eos2evmDesc.p3.testnet': '目前官方支持的代币包括',
'home.eos2evmDesc.p3.mainnet': '目前官方支持的代币包括',
'home.eos2evmDesc.p4.testnet': '可在此处访问一系列代币及其跨链手续费: <a href="https://jungle4.eosq.eosnation.io/account/eosio.erc2o/tables?scope=eosio.erc2o&tableName=tokens" rel="nofollow">https://jungle4.eosq.eosnation.io</a>',
'home.eos2evmDesc.p4.mainnet': '可在此处访问一系列代币及其跨链手续费: <a href="https://eos.eosq.eosnation.io/account/eosio.erc2o/tables?scope=eosio.erc2o&tableName=tokens" rel="nofollow">https://eos.eosq.eosnation.io</a>',


'home.addressCheck.invalidAddress': '地址包含违规字符',
'home.addressCheck.invalid13Char': '第 13 个字符无效',
Expand Down
228 changes: 181 additions & 47 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<div class="mb-3">
<label for="address">{{ $t('home.destinationAccount') }}</label>
<div class="form-text mb-2">{{ $t('home.destinationAccountDesc') }}</div>
<input type="text" id="address" class="form-control select" v-model="targetAddress"
maxlength="13" list="addresses">
<input type="text" id="address" class="form-control select" v-model="targetAddress" maxlength="13"
list="addresses">
<div class="form-text font-monospace" v-if='extraWarning !== ""'>
<span style="color: red">{{ extraWarning }}</span>
</div>
Expand Down Expand Up @@ -108,11 +108,7 @@
</div>

<div class="mt-2 text-center small text-white">
{{ $t('home.gasFee') }}
<span v-if="tokenName() === 'EOS'">~0.0032 EOS</span>
<span v-else>~0.016 EOS</span>
<span v-if="tokenName() != 'EOS'">
<br>
{{ $t('home.bridgeFee') }} {{ egressFeeInEOS() }} EOS
</span>
<br>
Expand Down Expand Up @@ -161,6 +157,26 @@
<p>{{ $t('home.eos2evmDesc.p2') }}</p>
<p v-if="env === 'TESTNET'">{{ $t('home.eos2evmDesc.p3.testnet') }}</p>
<p v-else>{{ $t('home.eos2evmDesc.p3.mainnet') }}</p>
<table class="table table-striped" style="max-width: 16em;">
<thead>
<tr>
<th>Token</th>
<th>Ingress fee</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in tokenList">
<td>{{item.name}}</td>
<td>{{item.ingressFee}} {{item.name}}</td>
</tr>
</tbody>
</table>

<div v-if="env === 'TESTNET'" v-html="$t('home.eos2evmDesc.p4.testnet', { 'interpolation': {'escapeValue': false} })"></div>
<div v-else v-html="$t('home.eos2evmDesc.p4.mainnet', { 'interpolation': {'escapeValue': false} })"></div>
<div ></div>


</div>
</b-row>
</b-card>
Expand Down Expand Up @@ -213,9 +229,6 @@
</div>

<div class="mt-2 text-center small text-white">
{{ $t('home.bridgeFee') }}
<span>0.01 EOS</span>
<br>
{{ $t('home.transferTime', ['~ 5 s']) }}
</div>
</b-tab>
Expand Down Expand Up @@ -257,44 +270,74 @@ export default {
finished: false,
transactionError: '',
extraWarning: '',
tokenList: null,
tokenList: [{ name: 'EOS', addr: '', logo: 'images/eos.png', ingressFee: 0}],
selectedToken: 0,
egressFee: '0',
decimals: null,
tokenListTestnet: [
{ name: 'EOS', addr: '', logo: 'images/eos.png' },
{ name: 'JUNGLE', addr: '0x4ea3b729669bF6C34F7B80E5D6c17DB71F89F21F', logo: 'images/jungle.png', erc20_contract: null },
{ name: 'EOS', addr: '', logo: 'images/eos.png', ingressFee: 0},
{ name: 'JUNGLE', addr: '0x4ea3b729669bF6C34F7B80E5D6c17DB71F89F21F', logo: 'images/jungle.png', erc20_contract: null, ingressFee: 0 },
],
tokenListMainnet: [
{ name: 'EOS', addr: '', logo: 'images/eos.png',
blockList: ['eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos'],
warningList: ['huobideposit', 'okbtothemoon', 'gateiowallet', 'coinbasebase', 'krakenkraken']
},
{ name: 'USDT', addr: '0x33B57dC70014FD7AA6e1ed3080eeD2B619632B8e', logo: 'images/usdt.png' ,
blockList: ['eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: ['gateiowallet']
},
{ name: 'SEOS', addr: '0xbfb10f85b889328e4a42507e31a07977ae00eec6', logo: 'images/seos.png' ,
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: []
},
{ name: 'BOX', addr: '0x9b3754f036de42846e60c8d8c89b18764f168367', logo: 'images/box.png' ,
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: []
},
{ name: 'USN', addr: '0x8d0258d6ccfb0ce394dc542c545566936b7974f9', logo: 'images/usn.png' ,
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: []
},
{
name: 'EOS', addr: '', logo: 'images/eos.png',
blockList: ['eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos'],
warningList: ['huobideposit', 'okbtothemoon', 'gateiowallet', 'coinbasebase', 'krakenkraken'],
ingressFee: 0
},
{
name: 'USDT', addr: '0x33B57dC70014FD7AA6e1ed3080eeD2B619632B8e', logo: 'images/usdt.png',
blockList: ['eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: ['gateiowallet'],
ingressFee: 0
},
{
name: 'ZEOS', addr: '0x477F09A0bDb273C8933429109fEBd3c3b0388B8A', logo: 'images/zeos.png',
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: [],
ingressFee: 0
},
{
name: 'BRAM', addr: '0x102F21abC12eBD194259C1081B13916192E7cBe5', logo: 'images/bram.png',
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: [],
ingressFee: 0
},
{
name: 'SEOS', addr: '0xbfb10f85b889328e4a42507e31a07977ae00eec6', logo: 'images/seos.png',
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: [],
ingressFee: 0
},
{
name: 'BOX', addr: '0x9b3754f036de42846e60c8d8c89b18764f168367', logo: 'images/box.png',
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: [],
ingressFee: 0
},
{
name: 'USN', addr: '0x8d0258d6ccfb0ce394dc542c545566936b7974f9', logo: 'images/usn.png',
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: [],
ingressFee: 0
},
{
name: 'BANANA', addr: '0xC500C831AF8a5d1F4f3B1fc3940175A8db68C3CB', logo: 'images/banana.png',
blockList: ['gateiowallet', 'eosbndeposit', 'bybitdeposit', 'bitgeteosdep', 'kucoindoteos', 'binancecleos', 'coinbasebase', 'krakenkraken', 'huobideposit', 'okbtothemoon'],
warningList: [],
ingressFee: 0
},
],
}
},
created() {
async created() {
this.rpc = (this.env === "TESTNET" ? new JsonRpc('https://jungle4.api.eosnation.io:443', { fetch }) : new JsonRpc('https://eos.api.eosnation.io:443', { fetch }));
// this.wallet.connect = this.connectWallet
this.tokenList = await this.refreshIngressFee(this.env === "TESTNET" ? this.tokenListTestnet : this.tokenListMainnet);
console.log(this.tokenList)
this.tokenList = this.env === "TESTNET" ? this.tokenListTestnet : this.tokenListMainnet;
this.selectedToken = 0;
for (var item of this.tokenList) {
Expand Down Expand Up @@ -353,16 +396,12 @@ export default {
return this.convertAddress(this.targetAddress)
},
transferValue() {
if (!this.amount) {
if (!this.amount || this.decimals === null) {
return null
}
try {
if (this.tokenName() == "EOS") {
return Web3.utils.toBN(Web3.utils.toWei(this.amount.toString(), 'ether')).toString()
}
else {
return Web3.utils.toBN(Web3.utils.toWei(this.amount.toString(), 'mwei')).toString()
}
let parsed = this.parseInputValue(this.amount, this.decimals)
return parsed
} catch (err) {
return null
}
Expand All @@ -386,6 +425,64 @@ export default {
blockList() { return this.tokenList[this.selectedToken].blockList; },
warningList() { return this.tokenList[this.selectedToken].warningList; },
async refreshIngressFee(tokenList) {
const erclist = (await this.rpc.fetch('/v1/chain/get_table_rows', { "table": "tokens", "scope": "eosio.erc2o", "code": "eosio.erc2o", "json": true })).rows
await tokenList.forEach(async e=>{
if (e.name === "EOS") {
const r = await this.rpc.fetch('/v1/chain/get_table_rows', { "table": "config", "scope": "eosio.evm", "code": "eosio.evm", "json": true })
e.ingressFee = Number(r.rows[0].ingress_bridge_fee.split(' ')[0])
}
else {
const addr = e.addr.substr(2).toLowerCase()
for(const erc of erclist) {
if (erc.address.toLowerCase() === addr) {
e.ingressFee = Number(erc.ingress_fee.split(' ')[0])
break
}
}
}
})
return tokenList
},
parseInputValue(inputAmount, inputDeciamls) {
let amount = inputAmount.toString()
let extraExp = 0
if (amount.includes("e")) {
const s = amount.split('e');
amount = s[0]
extraExp = Number(s[1]);
}
const denomination = BigInt(10) ** BigInt(inputDeciamls)
// From web3.js
// if value is decimal e.g. 24.56 extract `integer` and `fraction` part
// to avoid `fraction` to be null use `concat` with empty string
const [integer, fraction] = amount.split('.').concat('');
// join the value removing `.` from
// 24.56 -> 2456
const value = BigInt(`${integer}${fraction}`);
// multiply value with denomination
// 2456 * 1000000 -> 2456000000
const updatedValue = value * denomination;
let result = updatedValue.toString();
if (extraExp > 0) {
result = result.padEnd(result.length + extraExp, '0')
}
else if (extraExp < 0) {
result = result.slice(0, extraExp).padStart(1, "0")
}
if (fraction.length === 0) {
return result.toString();
}
return result.slice(0, -fraction.length).padStart(1, "0");
},
async getPrice() {
const feeData = await fetchFeeData({
Expand Down Expand Up @@ -416,6 +513,39 @@ export default {
async connectWallet() {
},
displayValue(valueString, decimals) {
// Logic from web3.js
if (decimals <= 0) {
return valueString;
}
// pad the value with required zeros
// 13456789 -> 13456789, 1234 -> 001234
const zeroPaddedValue = valueString.padStart(decimals, '0');
// get the integer part of value by counting number of zeros from start
// 13456789 -> '13'
// 001234 -> ''
const integer = zeroPaddedValue.slice(0, -decimals);
// get the fraction part of value by counting number of zeros backward
// 13456789 -> '456789'
// 001234 -> '001234'
const fraction = zeroPaddedValue.slice(-decimals).replace(/\.?0+$/, '');
if (integer === '') {
if (fraction === '') {
return '0';
}
return `0.${fraction}`;
}
if (fraction === '') {
return integer;
}
return `${integer}.${fraction}`;
},
async getBalance() {
const address = this.address
Expand All @@ -427,15 +557,20 @@ export default {
address,
formatUnits: 'wei',
})
this.decimals = 18
const wei = new BN(bal.formatted)
this.balance = Web3.utils.fromWei(wei, 'ether')
}
else {
if ((this.erc20_contract())) {
const wei = new BN((await this.erc20_contract().read.balanceOf([address])).toString())
this.balance = Web3.utils.fromWei(wei, 'mwei')
this.decimals = await this.erc20_contract().read.decimals()
this.balance = this.displayValue(wei.toString(), this.decimals)
}
else {
this.balance = null;
this.decimals = null;
}
else { this.balance = null; }
}
},
Expand All @@ -448,7 +583,7 @@ export default {
else {
this.egressFee = '0'
}
this.getBalance()
},
Expand Down Expand Up @@ -484,7 +619,7 @@ export default {
var vm = this
let tx = null;
await this.getPrice()
if (this.tokenName() === 'EOS') {
Expand Down Expand Up @@ -725,5 +860,4 @@ export default {
.error {
color: #fff;
}
</style>
}</style>

0 comments on commit 93cf957

Please sign in to comment.