Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solflare-wallet/metamask-wallet-standard

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solflare-wallet/metamask-wallet-standard - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

2

lib/cjs/account.d.ts
import type { WalletAccount } from '@wallet-standard/base';
export declare class SolflareMetamaskWalletAccount implements WalletAccount {
export declare class SolflareMetaMaskWalletAccount implements WalletAccount {
#private;

@@ -4,0 +4,0 @@ get address(): string;

@@ -14,5 +14,5 @@ "use strict";

};
var _SolflareMetamaskWalletAccount_address, _SolflareMetamaskWalletAccount_publicKey, _SolflareMetamaskWalletAccount_chains, _SolflareMetamaskWalletAccount_features, _SolflareMetamaskWalletAccount_label, _SolflareMetamaskWalletAccount_icon;
var _SolflareMetaMaskWalletAccount_address, _SolflareMetaMaskWalletAccount_publicKey, _SolflareMetaMaskWalletAccount_chains, _SolflareMetaMaskWalletAccount_features, _SolflareMetaMaskWalletAccount_label, _SolflareMetaMaskWalletAccount_icon;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SolflareMetamaskWalletAccount = void 0;
exports.SolflareMetaMaskWalletAccount = void 0;
const wallet_standard_features_1 = require("@solana/wallet-standard-features");

@@ -22,40 +22,40 @@ const solana_js_1 = require("./solana.js");

const features = [wallet_standard_features_1.SolanaSignAndSendTransaction, wallet_standard_features_1.SolanaSignTransaction, wallet_standard_features_1.SolanaSignMessage];
class SolflareMetamaskWalletAccount {
class SolflareMetaMaskWalletAccount {
get address() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_address, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_address, "f");
}
get publicKey() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_publicKey, "f").slice();
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_publicKey, "f").slice();
}
get chains() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_chains, "f").slice();
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_chains, "f").slice();
}
get features() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_features, "f").slice();
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_features, "f").slice();
}
get label() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_label, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_label, "f");
}
get icon() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_icon, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_icon, "f");
}
constructor({ address, publicKey, label, icon }) {
_SolflareMetamaskWalletAccount_address.set(this, void 0);
_SolflareMetamaskWalletAccount_publicKey.set(this, void 0);
_SolflareMetamaskWalletAccount_chains.set(this, void 0);
_SolflareMetamaskWalletAccount_features.set(this, void 0);
_SolflareMetamaskWalletAccount_label.set(this, void 0);
_SolflareMetamaskWalletAccount_icon.set(this, void 0);
if (new.target === SolflareMetamaskWalletAccount) {
_SolflareMetaMaskWalletAccount_address.set(this, void 0);
_SolflareMetaMaskWalletAccount_publicKey.set(this, void 0);
_SolflareMetaMaskWalletAccount_chains.set(this, void 0);
_SolflareMetaMaskWalletAccount_features.set(this, void 0);
_SolflareMetaMaskWalletAccount_label.set(this, void 0);
_SolflareMetaMaskWalletAccount_icon.set(this, void 0);
if (new.target === SolflareMetaMaskWalletAccount) {
Object.freeze(this);
}
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_address, address, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_publicKey, publicKey, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_chains, chains, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_features, features, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_label, label, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_icon, icon, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_address, address, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_publicKey, publicKey, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_chains, chains, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_features, features, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_label, label, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_icon, icon, "f");
}
}
exports.SolflareMetamaskWalletAccount = SolflareMetamaskWalletAccount;
_SolflareMetamaskWalletAccount_address = new WeakMap(), _SolflareMetamaskWalletAccount_publicKey = new WeakMap(), _SolflareMetamaskWalletAccount_chains = new WeakMap(), _SolflareMetamaskWalletAccount_features = new WeakMap(), _SolflareMetamaskWalletAccount_label = new WeakMap(), _SolflareMetamaskWalletAccount_icon = new WeakMap();
exports.SolflareMetaMaskWalletAccount = SolflareMetaMaskWalletAccount;
_SolflareMetaMaskWalletAccount_address = new WeakMap(), _SolflareMetaMaskWalletAccount_publicKey = new WeakMap(), _SolflareMetaMaskWalletAccount_chains = new WeakMap(), _SolflareMetaMaskWalletAccount_features = new WeakMap(), _SolflareMetaMaskWalletAccount_label = new WeakMap(), _SolflareMetaMaskWalletAccount_icon = new WeakMap();

@@ -1,3 +0,3 @@

import SolflareMetamask from '@solflare-wallet/metamask-sdk';
export declare function initialize(instance?: SolflareMetamask): void;
export declare function initializeWhenDetected(instance?: SolflareMetamask): Promise<void>;
import SolflareMetaMask from '@solflare-wallet/metamask-sdk';
export declare function initialize(instance?: SolflareMetaMask): void;
export declare function initializeWhenDetected(instance?: SolflareMetaMask): Promise<void>;

@@ -25,3 +25,3 @@ "use strict";

isInitialized = true;
(0, register_js_1.registerWallet)(new wallet_js_1.SolflareMetamaskWallet(instance !== null && instance !== void 0 ? instance : new metamask_sdk_1.default()));
(0, register_js_1.registerWallet)(new wallet_js_1.SolflareMetaMaskWallet(instance !== null && instance !== void 0 ? instance : new metamask_sdk_1.default()));
}

@@ -28,0 +28,0 @@ exports.initialize = initialize;

