@onekeyfe/onekey-cardano-provider 2.2.58 → 2.2.59-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProviderCardano.d.ts +0 -4
- package/dist/ProviderCardano.js +0 -3
- package/dist/cjs/ProviderCardano.js +0 -3
- package/dist/cjs/inject.js +29 -8
- package/dist/inject.d.ts +9 -1
- package/dist/inject.js +29 -8
- package/package.json +6 -6
|
@@ -39,7 +39,6 @@ type CardanoProviderEventsMap = {
|
|
|
39
39
|
};
|
|
40
40
|
interface IProviderCardano extends ProviderBase {
|
|
41
41
|
isConnected: boolean;
|
|
42
|
-
onekey: Cip30Wallet;
|
|
43
42
|
getNetworkId(): Promise<NetworkId>;
|
|
44
43
|
}
|
|
45
44
|
type OneKeyCardanoProviderProps = IInpageProviderConfig & {
|
|
@@ -49,9 +48,6 @@ declare class ProviderCardano extends ProviderCardanoBase implements IProviderCa
|
|
|
49
48
|
private _account;
|
|
50
49
|
get account(): string | null;
|
|
51
50
|
get isConnected(): boolean;
|
|
52
|
-
onekey: Cip30Wallet;
|
|
53
|
-
nami: Cip30Wallet;
|
|
54
|
-
yoroi: Cip30Wallet;
|
|
55
51
|
constructor(props: OneKeyCardanoProviderProps);
|
|
56
52
|
private _registerEvents;
|
|
57
53
|
private _callBridge;
|
package/dist/ProviderCardano.js
CHANGED
|
@@ -30,9 +30,6 @@ class ProviderCardano extends ProviderCardanoBase {
|
|
|
30
30
|
super(Object.assign(Object.assign({}, props), { bridge: props.bridge || getOrCreateExtInjectedJsBridge({ timeout: props.timeout }) }));
|
|
31
31
|
this._account = null;
|
|
32
32
|
this._registerEvents();
|
|
33
|
-
this.nami = Object.assign(Object.assign({}, this.walletInfo()), { name: 'Nami' });
|
|
34
|
-
this.onekey = Object.assign({}, this.walletInfo());
|
|
35
|
-
this.yoroi = Object.assign(Object.assign({}, this.walletInfo()), { name: 'yoroi' });
|
|
36
33
|
}
|
|
37
34
|
_registerEvents() {
|
|
38
35
|
window.addEventListener('onekey_bridge_disconnect', () => {
|
|
@@ -33,9 +33,6 @@ class ProviderCardano extends ProviderCardanoBase_1.ProviderCardanoBase {
|
|
|
33
33
|
super(Object.assign(Object.assign({}, props), { bridge: props.bridge || (0, extension_bridge_injected_1.getOrCreateExtInjectedJsBridge)({ timeout: props.timeout }) }));
|
|
34
34
|
this._account = null;
|
|
35
35
|
this._registerEvents();
|
|
36
|
-
this.nami = Object.assign(Object.assign({}, this.walletInfo()), { name: 'Nami' });
|
|
37
|
-
this.onekey = Object.assign({}, this.walletInfo());
|
|
38
|
-
this.yoroi = Object.assign(Object.assign({}, this.walletInfo()), { name: 'yoroi' });
|
|
39
36
|
}
|
|
40
37
|
_registerEvents() {
|
|
41
38
|
window.addEventListener('onekey_bridge_disconnect', () => {
|
package/dist/cjs/inject.js
CHANGED
|
@@ -4,15 +4,36 @@
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.defineWindowCardanoProperty = defineWindowCardanoProperty;
|
|
7
|
-
|
|
7
|
+
const PROXY_WALLETS = ['nami', 'yoroi'];
|
|
8
|
+
const proxyWalletConfigs = {
|
|
9
|
+
nami: { name: 'Nami' },
|
|
10
|
+
yoroi: { name: 'yoroi' },
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Define window.cardano property
|
|
14
|
+
* - Always injects OneKey wallet
|
|
15
|
+
* - Injects proxy wallets (Nami, etc.) only when registerProxyWallets is true
|
|
16
|
+
*/
|
|
17
|
+
function defineWindowCardanoProperty(property, provider, options) {
|
|
18
|
+
const walletInfo = provider.walletInfo();
|
|
19
|
+
const protectedKeys = ['onekey'];
|
|
20
|
+
// Always register OneKey wallet
|
|
21
|
+
provider.onekey = walletInfo;
|
|
22
|
+
// Register proxy wallets on the provider instance if needed
|
|
23
|
+
if (options === null || options === void 0 ? void 0 : options.registerProxyWallets) {
|
|
24
|
+
PROXY_WALLETS.forEach((walletKey) => {
|
|
25
|
+
const config = proxyWalletConfigs[walletKey];
|
|
26
|
+
provider[walletKey] = Object.assign(Object.assign({}, walletInfo), { name: config.name });
|
|
27
|
+
protectedKeys.push(walletKey);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
8
30
|
const proxyProvider = new Proxy(provider, {
|
|
9
|
-
defineProperty(target,
|
|
10
|
-
if (
|
|
11
|
-
|
|
31
|
+
defineProperty(target, prop, attributes) {
|
|
32
|
+
if (protectedKeys.includes(prop)) {
|
|
33
|
+
// skip define to prevent overwriting
|
|
34
|
+
return true;
|
|
12
35
|
}
|
|
13
|
-
|
|
14
|
-
console.log('skip define Prevent overwriting');
|
|
15
|
-
return true;
|
|
36
|
+
return Reflect.defineProperty(target, prop, attributes);
|
|
16
37
|
},
|
|
17
38
|
});
|
|
18
39
|
Object.keys(provider).forEach((key) => {
|
|
@@ -24,7 +45,7 @@ function defineWindowCardanoProperty(property, provider) {
|
|
|
24
45
|
get() {
|
|
25
46
|
return proxyProvider;
|
|
26
47
|
},
|
|
27
|
-
set(
|
|
48
|
+
set() {
|
|
28
49
|
// skip set
|
|
29
50
|
},
|
|
30
51
|
});
|
package/dist/inject.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ProviderCardano } from './ProviderCardano';
|
|
2
|
+
/**
|
|
3
|
+
* Define window.cardano property
|
|
4
|
+
* - Always injects OneKey wallet
|
|
5
|
+
* - Injects proxy wallets (Nami, etc.) only when registerProxyWallets is true
|
|
6
|
+
*/
|
|
7
|
+
export declare function defineWindowCardanoProperty(property: string, provider: ProviderCardano, options?: {
|
|
8
|
+
registerProxyWallets?: boolean;
|
|
9
|
+
}): void;
|
package/dist/inject.js
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
|
-
|
|
4
|
+
const PROXY_WALLETS = ['nami', 'yoroi'];
|
|
5
|
+
const proxyWalletConfigs = {
|
|
6
|
+
nami: { name: 'Nami' },
|
|
7
|
+
yoroi: { name: 'yoroi' },
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Define window.cardano property
|
|
11
|
+
* - Always injects OneKey wallet
|
|
12
|
+
* - Injects proxy wallets (Nami, etc.) only when registerProxyWallets is true
|
|
13
|
+
*/
|
|
14
|
+
export function defineWindowCardanoProperty(property, provider, options) {
|
|
15
|
+
const walletInfo = provider.walletInfo();
|
|
16
|
+
const protectedKeys = ['onekey'];
|
|
17
|
+
// Always register OneKey wallet
|
|
18
|
+
provider.onekey = walletInfo;
|
|
19
|
+
// Register proxy wallets on the provider instance if needed
|
|
20
|
+
if (options === null || options === void 0 ? void 0 : options.registerProxyWallets) {
|
|
21
|
+
PROXY_WALLETS.forEach((walletKey) => {
|
|
22
|
+
const config = proxyWalletConfigs[walletKey];
|
|
23
|
+
provider[walletKey] = Object.assign(Object.assign({}, walletInfo), { name: config.name });
|
|
24
|
+
protectedKeys.push(walletKey);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
5
27
|
const proxyProvider = new Proxy(provider, {
|
|
6
|
-
defineProperty(target,
|
|
7
|
-
if (
|
|
8
|
-
|
|
28
|
+
defineProperty(target, prop, attributes) {
|
|
29
|
+
if (protectedKeys.includes(prop)) {
|
|
30
|
+
// skip define to prevent overwriting
|
|
31
|
+
return true;
|
|
9
32
|
}
|
|
10
|
-
|
|
11
|
-
console.log('skip define Prevent overwriting');
|
|
12
|
-
return true;
|
|
33
|
+
return Reflect.defineProperty(target, prop, attributes);
|
|
13
34
|
},
|
|
14
35
|
});
|
|
15
36
|
Object.keys(provider).forEach((key) => {
|
|
@@ -21,7 +42,7 @@ export function defineWindowCardanoProperty(property, provider) {
|
|
|
21
42
|
get() {
|
|
22
43
|
return proxyProvider;
|
|
23
44
|
},
|
|
24
|
-
set(
|
|
45
|
+
set() {
|
|
25
46
|
// skip set
|
|
26
47
|
},
|
|
27
48
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-cardano-provider",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.59-alpha.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider",
|
|
6
6
|
"cardano"
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@onekeyfe/cross-inpage-provider-core": "2.2.
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-errors": "2.2.
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-types": "2.2.
|
|
34
|
-
"@onekeyfe/extension-bridge-injected": "2.2.
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "2.2.59-alpha.1",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-errors": "2.2.59-alpha.1",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-types": "2.2.59-alpha.1",
|
|
34
|
+
"@onekeyfe/extension-bridge-injected": "2.2.59-alpha.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "8fcceb1d4bdf50f336f85fcae2c35574f41aeeda"
|
|
37
37
|
}
|