Skip to content

Commit

Permalink
feat: support alwaysInject (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 authored Aug 22, 2024
1 parent 14446b6 commit 6688b0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/walletProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,13 @@ export function defineWindowProperty(
options?: {
enumerable?: boolean;
disablePlatform?: IPlatformType[];
alwaysInject?: boolean;
},
) {
if (!checkPlatformEnable(options?.disablePlatform)) return;
if (!checkWalletSwitchEnable()) return;
if (!options?.alwaysInject) {
if (!checkPlatformEnable(options?.disablePlatform)) return;
if (!checkWalletSwitchEnable()) return;
}
const enable = checkEnableDefineProperty(property);
const proxyProvider = new Proxy(provider as object, {
defineProperty(target, property, attributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function injectWeb3Provider(): unknown {
algorand,
};

defineWindowProperty('$onekey', $onekey, { enumerable: true });
defineWindowProperty('$onekey', $onekey, { enumerable: true, alwaysInject: true });

const martianProxy = new Proxy(martian, {
get: (target, property, ...args) => {
Expand Down

0 comments on commit 6688b0c

Please sign in to comment.