@thirdweb-dev/wallets
Version:
<p align="center"> <br /> <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> <br /> </p> <h1 align="center">thirdweb Wallet SDK</h1> <p align="center"> <a href="ht
50 lines (47 loc) • 2.08 kB
JavaScript
import { _ as _classPrivateFieldInitSpec, a as _classPrivateFieldSet } from '../../../../dist/classPrivateFieldSet-e25e1cec.esm.js';
import { w as walletIds } from '../../../../dist/walletIds-18a8e969.esm.js';
import { a as AbstractClientWallet, c as createAsyncLocalStorage } from '../../../../dist/base-b9012a78.esm.js';
import { updateChainRPCs, defaultChains, Ethereum } from '@thirdweb-dev/chains';
import '../../../../dist/classPrivateMethodGet-71fe23d8.esm.js';
import '../../abstract/dist/thirdweb-dev-wallets-evm-wallets-abstract.esm.js';
import '../../../../dist/defineProperty-e24c82ea.esm.js';
import 'ethers';
import 'eventemitter3';
import '@thirdweb-dev/sdk';
// eslint-disable-next-line @typescript-eslint/ban-types
var _storage = /*#__PURE__*/new WeakMap();
class SignerWallet extends AbstractClientWallet {
constructor(options) {
super("signerWallet", options);
_classPrivateFieldInitSpec(this, _storage, {
writable: true,
value: void 0
});
if (options.clientId && options.chain) {
options.chain = updateChainRPCs(options.chain, options.clientId);
}
this.options = options;
this.signer = options.signer;
_classPrivateFieldSet(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 };