import { type SolanaSignAndSendTransactionFeature, type SolanaSignMessageFeature, type SolanaSignTransactionFeature } from '@solana/wallet-standard-features';
import type { Wallet } from '@wallet-standard/base';
import { type StandardConnectFeature, type StandardDisconnectFeature, type StandardEventsFeature } from '@wallet-standard/features';
import { SolflareMetamaskWalletAccount } from './account.js';
import Solflare from '@solflare-wallet/metamask-sdk';
export declare const SolflareNamespace = "solflare:";
export type SolflareMetamaskFeature = {
[SolflareNamespace]: {
solflare: Solflare;
import { SolflareMetaMaskWalletAccount } from './account.js';
import SolflareMetaMask from '@solflare-wallet/metamask-sdk';
export declare const SolflareMetaMaskNamespace = "solflareMetaMask:";
export type SolflareMetaMaskFeature = {
[SolflareMetaMaskNamespace]: {
solflareMetaMask: SolflareMetaMask;
};
};
export declare class SolflareMetamaskWallet implements Wallet {
export declare class SolflareMetaMaskWallet implements Wallet {
#private;

@@ -18,5 +18,5 @@ get version(): "1.0.0";

get chains(): ("solana:mainnet" | "solana:devnet" | "solana:testnet" | "solana:localnet")[];
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SolanaSignAndSendTransactionFeature & SolanaSignTransactionFeature & SolanaSignMessageFeature & SolflareMetamaskFeature;
get accounts(): SolflareMetamaskWalletAccount[];
constructor(instance: Solflare);
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SolanaSignAndSendTransactionFeature & SolanaSignTransactionFeature & SolanaSignMessageFeature & SolflareMetaMaskFeature;
get accounts(): SolflareMetaMaskWalletAccount[];
constructor(instance: SolflareMetaMask);
}

@@ -25,5 +25,5 @@ "use strict";

};
var _SolflareMetamaskWallet_instances, _SolflareMetamaskWallet_listeners, _SolflareMetamaskWallet_version, _SolflareMetamaskWallet_name, _SolflareMetamaskWallet_icon, _SolflareMetamaskWallet_account, _SolflareMetamaskWallet_solflare, _SolflareMetamaskWallet_on, _SolflareMetamaskWallet_emit, _SolflareMetamaskWallet_off, _SolflareMetamaskWallet_connected, _SolflareMetamaskWallet_disconnected, _SolflareMetamaskWallet_reconnected, _SolflareMetamaskWallet_connect, _SolflareMetamaskWallet_disconnect, _SolflareMetamaskWallet_signAndSendTransaction, _SolflareMetamaskWallet_signTransaction, _SolflareMetamaskWallet_signMessage;
var _SolflareMetaMaskWallet_instances, _SolflareMetaMaskWallet_listeners, _SolflareMetaMaskWallet_version, _SolflareMetaMaskWallet_name, _SolflareMetaMaskWallet_icon, _SolflareMetaMaskWallet_account, _SolflareMetaMaskWallet_instance, _SolflareMetaMaskWallet_on, _SolflareMetaMaskWallet_emit, _SolflareMetaMaskWallet_off, _SolflareMetaMaskWallet_connected, _SolflareMetaMaskWallet_disconnected, _SolflareMetaMaskWallet_reconnected, _SolflareMetaMaskWallet_connect, _SolflareMetaMaskWallet_disconnect, _SolflareMetaMaskWallet_signAndSendTransaction, _SolflareMetaMaskWallet_signTransaction, _SolflareMetaMaskWallet_signMessage;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SolflareMetamaskWallet = exports.SolflareNamespace = void 0;
exports.SolflareMetaMaskWallet = exports.SolflareMetaMaskNamespace = void 0;
const wallet_standard_features_1 = require("@solana/wallet-standard-features");

@@ -36,12 +36,12 @@ const web3_js_1 = require("@solana/web3.js");

const solana_js_1 = require("./solana.js");
exports.SolflareNamespace = 'solflare:';
class SolflareMetamaskWallet {
exports.SolflareMetaMaskNamespace = 'solflareMetaMask:';
class SolflareMetaMaskWallet {
get version() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_version, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_version, "f");
}
get name() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_name, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_name, "f");
}
get icon() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_icon, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_icon, "f");
}

@@ -55,11 +55,11 @@ get chains() {

version: '1.0.0',
connect: __classPrivateFieldGet(this, _SolflareMetamaskWallet_connect, "f")
connect: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_connect, "f")
},
[features_1.StandardDisconnect]: {
version: '1.0.0',
disconnect: __classPrivateFieldGet(this, _SolflareMetamaskWallet_disconnect, "f")
disconnect: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_disconnect, "f")
},
[features_1.StandardEvents]: {
version: '1.0.0',
on: __classPrivateFieldGet(this, _SolflareMetamaskWallet_on, "f")
on: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_on, "f")
},

@@ -69,3 +69,3 @@ [wallet_standard_features_1.SolanaSignAndSendTransaction]: {

supportedTransactionVersions: ['legacy', 0],
signAndSendTransaction: __classPrivateFieldGet(this, _SolflareMetamaskWallet_signAndSendTransaction, "f")
signAndSendTransaction: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signAndSendTransaction, "f")
},

@@ -75,10 +75,10 @@ [wallet_standard_features_1.SolanaSignTransaction]: {

supportedTransactionVersions: ['legacy', 0],
signTransaction: __classPrivateFieldGet(this, _SolflareMetamaskWallet_signTransaction, "f")
signTransaction: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signTransaction, "f")
},
[wallet_standard_features_1.SolanaSignMessage]: {
version: '1.0.0',
signMessage: __classPrivateFieldGet(this, _SolflareMetamaskWallet_signMessage, "f")
signMessage: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signMessage, "f")
},
[exports.SolflareNamespace]: {
solflare: __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f")
[exports.SolflareMetaMaskNamespace]: {
solflareMetaMask: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f")
}

@@ -88,56 +88,56 @@ };

get accounts() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f") ? [__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f")] : [];
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f") ? [__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f")] : [];
}
constructor(instance) {
_SolflareMetamaskWallet_instances.add(this);
_SolflareMetamaskWallet_listeners.set(this, {});
_SolflareMetamaskWallet_version.set(this, '1.0.0');
_SolflareMetamaskWallet_name.set(this, 'MetaMask');
_SolflareMetamaskWallet_icon.set(this, icon_js_1.icon);
_SolflareMetamaskWallet_account.set(this, null);
_SolflareMetamaskWallet_solflare.set(this, void 0);
_SolflareMetamaskWallet_on.set(this, (event, listener) => {
_SolflareMetaMaskWallet_instances.add(this);
_SolflareMetaMaskWallet_listeners.set(this, {});
_SolflareMetaMaskWallet_version.set(this, '1.0.0');
_SolflareMetaMaskWallet_name.set(this, 'MetaMask');
_SolflareMetaMaskWallet_icon.set(this, icon_js_1.icon);
_SolflareMetaMaskWallet_account.set(this, null);
_SolflareMetaMaskWallet_instance.set(this, void 0);
_SolflareMetaMaskWallet_on.set(this, (event, listener) => {
var _a;
((_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event] = [listener]);
return () => __classPrivateFieldGet(this, _SolflareMetamaskWallet_instances, "m", _SolflareMetamaskWallet_off).call(this, event, listener);
((_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event] = [listener]);
return () => __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, "m", _SolflareMetaMaskWallet_off).call(this, event, listener);
});
_SolflareMetamaskWallet_connected.set(this, () => {
_SolflareMetaMaskWallet_connected.set(this, () => {
var _a;
const address = (_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").publicKey) === null || _a === void 0 ? void 0 : _a.toString();
const address = (_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").publicKey) === null || _a === void 0 ? void 0 : _a.toString();
if (address) {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f") || __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f").address !== address) {
__classPrivateFieldSet(this, _SolflareMetamaskWallet_account, new account_js_1.SolflareMetamaskWalletAccount({
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f") || __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f").address !== address) {
__classPrivateFieldSet(this, _SolflareMetaMaskWallet_account, new account_js_1.SolflareMetaMaskWalletAccount({
address,
publicKey: __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").publicKey.toBytes()
publicKey: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").publicKey.toBytes()
}), "f");
__classPrivateFieldGet(this, _SolflareMetamaskWallet_instances, "m", _SolflareMetamaskWallet_emit).call(this, 'change', { accounts: this.accounts });
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, "m", _SolflareMetaMaskWallet_emit).call(this, 'change', { accounts: this.accounts });
}
}
});
_SolflareMetamaskWallet_disconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f")) {
__classPrivateFieldSet(this, _SolflareMetamaskWallet_account, null, "f");
__classPrivateFieldGet(this, _SolflareMetamaskWallet_instances, "m", _SolflareMetamaskWallet_emit).call(this, 'change', { accounts: this.accounts });
_SolflareMetaMaskWallet_disconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f")) {
__classPrivateFieldSet(this, _SolflareMetaMaskWallet_account, null, "f");
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, "m", _SolflareMetaMaskWallet_emit).call(this, 'change', { accounts: this.accounts });
}
});
_SolflareMetamaskWallet_reconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").publicKey) {
__classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f").call(this);
_SolflareMetaMaskWallet_reconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").publicKey) {
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f").call(this);
}
else {
__classPrivateFieldGet(this, _SolflareMetamaskWallet_disconnected, "f").call(this);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_disconnected, "f").call(this);
}
});
_SolflareMetamaskWallet_connect.set(this, () => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f")) {
yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").connect();
_SolflareMetaMaskWallet_connect.set(this, () => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f")) {
yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").connect();
}
__classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f").call(this);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f").call(this);
return { accounts: this.accounts };
}));
_SolflareMetamaskWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").disconnect();
_SolflareMetaMaskWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").disconnect();
}));
_SolflareMetamaskWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
_SolflareMetaMaskWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('not connected');

@@ -149,7 +149,7 @@ const outputs = [];

const { minContextSlot, preflightCommitment, skipPreflight, maxRetries } = options || {};
if (account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');
if (!(0, solana_js_1.isSolanaChain)(chain))
throw new Error('invalid chain');
const signature = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signAndSendTransaction(web3_js_1.VersionedTransaction.deserialize(transaction), {
const signature = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signAndSendTransaction(web3_js_1.VersionedTransaction.deserialize(transaction), {
preflightCommitment,

@@ -164,3 +164,3 @@ minContextSlot,

for (const input of inputs) {
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_signAndSendTransaction, "f").call(this, input)));
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signAndSendTransaction, "f").call(this, input)));
}

@@ -170,4 +170,4 @@ }

}));
_SolflareMetamaskWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
_SolflareMetaMaskWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('not connected');

@@ -178,7 +178,7 @@ const outputs = [];

const { transaction, account, chain } = inputs[0];
if (account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');
if (chain && !(0, solana_js_1.isSolanaChain)(chain))
throw new Error('invalid chain');
const signedTransaction = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signTransaction(web3_js_1.VersionedTransaction.deserialize(transaction));
const signedTransaction = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signTransaction(web3_js_1.VersionedTransaction.deserialize(transaction));
outputs.push({ signedTransaction: signedTransaction.serialize() });

@@ -189,3 +189,3 @@ }

for (const input of inputs) {
if (input.account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (input.account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');

@@ -205,3 +205,3 @@ if (input.chain) {

const transactions = inputs.map(({ transaction }) => web3_js_1.VersionedTransaction.deserialize(transaction));
const signedTransactions = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signAllTransactions(transactions);
const signedTransactions = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signAllTransactions(transactions);
outputs.push(...signedTransactions.map((signedTransaction) => ({

@@ -213,4 +213,4 @@ signedTransaction: signedTransaction.serialize()

}));
_SolflareMetamaskWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
_SolflareMetaMaskWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('not connected');

@@ -221,5 +221,5 @@ const outputs = [];

const { message, account } = inputs[0];
if (account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');
const signature = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signMessage(message);
const signature = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signMessage(message);
outputs.push({ signedMessage: message, signature });

@@ -229,3 +229,3 @@ }

for (const input of inputs) {
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_signMessage, "f").call(this, input)));
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signMessage, "f").call(this, input)));
}

