FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

202
node_modules/@solana/wallet-adapter-base/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

5
node_modules/@solana/wallet-adapter-base/README.md generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# `@solana/wallet-adapter-base`
<!-- @TODO -->
Coming soon.

View File

@@ -0,0 +1,134 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseWalletAdapter = exports.WalletReadyState = exports.EventEmitter = void 0;
exports.scopePollingDetectionStrategy = scopePollingDetectionStrategy;
exports.isIosAndRedirectable = isIosAndRedirectable;
const eventemitter3_1 = __importDefault(require("eventemitter3"));
exports.EventEmitter = eventemitter3_1.default;
const errors_js_1 = require("./errors.js");
/**
* A wallet's readiness describes a series of states that the wallet can be in,
* depending on what kind of wallet it is. An installable wallet (eg. a browser
* extension like Phantom) might be `Installed` if we've found the Phantom API
* in the global scope, or `NotDetected` otherwise. A loadable, zero-install
* runtime (eg. Torus Wallet) might simply signal that it's `Loadable`. Use this
* metadata to personalize the wallet list for each user (eg. to show their
* installed wallets first).
*/
var WalletReadyState;
(function (WalletReadyState) {
/**
* User-installable wallets can typically be detected by scanning for an API
* that they've injected into the global context. If such an API is present,
* we consider the wallet to have been installed.
*/
WalletReadyState["Installed"] = "Installed";
WalletReadyState["NotDetected"] = "NotDetected";
/**
* Loadable wallets are always available to you. Since you can load them at
* any time, it's meaningless to say that they have been detected.
*/
WalletReadyState["Loadable"] = "Loadable";
/**
* If a wallet is not supported on a given platform (eg. server-rendering, or
* mobile) then it will stay in the `Unsupported` state.
*/
WalletReadyState["Unsupported"] = "Unsupported";
})(WalletReadyState || (exports.WalletReadyState = WalletReadyState = {}));
class BaseWalletAdapter extends eventemitter3_1.default {
get connected() {
return !!this.publicKey;
}
autoConnect() {
return __awaiter(this, void 0, void 0, function* () {
yield this.connect();
});
}
prepareTransaction(transaction_1, connection_1) {
return __awaiter(this, arguments, void 0, function* (transaction, connection, options = {}) {
const publicKey = this.publicKey;
if (!publicKey)
throw new errors_js_1.WalletNotConnectedError();
transaction.feePayer = transaction.feePayer || publicKey;
transaction.recentBlockhash =
transaction.recentBlockhash ||
(yield connection.getLatestBlockhash({
commitment: options.preflightCommitment,
minContextSlot: options.minContextSlot,
})).blockhash;
return transaction;
});
}
}
exports.BaseWalletAdapter = BaseWalletAdapter;
function scopePollingDetectionStrategy(detect) {
// Early return when server-side rendering
if (typeof window === 'undefined' || typeof document === 'undefined')
return;
const disposers = [];
function detectAndDispose() {
const detected = detect();
if (detected) {
for (const dispose of disposers) {
dispose();
}
}
}
// Strategy #1: Try detecting every second.
const interval =
// TODO: #334 Replace with idle callback strategy.
setInterval(detectAndDispose, 1000);
disposers.push(() => clearInterval(interval));
// Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.
if (
// Implies that `DOMContentLoaded` has not yet fired.
document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', detectAndDispose, { once: true });
disposers.push(() => document.removeEventListener('DOMContentLoaded', detectAndDispose));
}
// Strategy #3: Detect after the `window` has fully loaded.
if (
// If the `complete` state has been reached, we're too late.
document.readyState !== 'complete') {
window.addEventListener('load', detectAndDispose, { once: true });
disposers.push(() => window.removeEventListener('load', detectAndDispose));
}
// Strategy #4: Detect synchronously, now.
detectAndDispose();
}
/**
* Users on iOS can be redirected into a wallet's in-app browser automatically,
* if that wallet has a universal link configured to do so
* But should not be redirected from within a webview, eg. if they're already
* inside a wallet's browser
* This function can be used to identify users who are on iOS and can be redirected
*
* @returns true if the user can be redirected
*/
function isIosAndRedirectable() {
// SSR: return false
if (!navigator)
return false;
const userAgent = navigator.userAgent.toLowerCase();
// if on iOS the user agent will contain either iPhone or iPad
// caveat: if requesting desktop site then this won't work
const isIos = userAgent.includes('iphone') || userAgent.includes('ipad');
// if in a webview then it will not include Safari
// note that other iOS browsers also include Safari
// so we will redirect only if Safari is also included
const isSafari = userAgent.includes('safari');
return isIos && isSafari;
}
//# sourceMappingURL=adapter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA4HA,sEAyCC;AAWD,oDAgBC;AA/LD,kEAAyC;AAIhC,uBAJF,uBAAY,CAIE;AAHrB,2CAAwE;AA0CxE;;;;;;;;GAQG;AACH,IAAY,gBAkBX;AAlBD,WAAY,gBAAgB;IACxB;;;;OAIG;IACH,2CAAuB,CAAA;IACvB,+CAA2B,CAAA;IAC3B;;;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AQ,CAAC,CAAC;IAE9C,OAAO,KAAK,IAAI,QAAQ,CAAC;AAC7B,CAAC"}

View File

@@ -0,0 +1,131 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletWindowClosedError = exports.WalletWindowBlockedError = exports.WalletTimeoutError = exports.WalletSignInError = exports.WalletSignMessageError = exports.WalletSignTransactionError = exports.WalletSendTransactionError = exports.WalletNotConnectedError = exports.WalletKeypairError = exports.WalletPublicKeyError = exports.WalletAccountError = exports.WalletDisconnectionError = exports.WalletDisconnectedError = exports.WalletConnectionError = exports.WalletConfigError = exports.WalletLoadError = exports.WalletNotReadyError = exports.WalletError = void 0;
class WalletError extends Error {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
constructor(message, error) {
super(message);
this.error = error;
}
}
exports.WalletError = WalletError;
class WalletNotReadyError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletNotReadyError';
}
}
exports.WalletNotReadyError = WalletNotReadyError;
class WalletLoadError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletLoadError';
}
}
exports.WalletLoadError = WalletLoadError;
class WalletConfigError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletConfigError';
}
}
exports.WalletConfigError = WalletConfigError;
class WalletConnectionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletConnectionError';
}
}
exports.WalletConnectionError = WalletConnectionError;
class WalletDisconnectedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletDisconnectedError';
}
}
exports.WalletDisconnectedError = WalletDisconnectedError;
class WalletDisconnectionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletDisconnectionError';
}
}
exports.WalletDisconnectionError = WalletDisconnectionError;
class WalletAccountError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletAccountError';
}
}
exports.WalletAccountError = WalletAccountError;
class WalletPublicKeyError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletPublicKeyError';
}
}
exports.WalletPublicKeyError = WalletPublicKeyError;
class WalletKeypairError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletKeypairError';
}
}
exports.WalletKeypairError = WalletKeypairError;
class WalletNotConnectedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletNotConnectedError';
}
}
exports.WalletNotConnectedError = WalletNotConnectedError;
class WalletSendTransactionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSendTransactionError';
}
}
exports.WalletSendTransactionError = WalletSendTransactionError;
class WalletSignTransactionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSignTransactionError';
}
}
exports.WalletSignTransactionError = WalletSignTransactionError;
class WalletSignMessageError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSignMessageError';
}
}
exports.WalletSignMessageError = WalletSignMessageError;
class WalletSignInError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSignInError';
}
}
exports.WalletSignInError = WalletSignInError;
class WalletTimeoutError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletTimeoutError';
}
}
exports.WalletTimeoutError = WalletTimeoutError;
class WalletWindowBlockedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletWindowBlockedError';
}
}
exports.WalletWindowBlockedError = WalletWindowBlockedError;
class WalletWindowClosedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletWindowClosedError';
}
}
exports.WalletWindowClosedError = WalletWindowClosedError;
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAY,SAAQ,KAAK;IAGlC,6EAA6E;IAC7E,YAAY,OAAgB,EAAE,KAAW;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AARD,kCAQC;AAED,MAAa,mBAAoB,SAAQ,WAAW;IAApD;;QACI,SAAI,GAAG,qBAAqB,CAAC;IACjC,CAAC;CAAA;AAF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CAAA;AAFD,wDAEC;AAED,MAAa,iBAAkB,SAAQ,WAAW;IAAlD;;QACI,SAAI,GAAG,mBAAmB,CAAC;IAC/B,CAAC;CAAA;AAFD,8CAEC;AAED,MAAa,kBAAmB,SAAQ,WAAW;IAAnD;;QACI,SAAI,GAAG,oBAAoB,CAAC;IAChC,CAAC;CAAA;AAFD,gDAEC;AAED,MAAa,wBAAyB,SAAQ,WAAW;IAAzD;;QACI,SAAI,GAAG,0BAA0B,CAAC;IACtC,CAAC;CAAA;AAFD,4DAEC;AAED,MAAa,uBAAwB,SAAQ,WAAW;IAAxD;;QACI,SAAI,GAAG,yBAAyB,CAAC;IACrC,CAAC;CAAA;AAFD,0DAEC"}

View File

@@ -0,0 +1,23 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./adapter.js"), exports);
__exportStar(require("./errors.js"), exports);
__exportStar(require("./signer.js"), exports);
__exportStar(require("./standard.js"), exports);
__exportStar(require("./transaction.js"), exports);
__exportStar(require("./types.js"), exports);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,8CAA4B;AAC5B,8CAA4B;AAC5B,gDAA8B;AAC9B,mDAAiC;AACjC,6CAA2B"}

View File

@@ -0,0 +1 @@
{ "type": "commonjs" }

View File

