Skip to content

Commit

Permalink
Merge branch 'indexer-api' of https://github.com/telosnetwork/teloscan
Browse files Browse the repository at this point in the history
…into indexer-api
  • Loading branch information
tomtomcrypto committed Jan 30, 2024
2 parents f457229 + 5109686 commit fec73a6
Show file tree
Hide file tree
Showing 44 changed files with 6,745 additions and 709 deletions.
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
publish = "dist/spa"

[context.environment]
NODE_VERSION = "14"
NODE_VERSION = "16"

[[redirects]]
from = "/*"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"oreid-js": "^4.7.1",
"oreid-webpopup": "^2.4.0",
"quasar": "2",
"rxjs": "^7.8.0",
"ual-anchor": "^1.0.0",
"ual-ledger": "^0.3.0",
"ual-wombat": "^0.3.3",
"universal-authenticator-library": "^0.3.0",
"vue": "3",
Expand Down
File renamed without changes
Binary file added public/branding/favicon-16x16.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/branding/favicon-32x32.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/branding/favicon.ico
Binary file not shown.
Binary file added public/branding/stlos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6,262 changes: 6,262 additions & 0 deletions public/branding/telos-bridge-logo.svg
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/branding/telos-circle-logo.svg
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/branding/telos-logo-dark.svg
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/branding/telos-logo.svg
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/branding/telos-scan.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 modified public/favicon.ico
Binary file not shown.
10 changes: 5 additions & 5 deletions quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,27 +139,27 @@ module.exports = function(/* ctx */) {
theme_color: '#027be3',
icons: [
{
src: 'icons/icon-128x128.png',
src: 'branding/telos-scan.png',
sizes: '128x128',
type: 'image/png',
},
{
src: 'icons/icon-192x192.png',
src: 'branding/telos-scan.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'icons/icon-256x256.png',
src: 'branding/telos-scan.png',
sizes: '256x256',
type: 'image/png',
},
{
src: 'icons/icon-384x384.png',
src: 'branding/telos-scan.png',
sizes: '384x384',
type: 'image/png',
},
{
src: 'icons/icon-512x512.png',
src: 'branding/telos-scan.png',
sizes: '512x512',
type: 'image/png',
},
Expand Down
41 changes: 38 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
<script>
export default {
<script lang="ts">
import { defineComponent } from 'vue';
import { getAntelope, useChainStore } from 'src/antelope';
import { TELOS_NETWORK_NAMES } from 'src/antelope/mocks/chain-constants';
export const isTodayBeforeTelosCloudDown = new Date().getTime() < new Date('2023-12-31').getTime();
export default defineComponent({
name: 'App',
};
mounted() {
const network = useChainStore().currentChain.settings.getNetwork();
if (TELOS_NETWORK_NAMES.includes(network)) {
const script = document.createElement('script');
script.src = 'https://cdn.usefathom.com/script.js';
script.dataset.site = 'PDKJSBKL';
script.dataset.spa = 'auto';
script.defer = true;
document.body.appendChild(script);
}
if (isTodayBeforeTelosCloudDown) {
getAntelope().config.notifyRememberInfoHandler(
this.$t('temporal.telos_cloud_discontinued_title'),
[{
tag: 'p',
class: 'c-notify__message--subtitle',
text: this.$t('temporal.telos_cloud_discontinued_message_title'),
}, {
tag: 'p',
class: '',
text: this.$t('temporal.telos_cloud_discontinued_message_body'),
}],
'',
'telos-cloud-discontinued',
);
}
},
});
</script>
<template>
<div id="q-app">
Expand Down
7 changes: 5 additions & 2 deletions src/antelope/mocks/AccountStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class AccountStore {
} as AccountModel;
}

async loginEVM({ authenticator, network }: LoginEVMActionData): Promise<boolean> {
async loginEVM({ authenticator, network }: LoginEVMActionData, trackAnalyticsEvents: boolean): Promise<boolean> {
currentAuthenticator = authenticator;
currentAccount = await authenticator.login(network);
currentAccount = await authenticator.login(network, trackAnalyticsEvents);
const account = useAccountStore().getAccount(authenticator.label);
getAntelope().events.onLoggedIn.next(account);
return true;
}

Expand All @@ -62,6 +64,7 @@ class AccountStore {
currentAuthenticator.logout();
currentAuthenticator = {} as EVMAuthenticator;
currentAccount = null;
getAntelope().events.onLoggedOut.next();
}

get loggedAccount() {
Expand Down
28 changes: 28 additions & 0 deletions src/antelope/mocks/AntelopeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import { EVMAuthenticator } from 'src/antelope/wallets/authenticators/EVMAuthent
import { AntelopeError, AntelopeErrorPayload } from 'src/antelope/types';
import { App } from 'vue';
import { Authenticator } from 'universal-authenticator-library';
import { Subject } from 'rxjs';
import { AccountModel } from 'src/antelope/mocks/AccountStore';

export interface ComplexMessage {
tag: string,
class: string,
text: string,
}

export class AntelopeWallets {
private authenticators: Map<string, EVMAuthenticator> = new Map();
Expand Down Expand Up @@ -52,6 +60,8 @@ export class AntelopeConfig {
private __notify_failure_action_handler: (message: string, payload?: AntelopeErrorPayload) => void = alert;
private __notify_disconnected_handler: () => void = alert;
private __notify_neutral_message_handler: (message: string) => (() => void) = () => (() => void 0);
private __notify_remember_info_handler: (title: string, message: string | ComplexMessage[],
payload: string, key: string) => (() => void) = () => (() => void 0);

// ual authenticators list getter --
private __authenticators_getter: () => Authenticator[] = () => [];
Expand Down Expand Up @@ -175,6 +185,10 @@ export class AntelopeConfig {
return this.__notify_neutral_message_handler;
}

get notifyRememberInfoHandler() {
return this.__notify_remember_info_handler;
}

get authenticatorsGetter() {
return this.__authenticators_getter;
}
Expand Down Expand Up @@ -241,6 +255,15 @@ export class AntelopeConfig {
this.__notify_neutral_message_handler = handler;
}

public setNotifyRememberInfoHandler(handler: (
title: string,
message: string | ComplexMessage[],
payload: string,
key: string,
) => (() => void)) {
this.__notify_remember_info_handler = handler;
}

// setting authenticators getter --
public setAuthenticatorsGetter(getter: () => Authenticator[]) {
this.__authenticators_getter = getter;
Expand All @@ -265,9 +288,14 @@ export class AntelopeConfig {

const config = new AntelopeConfig();
const wallets = new AntelopeWallets();
const events = {
onLoggedIn: new Subject<AccountModel>(),
onLoggedOut: new Subject<void>(),
};
const Antelope = {
config,
wallets,
events,
};

export const getAntelope = () => Antelope;
Expand Down
12 changes: 10 additions & 2 deletions src/antelope/mocks/ChainStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* 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';
Expand All @@ -10,7 +11,7 @@ export interface EVMChainSettings {
getWrappedSystemToken: () => TokenClass;
getChainId: () => string;
getDisplay: () => string;
trackAnalyticsEvent: (o: {id:string}) => void;
trackAnalyticsEvent: (name: string) => void;
getRPCEndpoint: () => RpcEndpoint;
getEscrowContractAddress: () => string;
getNetwork: () => string;
Expand All @@ -23,7 +24,14 @@ export interface EVMChainSettings {
const settings = {
getChainId: () => process.env.NETWORK_EVM_CHAIN_ID,
getDisplay: () => process.env.NETWORK_EVM_DISPLAY,
trackAnalyticsEvent: () => void 0,
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+))?(\/.*)?$/;
Expand Down
2 changes: 1 addition & 1 deletion src/antelope/mocks/EVMStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class EVMStore {
if (!authenticator) {
console.error('Inconsistency: logged account authenticator is null', authenticator);
} else {
useAccountStore().loginEVM({ authenticator, network });
useAccountStore().loginEVM({ authenticator, network }, false);
}
}
} else {
Expand Down
24 changes: 13 additions & 11 deletions src/antelope/mocks/chain-constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export const TELOS_CHAIN_IDS = ['40', '41'];
export const TELOS_NETWORK_NAMES = ['telos-evm', 'telos-evm-testnet'];
export const TELOS_ANALYTICS_EVENT_IDS = {
loginStarted: 'GXQ8FOAU',
loginSuccessful: 'B1BZBK5R',
loginSuccessfulMetamask: 'JQTSKEFY',
loginFailedMetamask: 'PKHBRTYV',
loginSuccessfulSafepal: 'WV5OSVMQ',
loginFailedSafepal: '7WSBR8LA',
loginSuccessfulOreId: 'HUDIQQEK',
loginFailedOreId: 'AJXWOXWJ',
loginFailedWalletConnect: 'ZVKXJDK1',
loginSuccessfulWalletConnect: 'AQMOMICF',
export const TELOS_ANALYTICS_EVENT_NAMES = {
loginStarted: 'Login Started',
loginSuccessful: 'Login Successful',
loginSuccessfulMetamask: 'Login Successful - Metamask',
loginFailedMetamask: 'Login Failed - Metamask',
loginSuccessfulSafepal: 'Login Successful - Safepal',
loginFailedSafepal: 'Login Failed - Safepal',
loginSuccessfulOreId: 'Login Successful - OreId',
loginFailedOreId: 'Login Failed - OreId',
loginFailedWalletConnect: 'Login Failed - WalletConnect',
loginSuccessfulWalletConnect: 'Login Successful - WalletConnect',
loginSuccessfulBrave: 'Login Successful - Brave',
loginFailedBrave: 'Login Failed - Brave',
};
4 changes: 3 additions & 1 deletion src/antelope/wallets/authenticators/EVMAuthenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export abstract class EVMAuthenticator {
return (useChainStore().getChain(this.label).settings as EVMChainSettings);
}

async login(network: string): Promise<addressString | null> {
async login(network: string, trackAnalyticsEvents?: boolean): Promise<addressString | null> {
this.trace('login', network);
this.trace('Login analytics enabled =', trackAnalyticsEvents);

const chain = useChainStore();
try {
chain.setChain(CURRENT_CONTEXT, network);
Expand Down
61 changes: 30 additions & 31 deletions src/antelope/wallets/authenticators/InjectedProviderAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import {
wtlosAbiDeposit,
wtlosAbiWithdraw,
} from 'src/antelope/types';
import { EVMAuthenticator } from 'src/antelope/wallets';
import { MetamaskAuthName, SafePalAuthName } from 'src/antelope/wallets';
import { TELOS_ANALYTICS_EVENT_IDS, TELOS_NETWORK_NAMES } from 'src/antelope/mocks/chain-constants';
import { BraveAuthName, EVMAuthenticator, MetamaskAuthName, SafePalAuthName } from 'src/antelope/wallets';
import { TELOS_ANALYTICS_EVENT_NAMES, TELOS_NETWORK_NAMES } from 'src/antelope/mocks/chain-constants';

export abstract class InjectedProviderAuth extends EVMAuthenticator {
onReady = new BehaviorSubject<boolean>(false);
Expand Down Expand Up @@ -132,61 +131,61 @@ export abstract class InjectedProviderAuth extends EVMAuthenticator {
});
}

async login(network: string): Promise<addressString | null> {
async login(network: string, trackAnalyticsEvents?: boolean): Promise<addressString | null> {
const chainSettings = this.getChainSettings();
const authName = this.getName();
const isTelos = TELOS_NETWORK_NAMES.includes(network);

this.trace('login', network);
useFeedbackStore().setLoading(`${this.getName()}.login`);

this.trace('login', 'trackAnalyticsEvent -> login started');
chainSettings.trackAnalyticsEvent(
{ id: TELOS_ANALYTICS_EVENT_IDS.loginStarted },
);
if (isTelos && trackAnalyticsEvents) {
this.trace('login', 'trackAnalyticsEvent -> login started');
chainSettings.trackAnalyticsEvent(TELOS_ANALYTICS_EVENT_NAMES.loginStarted);
}

const response = await super.login(network).then((res) => {
if (TELOS_NETWORK_NAMES.includes(network)) {
let successfulLoginEventId = '';
const response = await super.login(network, trackAnalyticsEvents).then((res) => {
if (isTelos && trackAnalyticsEvents && TELOS_NETWORK_NAMES.includes(network)) {
let successfulLoginEventName = '';

if (authName === MetamaskAuthName) {
successfulLoginEventId = TELOS_ANALYTICS_EVENT_IDS.loginSuccessfulMetamask;
successfulLoginEventName = TELOS_ANALYTICS_EVENT_NAMES.loginSuccessfulMetamask;
} else if (authName === SafePalAuthName) {
successfulLoginEventId = TELOS_ANALYTICS_EVENT_IDS.loginSuccessfulSafepal;
successfulLoginEventName = TELOS_ANALYTICS_EVENT_NAMES.loginSuccessfulSafepal;
} else if (authName === BraveAuthName) {
successfulLoginEventName = TELOS_ANALYTICS_EVENT_NAMES.loginSuccessfulBrave;
}

if (successfulLoginEventId) {
this.trace('login', 'trackAnalyticsEvent -> login succeeded', authName, successfulLoginEventId);
chainSettings.trackAnalyticsEvent(
{ id: successfulLoginEventId },
);
if (successfulLoginEventName) {
this.trace('login', 'trackAnalyticsEvent -> login succeeded', authName, successfulLoginEventName);
chainSettings.trackAnalyticsEvent(successfulLoginEventName);
}

this.trace('login', 'trackAnalyticsEvent -> generic login succeeded', TELOS_ANALYTICS_EVENT_IDS.loginSuccessful);
chainSettings.trackAnalyticsEvent(
{ id: TELOS_ANALYTICS_EVENT_IDS.loginSuccessful },
);
this.trace('login', 'trackAnalyticsEvent -> generic login succeeded', TELOS_ANALYTICS_EVENT_NAMES.loginSuccessful);
chainSettings.trackAnalyticsEvent(TELOS_ANALYTICS_EVENT_NAMES.loginSuccessful);
}

return res;
}).catch((error) => {
// if the user rejects the connection, we don't want to track it as an error
if (
TELOS_NETWORK_NAMES.includes(network) &&
trackAnalyticsEvents &&
isTelos &&
error.message !== 'antelope.evm.error_connect_rejected'
) {
let failedLoginEventId = '';
let failedLoginEventName = '';

if (authName === MetamaskAuthName) {
failedLoginEventId = TELOS_ANALYTICS_EVENT_IDS.loginFailedMetamask;
failedLoginEventName = TELOS_ANALYTICS_EVENT_NAMES.loginFailedMetamask;
} else if (authName === SafePalAuthName) {
failedLoginEventId = TELOS_ANALYTICS_EVENT_IDS.loginFailedSafepal;
failedLoginEventName = TELOS_ANALYTICS_EVENT_NAMES.loginFailedSafepal;
} else if (authName === BraveAuthName) {
failedLoginEventName = TELOS_ANALYTICS_EVENT_NAMES.loginFailedBrave;
}

if (failedLoginEventId) {
this.trace('login', 'trackAnalyticsEvent -> login failed', authName, failedLoginEventId);
chainSettings.trackAnalyticsEvent(
{ id: failedLoginEventId },
);
if (failedLoginEventName) {
this.trace('login', 'trackAnalyticsEvent -> login failed', authName, failedLoginEventName);
chainSettings.trackAnalyticsEvent(failedLoginEventName);
}
}
}).finally(() => {
Expand Down
Loading

0 comments on commit fec73a6

Please sign in to comment.