@onekeyfe/onekey-sui-provider 1.1.24 → 1.1.26
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/OnekeySuiProvider.d.ts +30 -1557
- package/dist/OnekeySuiProvider.js +15 -13
- package/dist/OnekeySuiStandardWallet.js +61 -27
- package/dist/cjs/OnekeySuiProvider.js +15 -13
- package/dist/cjs/OnekeySuiStandardWallet.js +60 -26
- package/dist/types.d.ts +4 -0
- package/package.json +7 -7
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
10
11
|
import { getOrCreateExtInjectedJsBridge } from '@onekeyfe/extension-bridge-injected';
|
|
11
12
|
import { ProviderSuiBase } from './ProviderSuiBase';
|
|
12
13
|
import { web3Errors } from '@onekeyfe/cross-inpage-provider-errors';
|
|
@@ -49,8 +50,8 @@ class ProviderSui extends ProviderSuiBase {
|
|
|
49
50
|
if (options.emit && this.isConnectionStatusChanged('connected')) {
|
|
50
51
|
this.connectionStatus = 'connected';
|
|
51
52
|
const address = account !== null && account !== void 0 ? account : null;
|
|
52
|
-
this.emit('connect', address);
|
|
53
|
-
this.emit('accountChanged', address);
|
|
53
|
+
this.emit('connect', address.address);
|
|
54
|
+
this.emit('accountChanged', address.address);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
_handleDisconnected(options = { emit: true }) {
|
|
@@ -62,13 +63,14 @@ class ProviderSui extends ProviderSuiBase {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
isAccountsChanged(account) {
|
|
65
|
-
|
|
66
|
+
var _a;
|
|
67
|
+
return (account === null || account === void 0 ? void 0 : account.address) !== ((_a = this._account) === null || _a === void 0 ? void 0 : _a.address);
|
|
66
68
|
}
|
|
67
69
|
// trigger by bridge account change event
|
|
68
70
|
_handleAccountChange(payload) {
|
|
69
71
|
const account = payload;
|
|
70
72
|
if (this.isAccountsChanged(account)) {
|
|
71
|
-
this.emit('accountChanged', account || null);
|
|
73
|
+
this.emit('accountChanged', account.address || null);
|
|
72
74
|
}
|
|
73
75
|
if (!account) {
|
|
74
76
|
this._handleDisconnected();
|
|
@@ -133,27 +135,27 @@ class ProviderSui extends ProviderSuiBase {
|
|
|
133
135
|
});
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
|
-
|
|
138
|
+
signAndExecuteTransactionBlock(input) {
|
|
137
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
140
|
return this._callBridge({
|
|
139
|
-
method: '
|
|
140
|
-
params: input,
|
|
141
|
+
method: 'signAndExecuteTransactionBlock',
|
|
142
|
+
params: Object.assign(Object.assign({}, input), { walletSerialize: JSON.stringify(input.account), blockSerialize: input.transactionBlock.serialize() }),
|
|
141
143
|
});
|
|
142
144
|
});
|
|
143
145
|
}
|
|
144
|
-
|
|
146
|
+
signTransactionBlock(input) {
|
|
145
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
148
|
return this._callBridge({
|
|
147
|
-
method: '
|
|
148
|
-
params:
|
|
149
|
+
method: 'signTransactionBlock',
|
|
150
|
+
params: Object.assign(Object.assign({}, input), { walletSerialize: JSON.stringify(input.account), blockSerialize: input.transactionBlock.serialize() }),
|
|
149
151
|
});
|
|
150
152
|
});
|
|
151
153
|
}
|
|
152
|
-
|
|
154
|
+
signMessage(input) {
|
|
153
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
156
|
return this._callBridge({
|
|
155
|
-
method: '
|
|
156
|
-
params:
|
|
157
|
+
method: 'signMessage',
|
|
158
|
+
params: Object.assign(Object.assign({}, input), { walletSerialize: JSON.stringify(input.account), messageSerialize: bytesToHex(input.message) }),
|
|
157
159
|
});
|
|
158
160
|
});
|
|
159
161
|
}
|
|
@@ -7,16 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { hexToBytes } from '@noble/hashes/utils';
|
|
10
11
|
import mitt from 'mitt';
|
|
11
|
-
import { registerWallet } from '@mysten/wallet-standard';
|
|
12
|
-
import { SUI_CHAINS, ReadonlyWalletAccount, } from '@mysten/wallet-standard';
|
|
12
|
+
import { ReadonlyWalletAccount, registerWallet, SUI_DEVNET_CHAIN, SUI_TESTNET_CHAIN, } from '@mysten/wallet-standard';
|
|
13
13
|
import { ALL_PERMISSION_TYPES } from './types';
|
|
14
14
|
var Feature;
|
|
15
15
|
(function (Feature) {
|
|
16
16
|
Feature["STANDARD__CONNECT"] = "standard:connect";
|
|
17
17
|
Feature["STANDARD__DISCONNECT"] = "standard:disconnect";
|
|
18
18
|
Feature["STANDARD__EVENTS"] = "standard:events";
|
|
19
|
-
Feature["
|
|
19
|
+
Feature["SUI__SIGN_AND_EXECUTE_TRANSACTION_BLOCK"] = "sui:signAndExecuteTransactionBlock";
|
|
20
|
+
Feature["SUI__SIGN_TRANSACTION_BLOCK"] = "sui:signTransactionBlock";
|
|
21
|
+
Feature["SUI__SIGN_MESSAGE"] = "sui:signMessage";
|
|
20
22
|
})(Feature || (Feature = {}));
|
|
21
23
|
class OnekeySuiStandardWallet {
|
|
22
24
|
constructor(provider, options) {
|
|
@@ -27,24 +29,30 @@ class OnekeySuiStandardWallet {
|
|
|
27
29
|
return () => this._events.off(event, listener);
|
|
28
30
|
};
|
|
29
31
|
this.$connected = () => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const activeChain = yield this
|
|
32
|
+
const activeChain = yield this.getActiveChain();
|
|
31
33
|
if (!(yield this.$hasPermissions(['viewAccount']))) {
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
const accounts = yield this.provider.getAccounts();
|
|
35
|
-
const [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
const [account] = accounts;
|
|
38
|
+
const activateAccount = this._account;
|
|
39
|
+
if (activateAccount && activateAccount.address === account.address) {
|
|
40
|
+
return { accounts: this.accounts };
|
|
41
|
+
}
|
|
42
|
+
if (account) {
|
|
43
|
+
this._account = new ReadonlyWalletAccount({
|
|
44
|
+
address: account.address,
|
|
45
|
+
publicKey: hexToBytes(account.publicKey),
|
|
46
|
+
chains: activeChain ? [activeChain] : [],
|
|
47
|
+
features: [
|
|
48
|
+
Feature.STANDARD__CONNECT,
|
|
49
|
+
Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION_BLOCK,
|
|
50
|
+
Feature.SUI__SIGN_TRANSACTION_BLOCK,
|
|
51
|
+
Feature.SUI__SIGN_MESSAGE,
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
this._events.emit('change', { accounts: this.accounts });
|
|
55
|
+
return { accounts: this.accounts };
|
|
48
56
|
}
|
|
49
57
|
});
|
|
50
58
|
this.$connect = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -59,13 +67,20 @@ class OnekeySuiStandardWallet {
|
|
|
59
67
|
this._account = null;
|
|
60
68
|
this._events.all.clear();
|
|
61
69
|
});
|
|
62
|
-
this.$
|
|
63
|
-
return this.provider.
|
|
70
|
+
this.$signAndExecuteTransactionBlock = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return this.provider.signAndExecuteTransactionBlock(input);
|
|
72
|
+
});
|
|
73
|
+
this.$signTransactionBlock = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
return this.provider.signTransactionBlock(input);
|
|
75
|
+
});
|
|
76
|
+
this.$signMessage = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
return this.provider.signMessage(input);
|
|
64
78
|
});
|
|
65
79
|
this.provider = provider;
|
|
66
80
|
this._events = mitt();
|
|
67
81
|
this._account = null;
|
|
68
82
|
this.options = options;
|
|
83
|
+
this.subscribeEventFromBackend();
|
|
69
84
|
void this.$connected();
|
|
70
85
|
}
|
|
71
86
|
get name() {
|
|
@@ -78,8 +93,7 @@ class OnekeySuiStandardWallet {
|
|
|
78
93
|
return (((_a = this.options) === null || _a === void 0 ? void 0 : _a.logo) || '');
|
|
79
94
|
}
|
|
80
95
|
get chains() {
|
|
81
|
-
|
|
82
|
-
return SUI_CHAINS;
|
|
96
|
+
return [SUI_DEVNET_CHAIN, SUI_TESTNET_CHAIN];
|
|
83
97
|
}
|
|
84
98
|
get accounts() {
|
|
85
99
|
return this._account ? [this._account] : [];
|
|
@@ -98,19 +112,39 @@ class OnekeySuiStandardWallet {
|
|
|
98
112
|
version: '1.0.0',
|
|
99
113
|
on: this.$on,
|
|
100
114
|
},
|
|
101
|
-
[Feature.
|
|
102
|
-
version: '1.
|
|
103
|
-
|
|
115
|
+
[Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION_BLOCK]: {
|
|
116
|
+
version: '1.0.0',
|
|
117
|
+
signAndExecuteTransactionBlock: this.$signAndExecuteTransactionBlock,
|
|
118
|
+
},
|
|
119
|
+
[Feature.SUI__SIGN_TRANSACTION_BLOCK]: {
|
|
120
|
+
version: '1.0.0',
|
|
121
|
+
signTransactionBlock: this.$signTransactionBlock,
|
|
122
|
+
},
|
|
123
|
+
[Feature.SUI__SIGN_MESSAGE]: {
|
|
124
|
+
version: '1.0.0',
|
|
125
|
+
signMessage: this.$signMessage,
|
|
104
126
|
},
|
|
105
127
|
};
|
|
106
128
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return (_a = this.provider.getActiveChain()) !== null && _a !== void 0 ? _a : 'sui:unknown';
|
|
129
|
+
getActiveChain() {
|
|
130
|
+
return this.provider.getActiveChain();
|
|
110
131
|
}
|
|
111
132
|
$hasPermissions(permissions = ALL_PERMISSION_TYPES) {
|
|
112
133
|
return this.provider.hasPermissions(permissions);
|
|
113
134
|
}
|
|
135
|
+
subscribeEventFromBackend() {
|
|
136
|
+
this.provider.onNetworkChange((network) => {
|
|
137
|
+
if (!network)
|
|
138
|
+
return;
|
|
139
|
+
return this.handleNetworkSwitch({ network });
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
handleNetworkSwitch(payload) {
|
|
143
|
+
const { network } = payload;
|
|
144
|
+
this._events.emit('change', {
|
|
145
|
+
chains: [network],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
114
148
|
}
|
|
115
149
|
export function registerSuiWallet(provider, options) {
|
|
116
150
|
try {
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ProviderSui = void 0;
|
|
13
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
13
14
|
const extension_bridge_injected_1 = require("@onekeyfe/extension-bridge-injected");
|
|
14
15
|
const ProviderSuiBase_1 = require("./ProviderSuiBase");
|
|
15
16
|
const cross_inpage_provider_errors_1 = require("@onekeyfe/cross-inpage-provider-errors");
|
|
@@ -52,8 +53,8 @@ class ProviderSui extends ProviderSuiBase_1.ProviderSuiBase {
|
|
|
52
53
|
if (options.emit && this.isConnectionStatusChanged('connected')) {
|
|
53
54
|
this.connectionStatus = 'connected';
|
|
54
55
|
const address = account !== null && account !== void 0 ? account : null;
|
|
55
|
-
this.emit('connect', address);
|
|
56
|
-
this.emit('accountChanged', address);
|
|
56
|
+
this.emit('connect', address.address);
|
|
57
|
+
this.emit('accountChanged', address.address);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
_handleDisconnected(options = { emit: true }) {
|
|
@@ -65,13 +66,14 @@ class ProviderSui extends ProviderSuiBase_1.ProviderSuiBase {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
isAccountsChanged(account) {
|
|
68
|
-
|
|
69
|
+
var _a;
|
|
70
|
+
return (account === null || account === void 0 ? void 0 : account.address) !== ((_a = this._account) === null || _a === void 0 ? void 0 : _a.address);
|
|
69
71
|
}
|
|
70
72
|
// trigger by bridge account change event
|
|
71
73
|
_handleAccountChange(payload) {
|
|
72
74
|
const account = payload;
|
|
73
75
|
if (this.isAccountsChanged(account)) {
|
|
74
|
-
this.emit('accountChanged', account || null);
|
|
76
|
+
this.emit('accountChanged', account.address || null);
|
|
75
77
|
}
|
|
76
78
|
if (!account) {
|
|
77
79
|
this._handleDisconnected();
|
|
@@ -136,27 +138,27 @@ class ProviderSui extends ProviderSuiBase_1.ProviderSuiBase {
|
|
|
136
138
|
});
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
|
-
|
|
141
|
+
signAndExecuteTransactionBlock(input) {
|
|
140
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
143
|
return this._callBridge({
|
|
142
|
-
method: '
|
|
143
|
-
params: input,
|
|
144
|
+
method: 'signAndExecuteTransactionBlock',
|
|
145
|
+
params: Object.assign(Object.assign({}, input), { walletSerialize: JSON.stringify(input.account), blockSerialize: input.transactionBlock.serialize() }),
|
|
144
146
|
});
|
|
145
147
|
});
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
signTransactionBlock(input) {
|
|
148
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
151
|
return this._callBridge({
|
|
150
|
-
method: '
|
|
151
|
-
params:
|
|
152
|
+
method: 'signTransactionBlock',
|
|
153
|
+
params: Object.assign(Object.assign({}, input), { walletSerialize: JSON.stringify(input.account), blockSerialize: input.transactionBlock.serialize() }),
|
|
152
154
|
});
|
|
153
155
|
});
|
|
154
156
|
}
|
|
155
|
-
|
|
157
|
+
signMessage(input) {
|
|
156
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
159
|
return this._callBridge({
|
|
158
|
-
method: '
|
|
159
|
-
params:
|
|
160
|
+
method: 'signMessage',
|
|
161
|
+
params: Object.assign(Object.assign({}, input), { walletSerialize: JSON.stringify(input.account), messageSerialize: (0, utils_1.bytesToHex)(input.message) }),
|
|
160
162
|
});
|
|
161
163
|
});
|
|
162
164
|
}
|
|
@@ -13,16 +13,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerSuiWallet = void 0;
|
|
16
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
16
17
|
const mitt_1 = __importDefault(require("mitt"));
|
|
17
18
|
const wallet_standard_1 = require("@mysten/wallet-standard");
|
|
18
|
-
const wallet_standard_2 = require("@mysten/wallet-standard");
|
|
19
19
|
const types_1 = require("./types");
|
|
20
20
|
var Feature;
|
|
21
21
|
(function (Feature) {
|
|
22
22
|
Feature["STANDARD__CONNECT"] = "standard:connect";
|
|
23
23
|
Feature["STANDARD__DISCONNECT"] = "standard:disconnect";
|
|
24
24
|
Feature["STANDARD__EVENTS"] = "standard:events";
|
|
25
|
-
Feature["
|
|
25
|
+
Feature["SUI__SIGN_AND_EXECUTE_TRANSACTION_BLOCK"] = "sui:signAndExecuteTransactionBlock";
|
|
26
|
+
Feature["SUI__SIGN_TRANSACTION_BLOCK"] = "sui:signTransactionBlock";
|
|
27
|
+
Feature["SUI__SIGN_MESSAGE"] = "sui:signMessage";
|
|
26
28
|
})(Feature || (Feature = {}));
|
|
27
29
|
class OnekeySuiStandardWallet {
|
|
28
30
|
constructor(provider, options) {
|
|
@@ -33,24 +35,30 @@ class OnekeySuiStandardWallet {
|
|
|
33
35
|
return () => this._events.off(event, listener);
|
|
34
36
|
};
|
|
35
37
|
this.$connected = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const activeChain = yield this
|
|
38
|
+
const activeChain = yield this.getActiveChain();
|
|
37
39
|
if (!(yield this.$hasPermissions(['viewAccount']))) {
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
42
|
const accounts = yield this.provider.getAccounts();
|
|
41
|
-
const [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
const [account] = accounts;
|
|
44
|
+
const activateAccount = this._account;
|
|
45
|
+
if (activateAccount && activateAccount.address === account.address) {
|
|
46
|
+
return { accounts: this.accounts };
|
|
47
|
+
}
|
|
48
|
+
if (account) {
|
|
49
|
+
this._account = new wallet_standard_1.ReadonlyWalletAccount({
|
|
50
|
+
address: account.address,
|
|
51
|
+
publicKey: (0, utils_1.hexToBytes)(account.publicKey),
|
|
52
|
+
chains: activeChain ? [activeChain] : [],
|
|
53
|
+
features: [
|
|
54
|
+
Feature.STANDARD__CONNECT,
|
|
55
|
+
Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION_BLOCK,
|
|
56
|
+
Feature.SUI__SIGN_TRANSACTION_BLOCK,
|
|
57
|
+
Feature.SUI__SIGN_MESSAGE,
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
this._events.emit('change', { accounts: this.accounts });
|
|
61
|
+
return { accounts: this.accounts };
|
|
54
62
|
}
|
|
55
63
|
});
|
|
56
64
|
this.$connect = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -65,13 +73,20 @@ class OnekeySuiStandardWallet {
|
|
|
65
73
|
this._account = null;
|
|
66
74
|
this._events.all.clear();
|
|
67
75
|
});
|
|
68
|
-
this.$
|
|
69
|
-
return this.provider.
|
|
76
|
+
this.$signAndExecuteTransactionBlock = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
return this.provider.signAndExecuteTransactionBlock(input);
|
|
78
|
+
});
|
|
79
|
+
this.$signTransactionBlock = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
return this.provider.signTransactionBlock(input);
|
|
81
|
+
});
|
|
82
|
+
this.$signMessage = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
return this.provider.signMessage(input);
|
|
70
84
|
});
|
|
71
85
|
this.provider = provider;
|
|
72
86
|
this._events = (0, mitt_1.default)();
|
|
73
87
|
this._account = null;
|
|
74
88
|
this.options = options;
|
|
89
|
+
this.subscribeEventFromBackend();
|
|
75
90
|
void this.$connected();
|
|
76
91
|
}
|
|
77
92
|
get name() {
|
|
@@ -84,8 +99,7 @@ class OnekeySuiStandardWallet {
|
|
|
84
99
|
return (((_a = this.options) === null || _a === void 0 ? void 0 : _a.logo) || '');
|
|
85
100
|
}
|
|
86
101
|
get chains() {
|
|
87
|
-
|
|
88
|
-
return wallet_standard_2.SUI_CHAINS;
|
|
102
|
+
return [wallet_standard_1.SUI_DEVNET_CHAIN, wallet_standard_1.SUI_TESTNET_CHAIN];
|
|
89
103
|
}
|
|
90
104
|
get accounts() {
|
|
91
105
|
return this._account ? [this._account] : [];
|
|
@@ -104,19 +118,39 @@ class OnekeySuiStandardWallet {
|
|
|
104
118
|
version: '1.0.0',
|
|
105
119
|
on: this.$on,
|
|
106
120
|
},
|
|
107
|
-
[Feature.
|
|
108
|
-
version: '1.
|
|
109
|
-
|
|
121
|
+
[Feature.SUI__SIGN_AND_EXECUTE_TRANSACTION_BLOCK]: {
|
|
122
|
+
version: '1.0.0',
|
|
123
|
+
signAndExecuteTransactionBlock: this.$signAndExecuteTransactionBlock,
|
|
124
|
+
},
|
|
125
|
+
[Feature.SUI__SIGN_TRANSACTION_BLOCK]: {
|
|
126
|
+
version: '1.0.0',
|
|
127
|
+
signTransactionBlock: this.$signTransactionBlock,
|
|
128
|
+
},
|
|
129
|
+
[Feature.SUI__SIGN_MESSAGE]: {
|
|
130
|
+
version: '1.0.0',
|
|
131
|
+
signMessage: this.$signMessage,
|
|
110
132
|
},
|
|
111
133
|
};
|
|
112
134
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return (_a = this.provider.getActiveChain()) !== null && _a !== void 0 ? _a : 'sui:unknown';
|
|
135
|
+
getActiveChain() {
|
|
136
|
+
return this.provider.getActiveChain();
|
|
116
137
|
}
|
|
117
138
|
$hasPermissions(permissions = types_1.ALL_PERMISSION_TYPES) {
|
|
118
139
|
return this.provider.hasPermissions(permissions);
|
|
119
140
|
}
|
|
141
|
+
subscribeEventFromBackend() {
|
|
142
|
+
this.provider.onNetworkChange((network) => {
|
|
143
|
+
if (!network)
|
|
144
|
+
return;
|
|
145
|
+
return this.handleNetworkSwitch({ network });
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
handleNetworkSwitch(payload) {
|
|
149
|
+
const { network } = payload;
|
|
150
|
+
this._events.emit('change', {
|
|
151
|
+
chains: [network],
|
|
152
|
+
});
|
|
153
|
+
}
|
|
120
154
|
}
|
|
121
155
|
function registerSuiWallet(provider, options) {
|
|
122
156
|
try {
|
package/dist/types.d.ts
CHANGED
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.26",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@mysten/wallet-standard": "^0.
|
|
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.
|
|
31
|
+
"@mysten/wallet-standard": "^0.5.1",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.26",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.26",
|
|
34
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.26",
|
|
35
|
+
"@onekeyfe/extension-bridge-injected": "1.1.26",
|
|
36
36
|
"eth-rpc-errors": "^4.0.3",
|
|
37
37
|
"mitt": "^3.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "c5fecd176e00c399c4829f73b9da5e74e1f4e1b9"
|
|
40
40
|
}
|