@@ -0,0 +1,103 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseSignInMessageSignerWalletAdapter = exports.BaseMessageSignerWalletAdapter = exports.BaseSignerWalletAdapter = void 0;
const adapter_js_1 = require("./adapter.js");
const errors_js_1 = require("./errors.js");
const transaction_js_1 = require("./transaction.js");
class BaseSignerWalletAdapter extends adapter_js_1.BaseWalletAdapter {
sendTransaction(transaction_1, connection_1) {
return __awaiter(this, arguments, void 0, function* (transaction, connection, options = {}) {
let emit = true;
try {
if ((0, transaction_js_1.isVersionedTransaction)(transaction)) {
if (!this.supportedTransactionVersions)
throw new errors_js_1.WalletSendTransactionError(`Sending versioned transactions isn't supported by this wallet`);
if (!this.supportedTransactionVersions.has(transaction.version))
throw new errors_js_1.WalletSendTransactionError(`Sending transaction version ${transaction.version} isn't supported by this wallet`);
try {
transaction = yield this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return yield connection.sendRawTransaction(rawTransaction, options);
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof errors_js_1.WalletSignTransactionError) {
emit = false;
throw error;
}
throw new errors_js_1.WalletSendTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
}
}
else {
try {
const { signers } = options, sendOptions = __rest(options, ["signers"]);
transaction = yield this.prepareTransaction(transaction, connection, sendOptions);
(signers === null || signers === void 0 ? void 0 : signers.length) && transaction.partialSign(...signers);
transaction = yield this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return yield connection.sendRawTransaction(rawTransaction, sendOptions);
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof errors_js_1.WalletSignTransactionError) {
emit = false;
throw error;
}
throw new errors_js_1.WalletSendTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
}
}
}
catch (error) {
if (emit) {
this.emit('error', error);
}
throw error;
}
});
}
signAllTransactions(transactions) {
return __awaiter(this, void 0, void 0, function* () {
for (const transaction of transactions) {
if ((0, transaction_js_1.isVersionedTransaction)(transaction)) {
if (!this.supportedTransactionVersions)
throw new errors_js_1.WalletSignTransactionError(`Signing versioned transactions isn't supported by this wallet`);
if (!this.supportedTransactionVersions.has(transaction.version))
throw new errors_js_1.WalletSignTransactionError(`Signing transaction version ${transaction.version} isn't supported by this wallet`);
}
}
const signedTransactions = [];
for (const transaction of transactions) {
signedTransactions.push(yield this.signTransaction(transaction));
}
return signedTransactions;
});
}
}
exports.BaseSignerWalletAdapter = BaseSignerWalletAdapter;
class BaseMessageSignerWalletAdapter extends BaseSignerWalletAdapter {
}
exports.BaseMessageSignerWalletAdapter = BaseMessageSignerWalletAdapter;
class BaseSignInMessageSignerWalletAdapter extends BaseMessageSignerWalletAdapter {
}
exports.BaseSignInMessageSignerWalletAdapter = BaseSignInMessageSignerWalletAdapter;
//# sourceMappingURL=signer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAKsB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YAED,MAAM,kBAAkB,GAAQ,EAAE,CAAC;YACnC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;gBACrC,kBAAkB,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,OAAO,kBAAkB,CAAC;QAC9B,CAAC;KAAA;CACJ;AA7FD,0DA6FC;AASD,MAAsB,8BAClB,SAAQ,uBAA6B;CAIxC;AALD,wEAKC;AASD,MAAsB,oCAClB,SAAQ,8BAAoC;CAI/C;AALD,oFAKC"}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWalletAdapterCompatibleStandardWallet = isWalletAdapterCompatibleStandardWallet;
const wallet_standard_features_1 = require("@solana/wallet-standard-features");
const features_1 = require("@wallet-standard/features");
function isWalletAdapterCompatibleStandardWallet(wallet) {
return (features_1.StandardConnect in wallet.features &&
features_1.StandardEvents in wallet.features &&
(wallet_standard_features_1.SolanaSignAndSendTransaction in wallet.features || wallet_standard_features_1.SolanaSignTransaction in wallet.features));
}
//# sourceMappingURL=standard.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"standard.js","sourceRoot":"","sources":["../../src/standard.ts"],"names":[],"mappings":";;AAiCA,0FAQC;AAzCD,+EAO0C;AAE1C,wDAMmC;AAkBnC,SAAgB,uCAAuC,CACnD,MAAsB;IAEtB,OAAO,CACH,0BAAe,IAAI,MAAM,CAAC,QAAQ;QAClC,yBAAc,IAAI,MAAM,CAAC,QAAQ;QACjC,CAAC,uDAA4B,IAAI,MAAM,CAAC,QAAQ,IAAI,gDAAqB,IAAI,MAAM,CAAC,QAAQ,CAAC,CAChG,CAAC;AACN,CAAC"}

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isVersionedTransaction = isVersionedTransaction;
function isVersionedTransaction(transaction) {
return 'version' in transaction;
}
//# sourceMappingURL=transaction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":";;AAQA,wDAIC;AAJD,SAAgB,sBAAsB,CAClC,WAA+C;IAE/C,OAAO,SAAS,IAAI,WAAW,CAAC;AACpC,CAAC"}

View File

@@ -0,0 +1 @@
{"root":["../../src/adapter.ts","../../src/errors.ts","../../src/index.ts","../../src/signer.ts","../../src/standard.ts","../../src/transaction.ts","../../src/types.ts"],"version":"5.8.3"}

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletAdapterNetwork = void 0;
var WalletAdapterNetwork;
(function (WalletAdapterNetwork) {
WalletAdapterNetwork["Mainnet"] = "mainnet-beta";
WalletAdapterNetwork["Testnet"] = "testnet";
WalletAdapterNetwork["Devnet"] = "devnet";
})(WalletAdapterNetwork || (exports.WalletAdapterNetwork = WalletAdapterNetwork = {}));
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAWA,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,gDAAwB,CAAA;IACxB,2CAAmB,CAAA;IACnB,yCAAiB,CAAA;AACrB,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B"}

View File

@@ -0,0 +1,112 @@
import EventEmitter from 'eventemitter3';
import { WalletNotConnectedError } from './errors.js';
export { EventEmitter };
/**
* A wallet's readiness describes a series of states that the wallet can be in,
* depending on what kind of wallet it is. An installable wallet (eg. a browser
* extension like Phantom) might be `Installed` if we've found the Phantom API
* in the global scope, or `NotDetected` otherwise. A loadable, zero-install
* runtime (eg. Torus Wallet) might simply signal that it's `Loadable`. Use this
* metadata to personalize the wallet list for each user (eg. to show their
* installed wallets first).
*/
export var WalletReadyState;
(function (WalletReadyState) {
/**
* User-installable wallets can typically be detected by scanning for an API
* that they've injected into the global context. If such an API is present,
* we consider the wallet to have been installed.
*/
WalletReadyState["Installed"] = "Installed";
WalletReadyState["NotDetected"] = "NotDetected";
/**
* Loadable wallets are always available to you. Since you can load them at
* any time, it's meaningless to say that they have been detected.
*/
WalletReadyState["Loadable"] = "Loadable";
/**
* If a wallet is not supported on a given platform (eg. server-rendering, or
* mobile) then it will stay in the `Unsupported` state.
*/
WalletReadyState["Unsupported"] = "Unsupported";
})(WalletReadyState || (WalletReadyState = {}));
export class BaseWalletAdapter extends EventEmitter {
get connected() {
return !!this.publicKey;
}
async autoConnect() {
await this.connect();
}
async prepareTransaction(transaction, connection, options = {}) {
const publicKey = this.publicKey;
if (!publicKey)
throw new WalletNotConnectedError();
transaction.feePayer = transaction.feePayer || publicKey;
transaction.recentBlockhash =
transaction.recentBlockhash ||
(await connection.getLatestBlockhash({
commitment: options.preflightCommitment,
minContextSlot: options.minContextSlot,
})).blockhash;
return transaction;
}
}
export function scopePollingDetectionStrategy(detect) {
// Early return when server-side rendering
if (typeof window === 'undefined' || typeof document === 'undefined')
return;
const disposers = [];
function detectAndDispose() {
const detected = detect();
if (detected) {
for (const dispose of disposers) {
dispose();
}
}
}
// Strategy #1: Try detecting every second.
const interval =
// TODO: #334 Replace with idle callback strategy.
setInterval(detectAndDispose, 1000);
disposers.push(() => clearInterval(interval));
// Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.
if (
// Implies that `DOMContentLoaded` has not yet fired.
document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', detectAndDispose, { once: true });
disposers.push(() => document.removeEventListener('DOMContentLoaded', detectAndDispose));
}
// Strategy #3: Detect after the `window` has fully loaded.
if (
// If the `complete` state has been reached, we're too late.
document.readyState !== 'complete') {
window.addEventListener('load', detectAndDispose, { once: true });
disposers.push(() => window.removeEventListener('load', detectAndDispose));
}
// Strategy #4: Detect synchronously, now.
detectAndDispose();
}
/**
* Users on iOS can be redirected into a wallet's in-app browser automatically,
* if that wallet has a universal link configured to do so
* But should not be redirected from within a webview, eg. if they're already
* inside a wallet's browser
* This function can be used to identify users who are on iOS and can be redirected
*
* @returns true if the user can be redirected
*/
export function isIosAndRedirectable() {
// SSR: return false
if (!navigator)
return false;
const userAgent = navigator.userAgent.toLowerCase();
// if on iOS the user agent will contain either iPhone or iPad
// caveat: if requesting desktop site then this won't work
const isIos = userAgent.includes('iphone') || userAgent.includes('ipad');
// if in a webview then it will not include Safari
// note that other iOS browsers also include Safari
// so we will redirect only if Safari is also included
const isSafari = userAgent.includes('safari');
return isIos && isSafari;
}
//# sourceMappingURL=adapter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAoB,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,CAAC;AAuCxB;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,gBAkBX;AAlBD,WAAY,gBAAgB;IACxB;;;;OAIG;IACH,2CAAuB,CAAA;IACvB,+CAA2B,CAAA;IAC3B;;;OAGG;IACH,yCAAqB,CAAA;IACrB;;;OAGG;IACH,+CAA2B,CAAA;AAC/B,CAAC,EAlBW,gBAAgB,KAAhB,gBAAgB,QAkB3B;AAED,MAAM,OAAgB,iBAClB,SAAQ,YAAiC;IAWzC,IAAI,SAAS;QACT,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,WAAW;QACb,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAWS,KAAK,CAAC,kBAAkB,CAC9B,WAAwB,EACxB,UAAsB,EACtB,UAAuB,EAAE;QAEzB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,uBAAuB,EAAE,CAAC;QAEpD,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,IAAI,SA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AAC,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,0CAA0C;IAC1C,gBAAgB,EAAE,CAAC;AACvB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB;IAChC,oBAAoB;IACpB,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAE7B,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;IAEpD,8DAA8D;IAC9D,0DAA0D;IAC1D,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEzE,kDAAkD;IAClD,mDAAmD;IACnD,sDAAsD;IACtD,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAO,KAAK,IAAI,QAAQ,CAAC;AAC7B,CAAC"}

View File

@@ -0,0 +1,110 @@
export class WalletError extends Error {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
constructor(message, error) {
super(message);
this.error = error;
}
}
export class WalletNotReadyError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletNotReadyError';
}
}
export class WalletLoadError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletLoadError';
}
}
export class WalletConfigError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletConfigError';
}
}
export class WalletConnectionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletConnectionError';
}
}
export class WalletDisconnectedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletDisconnectedError';
}
}
export class WalletDisconnectionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletDisconnectionError';
}
}
export class WalletAccountError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletAccountError';
}
}
export class WalletPublicKeyError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletPublicKeyError';
}
}
export class WalletKeypairError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletKeypairError';
}
}
export class WalletNotConnectedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletNotConnectedError';
}
}
export class WalletSendTransactionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSendTransactionError';
}
}
export class WalletSignTransactionError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSignTransactionError';
}
}
export class WalletSignMessageError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSignMessageError';
}
}
export class WalletSignInError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletSignInError';
}
}
export class WalletTimeoutError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletTimeoutError';
}
}
export class WalletWindowBlockedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletWindowBlockedError';
}
}
export class WalletWindowClosedError extends WalletError {
constructor() {
super(...arguments);
this.name = 'WalletWindowClosedError';
}
}
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGlC,6EAA6E;IAC7E,YAAY,OAAgB,EAAE,KAAW;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAED,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAApD;;QACI,SAAI,GAAG,qBAAqB,CAAC;IACjC,CAAC;CAAA;AAED,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAAhD;;QACI,SAAI,GAAG,iBAAiB,CAAC;IAC7B,CAAC;CAAA;AAED,MAAM,OAAO,iBAAkB,S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AAM,OAAO,wBAAyB,SAAQ,WAAW;IAAzD;;QACI,SAAI,GAAG,0BAA0B,CAAC;IACtC,CAAC;CAAA;AAED,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IAAxD;;QACI,SAAI,GAAG,yBAAyB,CAAC;IACrC,CAAC;CAAA"}

View File

@@ -0,0 +1,7 @@
export * from './adapter.js';
export * from './errors.js';
export * from './signer.js';
export * from './standard.js';
export * from './transaction.js';
export * from './types.js';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}

View File

@@ -0,0 +1,73 @@
import { BaseWalletAdapter, } from './adapter.js';
import { WalletSendTransactionError, WalletSignTransactionError } from './errors.js';
import { isVersionedTransaction } from './transaction.js';
export class BaseSignerWalletAdapter extends BaseWalletAdapter {
async sendTransaction(transaction, connection, options = {}) {
let emit = true;
try {
if (isVersionedTransaction(transaction)) {
if (!this.supportedTransactionVersions)
throw new WalletSendTransactionError(`Sending versioned transactions isn't supported by this wallet`);
if (!this.supportedTransactionVersions.has(transaction.version))
throw new WalletSendTransactionError(`Sending transaction version ${transaction.version} isn't supported by this wallet`);
try {
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, options);
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
}
else {
try {
const { signers, ...sendOptions } = options;
transaction = await this.prepareTransaction(transaction, connection, sendOptions);
signers?.length && transaction.partialSign(...signers);
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, sendOptions);
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
}
}
catch (error) {
if (emit) {
this.emit('error', error);
}
throw error;
}
}
async signAllTransactions(transactions) {
for (const transaction of transactions) {
if (isVersionedTransaction(transaction)) {
if (!this.supportedTransactionVersions)
throw new WalletSignTransactionError(`Signing versioned transactions isn't supported by this wallet`);
if (!this.supportedTransactionVersions.has(transaction.version))
throw new WalletSignTransactionError(`Signing transaction version ${transaction.version} isn't supported by this wallet`);
}
}
const signedTransactions = [];
for (const transaction of transactions) {
signedTransactions.push(await this.signTransaction(transaction));
}
return signedTransactions;
}
}
export class BaseMessageSignerWalletAdapter extends BaseSignerWalletAdapter {
}
export class BaseSignInMessageSignerWalletAdapter extends BaseMessageSignerWalletAdapter {
}
//# sourceMappingURL=signer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,iBAAiB,GAIpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAA0C,MAAM,kBAAkB,CAAC;AAalG,MAAM,OAAgB,uBAClB,SAAQ,iBAAuB;IAG/B,KAAK,CAAC,eAAe,CACjB,WAAoF,EACpF,UAAsB,EACtB,UAAkC,EAAE;QAEpC,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC;YACD,IAAI,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtC,IAAI,CAAC,IAAI,CAAC,4BAA4B;oBAClC,MAAM,IAAI,0BAA0B,CAChC,+DAA+D,CAClE,CAAC;gBAEN,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAA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oBACD,MAAM,IAAI,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;gBAChE,CAAC;YACL,CAAC;QACL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,IAAI,IAAI,EAAE,CAAC;gBACP,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9B,CAAC;YACD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAMD,KAAK,CAAC,mBAAmB,CACrB,YAAiB;QAEjB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACrC,IAAI,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtC,IAAI,CAAC,IAAI,CAAC,4BAA4B;oBAClC,MAAM,IAAI,0BAA0B,CAChC,+DAA+D,CAClE,CAAC;gBAEN,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC;oBAC3D,MAAM,IAAI,0BAA0B,CAChC,+BAA+B,WAAW,CAAC,OAAO,iCAAiC,CACtF,CAAC;YACV,CAAC;QACL,CAAC;QAED,MAAM,kBAAkB,GAAQ,EAAE,CAAC;QACnC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACrC,kBAAkB,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ;AASD,MAAM,OAAgB,8BAClB,SAAQ,uBAA6B;CAIxC;AASD,MAAM,OAAgB,oCAClB,SAAQ,8BAAoC;CAI/C"}

View File

@@ -0,0 +1,8 @@
import { SolanaSignAndSendTransaction, SolanaSignTransaction, } from '@solana/wallet-standard-features';
import { StandardConnect, StandardEvents, } from '@wallet-standard/features';
export function isWalletAdapterCompatibleStandardWallet(wallet) {
return (StandardConnect in wallet.features &&
StandardEvents in wallet.features &&
(SolanaSignAndSendTransaction in wallet.features || SolanaSignTransaction in wallet.features));
}
//# sourceMappingURL=standard.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"standard.js","sourceRoot":"","sources":["../../src/standard.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,4BAA4B,EAI5B,qBAAqB,GAExB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACH,eAAe,EAGf,cAAc,GAEjB,MAAM,2BAA2B,CAAC;AAkBnC,MAAM,UAAU,uCAAuC,CACnD,MAAsB;IAEtB,OAAO,CACH,eAAe,IAAI,MAAM,CAAC,QAAQ;QAClC,cAAc,IAAI,MAAM,CAAC,QAAQ;QACjC,CAAC,4BAA4B,IAAI,MAAM,CAAC,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC,QAAQ,CAAC,CAChG,CAAC;AACN,CAAC"}

View File

@@ -0,0 +1,4 @@
export function isVersionedTransaction(transaction) {
return 'version' in transaction;
}
//# sourceMappingURL=transaction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,sBAAsB,CAClC,WAA+C;IAE/C,OAAO,SAAS,IAAI,WAAW,CAAC;AACpC,CAAC"}

View File

@@ -0,0 +1 @@
{"root":["../../src/adapter.ts","../../src/errors.ts","../../src/index.ts","../../src/signer.ts","../../src/standard.ts","../../src/transaction.ts","../../src/types.ts"],"version":"5.8.3"}

View File

@@ -0,0 +1,7 @@
export var WalletAdapterNetwork;
(function (WalletAdapterNetwork) {
WalletAdapterNetwork["Mainnet"] = "mainnet-beta";
WalletAdapterNetwork["Testnet"] = "testnet";
WalletAdapterNetwork["Devnet"] = "devnet";
})(WalletAdapterNetwork || (WalletAdapterNetwork = {}));
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAWA,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,gDAAwB,CAAA;IACxB,2CAAmB,CAAA;IACnB,yCAAiB,CAAA;AACrB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B"}

View File

