Skip to content

Commit

Permalink
Merge pull request #464 from telosnetwork/dev
Browse files Browse the repository at this point in the history
v1.4.5-rc
  • Loading branch information
pmjanus authored Oct 26, 2023
2 parents 236309d + dd8a5d2 commit e3cf004
Show file tree
Hide file tree
Showing 104 changed files with 11,157 additions and 3,355 deletions.
33 changes: 7 additions & 26 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
module.exports = {
root: true,
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@babel/eslint-parser',
ecmaVersion: 2018,
extraFileExtensions: ['.vue'],
parser: '@typescript-eslint/parser',
sourceType: 'module',
},
env: {
'browser': true,
'es2021': true,
'amd': true,
'node': true,
'vue/setup-compiler-macros': true,
'jest/globals': true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vue/vue3-essential',
'eslint:recommended',
],
plugins: [
'@typescript-eslint',
'vue',
'jest',
],
Expand Down Expand Up @@ -105,27 +109,4 @@ module.exports = {
'vue/component-definition-name-casing': ['error', 'PascalCase'],
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
},
overrides:[
{
'files': ['**/*.ts', '**/*.tsx', '**/*/.vue'],
'env': { 'browser': true, 'es6': true, 'node': true },
'extends': [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vue/vue3-essential',
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaFeatures': { 'jsx': true },
'ecmaVersion': 2018,
'sourceType': 'module',
'project': './tsconfig.json',
},
'plugins': ['vue', '@typescript-eslint'],
'rules': {
'@typescript-eslint/no-explicit-any': 1,
},
},
],
};
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module.exports = {
presets: [
'@quasar/babel-preset-app',
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};
9 changes: 9 additions & 0 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const sharedEnv = {
NETWORK_PROTOCOL: 'https',
NETWORK_PORT: 443,
NETWORK_EVM_CONTRACT: 'eosio.evm',
PROJECT_ID: '14ec76c44bae7d461fa0f5fd5f8a9da1',
};

const TESTNET = {
Expand All @@ -19,12 +20,16 @@ const TESTNET = {
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
VERIFIED_CONTRACTS_BUCKET: 'verified-evm-contracts-testnet',
STAKED_TLOS_CONTRACT_ADDRESS: '0xa9991E4daA44922D00a78B6D986cDf628d46C4DD',
TELOS_ESCROW_CONTRACT_ADDRESS: '0x7E9cF9fBc881652B05BB8F26298fFAB538163b6f',
OREID_APP_ID: 't_1e0417d2456e401893ec106e5e4c6314',
OREID_APP_ID_NATIVE: 't_a61e9926d5204387a9ac113dfce7cbc5',
};

const MAINNET = {
Expand All @@ -36,12 +41,16 @@ const MAINNET = {
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
VERIFIED_CONTRACTS_BUCKET: 'verified-evm-contracts',
STAKED_TLOS_CONTRACT_ADDRESS: '0xB4B01216a5Bc8F1C8A33CD990A1239030E60C905',
TELOS_ESCROW_CONTRACT_ADDRESS: '0x95F5713A1422Aa3FBD3DCB8D553945C128ee3855',
OREID_APP_ID: 'p_b5cfbadeb17a44bdaf01e73b3120d202',
OREID_APP_ID_NATIVE: 'p_751f87258d5b40998b55c626d612fd4e',
};

const env = process.env.NETWORK === 'mainnet' ? MAINNET : TESTNET;
Expand Down
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

module.exports = {
preset: 'ts-jest/presets/js-with-ts',
rootDir: './',
moduleNameMapper: {
'^src(.*)$': '<rootDir>/src$1',
Expand All @@ -12,8 +13,9 @@ module.exports = {
'^store(.*)$': '<rootDir>/src/store$1',
'^test(.*)$': '<rootDir>/test$1',
},
moduleFileExtensions: ['js', 'vue'],
moduleFileExtensions: ['js', 'ts', 'vue'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': '@vue/vue3-jest',
'^.+\\.svg$': '<rootDir>/test/__mocks__/svg.mocks.js',
Expand Down
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telos-template",
"version": "1.4.4",
"name": "teloscan",
"version": "1.4.5",
"description": "Teloscan block explorer",
"productName": "Teloscan",
"author": "Jesse Schulman <jesse@caleos.io>",
Expand All @@ -18,12 +18,16 @@
"@metamask/detect-provider": "^2.0.0",
"@quasar/extras": "^1.0.0",
"@telosnetwork/telosevm-js": "^0.2.6",
"@wagmi/core": "^1.3.7",
"@web3modal/ethereum": "2.7.0",
"@web3modal/html": "2.7.0",
"axios": "^0.21.2",
"axios-time": "^1.0.0",
"babel-loader": "^8.1.0",
"big.js": "^6.2.1",
"bn.js": "^5.2.0",
"core-js": "^3.6.5",
"date-fns": "^2.29.3",
"dotenv": "^8.2.0",
"eosjs": "^21.0.3",
"eosjs-ecc": "^4.0.7",
Expand All @@ -34,6 +38,8 @@
"highlight.js": "10",
"highlightjs-solidity": "^2.0.3",
"moment": "^2.29.4",
"oreid-js": "^4.7.1",
"oreid-webpopup": "^2.4.0",
"quasar": "2",
"ual-anchor": "^1.0.0",
"ual-ledger": "^0.3.0",
Expand All @@ -51,6 +57,7 @@
"@babel/core": "7.19.3",
"@babel/eslint-parser": "^7.13.14",
"@babel/preset-env": "7.19.3",
"@babel/preset-typescript": "^7.23.0",
"@quasar/app-webpack": "3.6.2",
"@types/jest": "29.1.1",
"@types/lodash": "^4.14.182",
Expand All @@ -63,10 +70,11 @@
"eslint-plugin-jest": "27.1.0",
"eslint-plugin-vue": "^9.0.0",
"eslint-webpack-plugin": "^2.4.0",
"jest": "29.1.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "29.1.2",
"jest-serializer-vue": "^2.0.2",
"node-polyfill-webpack-plugin": "^2.0.1"
"node-polyfill-webpack-plugin": "^2.0.1",
"ts-jest": "^29.1.1"
},
"browserslist": [
"last 10 Chrome versions",
Expand Down
3 changes: 2 additions & 1 deletion quasar.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/*
* This file runs in a Node context (it's NOT transpiled by Babel), so use only
* the ES6 features that are supported by your Node version. https://node.green/
Expand Down Expand Up @@ -30,7 +31,7 @@ module.exports = function(/* ctx */) {
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/boot-files
boot: ['ual', 'hyperion', 'i18n', 'api', 'telosApi', 'evm', 'q-component-defaults'],
boot: ['ual', 'hyperion', 'i18n', 'api', 'telosApi', 'evm', 'q-component-defaults', 'antelope'],

// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
css: ['fonts/silka/silka.css', 'app.sass'],
Expand Down
7 changes: 7 additions & 0 deletions src/antelope/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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';
52 changes: 52 additions & 0 deletions src/antelope/mocks/AccountStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Mocking AccountStore -----------------------------------
// useAccountStore().getAccount(this.label).account as addressString;
import { EVMAuthenticator } from 'src/antelope/wallets';
import { addressString } from 'src/antelope/types';
import { CURRENT_CONTEXT } from 'src/antelope/mocks';

export interface AccountModel {
label: typeof CURRENT_CONTEXT;
isNative: boolean;
authenticator: EVMAuthenticator;
account: addressString;
}

let currentAuthenticator = {} as EVMAuthenticator;
let currentAccount = null as addressString | null;

interface LoginEVMActionData {
authenticator: EVMAuthenticator
network: string,
}

const AccountStore = {
getAccount: (label: string) => ({
label,
isNative: false,
authenticator: currentAuthenticator,
account: currentAccount,
} as AccountModel),

async loginEVM({ authenticator, network }: LoginEVMActionData): Promise<boolean> {
currentAuthenticator = authenticator;
currentAccount = await authenticator.login(network);
return true;
},

logout() {
console.log('AccountStore.logout()');
currentAuthenticator.logout();
currentAuthenticator = {} as EVMAuthenticator;
currentAccount = null;
},

get loggedAccount() {
return this.getAccount(CURRENT_CONTEXT);
},

get currentAccount() {
return this.getAccount(CURRENT_CONTEXT);
},
};

export const useAccountStore = () => AccountStore;
34 changes: 34 additions & 0 deletions src/antelope/mocks/AntelopeConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
// Mocking Antelope and Config -----------------------------------
import { EVMAuthenticator } from 'src/antelope/wallets/authenticators/EVMAuthenticator';

export class AntelopeWallets {
private authenticators: Map<string, EVMAuthenticator> = new Map();
init() {
// dummie function
}
addEVMAuthenticator(authenticator: EVMAuthenticator) {
this.authenticators.set(authenticator.getName(), authenticator);
}
getAuthenticator(name: string) {
return this.authenticators.get(name);
}
}

const config = {
notifyNeutralMessageHandler: (message: string) => void 0,
localizationHandler: (message: string, params?: Record<string, string>) => message,
notifyFailureWithActionHandler: (message: string, action: () => void) => void 0,
notifyFailureWithAction: (message: string, params?: { label: string; handler: () => void; }) => void 0,
};

const wallets = new AntelopeWallets();
const Antelope = {
config,
wallets,
};

export const getAntelope = () => Antelope;
// ----------------------------------------------------------------

82 changes: 82 additions & 0 deletions src/antelope/mocks/ChainStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
// Mocking ChainStore -----------------------------------

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: (o: {id: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: () => void 0,
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: () => process.env.NETWORK_EXPLORER,
getSmallLogoPath: () => 'small-icon-url',
getLargeLogoPath: () => 'large-icon-url',
} as EVMChainSettings;

const currentChain = {
settings,
};

const loggedChain = {
settings,
};

const ChainStore = {
currentChain,
loggedChain,
getNetworkSettings: (network: string) => settings,
getChain: (label: string) => currentChain,
setChain: (context: string, network: string) => void 0,
};

export const useChainStore = () => ChainStore;
17 changes: 17 additions & 0 deletions src/antelope/mocks/ContractStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable max-len */

import { EvmABI, erc1155Abi, erc20Abi, erc721Abi } from 'src/antelope/types';

// Mocking ContractStore -----------------------------------
const ContractStore = {
getTokenABI(type:string): EvmABI {
if(type === 'erc721'){
return erc721Abi;
} else if(type === 'erc1155'){
return erc1155Abi;
}
return erc20Abi;
},
};

export const useContractStore = () => ContractStore;
Loading

0 comments on commit e3cf004

Please sign in to comment.