Skip to content

Commit

Permalink
Merge branch 'main' into feat/safari-support
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Mar 11, 2025
2 parents 3a4d6c1 + 88b1888 commit 2fab90b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enkryptcom/extension",
"version": "2.4.2",
"version": "2.4.3",
"private": true,
"type": "module",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import { ProviderRPCRequest } from '@/types/provider';
import { WindowPromise } from '@/libs/window-promise';
import AccountState from '../libs/accounts-state';
import { getCustomError } from '@/libs/error';
import openOnboard from '@/libs/utils/open-onboard';
import { throttle } from 'lodash';

let isAccountAccessPending = false;
const throttledOpenOnboard = throttle(() => openOnboard(), 10000);
const pendingPromises: {
payload: ProviderRPCRequest;
res: CallbackFunction;
}[] = [];
const method: MiddlewareFunction = function (
const method: MiddlewareFunction = async function (
this: BitcoinProvider,
payload: ProviderRPCRequest,
res,
next,
): void {
): Promise<void> {
if (payload.method !== 'btc_requestAccounts') return next();
else {
if (isAccountAccessPending) {
Expand All @@ -25,6 +29,7 @@ const method: MiddlewareFunction = function (
return;
}
isAccountAccessPending = true;
const isInitialized = await this.KeyRing.isInitialized();
const handleRemainingPromises = () => {
isAccountAccessPending = false;
if (pendingPromises.length) {
Expand All @@ -38,6 +43,11 @@ const method: MiddlewareFunction = function (
) => {
if (_payload.options && _payload.options.domain) {
isAccountAccessPending = true;
if (!isInitialized) {
_res(getCustomError('Enkrypt not initialized'));
throttledOpenOnboard();
return handleRemainingPromises();
}
const accountsState = new AccountState();
accountsState
.getApprovedAddresses(_payload.options.domain)
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/providers/ethereum/networks/aa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const artheraOptions: EvmNetworkOptions = {
isTestNetwork: false,
currencyName: 'AA',
currencyNameLong: 'Arthera',
node: 'wss://ws.arthera.net',
node: 'https://rpc.arthera.net',
icon,
activityHandler: wrapActivityHandler(EtherscanActivity),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/providers/ethereum/networks/aat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const artheraTestOptions: EvmNetworkOptions = {
isTestNetwork: true,
currencyName: 'AA',
currencyNameLong: 'Arthera',
node: 'wss://ws-test.arthera.net',
node: 'https://rpc-test.arthera.net',
icon,
activityHandler: wrapActivityHandler(EtherscanActivity),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ import KadenaProvider from '..';
import AccountState from '../libs/accounts-state';
import { KadenaNetworks } from '../types';
import { getNetworkInfo } from '../libs/network';
import openOnboard from '@/libs/utils/open-onboard';
import { throttle } from 'lodash';

let isAccountAccessPending = false;
const throttledOpenOnboard = throttle(() => openOnboard(), 10000);

const pendingPromises: {
payload: ProviderRPCRequest;
res: CallbackFunction;
}[] = [];

const method: MiddlewareFunction = function (
const method: MiddlewareFunction = async function (
this: KadenaProvider,
payload: ProviderRPCRequest,
res,
next,
): void {
): Promise<void> {
if (payload.method !== 'kda_requestAccounts') return next();
else {
const isInitialized = await this.KeyRing.isInitialized();
if (isAccountAccessPending) {
pendingPromises.push({
payload,
Expand Down Expand Up @@ -95,6 +99,11 @@ const method: MiddlewareFunction = function (
) => {
if (_payload.options && _payload.options.domain) {
isAccountAccessPending = true;
if (!isInitialized) {
_res(getCustomError('Enkrypt not initialized'));
throttledOpenOnboard();
return handleRemainingPromises();
}
const accountsState = new AccountState();

accountsState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@ import PublicKeyRing from '@/libs/keyring/public-keyring';
import AccountState from '../libs/accounts-state';
import { ProviderRPCRequest } from '@/types/provider';
import { getCustomError } from '@/libs/error';
import openOnboard from '@/libs/utils/open-onboard';
import { throttle } from 'lodash';

let isAccountAccessPending = false;
const throttledOpenOnboard = throttle(() => openOnboard(), 10000);
const pendingPromises: {
payload: ProviderRPCRequest;
res: CallbackFunction;
}[] = [];
const method: MiddlewareFunction = function (
const method: MiddlewareFunction = async function (
this: SubstrateProvider,
payload: ProviderRPCRequest,
res,
next,
): void {
): Promise<void> {
if (payload.method !== 'dot_accounts_get') return next();
else {
const isInitialized = await this.KeyRing.isInitialized();

if (isAccountAccessPending) {
pendingPromises.push({
payload,
Expand Down Expand Up @@ -59,6 +64,11 @@ const method: MiddlewareFunction = function (
) => {
if (_payload.options && _payload.options.domain) {
isAccountAccessPending = true;
if (!isInitialized) {
_res(getCustomError('Enkrypt not initialized'));
throttledOpenOnboard();
return handleRemainingPromises();
}
const accountsState = new AccountState();
accountsState.isApproved(_payload.options.domain).then(isApproved => {
if (isApproved) {
Expand Down
15 changes: 13 additions & 2 deletions packages/extension/src/providers/solana/methods/sol_connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ import { ProviderRPCRequest } from '@/types/provider';
import { WindowPromise } from '@/libs/window-promise';
import AccountState from '../libs/accounts-state';
import { getCustomError } from '@/libs/error';
import openOnboard from '@/libs/utils/open-onboard';
import { throttle } from 'lodash';

import SolanaProvider from '..';
let isAccountAccessPending = false;
const throttledOpenOnboard = throttle(() => openOnboard(), 10000);
const pendingPromises: {
payload: ProviderRPCRequest;
res: CallbackFunction;
}[] = [];
const method: MiddlewareFunction = function (
const method: MiddlewareFunction = async function (
this: SolanaProvider,
payload: ProviderRPCRequest,
res,
next,
): void {
): Promise<void> {
if (payload.method !== 'sol_connect') return next();
else {
if (isAccountAccessPending) {
Expand All @@ -25,6 +29,7 @@ const method: MiddlewareFunction = function (
return;
}
isAccountAccessPending = true;
const isInitialized = await this.KeyRing.isInitialized();
const handleRemainingPromises = () => {
isAccountAccessPending = false;
if (pendingPromises.length) {
Expand All @@ -38,6 +43,12 @@ const method: MiddlewareFunction = function (
) => {
if (_payload.options && _payload.options.domain) {
isAccountAccessPending = true;
if (!isInitialized) {
_res(getCustomError('Enkrypt not initialized'));
throttledOpenOnboard();
return handleRemainingPromises();
}

const accountsState = new AccountState();
accountsState
.getApprovedAddresses(_payload.options.domain)
Expand Down

0 comments on commit 2fab90b

Please sign in to comment.