New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@particle-network/connect

Package Overview
Dependencies
Maintainers
4
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@particle-network/connect - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

lib/types/utils/isMobile.d.ts

32

lib/connectors/injected.js

@@ -61,2 +61,15 @@ "use strict";

_this.chainId = chainId;
_this.onAccountsChanged = function (accounts) {
if (accounts.length === 0) {
_this.provider = undefined;
}
_this.emit('accountsChanged', accounts);
};
_this.onChainChanged = function (chainId) {
_this.emit('chainChanged', chainId);
};
_this.onDisconnect = function () {
_this.provider = undefined;
_this.emit('disconnect');
};
return _this;

@@ -67,2 +80,3 @@ }

var provider, error_1;
var _this = this;
return __generator(this, function (_a) {

@@ -77,2 +91,7 @@ switch (_a.label) {

_a.trys.push([1, 4, , 5]);
if (provider.on) {
provider.on('accountsChanged', this.onAccountsChanged);
provider.on('chainChanged', function () { return _this.onChainChanged; });
provider.on('disconnect', function () { return _this.onDisconnect; });
}
return [4 /*yield*/, provider.request({ method: 'eth_requestAccounts' })];

@@ -97,3 +116,5 @@ case 2:

_a.label = 7;
case 7: return [2 /*return*/, provider];
case 7:
this.provider = provider;
return [2 /*return*/, provider];
}

@@ -104,5 +125,8 @@ });

InjectedConnector.prototype.disconnect = function () {
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/];
}); });
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this.provider = undefined;
return [2 /*return*/];
});
});
};

@@ -109,0 +133,0 @@ return InjectedConnector;

@@ -17,2 +17,13 @@ "use strict";

})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -85,2 +96,15 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var _this = _super.call(this, chainId) || this;
_this.onAccountsChanged = function (accounts) {
if (accounts.length === 0) {
_this.provider = undefined;
}
_this.emit('accountsChanged', accounts);
};
_this.onChainChanged = function (chainId) {
_this.emit('chainChanged', chainId);
};
_this.onDisconnect = function () {
_this.provider = undefined;
_this.emit('disconnect');
};
_this.chainId = chainId;

@@ -92,2 +116,3 @@ return _this;

var provider, accounts, isConnected, permissions, error_1;
var _this = this;
return __generator(this, function (_a) {

@@ -103,2 +128,7 @@ switch (_a.label) {

throw new errors_1.ConnectorNotFoundError();
if (provider.on) {
provider.on('accountsChanged', this.onAccountsChanged);
provider.on('chainChanged', function () { return _this.onChainChanged; });
provider.on('disconnect', function () { return _this.onDisconnect; });
}
_a.label = 2;

@@ -143,5 +173,8 @@ case 2:

MetaMaskConnector.prototype.disconnect = function () {
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/];
}); });
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this.provider = undefined;
return [2 /*return*/];
});
});
};

