@fastnear/wallet 0.9.9
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/cjs/connector.cjs +300 -0
- package/dist/cjs/connector.cjs.map +1 -0
- package/dist/cjs/index.cjs +63 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +131 -0
- package/dist/esm/connector.js +263 -0
- package/dist/esm/connector.js.map +1 -0
- package/dist/esm/index.d.ts +131 -0
- package/dist/esm/index.js +41 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/umd/browser.global.js +2776 -0
- package/dist/umd/browser.global.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNear Wallet Connector - CJS (@fastnear/wallet version 0.9.9) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/wallet/v/0.9.9 */
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var connector_exports = {};
|
|
23
|
+
__export(connector_exports, {
|
|
24
|
+
accountId: () => accountId,
|
|
25
|
+
availableWallets: () => availableWallets,
|
|
26
|
+
connect: () => connect,
|
|
27
|
+
disconnect: () => disconnect,
|
|
28
|
+
isConnected: () => isConnected,
|
|
29
|
+
onConnect: () => onConnect,
|
|
30
|
+
onDisconnect: () => onDisconnect,
|
|
31
|
+
registerDebugWallet: () => registerDebugWallet,
|
|
32
|
+
removeDebugWallet: () => removeDebugWallet,
|
|
33
|
+
reset: () => reset,
|
|
34
|
+
restore: () => restore,
|
|
35
|
+
selectWallet: () => selectWallet,
|
|
36
|
+
sendTransaction: () => sendTransaction,
|
|
37
|
+
sendTransactions: () => sendTransactions,
|
|
38
|
+
signMessage: () => signMessage,
|
|
39
|
+
switchNetwork: () => switchNetwork,
|
|
40
|
+
walletName: () => walletName
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(connector_exports);
|
|
43
|
+
var import_near_connect = require("@fastnear/near-connect");
|
|
44
|
+
function toConnectorAction(action) {
|
|
45
|
+
const { type, ...rest } = action;
|
|
46
|
+
switch (type) {
|
|
47
|
+
case "FunctionCall":
|
|
48
|
+
return { type: "FunctionCall", params: { methodName: rest.methodName, args: rest.args ?? {}, gas: rest.gas ?? "30000000000000", deposit: rest.deposit ?? "0" } };
|
|
49
|
+
case "Transfer":
|
|
50
|
+
return { type: "Transfer", params: { deposit: rest.deposit } };
|
|
51
|
+
case "Stake":
|
|
52
|
+
return { type: "Stake", params: { stake: rest.stake, publicKey: rest.publicKey } };
|
|
53
|
+
case "AddKey":
|
|
54
|
+
return { type: "AddKey", params: { publicKey: rest.publicKey, accessKey: rest.accessKey } };
|
|
55
|
+
case "DeleteKey":
|
|
56
|
+
return { type: "DeleteKey", params: { publicKey: rest.publicKey } };
|
|
57
|
+
case "DeleteAccount":
|
|
58
|
+
return { type: "DeleteAccount", params: { beneficiaryId: rest.beneficiaryId } };
|
|
59
|
+
case "CreateAccount":
|
|
60
|
+
return { type: "CreateAccount" };
|
|
61
|
+
case "DeployContract":
|
|
62
|
+
return { type: "DeployContract", params: { code: rest.code ?? rest.codeBase64 } };
|
|
63
|
+
default:
|
|
64
|
+
return action;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
__name(toConnectorAction, "toConnectorAction");
|
|
68
|
+
function toConnectorActions(actions) {
|
|
69
|
+
return actions.map(toConnectorAction);
|
|
70
|
+
}
|
|
71
|
+
__name(toConnectorActions, "toConnectorActions");
|
|
72
|
+
function isFastnearAction(action) {
|
|
73
|
+
return action.type && !action.params && action.type !== "CreateAccount";
|
|
74
|
+
}
|
|
75
|
+
__name(isFastnearAction, "isFastnearAction");
|
|
76
|
+
let connector = null;
|
|
77
|
+
let connectedWallet = null;
|
|
78
|
+
let currentAccountId = null;
|
|
79
|
+
let currentNetwork = "mainnet";
|
|
80
|
+
const connectListeners = [];
|
|
81
|
+
const disconnectListeners = [];
|
|
82
|
+
function getOrCreateConnector(options) {
|
|
83
|
+
if (connector) return connector;
|
|
84
|
+
const opts = {
|
|
85
|
+
network: options?.network ?? currentNetwork,
|
|
86
|
+
footerBranding: options?.footerBranding !== void 0 ? options.footerBranding : {
|
|
87
|
+
heading: "Powered by FastNear",
|
|
88
|
+
link: "https://fastnear.com",
|
|
89
|
+
linkText: "fastnear.com"
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
if (options?.contractId) {
|
|
93
|
+
opts.signIn = {
|
|
94
|
+
contractId: options.contractId,
|
|
95
|
+
methodNames: options.methodNames ?? []
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (options?.excludedWallets) {
|
|
99
|
+
opts.excludedWallets = options.excludedWallets;
|
|
100
|
+
}
|
|
101
|
+
if (options?.features) {
|
|
102
|
+
opts.features = options.features;
|
|
103
|
+
}
|
|
104
|
+
if (options?.manifest) {
|
|
105
|
+
opts.manifest = options.manifest;
|
|
106
|
+
}
|
|
107
|
+
connector = new import_near_connect.NearConnector(opts);
|
|
108
|
+
connector.on("wallet:signIn", (event) => {
|
|
109
|
+
const acct = event?.accounts?.[0];
|
|
110
|
+
if (acct) {
|
|
111
|
+
currentAccountId = acct.accountId;
|
|
112
|
+
const result = {
|
|
113
|
+
accountId: acct.accountId,
|
|
114
|
+
publicKey: acct.publicKey
|
|
115
|
+
};
|
|
116
|
+
for (const cb of connectListeners) {
|
|
117
|
+
try {
|
|
118
|
+
cb(result);
|
|
119
|
+
} catch (_) {
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
connector.on("wallet:signOut", () => {
|
|
125
|
+
connectedWallet = null;
|
|
126
|
+
currentAccountId = null;
|
|
127
|
+
for (const cb of disconnectListeners) {
|
|
128
|
+
try {
|
|
129
|
+
cb();
|
|
130
|
+
} catch (_) {
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return connector;
|
|
135
|
+
}
|
|
136
|
+
__name(getOrCreateConnector, "getOrCreateConnector");
|
|
137
|
+
async function restore(options) {
|
|
138
|
+
const c = getOrCreateConnector(options);
|
|
139
|
+
try {
|
|
140
|
+
const result = await c.getConnectedWallet();
|
|
141
|
+
if (result?.wallet && result?.accounts?.length) {
|
|
142
|
+
connectedWallet = result.wallet;
|
|
143
|
+
currentAccountId = result.accounts[0].accountId;
|
|
144
|
+
const connectResult = {
|
|
145
|
+
accountId: currentAccountId || "",
|
|
146
|
+
publicKey: result.accounts[0].publicKey
|
|
147
|
+
};
|
|
148
|
+
for (const cb of connectListeners) {
|
|
149
|
+
try {
|
|
150
|
+
cb(connectResult);
|
|
151
|
+
} catch (_) {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return connectResult;
|
|
155
|
+
}
|
|
156
|
+
} catch (_) {
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
__name(restore, "restore");
|
|
161
|
+
async function selectWallet(options) {
|
|
162
|
+
const c = getOrCreateConnector(options);
|
|
163
|
+
return c.selectWallet({ features: options?.features });
|
|
164
|
+
}
|
|
165
|
+
__name(selectWallet, "selectWallet");
|
|
166
|
+
async function availableWallets(options) {
|
|
167
|
+
const c = getOrCreateConnector(options);
|
|
168
|
+
await c.whenManifestLoaded.catch(() => {
|
|
169
|
+
});
|
|
170
|
+
return c.availableWallets.map((w) => w.manifest);
|
|
171
|
+
}
|
|
172
|
+
__name(availableWallets, "availableWallets");
|
|
173
|
+
async function registerDebugWallet(manifest, options) {
|
|
174
|
+
const c = getOrCreateConnector(options);
|
|
175
|
+
return c.registerDebugWallet(manifest);
|
|
176
|
+
}
|
|
177
|
+
__name(registerDebugWallet, "registerDebugWallet");
|
|
178
|
+
async function removeDebugWallet(id, options) {
|
|
179
|
+
const c = getOrCreateConnector(options);
|
|
180
|
+
return c.removeDebugWallet(id);
|
|
181
|
+
}
|
|
182
|
+
__name(removeDebugWallet, "removeDebugWallet");
|
|
183
|
+
async function switchNetwork(network, signInData) {
|
|
184
|
+
if (!connector) throw new Error("No connector initialized. Call connect() or restore() first.");
|
|
185
|
+
return connector.switchNetwork(network, signInData);
|
|
186
|
+
}
|
|
187
|
+
__name(switchNetwork, "switchNetwork");
|
|
188
|
+
async function connect(options) {
|
|
189
|
+
const c = getOrCreateConnector(options);
|
|
190
|
+
let wallet;
|
|
191
|
+
try {
|
|
192
|
+
wallet = await c.connect({ walletId: options?.walletId });
|
|
193
|
+
} catch (_) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
connectedWallet = wallet;
|
|
197
|
+
if (!currentAccountId) {
|
|
198
|
+
try {
|
|
199
|
+
const info = await c.getConnectedWallet();
|
|
200
|
+
if (info?.accounts?.length) {
|
|
201
|
+
currentAccountId = info.accounts[0].accountId;
|
|
202
|
+
}
|
|
203
|
+
} catch (_) {
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
accountId: currentAccountId ?? "",
|
|
208
|
+
publicKey: void 0
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
__name(connect, "connect");
|
|
212
|
+
async function disconnect() {
|
|
213
|
+
if (connector) {
|
|
214
|
+
await connector.disconnect(connectedWallet ?? void 0);
|
|
215
|
+
}
|
|
216
|
+
connectedWallet = null;
|
|
217
|
+
currentAccountId = null;
|
|
218
|
+
}
|
|
219
|
+
__name(disconnect, "disconnect");
|
|
220
|
+
async function sendTransaction(params) {
|
|
221
|
+
if (!connectedWallet) {
|
|
222
|
+
throw new Error("No wallet connected. Call connect() first.");
|
|
223
|
+
}
|
|
224
|
+
const actions = params.actions.some(isFastnearAction) ? toConnectorActions(params.actions) : params.actions;
|
|
225
|
+
return connectedWallet.signAndSendTransaction({
|
|
226
|
+
receiverId: params.receiverId,
|
|
227
|
+
actions,
|
|
228
|
+
signerId: params.signerId ?? currentAccountId ?? void 0
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
__name(sendTransaction, "sendTransaction");
|
|
232
|
+
async function sendTransactions(params) {
|
|
233
|
+
if (!connectedWallet) {
|
|
234
|
+
throw new Error("No wallet connected. Call connect() first.");
|
|
235
|
+
}
|
|
236
|
+
const transactions = params.transactions.map((tx) => ({
|
|
237
|
+
receiverId: tx.receiverId,
|
|
238
|
+
actions: tx.actions.some(isFastnearAction) ? toConnectorActions(tx.actions) : tx.actions
|
|
239
|
+
}));
|
|
240
|
+
return connectedWallet.signAndSendTransactions({
|
|
241
|
+
transactions,
|
|
242
|
+
signerId: params.signerId ?? currentAccountId ?? void 0
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
__name(sendTransactions, "sendTransactions");
|
|
246
|
+
async function signMessage(params) {
|
|
247
|
+
if (!connectedWallet) {
|
|
248
|
+
throw new Error("No wallet connected. Call connect() first.");
|
|
249
|
+
}
|
|
250
|
+
return connectedWallet.signMessage(params);
|
|
251
|
+
}
|
|
252
|
+
__name(signMessage, "signMessage");
|
|
253
|
+
function accountId() {
|
|
254
|
+
return currentAccountId;
|
|
255
|
+
}
|
|
256
|
+
__name(accountId, "accountId");
|
|
257
|
+
function isConnected() {
|
|
258
|
+
return currentAccountId !== null && connectedWallet !== null;
|
|
259
|
+
}
|
|
260
|
+
__name(isConnected, "isConnected");
|
|
261
|
+
function walletName() {
|
|
262
|
+
if (!connectedWallet) return null;
|
|
263
|
+
return connectedWallet.metadata?.name ?? null;
|
|
264
|
+
}
|
|
265
|
+
__name(walletName, "walletName");
|
|
266
|
+
function reset() {
|
|
267
|
+
connector = null;
|
|
268
|
+
connectedWallet = null;
|
|
269
|
+
currentAccountId = null;
|
|
270
|
+
}
|
|
271
|
+
__name(reset, "reset");
|
|
272
|
+
function onConnect(cb) {
|
|
273
|
+
connectListeners.push(cb);
|
|
274
|
+
}
|
|
275
|
+
__name(onConnect, "onConnect");
|
|
276
|
+
function onDisconnect(cb) {
|
|
277
|
+
disconnectListeners.push(cb);
|
|
278
|
+
}
|
|
279
|
+
__name(onDisconnect, "onDisconnect");
|
|
280
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
281
|
+
0 && (module.exports = {
|
|
282
|
+
accountId,
|
|
283
|
+
availableWallets,
|
|
284
|
+
connect,
|
|
285
|
+
disconnect,
|
|
286
|
+
isConnected,
|
|
287
|
+
onConnect,
|
|
288
|
+
onDisconnect,
|
|
289
|
+
registerDebugWallet,
|
|
290
|
+
removeDebugWallet,
|
|
291
|
+
reset,
|
|
292
|
+
restore,
|
|
293
|
+
selectWallet,
|
|
294
|
+
sendTransaction,
|
|
295
|
+
sendTransactions,
|
|
296
|
+
signMessage,
|
|
297
|
+
switchNetwork,
|
|
298
|
+
walletName
|
|
299
|
+
});
|
|
300
|
+
//# sourceMappingURL=connector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/connector.ts"],"sourcesContent":["import {\n NearConnector,\n type NearWalletBase,\n type SignAndSendTransactionParams,\n type SignAndSendTransactionsParams,\n type SignMessageParams,\n type ConnectorAction,\n type WalletManifest,\n} from \"@fastnear/near-connect\";\n\nexport type { WalletManifest };\n\ntype Network = \"mainnet\" | \"testnet\";\n\nexport interface ConnectOptions {\n network?: Network;\n contractId?: string;\n methodNames?: string[];\n excludedWallets?: string[];\n features?: Record<string, boolean>;\n manifest?: string | { wallets: WalletManifest[]; version: string };\n walletConnect?: {\n projectId: string;\n metadata?: {\n name?: string;\n description?: string;\n url?: string;\n icons?: string[];\n };\n };\n footerBranding?: {\n heading?: string;\n link?: string;\n linkText?: string;\n icon?: string;\n } | null;\n}\n\n/**\n * Convert a fastnear-style flat action to a @hot-labs/near-connect ConnectorAction.\n * Fastnear format: { type: \"FunctionCall\", methodName, args, gas, deposit }\n * Connector format: { type: \"FunctionCall\", params: { methodName, args, gas, deposit } }\n */\nfunction toConnectorAction(action: any): ConnectorAction {\n const { type, ...rest } = action;\n switch (type) {\n case \"FunctionCall\":\n return { type: \"FunctionCall\", params: { methodName: rest.methodName, args: rest.args ?? {}, gas: rest.gas ?? \"30000000000000\", deposit: rest.deposit ?? \"0\" } };\n case \"Transfer\":\n return { type: \"Transfer\", params: { deposit: rest.deposit } };\n case \"Stake\":\n return { type: \"Stake\", params: { stake: rest.stake, publicKey: rest.publicKey } };\n case \"AddKey\":\n return { type: \"AddKey\", params: { publicKey: rest.publicKey, accessKey: rest.accessKey } };\n case \"DeleteKey\":\n return { type: \"DeleteKey\", params: { publicKey: rest.publicKey } };\n case \"DeleteAccount\":\n return { type: \"DeleteAccount\", params: { beneficiaryId: rest.beneficiaryId } };\n case \"CreateAccount\":\n return { type: \"CreateAccount\" } as ConnectorAction;\n case \"DeployContract\":\n return { type: \"DeployContract\", params: { code: rest.code ?? rest.codeBase64 } } as ConnectorAction;\n default:\n // Pass through if already in connector format (has params)\n return action;\n }\n}\n\nfunction toConnectorActions(actions: any[]): ConnectorAction[] {\n return actions.map(toConnectorAction);\n}\n\n/**\n * Detect whether an action is in fastnear flat format (no params wrapper).\n */\nfunction isFastnearAction(action: any): boolean {\n return action.type && !action.params && action.type !== \"CreateAccount\";\n}\n\nexport interface ConnectResult {\n accountId: string;\n publicKey?: string;\n}\n\ntype ConnectCallback = (result: ConnectResult) => void;\ntype DisconnectCallback = () => void;\n\n// Module-level state\nlet connector: NearConnector | null = null;\nlet connectedWallet: NearWalletBase | null = null;\nlet currentAccountId: string | null = null;\nlet currentNetwork: Network = \"mainnet\";\n\nconst connectListeners: ConnectCallback[] = [];\nconst disconnectListeners: DisconnectCallback[] = [];\n\nfunction getOrCreateConnector(options?: ConnectOptions): NearConnector {\n if (connector) return connector;\n\n const opts: Record<string, any> = {\n network: options?.network ?? currentNetwork,\n footerBranding: options?.footerBranding !== undefined\n ? options.footerBranding\n : {\n heading: \"Powered by FastNear\",\n link: \"https://fastnear.com\",\n linkText: \"fastnear.com\",\n },\n };\n\n if (options?.contractId) {\n opts.signIn = {\n contractId: options.contractId,\n methodNames: options.methodNames ?? [],\n };\n }\n\n if (options?.excludedWallets) {\n opts.excludedWallets = options.excludedWallets;\n }\n\n if (options?.features) {\n opts.features = options.features;\n }\n\n if (options?.manifest) {\n opts.manifest = options.manifest;\n }\n\n connector = new NearConnector(opts);\n\n connector.on(\"wallet:signIn\", (event: any) => {\n const acct = event?.accounts?.[0];\n if (acct) {\n currentAccountId = acct.accountId;\n const result: ConnectResult = {\n accountId: acct.accountId,\n publicKey: acct.publicKey,\n };\n for (const cb of connectListeners) {\n try { cb(result); } catch (_) { /* listener error */ }\n }\n }\n });\n\n connector.on(\"wallet:signOut\", () => {\n connectedWallet = null;\n currentAccountId = null;\n for (const cb of disconnectListeners) {\n try { cb(); } catch (_) { /* listener error */ }\n }\n });\n\n return connector;\n}\n\n/**\n * Restore a previously connected wallet session.\n * Call this on page load to re-hydrate state from storage.\n */\nexport async function restore(options?: ConnectOptions): Promise<ConnectResult | null> {\n const c = getOrCreateConnector(options);\n try {\n const result = await c.getConnectedWallet();\n if (result?.wallet && result?.accounts?.length) {\n connectedWallet = result.wallet;\n currentAccountId = result.accounts[0].accountId;\n const connectResult: ConnectResult = {\n accountId: currentAccountId || '',\n publicKey: result.accounts[0].publicKey,\n };\n for (const cb of connectListeners) {\n try { cb(connectResult); } catch (_) { /* listener error */ }\n }\n return connectResult;\n }\n } catch (_) {\n // No previous session\n }\n return null;\n}\n\n/**\n * Show the wallet picker popup without signing in.\n * Returns the selected wallet ID string.\n */\nexport async function selectWallet(\n options?: ConnectOptions & { features?: Partial<Record<string, boolean>> }\n): Promise<string> {\n const c = getOrCreateConnector(options);\n return c.selectWallet({ features: options?.features });\n}\n\n/**\n * Return the list of available wallet manifests so apps can build custom UI.\n */\nexport async function availableWallets(options?: ConnectOptions): Promise<WalletManifest[]> {\n const c = getOrCreateConnector(options);\n await c.whenManifestLoaded.catch(() => {});\n return c.availableWallets.map((w: any) => w.manifest);\n}\n\n/**\n * Register a debug wallet for developer tooling.\n */\nexport async function registerDebugWallet(\n manifest: string | WalletManifest,\n options?: ConnectOptions\n): Promise<WalletManifest> {\n const c = getOrCreateConnector(options);\n return c.registerDebugWallet(manifest);\n}\n\n/**\n * Remove a previously registered debug wallet.\n */\nexport async function removeDebugWallet(\n id: string,\n options?: ConnectOptions\n): Promise<void> {\n const c = getOrCreateConnector(options);\n return c.removeDebugWallet(id);\n}\n\n/**\n * Switch the connector to a different network.\n * Requires an existing connector (call connect() or restore() first).\n */\nexport async function switchNetwork(\n network: Network,\n signInData?: { contractId?: string; methodNames?: string[] }\n): Promise<void> {\n if (!connector) throw new Error(\"No connector initialized. Call connect() or restore() first.\");\n return connector.switchNetwork(network, signInData);\n}\n\n/**\n * Show the wallet picker popup and connect.\n * Returns the connected account info.\n * If walletId is provided, connects directly to that wallet without showing the picker.\n */\nexport async function connect(\n options?: ConnectOptions & { walletId?: string }\n): Promise<ConnectResult | null> {\n const c = getOrCreateConnector(options);\n let wallet;\n try {\n wallet = await c.connect({ walletId: options?.walletId });\n } catch (_) {\n // User closed the modal or wallet rejected\n return null;\n }\n connectedWallet = wallet;\n\n // Account info is set by the wallet:signIn event handler,\n // but if it hasn't fired yet, try to get it from the connector.\n if (!currentAccountId) {\n try {\n const info = await c.getConnectedWallet();\n if (info?.accounts?.length) {\n currentAccountId = info.accounts[0].accountId;\n }\n } catch (_) {\n // ignore\n }\n }\n\n return {\n accountId: currentAccountId ?? \"\",\n publicKey: undefined,\n };\n}\n\n/**\n * Disconnect the current wallet session.\n */\nexport async function disconnect(): Promise<void> {\n if (connector) {\n await connector.disconnect(connectedWallet ?? undefined);\n }\n connectedWallet = null;\n currentAccountId = null;\n}\n\n/**\n * Sign and send a single transaction via the connected wallet.\n * Accepts both fastnear-style flat actions and @hot-labs/near-connect ConnectorActions.\n */\nexport async function sendTransaction(params: SignAndSendTransactionParams | { receiverId: string; actions: any[]; signerId?: string }): Promise<any> {\n if (!connectedWallet) {\n throw new Error(\"No wallet connected. Call connect() first.\");\n }\n const actions = params.actions.some(isFastnearAction)\n ? toConnectorActions(params.actions)\n : params.actions;\n return connectedWallet.signAndSendTransaction({\n receiverId: params.receiverId,\n actions,\n signerId: params.signerId ?? currentAccountId ?? undefined,\n });\n}\n\n/**\n * Sign and send multiple transactions via the connected wallet.\n * Accepts both fastnear-style flat actions and @hot-labs/near-connect ConnectorActions.\n */\nexport async function sendTransactions(params: SignAndSendTransactionsParams | { transactions: Array<{ receiverId: string; actions: any[] }>; signerId?: string }): Promise<any> {\n if (!connectedWallet) {\n throw new Error(\"No wallet connected. Call connect() first.\");\n }\n const transactions = (params as any).transactions.map((tx: any) => ({\n receiverId: tx.receiverId,\n actions: tx.actions.some(isFastnearAction)\n ? toConnectorActions(tx.actions)\n : tx.actions,\n }));\n return connectedWallet.signAndSendTransactions({\n transactions,\n signerId: params.signerId ?? currentAccountId ?? undefined,\n });\n}\n\n/**\n * Sign a message (NEP-413) via the connected wallet.\n */\nexport async function signMessage(params: SignMessageParams): Promise<any> {\n if (!connectedWallet) {\n throw new Error(\"No wallet connected. Call connect() first.\");\n }\n return connectedWallet.signMessage(params);\n}\n\n/**\n * Get the current connected account ID, or null if not connected.\n */\nexport function accountId(): string | null {\n return currentAccountId;\n}\n\n/**\n * Check whether a wallet is currently connected.\n */\nexport function isConnected(): boolean {\n return currentAccountId !== null && connectedWallet !== null;\n}\n\n/**\n * Get the name of the connected wallet (e.g. \"MyNearWallet\").\n */\nexport function walletName(): string | null {\n if (!connectedWallet) return null;\n return (connectedWallet as any).metadata?.name ?? null;\n}\n\n/**\n * Destroy the current connector so the next connect() or restore() creates a new one\n * with fresh options (e.g. different excludedWallets or features).\n */\nexport function reset(): void {\n connector = null;\n connectedWallet = null;\n currentAccountId = null;\n}\n\n/**\n * Register a callback for when a wallet connects.\n */\nexport function onConnect(cb: ConnectCallback): void {\n connectListeners.push(cb);\n}\n\n/**\n * Register a callback for when a wallet disconnects.\n */\nexport function onDisconnect(cb: DisconnectCallback): void {\n disconnectListeners.push(cb);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAQO;AAmCP,SAAS,kBAAkB,QAA8B;AACvD,QAAM,EAAE,MAAM,GAAG,KAAK,IAAI;AAC1B,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,EAAE,MAAM,gBAAgB,QAAQ,EAAE,YAAY,KAAK,YAAY,MAAM,KAAK,QAAQ,CAAC,GAAG,KAAK,KAAK,OAAO,kBAAkB,SAAS,KAAK,WAAW,IAAI,EAAE;AAAA,IACjK,KAAK;AACH,aAAO,EAAE,MAAM,YAAY,QAAQ,EAAE,SAAS,KAAK,QAAQ,EAAE;AAAA,IAC/D,KAAK;AACH,aAAO,EAAE,MAAM,SAAS,QAAQ,EAAE,OAAO,KAAK,OAAO,WAAW,KAAK,UAAU,EAAE;AAAA,IACnF,KAAK;AACH,aAAO,EAAE,MAAM,UAAU,QAAQ,EAA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
|
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNear Wallet Connector - CJS (@fastnear/wallet version 0.9.9) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/wallet/v/0.9.9 */
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
accountId: () => import_connector.accountId,
|
|
24
|
+
availableWallets: () => import_connector.availableWallets,
|
|
25
|
+
connect: () => import_connector.connect,
|
|
26
|
+
disconnect: () => import_connector.disconnect,
|
|
27
|
+
isConnected: () => import_connector.isConnected,
|
|
28
|
+
onConnect: () => import_connector.onConnect,
|
|
29
|
+
onDisconnect: () => import_connector.onDisconnect,
|
|
30
|
+
registerDebugWallet: () => import_connector.registerDebugWallet,
|
|
31
|
+
removeDebugWallet: () => import_connector.removeDebugWallet,
|
|
32
|
+
reset: () => import_connector.reset,
|
|
33
|
+
restore: () => import_connector.restore,
|
|
34
|
+
selectWallet: () => import_connector.selectWallet,
|
|
35
|
+
sendTransaction: () => import_connector.sendTransaction,
|
|
36
|
+
sendTransactions: () => import_connector.sendTransactions,
|
|
37
|
+
signMessage: () => import_connector.signMessage,
|
|
38
|
+
switchNetwork: () => import_connector.switchNetwork,
|
|
39
|
+
walletName: () => import_connector.walletName
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
|
+
var import_connector = require("./connector");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
accountId,
|
|
46
|
+
availableWallets,
|
|
47
|
+
connect,
|
|
48
|
+
disconnect,
|
|
49
|
+
isConnected,
|
|
50
|
+
onConnect,
|
|
51
|
+
onDisconnect,
|
|
52
|
+
registerDebugWallet,
|
|
53
|
+
removeDebugWallet,
|
|
54
|
+
reset,
|
|
55
|
+
restore,
|
|
56
|
+
selectWallet,
|
|
57
|
+
sendTransaction,
|
|
58
|
+
sendTransactions,
|
|
59
|
+
signMessage,
|
|
60
|
+
switchNetwork,
|
|
61
|
+
walletName
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n connect,\n disconnect,\n restore,\n reset,\n sendTransaction,\n sendTransactions,\n signMessage,\n accountId,\n isConnected,\n walletName,\n onConnect,\n onDisconnect,\n selectWallet,\n availableWallets,\n registerDebugWallet,\n removeDebugWallet,\n switchNetwork,\n} from \"./connector\";\n\nexport type { ConnectOptions, ConnectResult, WalletManifest } from \"./connector\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAkBO;","names":[]}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { WalletManifest, SignAndSendTransactionParams, SignAndSendTransactionsParams, SignMessageParams } from '@fastnear/near-connect';
|
|
2
|
+
export { WalletManifest } from '@fastnear/near-connect';
|
|
3
|
+
|
|
4
|
+
type Network = "mainnet" | "testnet";
|
|
5
|
+
interface ConnectOptions {
|
|
6
|
+
network?: Network;
|
|
7
|
+
contractId?: string;
|
|
8
|
+
methodNames?: string[];
|
|
9
|
+
excludedWallets?: string[];
|
|
10
|
+
features?: Record<string, boolean>;
|
|
11
|
+
manifest?: string | {
|
|
12
|
+
wallets: WalletManifest[];
|
|
13
|
+
version: string;
|
|
14
|
+
};
|
|
15
|
+
walletConnect?: {
|
|
16
|
+
projectId: string;
|
|
17
|
+
metadata?: {
|
|
18
|
+
name?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
icons?: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
footerBranding?: {
|
|
25
|
+
heading?: string;
|
|
26
|
+
link?: string;
|
|
27
|
+
linkText?: string;
|
|
28
|
+
icon?: string;
|
|
29
|
+
} | null;
|
|
30
|
+
}
|
|
31
|
+
interface ConnectResult {
|
|
32
|
+
accountId: string;
|
|
33
|
+
publicKey?: string;
|
|
34
|
+
}
|
|
35
|
+
type ConnectCallback = (result: ConnectResult) => void;
|
|
36
|
+
type DisconnectCallback = () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Restore a previously connected wallet session.
|
|
39
|
+
* Call this on page load to re-hydrate state from storage.
|
|
40
|
+
*/
|
|
41
|
+
declare function restore(options?: ConnectOptions): Promise<ConnectResult | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Show the wallet picker popup without signing in.
|
|
44
|
+
* Returns the selected wallet ID string.
|
|
45
|
+
*/
|
|
46
|
+
declare function selectWallet(options?: ConnectOptions & {
|
|
47
|
+
features?: Partial<Record<string, boolean>>;
|
|
48
|
+
}): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Return the list of available wallet manifests so apps can build custom UI.
|
|
51
|
+
*/
|
|
52
|
+
declare function availableWallets(options?: ConnectOptions): Promise<WalletManifest[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Register a debug wallet for developer tooling.
|
|
55
|
+
*/
|
|
56
|
+
declare function registerDebugWallet(manifest: string | WalletManifest, options?: ConnectOptions): Promise<WalletManifest>;
|
|
57
|
+
/**
|
|
58
|
+
* Remove a previously registered debug wallet.
|
|
59
|
+
*/
|
|
60
|
+
declare function removeDebugWallet(id: string, options?: ConnectOptions): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Switch the connector to a different network.
|
|
63
|
+
* Requires an existing connector (call connect() or restore() first).
|
|
64
|
+
*/
|
|
65
|
+
declare function switchNetwork(network: Network, signInData?: {
|
|
66
|
+
contractId?: string;
|
|
67
|
+
methodNames?: string[];
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Show the wallet picker popup and connect.
|
|
71
|
+
* Returns the connected account info.
|
|
72
|
+
* If walletId is provided, connects directly to that wallet without showing the picker.
|
|
73
|
+
*/
|
|
74
|
+
declare function connect(options?: ConnectOptions & {
|
|
75
|
+
walletId?: string;
|
|
76
|
+
}): Promise<ConnectResult | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Disconnect the current wallet session.
|
|
79
|
+
*/
|
|
80
|
+
declare function disconnect(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Sign and send a single transaction via the connected wallet.
|
|
83
|
+
* Accepts both fastnear-style flat actions and @hot-labs/near-connect ConnectorActions.
|
|
84
|
+
*/
|
|
85
|
+
declare function sendTransaction(params: SignAndSendTransactionParams | {
|
|
86
|
+
receiverId: string;
|
|
87
|
+
actions: any[];
|
|
88
|
+
signerId?: string;
|
|
89
|
+
}): Promise<any>;
|
|
90
|
+
/**
|
|
91
|
+
* Sign and send multiple transactions via the connected wallet.
|
|
92
|
+
* Accepts both fastnear-style flat actions and @hot-labs/near-connect ConnectorActions.
|
|
93
|
+
*/
|
|
94
|
+
declare function sendTransactions(params: SignAndSendTransactionsParams | {
|
|
95
|
+
transactions: Array<{
|
|
96
|
+
receiverId: string;
|
|
97
|
+
actions: any[];
|
|
98
|
+
}>;
|
|
99
|
+
signerId?: string;
|
|
100
|
+
}): Promise<any>;
|
|
101
|
+
/**
|
|
102
|
+
* Sign a message (NEP-413) via the connected wallet.
|
|
103
|
+
*/
|
|
104
|
+
declare function signMessage(params: SignMessageParams): Promise<any>;
|
|
105
|
+
/**
|
|
106
|
+
* Get the current connected account ID, or null if not connected.
|
|
107
|
+
*/
|
|
108
|
+
declare function accountId(): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Check whether a wallet is currently connected.
|
|
111
|
+
*/
|
|
112
|
+
declare function isConnected(): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Get the name of the connected wallet (e.g. "MyNearWallet").
|
|
115
|
+
*/
|
|
116
|
+
declare function walletName(): string | null;
|
|
117
|
+
/**
|
|
118
|
+
* Destroy the current connector so the next connect() or restore() creates a new one
|
|
119
|
+
* with fresh options (e.g. different excludedWallets or features).
|
|
120
|
+
*/
|
|
121
|
+
declare function reset(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Register a callback for when a wallet connects.
|
|
124
|
+
*/
|
|
125
|
+
declare function onConnect(cb: ConnectCallback): void;
|
|
126
|
+
/**
|
|
127
|
+
* Register a callback for when a wallet disconnects.
|
|
128
|
+
*/
|
|
129
|
+
declare function onDisconnect(cb: DisconnectCallback): void;
|
|
130
|
+
|
|
131
|
+
export { type ConnectOptions, type ConnectResult, accountId, availableWallets, connect, disconnect, isConnected, onConnect, onDisconnect, registerDebugWallet, removeDebugWallet, reset, restore, selectWallet, sendTransaction, sendTransactions, signMessage, switchNetwork, walletName };
|