@onekeyfe/onekey-sui-provider 1.1.9 → 1.1.10
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.
|
@@ -7,18 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
-
};
|
|
16
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
17
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
18
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
19
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
|
-
};
|
|
21
|
-
var _OnekeySuiStandardWallet_instances, _OnekeySuiStandardWallet_name, _OnekeySuiStandardWallet_provider, _OnekeySuiStandardWallet_events, _OnekeySuiStandardWallet_account, _OnekeySuiStandardWallet_on, _OnekeySuiStandardWallet_connected, _OnekeySuiStandardWallet_connect, _OnekeySuiStandardWallet_disconnect, _OnekeySuiStandardWallet_hasPermissions, _OnekeySuiStandardWallet_signAndExecuteTransaction;
|
|
22
10
|
import mitt from 'mitt';
|
|
23
11
|
import { registerWallet } from '@mysten/wallet-standard';
|
|
24
12
|
import { SUI_CHAINS, ReadonlyWalletAccount, } from '@mysten/wallet-standard';
|
|
@@ -32,58 +20,54 @@ var Feature;
|
|
|
32
20
|
})(Feature || (Feature = {}));
|
|
33
21
|
class OnekeySuiStandardWallet {
|
|
34
22
|
constructor(provider) {
|
|
35
|
-
_OnekeySuiStandardWallet_instances.add(this);
|
|
36
23
|
this.version = '1.0.0';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
_OnekeySuiStandardWallet_connected.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (!(yield __classPrivateFieldGet(this, _OnekeySuiStandardWallet_instances, "m", _OnekeySuiStandardWallet_hasPermissions).call(this, ['viewAccount']))) {
|
|
24
|
+
this._name = 'OneKey Wallet';
|
|
25
|
+
this.$on = (event, listener) => {
|
|
26
|
+
this._events.on(event, listener);
|
|
27
|
+
return () => this._events.off(event, listener);
|
|
28
|
+
};
|
|
29
|
+
this.$connected = () => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (!(yield this.$hasPermissions(['viewAccount']))) {
|
|
47
31
|
return;
|
|
48
32
|
}
|
|
49
|
-
const accounts = yield
|
|
33
|
+
const accounts = yield this.provider.getAccounts();
|
|
50
34
|
const [address] = accounts;
|
|
51
35
|
if (address) {
|
|
52
|
-
const account =
|
|
36
|
+
const account = this._account;
|
|
53
37
|
if (!account || account.address !== address) {
|
|
54
|
-
|
|
38
|
+
this._account = new ReadonlyWalletAccount({
|
|
55
39
|
address,
|
|
56
40
|
// TODO: Expose public key instead of address:
|
|
57
41
|
publicKey: new Uint8Array(),
|
|
58
42
|
chains: SUI_CHAINS,
|
|
59
43
|
features: [Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION],
|
|
60
|
-
})
|
|
61
|
-
|
|
44
|
+
});
|
|
45
|
+
this._events.emit('change', { accounts: this.accounts });
|
|
62
46
|
}
|
|
63
47
|
}
|
|
64
|
-
})
|
|
65
|
-
|
|
48
|
+
});
|
|
49
|
+
this.$connect = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
66
50
|
if (!(input === null || input === void 0 ? void 0 : input.silent)) {
|
|
67
|
-
yield
|
|
51
|
+
yield this.provider.requestPermissions();
|
|
68
52
|
}
|
|
69
|
-
yield
|
|
53
|
+
yield this.$connected();
|
|
70
54
|
return { accounts: this.accounts };
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
yield
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
return
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
void
|
|
55
|
+
});
|
|
56
|
+
this.$disconnect = () => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
yield this.provider.disconnect();
|
|
58
|
+
this._account = null;
|
|
59
|
+
this._events.all.clear();
|
|
60
|
+
});
|
|
61
|
+
this.$signAndExecuteTransaction = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return this.provider.signAndExecuteTransaction(input.transaction);
|
|
63
|
+
});
|
|
64
|
+
this.provider = provider;
|
|
65
|
+
this._events = mitt();
|
|
66
|
+
this._account = null;
|
|
67
|
+
void this.$connected();
|
|
84
68
|
}
|
|
85
69
|
get name() {
|
|
86
|
-
return
|
|
70
|
+
return this._name;
|
|
87
71
|
}
|
|
88
72
|
get icon() {
|
|
89
73
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -94,32 +78,32 @@ class OnekeySuiStandardWallet {
|
|
|
94
78
|
return SUI_CHAINS;
|
|
95
79
|
}
|
|
96
80
|
get accounts() {
|
|
97
|
-
return
|
|
81
|
+
return this._account ? [this._account] : [];
|
|
98
82
|
}
|
|
99
83
|
get features() {
|
|
100
84
|
return {
|
|
101
85
|
[Feature.STANDARD__CONNECT]: {
|
|
102
86
|
version: '1.0.0',
|
|
103
|
-
connect:
|
|
87
|
+
connect: this.$connect,
|
|
104
88
|
},
|
|
105
89
|
[Feature.STANDARD__DISCONNECT]: {
|
|
106
90
|
version: '1.0.0',
|
|
107
|
-
disconnect:
|
|
91
|
+
disconnect: this.$disconnect,
|
|
108
92
|
},
|
|
109
93
|
[Feature.STANDARD__EVENTS]: {
|
|
110
94
|
version: '1.0.0',
|
|
111
|
-
on:
|
|
95
|
+
on: this.$on,
|
|
112
96
|
},
|
|
113
97
|
[Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION]: {
|
|
114
98
|
version: '1.0.0',
|
|
115
|
-
signAndExecuteTransaction:
|
|
99
|
+
signAndExecuteTransaction: this.$signAndExecuteTransaction,
|
|
116
100
|
},
|
|
117
101
|
};
|
|
118
102
|
}
|
|
103
|
+
$hasPermissions(permissions = ALL_PERMISSION_TYPES) {
|
|
104
|
+
return this.provider.hasPermissions(permissions);
|
|
105
|
+
}
|
|
119
106
|
}
|
|
120
|
-
_OnekeySuiStandardWallet_name = new WeakMap(), _OnekeySuiStandardWallet_provider = new WeakMap(), _OnekeySuiStandardWallet_events = new WeakMap(), _OnekeySuiStandardWallet_account = new WeakMap(), _OnekeySuiStandardWallet_on = new WeakMap(), _OnekeySuiStandardWallet_connected = new WeakMap(), _OnekeySuiStandardWallet_connect = new WeakMap(), _OnekeySuiStandardWallet_disconnect = new WeakMap(), _OnekeySuiStandardWallet_signAndExecuteTransaction = new WeakMap(), _OnekeySuiStandardWallet_instances = new WeakSet(), _OnekeySuiStandardWallet_hasPermissions = function _OnekeySuiStandardWallet_hasPermissions(permissions = ALL_PERMISSION_TYPES) {
|
|
121
|
-
return __classPrivateFieldGet(this, _OnekeySuiStandardWallet_provider, "f").hasPermissions(permissions);
|
|
122
|
-
};
|
|
123
107
|
export function registerSuiWallet(provider) {
|
|
124
108
|
try {
|
|
125
109
|
registerWallet(new OnekeySuiStandardWallet(provider));
|
|
@@ -8,21 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
13
|
};
|
|
25
|
-
var _OnekeySuiStandardWallet_instances, _OnekeySuiStandardWallet_name, _OnekeySuiStandardWallet_provider, _OnekeySuiStandardWallet_events, _OnekeySuiStandardWallet_account, _OnekeySuiStandardWallet_on, _OnekeySuiStandardWallet_connected, _OnekeySuiStandardWallet_connect, _OnekeySuiStandardWallet_disconnect, _OnekeySuiStandardWallet_hasPermissions, _OnekeySuiStandardWallet_signAndExecuteTransaction;
|
|
26
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
15
|
exports.registerSuiWallet = void 0;
|
|
28
16
|
const mitt_1 = __importDefault(require("mitt"));
|
|
@@ -38,58 +26,54 @@ var Feature;
|
|
|
38
26
|
})(Feature || (Feature = {}));
|
|
39
27
|
class OnekeySuiStandardWallet {
|
|
40
28
|
constructor(provider) {
|
|
41
|
-
_OnekeySuiStandardWallet_instances.add(this);
|
|
42
29
|
this.version = '1.0.0';
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
_OnekeySuiStandardWallet_connected.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
if (!(yield __classPrivateFieldGet(this, _OnekeySuiStandardWallet_instances, "m", _OnekeySuiStandardWallet_hasPermissions).call(this, ['viewAccount']))) {
|
|
30
|
+
this._name = 'OneKey Wallet';
|
|
31
|
+
this.$on = (event, listener) => {
|
|
32
|
+
this._events.on(event, listener);
|
|
33
|
+
return () => this._events.off(event, listener);
|
|
34
|
+
};
|
|
35
|
+
this.$connected = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
if (!(yield this.$hasPermissions(['viewAccount']))) {
|
|
53
37
|
return;
|
|
54
38
|
}
|
|
55
|
-
const accounts = yield
|
|
39
|
+
const accounts = yield this.provider.getAccounts();
|
|
56
40
|
const [address] = accounts;
|
|
57
41
|
if (address) {
|
|
58
|
-
const account =
|
|
42
|
+
const account = this._account;
|
|
59
43
|
if (!account || account.address !== address) {
|
|
60
|
-
|
|
44
|
+
this._account = new wallet_standard_2.ReadonlyWalletAccount({
|
|
61
45
|
address,
|
|
62
46
|
// TODO: Expose public key instead of address:
|
|
63
47
|
publicKey: new Uint8Array(),
|
|
64
48
|
chains: wallet_standard_2.SUI_CHAINS,
|
|
65
49
|
features: [Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION],
|
|
66
|
-
})
|
|
67
|
-
|
|
50
|
+
});
|
|
51
|
+
this._events.emit('change', { accounts: this.accounts });
|
|
68
52
|
}
|
|
69
53
|
}
|
|
70
|
-
})
|
|
71
|
-
|
|
54
|
+
});
|
|
55
|
+
this.$connect = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
72
56
|
if (!(input === null || input === void 0 ? void 0 : input.silent)) {
|
|
73
|
-
yield
|
|
57
|
+
yield this.provider.requestPermissions();
|
|
74
58
|
}
|
|
75
|
-
yield
|
|
59
|
+
yield this.$connected();
|
|
76
60
|
return { accounts: this.accounts };
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
yield
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
return
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
void
|
|
61
|
+
});
|
|
62
|
+
this.$disconnect = () => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield this.provider.disconnect();
|
|
64
|
+
this._account = null;
|
|
65
|
+
this._events.all.clear();
|
|
66
|
+
});
|
|
67
|
+
this.$signAndExecuteTransaction = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
return this.provider.signAndExecuteTransaction(input.transaction);
|
|
69
|
+
});
|
|
70
|
+
this.provider = provider;
|
|
71
|
+
this._events = (0, mitt_1.default)();
|
|
72
|
+
this._account = null;
|
|
73
|
+
void this.$connected();
|
|
90
74
|
}
|
|
91
75
|
get name() {
|
|
92
|
-
return
|
|
76
|
+
return this._name;
|
|
93
77
|
}
|
|
94
78
|
get icon() {
|
|
95
79
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -100,32 +84,32 @@ class OnekeySuiStandardWallet {
|
|
|
100
84
|
return wallet_standard_2.SUI_CHAINS;
|
|
101
85
|
}
|
|
102
86
|
get accounts() {
|
|
103
|
-
return
|
|
87
|
+
return this._account ? [this._account] : [];
|
|
104
88
|
}
|
|
105
89
|
get features() {
|
|
106
90
|
return {
|
|
107
91
|
[Feature.STANDARD__CONNECT]: {
|
|
108
92
|
version: '1.0.0',
|
|
109
|
-
connect:
|
|
93
|
+
connect: this.$connect,
|
|
110
94
|
},
|
|
111
95
|
[Feature.STANDARD__DISCONNECT]: {
|
|
112
96
|
version: '1.0.0',
|
|
113
|
-
disconnect:
|
|
97
|
+
disconnect: this.$disconnect,
|
|
114
98
|
},
|
|
115
99
|
[Feature.STANDARD__EVENTS]: {
|
|
116
100
|
version: '1.0.0',
|
|
117
|
-
on:
|
|
101
|
+
on: this.$on,
|
|
118
102
|
},
|
|
119
103
|
[Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION]: {
|
|
120
104
|
version: '1.0.0',
|
|
121
|
-
signAndExecuteTransaction:
|
|
105
|
+
signAndExecuteTransaction: this.$signAndExecuteTransaction,
|
|
122
106
|
},
|
|
123
107
|
};
|
|
124
108
|
}
|
|
109
|
+
$hasPermissions(permissions = types_1.ALL_PERMISSION_TYPES) {
|
|
110
|
+
return this.provider.hasPermissions(permissions);
|
|
111
|
+
}
|
|
125
112
|
}
|
|
126
|
-
_OnekeySuiStandardWallet_name = new WeakMap(), _OnekeySuiStandardWallet_provider = new WeakMap(), _OnekeySuiStandardWallet_events = new WeakMap(), _OnekeySuiStandardWallet_account = new WeakMap(), _OnekeySuiStandardWallet_on = new WeakMap(), _OnekeySuiStandardWallet_connected = new WeakMap(), _OnekeySuiStandardWallet_connect = new WeakMap(), _OnekeySuiStandardWallet_disconnect = new WeakMap(), _OnekeySuiStandardWallet_signAndExecuteTransaction = new WeakMap(), _OnekeySuiStandardWallet_instances = new WeakSet(), _OnekeySuiStandardWallet_hasPermissions = function _OnekeySuiStandardWallet_hasPermissions(permissions = types_1.ALL_PERMISSION_TYPES) {
|
|
127
|
-
return __classPrivateFieldGet(this, _OnekeySuiStandardWallet_provider, "f").hasPermissions(permissions);
|
|
128
|
-
};
|
|
129
113
|
function registerSuiWallet(provider) {
|
|
130
114
|
try {
|
|
131
115
|
(0, wallet_standard_1.registerWallet)(new OnekeySuiStandardWallet(provider));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-sui-provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@mysten/wallet-standard": "^0.2.3",
|
|
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.
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.10",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.10",
|
|
34
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.10",
|
|
35
|
+
"@onekeyfe/extension-bridge-injected": "1.1.10",
|
|
36
36
|
"eth-rpc-errors": "^4.0.3",
|
|
37
37
|
"mitt": "^3.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "daa07d3713c9bd9802833175a33da1d763567562"
|
|
40
40
|
}
|