@@ -182,3 +215,3 @@ MetaMaskConnector.prototype.getProvider = function () {

exports.MetaMaskConnector = MetaMaskConnector;
var metaMask = function () { return ({
var metaMask = function (opts) { return ({
id: 'metamask',

@@ -194,3 +227,3 @@ name: 'MetaMask',

? new MetaMaskConnector(chain.id)
: (0, wallet_connect_1.getWalletConnectConnector)({ chainId: chain.id });
: (0, wallet_connect_1.getWalletConnectConnector)(__assign(__assign({}, opts), { chainId: chain.id }));
return connector;

@@ -197,0 +230,0 @@ },

@@ -60,2 +60,15 @@ "use strict";

var _this = _super.call(this, opts) || this;
_this.onAccountsChanged = function (accounts) {
if (accounts.length === 0) {
_this.provider = undefined;
}
_this.emit('accountsChanged', accounts);
};
_this.onChainChanged = function (chainId) {
_this.emit('chainChanged', chainId);
};
_this.onDisconnect = function () {
_this.provider = undefined;
_this.emit('disconnect');
};
_this.opts = opts;

@@ -67,2 +80,3 @@ return _this;

var provider;
var _this = this;
return __generator(this, function (_a) {

@@ -75,2 +89,7 @@ switch (_a.label) {

provider = new this.opts.package(window.particle.auth);
if (provider.on) {
provider.on('accountsChanged', this.onAccountsChanged);
provider.on('chainChanged', function () { return _this.onChainChanged; });
provider.on('disconnect', function () { return _this.onDisconnect; });
}
return [4 /*yield*/, provider.request({ method: 'eth_requestAccounts' })];

@@ -77,0 +96,0 @@ case 1:

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.rainbow = void 0;
var wallet_connect_1 = require("./wallet-connect");
var rainbow = function () { return ({
var rainbow = function (opts) { return ({
id: 'rainbow',

@@ -13,3 +24,3 @@ name: 'Rainbow',

createConnector: function (chain) {
var connector = (0, wallet_connect_1.getWalletConnectConnector)({ chainId: chain.id });
var connector = (0, wallet_connect_1.getWalletConnectConnector)(__assign(__assign({}, opts), { chainId: chain.id }));
return connector;

@@ -16,0 +27,0 @@ },

47

lib/connectors/wallet-connect.js

@@ -17,2 +17,13 @@ "use strict";

})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

@@ -101,2 +112,15 @@ if (k2 === undefined) k2 = k;

}); };
_this.onAccountsChanged = function (accounts) {
if (accounts.length === 0) {
_this.provider = undefined;
}
_this.emit('accountsChanged', accounts);
};
_this.onChainChanged = function (chainId) {
_this.emit('chainChanged', chainId);
};
_this.onDisconnect = function () {
_this.provider = undefined;
_this.emit('disconnect');
};
_this.opts = opts;

@@ -108,2 +132,3 @@ return _this;

var provider;
var _this = this;
return __generator(this, function (_a) {

@@ -114,3 +139,9 @@ switch (_a.label) {

provider = _a.sent();
if (provider.on) {
provider.on('accountsChanged', this.onAccountsChanged);
provider.on('chainChanged', function () { return _this.onChainChanged; });
provider.on('disconnect', function () { return _this.onDisconnect; });
}
if (!provider.enable) return [3 /*break*/, 4];
console.log('WalletConnectConnector enable');
return [4 /*yield*/, provider.enable()];

@@ -161,3 +192,3 @@ case 2:

bridge = 'https://bridge.walletconnect.org';
qrcode = false;
qrcode = true;
infuraId = '';

@@ -198,5 +229,3 @@ rpc = undefined;

switch (_a.label) {
case 0:
console.log('walletconnect connector connect');
return [4 /*yield*/, this.evmSwitchChain(this.opts.chainId, provider)];
case 0: return [4 /*yield*/, this.evmSwitchChain(this.opts.chainId, provider)];
case 1:

@@ -223,11 +252,3 @@ _a.sent();

createConnector: function (chain) {
if (opts) {
opts.chainId = chain.id;
}
else {
opts = { chainId: chain.id };
}
//@ts-ignore
var options = opts;
var connector = getWalletConnectConnector(options);
var connector = getWalletConnectConnector(__assign(__assign({}, opts), { chainId: chain.id }));
return connector;

@@ -234,0 +255,0 @@ },

@@ -114,2 +114,27 @@ "use strict";

_this.connectorMap = {};
_this.onAccountsChanged = function (accounts) {
if (accounts.length === 0) {
_this.controller.setCachedProvider();
_this.emit('disconnect');
}
else {
_this.emit('accountsChanged', accounts);
}
};
_this.onChainChanged = function (chainId) {
var chain = (0, chains_1.getEVMChainById)(Number(chainId));
if (chain) {
_this.emit('chainChanged', chain);
}
else {
var solanaChain = (0, chains_1.getSolanaChainById)(Number(chainId));
if (solanaChain) {
_this.emit('chainChanged', solanaChain);
}
}
};
_this.onDisconnect = function () {
_this.controller.setCachedProvider();
_this.emit('disconnect');
};
if (!(0, chains_1.isChainSupported)(config.chain)) {

@@ -168,2 +193,6 @@ throw new Error('chain not supported');

});
console.log('Particle listen event');
connector_1.on('accountsChanged', this.onAccountsChanged);
connector_1.on('chainChanged', function () { return _this.onChainChanged; });
connector_1.on('disconnect', function () { return _this.onDisconnect; });
return connector_1;

@@ -295,5 +324,2 @@ }

});
ParticleConnect.prototype.isSolanaProvider = function (provider) {
return provider.connect && provider.signAllTransactions;
};
ParticleConnect.prototype.createParticleProvider = function (chainType) {

@@ -300,0 +326,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -14,3 +14,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getChainInfo = exports.isChainSupported = exports.getEVMChainById = exports.supportChains = exports.EVMChains = exports.Solana = void 0;
exports.getChainInfo = exports.isChainSupported = exports.getSolanaChainById = exports.getEVMChainById = exports.supportChains = exports.EVMChains = exports.Solana = void 0;
exports.Solana = {

@@ -188,2 +188,13 @@ icon: 'https://static.particle.network/token-list/solana/native.png',

exports.getEVMChainById = getEVMChainById;
function getSolanaChainById(chainId) {
var chainName = 'Solana';
if (Object.keys(exports.Solana.chainIds).includes(chainId.toString())) {
return {
name: chainName,
id: chainId,
};
}
return undefined;
}
exports.getSolanaChainById = getSolanaChainById;
function isChainSupported(chain) {

@@ -190,0 +201,0 @@ var chainInfo = exports.supportChains[chain.name];

@@ -7,4 +7,11 @@ import type { EVMProvider, Provider, SolanaProvider } from '../types';

chainChanged(chainId: string): void;
error(error: any): void;
accountsChanged(accounts: string[]): void;
}
export declare type ConnectKitConnector<C extends Connector = Connector> = {
connector: C;
mobile?: {
getUri?: () => Promise<string>;
};
qrCode: () => Promise<string>;
};
export declare abstract class Connector extends EventEmitter<ConnecterEvents> {

@@ -11,0 +18,0 @@ provider: Provider | undefined;

@@ -8,2 +8,5 @@ import type { EVMProvider, DownloadUrls, Wallet } from '../types';

disconnect(): Promise<void>;
private onAccountsChanged;
private onChainChanged;
private onDisconnect;
}

@@ -10,0 +13,0 @@ export interface InjectedOptions {

import type { EVMProvider, SolanaProvider, Wallet } from '../types';
import type { WalletConnectConnectorOptions } from './wallet-connect';
import { EVMConnector } from './base';

@@ -14,3 +15,6 @@ export declare function isMetaMaskInjected(): boolean;

private findProvider;
private onAccountsChanged;
private onChainChanged;
private onDisconnect;
}
export declare const metaMask: () => Wallet;
export declare const metaMask: (opts?: WalletConnectConnectorOptions) => Wallet;

@@ -11,3 +11,6 @@ import type { EVMProvider, Wallet } from '../types';

disconnect(): Promise<void>;
private onAccountsChanged;
private onChainChanged;
private onDisconnect;
}
export declare const particleLocalEVM: (opts: ParticleLocalProviderConfig) => Wallet;
import type { Wallet } from '../types';
export declare const rainbow: () => Wallet;
import type { WalletConnectConnectorOptions } from './wallet-connect';
export declare const rainbow: (opts?: WalletConnectConnectorOptions) => Wallet;

@@ -11,2 +11,3 @@ import type { EVMProvider, SolanaProvider, Wallet } from '../types';

}
export declare type WalletConnectConnectorOptions = Omit<IWalletConnectConnectorOptions, 'chainId'>;
export default class WalletConnectConnector extends EVMConnector {

@@ -20,4 +21,7 @@ private opts;

private onConnect;
private onAccountsChanged;
private onChainChanged;
private onDisconnect;
}
export declare function getWalletConnectConnector(opts: IWalletConnectConnectorOptions): WalletConnectConnector;
export declare const walletconnect: (opts?: Partial<IWalletConnectConnectorOptions>) => Wallet;
export declare const walletconnect: (opts?: WalletConnectConnectorOptions) => Wallet;

@@ -9,3 +9,3 @@ import { ParticleNetwork } from '@particle-network/auth';

chainChanged(chain: Chain): void;
error(error: any): void;
accountsChanged(accounts: string[]): void;
}

@@ -20,2 +20,5 @@ export declare class ParticleConnect extends EventEmitter<ConnectEvents> {

private walletConnector;
private onAccountsChanged;
private onChainChanged;
private onDisconnect;
private connectParticle;

@@ -32,4 +35,3 @@ connect(id?: string, options?: any): Promise<Provider>;

get cachedProviderId(): string | undefined | null;
private isSolanaProvider;
private createParticleProvider;
}

@@ -652,3 +652,4 @@ export declare const Solana: {

export declare function getEVMChainById(chainId: number): Chain | undefined;
export declare function getSolanaChainById(chainId: number): Chain | undefined;
export declare function isChainSupported(chain: Chain): boolean;
export declare function getChainInfo(chain: Chain): ChainInfo | undefined;
{
"name": "@particle-network/connect",
"version": "0.3.2",
"version": "0.3.3",
"files": [

@@ -5,0 +5,0 @@ "lib",

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc