diff --git a/.eslintrc.js b/.eslintrc.js
index d2f28d9c4..e87118a50 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -51,7 +51,6 @@ module.exports = {
'curly': 'error',
'brace-style': ['error', '1tbs', { 'allowSingleLine': false }],
'no-restricted-imports': ['error', {
- 'patterns': ['.*'], // disallow relative imports
}],
'no-return-assign': ['error', 'always'],
'no-param-reassign': 'error',
diff --git a/env.js b/env.js
index e503f8641..f3f9d3794 100644
--- a/env.js
+++ b/env.js
@@ -2,61 +2,24 @@
The environment variables ares set based on the single variable `MAINNET=true`
(or absence thereof) in the root `.env` file. The following env vars are then assigned in
`quasar.config.js`.
-*/
+Cross chain support: most of the variables that were here have been moved to `src/config/chains`
+
+*/
const sharedEnv = {
- NETWORK_PROTOCOL: 'https',
- NETWORK_PORT: 443,
- NETWORK_EVM_CONTRACT: 'eosio.evm',
PROJECT_ID: '14ec76c44bae7d461fa0f5fd5f8a9da1',
};
const TESTNET = {
...sharedEnv,
APP_NAME: 'Teloscan (testnet)',
- NETWORK_HOST: 'testnet.telos.net',
- NETWORK_CHAIN_ID:
- '1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f',
- NETWORK_EVM_RPC: 'https://testnet.telos.net/evm',
- NETWORK_EVM_ENDPOINT: 'https://testnet.telos.net',
- NETWORK_EVM_CHAIN_ID: 41,
- NETWORK_EVM_DISPLAY: 'Telos Testnet',
NETWORK_EVM_NAME: 'telos-evm-testnet',
- HYPERION_ENDPOINT: 'https://testnet.telos.net',
- NETWORK_EXPLORER: 'https://explorer-test.telos.net',
- TELOS_API_ENDPOINT: 'https://api-dev.telos.net/v1', //'http://localhost:9999/v1', //for local instance of api
- INDEXER_API_ENDPOINT: 'https://api.testnet.teloscan.io/v1',
- EXPORT_API_ENDPOINT: 'https://api.testnet.teloscan.io',
- VERIFIED_CONTRACTS_BUCKET: 'verified-evm-contracts-testnet',
- STAKED_TLOS_CONTRACT_ADDRESS: '0xa9991E4daA44922D00a78B6D986cDf628d46C4DD',
- TELOS_ESCROW_CONTRACT_ADDRESS: '0x7E9cF9fBc881652B05BB8F26298fFAB538163b6f',
- MULTICALL_CONTRACT_ADDRESS: '0x39b0CF441E616e4e21a5f7b37c9CE0Ca750bd05B',
- OREID_APP_ID: 't_1e0417d2456e401893ec106e5e4c6314',
- OREID_APP_ID_NATIVE: 't_a61e9926d5204387a9ac113dfce7cbc5',
};
const MAINNET = {
...sharedEnv,
APP_NAME: 'Teloscan',
- NETWORK_HOST: 'mainnet.telos.net',
- NETWORK_CHAIN_ID:
- '4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
- NETWORK_EVM_RPC: 'https://mainnet.telos.net/evm',
- NETWORK_EVM_ENDPOINT: 'https://mainnet.telos.net',
- NETWORK_EVM_CHAIN_ID: 40,
- NETWORK_EVM_DISPLAY: 'Telos',
NETWORK_EVM_NAME: 'telos-evm',
- HYPERION_ENDPOINT: 'https://mainnet.telos.net',
- NETWORK_EXPLORER: 'https://explorer.telos.net',
- TELOS_API_ENDPOINT: 'https://api.telos.net/v1', //'http://localhost:9999/v1', //for local instance of api
- INDEXER_API_ENDPOINT: 'https://api.teloscan.io/v1',
- EXPORT_API_ENDPOINT: 'https://api.teloscan.io',
- VERIFIED_CONTRACTS_BUCKET: 'verified-evm-contracts',
- STAKED_TLOS_CONTRACT_ADDRESS: '0xB4B01216a5Bc8F1C8A33CD990A1239030E60C905',
- TELOS_ESCROW_CONTRACT_ADDRESS: '0x95F5713A1422Aa3FBD3DCB8D553945C128ee3855',
- MULTICALL_CONTRACT_ADDRESS: '0xdDCbf776dF3dE60163066A5ddDF2277cB445E0F3',
- OREID_APP_ID: 'p_b5cfbadeb17a44bdaf01e73b3120d202',
- OREID_APP_ID_NATIVE: 'p_751f87258d5b40998b55c626d612fd4e',
};
const env = process.env.NETWORK === 'mainnet' ? MAINNET : TESTNET;
diff --git a/src/assets/telos-new-logo--dark.png b/public/assets/telos-new-logo--dark.png
similarity index 100%
rename from src/assets/telos-new-logo--dark.png
rename to public/assets/telos-new-logo--dark.png
diff --git a/src/assets/telos-new-logo.png b/public/assets/telos-new-logo.png
similarity index 100%
rename from src/assets/telos-new-logo.png
rename to public/assets/telos-new-logo.png
diff --git a/public/assets/telos-testnet-logo--dark.png b/public/assets/telos-testnet-logo--dark.png
new file mode 100644
index 000000000..ff8b8dbb6
Binary files /dev/null and b/public/assets/telos-testnet-logo--dark.png differ
diff --git a/public/assets/telos-testnet-logo.png b/public/assets/telos-testnet-logo.png
new file mode 100644
index 000000000..18fe32da9
Binary files /dev/null and b/public/assets/telos-testnet-logo.png differ
diff --git a/quasar.conf.js b/quasar.conf.js
index df0aa4be3..414e6f968 100644
--- a/quasar.conf.js
+++ b/quasar.conf.js
@@ -32,12 +32,8 @@ module.exports = function(/* ctx */) {
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/boot-files
boot: [
- 'ual',
- 'hyperion',
'i18n',
- 'api',
'errorHandling',
- 'telosApi',
'evm',
'q-component-defaults',
'antelope',
diff --git a/src/App.vue b/src/App.vue
index 5829078c8..50a8e7143 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -5,10 +5,8 @@ import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import moment from 'moment';
-import { getAntelope, useChainStore } from 'src/antelope';
-import { TELOS_NETWORK_NAMES } from 'src/antelope/mocks/chain-constants';
-import { indexerApi } from 'src/boot/telosApi';
-import { ual } from 'src/boot/ual';
+import { getAntelope, useChainStore } from 'src/core';
+import { TELOS_NETWORK_NAMES } from 'src/core/mocks/chain-constants';
import { providerManager } from 'src/boot/evm';
const $store = useStore();
@@ -28,8 +26,8 @@ onMounted(async () => {
script.defer = true;
document.body.appendChild(script);
}
-
- const health = await indexerApi.get('/health');
+ const indexerApi = useChainStore().currentChain.settings.getIndexerApi();
+ const health = await indexerApi.get('/v1/health');
if (health.data?.secondsBehind > 3) {
let behindBy = moment(health.data.secondsBehind * 1000).utc().format('HH:mm:ss');
@@ -63,7 +61,7 @@ onMounted(async () => {
return;
}
const loginObj = JSON.parse(loginData);
- const wallet = ual.getAuthenticators().availableAuthenticators.find(a => a.getName() === loginObj.provider);
+ const wallet = getAntelope().config.authenticatorsGetter().find(a => a.getName() === loginObj.provider);
wallet?.logout();
}
$store.commit('login/setLogin', {});
diff --git a/src/antelope/index.ts b/src/antelope/index.ts
deleted file mode 100644
index a1cfac13e..000000000
--- a/src/antelope/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export * from 'src/antelope/mocks/AccountStore';
-export * from 'src/antelope/mocks/AntelopeConfig';
-export * from 'src/antelope/mocks/ChainStore';
-export * from 'src/antelope/mocks/ContractStore';
-export * from 'src/antelope/mocks/EVMStore';
-export * from 'src/antelope/mocks/FeedbackStore';
-export * from 'src/antelope/mocks/PlatformStore';
diff --git a/src/antelope/mocks/ChainStore.ts b/src/antelope/mocks/ChainStore.ts
deleted file mode 100644
index 2afe7b82d..000000000
--- a/src/antelope/mocks/ChainStore.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-/* eslint-disable no-unused-vars */
-/* eslint-disable @typescript-eslint/no-unused-vars */
-// Mocking ChainStore -----------------------------------
-declare const fathom: { trackEvent: (eventName: string) => void };
-
-import { RpcEndpoint } from 'universal-authenticator-library';
-import { NativeCurrencyAddress, TokenClass } from 'src/antelope/types';
-
-export interface EVMChainSettings {
- getStakedSystemToken(): TokenClass;
- getWrappedSystemToken: () => TokenClass;
- getChainId: () => string;
- getDisplay: () => string;
- trackAnalyticsEvent: (name: string) => void;
- getRPCEndpoint: () => RpcEndpoint;
- getEscrowContractAddress: () => string;
- getNetwork: () => string;
- getSystemToken: () => TokenClass;
- getExplorerUrl: () => string;
- getSmallLogoPath: () => string;
- getLargeLogoPath: () => string;
-}
-
-const settings = {
- getChainId: () => process.env.NETWORK_EVM_CHAIN_ID,
- getDisplay: () => process.env.NETWORK_EVM_DISPLAY,
- trackAnalyticsEvent(eventName: string): void {
- if (typeof fathom === 'undefined') {
- console.warn(`Failed to track event with name ${eventName}: Fathom Analytics not loaded`);
- return;
- }
-
- fathom.trackEvent(eventName);
- },
- getRPCEndpoint: () => {
- // extract the url parts
- const regex = /^(https?):\/\/([^:/]+)(?::(\d+))?(\/.*)?$/;
- const match = (process.env.NETWORK_EVM_RPC as string).match(regex);
- if (!match) {
- throw new Error('Invalid RPC endpoint');
- }
- // We destructure the result of the match to get each component
- const [, protocol, host, port, path] = match;
- return {
- protocol,
- host,
- port: port ? parseInt(port, 10) : 443,
- path: path || '/',
- };
- },
- getEscrowContractAddress: () => process.env.TELOS_ESCROW_CONTRACT_ADDRESS,
- getStakedSystemToken: () => ({
- address: process.env.STAKED_TLOS_CONTRACT_ADDRESS,
- decimals: 18,
- symbol: 'STLOS',
- } as TokenClass),
- getWrappedSystemToken: () => ({
- address: process.env.WRAPPED_TLOS_CONTRACT_ADDRESS,
- decimals: 18,
- symbol: 'WTLOS',
- } as TokenClass),
- getSystemToken: () => ({
- name: 'Telos',
- address: NativeCurrencyAddress,
- decimals: 18,
- symbol: 'TLOS',
- } as TokenClass),
- getNetwork: () => process.env.NETWORK_EVM_NAME,
- getExplorerUrl: () => window.location.origin,
- getSmallLogoPath: () => 'small-icon-url',
- getLargeLogoPath: () => 'large-icon-url',
-} as EVMChainSettings;
-
-const currentChain = {
- settings,
-};
-
-const loggedChain = {
- settings,
-};
-
-const loggedEvmChain = {
- settings,
-};
-
-const ChainStore = {
- currentChain,
- loggedChain,
- loggedEvmChain,
- getNetworkSettings: (network: string) => settings,
- getChain: (label: string) => currentChain,
- setChain: (context: string, network: string) => void 0,
-};
-
-export const useChainStore = () => ChainStore;
diff --git a/src/antelope/mocks/index.ts b/src/antelope/mocks/index.ts
deleted file mode 100644
index a9ab5b7e7..000000000
--- a/src/antelope/mocks/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export * from 'src/antelope/mocks/FeedbackStore';
-export * from 'src/antelope/mocks/AccountStore';
-export * from 'src/antelope/mocks/AntelopeConfig';
-export * from 'src/antelope/mocks/ChainStore';
-export * from 'src/antelope/mocks/ContractStore';
-export * from 'src/antelope/mocks/EVMStore';
-export * from 'src/antelope/mocks/PlatformStore';
-
-export const CURRENT_CONTEXT = 'current';
diff --git a/src/antelope/types/Theme.ts b/src/antelope/types/Theme.ts
deleted file mode 100644
index dfe49cefd..000000000
--- a/src/antelope/types/Theme.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-export interface Theme {
- primary?: string;
- secondary?: string;
- accent?: string;
- dark?: string;
- positive?: string;
- negative?: string;
- info?: string;
- warning?: string;
- 'color-map'?: string;
- 'color-primary-gradient'?: string;
- 'color-secondary-gradient'?: string;
- 'color-tertiary-gradient'?: string;
- 'color-progress-gradient'?: string;
- 'color-producer-card-background'?: string;
- 'color-select-box-background'?: string;
-}
diff --git a/src/antelope/types/index.ts b/src/antelope/types/index.ts
deleted file mode 100644
index 9c121127f..000000000
--- a/src/antelope/types/index.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-// interfaces for antelope
-export * from 'src/antelope/types/ABIv1';
-export * from 'src/antelope/types/Actions';
-export * from 'src/antelope/types/AntelopeError';
-export * from 'src/antelope/types/Api';
-export * from 'src/antelope/types/ChainInfo';
-export * from 'src/antelope/types/ChainSettings';
-export * from 'src/antelope/types/EvmBlockData';
-export * from 'src/antelope/types/EvmContractData';
-export * from 'src/antelope/types/EvmLog';
-export * from 'src/antelope/types/EvmRexDeposit';
-export * from 'src/antelope/types/EvmTransaction';
-export * from 'src/antelope/types/ExceptionError';
-export * from 'src/antelope/types/Filters';
-export * from 'src/antelope/types/IndexerTypes';
-export * from 'src/antelope/types/KeyAccounts';
-export * from 'src/antelope/types/Basic';
-export * from 'src/antelope/types/NFTClass';
-export * from 'src/antelope/types/OpenSeaTypes';
-export * from 'src/antelope/types/PriceData';
-export * from 'src/antelope/types/Proposals';
-export * from 'src/antelope/types/Producers';
-export * from 'src/antelope/types/Providers';
-export * from 'src/antelope/types/Theme';
-export * from 'src/antelope/types/TokenClass';
-export * from 'src/antelope/types/TransactionV1';
-
-
-// classes for antelope
-export * from 'src/antelope/types/AntelopeError';
-
-// interfaces for antelope evm-abi
-export * from 'src/antelope/wallets/utils/abi';
diff --git a/src/antelope/wallets/index.ts b/src/antelope/wallets/index.ts
deleted file mode 100644
index 07b7d65ca..000000000
--- a/src/antelope/wallets/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-
-export * from 'src/antelope/wallets/authenticators/EVMAuthenticator';
-export * from 'src/antelope/wallets/authenticators/OreIdAuth';
-export * from 'src/antelope/wallets/authenticators/InjectedProviderAuth';
-export * from 'src/antelope/wallets/authenticators/MetamaskAuth';
-export * from 'src/antelope/wallets/authenticators/SafePalAuth';
-export * from 'src/antelope/wallets/authenticators/WalletConnectAuth';
-export * from 'src/antelope/wallets/authenticators/BraveAuth';
-export * from 'src/antelope/mocks';
diff --git a/src/antelope/wallets/utils/abi/signature/index.ts b/src/antelope/wallets/utils/abi/signature/index.ts
deleted file mode 100644
index 88a3fc857..000000000
--- a/src/antelope/wallets/utils/abi/signature/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from 'src/antelope/wallets/utils/abi/signature/events_signatures';
-export * from 'src/antelope/wallets/utils/abi/signature/functions_signatures';
-export * from 'src/antelope/wallets/utils/abi/signature/transfer_signatures';
diff --git a/src/assets/tokens/telos.png b/src/assets/tokens/telos.png
new file mode 100644
index 000000000..2be9c2c7c
Binary files /dev/null and b/src/assets/tokens/telos.png differ
diff --git a/src/boot/antelope.ts b/src/boot/antelope.ts
index 415b5528a..b45dbde81 100644
--- a/src/boot/antelope.ts
+++ b/src/boot/antelope.ts
@@ -1,9 +1,21 @@
import { boot } from 'quasar/wrappers';
-import { initAntelope } from 'src/antelope/wallets/init';
-
+import { initAntelope } from 'src/core/wallets/init';
+import { evmSettings, useChainStore } from 'src/core';
export default boot(({ app }) => {
initAntelope(app);
+
+ const defaultNetwork = Object.keys(evmSettings)[0];
+ let network = new URLSearchParams(window.location.search).get('network');
+ if (network) {
+ const exists = Object.keys(evmSettings).some(key => evmSettings[key].getNetwork() === network);
+ if (!exists) {
+ network = defaultNetwork;
+ }
+ } else {
+ network = defaultNetwork;
+ }
+ useChainStore().setChain('not-used', network);
});
diff --git a/src/boot/antelopeApi.js b/src/boot/antelopeApi.js
deleted file mode 100644
index e90dc7d37..000000000
--- a/src/boot/antelopeApi.js
+++ /dev/null
@@ -1,71 +0,0 @@
-import { boot } from 'quasar/wrappers';
-import { Api, JsonRpc } from 'eosjs';
-
-const signTransaction = async function(actions) {
- actions.forEach((action) => {
- if (!action.authorization || !action.authorization.length) {
- action.authorization = [
- {
- actor: this.state.account.accountName,
- permission: 'active',
- },
- ];
- }
- });
- let transaction = null;
- try {
- if (this.$type === 'ual') {
- transaction = await this.$ualUser.signTransaction(
- {
- actions,
- },
- {
- blocksBehind: 3,
- expireSeconds: 30,
- },
- );
- }
- } catch (e) {
- console.error(actions, e.cause.message);
- throw e.cause.message;
- }
- return transaction;
-};
-
-const getRpc = function () {
- return this.$type === 'ual' ? this.$ualUser.rpc : this.$defaultApi.rpc;
-};
-
-const getTableRows = async function(options) {
- const rpc = this.$antelopeApi.getRpc();
- return await rpc.get_table_rows({
- json: true,
- ...options,
- });
-};
-
-const getAccount = async function (accountName) {
- const rpc = this.$antelopeApi.getRpc();
- return await rpc.get_account(accountName);
-};
-
-export default boot(async ({ app, store }) => {
- store.$isAntelopeCapable = app.config.globalProperties.isAntelopeCapable = false;
- if(process.env.NETWORK_PROTOCOL && process.env.NETWORK_HOST){
- const rpc = new JsonRpc(
- `${process.env.NETWORK_PROTOCOL}://${process.env.NETWORK_HOST}:${process.env.NETWORK_PORT}`,
- );
- store.$defaultApi = new Api({
- rpc,
- textDecoder: new TextDecoder(),
- textEncoder: new TextEncoder(),
- });
- store.$isAntelopeCapable = app.config.globalProperties.isAntelopeCapable = true;
- }
- store.$antelopeApi = {
- signTransaction: signTransaction.bind(store),
- getTableRows: getTableRows.bind(store),
- getAccount: getAccount.bind(store),
- getRpc: getRpc.bind(store),
- };
-});
diff --git a/src/boot/api.js b/src/boot/api.js
deleted file mode 100644
index 66ffe3a11..000000000
--- a/src/boot/api.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { boot } from 'quasar/wrappers';
-import { Api, JsonRpc } from 'eosjs';
-
-const signTransaction = async function(actions) {
- actions.forEach((action) => {
- if (!action.authorization || !action.authorization.length) {
- action.authorization = [
- {
- actor: this.state.account.accountName,
- permission: 'active',
- },
- ];
- }
- });
- let transaction = null;
- try {
- if (this.$type === 'ual') {
- transaction = await this.$ualUser.signTransaction(
- {
- actions,
- },
- {
- blocksBehind: 3,
- expireSeconds: 30,
- },
- );
- }
- } catch (e) {
- console.debug(actions, e.cause.message);
- throw e.cause.message;
- }
- return transaction;
-};
-
-const getRpc = function () {
- return this.$type === 'ual' ? this.$ualUser.rpc : this.$defaultApi.rpc;
-};
-
-const getTableRows = async function(options) {
- const rpc = this.$api.getRpc();
- return await rpc.get_table_rows({
- json: true,
- ...options,
- });
-};
-
-const getAccount = async function (accountName) {
- const rpc = this.$api.getRpc();
- return await rpc.get_account(accountName);
-};
-
-export default boot(async ({ store }) => {
- const rpc = new JsonRpc(
- `${process.env.NETWORK_PROTOCOL}://${process.env.NETWORK_HOST}:${process.env.NETWORK_PORT}`,
- );
- store['$defaultApi'] = new Api({
- rpc,
- textDecoder: new TextDecoder(),
- textEncoder: new TextEncoder(),
- });
-
- store['$api'] = {
- signTransaction: signTransaction.bind(store),
- getTableRows: getTableRows.bind(store),
- getAccount: getAccount.bind(store),
- getRpc: getRpc.bind(store),
- };
-
-});
diff --git a/src/boot/evm.js b/src/boot/evm.js
index 9ebb6557e..f19d51cbb 100644
--- a/src/boot/evm.js
+++ b/src/boot/evm.js
@@ -1,17 +1,6 @@
import { boot } from 'quasar/wrappers';
-import { TelosEvmApi } from '@telosnetwork/telosevm-js';
-import fetch from 'node-fetch';
-import axios from 'axios';
import { ethers } from 'ethers';
-
-const evm = new TelosEvmApi({
- endpoint: process.env.NETWORK_EVM_ENDPOINT,
- chainId: parseInt(process.env.NETWORK_EVM_CHAIN_ID),
- ethPrivateKeys: [],
- telosContract: process.env.NETWORK_EVM_CONTRACT,
- telosPrivateKeys: [],
- fetch,
-});
+import { useChainStore } from 'src/core';
// This is kinda bad, but if you try to store a web3 provider in the store, it has a call stack size exception,
// and if you freeze the provider before putting in the store so the call stack error goes away, you break
@@ -27,7 +16,7 @@ class ProviderManager {
getEthersProvider() {
return new ethers.providers.Web3Provider(
- providerContainer.provider, parseInt(process.env.NETWORK_EVM_CHAIN_ID, 10),
+ providerContainer.provider, parseInt(useChainStore().currentChain.settings.getChainId(), 10),
);
}
@@ -36,16 +25,10 @@ class ProviderManager {
}
}
-const hyperion = axios.create({
- baseURL: process.env.NETWORK_EVM_ENDPOINT,
-});
-
const providerManager = new ProviderManager();
export default boot(({ app, store }) => {
store.$providerManager = app.config.globalProperties.$providerManager = providerManager;
- store.$evm = app.config.globalProperties.$evm = evm;
- store.$evmEndpoint = app.config.globalProperties.$evmEndpoint = hyperion;
});
-export { evm, providerManager };
+export { providerManager };
diff --git a/src/boot/hyperion.js b/src/boot/hyperion.js
deleted file mode 100644
index 76bae4d9a..000000000
--- a/src/boot/hyperion.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import { boot } from 'quasar/wrappers';
-import axios from 'axios';
-
-const hyperion = axios.create({
- baseURL: process.env.HYPERION_ENDPOINT,
-});
-
-export default boot(({ app, store }) => {
- app.config.globalProperties.$hyperion = hyperion;
- store.$hyperion = hyperion;
-});
-
-export { hyperion };
diff --git a/src/boot/telosApi.js b/src/boot/telosApi.js
deleted file mode 100644
index 88724a0f4..000000000
--- a/src/boot/telosApi.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import { boot } from 'quasar/wrappers';
-import axios from 'axios';
-import ContractManager from 'src/lib/contract/ContractManager';
-import FragmentParser from 'src/lib/contract/FragmentParser';
-import { markRaw } from 'vue';
-
-const telosApi = axios.create({
- baseURL: process.env.TELOS_API_ENDPOINT,
-});
-const indexerApi = axios.create({
- baseURL: process.env.INDEXER_API_ENDPOINT,
-});
-const exportApi = axios.create({
- baseURL: process.env.EXPORT_API_ENDPOINT,
-});
-const hyperion = axios.create({
- baseURL: process.env.NETWORK_EVM_ENDPOINT,
-});
-
-const fragmentParser = new FragmentParser(hyperion);
-let contractManager = new ContractManager(indexerApi, fragmentParser);
-
-
-export default boot(({ app, store }) => {
- app.config.globalProperties.$telosApi = telosApi;
- app.config.globalProperties.$indexerApi = indexerApi;
- app.config.globalProperties.$exportApi = exportApi;
- app.config.globalProperties.$fragmentParser = fragmentParser;
- store.$contractManager = app.config.globalProperties.$contractManager = markRaw(contractManager);
- store.$indexerApi = indexerApi;
- store.$exportApi = exportApi;
- // Intercept API answer to set contracts & abi in cache directly
- indexerApi.interceptors.response.use(function (response) {
- if(response.data?.abi?.length > 0){
- for (const [key, value] of Object.entries(response.data.abi)) {
- app.config.globalProperties.$contractManager.parser.addFunctionInterface(key, value);
- app.config.globalProperties.$fragmentParser.addFunctionInterface(key, value);
- }
- }
- if(response.data?.contracts){
- app.config.globalProperties.$contractManager.addContractsToCache(response.data.contracts);
- }
- return response;
- }, function (error) {
- return Promise.reject(error);
- });
-
-});
-
-export { telosApi, indexerApi, exportApi, contractManager, fragmentParser };
diff --git a/src/boot/ual.js b/src/boot/ual.js
deleted file mode 100644
index 671ed4d49..000000000
--- a/src/boot/ual.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import { boot } from 'quasar/wrappers';
-import { UAL } from 'universal-authenticator-library';
-import { Wombat } from 'ual-wombat';
-import { Anchor } from 'ual-anchor';
-
-const chain = {
- chainId: process.env.NETWORK_CHAIN_ID,
- rpcEndpoints: [
- {
- protocol: process.env.NETWORK_PROTOCOL,
- host: process.env.NETWORK_HOST,
- port: process.env.NETWORK_PORT,
- },
- ],
-};
-
-const authenticators = [
- new Anchor([chain], { appName: process.env.APP_NAME }),
- new Wombat([chain], { appName: process.env.APP_NAME }),
-];
-
-const ual = new UAL([chain], 'ual', authenticators);
-
-export default boot(async({ app, store }) => {
- store['$ual'] = ual;
- app.config.globalProperties.$ual = ual;
-});
-
-export { ual };
diff --git a/src/components/AddressField.vue b/src/components/AddressField.vue
index 211199ed7..9d9528e99 100644
--- a/src/components/AddressField.vue
+++ b/src/components/AddressField.vue
@@ -1,13 +1,12 @@
@@ -42,6 +65,11 @@ onBeforeMount(async () => {
+
+
+ {{ $t('pages.no_transactions_yet') }}
+
+
{{ $t('pages.last') }} {{ $t('pages.transaction_sent') }}
@@ -56,7 +84,7 @@ onBeforeMount(async () => {
-
+
{{ $t('pages.first') }} {{ $t('pages.transaction_sent') }}
diff --git a/src/components/AddressOverview.vue b/src/components/AddressOverview.vue
index a078a040c..afc41b3e6 100644
--- a/src/components/AddressOverview.vue
+++ b/src/components/AddressOverview.vue
@@ -1,8 +1,8 @@
@@ -533,13 +77,12 @@ const handleResultClick = (item: SearchResult): void => {
v-model="searchTerm"
dense
outlined
- class="c-search__input"
color="black"
hide-bottom-space
:placeholder="$t('components.header.search_placeholder')"
type="search"
inputmode="search"
- @keydown="handleKeydown"
+ @keydown.enter="search"
>
{
size="24px"
class="c-search__icon"
aria-hidden="true"
+ @click="search"
/>
-
-
-
-
-
-
{{ $t('components.header.no_results') }}
-
-
-
-
-
- {{ resolveTabLabel(entry.category) }}
-
-
-
-
@@ -621,7 +109,7 @@ const handleResultClick = (item: SearchResult): void => {
max-width: 500px;
@media screen and (min-width: $breakpoint-md-min) {
- width: 450px;
+ width: 400px;
}
@media screen and (min-width: $breakpoint-lg-min) {
@@ -713,68 +201,5 @@ const handleResultClick = (item: SearchResult): void => {
&__icon {
cursor: pointer;
}
-
- // autocomplete styles
-
- &__loading {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100px;
- }
-
- &__no-results {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100px;
- color: var(--text-color);
- }
-
- &__result-category-divider {
- padding: 16px 8px 4px 18px;
- text-transform: uppercase;
- font-size: 0.65rem;
- letter-spacing: .5px;
- color: var(--text-color);
- border-top: 1px solid var(--border-color);
- }
-
- &__autocomplete {
- position: absolute;
- width: calc(100% - 24px);
- @media screen and (min-width: $breakpoint-md-min) {
- width: 680px;
- }
-
- @media screen and (min-width: $breakpoint-lg-min) {
- width: 730px;
- }
- #{$this}--homepage & {
- max-width: 800px;
- width: 100%;
- }
- background: var(--background-color);
- border: 1px solid var(--border-color);
- border-radius: 4px;
- margin-top: 4px;
- z-index: 10;
- }
-
- &__tabs {
- padding: 10px 10px 0px 10px;
- @include tabs-container;
- }
-
- &__results {
- @include scroll-bar;
- max-height: 30vh;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: 10px;
- padding-bottom: 10px;
- width: 100%;
- }
}
diff --git a/src/components/BlockTable.vue b/src/components/BlockTable.vue
index c3a2a52a9..04cb267b0 100644
--- a/src/components/BlockTable.vue
+++ b/src/components/BlockTable.vue
@@ -4,14 +4,13 @@ import { useRoute, useRouter } from 'vue-router';
import { onBeforeMount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
-import { indexerApi } from 'src/boot/telosApi';
-
import BlockField from 'components/BlockField.vue';
import DateField from 'components/DateField.vue';
import { BlockData } from 'src/types';
import { ethers } from 'ethers';
import { Pagination } from 'src/types';
+import { useChainStore } from 'src/core';
const $q = useQuasar();
const route = useRoute();
@@ -70,11 +69,12 @@ const columns = [
},
];
-watch(() => route.query.page,
- (pageParam) => {
+watch(() => route.query,
+ () => {
let page = 1;
let desc = true;
let size = page_size_options[0];
+ const pageParam = route.query.page;
// we also allow to pass a single number as the page number
if (typeof pageParam === 'number') {
@@ -122,6 +122,7 @@ async function onPaginationChange(settings: { pagination: Pagination}) {
async function fetchBlocksPage() {
const path = getPath();
+ const indexerApi = useChainStore().currentChain.settings.getIndexerApi();
const result = await indexerApi.get(path);
if (pagination.value.rowsNumber === 0) {
pagination.value.rowsNumber = result.data?.total_count ?? 0;
@@ -165,7 +166,7 @@ async function parseBlocks() {
function getPath() {
const { page, rowsPerPage, descending } = pagination.value;
- let path = `blocks?limit=${
+ let path = `v1/blocks?limit=${
rowsPerPage === 0 ? 25 : rowsPerPage
}`;
path += `&offset=${(page - 1) * rowsPerPage}`;
diff --git a/src/components/ContractTab/ContractByteCode.vue b/src/components/ContractTab/ContractByteCode.vue
index 153fad05d..e44d7c070 100644
--- a/src/components/ContractTab/ContractByteCode.vue
+++ b/src/components/ContractTab/ContractByteCode.vue
@@ -1,61 +1,63 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/components/ContractTab/ContractSource.vue b/src/components/ContractTab/ContractSource.vue
index 96c107857..a2658de7c 100644
--- a/src/components/ContractTab/ContractSource.vue
+++ b/src/components/ContractTab/ContractSource.vue
@@ -14,6 +14,7 @@ import { useRoute } from 'vue-router';
import CopyButton from 'src/components/CopyButton.vue';
import ContractHeader from 'components/ContractHeader.vue';
import { MetaData } from 'src/types/MetaData';
+import { useChainStore } from 'src/core';
hljs.registerLanguage('json', json);
hljsDefineSolidity(hljs);
@@ -104,9 +105,10 @@ watch(expanded.value, () => {
onMounted(async () => {
let sourceData;
try {
+ // TODO: remove this
const checkSumAddress = toChecksumAddress(route.params.address);
const response = await axios.get(
- `https://${process.env.VERIFIED_CONTRACTS_BUCKET}.s3.amazonaws.com/${checkSumAddress}/source.json`,
+ `${useChainStore().currentChain.settings.getTrustedContractsBucket()}/${checkSumAddress}/source.json`,
);
sourceData = response.data;
sources.value = sourceData;
diff --git a/src/components/ContractTab/FunctionInterface.vue b/src/components/ContractTab/FunctionInterface.vue
index ff2103012..9d7a019b4 100644
--- a/src/components/ContractTab/FunctionInterface.vue
+++ b/src/components/ContractTab/FunctionInterface.vue
@@ -7,28 +7,23 @@ import { mapGetters } from 'vuex';
import { BigNumber, ethers } from 'ethers';
import { Transaction } from '@ethereumjs/tx';
import { LOGIN_DATA_KEY } from 'src/lib/utils';
-import { useAccountStore } from 'src/antelope';
-import { CURRENT_CONTEXT } from 'src/antelope/wallets';
-import { EvmABI, EvmFunctionParam } from 'src/antelope/types';
-import { WEI_PRECISION } from 'src/antelope/wallets/utils';
+import { useAccountStore } from 'src/core';
+import { CURRENT_CONTEXT, useChainStore } from 'src/core/wallets';
+import { EvmABI, EvmFunctionParam } from 'src/core/types';
+import { WEI_PRECISION } from 'src/core/wallets/utils';
import {
asyncInputComponents,
- getComponentForInputType,
- getExpectedArrayLengthFromParameterType,
- getIntegerBits,
- inputIsComplex,
- parameterIsArrayType,
- parameterIsIntegerType,
- parameterTypeIsBoolean,
- parameterTypeIsSignedIntArray,
- parameterTypeIsTupleStruct,
- parameterTypeIsTupleStructArray,
- parameterTypeIsUnsignedIntArray,
} from 'src/lib/function-interface-utils';
import TransactionField from 'src/components/TransactionField.vue';
import LoginModal from 'components/LoginModal.vue';
import FunctionOutputViewer from 'components/ContractTab/FunctionOutputViewer.vue';
-import { OutputType, OutputValue, InputDescription } from 'src/types';
+import {
+ InputComponent,
+ OutputType,
+ OutputValue,
+ inputComponents,
+} from 'src/types';
+import { getComponentsForAbiInputs } from 'src/lib/function-interface-utils-ts';
interface Opts {
value?: string;
@@ -97,8 +92,12 @@ export default defineComponent({
selectDecimals: decimalOptions[0],
customDecimals: 0, // number
value: '0', // string
- inputModels: [] as string[], // raw input values
- params: [] as EvmFunctionParam[], // parsed input values
+ missingInputs: true, // boolean
+ models: {
+ inputs: [] as string[], // raw input values
+ values: [] as EvmFunctionParam[], // parsed input values
+ },
+
valueParam: {
'name': 'value',
'type': 'amount',
@@ -121,87 +120,39 @@ export default defineComponent({
functionABI(){
return `${this.abi.name}(${this.abi.inputs.map((i: { type: never; }) => i.type).join(',')})`;
},
- inputComponents() {
- if (!Array.isArray(this.abi?.inputs)) {
- return [];
+ inputComponents(): inputComponents {
+ const isRoot = true;
+ const components = getComponentsForAbiInputs(this.abi?.inputs, this.models, isRoot) as unknown as inputComponents;
+ return components;
+ },
+ },
+ methods: {
+ valueParsed(inputType: string, index: number, value: EvmFunctionParam, component: InputComponent) {
+ component.handleValueParsed(inputType, index, value);
+ this.updateMissingInputs();
+ },
+ updateMissingInputs() {
+ const inputs_length = this.abi.inputs.length;
+ const values_length = this.models.values.length;
+ if (inputs_length !== values_length) {
+ this.missingInputs = true;
+ return true;
}
- const getExtraBindingsForType = (input: InputDescription, index: number) => {
- const { type, name, components } = input;
- const label = `${name ? name : `Param ${index + 1}`}`;
- const extras = {} as {[key:string]: string | InputDescription[]};
-
- // represents integer bits (e.g. uint256) for int types, or array length for array types
- let size = undefined;
- if (parameterIsArrayType(type)) {
- size = getExpectedArrayLengthFromParameterType(type);
- } else if (parameterIsIntegerType(type)) {
- size = getIntegerBits(type);
- } else if (parameterTypeIsTupleStruct(type) && components) {
- size = toRaw(components).length;
- }
-
- const result = type.match(/(\d+)(?=\[)/);
- const intSize = result ? result[0] : undefined;
-
- if (intSize && parameterTypeIsUnsignedIntArray(type)) {
- extras['uint-size'] = intSize;
- } else if (intSize && parameterTypeIsSignedIntArray(type)) {
- extras['int-size'] = intSize;
- } else if (parameterTypeIsTupleStruct(type) && components) {
- extras['componentDescription'] = toRaw(components);
- } else if (parameterTypeIsTupleStructArray(type) && components) {
- extras['componentDescription'] = toRaw(components);
- }
-
- const defaultModelValue = parameterTypeIsBoolean(type) ? null : '';
-
- const bindings = {
- ...extras,
- label,
- size,
- modelValue: this.inputModels[index] ?? defaultModelValue,
- name: label.toLowerCase(),
- };
- return bindings;
- };
-
- const handleModelValueChange = (type: string, index: number, value: string) => {
- this.inputModels[index] = value;
-
- if (!inputIsComplex(type)) {
- this.params[index] = value;
- }
- };
- const handleValueParsed = (type: string, index: number, value: EvmFunctionParam) => {
- if (inputIsComplex(type)) {
- this.params[index] = value;
- }
- };
-
- return this.abi.inputs.map((input, index) => ({
- bindings: getExtraBindingsForType(input, index),
- is: getComponentForInputType(input.type),
- inputType: input.type,
- handleModelValueChange: (type: string, index: number, value: string) => handleModelValueChange(type, index, value),
- handleValueParsed: (type: string, index: number, value: EvmFunctionParam) => handleValueParsed(type, index, value),
- }));
- },
- missingInputs() {
- if (this.abi.inputs.length !== this.params.length) {
+ if (inputs_length !== values_length) {
+ this.missingInputs = true;
return true;
}
for (let i = 0; i < this.abi.inputs.length; i++) {
- if (['', null, undefined].includes(this.params[i] as never)) {
+ if (['', null, undefined].includes(this.models.values[i] as never)) {
+ this.missingInputs = true;
return true;
}
}
-
+ this.missingInputs = false;
return false;
},
- },
- methods: {
showAmountDialog(param: string) {
this.amountParam = param;
this.amountDecimals = 18;
@@ -217,7 +168,7 @@ export default defineComponent({
if (typeof this.amountParam === 'string') {
this.value = integerAmount;
} else {
- this.params[this.amountParam] = integerAmount as never;
+ this.models.values[this.amountParam] = integerAmount as never;
}
this.clearAmount();
@@ -229,7 +180,6 @@ export default defineComponent({
this.showLoginModal = true;
},
async run() {
- console.log('run');
if (!this.isLoggedIn && this.write){
this.login();
return;
@@ -267,12 +217,16 @@ export default defineComponent({
this.endLoading();
},
async getEthersFunction(provider?: ethers.providers.JsonRpcSigner | ethers.providers.JsonRpcProvider) {
- const contractInstance = await this.$contractManager.getContractInstance(this.contract, provider);
- return contractInstance[this.functionABI];
+ const contractInstance = await useChainStore().currentChain.settings.getContractManager().getContractInstance(this.contract, provider);
+ if (!contractInstance) {
+ throw new Error('Contract not found');
+ } else {
+ return contractInstance[this.functionABI];
+ }
},
runRead() {
return this.getEthersFunction()
- .then(func => func(...this.params)
+ .then(func => func(...this.models.values)
.then((response: OutputValue | OutputValue[]) => {
this.result = response as unknown as string;
this.response = Array.isArray(response) ? response : [response];
@@ -289,10 +243,18 @@ export default defineComponent({
const contractInstance = toRaw(await this.contract.getContractInstance());
const func = contractInstance.populateTransaction[this.functionABI];
const gasEstimater = contractInstance.estimateGas[this.functionABI];
- const gasLimit = await gasEstimater(...this.params, Object.assign({ from: this.address }, opts));
- const unsignedTrx = await func(...this.params, opts);
- const nonce = parseInt(await this.$evm.telos.getNonce(this.address), 16);
- const gasPrice = BigNumber.from(`0x${await this.$evm.telos.getGasPrice()}`);
+ const gasLimit = await gasEstimater(...this.models.values, Object.assign({ from: this.address }, opts));
+ const unsignedTrx = await func(...this.models.values, opts);
+ const chain = useChainStore().currentChain;
+ const evm = chain.settings.getNativeSupport();
+ if (!evm) {
+ // we need to notify the user that the chain does not support native contracts
+ this.errorMessage = this.$t('components.native_not_supported');
+ this.endLoading();
+ return;
+ }
+ const nonce = parseInt(await evm.telos.getNonce(this.address), 16);
+ const gasPrice = BigNumber.from(`0x${await evm.telos.getGasPrice()}`);
unsignedTrx.nonce = nonce;
unsignedTrx.gasLimit = gasLimit;
unsignedTrx.gasPrice = gasPrice;
@@ -335,7 +297,7 @@ export default defineComponent({
const trxBuffer = Buffer.from(raw.replace(/^0x/, ''), 'hex');
const tx = Transaction.fromSerializedTx(trxBuffer, {
- common: this.$evm.chainConfig,
+ common: evm.chainConfig,
});
this.hash = `0x${tx?.hash().toString('hex')}`;
@@ -355,7 +317,7 @@ export default defineComponent({
keyMsg = 'notification.neutral_message_custom_call_send';
keyErr = 'notification.error_message_custom_call_send';
const quantity = ethers.utils.formatUnits(value, WEI_PRECISION);
- const symbol = 'TLOS';
+ const symbol = useChainStore().currentChain.settings.getSystemToken().symbol;
message = this.$t(keyMsg, { name, params, quantity, symbol });
error = this.$t(keyErr, { name, params, quantity, symbol });
}
@@ -366,7 +328,7 @@ export default defineComponent({
error,
this.contract.address,
[this.abi] as EvmABI,
- this.params,
+ this.models.values,
value,
).then((result) => {
this.hash = result.hash;
@@ -449,8 +411,8 @@ export default defineComponent({
:key="index"
v-bind="component.bindings"
required="true"
- class="input-component q-pb-lg"
- @valueParsed="component.handleValueParsed(component.inputType, index, $event)"
+ class="input-component q-pb-md"
+ @valueParsed="valueParsed(component.inputType, index, $event, component)"
@update:modelValue="component.handleModelValueChange(component.inputType, index, $event)"
/>
@@ -482,7 +444,7 @@ export default defineComponent({
-
diff --git a/src/components/LoginModal.vue b/src/components/LoginModal.vue
index ac40eb234..efcc624b4 100644
--- a/src/components/LoginModal.vue
+++ b/src/components/LoginModal.vue
@@ -5,7 +5,6 @@ import { useStore } from 'vuex';
import { useI18n } from 'vue-i18n';
import detectEthereumProvider from '@metamask/detect-provider';
import { Authenticator } from 'universal-authenticator-library';
-import { TelosEvmApi } from '@telosnetwork/telosevm-js';
import {
LOGIN_EVM,
@@ -22,9 +21,8 @@ import {
getAntelope,
useAccountStore,
useChainStore,
-} from 'src/antelope/mocks';
-import { ual } from 'src/boot/ual';
-import { evm, providerManager } from 'src/boot/evm';
+} from 'src/core/mocks';
+import { providerManager } from 'src/boot/evm';
const $q = useQuasar();
const store = useStore();
@@ -42,7 +40,7 @@ const browserSupportsMetaMask = ref(true);
const isBraveBrowser = ref(false);
const isIOSMobile = ref(false);
-const authenticators = computed(() => ual.getAuthenticators().availableAuthenticators);
+const authenticators = computed(() => getAntelope().config.authenticatorsGetter());
onMounted(async () => {
await detectProvider();
@@ -111,9 +109,10 @@ async function ualLogin(wallet: Authenticator, account?: string) {
if (users.length) {
const account = users[0];
const accountName = await account.getAccountName();
- let evmAccount;
+ let evmAccount = '';
try {
- evmAccount = await (evm as unknown as TelosEvmApi).telos.getEthAccountByTelosAccount(accountName);
+ const chain = useChainStore().currentChain;
+ evmAccount = await chain.settings.getEthAccountByNativeAccount(accountName);
} catch (e) {
$q.notify({
position: 'top',
@@ -124,14 +123,14 @@ async function ualLogin(wallet: Authenticator, account?: string) {
return;
}
setLogin({
- address: evmAccount.address,
+ address: evmAccount,
nativeAccount: accountName,
});
providerManager.setProvider(account);
localStorage.setItem(LOGIN_DATA_KEY, JSON.stringify({
type: LOGIN_NATIVE,
provider: wallet.getName(),
- account: evmAccount.address,
+ account: evmAccount,
}));
}
emit('hide');
diff --git a/src/components/MethodField.vue b/src/components/MethodField.vue
index 235254f2d..505a98cf6 100644
--- a/src/components/MethodField.vue
+++ b/src/components/MethodField.vue
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import { ZERO_ADDRESSES } from 'src/lib/utils';
import { useStore } from 'vuex';
+import { useChainStore } from 'src/core';
const { t: $t } = useI18n();
@@ -103,7 +104,9 @@ const setValues = async () => {
nativeTooltipText.value = $t('pages.transactions.native_withdraw_tooltip');
methodName.value = $t('pages.transactions.withdraw_action_name');
} else if (!props.trx.parsedTransaction && props.trx.input === '0x' && propValue.value) {
- methodName.value = $t('pages.transactions.transfer_tlos_action_name');
+ methodName.value = $t('pages.transactions.transfer_tlos_action_name', {
+ symbol: useChainStore().currentChain.settings.getSystemToken().symbol,
+ });
} else if (!props.trx.parsedTransaction && props.trx.to === null) {
methodName.value = $t('pages.transactions.contract_deployment');
} else if (props.trx.parsedTransaction) {
diff --git a/src/components/NftItemField.vue b/src/components/NftItemField.vue
index 5addbc695..671407973 100644
--- a/src/components/NftItemField.vue
+++ b/src/components/NftItemField.vue
@@ -1,8 +1,7 @@
+
-
+
+
+
+
+
+
+ {{ $t('components.approvals.approvals_granted_title') }}
+
+
+
+
+
+
+
{{ $t('components.approvals.spender') }} :
+
+
+
+ {{ $t('components.approvals.amount') }} :
+
+
+
+
{{ $t('components.approvals.amount') }} :
+
+
+ {{ $t('components.approvals.infinite') }}
+
+
{{ $t('components.approvals.infinite_tooltip') }}
+
+
+
+
{{ $t('components.token') }} :
+
+
#{{ approval.tokenId }}
+
+
+
{{ $t('components.token') }} :
+
+
+
+
+
+
+
+
+
+
+ {{ $t('pages.loading_approvals') }}
+
+
+
+
+
+
diff --git a/src/components/Transaction/ERCTransferList.vue b/src/components/Transaction/ERCTransferList.vue
index 00c8b4089..cd704b4e1 100644
--- a/src/components/Transaction/ERCTransferList.vue
+++ b/src/components/Transaction/ERCTransferList.vue
@@ -5,13 +5,13 @@ import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import { BigNumber } from 'ethers';
-import { EvmLogs } from 'src/antelope/types/EvmLog';
+import { EvmLogs } from 'src/core/types/EvmLog';
import AddressField from 'components/AddressField.vue';
import ValueField from 'components/ValueField.vue';
import { ERC721Transfer, ERC1155Transfer, ERC20Transfer, TokenBasicData } from 'src/types';
-import { contractManager } from 'src/boot/telosApi';
-import { TRANSFER_SIGNATURES } from 'src/antelope/types';
+import { TRANSFER_SIGNATURES } from 'src/core/types';
+import { useChainStore } from 'src/core';
const $q = useQuasar();
const { t: $t } = useI18n();
@@ -46,6 +46,8 @@ const loadTransfers = async () => {
return;
}
+ const contractManager = useChainStore().currentChain.settings.getContractManager();
+
const logs = props.logs as EvmLogs;
for (const log of logs) {
diff --git a/src/components/Transaction/FragmentListElement.vue b/src/components/Transaction/FragmentListElement.vue
index 2c9a72798..1f5e73578 100644
--- a/src/components/Transaction/FragmentListElement.vue
+++ b/src/components/Transaction/FragmentListElement.vue
@@ -5,6 +5,7 @@ import ParameterList from 'components/Transaction/ParameterList';
import AddressField from 'components/AddressField';
import { formatWei } from 'src/lib/utils';
import { BigNumber } from 'ethers';
+import { useChainStore } from 'src/core';
export default {
name: 'FragmentListElement',
@@ -88,6 +89,9 @@ export default {
!this.fragment.name
);
},
+ systemSymbol(){
+ return useChainStore().currentChain.settings.getSystemToken().symbol;
+ },
},
};
@@ -186,7 +190,7 @@ export default {
{{ $t('components.transaction.value_uint256').toLowerCase() }}
- {{ fragment.value }} TLOS
+ {{ fragment.value }} {{ systemSymbol }}
diff --git a/src/components/Transaction/InternalTxns.vue b/src/components/Transaction/InternalTxns.vue
index 509c1cb52..afc453efe 100644
--- a/src/components/Transaction/InternalTxns.vue
+++ b/src/components/Transaction/InternalTxns.vue
@@ -3,6 +3,7 @@ import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';
import FragmentList from 'components/Transaction/FragmentList.vue';
import { getParsedInternalTransactions } from 'src/lib/transaction-utils';
+import { useChainStore } from 'src/core';
export default {
@@ -25,7 +26,7 @@ export default {
methods: {
async getContract(address){
try {
- return await this.$contractManager.getContract(address);
+ return await useChainStore().currentChain.settings.getContractManager().getContract(address);
} catch (e) {
console.error(`Failed to retrieve contract with address ${address}`);
// Notify the user
@@ -39,6 +40,10 @@ export default {
},
async created() {
this.loading = true;
+ if (!this.transaction) {
+ this.loading = false;
+ return;
+ }
const { parsedItxs, itxs } = await getParsedInternalTransactions(this.transaction.hash, this.$t);
this.parsedItxs = parsedItxs;
this.itxs = itxs;
diff --git a/src/components/Transaction/LogsViewer.vue b/src/components/Transaction/LogsViewer.vue
index 0020d5e27..cf214c121 100644
--- a/src/components/Transaction/LogsViewer.vue
+++ b/src/components/Transaction/LogsViewer.vue
@@ -3,6 +3,7 @@ import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';
import FragmentList from 'components/Transaction/FragmentList';
import { BigNumber } from 'ethers';
+import { useChainStore } from 'src/core';
export default {
name: 'LogsViewer',
@@ -13,7 +14,7 @@ export default {
methods: {
async getLogContract(log){
try {
- return await this.$contractManager.getContract(log.address);
+ return await useChainStore().currentChain.settings.getContractManager().getContract(log.address);
} catch (e) {
console.error(`Failed to retrieve contract with address ${log.address}: ${e}`);
this.$q.notify({
@@ -52,7 +53,7 @@ export default {
let contract = await this.getLogContract(log);
if (contract){
verified = (contract.isVerified()) ? verified + 1: verified;
- let parsedLog = await this.$fragmentParser.parseLog(log, contract);
+ let parsedLog = await useChainStore().currentChain.settings.getFragmentParser().parseLog(log, contract);
if(parsedLog){
this.parsedLogs.push(parsedLog);
} else {
diff --git a/src/components/Transaction/TLOSTransferList.vue b/src/components/Transaction/TLOSTransferList.vue
index 450089210..7f78f559e 100644
--- a/src/components/Transaction/TLOSTransferList.vue
+++ b/src/components/Transaction/TLOSTransferList.vue
@@ -8,6 +8,7 @@ import ValueField from 'components/ValueField.vue';
import { EvmTransactionExtended } from 'src/types';
import { getParsedInternalTransactions } from 'src/lib/transaction-utils';
+import { useChainStore } from 'src/core';
const { t: $t } = useI18n();
@@ -51,13 +52,15 @@ const loadTransfers = async () => {
tlos_transfers.value = result.parsedItxs
.map((itx: any, i: number) => ({ ...itx, index: i }))
- .filter((itx: any) => itx.name === $t('components.transaction.tlos_transfer'))
+ .filter((itx: any) => itx.name === $t('components.transaction.tlos_transfer', {
+ symbol: useChainStore().currentChain.settings.getSystemToken().symbol,
+ }))
.map((itx: any) => ({
from: itx.from,
to: itx.to,
value: (result.itxs[itx.index] as {action:{value:string}}).action.value,
token: {
- symbol: 'TLOS',
+ symbol: useChainStore().currentChain.settings.getSystemToken().symbol,
decimals: 18,
},
}));
diff --git a/src/components/TransactionAction.vue b/src/components/TransactionAction.vue
index f6295f06c..70ba7db39 100644
--- a/src/components/TransactionAction.vue
+++ b/src/components/TransactionAction.vue
@@ -5,6 +5,7 @@ import { useI18n } from 'vue-i18n';
import MethodField from 'components/MethodField.vue';
import AddressField from 'components/AddressField.vue';
import ValueField from 'components/ValueField.vue';
+import { useChainStore } from 'src/core';
const { t: $t } = useI18n();
@@ -98,7 +99,7 @@ const setValues = async () => {
to
diff --git a/src/components/TransactionDialog.vue b/src/components/TransactionDialog.vue
index 6c9c456ba..43a5c7f1c 100644
--- a/src/components/TransactionDialog.vue
+++ b/src/components/TransactionDialog.vue
@@ -3,10 +3,11 @@ import { computed, ref } from 'vue';
import { BigNumber } from 'ethers/lib/ethers';
import { useI18n } from 'vue-i18n';
-import { truncateAddress } from 'src/antelope/wallets/utils/text-utils';
+import { truncateAddress } from 'src/core/wallets/utils/text-utils';
import { WEI_PRECISION, ZERO_ADDRESSES, formatWei } from 'src/lib/utils';
import OutlineButton from 'src/components/OutlineButton.vue';
+import { useChainStore } from 'src/core';
const $i18n = useI18n();
const $t = $i18n.t;
@@ -130,7 +131,7 @@ function formatTlos(value: string) {
{{ $t('pages.transactions.transaction_fee_label') }}:
-
{{ totalGasFee }} TLOS
+
{{ totalGasFee }} {{ useChainStore().currentChain.settings.getSystemToken().symbol }}
{{ $t('pages.transactions.gas_info_label') }}:
diff --git a/src/components/TransactionOverview.vue b/src/components/TransactionOverview.vue
index 0023b475c..52a17da10 100644
--- a/src/components/TransactionOverview.vue
+++ b/src/components/TransactionOverview.vue
@@ -3,8 +3,6 @@
import { computed, onMounted, ref, toRaw, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { BlockData, EvmTransactionExtended } from 'src/types';
-import { WEI_PRECISION } from 'src/lib/utils';
-import { indexerApi } from 'src/boot/telosApi';
import AddressField from 'components/AddressField.vue';
import BlockField from 'components/BlockField.vue';
@@ -16,6 +14,7 @@ import TransactionField from 'components/TransactionField.vue';
import TransactionFeeField from 'components/TransactionFeeField.vue';
import ERCTransferList from 'components/Transaction/ERCTransferList.vue';
import TLOSTransferList from 'components/Transaction/TLOSTransferList.vue';
+import { useChainStore } from 'src/core';
import TransactionInputViewer from 'components/Transaction/TransactionInputViewer.vue';
import { DecodedTransactionInput, getParsedInternalTransactions } from 'src/lib/transaction-utils';
@@ -43,9 +42,10 @@ const showTLOSTransfers = ref(true);
const moreDetailsHeight = ref
(0);
const loadBlockData = async () => {
+ const indexerApi = useChainStore().currentChain.settings.getIndexerApi();
try {
if (blockNumber.value) {
- const response = await indexerApi.get(`/block/${blockNumber.value}`);
+ const response = await indexerApi.get(`/v1/block/${blockNumber.value}`);
blockData.value = response.data?.results?.[0] as BlockData;
}
} catch (error) {
@@ -72,7 +72,6 @@ async function loadParsedInternalTransactions() {
watch(() => props.trx, async (newTrx) => {
if (newTrx) {
- console.log('newTrx', newTrx);
if (newTrx.to) {
toAddress.value = newTrx.to;
} else {
@@ -352,11 +351,15 @@ onMounted(() => {
- {{ $t('components.transaction.tlos_transfers_tooltip') }}
+ {{ $t('components.transaction.tlos_transfers_tooltip', {
+ symbol: useChainStore().currentChain.settings.getSystemToken().symbol,
+ }) }}
- {{ $t('components.transaction.tlos_transfers') }}
+ {{ $t('components.transaction.tlos_transfers', {
+ symbol: useChainStore().currentChain.settings.getSystemToken().symbol,
+ }) }}
{
diff --git a/src/components/TransactionTable.vue b/src/components/TransactionTable.vue
index 07c468959..504102176 100644
--- a/src/components/TransactionTable.vue
+++ b/src/components/TransactionTable.vue
@@ -6,8 +6,6 @@ import { onBeforeMount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { getDirection } from 'src/lib/transaction-utils';
-import { contractManager, indexerApi } from 'src/boot/telosApi';
-import { WEI_PRECISION } from 'src/lib/utils';
import AddressField from 'components/AddressField.vue';
import BlockField from 'components/BlockField.vue';
@@ -18,8 +16,9 @@ import TransactionDialog from 'components/TransactionDialog.vue';
import TransactionField from 'components/TransactionField.vue';
import TransactionFeeField from 'components/TransactionFeeField.vue';
-import { Pagination, PaginationByKey } from 'src/types';
+import { PaginationByKey } from 'src/types';
import { useStore } from 'vuex';
+import { useChainStore } from 'src/core';
const $q = useQuasar();
const route = useRoute();
@@ -163,7 +162,7 @@ function setPagination(page: number, size: number, desc: boolean) {
parseTransactions();
}
-async function onPaginationChange(settings: { pagination: Pagination}) {
+async function onPaginationChange(settings: { pagination: { sortBy: string; descending: boolean; page: number; rowsPerPage: number; } }) {
const { page, rowsPerPage, descending } = settings.pagination;
pagination.value.page = page;
pagination.value.rowsPerPage = rowsPerPage;
@@ -191,8 +190,8 @@ async function parseTransactions() {
try {
const path = await getPath();
- let response = await indexerApi.get(path);
- totalRows.value = response.data.total_count;
+ let response = await useChainStore().currentChain.settings.getIndexerApi().get(path);
+ totalRows.value = response.data?.total_count;
const results = response.data.results;
pagination.value.rowsPerPage = rowsPerPage;
@@ -213,13 +212,13 @@ async function parseTransactions() {
continue;
}
- const contract = await contractManager.getContract(transaction.to);
+ const contract = await useChainStore().currentChain.settings.getContractManager().getContract(transaction.to);
if (!contract) {
continue;
}
- const parsedTransaction = await contractManager.parseContractTransaction(
+ const parsedTransaction = await useChainStore().currentChain.settings.getContractManager().parseContractTransaction(
transaction, transaction.input, contract, true,
);
if (parsedTransaction) {
@@ -261,18 +260,20 @@ async function parseTransactions() {
async function getPath() {
const { page, rowsPerPage, descending } = pagination.value;
- const limit = rowsPerPage === 0 ? 50 : Math.max(Math.min(rowsPerPage, props.initialPageSize), 10);
+ const limit = rowsPerPage;
+ console.assert(limit > 0, `Rows per page must be greater than 0, got ${limit}`);
let path = '';
if (props.accountAddress) {
- path = `address/${props.accountAddress}/transactions?limit=${limit}`;
+ path = `v1/address/${props.accountAddress}/transactions?limit=${limit}`;
path += `&offset=${(page - 1) * rowsPerPage}`;
} else {
- path = `transactions?limit=${limit}`;
- if (page === 1 || pagination.value.initialKey === 0) {
- let response = await indexerApi.get('transactions?includePagination=true&limit=1');
- const firstKey = response.data.results[0]?.id || 0;
- pagination.value.initialKey = firstKey + 1;
+ path = `v1/transactions?limit=${limit}`;
+ if (pagination.value.initialKey === 0) {
+ // in the case of the first query, we need to get the initial key
+ let response = await useChainStore().currentChain.settings.getIndexerApi().get('v1/transactions?includePagination=true&key=0');
+ const next = response.data.next;
+ pagination.value.initialKey = next + 1;
}
let currentKey = pagination.value.initialKey - ((page - 1) * rowsPerPage);
if (currentKey < 0) {
@@ -330,7 +331,6 @@ onBeforeMount(() => {
-
{
@@ -515,34 +515,11 @@ onBeforeMount(() => {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -578,7 +555,7 @@ onBeforeMount(() => {
}
&__cell {
- padding: 7px 13px !important;
+ padding: 7px 9px !important;
}
}
diff --git a/src/components/ValueField.vue b/src/components/ValueField.vue
index a9f92a036..8e978c92f 100644
--- a/src/components/ValueField.vue
+++ b/src/components/ValueField.vue
@@ -1,7 +1,7 @@