@mysten/enoki-connect 0.0.0-experimental-20250423105740
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/CHANGELOG.md +7 -0
- package/README.md +5 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +26 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/wallet/index.d.ts +30 -0
- package/dist/cjs/wallet/index.js +315 -0
- package/dist/cjs/wallet/index.js.map +7 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/wallet/index.d.ts +30 -0
- package/dist/esm/wallet/index.js +290 -0
- package/dist/esm/wallet/index.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +52 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# `@mysten/enoki-connect`
|
|
2
|
+
|
|
3
|
+
> ⚠️ **Warning**: This package is in active development and should be used with caution. APIs are
|
|
4
|
+
> experimental and subject to breaking changes without notice. We recommend thoroughly testing any
|
|
5
|
+
> implementation before using in production environments.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EnokiConnectWallet, registerEnokiConnectWallet, type SupportedNetwork, } from './wallet/index.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
EnokiConnectWallet: () => import_wallet.EnokiConnectWallet,
|
|
22
|
+
registerEnokiConnectWallet: () => import_wallet.registerEnokiConnectWallet
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(index_exports);
|
|
25
|
+
var import_wallet = require("./wallet/index.js");
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n\tEnokiConnectWallet,\n\tregisterEnokiConnectWallet,\n\ttype SupportedNetwork,\n} from './wallet/index.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAIO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StandardConnectFeature, StandardDisconnectFeature, StandardEventsFeature, SuiSignAndExecuteTransactionFeature, SuiSignPersonalMessageFeature, SuiSignTransactionBlockFeature, SuiSignTransactionFeature, Wallet, WalletIcon } from '@mysten/wallet-standard';
|
|
2
|
+
import { ReadonlyWalletAccount } from '@mysten/wallet-standard';
|
|
3
|
+
export type SupportedNetwork = 'mainnet' | 'testnet';
|
|
4
|
+
export declare class EnokiConnectWallet implements Wallet {
|
|
5
|
+
#private;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
get name(): string;
|
|
8
|
+
get icon(): `data:image/svg+xml;base64,${string}` | `data:image/webp;base64,${string}` | `data:image/png;base64,${string}` | `data:image/gif;base64,${string}`;
|
|
9
|
+
get version(): "1.0.0";
|
|
10
|
+
get chains(): readonly ["sui:mainnet", "sui:testnet"];
|
|
11
|
+
get accounts(): ReadonlyWalletAccount[];
|
|
12
|
+
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SuiSignTransactionBlockFeature & SuiSignTransactionFeature & SuiSignPersonalMessageFeature & SuiSignAndExecuteTransactionFeature;
|
|
13
|
+
constructor({ publicAppSlug, walletName, dappName, hostOrigin, icon, network, }: {
|
|
14
|
+
publicAppSlug: string;
|
|
15
|
+
walletName: string;
|
|
16
|
+
dappName: string;
|
|
17
|
+
network: SupportedNetwork;
|
|
18
|
+
hostOrigin: string;
|
|
19
|
+
icon: WalletIcon;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export declare function registerEnokiConnectWallet({ publicAppSlug, dappName, network, enokiApiUrl, }: {
|
|
23
|
+
publicAppSlug: string;
|
|
24
|
+
dappName: string;
|
|
25
|
+
network?: SupportedNetwork;
|
|
26
|
+
enokiApiUrl?: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
wallet: EnokiConnectWallet;
|
|
29
|
+
unregister: () => void;
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
33
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
34
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
35
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
36
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
37
|
+
var wallet_exports = {};
|
|
38
|
+
__export(wallet_exports, {
|
|
39
|
+
EnokiConnectWallet: () => EnokiConnectWallet,
|
|
40
|
+
registerEnokiConnectWallet: () => registerEnokiConnectWallet
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(wallet_exports);
|
|
43
|
+
var import_utils = require("@mysten/sui/utils");
|
|
44
|
+
var import_wallet_standard = require("@mysten/wallet-standard");
|
|
45
|
+
var import_mitt = __toESM(require("mitt"));
|
|
46
|
+
var import_window_wallet_core = require("@mysten/window-wallet-core");
|
|
47
|
+
var _events, _accounts, _hostOrigin, _walletName, _dappName, _icon, _defaultChain, _publicAppSlug, _signTransactionBlock, _signTransaction, _signAndExecuteTransaction, _signPersonalMessage, _on, _EnokiConnectWallet_instances, setAccounts_fn, _connect, _disconnect, getSessionKey_fn, getStoredSession_fn, getNewPopupChannel_fn, getAccountsFromSession_fn;
|
|
48
|
+
const SUPPORTED_CHAINS = [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN];
|
|
49
|
+
const ACCOUNT_FEATURES = [
|
|
50
|
+
"sui:signTransaction",
|
|
51
|
+
"sui:signAndExecuteTransaction",
|
|
52
|
+
"sui:signPersonalMessage",
|
|
53
|
+
"sui:signTransactionBlock",
|
|
54
|
+
"sui:signAndExecuteTransactionBlock"
|
|
55
|
+
];
|
|
56
|
+
class EnokiConnectWallet {
|
|
57
|
+
constructor({
|
|
58
|
+
publicAppSlug,
|
|
59
|
+
walletName,
|
|
60
|
+
dappName,
|
|
61
|
+
hostOrigin,
|
|
62
|
+
icon,
|
|
63
|
+
network
|
|
64
|
+
}) {
|
|
65
|
+
__privateAdd(this, _EnokiConnectWallet_instances);
|
|
66
|
+
__privateAdd(this, _events);
|
|
67
|
+
__privateAdd(this, _accounts);
|
|
68
|
+
__privateAdd(this, _hostOrigin);
|
|
69
|
+
__privateAdd(this, _walletName);
|
|
70
|
+
__privateAdd(this, _dappName);
|
|
71
|
+
__privateAdd(this, _icon);
|
|
72
|
+
__privateAdd(this, _defaultChain);
|
|
73
|
+
__privateAdd(this, _publicAppSlug);
|
|
74
|
+
__privateAdd(this, _signTransactionBlock, async ({
|
|
75
|
+
transactionBlock,
|
|
76
|
+
account,
|
|
77
|
+
chain
|
|
78
|
+
}) => {
|
|
79
|
+
const popup = __privateMethod(this, _EnokiConnectWallet_instances, getNewPopupChannel_fn).call(this);
|
|
80
|
+
const response = await popup.send({
|
|
81
|
+
type: "sign-transaction",
|
|
82
|
+
chain,
|
|
83
|
+
transaction: await transactionBlock.toJSON(),
|
|
84
|
+
address: account.address,
|
|
85
|
+
session: __privateMethod(this, _EnokiConnectWallet_instances, getStoredSession_fn).call(this)
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
transactionBlockBytes: response.bytes,
|
|
89
|
+
signature: response.signature
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
__privateAdd(this, _signTransaction, async ({ transaction, account, chain }) => {
|
|
93
|
+
const popup = __privateMethod(this, _EnokiConnectWallet_instances, getNewPopupChannel_fn).call(this);
|
|
94
|
+
const response = await popup.send({
|
|
95
|
+
type: "sign-transaction",
|
|
96
|
+
chain,
|
|
97
|
+
transaction: await transaction.toJSON(),
|
|
98
|
+
address: account.address,
|
|
99
|
+
session: __privateMethod(this, _EnokiConnectWallet_instances, getStoredSession_fn).call(this)
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
bytes: response.bytes,
|
|
103
|
+
signature: response.signature
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
__privateAdd(this, _signAndExecuteTransaction, async ({
|
|
107
|
+
transaction,
|
|
108
|
+
account,
|
|
109
|
+
chain
|
|
110
|
+
}) => {
|
|
111
|
+
const popup = __privateMethod(this, _EnokiConnectWallet_instances, getNewPopupChannel_fn).call(this);
|
|
112
|
+
const response = await popup.send({
|
|
113
|
+
type: "sign-and-execute-transaction",
|
|
114
|
+
transaction: await transaction.toJSON(),
|
|
115
|
+
address: account.address,
|
|
116
|
+
chain,
|
|
117
|
+
session: __privateMethod(this, _EnokiConnectWallet_instances, getStoredSession_fn).call(this)
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
bytes: response.bytes,
|
|
121
|
+
signature: response.signature,
|
|
122
|
+
digest: response.digest,
|
|
123
|
+
effects: response.effects
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
__privateAdd(this, _signPersonalMessage, async ({ message, account, chain }) => {
|
|
127
|
+
const popup = __privateMethod(this, _EnokiConnectWallet_instances, getNewPopupChannel_fn).call(this);
|
|
128
|
+
const response = await popup.send({
|
|
129
|
+
type: "sign-personal-message",
|
|
130
|
+
chain: chain ?? __privateGet(this, _defaultChain),
|
|
131
|
+
message: (0, import_utils.toBase64)(message),
|
|
132
|
+
address: account.address,
|
|
133
|
+
session: __privateMethod(this, _EnokiConnectWallet_instances, getStoredSession_fn).call(this)
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
bytes: response.bytes,
|
|
137
|
+
signature: response.signature
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
__privateAdd(this, _on, (event, listener) => {
|
|
141
|
+
__privateGet(this, _events).on(event, listener);
|
|
142
|
+
return () => __privateGet(this, _events).off(event, listener);
|
|
143
|
+
});
|
|
144
|
+
__privateAdd(this, _connect, async (input) => {
|
|
145
|
+
if (input?.silent) {
|
|
146
|
+
try {
|
|
147
|
+
const session = __privateMethod(this, _EnokiConnectWallet_instances, getStoredSession_fn).call(this);
|
|
148
|
+
if (session) {
|
|
149
|
+
__privateMethod(this, _EnokiConnectWallet_instances, setAccounts_fn).call(this, session);
|
|
150
|
+
}
|
|
151
|
+
} catch (_e) {
|
|
152
|
+
}
|
|
153
|
+
return { accounts: this.accounts };
|
|
154
|
+
}
|
|
155
|
+
const popup = __privateMethod(this, _EnokiConnectWallet_instances, getNewPopupChannel_fn).call(this);
|
|
156
|
+
const response = await popup.send({
|
|
157
|
+
type: "connect"
|
|
158
|
+
});
|
|
159
|
+
__privateMethod(this, _EnokiConnectWallet_instances, setAccounts_fn).call(this, response.session);
|
|
160
|
+
return { accounts: this.accounts };
|
|
161
|
+
});
|
|
162
|
+
__privateAdd(this, _disconnect, async () => {
|
|
163
|
+
localStorage.removeItem(__privateMethod(this, _EnokiConnectWallet_instances, getSessionKey_fn).call(this));
|
|
164
|
+
__privateMethod(this, _EnokiConnectWallet_instances, setAccounts_fn).call(this);
|
|
165
|
+
});
|
|
166
|
+
__privateSet(this, _accounts, []);
|
|
167
|
+
__privateSet(this, _events, (0, import_mitt.default)());
|
|
168
|
+
__privateSet(this, _hostOrigin, hostOrigin);
|
|
169
|
+
__privateSet(this, _walletName, walletName);
|
|
170
|
+
__privateSet(this, _dappName, dappName);
|
|
171
|
+
__privateSet(this, _icon, icon);
|
|
172
|
+
__privateSet(this, _defaultChain, `sui:${network}`);
|
|
173
|
+
__privateSet(this, _publicAppSlug, publicAppSlug);
|
|
174
|
+
this.id = `enoki-connect-${publicAppSlug}`;
|
|
175
|
+
}
|
|
176
|
+
get name() {
|
|
177
|
+
return __privateGet(this, _walletName);
|
|
178
|
+
}
|
|
179
|
+
get icon() {
|
|
180
|
+
return __privateGet(this, _icon);
|
|
181
|
+
}
|
|
182
|
+
get version() {
|
|
183
|
+
return "1.0.0";
|
|
184
|
+
}
|
|
185
|
+
get chains() {
|
|
186
|
+
return SUPPORTED_CHAINS;
|
|
187
|
+
}
|
|
188
|
+
get accounts() {
|
|
189
|
+
return __privateGet(this, _accounts);
|
|
190
|
+
}
|
|
191
|
+
get features() {
|
|
192
|
+
return {
|
|
193
|
+
"standard:connect": {
|
|
194
|
+
version: "1.0.0",
|
|
195
|
+
connect: __privateGet(this, _connect)
|
|
196
|
+
},
|
|
197
|
+
"standard:disconnect": {
|
|
198
|
+
version: "1.0.0",
|
|
199
|
+
disconnect: __privateGet(this, _disconnect)
|
|
200
|
+
},
|
|
201
|
+
"standard:events": {
|
|
202
|
+
version: "1.0.0",
|
|
203
|
+
on: __privateGet(this, _on)
|
|
204
|
+
},
|
|
205
|
+
"sui:signTransactionBlock": {
|
|
206
|
+
version: "1.0.0",
|
|
207
|
+
signTransactionBlock: __privateGet(this, _signTransactionBlock)
|
|
208
|
+
},
|
|
209
|
+
"sui:signTransaction": {
|
|
210
|
+
version: "2.0.0",
|
|
211
|
+
signTransaction: __privateGet(this, _signTransaction)
|
|
212
|
+
},
|
|
213
|
+
"sui:signPersonalMessage": {
|
|
214
|
+
version: "1.1.0",
|
|
215
|
+
signPersonalMessage: __privateGet(this, _signPersonalMessage)
|
|
216
|
+
},
|
|
217
|
+
"sui:signAndExecuteTransaction": {
|
|
218
|
+
version: "2.0.0",
|
|
219
|
+
signAndExecuteTransaction: __privateGet(this, _signAndExecuteTransaction)
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
_events = new WeakMap();
|
|
225
|
+
_accounts = new WeakMap();
|
|
226
|
+
_hostOrigin = new WeakMap();
|
|
227
|
+
_walletName = new WeakMap();
|
|
228
|
+
_dappName = new WeakMap();
|
|
229
|
+
_icon = new WeakMap();
|
|
230
|
+
_defaultChain = new WeakMap();
|
|
231
|
+
_publicAppSlug = new WeakMap();
|
|
232
|
+
_signTransactionBlock = new WeakMap();
|
|
233
|
+
_signTransaction = new WeakMap();
|
|
234
|
+
_signAndExecuteTransaction = new WeakMap();
|
|
235
|
+
_signPersonalMessage = new WeakMap();
|
|
236
|
+
_on = new WeakMap();
|
|
237
|
+
_EnokiConnectWallet_instances = new WeakSet();
|
|
238
|
+
setAccounts_fn = function(session) {
|
|
239
|
+
if (session) {
|
|
240
|
+
__privateSet(this, _accounts, __privateMethod(this, _EnokiConnectWallet_instances, getAccountsFromSession_fn).call(this, session));
|
|
241
|
+
localStorage.setItem(__privateMethod(this, _EnokiConnectWallet_instances, getSessionKey_fn).call(this), session);
|
|
242
|
+
} else {
|
|
243
|
+
__privateSet(this, _accounts, []);
|
|
244
|
+
}
|
|
245
|
+
__privateGet(this, _events).emit("change", { accounts: this.accounts });
|
|
246
|
+
};
|
|
247
|
+
_connect = new WeakMap();
|
|
248
|
+
_disconnect = new WeakMap();
|
|
249
|
+
getSessionKey_fn = function() {
|
|
250
|
+
return `enoki-connect-${__privateGet(this, _publicAppSlug)}:session`;
|
|
251
|
+
};
|
|
252
|
+
getStoredSession_fn = function() {
|
|
253
|
+
const session = localStorage.getItem(__privateMethod(this, _EnokiConnectWallet_instances, getSessionKey_fn).call(this));
|
|
254
|
+
if (!session) {
|
|
255
|
+
throw new Error("No session found");
|
|
256
|
+
}
|
|
257
|
+
return session;
|
|
258
|
+
};
|
|
259
|
+
getNewPopupChannel_fn = function() {
|
|
260
|
+
return new import_window_wallet_core.DappPostMessageChannel({
|
|
261
|
+
appName: __privateGet(this, _dappName),
|
|
262
|
+
hostOrigin: __privateGet(this, _hostOrigin),
|
|
263
|
+
extraRequestOptions: {
|
|
264
|
+
publicAppSlug: __privateGet(this, _publicAppSlug)
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
getAccountsFromSession_fn = function(session) {
|
|
269
|
+
try {
|
|
270
|
+
const {
|
|
271
|
+
payload: { accounts }
|
|
272
|
+
} = (0, import_window_wallet_core.decodeJwtSession)(session);
|
|
273
|
+
return accounts.map(
|
|
274
|
+
(anAccount) => new import_wallet_standard.ReadonlyWalletAccount({
|
|
275
|
+
address: anAccount.address,
|
|
276
|
+
chains: SUPPORTED_CHAINS,
|
|
277
|
+
features: ACCOUNT_FEATURES,
|
|
278
|
+
publicKey: (0, import_utils.fromBase64)(anAccount.publicKey)
|
|
279
|
+
})
|
|
280
|
+
);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
async function getEnokiConnectMetadata(publicAppSlug, enokiApiUrl) {
|
|
286
|
+
const res = await fetch(new URL(`/connect/metadata/${publicAppSlug}`, enokiApiUrl));
|
|
287
|
+
if (!res.ok) {
|
|
288
|
+
throw new Error("Failed to fetch enoki connect metadata");
|
|
289
|
+
}
|
|
290
|
+
const { data } = await res.json();
|
|
291
|
+
return data;
|
|
292
|
+
}
|
|
293
|
+
async function registerEnokiConnectWallet({
|
|
294
|
+
publicAppSlug,
|
|
295
|
+
dappName,
|
|
296
|
+
network = "mainnet",
|
|
297
|
+
enokiApiUrl = "https://api.enoki.mystenlabs.com"
|
|
298
|
+
}) {
|
|
299
|
+
const data = await getEnokiConnectMetadata(publicAppSlug, enokiApiUrl);
|
|
300
|
+
const wallets = (0, import_wallet_standard.getWallets)();
|
|
301
|
+
const wallet = new EnokiConnectWallet({
|
|
302
|
+
walletName: data.name,
|
|
303
|
+
dappName,
|
|
304
|
+
hostOrigin: data.appUrl,
|
|
305
|
+
icon: data.logoUrl,
|
|
306
|
+
network,
|
|
307
|
+
publicAppSlug
|
|
308
|
+
});
|
|
309
|
+
const unregister = wallets.register(wallet);
|
|
310
|
+
return {
|
|
311
|
+
wallet,
|
|
312
|
+
unregister
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/wallet/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/sui/utils';\nimport type {\n\tIdentifierString,\n\tStandardConnectFeature,\n\tStandardConnectMethod,\n\tStandardDisconnectFeature,\n\tStandardDisconnectMethod,\n\tStandardEventsFeature,\n\tStandardEventsListeners,\n\tStandardEventsOnMethod,\n\tSuiSignAndExecuteTransactionFeature,\n\tSuiSignAndExecuteTransactionMethod,\n\tSuiSignPersonalMessageFeature,\n\tSuiSignPersonalMessageMethod,\n\tSuiSignTransactionBlockFeature,\n\tSuiSignTransactionBlockMethod,\n\tSuiSignTransactionFeature,\n\tSuiSignTransactionMethod,\n\tWallet,\n\tWalletIcon,\n} from '@mysten/wallet-standard';\nimport {\n\tgetWallets,\n\tReadonlyWalletAccount,\n\tSUI_MAINNET_CHAIN,\n\tSUI_TESTNET_CHAIN,\n} from '@mysten/wallet-standard';\nimport type { Emitter } from 'mitt';\nimport mitt from 'mitt';\nimport { DappPostMessageChannel, decodeJwtSession } from '@mysten/window-wallet-core';\n\nexport type SupportedNetwork = 'mainnet' | 'testnet';\n\ntype WalletEventsMap = {\n\t[E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];\n};\n\nconst SUPPORTED_CHAINS = [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN] as const;\nconst ACCOUNT_FEATURES = [\n\t'sui:signTransaction',\n\t'sui:signAndExecuteTransaction',\n\t'sui:signPersonalMessage',\n\t'sui:signTransactionBlock',\n\t'sui:signAndExecuteTransactionBlock',\n] as const;\n\nexport class EnokiConnectWallet implements Wallet {\n\treadonly id: string;\n\t#events: Emitter<WalletEventsMap>;\n\t#accounts: ReadonlyWalletAccount[];\n\t#hostOrigin: string;\n\t#walletName: string;\n\t#dappName: string;\n\t#icon: WalletIcon;\n\t#defaultChain: IdentifierString;\n\t#publicAppSlug: string;\n\n\tget name() {\n\t\treturn this.#walletName;\n\t}\n\n\tget icon() {\n\t\treturn this.#icon;\n\t}\n\n\tget version() {\n\t\treturn '1.0.0' as const;\n\t}\n\n\tget chains() {\n\t\treturn SUPPORTED_CHAINS;\n\t}\n\n\tget accounts() {\n\t\treturn this.#accounts;\n\t}\n\n\tget features(): StandardConnectFeature &\n\t\tStandardDisconnectFeature &\n\t\tStandardEventsFeature &\n\t\tSuiSignTransactionBlockFeature &\n\t\tSuiSignTransactionFeature &\n\t\tSuiSignPersonalMessageFeature &\n\t\tSuiSignAndExecuteTransactionFeature {\n\t\treturn {\n\t\t\t'standard:connect': {\n\t\t\t\tversion: '1.0.0',\n\t\t\t\tconnect: this.#connect,\n\t\t\t},\n\t\t\t'standard:disconnect': {\n\t\t\t\tversion: '1.0.0',\n\t\t\t\tdisconnect: this.#disconnect,\n\t\t\t},\n\t\t\t'standard:events': {\n\t\t\t\tversion: '1.0.0',\n\t\t\t\ton: this.#on,\n\t\t\t},\n\t\t\t'sui:signTransactionBlock': {\n\t\t\t\tversion: '1.0.0',\n\t\t\t\tsignTransactionBlock: this.#signTransactionBlock,\n\t\t\t},\n\t\t\t'sui:signTransaction': {\n\t\t\t\tversion: '2.0.0',\n\t\t\t\tsignTransaction: this.#signTransaction,\n\t\t\t},\n\t\t\t'sui:signPersonalMessage': {\n\t\t\t\tversion: '1.1.0',\n\t\t\t\tsignPersonalMessage: this.#signPersonalMessage,\n\t\t\t},\n\t\t\t'sui:signAndExecuteTransaction': {\n\t\t\t\tversion: '2.0.0',\n\t\t\t\tsignAndExecuteTransaction: this.#signAndExecuteTransaction,\n\t\t\t},\n\t\t};\n\t}\n\n\tconstructor({\n\t\tpublicAppSlug,\n\t\twalletName,\n\t\tdappName,\n\t\thostOrigin,\n\t\ticon,\n\t\tnetwork,\n\t}: {\n\t\tpublicAppSlug: string;\n\t\twalletName: string;\n\t\tdappName: string;\n\t\tnetwork: SupportedNetwork;\n\t\thostOrigin: string;\n\t\ticon: WalletIcon;\n\t}) {\n\t\tthis.#accounts = [];\n\t\tthis.#events = mitt();\n\t\tthis.#hostOrigin = hostOrigin;\n\t\tthis.#walletName = walletName;\n\t\tthis.#dappName = dappName;\n\t\tthis.#icon = icon;\n\t\tthis.#defaultChain = `sui:${network}`;\n\t\tthis.#publicAppSlug = publicAppSlug;\n\t\tthis.id = `enoki-connect-${publicAppSlug}`;\n\t}\n\n\t#signTransactionBlock: SuiSignTransactionBlockMethod = async ({\n\t\ttransactionBlock,\n\t\taccount,\n\t\tchain,\n\t}) => {\n\t\tconst popup = this.#getNewPopupChannel();\n\t\tconst response = await popup.send({\n\t\t\ttype: 'sign-transaction',\n\t\t\tchain,\n\t\t\ttransaction: await transactionBlock.toJSON(),\n\t\t\taddress: account.address,\n\t\t\tsession: this.#getStoredSession(),\n\t\t});\n\n\t\treturn {\n\t\t\ttransactionBlockBytes: response.bytes,\n\t\t\tsignature: response.signature,\n\t\t};\n\t};\n\n\t#signTransaction: SuiSignTransactionMethod = async ({ transaction, account, chain }) => {\n\t\tconst popup = this.#getNewPopupChannel();\n\t\tconst response = await popup.send({\n\t\t\ttype: 'sign-transaction',\n\t\t\tchain,\n\t\t\ttransaction: await transaction.toJSON(),\n\t\t\taddress: account.address,\n\t\t\tsession: this.#getStoredSession(),\n\t\t});\n\n\t\treturn {\n\t\t\tbytes: response.bytes,\n\t\t\tsignature: response.signature,\n\t\t};\n\t};\n\n\t#signAndExecuteTransaction: SuiSignAndExecuteTransactionMethod = async ({\n\t\ttransaction,\n\t\taccount,\n\t\tchain,\n\t}) => {\n\t\tconst popup = this.#getNewPopupChannel();\n\t\tconst response = await popup.send({\n\t\t\ttype: 'sign-and-execute-transaction',\n\t\t\ttransaction: await transaction.toJSON(),\n\t\t\taddress: account.address,\n\t\t\tchain,\n\t\t\tsession: this.#getStoredSession(),\n\t\t});\n\n\t\treturn {\n\t\t\tbytes: response.bytes,\n\t\t\tsignature: response.signature,\n\t\t\tdigest: response.digest,\n\t\t\teffects: response.effects,\n\t\t};\n\t};\n\n\t#signPersonalMessage: SuiSignPersonalMessageMethod = async ({ message, account, chain }) => {\n\t\tconst popup = this.#getNewPopupChannel();\n\t\tconst response = await popup.send({\n\t\t\ttype: 'sign-personal-message',\n\t\t\tchain: chain ?? this.#defaultChain,\n\t\t\tmessage: toBase64(message),\n\t\t\taddress: account.address,\n\t\t\tsession: this.#getStoredSession(),\n\t\t});\n\n\t\treturn {\n\t\t\tbytes: response.bytes,\n\t\t\tsignature: response.signature,\n\t\t};\n\t};\n\n\t#on: StandardEventsOnMethod = (event, listener) => {\n\t\tthis.#events.on(event, listener);\n\n\t\treturn () => this.#events.off(event, listener);\n\t};\n\n\t#setAccounts(session?: string) {\n\t\tif (session) {\n\t\t\tthis.#accounts = this.#getAccountsFromSession(session);\n\t\t\tlocalStorage.setItem(this.#getSessionKey(), session);\n\t\t} else {\n\t\t\tthis.#accounts = [];\n\t\t}\n\n\t\tthis.#events.emit('change', { accounts: this.accounts });\n\t}\n\n\t#connect: StandardConnectMethod = async (input) => {\n\t\tif (input?.silent) {\n\t\t\ttry {\n\t\t\t\tconst session = this.#getStoredSession();\n\n\t\t\t\tif (session) {\n\t\t\t\t\tthis.#setAccounts(session);\n\t\t\t\t}\n\t\t\t} catch (_e) {\n\t\t\t\t// ignore\n\t\t\t}\n\n\t\t\treturn { accounts: this.accounts };\n\t\t}\n\n\t\tconst popup = this.#getNewPopupChannel();\n\t\tconst response = await popup.send({\n\t\t\ttype: 'connect',\n\t\t});\n\n\t\tthis.#setAccounts(response.session);\n\n\t\treturn { accounts: this.accounts };\n\t};\n\n\t#disconnect: StandardDisconnectMethod = async () => {\n\t\tlocalStorage.removeItem(this.#getSessionKey());\n\t\tthis.#setAccounts();\n\t};\n\n\t#getSessionKey() {\n\t\treturn `enoki-connect-${this.#publicAppSlug}:session`;\n\t}\n\n\t#getStoredSession() {\n\t\tconst session = localStorage.getItem(this.#getSessionKey());\n\n\t\tif (!session) {\n\t\t\tthrow new Error('No session found');\n\t\t}\n\n\t\treturn session;\n\t}\n\n\t#getNewPopupChannel() {\n\t\treturn new DappPostMessageChannel({\n\t\t\tappName: this.#dappName,\n\t\t\thostOrigin: this.#hostOrigin,\n\t\t\textraRequestOptions: {\n\t\t\t\tpublicAppSlug: this.#publicAppSlug,\n\t\t\t},\n\t\t});\n\t}\n\n\t#getAccountsFromSession(session: string) {\n\t\ttry {\n\t\t\tconst {\n\t\t\t\tpayload: { accounts },\n\t\t\t} = decodeJwtSession(session);\n\n\t\t\treturn accounts.map(\n\t\t\t\t(anAccount) =>\n\t\t\t\t\tnew ReadonlyWalletAccount({\n\t\t\t\t\t\taddress: anAccount.address,\n\t\t\t\t\t\tchains: SUPPORTED_CHAINS,\n\t\t\t\t\t\tfeatures: ACCOUNT_FEATURES,\n\t\t\t\t\t\tpublicKey: fromBase64(anAccount.publicKey),\n\t\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\treturn [];\n\t\t}\n\t}\n}\n\ntype EnokiConnectMetadata = {\n\tname: string;\n\tlogoUrl: WalletIcon;\n\tappUrl: string;\n};\n\nasync function getEnokiConnectMetadata(publicAppSlug: string, enokiApiUrl: string) {\n\tconst res = await fetch(new URL(`/connect/metadata/${publicAppSlug}`, enokiApiUrl));\n\n\tif (!res.ok) {\n\t\tthrow new Error('Failed to fetch enoki connect metadata');\n\t}\n\n\tconst { data } = await res.json();\n\n\treturn data as EnokiConnectMetadata;\n}\n\nexport async function registerEnokiConnectWallet({\n\tpublicAppSlug,\n\tdappName,\n\tnetwork = 'mainnet',\n\tenokiApiUrl = 'https://api.enoki.mystenlabs.com',\n}: {\n\tpublicAppSlug: string;\n\tdappName: string;\n\tnetwork?: SupportedNetwork;\n\tenokiApiUrl?: string;\n}) {\n\tconst data = await getEnokiConnectMetadata(publicAppSlug, enokiApiUrl);\n\tconst wallets = getWallets();\n\tconst wallet = new EnokiConnectWallet({\n\t\twalletName: data.name,\n\t\tdappName,\n\t\thostOrigin: data.appUrl,\n\t\ticon: data.logoUrl,\n\t\tnetwork,\n\t\tpublicAppSlug,\n\t});\n\tconst unregister = wallets.register(wallet);\n\n\treturn {\n\t\twallet,\n\t\tunregister,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAqC;AAqBrC,6BAKO;AAEP,kBAAiB;AACjB,gCAAyD;AAhCzD;AAwCA,MAAM,mBAAmB,CAAC,0CAAmB,wCAAiB;AAC9D,MAAM,mBAAmB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAA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A,IACjB;AAAA,IACA,YAAY,KAAK;AAAA,IACjB,MAAM,KAAK;AAAA,IACX;AAAA,IACA;AAAA,EACD,CAAC;AACD,QAAM,aAAa,QAAQ,SAAS,MAAM;AAE1C,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": ["mitt"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EnokiConnectWallet, registerEnokiConnectWallet, type SupportedNetwork, } from './wallet/index.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n\tEnokiConnectWallet,\n\tregisterEnokiConnectWallet,\n\ttype SupportedNetwork,\n} from './wallet/index.js';\n"],
|
|
5
|
+
"mappings": "AAGA;AAAA,EACC;AAAA,EACA;AAAA,OAEM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StandardConnectFeature, StandardDisconnectFeature, StandardEventsFeature, SuiSignAndExecuteTransactionFeature, SuiSignPersonalMessageFeature, SuiSignTransactionBlockFeature, SuiSignTransactionFeature, Wallet, WalletIcon } from '@mysten/wallet-standard';
|
|
2
|
+
import { ReadonlyWalletAccount } from '@mysten/wallet-standard';
|
|
3
|
+
export type SupportedNetwork = 'mainnet' | 'testnet';
|
|
4
|
+
export declare class EnokiConnectWallet implements Wallet {
|
|
5
|
+
#private;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
get name(): string;
|
|
8
|
+
get icon(): `data:image/svg+xml;base64,${string}` | `data:image/webp;base64,${string}` | `data:image/png;base64,${string}` | `data:image/gif;base64,${string}`;
|
|
9
|
+
get version(): "1.0.0";
|
|
10
|
+
get chains(): readonly ["sui:mainnet", "sui:testnet"];
|
|
11
|
+
get accounts(): ReadonlyWalletAccount[];
|
|
12
|
+
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SuiSignTransactionBlockFeature & SuiSignTransactionFeature & SuiSignPersonalMessageFeature & SuiSignAndExecuteTransactionFeature;
|
|
13
|
+
constructor({ publicAppSlug, walletName, dappName, hostOrigin, icon, network, }: {
|
|
14
|
+
publicAppSlug: string;
|
|
15
|
+
walletName: string;
|
|
16
|
+
dappName: string;
|
|
17
|
+
network: SupportedNetwork;
|
|
18
|
+
hostOrigin: string;
|
|
19
|
+
icon: WalletIcon;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export declare function registerEnokiConnectWallet({ publicAppSlug, dappName, network, enokiApiUrl, }: {
|
|
23
|
+
publicAppSlug: string;
|
|
24
|
+
dappName: string;
|
|
25
|
+
network?: SupportedNetwork;
|
|
26
|
+
enokiApiUrl?: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
wallet: EnokiConnectWallet;
|
|
29
|
+
unregister: () => void;
|
|
30
|
+
}>;
|