@@ -235,20 +235,20 @@ }

}));
if (new.target === SolflareMetamaskWallet) {
if (new.target === SolflareMetaMaskWallet) {
Object.freeze(this);
}
__classPrivateFieldSet(this, _SolflareMetamaskWallet_solflare, instance, "f");
instance.on('connect', __classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f"), this);
instance.on('disconnect', __classPrivateFieldGet(this, _SolflareMetamaskWallet_disconnected, "f"), this);
instance.on('accountChanged', __classPrivateFieldGet(this, _SolflareMetamaskWallet_reconnected, "f"), this);
__classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f").call(this);
__classPrivateFieldSet(this, _SolflareMetaMaskWallet_instance, instance, "f");
instance.on('connect', __classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f"), this);
instance.on('disconnect', __classPrivateFieldGet(this, _SolflareMetaMaskWallet_disconnected, "f"), this);
instance.on('accountChanged', __classPrivateFieldGet(this, _SolflareMetaMaskWallet_reconnected, "f"), this);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f").call(this);
}
}
exports.SolflareMetamaskWallet = SolflareMetamaskWallet;
_SolflareMetamaskWallet_listeners = new WeakMap(), _SolflareMetamaskWallet_version = new WeakMap(), _SolflareMetamaskWallet_name = new WeakMap(), _SolflareMetamaskWallet_icon = new WeakMap(), _SolflareMetamaskWallet_account = new WeakMap(), _SolflareMetamaskWallet_solflare = new WeakMap(), _SolflareMetamaskWallet_on = new WeakMap(), _SolflareMetamaskWallet_connected = new WeakMap(), _SolflareMetamaskWallet_disconnected = new WeakMap(), _SolflareMetamaskWallet_reconnected = new WeakMap(), _SolflareMetamaskWallet_connect = new WeakMap(), _SolflareMetamaskWallet_disconnect = new WeakMap(), _SolflareMetamaskWallet_signAndSendTransaction = new WeakMap(), _SolflareMetamaskWallet_signTransaction = new WeakMap(), _SolflareMetamaskWallet_signMessage = new WeakMap(), _SolflareMetamaskWallet_instances = new WeakSet(), _SolflareMetamaskWallet_emit = function _SolflareMetamaskWallet_emit(event, ...args) {
exports.SolflareMetaMaskWallet = SolflareMetaMaskWallet;
_SolflareMetaMaskWallet_listeners = new WeakMap(), _SolflareMetaMaskWallet_version = new WeakMap(), _SolflareMetaMaskWallet_name = new WeakMap(), _SolflareMetaMaskWallet_icon = new WeakMap(), _SolflareMetaMaskWallet_account = new WeakMap(), _SolflareMetaMaskWallet_instance = new WeakMap(), _SolflareMetaMaskWallet_on = new WeakMap(), _SolflareMetaMaskWallet_connected = new WeakMap(), _SolflareMetaMaskWallet_disconnected = new WeakMap(), _SolflareMetaMaskWallet_reconnected = new WeakMap(), _SolflareMetaMaskWallet_connect = new WeakMap(), _SolflareMetaMaskWallet_disconnect = new WeakMap(), _SolflareMetaMaskWallet_signAndSendTransaction = new WeakMap(), _SolflareMetaMaskWallet_signTransaction = new WeakMap(), _SolflareMetaMaskWallet_signMessage = new WeakMap(), _SolflareMetaMaskWallet_instances = new WeakSet(), _SolflareMetaMaskWallet_emit = function _SolflareMetaMaskWallet_emit(event, ...args) {
var _a;
// eslint-disable-next-line prefer-spread
(_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
}, _SolflareMetamaskWallet_off = function _SolflareMetamaskWallet_off(event, listener) {
(_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
}, _SolflareMetaMaskWallet_off = function _SolflareMetaMaskWallet_off(event, listener) {
var _a;
__classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
};
import type { WalletAccount } from '@wallet-standard/base';
export declare class SolflareMetamaskWalletAccount implements WalletAccount {
export declare class SolflareMetaMaskWalletAccount implements WalletAccount {
#private;

@@ -4,0 +4,0 @@ get address(): string;

@@ -13,3 +13,3 @@ // This is copied with modification from @wallet-standard/wallet

};
var _SolflareMetamaskWalletAccount_address, _SolflareMetamaskWalletAccount_publicKey, _SolflareMetamaskWalletAccount_chains, _SolflareMetamaskWalletAccount_features, _SolflareMetamaskWalletAccount_label, _SolflareMetamaskWalletAccount_icon;
var _SolflareMetaMaskWalletAccount_address, _SolflareMetaMaskWalletAccount_publicKey, _SolflareMetaMaskWalletAccount_chains, _SolflareMetaMaskWalletAccount_features, _SolflareMetaMaskWalletAccount_label, _SolflareMetaMaskWalletAccount_icon;
import { SolanaSignAndSendTransaction, SolanaSignMessage, SolanaSignTransaction } from '@solana/wallet-standard-features';

@@ -19,39 +19,39 @@ import { SOLANA_CHAINS } from './solana.js';

const features = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage];
export class SolflareMetamaskWalletAccount {
export class SolflareMetaMaskWalletAccount {
get address() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_address, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_address, "f");
}
get publicKey() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_publicKey, "f").slice();
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_publicKey, "f").slice();
}
get chains() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_chains, "f").slice();
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_chains, "f").slice();
}
get features() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_features, "f").slice();
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_features, "f").slice();
}
get label() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_label, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_label, "f");
}
get icon() {
return __classPrivateFieldGet(this, _SolflareMetamaskWalletAccount_icon, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWalletAccount_icon, "f");
}
constructor({ address, publicKey, label, icon }) {
_SolflareMetamaskWalletAccount_address.set(this, void 0);
_SolflareMetamaskWalletAccount_publicKey.set(this, void 0);
_SolflareMetamaskWalletAccount_chains.set(this, void 0);
_SolflareMetamaskWalletAccount_features.set(this, void 0);
_SolflareMetamaskWalletAccount_label.set(this, void 0);
_SolflareMetamaskWalletAccount_icon.set(this, void 0);
if (new.target === SolflareMetamaskWalletAccount) {
_SolflareMetaMaskWalletAccount_address.set(this, void 0);
_SolflareMetaMaskWalletAccount_publicKey.set(this, void 0);
_SolflareMetaMaskWalletAccount_chains.set(this, void 0);
_SolflareMetaMaskWalletAccount_features.set(this, void 0);
_SolflareMetaMaskWalletAccount_label.set(this, void 0);
_SolflareMetaMaskWalletAccount_icon.set(this, void 0);
if (new.target === SolflareMetaMaskWalletAccount) {
Object.freeze(this);
}
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_address, address, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_publicKey, publicKey, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_chains, chains, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_features, features, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_label, label, "f");
__classPrivateFieldSet(this, _SolflareMetamaskWalletAccount_icon, icon, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_address, address, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_publicKey, publicKey, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_chains, chains, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_features, features, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_label, label, "f");
__classPrivateFieldSet(this, _SolflareMetaMaskWalletAccount_icon, icon, "f");
}
}
_SolflareMetamaskWalletAccount_address = new WeakMap(), _SolflareMetamaskWalletAccount_publicKey = new WeakMap(), _SolflareMetamaskWalletAccount_chains = new WeakMap(), _SolflareMetamaskWalletAccount_features = new WeakMap(), _SolflareMetamaskWalletAccount_label = new WeakMap(), _SolflareMetamaskWalletAccount_icon = new WeakMap();
_SolflareMetaMaskWalletAccount_address = new WeakMap(), _SolflareMetaMaskWalletAccount_publicKey = new WeakMap(), _SolflareMetaMaskWalletAccount_chains = new WeakMap(), _SolflareMetaMaskWalletAccount_features = new WeakMap(), _SolflareMetaMaskWalletAccount_label = new WeakMap(), _SolflareMetaMaskWalletAccount_icon = new WeakMap();

