@onekeyfe/onekey-cardano-provider 1.1.18 → 1.1.20
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 +14 -2
- package/dist/ProviderCardano.js +26 -7
- package/dist/cjs/ProviderCardano.js +27 -8
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/inject.js +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inject.d.ts +1 -0
- package/dist/inject.js +28 -0
- package/package.json +7 -7
|
@@ -4,6 +4,7 @@ import { IInpageProviderConfig } from '@onekeyfe/cross-inpage-provider-core';
|
|
|
4
4
|
import { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types';
|
|
5
5
|
import { Cbor, Bytes, Cip30DataSignature, Cip30Wallet, NetworkId, Paginate, WalletApi } from './types';
|
|
6
6
|
import * as TypeUtils from './type-utils';
|
|
7
|
+
export declare const NAMI_TARGET = "nami-wallet";
|
|
7
8
|
export declare type CardanoRequest = WalletApi & {
|
|
8
9
|
connect: () => Promise<{
|
|
9
10
|
account: string;
|
|
@@ -48,8 +49,8 @@ declare class ProviderCardano extends ProviderCardanoBase implements IProviderCa
|
|
|
48
49
|
private _account;
|
|
49
50
|
get account(): string | null;
|
|
50
51
|
get isConnected(): boolean;
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
onekey: Cip30Wallet;
|
|
53
|
+
nami: Cip30Wallet;
|
|
53
54
|
constructor(props: OneKeyCardanoProviderProps);
|
|
54
55
|
private _registerEvents;
|
|
55
56
|
private _callBridge;
|
|
@@ -76,6 +77,11 @@ declare class ProviderCardano extends ProviderCardanoBase implements IProviderCa
|
|
|
76
77
|
signature: string;
|
|
77
78
|
}>;
|
|
78
79
|
submitTx: (tx: Cbor) => Promise<string>;
|
|
80
|
+
experimental: {
|
|
81
|
+
on: (eventName: string, callback: (detail: any) => void) => void;
|
|
82
|
+
off: () => void;
|
|
83
|
+
getCollateral: () => Promise<null>;
|
|
84
|
+
};
|
|
79
85
|
}>;
|
|
80
86
|
getNetworkId(): Promise<NetworkId>;
|
|
81
87
|
getUtxos(amount?: Cbor, paginate?: Paginate): Promise<string[] | undefined>;
|
|
@@ -91,5 +97,11 @@ declare class ProviderCardano extends ProviderCardanoBase implements IProviderCa
|
|
|
91
97
|
signature: string;
|
|
92
98
|
}>;
|
|
93
99
|
submitTx(tx: Cbor): Promise<string>;
|
|
100
|
+
/**
|
|
101
|
+
* @param {string} eventName
|
|
102
|
+
* @param {Function} callback
|
|
103
|
+
*/
|
|
104
|
+
namiOn(eventName: string, callback: (detail: any) => void): void;
|
|
105
|
+
namiOff(): void;
|
|
94
106
|
}
|
|
95
107
|
export { ProviderCardano };
|
package/dist/ProviderCardano.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
1
3
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
4
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
5
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,6 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
12
|
import { ProviderCardanoBase } from './ProviderCardanoBase';
|
|
11
13
|
import { getOrCreateExtInjectedJsBridge } from '@onekeyfe/extension-bridge-injected';
|
|
12
14
|
import { isWalletEventMethodMatch } from './utils';
|
|
15
|
+
export const NAMI_TARGET = 'nami-wallet';
|
|
13
16
|
const PROVIDER_EVENTS = {
|
|
14
17
|
'connect': 'connect',
|
|
15
18
|
'disconnect': 'disconnect',
|
|
@@ -21,6 +24,8 @@ class ProviderCardano extends ProviderCardanoBase {
|
|
|
21
24
|
super(Object.assign(Object.assign({}, props), { bridge: props.bridge || getOrCreateExtInjectedJsBridge({ timeout: props.timeout }) }));
|
|
22
25
|
this._account = null;
|
|
23
26
|
this._registerEvents();
|
|
27
|
+
this.nami = Object.assign(Object.assign({}, this.walletInfo()), { name: 'Nami' });
|
|
28
|
+
this.onekey = Object.assign({}, this.walletInfo());
|
|
24
29
|
}
|
|
25
30
|
get account() {
|
|
26
31
|
return this._account;
|
|
@@ -28,12 +33,6 @@ class ProviderCardano extends ProviderCardanoBase {
|
|
|
28
33
|
get isConnected() {
|
|
29
34
|
return this._account !== null;
|
|
30
35
|
}
|
|
31
|
-
get onekey() {
|
|
32
|
-
return this.walletInfo();
|
|
33
|
-
}
|
|
34
|
-
get nami() {
|
|
35
|
-
return this.walletInfo();
|
|
36
|
-
}
|
|
37
36
|
_registerEvents() {
|
|
38
37
|
window.addEventListener('onekey_bridge_disconnect', () => {
|
|
39
38
|
this._handleDisconnected();
|
|
@@ -112,7 +111,12 @@ class ProviderCardano extends ProviderCardanoBase {
|
|
|
112
111
|
getRewardAddresses: () => this.getRewardAddresses(),
|
|
113
112
|
signTx: (tx, partialSign) => this.signTx(tx, partialSign),
|
|
114
113
|
signData: (addr, payload) => this.signData(addr, payload),
|
|
115
|
-
submitTx: (tx) => this.submitTx(tx)
|
|
114
|
+
submitTx: (tx) => this.submitTx(tx),
|
|
115
|
+
experimental: {
|
|
116
|
+
on: (eventName, callback) => this.namiOn(eventName, callback),
|
|
117
|
+
off: () => this.namiOff(),
|
|
118
|
+
getCollateral: () => this.getCollateral(),
|
|
119
|
+
},
|
|
116
120
|
};
|
|
117
121
|
if (!this.account) {
|
|
118
122
|
const result = yield this._callBridge({
|
|
@@ -220,5 +224,20 @@ class ProviderCardano extends ProviderCardanoBase {
|
|
|
220
224
|
});
|
|
221
225
|
});
|
|
222
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* @param {string} eventName
|
|
229
|
+
* @param {Function} callback
|
|
230
|
+
*/
|
|
231
|
+
namiOn(eventName, callback) {
|
|
232
|
+
const handler = (event) => callback(event.detail);
|
|
233
|
+
// @ts-ignore
|
|
234
|
+
const events = window.cardano.nami._events[eventName] || [];
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
window.cardano.nami._events[eventName] = [...events, [callback, handler]];
|
|
237
|
+
window.addEventListener(`${NAMI_TARGET}${eventName}`, handler);
|
|
238
|
+
}
|
|
239
|
+
namiOff() {
|
|
240
|
+
// empty
|
|
241
|
+
}
|
|
223
242
|
}
|
|
224
243
|
export { ProviderCardano };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
4
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
5
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
6
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -9,10 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
11
|
});
|
|
10
12
|
};
|
|
11
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ProviderCardano = void 0;
|
|
14
|
+
exports.ProviderCardano = exports.NAMI_TARGET = void 0;
|
|
13
15
|
const ProviderCardanoBase_1 = require("./ProviderCardanoBase");
|
|
14
16
|
const extension_bridge_injected_1 = require("@onekeyfe/extension-bridge-injected");
|
|
15
17
|
const utils_1 = require("./utils");
|
|
18
|
+
exports.NAMI_TARGET = 'nami-wallet';
|
|
16
19
|
const PROVIDER_EVENTS = {
|
|
17
20
|
'connect': 'connect',
|
|
18
21
|
'disconnect': 'disconnect',
|
|
@@ -24,6 +27,8 @@ class ProviderCardano extends ProviderCardanoBase_1.ProviderCardanoBase {
|
|
|
24
27
|
super(Object.assign(Object.assign({}, props), { bridge: props.bridge || (0, extension_bridge_injected_1.getOrCreateExtInjectedJsBridge)({ timeout: props.timeout }) }));
|
|
25
28
|
this._account = null;
|
|
26
29
|
this._registerEvents();
|
|
30
|
+
this.nami = Object.assign(Object.assign({}, this.walletInfo()), { name: 'Nami' });
|
|
31
|
+
this.onekey = Object.assign({}, this.walletInfo());
|
|
27
32
|
}
|
|
28
33
|
get account() {
|
|
29
34
|
return this._account;
|
|
@@ -31,12 +36,6 @@ class ProviderCardano extends ProviderCardanoBase_1.ProviderCardanoBase {
|
|
|
31
36
|
get isConnected() {
|
|
32
37
|
return this._account !== null;
|
|
33
38
|
}
|
|
34
|
-
get onekey() {
|
|
35
|
-
return this.walletInfo();
|
|
36
|
-
}
|
|
37
|
-
get nami() {
|
|
38
|
-
return this.walletInfo();
|
|
39
|
-
}
|
|
40
39
|
_registerEvents() {
|
|
41
40
|
window.addEventListener('onekey_bridge_disconnect', () => {
|
|
42
41
|
this._handleDisconnected();
|
|
@@ -115,7 +114,12 @@ class ProviderCardano extends ProviderCardanoBase_1.ProviderCardanoBase {
|
|
|
115
114
|
getRewardAddresses: () => this.getRewardAddresses(),
|
|
116
115
|
signTx: (tx, partialSign) => this.signTx(tx, partialSign),
|
|
117
116
|
signData: (addr, payload) => this.signData(addr, payload),
|
|
118
|
-
submitTx: (tx) => this.submitTx(tx)
|
|
117
|
+
submitTx: (tx) => this.submitTx(tx),
|
|
118
|
+
experimental: {
|
|
119
|
+
on: (eventName, callback) => this.namiOn(eventName, callback),
|
|
120
|
+
off: () => this.namiOff(),
|
|
121
|
+
getCollateral: () => this.getCollateral(),
|
|
122
|
+
},
|
|
119
123
|
};
|
|
120
124
|
if (!this.account) {
|
|
121
125
|
const result = yield this._callBridge({
|
|
@@ -223,5 +227,20 @@ class ProviderCardano extends ProviderCardanoBase_1.ProviderCardanoBase {
|
|
|
223
227
|
});
|
|
224
228
|
});
|
|
225
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* @param {string} eventName
|
|
232
|
+
* @param {Function} callback
|
|
233
|
+
*/
|
|
234
|
+
namiOn(eventName, callback) {
|
|
235
|
+
const handler = (event) => callback(event.detail);
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
const events = window.cardano.nami._events[eventName] || [];
|
|
238
|
+
// @ts-ignore
|
|
239
|
+
window.cardano.nami._events[eventName] = [...events, [callback, handler]];
|
|
240
|
+
window.addEventListener(`${exports.NAMI_TARGET}${eventName}`, handler);
|
|
241
|
+
}
|
|
242
|
+
namiOff() {
|
|
243
|
+
// empty
|
|
244
|
+
}
|
|
226
245
|
}
|
|
227
246
|
exports.ProviderCardano = ProviderCardano;
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./ProviderCardano"), exports);
|
|
14
14
|
__exportStar(require("./ProviderCardanoBase"), exports);
|
|
15
|
+
__exportStar(require("./inject"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defineWindowCardanoProperty = void 0;
|
|
7
|
+
function defineWindowCardanoProperty(property, provider) {
|
|
8
|
+
const proxyProvider = new Proxy(provider, {
|
|
9
|
+
defineProperty(target, property, attributes) {
|
|
10
|
+
if (property !== 'nami') {
|
|
11
|
+
return Reflect.defineProperty(target, property, attributes);
|
|
12
|
+
}
|
|
13
|
+
// skip define Prevent overwriting
|
|
14
|
+
console.log('skip define Prevent overwriting');
|
|
15
|
+
return true;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
Object.keys(provider).forEach((key) => {
|
|
19
|
+
var _a;
|
|
20
|
+
((_a = window[property]) !== null && _a !== void 0 ? _a : {})[key] = proxyProvider[key];
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(window, property, {
|
|
23
|
+
configurable: false,
|
|
24
|
+
get() {
|
|
25
|
+
return proxyProvider;
|
|
26
|
+
},
|
|
27
|
+
set(val) {
|
|
28
|
+
// skip set
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.defineWindowCardanoProperty = defineWindowCardanoProperty;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/inject.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function defineWindowCardanoProperty(property: string, provider: unknown): void;
|
package/dist/inject.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
|
+
export function defineWindowCardanoProperty(property, provider) {
|
|
5
|
+
const proxyProvider = new Proxy(provider, {
|
|
6
|
+
defineProperty(target, property, attributes) {
|
|
7
|
+
if (property !== 'nami') {
|
|
8
|
+
return Reflect.defineProperty(target, property, attributes);
|
|
9
|
+
}
|
|
10
|
+
// skip define Prevent overwriting
|
|
11
|
+
console.log('skip define Prevent overwriting');
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
Object.keys(provider).forEach((key) => {
|
|
16
|
+
var _a;
|
|
17
|
+
((_a = window[property]) !== null && _a !== void 0 ? _a : {})[key] = proxyProvider[key];
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(window, property, {
|
|
20
|
+
configurable: false,
|
|
21
|
+
get() {
|
|
22
|
+
return proxyProvider;
|
|
23
|
+
},
|
|
24
|
+
set(val) {
|
|
25
|
+
// skip set
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-cardano-provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider",
|
|
6
6
|
"cardano"
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"start": "tsc --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-core": "1.1.
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-errors": "1.1.
|
|
34
|
-
"@onekeyfe/cross-inpage-provider-types": "1.1.
|
|
35
|
-
"@onekeyfe/extension-bridge-injected": "1.1.
|
|
36
|
-
"@onekeyfe/onekey-cardano-provider": "1.1.
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.20",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.20",
|
|
34
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.20",
|
|
35
|
+
"@onekeyfe/extension-bridge-injected": "1.1.20",
|
|
36
|
+
"@onekeyfe/onekey-cardano-provider": "1.1.20"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "2e6e9a818d159862fed88baf262deece5812bfc1"
|
|
39
39
|
}
|