@@ -0,0 +1,87 @@
import type { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js';
import EventEmitter from 'eventemitter3';
import { type WalletError } from './errors.js';
import type { SupportedTransactionVersions, TransactionOrVersionedTransaction } from './transaction.js';
export { EventEmitter };
export interface WalletAdapterEvents {
connect(publicKey: PublicKey): void;
disconnect(): void;
error(error: WalletError): void;
readyStateChange(readyState: WalletReadyState): void;
}
export interface SendTransactionOptions extends SendOptions {
signers?: Signer[];
}
export type WalletName<T extends string = string> = T & {
__brand__: 'WalletName';
};
export interface WalletAdapterProps<Name extends string = string> {
name: WalletName<Name>;
url: string;
icon: string;
readyState: WalletReadyState;
publicKey: PublicKey | null;
connecting: boolean;
connected: boolean;
supportedTransactionVersions?: SupportedTransactionVersions;
autoConnect(): Promise<void>;
connect(): Promise<void>;
disconnect(): Promise<void>;
sendTransaction(transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
}
export type WalletAdapter<Name extends string = string> = WalletAdapterProps<Name> & EventEmitter<WalletAdapterEvents>;
/**
* A wallet's readiness describes a series of states that the wallet can be in,
* depending on what kind of wallet it is. An installable wallet (eg. a browser
* extension like Phantom) might be `Installed` if we've found the Phantom API
* in the global scope, or `NotDetected` otherwise. A loadable, zero-install
* runtime (eg. Torus Wallet) might simply signal that it's `Loadable`. Use this
* metadata to personalize the wallet list for each user (eg. to show their
* installed wallets first).
*/
export declare enum WalletReadyState {
/**
* User-installable wallets can typically be detected by scanning for an API
* that they've injected into the global context. If such an API is present,
* we consider the wallet to have been installed.
*/
Installed = "Installed",
NotDetected = "NotDetected",
/**
* Loadable wallets are always available to you. Since you can load them at
* any time, it's meaningless to say that they have been detected.
*/
Loadable = "Loadable",
/**
* If a wallet is not supported on a given platform (eg. server-rendering, or
* mobile) then it will stay in the `Unsupported` state.
*/
Unsupported = "Unsupported"
}
export declare abstract class BaseWalletAdapter<Name extends string = string> extends EventEmitter<WalletAdapterEvents> implements WalletAdapter<Name> {
abstract name: WalletName<Name>;
abstract url: string;
abstract icon: string;
abstract readyState: WalletReadyState;
abstract publicKey: PublicKey | null;
abstract connecting: boolean;
abstract supportedTransactionVersions?: SupportedTransactionVersions;
get connected(): boolean;
autoConnect(): Promise<void>;
abstract connect(): Promise<void>;
abstract disconnect(): Promise<void>;
abstract sendTransaction(transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
protected prepareTransaction(transaction: Transaction, connection: Connection, options?: SendOptions): Promise<Transaction>;
}
export declare function scopePollingDetectionStrategy(detect: () => boolean): void;
/**
* Users on iOS can be redirected into a wallet's in-app browser automatically,
* if that wallet has a universal link configured to do so
* But should not be redirected from within a webview, eg. if they're already
* inside a wallet's browser
* This function can be used to identify users who are on iOS and can be redirected
*
* @returns true if the user can be redirected
*/
export declare function isIosAndRedirectable(): boolean;
//# sourceMappingURL=adapter.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACrH,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAA2B,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,4BAA4B,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AAExG,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,WAAW,mBAAmB;IAChC,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,C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class WalletNotReadyError extends WalletError {
name: string;
}
export declare class WalletLoadError extends WalletError {
name: string;
}
export declare class WalletConfigError extends WalletError {
name: string;
}
export declare class WalletConnectionError extends WalletError {
name: string;
}
export declare class WalletDisconnectedError extends WalletError {
name: string;
}
export declare class WalletDisconnectionError extends WalletError {
name: string;
}
export declare class WalletAccountError extends WalletError {
name: string;
}
export declare class WalletPublicKeyError extends WalletError {
name: string;
}
export declare class WalletKeypairError extends WalletError {
name: string;
}
export declare class WalletNotConnectedError extends WalletError {
name: string;
}
export declare class WalletSendTransactionError extends WalletError {
name: string;
}
export declare class WalletSignTransactionError extends WalletError {
name: string;
}
export declare class WalletSignMessageError extends WalletError {
name: string;
}
export declare class WalletSignInError extends WalletError {
name: string;
}
export declare class WalletTimeoutError extends WalletError {
name: string;
}
export declare class WalletWindowBlockedError extends WalletError {
name: string;
}
export declare class WalletWindowClosedError extends WalletError {
name: string;
}
//# sourceMappingURL=errors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IAClC,KAAK,EAAE,GAAG,CAAC;gBAGC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;CAI5C;AAED,qBAAa,mBAAoB,SAAQ,WAAW;IAChD,IAAI,SAAyB;CAChC;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAC5C,IAAI,SAAqB;CAC5B;AAED,qBAAa,iBAAkB,SAAQ,WAAW;IAC9C,IAAI,SAAuB;CAC9B;AAED,qBAAa,qBAAsB,SAAQ,WAAW;IAClD,IAAI,SAA2B;CAClC;AAED,qBAAa,uBAAwB,SAAQ,WAAW;IACpD,IAAI,SAA6B;CACpC;AAED,qBAAa,wBAAyB,SAAQ,WAAW;IACrD,IAAI,SAA8B;CACrC;AAED,qBAAa,kBAAmB,SAAQ,WAAW;IAC/C,IAAI,SAAwB;CAC/B;AAED,qBAAa,oBAAqB,SAAQ,WAAW;IACjD,IAAI,SAA0B;CACjC;AAED,qBAAa,kBAAmB,SAAQ,WAAW;IAC/C,IAAI,SAAwB;CAC/B;AAED,qBAAa,uBAAwB,SAAQ,WAAW;IACpD,IAAI,SAA6B;CACpC;AAED,qBAAa,0BAA2B,SAAQ,WAAW;IACvD,IAAI,SAAgC;CACvC;AAED,qBAAa,0BAA2B,SAAQ,WAAW;IACvD,IAAI,SAAgC;CACvC;AAED,qBAAa,sBAAuB,SAAQ,WAAW;IACnD,IAAI,SAA4B;CACnC;AAED,qBAAa,iBAAkB,SAAQ,WAAW;IAC9C,IAAI,SAAuB;CAC9B;AAED,qBAAa,kBAAmB,SAAQ,WAAW;IAC/C,IAAI,SAAwB;CAC/B;AAED,qBAAa,wBAAyB,SAAQ,WAAW;IACrD,IAAI,SAA8B;CACrC;AAED,qBAAa,uBAAwB,SAAQ,WAAW;IACpD,IAAI,SAA6B;CACpC"}

View File

@@ -0,0 +1,7 @@
export * from './adapter.js';
export * from './errors.js';
export * from './signer.js';
export * from './standard.js';
export * from './transaction.js';
export * from './types.js';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}

View File

@@ -0,0 +1,29 @@
import type { SolanaSignInInput, SolanaSignInOutput } from '@solana/wallet-standard-features';
import type { Connection, TransactionSignature } from '@solana/web3.js';
import { BaseWalletAdapter, type SendTransactionOptions, type WalletAdapter, type WalletAdapterProps } from './adapter.js';
import { type TransactionOrVersionedTransaction } from './transaction.js';
export interface SignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transaction: T): Promise<T>;
signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transactions: T[]): Promise<T[]>;
}
export type SignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> & SignerWalletAdapterProps<Name>;
export declare abstract class BaseSignerWalletAdapter<Name extends string = string> extends BaseWalletAdapter<Name> implements SignerWalletAdapter<Name> {
sendTransaction(transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
abstract signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transaction: T): Promise<T>;
signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transactions: T[]): Promise<T[]>;
}
export interface MessageSignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signMessage(message: Uint8Array): Promise<Uint8Array>;
}
export type MessageSignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> & MessageSignerWalletAdapterProps<Name>;
export declare abstract class BaseMessageSignerWalletAdapter<Name extends string = string> extends BaseSignerWalletAdapter<Name> implements MessageSignerWalletAdapter<Name> {
abstract signMessage(message: Uint8Array): Promise<Uint8Array>;
}
export interface SignInMessageSignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signIn(input?: SolanaSignInInput): Promise<SolanaSignInOutput>;
}
export type SignInMessageSignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> & SignInMessageSignerWalletAdapterProps<Name>;
export declare abstract class BaseSignInMessageSignerWalletAdapter<Name extends string = string> extends BaseMessageSignerWalletAdapter<Name> implements SignInMessageSignerWalletAdapter<Name> {
abstract signIn(input?: SolanaSignInInput): Promise<SolanaSignInOutput>;
}
//# sourceMappingURL=signer.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,k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kB,CAAC;CAC1E"}

View File

@@ -0,0 +1,12 @@
import { type SolanaSignAndSendTransactionFeature, type SolanaSignInFeature, type SolanaSignMessageFeature, type SolanaSignTransactionFeature } from '@solana/wallet-standard-features';
import type { Wallet as StandardWallet, WalletWithFeatures as StandardWalletWithFeatures } from '@wallet-standard/base';
import { type StandardConnectFeature, type StandardDisconnectFeature, type StandardEventsFeature } from '@wallet-standard/features';
import type { WalletAdapter, WalletAdapterProps } from './adapter.js';
export type WalletAdapterCompatibleStandardWallet = StandardWalletWithFeatures<StandardConnectFeature & StandardEventsFeature & (SolanaSignAndSendTransactionFeature | SolanaSignTransactionFeature) & (StandardDisconnectFeature | SolanaSignMessageFeature | SolanaSignInFeature | object)>;
export interface StandardWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
wallet: WalletAdapterCompatibleStandardWallet;
standard: true;
}
export type StandardWalletAdapter<Name extends string = string> = WalletAdapter<Name> & StandardWalletAdapterProps<Name>;
export declare function isWalletAdapterCompatibleStandardWallet(wallet: StandardWallet): wallet is WalletAdapterCompatibleStandardWallet;
//# sourceMappingURL=standard.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../src/standard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,mCAAmC,EACxC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAE7B,KAAK,4BAA4B,EACpC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,IAAI,cAAc,EAAE,kBAAkB,IAAI,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACxH,OAAO,EAEH,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAE9B,KAAK,qBAAqB,EAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,MAAM,qCAAqC,GAAG,0BAA0B,CAC1E,sBAAsB,GAClB,qBAAqB,GACrB,CAAC,mCAAmC,GAAG,4BAA4B,CAAC,GACpE,CAAC,yBAAyB,GAAG,wBAAwB,GAAG,mBAAmB,GAAG,MAAM,CAAC,CAC5F,CAAC;AAEF,MAAM,WAAW,0BAA0B,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,kBAAkB,CAAC,IAAI,CAAC;IACtG,MAAM,EAAE,qCAAqC,CAAC;IAC9C,QAAQ,EAAE,IAAI,CAAC;CAClB;AAED,MAAM,MAAM,qBAAqB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,GACjF,0BAA0B,CAAC,IAAI,CAAC,CAAC;AAErC,wBAAgB,uCAAuC,CACnD,MAAM,EAAE,cAAc,GACvB,MAAM,IAAI,qCAAqC,CAMjD"}

View File

