UNPKG

@thirdweb-dev/wallets

Version:

<p align="center"> <br /> <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> <br /> </p> <h1 align="center">thirdweb Wallet SDK</h1> <p align="center"> <a h

48 lines (44 loc) 1.79 kB
import { w as walletIds } from '../../../../dist/walletIds-c34dbb3f.esm.js'; import { a as AbstractClientWallet, c as createAsyncLocalStorage } from '../../../../dist/base-7cb4610a.esm.js'; import { updateChainRPCs, defaultChains, Ethereum } from '@thirdweb-dev/chains'; import '../../abstract/dist/thirdweb-dev-wallets-evm-wallets-abstract.esm.js'; import '../../../../dist/defineProperty-7303a112.esm.js'; import 'ethers'; import 'eventemitter3'; import '@thirdweb-dev/sdk'; import '../../../../dist/headers-31b6ef3b.esm.js'; // eslint-disable-next-line @typescript-eslint/ban-types /** * @internal */ class SignerWallet extends AbstractClientWallet { constructor(options) { super("signerWallet", options); if (options.clientId && options.chain) { options.chain = updateChainRPCs(options.chain, options.clientId); } this.options = options; this.signer = options.signer; this._storage = options?.storage || createAsyncLocalStorage(walletIds.localWallet); } async getConnector() { if (!this.connector) { const { SignerConnector } = await import('../../../connectors/signer/dist/thirdweb-dev-wallets-evm-connectors-signer.esm.js'); if (!this.signer) { this.signer = this.options.signer; } const defaults = (this.options.chain ? [...defaultChains, this.options.chain] : defaultChains).map(c => updateChainRPCs(c, this.options.clientId)); this.connector = new SignerConnector({ chain: this.options.chain || updateChainRPCs(Ethereum, this.options.clientId), signer: this.signer, chains: this.chains || defaults, clientId: this.options.clientId, secretKey: this.options.secretKey }); } return this.connector; } } export { SignerWallet };