mirror of
https://github.com/pezkuwichain/pezkuwi-extension.git
synced 2026-07-23 20:25:41 +00:00
Update domain references to pezkuwichain.app and rebrand from polkadot
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-mocks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import chrome from './chromeWrapper';
|
||||
|
||||
class MessagingFake {
|
||||
private listeners: ((...params: unknown[]) => unknown)[] = [];
|
||||
|
||||
get onMessage (): any {
|
||||
return {
|
||||
addListener: (cb: (...params: unknown[]) => unknown) => this.listeners.push(cb)
|
||||
};
|
||||
}
|
||||
|
||||
get onDisconnect (): any {
|
||||
return {
|
||||
addListener: (): any => undefined
|
||||
};
|
||||
}
|
||||
|
||||
postMessage (data: unknown): void {
|
||||
this.listeners.forEach((cb) => cb.call(this, data));
|
||||
}
|
||||
}
|
||||
|
||||
const messagingFake = new MessagingFake();
|
||||
|
||||
chrome.runtime.connect.returns(messagingFake);
|
||||
|
||||
chrome.storage.local.get.returns(
|
||||
new Promise<Record<string, any>>((resolve, reject) => {
|
||||
try {
|
||||
const result = {
|
||||
authUrls: JSON.stringify({
|
||||
'http://localhost:3000': {
|
||||
authorizedAccounts: ['5FbSap4BsWfjyRhCchoVdZHkDnmDm3NEgLZ25mesq4aw2WvX'],
|
||||
count: 0,
|
||||
id: '11',
|
||||
origin: 'example.com',
|
||||
url: 'http://localhost:3000'
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
resolve(result);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
}));
|
||||
|
||||
chrome.storage.local.set.returns(
|
||||
new Promise<void>((resolve, reject) => {
|
||||
try {
|
||||
resolve();
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
}));
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access
|
||||
(window as any).chrome = (globalThis as any).chrome = chrome;
|
||||
|
||||
export default chrome;
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-mocks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import sinonChrome from 'sinon-chrome';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace ChromeWrapper {
|
||||
export interface IAction {
|
||||
setBadgeText: (content: object) => Promise<void>;
|
||||
}
|
||||
export const action: IAction = {
|
||||
setBadgeText: (_: object) => {
|
||||
return new Promise<void>((resolve, _reject) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
const extendedSinonChrome = {
|
||||
...sinonChrome,
|
||||
action: ChromeWrapper.action
|
||||
};
|
||||
|
||||
export default extendedSinonChrome;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-mocks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default '';
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2019-2025 @polkadot/extension-mocks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-line
|
||||
module.exports = '';
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-mocks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
/**
|
||||
* Adjusts the resolver to point to empty files for .svg
|
||||
*
|
||||
* @param {*} specifier
|
||||
* @param {*} context
|
||||
* @param {*} nextResolve
|
||||
* @returns {*}
|
||||
*/
|
||||
export function resolve (specifier, context, nextResolve) {
|
||||
if (/\.(png|svg)$/.test(specifier)) {
|
||||
return {
|
||||
format: 'module',
|
||||
shortCircuit: true,
|
||||
url: pathToFileURL(
|
||||
path.join(process.cwd(), 'packages/extension-mocks/src/empty.js')
|
||||
).href
|
||||
};
|
||||
}
|
||||
|
||||
return nextResolve(specifier, context);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2019-2025 @pezkuwi/extension-mocks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type React from 'react';
|
||||
|
||||
interface useTranslationReturnObj {
|
||||
i18n: { changeLanguage: () => Promise<unknown>; };
|
||||
t: (str: string) => string;
|
||||
}
|
||||
|
||||
export const useTranslation = (): useTranslationReturnObj => {
|
||||
return {
|
||||
i18n: {
|
||||
changeLanguage: () => new Promise(() => { /**/ })
|
||||
},
|
||||
t: (str: string) => str
|
||||
};
|
||||
};
|
||||
|
||||
export const withTranslation = () => (component: React.ReactElement): React.ReactElement => component;
|
||||
|
||||
export const Trans = ({ children }: { children: React.ReactElement }): React.ReactElement => children;
|
||||
|
||||
export default withTranslation;
|
||||
Reference in New Issue
Block a user