@@ -1,3 +0,3 @@

import SolflareMetamask from '@solflare-wallet/metamask-sdk';
export declare function initialize(instance?: SolflareMetamask): void;
export declare function initializeWhenDetected(instance?: SolflareMetamask): Promise<void>;
import SolflareMetaMask from '@solflare-wallet/metamask-sdk';
export declare function initialize(instance?: SolflareMetaMask): void;
export declare function initializeWhenDetected(instance?: SolflareMetaMask): Promise<void>;

@@ -11,4 +11,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { registerWallet } from './register.js';
import { SolflareMetamaskWallet } from './wallet.js';
import SolflareMetamask from '@solflare-wallet/metamask-sdk';
import { SolflareMetaMaskWallet } from './wallet.js';
import SolflareMetaMask from '@solflare-wallet/metamask-sdk';
let isInitialized = false;

@@ -20,3 +20,3 @@ export function initialize(instance) {

isInitialized = true;
registerWallet(new SolflareMetamaskWallet(instance !== null && instance !== void 0 ? instance : new SolflareMetamask()));
registerWallet(new SolflareMetaMaskWallet(instance !== null && instance !== void 0 ? instance : new SolflareMetaMask()));
}

@@ -28,3 +28,3 @@ export function initializeWhenDetected(instance) {

}
if (!(yield SolflareMetamask.isSupported())) {
if (!(yield SolflareMetaMask.isSupported())) {
return;

@@ -31,0 +31,0 @@ }

import { type SolanaSignAndSendTransactionFeature, type SolanaSignMessageFeature, type SolanaSignTransactionFeature } from '@solana/wallet-standard-features';
import type { Wallet } from '@wallet-standard/base';
import { type StandardConnectFeature, type StandardDisconnectFeature, type StandardEventsFeature } from '@wallet-standard/features';
import { SolflareMetamaskWalletAccount } from './account.js';
import Solflare from '@solflare-wallet/metamask-sdk';
export declare const SolflareNamespace = "solflare:";
export type SolflareMetamaskFeature = {
[SolflareNamespace]: {
solflare: Solflare;
import { SolflareMetaMaskWalletAccount } from './account.js';
import SolflareMetaMask from '@solflare-wallet/metamask-sdk';
export declare const SolflareMetaMaskNamespace = "solflareMetaMask:";
export type SolflareMetaMaskFeature = {
[SolflareMetaMaskNamespace]: {
solflareMetaMask: SolflareMetaMask;
};
};
export declare class SolflareMetamaskWallet implements Wallet {
export declare class SolflareMetaMaskWallet implements Wallet {
#private;

@@ -18,5 +18,5 @@ get version(): "1.0.0";

get chains(): ("solana:mainnet" | "solana:devnet" | "solana:testnet" | "solana:localnet")[];
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SolanaSignAndSendTransactionFeature & SolanaSignTransactionFeature & SolanaSignMessageFeature & SolflareMetamaskFeature;
get accounts(): SolflareMetamaskWalletAccount[];
constructor(instance: Solflare);
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SolanaSignAndSendTransactionFeature & SolanaSignTransactionFeature & SolanaSignMessageFeature & SolflareMetaMaskFeature;
get accounts(): SolflareMetaMaskWalletAccount[];
constructor(instance: SolflareMetaMask);
}

@@ -21,3 +21,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
var _SolflareMetamaskWallet_instances, _SolflareMetamaskWallet_listeners, _SolflareMetamaskWallet_version, _SolflareMetamaskWallet_name, _SolflareMetamaskWallet_icon, _SolflareMetamaskWallet_account, _SolflareMetamaskWallet_solflare, _SolflareMetamaskWallet_on, _SolflareMetamaskWallet_emit, _SolflareMetamaskWallet_off, _SolflareMetamaskWallet_connected, _SolflareMetamaskWallet_disconnected, _SolflareMetamaskWallet_reconnected, _SolflareMetamaskWallet_connect, _SolflareMetamaskWallet_disconnect, _SolflareMetamaskWallet_signAndSendTransaction, _SolflareMetamaskWallet_signTransaction, _SolflareMetamaskWallet_signMessage;
var _SolflareMetaMaskWallet_instances, _SolflareMetaMaskWallet_listeners, _SolflareMetaMaskWallet_version, _SolflareMetaMaskWallet_name, _SolflareMetaMaskWallet_icon, _SolflareMetaMaskWallet_account, _SolflareMetaMaskWallet_instance, _SolflareMetaMaskWallet_on, _SolflareMetaMaskWallet_emit, _SolflareMetaMaskWallet_off, _SolflareMetaMaskWallet_connected, _SolflareMetaMaskWallet_disconnected, _SolflareMetaMaskWallet_reconnected, _SolflareMetaMaskWallet_connect, _SolflareMetaMaskWallet_disconnect, _SolflareMetaMaskWallet_signAndSendTransaction, _SolflareMetaMaskWallet_signTransaction, _SolflareMetaMaskWallet_signMessage;
import { SolanaSignAndSendTransaction, SolanaSignMessage, SolanaSignTransaction } from '@solana/wallet-standard-features';

@@ -27,15 +27,15 @@ import { VersionedTransaction } from '@solana/web3.js';

import bs58 from 'bs58';
import { SolflareMetamaskWalletAccount } from './account.js';
import { SolflareMetaMaskWalletAccount } from './account.js';
import { icon } from './icon.js';
import { isSolanaChain, SOLANA_CHAINS } from './solana.js';
export const SolflareNamespace = 'solflare:';
export class SolflareMetamaskWallet {
export const SolflareMetaMaskNamespace = 'solflareMetaMask:';
export class SolflareMetaMaskWallet {
get version() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_version, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_version, "f");
}
get name() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_name, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_name, "f");
}
get icon() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_icon, "f");
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_icon, "f");
}

