@solana/wallet-adapter-sollet
Advanced tools
Comparing version 0.11.6 to 0.11.7
@@ -37,2 +37,3 @@ "use strict"; | ||
const wallet_adapter_base_1 = require("@solana/wallet-adapter-base"); | ||
const web3_js_1 = require("@solana/web3.js"); | ||
class BaseSolletWalletAdapter extends wallet_adapter_base_1.BaseMessageSignerWalletAdapter { | ||
@@ -49,2 +50,3 @@ constructor({ provider, network = wallet_adapter_base_1.WalletAdapterNetwork.Mainnet, timeout = 10000 } = {}) { | ||
this._wallet = null; | ||
this._publicKey = null; | ||
this.emit('error', new wallet_adapter_base_1.WalletDisconnectedError()); | ||
@@ -59,2 +61,3 @@ this.emit('disconnect'); | ||
this._wallet = null; | ||
this._publicKey = null; | ||
if (this._readyState !== wallet_adapter_base_1.WalletReadyState.Unsupported) { | ||
@@ -78,4 +81,3 @@ if (typeof this._provider === 'string') { | ||
get publicKey() { | ||
var _a; | ||
return ((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.publicKey) || null; | ||
return this._publicKey; | ||
} | ||
@@ -172,6 +174,14 @@ get connecting() { | ||
if (!wallet.publicKey) | ||
throw new wallet_adapter_base_1.WalletPublicKeyError(); | ||
throw new wallet_adapter_base_1.WalletAccountError(); | ||
let publicKey; | ||
try { | ||
publicKey = new web3_js_1.PublicKey(wallet.publicKey.toBytes()); | ||
} | ||
catch (error) { | ||
throw new wallet_adapter_base_1.WalletPublicKeyError(error === null || error === void 0 ? void 0 : error.message, error); | ||
} | ||
wallet.on('disconnect', this._disconnected); | ||
this._wallet = wallet; | ||
this.emit('connect', wallet.publicKey); | ||
this._publicKey = publicKey; | ||
this.emit('connect', publicKey); | ||
} | ||
@@ -193,2 +203,3 @@ catch (error) { | ||
this._wallet = null; | ||
this._publicKey = null; | ||
// HACK: sol-wallet-adapter doesn't reliably fulfill its promise or emit an event on disconnect | ||
@@ -195,0 +206,0 @@ const handleDisconnect = wallet.handleDisconnect; |
import type SolWalletAdapter from '@project-serum/sol-wallet-adapter'; | ||
import { BaseMessageSignerWalletAdapter, WalletAdapterNetwork, WalletReadyState } from '@solana/wallet-adapter-base'; | ||
import type { PublicKey, Transaction } from '@solana/web3.js'; | ||
import type { Transaction } from '@solana/web3.js'; | ||
import { PublicKey } from '@solana/web3.js'; | ||
interface SolletWallet { | ||
@@ -18,2 +19,3 @@ postMessage?(...args: unknown[]): unknown; | ||
protected _wallet: SolWalletAdapter | null; | ||
protected _publicKey: PublicKey | null; | ||
protected _readyState: WalletReadyState; | ||
@@ -20,0 +22,0 @@ constructor({ provider, network, timeout }?: SolletWalletAdapterConfig); |
{ | ||
"name": "@solana/wallet-adapter-sollet", | ||
"version": "0.11.6", | ||
"version": "0.11.7", | ||
"author": "Solana Maintainers <maintainers@solana.foundation>", | ||
@@ -13,4 +13,5 @@ "repository": "https://github.com/solana-labs/wallet-adapter", | ||
"exports": { | ||
"require": "./lib/cjs/index.js", | ||
"import": "./lib/esm/index.mjs", | ||
"require": "./lib/cjs/index.js" | ||
"types": "./lib/types/index.d.ts" | ||
}, | ||
@@ -35,3 +36,3 @@ "files": [ | ||
"@project-serum/sol-wallet-adapter": "^0.2.6", | ||
"@solana/wallet-adapter-base": "^0.9.10" | ||
"@solana/wallet-adapter-base": "^0.9.12" | ||
}, | ||
@@ -41,3 +42,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "29b57115d1fd7bf097f14ca82cbb1c96e65b8372" | ||
"gitHead": "723e197f5bda4661b7bede354858948ce5d889c8" | ||
} |
@@ -5,2 +5,3 @@ import type SolWalletAdapter from '@project-serum/sol-wallet-adapter'; | ||
scopePollingDetectionStrategy, | ||
WalletAccountError, | ||
WalletAdapterNetwork, | ||
@@ -23,3 +24,4 @@ WalletConfigError, | ||
} from '@solana/wallet-adapter-base'; | ||
import type { PublicKey, Transaction } from '@solana/web3.js'; | ||
import type { Transaction } from '@solana/web3.js'; | ||
import { PublicKey } from '@solana/web3.js'; | ||
@@ -48,2 +50,3 @@ interface SolletWallet { | ||
protected _wallet: SolWalletAdapter | null; | ||
protected _publicKey: PublicKey | null; | ||
protected _readyState: WalletReadyState = | ||
@@ -62,2 +65,3 @@ typeof window === 'undefined' || typeof document === 'undefined' | ||
this._wallet = null; | ||
this._publicKey = null; | ||
@@ -80,15 +84,15 @@ if (this._readyState !== WalletReadyState.Unsupported) { | ||
get publicKey(): PublicKey | null { | ||
return this._wallet?.publicKey || null; | ||
get publicKey() { | ||
return this._publicKey; | ||
} | ||
get connecting(): boolean { | ||
get connecting() { | ||
return this._connecting; | ||
} | ||
get connected(): boolean { | ||
get connected() { | ||
return !!this._wallet?.connected; | ||
} | ||
get readyState(): WalletReadyState { | ||
get readyState() { | ||
return this._readyState; | ||
@@ -106,3 +110,3 @@ } | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const provider = this._provider || window!.sollet!; | ||
const provider = this._provider || window.sollet!; | ||
@@ -176,9 +180,17 @@ let SolWalletAdapterClass: typeof SolWalletAdapter; | ||
if (!wallet.publicKey) throw new WalletPublicKeyError(); | ||
if (!wallet.publicKey) throw new WalletAccountError(); | ||
let publicKey: PublicKey; | ||
try { | ||
publicKey = new PublicKey(wallet.publicKey.toBytes()); | ||
} catch (error: any) { | ||
throw new WalletPublicKeyError(error?.message, error); | ||
} | ||
wallet.on('disconnect', this._disconnected); | ||
this._wallet = wallet; | ||
this._publicKey = publicKey; | ||
this.emit('connect', wallet.publicKey); | ||
this.emit('connect', publicKey); | ||
} catch (error: any) { | ||
@@ -198,2 +210,3 @@ this.emit('error', error); | ||
this._wallet = null; | ||
this._publicKey = null; | ||
@@ -295,2 +308,3 @@ // HACK: sol-wallet-adapter doesn't reliably fulfill its promise or emit an event on disconnect | ||
this._wallet = null; | ||
this._publicKey = null; | ||
@@ -297,0 +311,0 @@ this.emit('error', new WalletDisconnectedError()); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91448
1030