@solana/wallet-adapter-slope
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base'; | ||
import { EventEmitter, WalletAdapter, WalletAdapterEvents } from '@solana/wallet-adapter-base'; | ||
import { PublicKey, Transaction } from '@solana/web3.js'; | ||
@@ -7,3 +7,3 @@ export interface SlopeWalletAdapterConfig { | ||
} | ||
export declare class SlopeWalletAdapter extends BaseSignerWalletAdapter { | ||
export declare class SlopeWalletAdapter extends EventEmitter<WalletAdapterEvents> implements WalletAdapter { | ||
private _connecting; | ||
@@ -10,0 +10,0 @@ private _wallet; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,11 +10,6 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SlopeWalletAdapter = void 0; | ||
const wallet_adapter_base_1 = require("@solana/wallet-adapter-base"); | ||
const web3_js_1 = require("@solana/web3.js"); | ||
const bs58_1 = __importDefault(require("bs58")); | ||
class SlopeWalletAdapter extends wallet_adapter_base_1.BaseSignerWalletAdapter { | ||
import { EventEmitter, pollUntilReady, WalletConnectionError, WalletDisconnectionError, WalletError, WalletNotConnectedError, WalletNotFoundError, WalletPublicKeyError, WalletSignatureError, } from '@solana/wallet-adapter-base'; | ||
import { PublicKey } from '@solana/web3.js'; | ||
import bs58 from 'bs58'; | ||
export class SlopeWalletAdapter extends EventEmitter { | ||
constructor(config = {}) { | ||
@@ -27,3 +21,3 @@ super(); | ||
if (!this.ready) | ||
(0, wallet_adapter_base_1.pollUntilReady)(this, config.pollInterval || 1000, config.pollCount || 3); | ||
pollUntilReady(this, config.pollInterval || 1000, config.pollCount || 3); | ||
} | ||
@@ -43,3 +37,4 @@ get publicKey() { | ||
get autoApprove() { | ||
return false; | ||
var _a; | ||
return !!((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.autoApprove); | ||
} | ||
@@ -53,3 +48,3 @@ connect() { | ||
if (!window.Slope) | ||
throw new wallet_adapter_base_1.WalletNotFoundError(); | ||
throw new WalletNotFoundError(); | ||
const wallet = new window.Slope(); | ||
@@ -60,16 +55,16 @@ let account; | ||
if (!data.publicKey) | ||
throw new wallet_adapter_base_1.WalletConnectionError(); | ||
throw new WalletConnectionError(); | ||
account = data.publicKey; | ||
} | ||
catch (error) { | ||
if (error instanceof wallet_adapter_base_1.WalletError) | ||
if (error instanceof WalletError) | ||
throw error; | ||
throw new wallet_adapter_base_1.WalletConnectionError(error === null || error === void 0 ? void 0 : error.message, error); | ||
throw new WalletConnectionError(error === null || error === void 0 ? void 0 : error.message, error); | ||
} | ||
let publicKey; | ||
try { | ||
publicKey = new web3_js_1.PublicKey(account); | ||
publicKey = new PublicKey(account); | ||
} | ||
catch (error) { | ||
throw new wallet_adapter_base_1.WalletPublicKeyError(error === null || error === void 0 ? void 0 : error.message, error); | ||
throw new WalletPublicKeyError(error === null || error === void 0 ? void 0 : error.message, error); | ||
} | ||
@@ -98,13 +93,13 @@ this._wallet = wallet; | ||
if (msg !== 'ok') | ||
throw new wallet_adapter_base_1.WalletDisconnectionError(msg); | ||
throw new WalletDisconnectionError(msg); | ||
} | ||
catch (error) { | ||
if (!(error instanceof wallet_adapter_base_1.WalletError)) { | ||
if (!(error instanceof WalletError)) { | ||
// eslint-disable-next-line no-ex-assign | ||
error = new wallet_adapter_base_1.WalletDisconnectionError(error === null || error === void 0 ? void 0 : error.message, error); | ||
error = new WalletDisconnectionError(error === null || error === void 0 ? void 0 : error.message, error); | ||
} | ||
this.emit('error', error); | ||
} | ||
this.emit('disconnect'); | ||
} | ||
this.emit('disconnect'); | ||
}); | ||
@@ -117,10 +112,10 @@ } | ||
if (!wallet) | ||
throw new wallet_adapter_base_1.WalletNotConnectedError(); | ||
throw new WalletNotConnectedError(); | ||
try { | ||
const message = bs58_1.default.encode(transaction.serializeMessage()); | ||
const message = bs58.encode(transaction.serializeMessage()); | ||
const { msg, data } = yield wallet.signTransaction(message); | ||
if (!data.publicKey || !data.signature) | ||
throw new wallet_adapter_base_1.WalletSignTransactionError(msg); | ||
const publicKey = new web3_js_1.PublicKey(data.publicKey); | ||
const signature = bs58_1.default.decode(data.signature); | ||
throw new WalletSignatureError(msg); | ||
const publicKey = new PublicKey(data.publicKey); | ||
const signature = bs58.decode(data.signature); | ||
transaction.addSignature(publicKey, signature); | ||
@@ -130,5 +125,5 @@ return transaction; | ||
catch (error) { | ||
if (error instanceof wallet_adapter_base_1.WalletError) | ||
if (error instanceof WalletError) | ||
throw error; | ||
throw new wallet_adapter_base_1.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error); | ||
throw new WalletSignatureError(error === null || error === void 0 ? void 0 : error.message, error); | ||
} | ||
@@ -148,12 +143,12 @@ } | ||
if (!wallet) | ||
throw new wallet_adapter_base_1.WalletNotConnectedError(); | ||
throw new WalletNotConnectedError(); | ||
try { | ||
const messages = transactions.map((transaction) => bs58_1.default.encode(transaction.serializeMessage())); | ||
const messages = transactions.map((transaction) => bs58.encode(transaction.serializeMessage())); | ||
const { msg, data } = yield wallet.signAllTransactions(messages); | ||
const length = transactions.length; | ||
if (!data.publicKey || ((_a = data.signatures) === null || _a === void 0 ? void 0 : _a.length) !== length) | ||
throw new wallet_adapter_base_1.WalletSignTransactionError(msg); | ||
const publicKey = new web3_js_1.PublicKey(data.publicKey); | ||
throw new WalletSignatureError(msg); | ||
const publicKey = new PublicKey(data.publicKey); | ||
for (let i = 0; i < length; i++) { | ||
transactions[i].addSignature(publicKey, bs58_1.default.decode(data.signatures[i])); | ||
transactions[i].addSignature(publicKey, bs58.decode(data.signatures[i])); | ||
} | ||
@@ -163,5 +158,5 @@ return transactions; | ||
catch (error) { | ||
if (error instanceof wallet_adapter_base_1.WalletError) | ||
if (error instanceof WalletError) | ||
throw error; | ||
throw new wallet_adapter_base_1.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error); | ||
throw new WalletSignatureError(error === null || error === void 0 ? void 0 : error.message, error); | ||
} | ||
@@ -176,3 +171,2 @@ } | ||
} | ||
exports.SlopeWalletAdapter = SlopeWalletAdapter; | ||
//# sourceMappingURL=adapter.js.map |
@@ -1,14 +0,2 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./adapter"), exports); | ||
export * from './adapter'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@solana/wallet-adapter-slope", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Solana Maintainers <maintainers@solana.foundation>", | ||
@@ -12,4 +12,3 @@ "repository": "https://github.com/solana-labs/wallet-adapter", | ||
"lib", | ||
"src", | ||
"LICENSE" | ||
"src" | ||
], | ||
@@ -20,18 +19,15 @@ "publishConfig": { | ||
"scripts": { | ||
"clean": "shx rm -rf lib/*", | ||
"clean": "rm -rf lib/*", | ||
"build": "yarn clean && tsc" | ||
}, | ||
"peerDependencies": { | ||
"@solana/wallet-adapter-base": "^0.5.2", | ||
"@solana/wallet-adapter-base": "^0.4.1", | ||
"@solana/web3.js": "^1.20.0" | ||
}, | ||
"dependencies": { | ||
"@types/bs58": "^4.0.1", | ||
"bs58": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"@solana/wallet-adapter-base": "^0.5.2", | ||
"@solana/web3.js": "^1.20.0" | ||
"@solana/wallet-adapter-base": "^0.4.1", | ||
"@solana/web3.js": "^1.20.0", | ||
"@types/bs58": "^4.0.1" | ||
}, | ||
"gitHead": "139856c15453e583411b162a927c42f3c99ca158" | ||
"gitHead": "e180bc70c6f422ef12cc32b03215f1c880bae7b1" | ||
} |
import { | ||
BaseSignerWalletAdapter, | ||
EventEmitter, | ||
pollUntilReady, | ||
WalletAccountError, | ||
WalletAdapter, | ||
WalletAdapterEvents, | ||
WalletConnectionError, | ||
@@ -11,3 +12,3 @@ WalletDisconnectionError, | ||
WalletPublicKeyError, | ||
WalletSignTransactionError, | ||
WalletSignatureError, | ||
} from '@solana/wallet-adapter-base'; | ||
@@ -18,2 +19,3 @@ import { PublicKey, Transaction } from '@solana/web3.js'; | ||
interface SlopeWallet { | ||
autoApprove: boolean; | ||
connect(): Promise<{ | ||
@@ -55,3 +57,3 @@ msg: string; | ||
export class SlopeWalletAdapter extends BaseSignerWalletAdapter { | ||
export class SlopeWalletAdapter extends EventEmitter<WalletAdapterEvents> implements WalletAdapter { | ||
private _connecting: boolean; | ||
@@ -87,3 +89,3 @@ private _wallet: SlopeWallet | null; | ||
get autoApprove(): boolean { | ||
return false; | ||
return !!this._wallet?.autoApprove; | ||
} | ||
@@ -147,5 +149,5 @@ | ||
} | ||
} | ||
this.emit('disconnect'); | ||
} | ||
this.emit('disconnect'); | ||
} | ||
@@ -162,3 +164,3 @@ | ||
if (!data.publicKey || !data.signature) throw new WalletSignTransactionError(msg); | ||
if (!data.publicKey || !data.signature) throw new WalletSignatureError(msg); | ||
@@ -172,3 +174,3 @@ const publicKey = new PublicKey(data.publicKey); | ||
if (error instanceof WalletError) throw error; | ||
throw new WalletSignTransactionError(error?.message, error); | ||
throw new WalletSignatureError(error?.message, error); | ||
} | ||
@@ -191,3 +193,3 @@ } catch (error: any) { | ||
const length = transactions.length; | ||
if (!data.publicKey || data.signatures?.length !== length) throw new WalletSignTransactionError(msg); | ||
if (!data.publicKey || data.signatures?.length !== length) throw new WalletSignatureError(msg); | ||
@@ -203,3 +205,3 @@ const publicKey = new PublicKey(data.publicKey); | ||
if (error instanceof WalletError) throw error; | ||
throw new WalletSignTransactionError(error?.message, error); | ||
throw new WalletSignatureError(error?.message, error); | ||
} | ||
@@ -206,0 +208,0 @@ } catch (error: any) { |
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
2
30895
3
353
+ Added@solana/wallet-adapter-base@0.4.1(transitive)
- Removed@types/bs58@^4.0.1
- Removedbs58@^4.0.1
- Removed@solana/wallet-adapter-base@0.5.2(transitive)
- Removed@types/bs58@4.0.4(transitive)
- Removed@types/node@22.9.0(transitive)
- Removedundici-types@6.19.8(transitive)