
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@talisman-connect/wallets
Advanced tools
This package provides the building blocks for wallet connection UIs.
This package provides the building blocks for wallet connection UIs.
Dapps currently use the @polkadot/extension-dapp
package with web3Enable
.
While it is a great way to enable all wallets at once, it does cause multiple unnecessary wallet extension popups.
This is not a problem when it was just Polkadot.js extension. But now with Talisman and possibly some other wallet extensions coming in, the multiple popups is not desirable.
Furthermore, most use cases, one wallet is selected (and enabled) at one time.
@talisman-connect/wallets
aims to solve this issue.
npm i --save @talisman-connect/wallets
import { getWallets } from '@talisman-connect/wallets';
const DAPP_NAME = /* Get Dapp name */
// ...
const MyWalletSelector = () => {
const supportedWallets: Wallet[] = getWallets();
return (
<div>
{supportedWallets.map((wallet: Wallet) => {
<button
key={wallet.extensionName}
onClick={async () => {
try {
await wallet.enable(DAPP_NAME);
const unsubscribe = await wallet.subscribeAccounts((accounts: WalletAccount[]) => {
// Save accounts...
// Also save the selected wallet name as well...
});
} catch (err) {
// Handle error. Refer to `libs/wallets/src/lib/errors`
}
}}
>
Connect to {wallet.title}
</button>
})}
<div>
);
}
try {
// NOTE: If `account` object is not handy, then use `getWalletBySource` to get the wallet then the signer.
const signer = account.wallet.signer;
// NOTE: This line will trigger the extension popup
const { signature } = await signer.signRaw({
type: 'payload',
data: 'Some data to sign...',
address: account.address,
});
} catch (err) {
// Handle error...
}
getWallets(): Wallet[]
Retrieves all the supported wallets.
getWalletBySource(source: string): Wallet
Retrieves the wallet by extension name (source). Useful if account: WalletAccount
object is not available.
wallet.enable(dappName)
Needs to be called first before subscribeAccounts
. Connects to the wallet extension.
This will trigger the extension to popup if it's the first time being enabled.
wallet.subscribeAccounts(callback): UnsubscribeFn
Subscribe to the wallet's accounts.
NOTE: Call the returned unsubscribe
function on unmount.
wallet.extension
This is the main object that Dapp developers will need to interface.
Refer to the appropriate documentation on what the object has to offer.
Example in BaseDotsamaWallet.extension()
.
wallet.signer
This is for convenience and is derived from the wallet.extension
.
Refer to libs/wallets/src/types.ts
.
/src/lib
. (i.e. /src/lib/foo-wallet/index.ts
)class
which implements Wallet
. (i.e. export class FooWallet implements Wallet
)supportedWallets
array in libs/wallets/src/lib/wallets.ts
.logo
should not exceed 10KB (will be inlined)NOTE: There may be 2 or more wallets that share a common wallet interface. It is recommended to create a base class in this case.
Refer to BaseDotsamaWallet
for an example base class and its derived classes.
Run nx test wallets
to execute the unit tests via Jest.
FAQs
This package provides the building blocks for wallet connection UIs.
We found that @talisman-connect/wallets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.