Socket
Socket
Sign inDemoInstall

@web3-onboard/wagmi

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3-onboard/wagmi - npm Package Compare versions

Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6

17

dist/index.js

@@ -1,2 +0,2 @@

import { createConfig, createConnector } from '@wagmi/core';
import { createConfig, createConnector, getConnectors } from '@wagmi/core';
import { createWagmiChains, createWalletId } from './utils';

@@ -27,3 +27,4 @@ import { connect as wagmiConnect } from '@wagmi/core';

wagmiConnect,
wagmiDisconnectWallet
wagmiDisconnectWallet,
getWagmiConnector
};

@@ -48,2 +49,3 @@ }

}
console.log('wagmiConnectorFn', wagmiConnectorFn);
const connectors = [...Object.values(wagmiConnectorFn)];

@@ -100,2 +102,13 @@ const viemChains = await createWagmiChains(chainsList || [], transports);

}
function getWagmiConnector(label) {
try {
const wagmiConnectors = getConnectors(wagmiConfig);
if (!(wagmiConnectors === null || wagmiConnectors === void 0 ? void 0 : wagmiConnectors.length))
return undefined;
return wagmiConnectors.find(connector => connector.name === label);
}
catch (e) {
console.error('error disconnecting wallet from wagmi', e);
}
}
const convertW3OToWagmiWallet = (label, provider, coreProviderMethods) => {

@@ -102,0 +115,0 @@ if (!coreProviderMethods || typeof coreProviderMethods === undefined) {

3

dist/types.d.ts

@@ -1,2 +0,2 @@

import type { Config, ConnectReturnType, CreateConnectorFn } from '@wagmi/core';
import type { Config, ConnectReturnType, Connector, CreateConnectorFn } from '@wagmi/core';
import type { Chain, EIP1193Provider, ProviderAccounts } from '@web3-onboard/common';

@@ -23,2 +23,3 @@ import type { ConnectParameters } from '@wagmi/core';

wagmiDisconnectWallet: (label: string) => Promise<Config | undefined>;
getWagmiConnector: (label: string) => Connector | undefined;
};
{
"name": "@web3-onboard/wagmi",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"description": "Module to configure, connect and return web3-onboard wallets as wagmi wallets and wagmi-config to be used with wagmi-core methods",

@@ -67,5 +67,5 @@ "keywords": [

"viem": "2.12.0",
"@wagmi/core": "2.10.3",
"@wagmi/core": "2.10.4",
"eventemitter3": "^4.0.7"
}
}

@@ -18,2 +18,7 @@ # @web3-onboard/wagmi

### `wagmiConnector` and Connectors
`wagmiConnector` is a property returned as part of the wallet state object and can be used to interact with
the WAGMI API returned from this module or an external WAGMI instance. Please see examples below...
```ts

@@ -23,3 +28,2 @@ import Onboard from '@web3-onboard/core'

import wagmi from '@web3-onboard/wagmi'
import { parseEther } from 'viem'
import {

@@ -36,2 +40,3 @@ sendTransaction as wagmiSendTransaction,

const onboard = Onboard({
// This javascript object is unordered meaning props do not require a certain order
wagmi,

@@ -52,3 +57,4 @@ wallets: [injected],

// current primary wallet - as multiple wallets can connect this value is the currently active
const [currentPrimaryWallet] = onboard.state.get().wallets
const [activeWallet] = onboard.state.get().wallets
const { wagmiConnector } = activeWallet
const wagmiConfig = onboard.state.get().wagmiConfig

@@ -58,3 +64,3 @@ const result = await wagmiSendTransaction(wagmiConfig, {

// desired connector to send txn from
account: currentPrimaryWallet.accounts[0],
connector: wagmiConnector,
value: parseEther('0.001')

@@ -65,13 +71,10 @@ })

async function switchWagmiChain(chainId) {
let chainAsNumber
if (isHex(chainId)) {
chainAsNumber = fromHex(chainId, 'number')
} else if (!isHex(chainId) && typeof chainId === 'number') {
chainAsNumber = chainId
} else {
throw new Error('Invalid chainId')
}
async function signMessage(chainId) {
// current primary wallet - as multiple wallets can connect this value is the currently active
const [activeWallet] = onboard.state.get().wallets
const wagmiConfig = onboard.state.get().wagmiConfig
await switchChain(wagmiConfig, { chainId: chainAsNumber })
await wagmiSignMessage(wagmiConfig, {
message: 'This is my message to you',
connector: activeWallet.wagmiConnector
})
}

@@ -81,7 +84,6 @@

const wagmiConfig = onboard.state.get().wagmiConfig
const disconnectThisWallet = getConnectors(wagmiConfig).find(
connector => connector.name === label
)
disconnect(wagmiConfig, { connector: disconnectThisWallet })
const [activeWallet] = onboard.state.get().wallets
const { wagmiConnector } = activeWallet
disconnect(wagmiConfig, { connector: wagmiConnector })
}
```
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