@@ -49,11 +49,11 @@ get chains() {

version: '1.0.0',
connect: __classPrivateFieldGet(this, _SolflareMetamaskWallet_connect, "f")
connect: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_connect, "f")
},
[StandardDisconnect]: {
version: '1.0.0',
disconnect: __classPrivateFieldGet(this, _SolflareMetamaskWallet_disconnect, "f")
disconnect: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_disconnect, "f")
},
[StandardEvents]: {
version: '1.0.0',
on: __classPrivateFieldGet(this, _SolflareMetamaskWallet_on, "f")
on: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_on, "f")
},

@@ -63,3 +63,3 @@ [SolanaSignAndSendTransaction]: {

supportedTransactionVersions: ['legacy', 0],
signAndSendTransaction: __classPrivateFieldGet(this, _SolflareMetamaskWallet_signAndSendTransaction, "f")
signAndSendTransaction: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signAndSendTransaction, "f")
},

@@ -69,10 +69,10 @@ [SolanaSignTransaction]: {

supportedTransactionVersions: ['legacy', 0],
signTransaction: __classPrivateFieldGet(this, _SolflareMetamaskWallet_signTransaction, "f")
signTransaction: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signTransaction, "f")
},
[SolanaSignMessage]: {
version: '1.0.0',
signMessage: __classPrivateFieldGet(this, _SolflareMetamaskWallet_signMessage, "f")
signMessage: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signMessage, "f")
},
[SolflareNamespace]: {
solflare: __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f")
[SolflareMetaMaskNamespace]: {
solflareMetaMask: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f")
}

@@ -82,56 +82,56 @@ };

get accounts() {
return __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f") ? [__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f")] : [];
return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f") ? [__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f")] : [];
}
constructor(instance) {
_SolflareMetamaskWallet_instances.add(this);
_SolflareMetamaskWallet_listeners.set(this, {});
_SolflareMetamaskWallet_version.set(this, '1.0.0');
_SolflareMetamaskWallet_name.set(this, 'MetaMask');
_SolflareMetamaskWallet_icon.set(this, icon);
_SolflareMetamaskWallet_account.set(this, null);
_SolflareMetamaskWallet_solflare.set(this, void 0);
_SolflareMetamaskWallet_on.set(this, (event, listener) => {
_SolflareMetaMaskWallet_instances.add(this);
_SolflareMetaMaskWallet_listeners.set(this, {});
_SolflareMetaMaskWallet_version.set(this, '1.0.0');
_SolflareMetaMaskWallet_name.set(this, 'MetaMask');
_SolflareMetaMaskWallet_icon.set(this, icon);
_SolflareMetaMaskWallet_account.set(this, null);
_SolflareMetaMaskWallet_instance.set(this, void 0);
_SolflareMetaMaskWallet_on.set(this, (event, listener) => {
var _a;
((_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event] = [listener]);
return () => __classPrivateFieldGet(this, _SolflareMetamaskWallet_instances, "m", _SolflareMetamaskWallet_off).call(this, event, listener);
((_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event] = [listener]);
return () => __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, "m", _SolflareMetaMaskWallet_off).call(this, event, listener);
});
_SolflareMetamaskWallet_connected.set(this, () => {
_SolflareMetaMaskWallet_connected.set(this, () => {
var _a;
const address = (_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").publicKey) === null || _a === void 0 ? void 0 : _a.toString();
const address = (_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").publicKey) === null || _a === void 0 ? void 0 : _a.toString();
if (address) {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f") || __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f").address !== address) {
__classPrivateFieldSet(this, _SolflareMetamaskWallet_account, new SolflareMetamaskWalletAccount({
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f") || __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f").address !== address) {
__classPrivateFieldSet(this, _SolflareMetaMaskWallet_account, new SolflareMetaMaskWalletAccount({
address,
publicKey: __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").publicKey.toBytes()
publicKey: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").publicKey.toBytes()
}), "f");
__classPrivateFieldGet(this, _SolflareMetamaskWallet_instances, "m", _SolflareMetamaskWallet_emit).call(this, 'change', { accounts: this.accounts });
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, "m", _SolflareMetaMaskWallet_emit).call(this, 'change', { accounts: this.accounts });
}
}
});
_SolflareMetamaskWallet_disconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f")) {
__classPrivateFieldSet(this, _SolflareMetamaskWallet_account, null, "f");
__classPrivateFieldGet(this, _SolflareMetamaskWallet_instances, "m", _SolflareMetamaskWallet_emit).call(this, 'change', { accounts: this.accounts });
_SolflareMetaMaskWallet_disconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f")) {
__classPrivateFieldSet(this, _SolflareMetaMaskWallet_account, null, "f");
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, "m", _SolflareMetaMaskWallet_emit).call(this, 'change', { accounts: this.accounts });
}
});
_SolflareMetamaskWallet_reconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").publicKey) {
__classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f").call(this);
_SolflareMetaMaskWallet_reconnected.set(this, () => {
if (__classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").publicKey) {
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f").call(this);
}
else {
__classPrivateFieldGet(this, _SolflareMetamaskWallet_disconnected, "f").call(this);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_disconnected, "f").call(this);
}
});
_SolflareMetamaskWallet_connect.set(this, () => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f")) {
yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").connect();
_SolflareMetaMaskWallet_connect.set(this, () => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f")) {
yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").connect();
}
__classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f").call(this);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f").call(this);
return { accounts: this.accounts };
}));
_SolflareMetamaskWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").disconnect();
_SolflareMetaMaskWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").disconnect();
}));
_SolflareMetamaskWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
_SolflareMetaMaskWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('not connected');

@@ -143,7 +143,7 @@ const outputs = [];