@@ -0,0 +1,5 @@
import type { Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
export type SupportedTransactionVersions = ReadonlySet<TransactionVersion> | null | undefined;
export type TransactionOrVersionedTransaction<S extends SupportedTransactionVersions> = S extends null | undefined ? Transaction : Transaction | VersionedTransaction;
export declare function isVersionedTransaction(transaction: Transaction | VersionedTransaction): transaction is VersionedTransaction;
//# sourceMappingURL=transaction.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE7F,MAAM,MAAM,4BAA4B,GAAG,WAAW,CAAC,kBAAkB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9F,MAAM,MAAM,iCAAiC,CAAC,CAAC,SAAS,4BAA4B,IAAI,CAAC,SAAS,IAAI,GAAG,SAAS,GAC5G,WAAW,GACX,WAAW,GAAG,oBAAoB,CAAC;AAEzC,wBAAgB,sBAAsB,CAClC,WAAW,EAAE,WAAW,GAAG,oBAAoB,GAChD,WAAW,IAAI,oBAAoB,CAErC"}

View File

@@ -0,0 +1,10 @@
import type { WalletAdapter } from './adapter.js';
import type { MessageSignerWalletAdapter, SignerWalletAdapter, SignInMessageSignerWalletAdapter } from './signer.js';
import type { StandardWalletAdapter } from './standard.js';
export type Adapter = WalletAdapter | SignerWalletAdapter | MessageSignerWalletAdapter | SignInMessageSignerWalletAdapter | StandardWalletAdapter;
export declare enum WalletAdapterNetwork {
Mainnet = "mainnet-beta",
Testnet = "testnet",
Devnet = "devnet"
}
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AACrH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,MAAM,OAAO,GACb,aAAa,GACb,mBAAmB,GACnB,0BAA0B,GAC1B,gCAAgC,GAChC,qBAAqB,CAAC;AAE5B,oBAAY,oBAAoB;IAC5B,OAAO,iBAAiB;IACxB,OAAO,YAAY;IACnB,MAAM,WAAW;CACpB"}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Arnout Kazemier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,85 @@
# EventEmitter3
[![Version npm](https://img.shields.io/npm/v/eventemitter3.svg?style=flat-square)](https://www.npmjs.com/package/eventemitter3)[![CI](https://img.shields.io/github/actions/workflow/status/primus/eventemitter3/ci.yml?branch=master&label=CI&style=flat-square)](https://github.com/primus/eventemitter3/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/primus/eventemitter3/master.svg?style=flat-square)](https://coveralls.io/r/primus/eventemitter3?branch=master)
EventEmitter3 is a high performance EventEmitter. It has been micro-optimized
for various of code paths making this, one of, if not the fastest EventEmitter
available for Node.js and browsers. The module is API compatible with the
EventEmitter that ships by default with Node.js but there are some slight
differences:
- Domain support has been removed.
- We do not `throw` an error when you emit an `error` event and nobody is
listening.
- The `newListener` and `removeListener` events have been removed as they
are useful only in some uncommon use-cases.
- The `setMaxListeners`, `getMaxListeners`, `prependListener` and
`prependOnceListener` methods are not available.
- Support for custom context for events so there is no need to use `fn.bind`.
- The `removeListener` method removes all matching listeners, not only the
first.
It's a drop in replacement for existing EventEmitters, but just faster. Free
performance, who wouldn't want that? The EventEmitter is written in EcmaScript 3
so it will work in the oldest browsers and node versions that you need to
support.
## Installation
```bash
$ npm install --save eventemitter3
```
## CDN
Recommended CDN:
```text
https://unpkg.com/eventemitter3@latest/dist/eventemitter3.umd.min.js
```
## Usage
After installation the only thing you need to do is require the module:
```js
var EventEmitter = require('eventemitter3');
```
And you're ready to create your own EventEmitter instances. For the API
documentation, please follow the official Node.js documentation:
http://nodejs.org/api/events.html
### Contextual emits
We've upgraded the API of the `EventEmitter.on`, `EventEmitter.once` and
`EventEmitter.removeListener` to accept an extra argument which is the `context`
or `this` value that should be set for the emitted events. This means you no
longer have the overhead of an event that required `fn.bind` in order to get a
custom `this` value.
```js
var EE = new EventEmitter()
, context = { foo: 'bar' };
function emitted() {
console.log(this === context); // true
}
EE.once('event-name', emitted, context);
EE.on('another-event', emitted, context);
EE.removeListener('another-event', emitted, context);
```
### Tests and benchmarks
To run tests run `npm test`. To run the benchmarks run `npm run benchmark`.
Tests and benchmarks are not included in the npm package. If you want to play
with them you have to clone the GitHub repository. Note that you will have to
run an additional `npm i` in the benchmarks folder before `npm run benchmark`.
## License
[MIT](LICENSE)

View File

@@ -0,0 +1,355 @@
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var eventemitter3 = {exports: {}};
var hasRequiredEventemitter3;
function requireEventemitter3 () {
if (hasRequiredEventemitter3) return eventemitter3.exports;
hasRequiredEventemitter3 = 1;
(function (module) {
var has = Object.prototype.hasOwnProperty
, prefix = '~';
/**
* Constructor to create a storage for our `EE` objects.
* An `Events` instance is a plain object whose properties are event names.
*
* @constructor
* @private
*/
function Events() {}
//
// We try to not inherit from `Object.prototype`. In some engines creating an
// instance in this way is faster than calling `Object.create(null)` directly.
// If `Object.create(null)` is not supported we prefix the event names with a
// character to make sure that the built-in object properties are not
// overridden or used as an attack vector.
//
if (Object.create) {
Events.prototype = Object.create(null);
//
// This hack is needed because the `__proto__` property is still inherited in
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
//
if (!new Events().__proto__) prefix = false;
}
/**
* Representation of a single event listener.
*
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
* @constructor
* @private
*/
function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
}
/**
* Add a listener for a given event.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} once Specify if the listener is a one-time listener.
* @returns {EventEmitter}
* @private
*/
function addListener(emitter, event, fn, context, once) {
if (typeof fn !== 'function') {
throw new TypeError('The listener must be a function');
}
var listener = new EE(fn, context || emitter, once)
, evt = prefix ? prefix + event : event;
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
else emitter._events[evt] = [emitter._events[evt], listener];
return emitter;
}
/**
* Clear event by name.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} evt The Event name.
* @private
*/
function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();
else delete emitter._events[evt];
}
/**
* Minimal `EventEmitter` interface that is molded against the Node.js
* `EventEmitter` interface.
*
* @constructor
* @public
*/
function EventEmitter() {
this._events = new Events();
this._eventsCount = 0;
}
/**
* Return an array listing the events for which the emitter has registered
* listeners.
*
* @returns {Array}
* @public
*/
EventEmitter.prototype.eventNames = function eventNames() {
var names = []
, events
, name;
if (this._eventsCount === 0) return names;
for (name in (events = this._events)) {
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
}
if (Object.getOwnPropertySymbols) {
return names.concat(Object.getOwnPropertySymbols(events));
}
return names;
};
/**
* Return the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Array} The registered listeners.
* @public
*/
EventEmitter.prototype.listeners = function listeners(event) {
var evt = prefix ? prefix + event : event
, handlers = this._events[evt];
if (!handlers) return [];
if (handlers.fn) return [handlers.fn];
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
ee[i] = handlers[i].fn;
}
return ee;
};
/**
* Return the number of listeners listening to a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Number} The number of listeners.
* @public
*/
EventEmitter.prototype.listenerCount = function listenerCount(event) {
var evt = prefix ? prefix + event : event
, listeners = this._events[evt];
if (!listeners) return 0;
if (listeners.fn) return 1;
return listeners.length;
};
/**
* Calls each of the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Boolean} `true` if the event had listeners, else `false`.
* @public
*/
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return false;
var listeners = this._events[evt]
, len = arguments.length
, args
, i;
if (listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
switch (len) {
case 1: return listeners.fn.call(listeners.context), true;
case 2: return listeners.fn.call(listeners.context, a1), true;
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}
for (i = 1, args = new Array(len -1); i < len; i++) {
args[i - 1] = arguments[i];
}
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length
, j;
for (i = 0; i < length; i++) {
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
switch (len) {
case 1: listeners[i].fn.call(listeners[i].context); break;
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
default:
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
args[j - 1] = arguments[j];
}
listeners[i].fn.apply(listeners[i].context, args);
}
}
}
return true;
};
/**
* Add a listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.on = function on(event, fn, context) {
return addListener(this, event, fn, context, false);
};
/**
* Add a one-time listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.once = function once(event, fn, context) {
return addListener(this, event, fn, context, true);
};
/**
* Remove the listeners of a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn Only remove the listeners that match this function.
* @param {*} context Only remove the listeners that have this context.
* @param {Boolean} once Only remove one-time listeners.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return this;
if (!fn) {
clearEvent(this, evt);
return this;
}
var listeners = this._events[evt];
if (listeners.fn) {
if (
listeners.fn === fn &&
(!once || listeners.once) &&
(!context || listeners.context === context)
) {
clearEvent(this, evt);
}
} else {
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
if (
listeners[i].fn !== fn ||
(once && !listeners[i].once) ||
(context && listeners[i].context !== context)
) {
events.push(listeners[i]);
}
}
//
// Reset the array, or remove it completely if we have no more listeners.
//
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
else clearEvent(this, evt);
}
return this;
};
/**
* Remove all listeners, or those of the specified event.
*
* @param {(String|Symbol)} [event] The event name.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
var evt;
if (event) {
evt = prefix ? prefix + event : event;
if (this._events[evt]) clearEvent(this, evt);
} else {
this._events = new Events();
this._eventsCount = 0;
}
return this;
};
//
// Alias methods names because people roll like that.
//
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
//
// Expose the prefix.
//
EventEmitter.prefixed = prefix;
//
// Allow `EventEmitter` to be imported as module namespace.
//
EventEmitter.EventEmitter = EventEmitter;
//
// Expose the module.
//
{
module.exports = EventEmitter;
}
} (eventemitter3));
return eventemitter3.exports;
}
var eventemitter3Exports = requireEventemitter3();
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
export { EventEmitter, EventEmitter as default };

View File

@@ -0,0 +1 @@
function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,n={exports:{}};var r=(t||(t=1,function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||e,i),f=n?n+t:t;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],c]:e._events[f].push(c):(e._events[f]=c,e._eventsCount++),e}function i(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,s,i){var c=n?n+e:e;if(!this._events[c])return!1;var f,a,u=this._events[c],l=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),l){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,s),!0;case 6:return u.fn.call(u.context,t,r,o,s,i),!0}for(a=1,f=new Array(l-1);a<l;a++)f[a-1]=arguments[a];u.fn.apply(u.context,f)}else{var p,v=u.length;for(a=0;a<v;a++)switch(u[a].once&&this.removeListener(e,u[a].fn,void 0,!0),l){case 1:u[a].fn.call(u[a].context);break;case 2:u[a].fn.call(u[a].context,t);break;case 3:u[a].fn.call(u[a].context,t,r);break;case 4:u[a].fn.call(u[a].context,t,r,o);break;default:if(!f)for(p=1,f=new Array(l-1);p<l;p++)f[p-1]=arguments[p];u[a].fn.apply(u[a].context,f)}}return!0},c.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==t||o&&!c.once||r&&c.context!==r||i(this,s);else{for(var f=0,a=[],u=c.length;f<u;f++)(c[f].fn!==t||o&&!c[f].once||r&&c[f].context!==r)&&a.push(c[f]);a.length?this._events[s]=1===a.length?a[0]:a:i(this,s)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c}(n)),n.exports),o=e(r);export{o as EventEmitter,o as default};//# sourceMappingURL=eventemitter3.esm.min.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,363 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EventEmitter3 = factory());
})(this, (function () { 'use strict';
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var eventemitter3 = {exports: {}};
var hasRequiredEventemitter3;
function requireEventemitter3 () {
if (hasRequiredEventemitter3) return eventemitter3.exports;
hasRequiredEventemitter3 = 1;
(function (module) {
var has = Object.prototype.hasOwnProperty
, prefix = '~';
/**
* Constructor to create a storage for our `EE` objects.
* An `Events` instance is a plain object whose properties are event names.
*
* @constructor
* @private
*/
function Events() {}
//
// We try to not inherit from `Object.prototype`. In some engines creating an
// instance in this way is faster than calling `Object.create(null)` directly.
// If `Object.create(null)` is not supported we prefix the event names with a
// character to make sure that the built-in object properties are not
// overridden or used as an attack vector.
//
if (Object.create) {
Events.prototype = Object.create(null);
//
// This hack is needed because the `__proto__` property is still inherited in
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
//
if (!new Events().__proto__) prefix = false;
}
/**
* Representation of a single event listener.
*
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
* @constructor
* @private
*/
function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
}
/**
* Add a listener for a given event.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} once Specify if the listener is a one-time listener.
* @returns {EventEmitter}
* @private
*/
function addListener(emitter, event, fn, context, once) {
if (typeof fn !== 'function') {
throw new TypeError('The listener must be a function');
}
var listener = new EE(fn, context || emitter, once)
, evt = prefix ? prefix + event : event;
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
else emitter._events[evt] = [emitter._events[evt], listener];
return emitter;
}
/**
* Clear event by name.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} evt The Event name.
* @private
*/
function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();
else delete emitter._events[evt];
}
/**
* Minimal `EventEmitter` interface that is molded against the Node.js
* `EventEmitter` interface.
*
* @constructor
* @public
*/
function EventEmitter() {
this._events = new Events();
this._eventsCount = 0;
}
/**
* Return an array listing the events for which the emitter has registered
* listeners.
*
* @returns {Array}
* @public
*/
EventEmitter.prototype.eventNames = function eventNames() {
var names = []
, events
, name;
if (this._eventsCount === 0) return names;
for (name in (events = this._events)) {
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
}
if (Object.getOwnPropertySymbols) {
return names.concat(Object.getOwnPropertySymbols(events));
}
return names;
};
/**
* Return the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Array} The registered listeners.
* @public
*/
EventEmitter.prototype.listeners = function listeners(event) {
var evt = prefix ? prefix + event : event
, handlers = this._events[evt];
if (!handlers) return [];
if (handlers.fn) return [handlers.fn];
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
ee[i] = handlers[i].fn;
}
return ee;
};
/**
* Return the number of listeners listening to a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Number} The number of listeners.
* @public
*/
EventEmitter.prototype.listenerCount = function listenerCount(event) {
var evt = prefix ? prefix + event : event
, listeners = this._events[evt];
if (!listeners) return 0;
if (listeners.fn) return 1;
return listeners.length;
};
/**
* Calls each of the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Boolean} `true` if the event had listeners, else `false`.
* @public
*/
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return false;
var listeners = this._events[evt]
, len = arguments.length
, args
, i;
if (listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
switch (len) {
case 1: return listeners.fn.call(listeners.context), true;
case 2: return listeners.fn.call(listeners.context, a1), true;
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}
for (i = 1, args = new Array(len -1); i < len; i++) {
args[i - 1] = arguments[i];
}
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length
, j;
for (i = 0; i < length; i++) {
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
switch (len) {
case 1: listeners[i].fn.call(listeners[i].context); break;
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
default:
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
args[j - 1] = arguments[j];
}
listeners[i].fn.apply(listeners[i].context, args);
}
}
}
return true;
};
/**
* Add a listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.on = function on(event, fn, context) {
return addListener(this, event, fn, context, false);
};
/**
* Add a one-time listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.once = function once(event, fn, context) {
return addListener(this, event, fn, context, true);
};
/**
* Remove the listeners of a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn Only remove the listeners that match this function.
* @param {*} context Only remove the listeners that have this context.
* @param {Boolean} once Only remove one-time listeners.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return this;
if (!fn) {
clearEvent(this, evt);
return this;
}
var listeners = this._events[evt];
if (listeners.fn) {
if (
listeners.fn === fn &&
(!once || listeners.once) &&
(!context || listeners.context === context)
) {
clearEvent(this, evt);
}
} else {
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
if (
listeners[i].fn !== fn ||
(once && !listeners[i].once) ||
(context && listeners[i].context !== context)
) {
events.push(listeners[i]);
}
}
//
// Reset the array, or remove it completely if we have no more listeners.
//
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
else clearEvent(this, evt);
}
return this;
};
/**
* Remove all listeners, or those of the specified event.
*
* @param {(String|Symbol)} [event] The event name.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
var evt;
if (event) {
evt = prefix ? prefix + event : event;
if (this._events[evt]) clearEvent(this, evt);
} else {
this._events = new Events();
this._eventsCount = 0;
}
return this;
};
//
// Alias methods names because people roll like that.
//
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
//
// Expose the prefix.
//
EventEmitter.prefixed = prefix;
//
// Allow `EventEmitter` to be imported as module namespace.
//
EventEmitter.EventEmitter = EventEmitter;
//
// Expose the module.
//
{
module.exports = EventEmitter;
}
} (eventemitter3));
return eventemitter3.exports;
}
var eventemitter3Exports = requireEventemitter3();
var index = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
return index;
}));

View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).EventEmitter3=t()}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,n={exports:{}};var r=(t||(t=1,function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||e,i),f=n?n+t:t;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],c]:e._events[f].push(c):(e._events[f]=c,e._eventsCount++),e}function i(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,s,i){var c=n?n+e:e;if(!this._events[c])return!1;var f,u,a=this._events[c],l=arguments.length;if(a.fn){switch(a.once&&this.removeListener(e,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,t),!0;case 3:return a.fn.call(a.context,t,r),!0;case 4:return a.fn.call(a.context,t,r,o),!0;case 5:return a.fn.call(a.context,t,r,o,s),!0;case 6:return a.fn.call(a.context,t,r,o,s,i),!0}for(u=1,f=new Array(l-1);u<l;u++)f[u-1]=arguments[u];a.fn.apply(a.context,f)}else{var p,v=a.length;for(u=0;u<v;u++)switch(a[u].once&&this.removeListener(e,a[u].fn,void 0,!0),l){case 1:a[u].fn.call(a[u].context);break;case 2:a[u].fn.call(a[u].context,t);break;case 3:a[u].fn.call(a[u].context,t,r);break;case 4:a[u].fn.call(a[u].context,t,r,o);break;default:if(!f)for(p=1,f=new Array(l-1);p<l;p++)f[p-1]=arguments[p];a[u].fn.apply(a[u].context,f)}}return!0},c.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==t||o&&!c.once||r&&c.context!==r||i(this,s);else{for(var f=0,u=[],a=c.length;f<a;f++)(c[f].fn!==t||o&&!c[f].once||r&&c[f].context!==r)&&u.push(c[f]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c}(n)),n.exports);return e(r)});//# sourceMappingURL=eventemitter3.umd.min.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,135 @@
/**
* Minimal `EventEmitter` interface that is molded against the Node.js
* `EventEmitter` interface.
*/
declare class EventEmitter<
EventTypes extends EventEmitter.ValidEventTypes = string | symbol,
Context extends any = any
> {
static prefixed: string | boolean;
/**
* Return an array listing the events for which the emitter has registered
* listeners.
*/
eventNames(): Array<EventEmitter.EventNames<EventTypes>>;
/**
* Return the listeners registered for a given event.
*/
listeners<T extends EventEmitter.EventNames<EventTypes>>(
event: T
): Array<EventEmitter.EventListener<EventTypes, T>>;
/**
* Return the number of listeners listening to a given event.
*/
listenerCount(event: EventEmitter.EventNames<EventTypes>): number;
/**
* Calls each of the listeners registered for a given event.
*/
emit<T extends EventEmitter.EventNames<EventTypes>>(
event: T,
...args: EventEmitter.EventArgs<EventTypes, T>
): boolean;
/**
* Add a listener for a given event.
*/
on<T extends EventEmitter.EventNames<EventTypes>>(
event: T,
fn: EventEmitter.EventListener<EventTypes, T>,
context?: Context
): this;
addListener<T extends EventEmitter.EventNames<EventTypes>>(
event: T,
fn: EventEmitter.EventListener<EventTypes, T>,
context?: Context
): this;
/**
* Add a one-time listener for a given event.
*/
once<T extends EventEmitter.EventNames<EventTypes>>(
event: T,
fn: EventEmitter.EventListener<EventTypes, T>,
context?: Context
): this;
/**
* Remove the listeners of a given event.
*/
removeListener<T extends EventEmitter.EventNames<EventTypes>>(
event: T,
fn?: EventEmitter.EventListener<EventTypes, T>,
context?: Context,
once?: boolean
): this;
off<T extends EventEmitter.EventNames<EventTypes>>(
event: T,
fn?: EventEmitter.EventListener<EventTypes, T>,
context?: Context,
once?: boolean
): this;
/**
* Remove all listeners, or those of the specified event.
*/
removeAllListeners(event?: EventEmitter.EventNames<EventTypes>): this;
}
declare namespace EventEmitter {
export interface ListenerFn<Args extends any[] = any[]> {
(...args: Args): void;
}
export interface EventEmitterStatic {
new <
EventTypes extends ValidEventTypes = string | symbol,
Context = any
>(): EventEmitter<EventTypes, Context>;
}
/**
* `object` should be in either of the following forms:
* ```
* interface EventTypes {
* 'event-with-parameters': any[]
* 'event-with-example-handler': (...args: any[]) => void
* }
* ```
*/
export type ValidEventTypes = string | symbol | object;
export type EventNames<T extends ValidEventTypes> = T extends string | symbol
? T
: keyof T;
export type ArgumentMap<T extends object> = {
[K in keyof T]: T[K] extends (...args: any[]) => void
? Parameters<T[K]>
: T[K] extends any[]
? T[K]
: any[];
};
export type EventListener<
T extends ValidEventTypes,
K extends EventNames<T>
> = T extends string | symbol
? (...args: any[]) => void
: (
...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]
) => void;
export type EventArgs<
T extends ValidEventTypes,
K extends EventNames<T>
> = Parameters<EventListener<T, K>>;
export const EventEmitter: EventEmitterStatic;
}
export { EventEmitter }
export default EventEmitter;

