@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.83 kB
JavaScript
import { w as walletIds } from '../../../../dist/walletIds-dff6dced.browser.esm.js';
import { a as AbstractClientWallet, c as createAsyncLocalStorage } from '../../../../dist/base-a72d5b10.browser.esm.js';
import { updateChainRPCs, defaultChains, Ethereum } from '@thirdweb-dev/chains';
import '../../abstract/dist/thirdweb-dev-wallets-evm-wallets-abstract.browser.esm.js';
import '../../../../dist/defineProperty-350fc508.browser.esm.js';
import 'ethers';
import 'eventemitter3';
import '@thirdweb-dev/sdk';
import '../../../../dist/headers-733a8199.browser.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.browser.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 };