Skip to content

Commit

Permalink
pull from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterbo committed Nov 30, 2023
1 parent c54a0c8 commit 02f9eec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import { getAntelope, useChainStore } from 'src/antelope';
import { ComplexMessage } from 'src/antelope/config';
import EVMChainSettings from 'src/antelope/chains/EVMChainSettings';
import { TELOS_CHAIN_IDS } from 'src/antelope/chains/chain-constants';
import packageInfo from '../package.json';
Expand Down
38 changes: 28 additions & 10 deletions src/antelope/config/AntelopeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ import { getAntelope } from 'src/antelope';
import { AntelopeError, AntelopeErrorPayload } from 'src/antelope/types';
import { AntelopeDebug } from 'src/antelope/config/AntelopeDebug';


export const chainNetworkNames: Record<string, string> = {
telos: 'telos-evm',
'telos-testnet': 'telos-evm-testnet',
};

export const errorToString = (error: unknown) =>
getAntelope().config.errorToStringHandler(error);

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

export class AntelopeConfig {
transactionError(description: string, error: unknown): AntelopeError {
Expand All @@ -34,7 +30,7 @@ export class AntelopeConfig {
// indexer health check interval --
private __indexer_health_check_interval = 1000 * 60 * 5; // 5 minutes expressed in milliseconds

// notification handlers --
// notifucation handlers --
private __notify_error_handler: (message: string) => void = m => alert(`Error: ${m}`);
private __notify_success_handler: (message: string) => void = alert;
private __notify_warning_handler: (message: string) => void = alert;
Expand All @@ -47,6 +43,7 @@ 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 @@ -171,6 +168,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 @@ -237,6 +238,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 @@ -256,5 +266,13 @@ export class AntelopeConfig {
public setErrorToStringHandler(handler: (catched: unknown) => string) {
this.__error_to_string_handler = handler;
}

}

export const errorToString = (error: unknown) =>
getAntelope().config.errorToStringHandler(error);

export const chainNetworkNames: Record<string, string> = {
telos: 'telos-evm',
'telos-testnet': 'telos-evm-testnet',
};
2 changes: 1 addition & 1 deletion src/antelope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { App, toRaw } from 'vue';
import { BehaviorSubject, Subject } from 'rxjs';
import { Store } from 'pinia';

import { AntelopeConfig, AntelopeDebug, chainNetworkNames } from 'src/antelope/config/';
import { AntelopeConfig, AntelopeDebug, chainNetworkNames } from 'src/antelope/config';
import installPinia from 'src/antelope/stores';

import { AccountModel } from 'src/antelope/stores/account';
Expand Down

0 comments on commit 02f9eec

Please sign in to comment.