View File

@@ -0,0 +1,336 @@
'use strict';
var has = Object.prototype.hasOwnProperty
, prefix = '~';
/**
* Constructor to create a storage for our `EE` objects.
* An `Events` instance is a plain object whose properties are event names.
*
* @constructor
* @private
*/
function Events() {}
//
// We try to not inherit from `Object.prototype`. In some engines creating an
// instance in this way is faster than calling `Object.create(null)` directly.
// If `Object.create(null)` is not supported we prefix the event names with a
// character to make sure that the built-in object properties are not
// overridden or used as an attack vector.
//
if (Object.create) {
Events.prototype = Object.create(null);
//
// This hack is needed because the `__proto__` property is still inherited in
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
//
if (!new Events().__proto__) prefix = false;
}
/**
* Representation of a single event listener.
*
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
* @constructor
* @private
*/
function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
}
/**
* Add a listener for a given event.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} once Specify if the listener is a one-time listener.
* @returns {EventEmitter}
* @private
*/
function addListener(emitter, event, fn, context, once) {
if (typeof fn !== 'function') {
throw new TypeError('The listener must be a function');
}
var listener = new EE(fn, context || emitter, once)
, evt = prefix ? prefix + event : event;
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
else emitter._events[evt] = [emitter._events[evt], listener];
return emitter;
}
/**
* Clear event by name.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} evt The Event name.
* @private
*/
function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();
else delete emitter._events[evt];
}
/**
* Minimal `EventEmitter` interface that is molded against the Node.js
* `EventEmitter` interface.
*
* @constructor
* @public
*/
function EventEmitter() {
this._events = new Events();
this._eventsCount = 0;
}
/**
* Return an array listing the events for which the emitter has registered
* listeners.
*
* @returns {Array}
* @public
*/
EventEmitter.prototype.eventNames = function eventNames() {
var names = []
, events
, name;
if (this._eventsCount === 0) return names;
for (name in (events = this._events)) {
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
}
if (Object.getOwnPropertySymbols) {
return names.concat(Object.getOwnPropertySymbols(events));
}
return names;
};
/**
* Return the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Array} The registered listeners.
* @public
*/
EventEmitter.prototype.listeners = function listeners(event) {
var evt = prefix ? prefix + event : event
, handlers = this._events[evt];
if (!handlers) return [];
if (handlers.fn) return [handlers.fn];
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
ee[i] = handlers[i].fn;
}
return ee;
};
/**
* Return the number of listeners listening to a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Number} The number of listeners.
* @public
*/
EventEmitter.prototype.listenerCount = function listenerCount(event) {
var evt = prefix ? prefix + event : event
, listeners = this._events[evt];
if (!listeners) return 0;
if (listeners.fn) return 1;
return listeners.length;
};
/**
* Calls each of the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Boolean} `true` if the event had listeners, else `false`.
* @public
*/
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return false;
var listeners = this._events[evt]
, len = arguments.length
, args
, i;
if (listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
switch (len) {
case 1: return listeners.fn.call(listeners.context), true;
case 2: return listeners.fn.call(listeners.context, a1), true;
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}
for (i = 1, args = new Array(len -1); i < len; i++) {
args[i - 1] = arguments[i];
}
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length
, j;
for (i = 0; i < length; i++) {
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
switch (len) {
case 1: listeners[i].fn.call(listeners[i].context); break;
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
default:
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
args[j - 1] = arguments[j];
}
listeners[i].fn.apply(listeners[i].context, args);
}
}
}
return true;
};
/**
* Add a listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.on = function on(event, fn, context) {
return addListener(this, event, fn, context, false);
};
/**
* Add a one-time listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.once = function once(event, fn, context) {
return addListener(this, event, fn, context, true);
};
/**
* Remove the listeners of a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn Only remove the listeners that match this function.
* @param {*} context Only remove the listeners that have this context.
* @param {Boolean} once Only remove one-time listeners.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return this;
if (!fn) {
clearEvent(this, evt);
return this;
}
var listeners = this._events[evt];
if (listeners.fn) {
if (
listeners.fn === fn &&
(!once || listeners.once) &&
(!context || listeners.context === context)
) {
clearEvent(this, evt);
}
} else {
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
if (
listeners[i].fn !== fn ||
(once && !listeners[i].once) ||
(context && listeners[i].context !== context)
) {
events.push(listeners[i]);
}
}
//
// Reset the array, or remove it completely if we have no more listeners.
//
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
else clearEvent(this, evt);
}
return this;
};
/**
* Remove all listeners, or those of the specified event.
*
* @param {(String|Symbol)} [event] The event name.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
var evt;
if (event) {
evt = prefix ? prefix + event : event;
if (this._events[evt]) clearEvent(this, evt);
} else {
this._events = new Events();
this._eventsCount = 0;
}
return this;
};
//
// Alias methods names because people roll like that.
//
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
//
// Expose the prefix.
//
EventEmitter.prefixed = prefix;
//
// Allow `EventEmitter` to be imported as module namespace.
//
EventEmitter.EventEmitter = EventEmitter;
//
// Expose the module.
//
if ('undefined' !== typeof module) {
module.exports = EventEmitter;
}

View File

@@ -0,0 +1,4 @@
import EventEmitter from './index.js'
export { EventEmitter }
export default EventEmitter

View File

@@ -0,0 +1,62 @@
{
"name": "eventemitter3",
"version": "5.0.4",
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"require": "./index.js"
},
"./package.json": "./package.json"
},
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"rollup": "rm -rf dist && rollup -c",
"benchmark": "find benchmarks/run -name '*.js' -exec benchmarks/start.sh {} \\;",
"test": "c8 --reporter=lcov --reporter=text mocha test/test.js",
"test-esm": "mocha test/test.mjs",
"prepublishOnly": "npm run rollup"
},
"files": [
"index.js",
"index.mjs",
"index.d.ts",
"dist"
],
"repository": {
"type": "git",
"url": "git://github.com/primus/eventemitter3.git"
},
"keywords": [
"EventEmitter",
"EventEmitter2",
"EventEmitter3",
"Events",
"addEventListener",
"addListener",
"emit",
"emits",
"emitter",
"event",
"once",
"pub/sub",
"publish",
"reactor",
"subscribe"
],
"author": "Arnout Kazemier",
"license": "MIT",
"bugs": {
"url": "https://github.com/primus/eventemitter3/issues"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-terser": "^0.4.0",
"assume": "^2.2.0",
"c8": "^10.1.3",
"mocha": "^11.7.5",
"rollup": "^4.5.2"
}
}

48
node_modules/@solana/wallet-adapter-base/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "@solana/wallet-adapter-base",
"version": "0.9.27",
"author": "Solana Maintainers <maintainers@solana.foundation>",
"repository": "https://github.com/anza-xyz/wallet-adapter",
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
},
"files": [
"lib",
"src",
"LICENSE"
],
"engines": {
"node": ">=20"
},
"type": "module",
"sideEffects": false,
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/types/index.d.ts",
"exports": {
"require": "./lib/cjs/index.js",
"import": "./lib/esm/index.js",
"types": "./lib/types/index.d.ts"
},
"peerDependencies": {
"@solana/web3.js": "^1.98.0"
},
"dependencies": {
"@solana/wallet-standard-features": "^1.3.0",
"@wallet-standard/base": "^1.1.0",
"@wallet-standard/features": "^1.1.0",
"eventemitter3": "^5.0.1"
},
"devDependencies": {
"@solana/web3.js": "^1.98.2",
"@types/node-fetch": "^2.6.12",
"shx": "^0.4.0"
},
"scripts": {
"build": "tsc --build --verbose && pnpm run package",
"clean": "shx mkdir -p lib && shx rm -rf lib",
"lint": "prettier --check 'src/{*,**/*}.{ts,tsx,js,jsx,json}' && eslint",
"package": "shx mkdir -p lib/cjs && shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json"
}
}