const { minContextSlot, preflightCommitment, skipPreflight, maxRetries } = options || {};
if (account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');
if (!isSolanaChain(chain))
throw new Error('invalid chain');
const signature = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signAndSendTransaction(VersionedTransaction.deserialize(transaction), {
const signature = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signAndSendTransaction(VersionedTransaction.deserialize(transaction), {
preflightCommitment,

@@ -158,3 +158,3 @@ minContextSlot,

for (const input of inputs) {
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_signAndSendTransaction, "f").call(this, input)));
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signAndSendTransaction, "f").call(this, input)));
}

@@ -164,4 +164,4 @@ }

}));
_SolflareMetamaskWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
_SolflareMetaMaskWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('not connected');

@@ -172,7 +172,7 @@ const outputs = [];

const { transaction, account, chain } = inputs[0];
if (account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');
if (chain && !isSolanaChain(chain))
throw new Error('invalid chain');
const signedTransaction = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signTransaction(VersionedTransaction.deserialize(transaction));
const signedTransaction = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signTransaction(VersionedTransaction.deserialize(transaction));
outputs.push({ signedTransaction: signedTransaction.serialize() });

@@ -183,3 +183,3 @@ }

for (const input of inputs) {
if (input.account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (input.account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');

@@ -199,3 +199,3 @@ if (input.chain) {

const transactions = inputs.map(({ transaction }) => VersionedTransaction.deserialize(transaction));
const signedTransactions = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signAllTransactions(transactions);
const signedTransactions = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signAllTransactions(transactions);
outputs.push(...signedTransactions.map((signedTransaction) => ({

@@ -207,4 +207,4 @@ signedTransaction: signedTransaction.serialize()

}));
_SolflareMetamaskWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
_SolflareMetaMaskWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('not connected');

@@ -215,5 +215,5 @@ const outputs = [];

const { message, account } = inputs[0];
if (account !== __classPrivateFieldGet(this, _SolflareMetamaskWallet_account, "f"))
if (account !== __classPrivateFieldGet(this, _SolflareMetaMaskWallet_account, "f"))
throw new Error('invalid account');
const signature = yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_solflare, "f").signMessage(message);
const signature = yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instance, "f").signMessage(message);
outputs.push({ signedMessage: message, signature });

@@ -223,3 +223,3 @@ }

for (const input of inputs) {
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetamaskWallet_signMessage, "f").call(this, input)));
outputs.push(...(yield __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signMessage, "f").call(this, input)));
}

