@mysten/wallet-standard
Version:
A suite of standard utilities for implementing wallets based on the Wallet Standard.
21 lines (16 loc) • 941 B
text/typescript
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { StandardConnect, StandardEvents } from '@wallet-standard/core';
import type { Wallet, WalletWithFeatures } from '@wallet-standard/core';
import type { MinimallyRequiredFeatures } from './features/index.js';
// These features are absolutely required for wallets to function in the Sui ecosystem.
// Eventually, as wallets have more consistent support of features, we may want to extend this list.
const REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[] = [StandardConnect, StandardEvents];
export function isWalletWithRequiredFeatureSet<AdditionalFeatures extends Wallet['features']>(
wallet: Wallet,
additionalFeatures: (keyof AdditionalFeatures)[] = [],
): wallet is WalletWithFeatures<MinimallyRequiredFeatures & AdditionalFeatures> {
return [...REQUIRED_FEATURES, ...additionalFeatures].every(
(feature) => feature in wallet.features,
);
}