193
node_modules/@solana/wallet-adapter-base/src/adapter.ts generated vendored Normal file
View File

@@ -0,0 +1,193 @@
import type { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js';
import EventEmitter from 'eventemitter3';
import { type WalletError, WalletNotConnectedError } from './errors.js';
import type { SupportedTransactionVersions, TransactionOrVersionedTransaction } from './transaction.js';
export { EventEmitter };
export interface WalletAdapterEvents {
connect(publicKey: PublicKey): void;
disconnect(): void;
error(error: WalletError): void;
readyStateChange(readyState: WalletReadyState): void;
}
export interface SendTransactionOptions extends SendOptions {
signers?: Signer[];
}
// WalletName is a nominal type that wallet adapters should use, e.g. `'MyCryptoWallet' as WalletName<'MyCryptoWallet'>`
// https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d
export type WalletName<T extends string = string> = T & { __brand__: 'WalletName' };
export interface WalletAdapterProps<Name extends string = string> {
name: WalletName<Name>;
url: string;
icon: string;
readyState: WalletReadyState;
publicKey: PublicKey | null;
connecting: boolean;
connected: boolean;
supportedTransactionVersions?: SupportedTransactionVersions;
autoConnect(): Promise<void>;
connect(): Promise<void>;
disconnect(): Promise<void>;
sendTransaction(
transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>,
connection: Connection,
options?: SendTransactionOptions
): Promise<TransactionSignature>;
}
export type WalletAdapter<Name extends string = string> = WalletAdapterProps<Name> & EventEmitter<WalletAdapterEvents>;
/**
* A wallet's readiness describes a series of states that the wallet can be in,
* depending on what kind of wallet it is. An installable wallet (eg. a browser
* extension like Phantom) might be `Installed` if we've found the Phantom API
* in the global scope, or `NotDetected` otherwise. A loadable, zero-install
* runtime (eg. Torus Wallet) might simply signal that it's `Loadable`. Use this
* metadata to personalize the wallet list for each user (eg. to show their
* installed wallets first).
*/
export enum WalletReadyState {
/**
* User-installable wallets can typically be detected by scanning for an API
* that they've injected into the global context. If such an API is present,
* we consider the wallet to have been installed.
*/
Installed = 'Installed',
NotDetected = 'NotDetected',
/**
* Loadable wallets are always available to you. Since you can load them at
* any time, it's meaningless to say that they have been detected.
*/
Loadable = 'Loadable',
/**
* If a wallet is not supported on a given platform (eg. server-rendering, or
* mobile) then it will stay in the `Unsupported` state.
*/
Unsupported = 'Unsupported',
}
export abstract class BaseWalletAdapter<Name extends string = string>
extends EventEmitter<WalletAdapterEvents>
implements WalletAdapter<Name>
{
abstract name: WalletName<Name>;
abstract url: string;
abstract icon: string;
abstract readyState: WalletReadyState;
abstract publicKey: PublicKey | null;
abstract connecting: boolean;
abstract supportedTransactionVersions?: SupportedTransactionVersions;
get connected() {
return !!this.publicKey;
}
async autoConnect() {
await this.connect();
}
abstract connect(): Promise<void>;
abstract disconnect(): Promise<void>;
abstract sendTransaction(
transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>,
connection: Connection,
options?: SendTransactionOptions
): Promise<TransactionSignature>;
protected async prepareTransaction(
transaction: Transaction,
connection: Connection,
options: SendOptions = {}
): Promise<Transaction> {
const publicKey = this.publicKey;
if (!publicKey) throw new WalletNotConnectedError();
transaction.feePayer = transaction.feePayer || publicKey;
transaction.recentBlockhash =
transaction.recentBlockhash ||
(
await connection.getLatestBlockhash({
commitment: options.preflightCommitment,
minContextSlot: options.minContextSlot,
})
).blockhash;
return transaction;
}
}
export function scopePollingDetectionStrategy(detect: () => boolean): void {
// Early return when server-side rendering
if (typeof window === 'undefined' || typeof document === 'undefined') return;
const disposers: (() => void)[] = [];
function detectAndDispose() {
const detected = detect();
if (detected) {
for (const dispose of disposers) {
dispose();
}
}
}
// Strategy #1: Try detecting every second.
const interval =
// TODO: #334 Replace with idle callback strategy.
setInterval(detectAndDispose, 1000);
disposers.push(() => clearInterval(interval));
// Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.
if (
// Implies that `DOMContentLoaded` has not yet fired.
document.readyState === 'loading'
) {
document.addEventListener('DOMContentLoaded', detectAndDispose, { once: true });
disposers.push(() => document.removeEventListener('DOMContentLoaded', detectAndDispose));
}
// Strategy #3: Detect after the `window` has fully loaded.
if (
// If the `complete` state has been reached, we're too late.
document.readyState !== 'complete'
) {
window.addEventListener('load', detectAndDispose, { once: true });
disposers.push(() => window.removeEventListener('load', detectAndDispose));
}
// Strategy #4: Detect synchronously, now.
detectAndDispose();
}
/**
* Users on iOS can be redirected into a wallet's in-app browser automatically,
* if that wallet has a universal link configured to do so
* But should not be redirected from within a webview, eg. if they're already
* inside a wallet's browser
* This function can be used to identify users who are on iOS and can be redirected
*
* @returns true if the user can be redirected
*/
export function isIosAndRedirectable() {
// SSR: return false
if (!navigator) return false;
const userAgent = navigator.userAgent.toLowerCase();
// if on iOS the user agent will contain either iPhone or iPad
// caveat: if requesting desktop site then this won't work
const isIos = userAgent.includes('iphone') || userAgent.includes('ipad');
// if in a webview then it will not include Safari
// note that other iOS browsers also include Safari
// so we will redirect only if Safari is also included
const isSafari = userAgent.includes('safari');
return isIos && isSafari;
}

77
node_modules/@solana/wallet-adapter-base/src/errors.ts generated vendored Normal file
View File

@@ -0,0 +1,77 @@
export class WalletError extends Error {
error: any;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
constructor(message?: string, error?: any) {
super(message);
this.error = error;
}
}
export class WalletNotReadyError extends WalletError {
name = 'WalletNotReadyError';
}
export class WalletLoadError extends WalletError {
name = 'WalletLoadError';
}
export class WalletConfigError extends WalletError {
name = 'WalletConfigError';
}
export class WalletConnectionError extends WalletError {
name = 'WalletConnectionError';
}
export class WalletDisconnectedError extends WalletError {
name = 'WalletDisconnectedError';
}
export class WalletDisconnectionError extends WalletError {
name = 'WalletDisconnectionError';
}
export class WalletAccountError extends WalletError {
name = 'WalletAccountError';
}
export class WalletPublicKeyError extends WalletError {
name = 'WalletPublicKeyError';
}
export class WalletKeypairError extends WalletError {
name = 'WalletKeypairError';
}
export class WalletNotConnectedError extends WalletError {
name = 'WalletNotConnectedError';
}
export class WalletSendTransactionError extends WalletError {
name = 'WalletSendTransactionError';
}
export class WalletSignTransactionError extends WalletError {
name = 'WalletSignTransactionError';
}
export class WalletSignMessageError extends WalletError {
name = 'WalletSignMessageError';
}
export class WalletSignInError extends WalletError {
name = 'WalletSignInError';
}
export class WalletTimeoutError extends WalletError {
name = 'WalletTimeoutError';
}
export class WalletWindowBlockedError extends WalletError {
name = 'WalletWindowBlockedError';
}
export class WalletWindowClosedError extends WalletError {
name = 'WalletWindowClosedError';
}

View File

@@ -0,0 +1,6 @@
export * from './adapter.js';
export * from './errors.js';
export * from './signer.js';
export * from './standard.js';
export * from './transaction.js';
export * from './types.js';

144
node_modules/@solana/wallet-adapter-base/src/signer.ts generated vendored Normal file
View File

@@ -0,0 +1,144 @@
import type { SolanaSignInInput, SolanaSignInOutput } from '@solana/wallet-standard-features';
import type { Connection, TransactionSignature } from '@solana/web3.js';
import {
BaseWalletAdapter,
type SendTransactionOptions,
type WalletAdapter,
type WalletAdapterProps,
} from './adapter.js';
import { WalletSendTransactionError, WalletSignTransactionError } from './errors.js';
import { isVersionedTransaction, type TransactionOrVersionedTransaction } from './transaction.js';
export interface SignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transaction: T
): Promise<T>;
signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transactions: T[]
): Promise<T[]>;
}
export type SignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> & SignerWalletAdapterProps<Name>;
export abstract class BaseSignerWalletAdapter<Name extends string = string>
extends BaseWalletAdapter<Name>
implements SignerWalletAdapter<Name>
{
async sendTransaction(
transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>,
connection: Connection,
options: SendTransactionOptions = {}
): Promise<TransactionSignature> {
let emit = true;
try {
if (isVersionedTransaction(transaction)) {
if (!this.supportedTransactionVersions)
throw new WalletSendTransactionError(
`Sending versioned transactions isn't supported by this wallet`
);
if (!this.supportedTransactionVersions.has(transaction.version))
throw new WalletSendTransactionError(
`Sending transaction version ${transaction.version} isn't supported by this wallet`
);
try {
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, options);
} catch (error: any) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
} else {
try {
const { signers, ...sendOptions } = options;
transaction = await this.prepareTransaction(transaction, connection, sendOptions);
signers?.length && transaction.partialSign(...signers);
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, sendOptions);
} catch (error: any) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
}
} catch (error: any) {
if (emit) {
this.emit('error', error);
}
throw error;
}
}
abstract signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transaction: T
): Promise<T>;
async signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transactions: T[]
): Promise<T[]> {
for (const transaction of transactions) {
if (isVersionedTransaction(transaction)) {
if (!this.supportedTransactionVersions)
throw new WalletSignTransactionError(
`Signing versioned transactions isn't supported by this wallet`
);
if (!this.supportedTransactionVersions.has(transaction.version))
throw new WalletSignTransactionError(
`Signing transaction version ${transaction.version} isn't supported by this wallet`
);
}
}
const signedTransactions: T[] = [];
for (const transaction of transactions) {
signedTransactions.push(await this.signTransaction(transaction));
}
return signedTransactions;
}
}
export interface MessageSignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signMessage(message: Uint8Array): Promise<Uint8Array>;
}
export type MessageSignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> &
MessageSignerWalletAdapterProps<Name>;
export abstract class BaseMessageSignerWalletAdapter<Name extends string = string>
extends BaseSignerWalletAdapter<Name>
implements MessageSignerWalletAdapter<Name>
{
abstract signMessage(message: Uint8Array): Promise<Uint8Array>;
}
export interface SignInMessageSignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signIn(input?: SolanaSignInInput): Promise<SolanaSignInOutput>;
}
export type SignInMessageSignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> &
SignInMessageSignerWalletAdapterProps<Name>;
export abstract class BaseSignInMessageSignerWalletAdapter<Name extends string = string>
extends BaseMessageSignerWalletAdapter<Name>
implements SignInMessageSignerWalletAdapter<Name>
{
abstract signIn(input?: SolanaSignInInput): Promise<SolanaSignInOutput>;
}

View File

@@ -0,0 +1,42 @@
import {
SolanaSignAndSendTransaction,
type SolanaSignAndSendTransactionFeature,
type SolanaSignInFeature,
type SolanaSignMessageFeature,
SolanaSignTransaction,
type SolanaSignTransactionFeature,
} from '@solana/wallet-standard-features';
import type { Wallet as StandardWallet, WalletWithFeatures as StandardWalletWithFeatures } from '@wallet-standard/base';
import {
StandardConnect,
type StandardConnectFeature,
type StandardDisconnectFeature,
StandardEvents,
type StandardEventsFeature,
} from '@wallet-standard/features';
import type { WalletAdapter, WalletAdapterProps } from './adapter.js';
export type WalletAdapterCompatibleStandardWallet = StandardWalletWithFeatures<
StandardConnectFeature &
StandardEventsFeature &
(SolanaSignAndSendTransactionFeature | SolanaSignTransactionFeature) &
(StandardDisconnectFeature | SolanaSignMessageFeature | SolanaSignInFeature | object)
>;
export interface StandardWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
wallet: WalletAdapterCompatibleStandardWallet;
standard: true;
}
export type StandardWalletAdapter<Name extends string = string> = WalletAdapter<Name> &
StandardWalletAdapterProps<Name>;
export function isWalletAdapterCompatibleStandardWallet(
wallet: StandardWallet
): wallet is WalletAdapterCompatibleStandardWallet {
return (
StandardConnect in wallet.features &&
StandardEvents in wallet.features &&
(SolanaSignAndSendTransaction in wallet.features || SolanaSignTransaction in wallet.features)
);
}

View File

@@ -0,0 +1,13 @@
import type { Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
export type SupportedTransactionVersions = ReadonlySet<TransactionVersion> | null | undefined;
export type TransactionOrVersionedTransaction<S extends SupportedTransactionVersions> = S extends null | undefined
? Transaction
: Transaction | VersionedTransaction;
export function isVersionedTransaction(
transaction: Transaction | VersionedTransaction
): transaction is VersionedTransaction {
return 'version' in transaction;
}

16
node_modules/@solana/wallet-adapter-base/src/types.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import type { WalletAdapter } from './adapter.js';
import type { MessageSignerWalletAdapter, SignerWalletAdapter, SignInMessageSignerWalletAdapter } from './signer.js';
import type { StandardWalletAdapter } from './standard.js';
export type Adapter =
| WalletAdapter
| SignerWalletAdapter
| MessageSignerWalletAdapter
| SignInMessageSignerWalletAdapter
| StandardWalletAdapter;
export enum WalletAdapterNetwork {
Mainnet = 'mainnet-beta',
Testnet = 'testnet',
Devnet = 'devnet',
}