@@ -229,19 +229,19 @@ }

}));
if (new.target === SolflareMetamaskWallet) {
if (new.target === SolflareMetaMaskWallet) {
Object.freeze(this);
}
__classPrivateFieldSet(this, _SolflareMetamaskWallet_solflare, instance, "f");
instance.on('connect', __classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f"), this);
instance.on('disconnect', __classPrivateFieldGet(this, _SolflareMetamaskWallet_disconnected, "f"), this);
instance.on('accountChanged', __classPrivateFieldGet(this, _SolflareMetamaskWallet_reconnected, "f"), this);
__classPrivateFieldGet(this, _SolflareMetamaskWallet_connected, "f").call(this);
__classPrivateFieldSet(this, _SolflareMetaMaskWallet_instance, instance, "f");
instance.on('connect', __classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f"), this);
instance.on('disconnect', __classPrivateFieldGet(this, _SolflareMetaMaskWallet_disconnected, "f"), this);
instance.on('accountChanged', __classPrivateFieldGet(this, _SolflareMetaMaskWallet_reconnected, "f"), this);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_connected, "f").call(this);
}
}
_SolflareMetamaskWallet_listeners = new WeakMap(), _SolflareMetamaskWallet_version = new WeakMap(), _SolflareMetamaskWallet_name = new WeakMap(), _SolflareMetamaskWallet_icon = new WeakMap(), _SolflareMetamaskWallet_account = new WeakMap(), _SolflareMetamaskWallet_solflare = new WeakMap(), _SolflareMetamaskWallet_on = new WeakMap(), _SolflareMetamaskWallet_connected = new WeakMap(), _SolflareMetamaskWallet_disconnected = new WeakMap(), _SolflareMetamaskWallet_reconnected = new WeakMap(), _SolflareMetamaskWallet_connect = new WeakMap(), _SolflareMetamaskWallet_disconnect = new WeakMap(), _SolflareMetamaskWallet_signAndSendTransaction = new WeakMap(), _SolflareMetamaskWallet_signTransaction = new WeakMap(), _SolflareMetamaskWallet_signMessage = new WeakMap(), _SolflareMetamaskWallet_instances = new WeakSet(), _SolflareMetamaskWallet_emit = function _SolflareMetamaskWallet_emit(event, ...args) {
_SolflareMetaMaskWallet_listeners = new WeakMap(), _SolflareMetaMaskWallet_version = new WeakMap(), _SolflareMetaMaskWallet_name = new WeakMap(), _SolflareMetaMaskWallet_icon = new WeakMap(), _SolflareMetaMaskWallet_account = new WeakMap(), _SolflareMetaMaskWallet_instance = new WeakMap(), _SolflareMetaMaskWallet_on = new WeakMap(), _SolflareMetaMaskWallet_connected = new WeakMap(), _SolflareMetaMaskWallet_disconnected = new WeakMap(), _SolflareMetaMaskWallet_reconnected = new WeakMap(), _SolflareMetaMaskWallet_connect = new WeakMap(), _SolflareMetaMaskWallet_disconnect = new WeakMap(), _SolflareMetaMaskWallet_signAndSendTransaction = new WeakMap(), _SolflareMetaMaskWallet_signTransaction = new WeakMap(), _SolflareMetaMaskWallet_signMessage = new WeakMap(), _SolflareMetaMaskWallet_instances = new WeakSet(), _SolflareMetaMaskWallet_emit = function _SolflareMetaMaskWallet_emit(event, ...args) {
var _a;
// eslint-disable-next-line prefer-spread
(_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
}, _SolflareMetamaskWallet_off = function _SolflareMetamaskWallet_off(event, listener) {
(_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
}, _SolflareMetaMaskWallet_off = function _SolflareMetaMaskWallet_off(event, listener) {
var _a;
__classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet(this, _SolflareMetamaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
__classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
};
{
"name": "@solflare-wallet/metamask-wallet-standard",
"version": "0.0.9",
"version": "0.0.10",
"author": "Solflare Developers <developers@solflare.com>",

@@ -30,3 +30,3 @@ "repository": "",

"@solana/web3.js": "^1.78.1",
"@solflare-wallet/metamask-sdk": "^0.0.8",
"@solflare-wallet/metamask-sdk": "^0.0.9",
"@wallet-standard/base": "^1.0.1",

@@ -33,0 +33,0 @@ "@wallet-standard/features": "^1.0.3",

@@ -14,3 +14,3 @@ // This is copied with modification from @wallet-standard/wallet

export class SolflareMetamaskWalletAccount implements WalletAccount {
export class SolflareMetaMaskWalletAccount implements WalletAccount {
readonly #address: WalletAccount['address'];

@@ -48,3 +48,3 @@ readonly #publicKey: WalletAccount['publicKey'];

constructor({ address, publicKey, label, icon }: Omit<WalletAccount, 'chains' | 'features'>) {
if (new.target === SolflareMetamaskWalletAccount) {
if (new.target === SolflareMetaMaskWalletAccount) {
Object.freeze(this);

@@ -51,0 +51,0 @@ }

import { registerWallet } from './register.js';
import { SolflareMetamaskWallet } from './wallet.js';
import SolflareMetamask from '@solflare-wallet/metamask-sdk';
import { SolflareMetaMaskWallet } from './wallet.js';
import SolflareMetaMask from '@solflare-wallet/metamask-sdk';
let isInitialized = false;
export function initialize(instance?: SolflareMetamask): void {
export function initialize(instance?: SolflareMetaMask): void {
if (isInitialized) {

@@ -14,6 +14,6 @@ return;

registerWallet(new SolflareMetamaskWallet(instance ?? new SolflareMetamask()));
registerWallet(new SolflareMetaMaskWallet(instance ?? new SolflareMetaMask()));
}
export async function initializeWhenDetected(instance?: SolflareMetamask): Promise<void> {
export async function initializeWhenDetected(instance?: SolflareMetaMask): Promise<void> {
if (isInitialized) {

@@ -23,3 +23,3 @@ return;

if (!(await SolflareMetamask.isSupported())) {
if (!(await SolflareMetaMask.isSupported())) {
return;

@@ -26,0 +26,0 @@ }

@@ -31,17 +31,17 @@ import {

import bs58 from 'bs58';
import { SolflareMetamaskWalletAccount } from './account.js';
import { SolflareMetaMaskWalletAccount } from './account.js';
import { icon } from './icon.js';
import type { SolanaChain } from './solana.js';
import { isSolanaChain, SOLANA_CHAINS } from './solana.js';
import Solflare from '@solflare-wallet/metamask-sdk';
import SolflareMetaMask from '@solflare-wallet/metamask-sdk';
export const SolflareNamespace = 'solflare:';
export const SolflareMetaMaskNamespace = 'solflareMetaMask:';
export type SolflareMetamaskFeature = {
[SolflareNamespace]: {
solflare: Solflare;
export type SolflareMetaMaskFeature = {
[SolflareMetaMaskNamespace]: {
solflareMetaMask: SolflareMetaMask;
};
};
export class SolflareMetamaskWallet implements Wallet {
export class SolflareMetaMaskWallet implements Wallet {
readonly #listeners: { [E in StandardEventsNames]?: StandardEventsListeners[E][] } = {};

@@ -51,4 +51,4 @@ readonly #version = '1.0.0' as const;

readonly #icon = icon;
#account: SolflareMetamaskWalletAccount | null = null;
readonly #solflare: Solflare;
#account: SolflareMetaMaskWalletAccount | null = null;
readonly #instance: SolflareMetaMask;

@@ -77,3 +77,3 @@ get version() {

SolanaSignMessageFeature &
SolflareMetamaskFeature {
SolflareMetaMaskFeature {
return {

@@ -106,4 +106,4 @@ [StandardConnect]: {

},
[SolflareNamespace]: {
solflare: this.#solflare
[SolflareMetaMaskNamespace]: {
solflareMetaMask: this.#instance
}

@@ -117,8 +117,8 @@ };

constructor(instance: Solflare) {
if (new.target === SolflareMetamaskWallet) {
constructor(instance: SolflareMetaMask) {
if (new.target === SolflareMetaMaskWallet) {
Object.freeze(this);
}
this.#solflare = instance;
this.#instance = instance;

@@ -152,8 +152,8 @@ instance.on('connect', this.#connected, this);

#connected = () => {
const address = this.#solflare.publicKey?.toString();
const address = this.#instance.publicKey?.toString();
if (address) {
if (!this.#account || this.#account.address !== address) {
this.#account = new SolflareMetamaskWalletAccount({
this.#account = new SolflareMetaMaskWalletAccount({
address,
publicKey: this.#solflare.publicKey!.toBytes()
publicKey: this.#instance.publicKey!.toBytes()
});

@@ -173,3 +173,3 @@ this.#emit('change', { accounts: this.accounts });

#reconnected = () => {
if (this.#solflare.publicKey) {
if (this.#instance.publicKey) {
this.#connected();

@@ -183,3 +183,3 @@ } else {

if (!this.#account) {
await this.#solflare.connect();
await this.#instance.connect();
}

@@ -193,3 +193,3 @@

#disconnect: StandardDisconnectMethod = async () => {
await this.#solflare.disconnect();
await this.#instance.disconnect();
};

@@ -209,3 +209,3 @@

const signature = await this.#solflare.signAndSendTransaction(
const signature = await this.#instance.signAndSendTransaction(
VersionedTransaction.deserialize(transaction),

@@ -241,3 +241,3 @@ {

const signedTransaction = await this.#solflare.signTransaction(
const signedTransaction = await this.#instance.signTransaction(
VersionedTransaction.deserialize(transaction)

@@ -265,3 +265,3 @@ );

const signedTransactions = await this.#solflare.signAllTransactions(transactions);
const signedTransactions = await this.#instance.signAllTransactions(transactions);

@@ -288,3 +288,3 @@ outputs.push(

const signature = await this.#solflare.signMessage(message);
const signature = await this.#instance.signMessage(message);

@@ -291,0 +291,0 @@ outputs.push({ signedMessage: message, signature });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc