Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
"bip39": "^3.1.0",
"bitcoinjs-lib": "^6.1.7",
"bs58": "^6.0.0",
"chronik-client": "^4.1.0",
"concurrently": "^9.2.1",
"ecash-lib": "^4.7.0",
"ecash-wallet": "^5.1.0",
"echarts": "^6.0.0",
"ethereum-cryptography": "^2.2.1",
"ethereumjs-abi": "^0.6.8",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import ActivityState from '.';
import { ActivityHandlerType } from './types';
const CACHE_TTL = 1000 * 60 * 5; // 5 mins

const CACHE_TTL = 1000 * 60 * 5;
const ECASH_CACHE_TTL = 1000 * 3;

export default (activityHandler: ActivityHandlerType): ActivityHandlerType => {
const returnFunction: ActivityHandlerType = async (network, address) => {
const activityState = new ActivityState();

const options = {
address: address,
network: network.name,
};

// Use shorter cache TTL for eCash due to faster finality
const isECash = network.name === 'XEC' || network.name === 'XECTest';
const cacheTTL = isECash ? ECASH_CACHE_TTL : CACHE_TTL;

const [activities, cacheTime] = await Promise.all([
activityState.getAllActivities(options),
activityState.getCacheTime(options),
]);
if (cacheTime + CACHE_TTL < new Date().getTime()) {

if (cacheTime + cacheTTL < new Date().getTime()) {
const liveActivities = await activityHandler(network, address);
if (!activities.length) {
await activityState.addActivities(liveActivities, options);
Expand Down
13 changes: 13 additions & 0 deletions packages/extension/src/libs/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
sendToTab,
newAccount,
lock,
ecashSign,
} from './internal';
import { handlePersistentEvents } from './external';
import SettingsState from '../settings-state';
Expand All @@ -51,6 +52,7 @@ class BackgroundHandler {
[ProviderName.kadena]: {},
[ProviderName.solana]: {},
[ProviderName.massa]: {},
[ProviderName.ecash]: {},
};
this.#providers = Providers;
this.#geoRestricted = undefined;
Expand Down Expand Up @@ -106,6 +108,15 @@ class BackgroundHandler {
error: JSON.stringify(getCustomError('Enkrypt: not implemented')),
};
}
if (_provider === ProviderName.ecash) {
return {
error: JSON.stringify(
getCustomError(
'Enkrypt: eCash does not support external requests in this wallet',
),
),
};
}
if (this.#geoRestricted !== undefined && this.#geoRestricted) {
return {
error: JSON.stringify(
Expand Down Expand Up @@ -186,6 +197,8 @@ class BackgroundHandler {
case InternalMethods.getNewAccount:
case InternalMethods.saveNewAccount:
return newAccount(this.#keyring, message);
case InternalMethods.ecashSign:
return ecashSign(this.#keyring, message);
default:
return Promise.resolve({
error: getCustomError(
Expand Down
Loading