Skip to content

Commit

Permalink
Antlib stores dependency now are cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterbo committed Jan 9, 2024
2 parents e1b9881 + 69ff14c commit a9164de
Show file tree
Hide file tree
Showing 103 changed files with 5,540 additions and 2,028 deletions.
2 changes: 2 additions & 0 deletions jest.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { QBtn } from 'quasar';

config.global.mocks = {
$t: str => str,
$warningNotification: jest.fn(),
};


config.global.components = {
'q-btn': QBtn,
};
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telos-web-wallet",
"version": "2.3.3",
"version": "2.4.0",
"description": "A Web Wallet for Telos",
"productName": "Telos Web Wallet",
"private": true,
Expand Down Expand Up @@ -46,7 +46,6 @@
"quasar": "2",
"rxjs": "^7.8.0",
"ual-anchor": "^1.1.2",
"ual-ledger": "^0.3.0",
"ual-oreid": "^1.0.0",
"ual-wombat": "^0.3.3",
"universal-authenticator-library": "^0.3.0",
Expand Down
17 changes: 0 additions & 17 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ export default defineComponent({
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>
Expand Down
48 changes: 42 additions & 6 deletions src/antelope/chains/EVMChainSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ import {
IndexerAccountNftsFilter,
IndexerAccountNftsResponse,
GenericIndexerNft,
IndexerNftContract,
IndexerContract,
NftRawData,
IndexerCollectionNftsResponse,
Erc721Nft,
getErc721Owner,
Erc1155Nft,
AntelopeError,
IndexerAllowanceFilter,
IndexerAllowanceResponseErc20,
IndexerAllowanceResponseErc721,
IndexerAllowanceResponseErc1155,
getErc1155OwnersFromIndexer,
} from 'src/antelope/types';
import EvmContract from 'src/antelope/stores/utils/contracts/EvmContract';
Expand Down Expand Up @@ -290,7 +294,7 @@ export default abstract class EVMChainSettings implements ChainSettings {
abstract getSystemTokens(): TokenClass[];
abstract getIndexerApiEndpoint(): string;
abstract hasIndexerSupport(): boolean;
abstract trackAnalyticsEvent(params: Record<string, unknown>): void;
abstract trackAnalyticsEvent(eventName: string): void;

async getApy(): Promise<string> {
const response = await this.api.get('apy/evm');
Expand Down Expand Up @@ -378,12 +382,12 @@ export default abstract class EVMChainSettings implements ChainSettings {
imageCache: nftResponse.imageCache,
tokenUri: nftResponse.tokenUri,
supply: nftResponse.supply,
owner: nftResponse.owner,
}));

// we fix the supportedInterfaces property if it is undefined in the response but present in the request
Object.values(response.contracts).forEach((contract) => {
contract.supportedInterfaces = contract.supportedInterfaces ||
params.type ? [params.type?.toLowerCase() as string] : undefined;
contract.supportedInterfaces = contract.supportedInterfaces || (params.type ? [params.type.toLowerCase()] : undefined);
});

this.processNftContractsCalldata(response.contracts);
Expand Down Expand Up @@ -431,7 +435,7 @@ export default abstract class EVMChainSettings implements ChainSettings {
}

// ensure NFT contract calldata is an object
processNftContractsCalldata(contracts: Record<string, IndexerNftContract>) {
processNftContractsCalldata(contracts: Record<string, IndexerContract>) {
for (const contract of Object.values(contracts)) {
try {
contract.calldata = typeof contract.calldata === 'string' ? JSON.parse(contract.calldata) : contract.calldata;
Expand All @@ -444,7 +448,7 @@ export default abstract class EVMChainSettings implements ChainSettings {
// shape the raw data from the indexer into a format that can be used to construct NFTs
shapeNftRawData(
raw: GenericIndexerNft[],
contracts: Record<string, IndexerNftContract>,
contracts: Record<string, IndexerContract>,
): NftRawData[] {
const shaped = [] as NftRawData[];
for (const item_source of raw) {
Expand Down Expand Up @@ -718,4 +722,36 @@ export default abstract class EVMChainSettings implements ChainSettings {
return response.result as EvmBlockData;
});
}

// allowances

async fetchErc20Allowances(account: string, filter: IndexerAllowanceFilter): Promise<IndexerAllowanceResponseErc20> {
const params = {
...filter,
type: 'erc20',
all: true,
};
const response = await this.indexer.get(`v1/account/${account}/approvals`, { params });
return response.data as IndexerAllowanceResponseErc20;
}

async fetchErc721Allowances(account: string, filter: IndexerAllowanceFilter): Promise<IndexerAllowanceResponseErc721> {
const params = {
...filter,
type: 'erc721',
all: true,
};
const response = await this.indexer.get(`v1/account/${account}/approvals`, { params });
return response.data as IndexerAllowanceResponseErc721;
}

async fetchErc1155Allowances(account: string, filter: IndexerAllowanceFilter): Promise<IndexerAllowanceResponseErc1155> {
const params = {
...filter,
type: 'erc1155',
all: true,
};
const response = await this.indexer.get(`v1/account/${account}/approvals`, { params });
return response.data as IndexerAllowanceResponseErc1155;
}
}
2 changes: 1 addition & 1 deletion src/antelope/chains/NativeChainSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default abstract class NativeChainSettings implements ChainSettings {
abstract getMapDisplay(): boolean;
abstract getTheme(): Theme;
abstract getFiltersSupported(prop: string): boolean;
abstract trackAnalyticsEvent(params: Record<string, unknown>): void;
abstract trackAnalyticsEvent(eventName: string): void;

/**
* Retrieves the list of IDs for the important tokens.
Expand Down
26 changes: 15 additions & 11 deletions src/antelope/chains/chain-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import { NETWORK as telosTestnetEvmNetwork } from 'src/antelope/chains/evm/telos

export const TELOS_CHAIN_IDS = ['40', '41'];
export const TELOS_NETWORK_NAMES = [telosEvmNetwork, telosTestnetEvmNetwork];
export const TELOS_ANALYTICS_EVENT_IDS = {
loginStarted: 'JXIYBP1S',
loginSuccessful: 'HIP11SFR',
loginSuccessfulMetamask: 'ABGMND23',
loginFailedMetamask: 'ZFGE6TFS',
loginSuccessfulSafepal: 'LKCBKDU2',
loginFailedSafepal: '6PSIWGNV',
loginSuccessfulOreId: 'MSXMDDNK',
loginFailedOreId: 'UFX3JYRJ',
loginFailedWalletConnect: '9V4IV1BV',
loginSuccessfulWalletConnect: '2EG2OR3H',
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',
};

export const ZERO_ADDRESS = '0x'.concat('0'.repeat(40));
11 changes: 5 additions & 6 deletions src/antelope/chains/evm/telos-evm-testnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const NETWORK_EVM_ENDPOINT = 'https://testnet.telos.net';
const INDEXER_ENDPOINT = 'https://api.testnet.teloscan.io';
const CONTRACTS_BUCKET = 'https://verified-evm-contracts-testnet.s3.amazonaws.com';

declare const fathom: { trackGoal: (eventId: string, value: 0) => void };
declare const fathom: { trackEvent: (eventName: string) => void };

export default class TelosEVMTestnet extends EVMChainSettings {
isTestnet() {
Expand Down Expand Up @@ -149,7 +149,7 @@ export default class TelosEVMTestnet extends EVMChainSettings {
}

getBuyMoreOfTokenLink(): string {
return 'https://www.telos.net/#buy-tlos-simplex';
return 'https://telos.net/ecosystem?category=Exchanges';
}

getSystemTokens(): TokenClass[] {
Expand All @@ -164,13 +164,12 @@ export default class TelosEVMTestnet extends EVMChainSettings {
return true;
}

trackAnalyticsEvent(params: Record<string, unknown>): void {
trackAnalyticsEvent(eventName: string): void {
if (typeof fathom === 'undefined') {
console.warn(`Failed to track event with ID ${params.id}: Fathom Analytics not loaded`);
console.warn(`Failed to track event with name '${eventName}': Fathom Analytics not loaded`);
return;
}

const id = params.id as string;
fathom.trackGoal(id, 0);
fathom.trackEvent(eventName);
}
}
11 changes: 5 additions & 6 deletions src/antelope/chains/evm/telos-evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const NETWORK_EVM_ENDPOINT = 'https://mainnet.telos.net';
const INDEXER_ENDPOINT = 'https://api.teloscan.io';
const CONTRACTS_BUCKET = 'https://verified-evm-contracts.s3.amazonaws.com';

declare const fathom: { trackGoal: (eventId: string, value: 0) => void };
declare const fathom: { trackEvent: (eventName: string) => void };

export default class TelosEVMTestnet extends EVMChainSettings {
getNetwork(): string {
Expand Down Expand Up @@ -145,7 +145,7 @@ export default class TelosEVMTestnet extends EVMChainSettings {
}

getBuyMoreOfTokenLink(): string {
return 'https://www.telos.net/#buy-tlos-simplex';
return 'https://telos.net/ecosystem?category=Exchanges';
}

getSystemTokens(): TokenClass[] {
Expand All @@ -160,13 +160,12 @@ export default class TelosEVMTestnet extends EVMChainSettings {
return true;
}

trackAnalyticsEvent(params: Record<string, unknown>): void {
trackAnalyticsEvent(eventName: string): void {
if (typeof fathom === 'undefined') {
console.warn(`Failed to track event with ID ${params.id}: Fathom Analytics not loaded`);
console.warn(`Failed to track event with name '${eventName}': Fathom Analytics not loaded`);
return;
}

const id = params.id as string;
fathom.trackGoal(id, 0);
fathom.trackEvent(eventName);
}
}
15 changes: 13 additions & 2 deletions src/antelope/config/AntelopeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class AntelopeConfig {
private __notify_success_copy_handler: () => void = alert;
private __notify_failure_message_handler: (message: string, payload?: AntelopeErrorPayload) => void = alert;
private __notify_failure_action_handler: (message: string, payload?: AntelopeErrorPayload) => void = alert;
private __notify_warning_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);
Expand Down Expand Up @@ -116,13 +117,14 @@ export class AntelopeConfig {
// Vue.App holder --
private __app: App | null = null;

constructor(public debug: AntelopeDebug) {
constructor(
public debug: AntelopeDebug,
) {
//
}

init(app: App) {
this.__app = app;
this.debug.init();
}

get app() {
Expand Down Expand Up @@ -169,6 +171,10 @@ export class AntelopeConfig {
return this.__notify_failure_action_handler;
}

get notifyWarningWithAction() {
return this.__notify_warning_action_handler;
}

get notifyDisconnectedHandler() {
return this.__notify_disconnected_handler;
}
Expand Down Expand Up @@ -239,6 +245,10 @@ export class AntelopeConfig {
this.__notify_failure_action_handler = handler;
}

public setNotifyWarningWithAction(handler: (message: string, payload?: AntelopeErrorPayload) => void) {
this.__notify_warning_action_handler = handler;
}

public setNotifyDisconnectedHandler(handler: () => void) {
this.__notify_disconnected_handler = handler;
}
Expand Down Expand Up @@ -277,3 +287,4 @@ export class AntelopeConfig {
}

}

Loading

0 comments on commit a9164de

Please sign in to comment.