Socket
Socket
Sign inDemoInstall

@web3modal/core

Package Overview
Dependencies
Maintainers
11
Versions
374
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3modal/core - npm Package Compare versions

Comparing version 4.2.0-65f3d27d.0 to 4.2.0-alpha.0

dist/esm/src/controllers/SwapController.js

2

dist/esm/index.js

@@ -17,3 +17,5 @@ export { ModalController } from './src/controllers/ModalController.js';

export { TransactionsController } from './src/controllers/TransactionsController.js';
export { SwapController } from './src/controllers/SwapController.js';
export { SendController } from './src/controllers/SendController.js';
export { TooltipController } from './src/controllers/TooltipController.js';
export { AssetUtil } from './src/utils/AssetUtil.js';

@@ -20,0 +22,0 @@ export { ConstantsUtil } from './src/utils/ConstantsUtil.js';

27

dist/esm/src/controllers/AccountController.js

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

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, ref, subscribe as sub } from 'valtio/vanilla';

@@ -6,6 +6,10 @@ import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';

import { SnackController } from './SnackController.js';
import { SwapController } from './SwapController.js';
import { SwapApiUtil } from '../utils/SwapApiUtil.js';
import { NetworkController } from './NetworkController.js';
const state = proxy({
isConnected: false,
currentTab: 0,
tokenBalance: []
tokenBalance: [],
smartAccountDeployed: false
});

@@ -51,7 +55,15 @@ export const AccountController = {

},
setConnectedWalletInfo(connectedWalletInfo) {
state.connectedWalletInfo = connectedWalletInfo;
},
setPreferredAccountType(preferredAccountType) {
state.preferredAccountType = preferredAccountType;
},
async fetchTokenBalance() {
const chainId = NetworkController.state.caipNetwork?.id;
try {
if (state.address) {
const response = await BlockchainApiController.getBalance(state.address);
if (state.address && chainId) {
const response = await BlockchainApiController.getBalance(state.address, chainId);
this.setTokenBalance(response.balances);
SwapController.setBalances(SwapApiUtil.mapBalancesToSwapTokens(response.balances));
}

@@ -65,2 +77,4 @@ }

state.isConnected = false;
state.smartAccountDeployed = false;
state.currentTab = 0;
state.caipAddress = undefined;

@@ -73,6 +87,7 @@ state.address = undefined;

state.addressExplorerUrl = undefined;
state.smartAccountDeployed = undefined;
state.currentTab = 0;
state.tokenBalance = [];
state.connectedWalletInfo = undefined;
state.preferredAccountType = undefined;
}
};
//# sourceMappingURL=AccountController.js.map

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

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy } from 'valtio/vanilla';

@@ -156,3 +156,3 @@ import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';

entries: '100',
search,
search: search?.trim(),
chains: NetworkController.state.caipNetwork?.id,

@@ -159,0 +159,0 @@ include: includeWalletIds?.join(','),

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

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, subscribe as sub } from 'valtio/vanilla';

@@ -3,0 +3,0 @@ const state = proxy({

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

import { ConstantsUtil } from '../utils/ConstantsUtil.js';
import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';

@@ -81,7 +82,6 @@ import { FetchUtil } from '../utils/FetchUtil.js';

export const BlockchainApiController = {
fetchIdentity({ caipChainId, address }) {
fetchIdentity({ address }) {
return api.get({
path: `/v1/identity/${address}`,
params: {
chainId: caipChainId,
projectId: OptionsController.state.projectId

@@ -99,8 +99,83 @@ }

},
async getBalance(address) {
fetchSwapTokens({ projectId, chainId }) {
return api.get({
path: `/v1/convert/tokens?projectId=${projectId}&chainId=${chainId}`
});
},
fetchTokenPrice({ projectId, addresses }) {
return api.post({
path: '/v1/fungible/price',
body: {
projectId,
currency: 'usd',
addresses
},
headers: {
'Content-Type': 'application/json'
}
});
},
fetchSwapAllowance({ projectId, tokenAddress, userAddress }) {
const { sdkType, sdkVersion } = OptionsController.state;
return api.get({
path: `/v1/convert/allowance?projectId=${projectId}&tokenAddress=${tokenAddress}&userAddress=${userAddress}`,
headers: {
'Content-Type': 'application/json',
'x-sdk-type': sdkType,
'x-sdk-version': sdkVersion
}
});
},
fetchGasPrice({ projectId, chainId }) {
const { sdkType, sdkVersion } = OptionsController.state;
return api.get({
path: `/v1/convert/gas-price?projectId=${projectId}&chainId=${chainId}`,
headers: {
'Content-Type': 'application/json',
'x-sdk-type': sdkType,
'x-sdk-version': sdkVersion
}
});
},
generateSwapCalldata({ amount, from, projectId, to, userAddress }) {
return api.post({
path: '/v1/convert/build-transaction',
headers: {
'Content-Type': 'application/json'
},
body: {
amount,
eip155: {
slippage: ConstantsUtil.CONVERT_SLIPPAGE_TOLERANCE
},
from,
projectId,
to,
userAddress
}
});
},
generateApproveCalldata({ from, projectId, to, userAddress }) {
const { sdkType, sdkVersion } = OptionsController.state;
return api.get({
path: `/v1/convert/build-approve?projectId=${projectId}&userAddress=${userAddress}&from=${from}&to=${to}`,
headers: {
'Content-Type': 'application/json',
'x-sdk-type': sdkType,
'x-sdk-version': sdkVersion
}
});
},
async getBalance(address, chainId) {
const { sdkType, sdkVersion } = OptionsController.state;
return api.get({
path: `/v1/account/${address}/balance`,
headers: {
'x-sdk-type': sdkType,
'x-sdk-version': sdkVersion
},
params: {
currency: 'usd',
projectId: OptionsController.state.projectId
projectId: OptionsController.state.projectId,
chainId
}

@@ -107,0 +182,0 @@ });

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

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, ref } from 'valtio/vanilla';

@@ -35,5 +35,30 @@ import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';

},
async reconnectExternal(options) {
await this._getClient().reconnectExternal?.(options);
StorageUtil.setConnectedConnector(options.type);
},
async signMessage(message) {
return this._getClient().signMessage(message);
},
parseUnits(value, decimals) {
return this._getClient().parseUnits(value, decimals);
},
formatUnits(value, decimals) {
return this._getClient().formatUnits(value, decimals);
},
async sendTransaction(args) {
return this._getClient().sendTransaction(args);
},
async estimateGas(args) {
return this._getClient().estimateGas(args);
},
async writeContract(args) {
return this._getClient().writeContract(args);
},
async getEnsAddress(value) {
return this._getClient().getEnsAddress(value);
},
async getEnsAvatar(value) {
return this._getClient().getEnsAvatar(value);
},
checkInstalled(ids) {

@@ -66,2 +91,3 @@ return this._getClient().checkInstalled?.(ids);

await this._getClient().disconnect();
StorageUtil.removeConnectedWalletImageUrl();
this.resetWcConnection();

@@ -68,0 +94,0 @@ }

@@ -1,3 +0,4 @@

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, ref, snapshot } from 'valtio/vanilla';
import { getW3mThemeVariables } from '@web3modal/common';
import { OptionsController } from './OptionsController.js';

@@ -21,2 +22,4 @@ import { ThemeController } from './ThemeController.js';

const optionsState = snapshot(OptionsController.state);
const themeMode = ThemeController.getSnapshot().themeMode;
const themeVariables = ThemeController.getSnapshot().themeVariables;
emailConnector?.provider?.syncDappData?.({

@@ -28,4 +31,5 @@ metadata: optionsState.metadata,

emailConnector.provider.syncTheme({
themeMode: ThemeController.getSnapshot().themeMode,
themeVariables: ThemeController.getSnapshot().themeVariables
themeMode,
themeVariables,
w3mThemeVariables: getW3mThemeVariables(themeVariables, themeMode)
});

@@ -32,0 +36,0 @@ }

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

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, subscribe as sub } from 'valtio/vanilla';

@@ -52,4 +52,5 @@ import { AccountController } from './AccountController.js';

state.loading = loading;
PublicStateController.set({ loading });
}
};
//# sourceMappingURL=ModalController.js.map
import { subscribeKey as subKey } from 'valtio/utils';
import { proxy, ref } from 'valtio/vanilla';
import { proxy, ref, subscribe as sub } from 'valtio/vanilla';
import { PublicStateController } from './PublicStateController.js';

@@ -7,8 +7,13 @@ import { EventsController } from './EventsController.js';

import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';
import { NetworkUtil } from '@web3modal/common';
const state = proxy({
supportsAllNetworks: true,
isDefaultCaipNetwork: false
isDefaultCaipNetwork: false,
smartAccountEnabledNetworks: []
});
export const NetworkController = {
state,
subscribe(callback) {
return sub(state, () => callback(state));
},
subscribeKey(key, callback) {

@@ -44,2 +49,5 @@ return subKey(state, key, callback);

},
setSmartAccountEnabledNetworks(smartAccountEnabledNetworks) {
state.smartAccountEnabledNetworks = smartAccountEnabledNetworks;
},
getRequestedCaipNetworks() {

@@ -73,2 +81,9 @@ const { approvedCaipNetworkIds, requestedCaipNetworks } = state;

},
checkIfSmartAccountEnabled() {
const networkId = NetworkUtil.caipNetworkIdToNumber(state.caipNetwork?.id);
if (!networkId) {
return false;
}
return Boolean(state.smartAccountEnabledNetworks?.includes(networkId));
},
resetNetwork() {

@@ -80,2 +95,3 @@ if (!state.isDefaultCaipNetwork) {

state.supportsAllNetworks = true;
state.smartAccountEnabledNetworks = [];
},

@@ -82,0 +98,0 @@ showUnsupportedChainUI() {

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

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, subscribe as sub } from 'valtio/vanilla';

@@ -3,0 +3,0 @@ import { ONRAMP_PROVIDERS } from '../utils/ConstantsUtil.js';

@@ -1,3 +0,3 @@

import { subscribeKey as subKey } from 'valtio/utils';
import { proxy } from 'valtio/vanilla';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, snapshot } from 'valtio/vanilla';
const state = proxy({

@@ -57,4 +57,7 @@ projectId: '',

state.enableWalletFeatures = enableWalletFeatures;
},
getSnapshot() {
return snapshot(state);
}
};
//# sourceMappingURL=OptionsController.js.map
import { proxy, subscribe as sub } from 'valtio/vanilla';
const state = proxy({
loading: false,
open: false,

@@ -4,0 +5,0 @@ selectedNetworkId: undefined

@@ -1,6 +0,7 @@

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy } from 'valtio/vanilla';
const state = proxy({
view: 'Connect',
history: ['Connect']
history: ['Connect'],
transactionStack: []
});

@@ -12,2 +13,24 @@ export const RouterController = {

},
pushTransactionStack(action) {
state.transactionStack.push(action);
},
popTransactionStack(cancel) {
const action = state.transactionStack.pop();
if (!action) {
return;
}
if (cancel) {
this.goBack();
action?.onCancel?.();
}
else {
if (action.goBack) {
this.goBack();
}
else if (action.view) {
this.reset(action.view);
}
action?.onSuccess?.();
}
},
push(view, data) {

@@ -25,3 +48,3 @@ if (view !== state.view) {

replace(view, data) {
if (state.history.length > 1 && state.history.at(-1) !== view) {
if (state.history.length >= 1 && state.history.at(-1) !== view) {
state.view = view;

@@ -28,0 +51,0 @@ state.history[state.history.length - 1] = view;

@@ -1,4 +0,13 @@

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy, ref, subscribe as sub } from 'valtio/vanilla';
const state = proxy({});
import {} from '@web3modal/common';
import { erc20ABI } from '@web3modal/common';
import { RouterController } from './RouterController.js';
import { AccountController } from './AccountController.js';
import { ConnectionController } from './ConnectionController.js';
import { SnackController } from './SnackController.js';
import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';
const state = proxy({
loading: false
});
export const SendController = {

@@ -29,2 +38,83 @@ state,

},
setGasPrice(gasPrice) {
state.gasPrice = gasPrice;
},
setGasPriceInUsd(gasPriceInUSD) {
state.gasPriceInUSD = gasPriceInUSD;
},
setLoading(loading) {
state.loading = loading;
},
sendToken() {
if (this.state.token?.address && this.state.sendTokenAmount && this.state.receiverAddress) {
this.sendERC20Token({
receiverAddress: this.state.receiverAddress,
tokenAddress: this.state.token.address,
sendTokenAmount: this.state.sendTokenAmount,
decimals: this.state.token.quantity.decimals
});
}
else if (this.state.receiverAddress &&
this.state.sendTokenAmount &&
this.state.gasPrice &&
this.state.token?.quantity.decimals) {
this.sendNativeToken({
receiverAddress: this.state.receiverAddress,
sendTokenAmount: this.state.sendTokenAmount,
gasPrice: this.state.gasPrice,
decimals: this.state.token.quantity.decimals
});
}
},
async sendNativeToken(params) {
RouterController.pushTransactionStack({
view: 'Account',
goBack: false
});
const to = params.receiverAddress;
const address = AccountController.state.address;
const value = ConnectionController.parseUnits(params.sendTokenAmount.toString(), Number(params.decimals));
const data = '0x';
try {
await ConnectionController.sendTransaction({
to,
address,
data,
value,
gasPrice: params.gasPrice
});
SnackController.showSuccess('Transaction started');
this.resetSend();
}
catch (error) {
SnackController.showError('Something went wrong');
}
},
async sendERC20Token(params) {
RouterController.pushTransactionStack({
view: 'Account',
goBack: false
});
const amount = ConnectionController.parseUnits(params.sendTokenAmount.toString(), Number(params.decimals));
try {
if (AccountController.state.address &&
params.sendTokenAmount &&
params.receiverAddress &&
params.tokenAddress) {
await ConnectionController.writeContract({
fromAddress: AccountController.state.address,
tokenAddress: CoreHelperUtil.getPlainAddress(params.tokenAddress),
receiverAddress: params.receiverAddress,
tokenAmount: amount,
method: 'transfer',
abi: erc20ABI
});
SnackController.showSuccess('Transaction started');
this.resetSend();
}
}
catch (error) {
SnackController.showError('Something went wrong');
}
},
resetSend() {

@@ -36,4 +126,5 @@ state.token = undefined;

state.receiverProfileName = undefined;
state.loading = false;
}
};
//# sourceMappingURL=SendController.js.map

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

import { subscribeKey as subKey } from 'valtio/utils';
import { subscribeKey as subKey } from 'valtio/vanilla/utils';
import { proxy } from 'valtio/vanilla';

@@ -3,0 +3,0 @@ import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';

import { proxy, subscribe as sub, snapshot } from 'valtio/vanilla';
import { ConnectorController } from './ConnectorController.js';
import { getW3mThemeVariables } from '@web3modal/common';
const state = proxy({
themeMode: 'dark',
themeVariables: {}
themeVariables: {},
w3mThemeVariables: undefined
});

@@ -17,4 +19,7 @@ export const ThemeController = {

if (emailConnector) {
const themeVariables = ThemeController.getSnapshot().themeVariables;
emailConnector.provider.syncTheme({
themeMode: ThemeController.getSnapshot().themeMode
themeMode,
themeVariables,
w3mThemeVariables: getW3mThemeVariables(themeVariables, themeMode)
});

@@ -32,4 +37,6 @@ }

if (emailConnector) {
const themeVariablesSnapshot = ThemeController.getSnapshot().themeVariables;
emailConnector.provider.syncTheme({
themeVariables: ThemeController.getSnapshot().themeVariables
themeVariables: themeVariablesSnapshot,
w3mThemeVariables: getW3mThemeVariables(state.themeVariables, state.themeMode)
});

@@ -36,0 +43,0 @@ }

@@ -58,2 +58,3 @@ import { proxy, subscribe as sub } from 'valtio/vanilla';

state.empty = true;
state.next = undefined;
}

@@ -82,2 +83,5 @@ },

},
clearCursor() {
state.next = undefined;
},
resetTransactions() {

@@ -84,0 +88,0 @@ state.transactions = [];

@@ -29,5 +29,2 @@ const SECURE_SITE = 'https://secure.walletconnect.com';

],
CONNECTOR_RDNS_MAP: {
coinbaseWallet: 'com.coinbase.wallet'
},
WC_COINBASE_PAY_SDK_CHAINS: [

@@ -52,4 +49,108 @@ 'ethereum',

},
WC_COINBASE_ONRAMP_APP_ID: 'bf18c88d-495a-463b-b249-0b9d3656cf5e'
WC_COINBASE_ONRAMP_APP_ID: 'bf18c88d-495a-463b-b249-0b9d3656cf5e',
SWAP_SUGGESTED_TOKENS: [
'ETH',
'UNI',
'1INCH',
'AAVE',
'SOL',
'ADA',
'AVAX',
'DOT',
'LINK',
'NITRO',
'GAIA',
'MILK',
'TRX',
'NEAR',
'GNO',
'WBTC',
'DAI',
'WETH',
'USDC',
'USDT',
'ARB',
'BAL',
'BICO',
'CRV',
'ENS',
'MATIC',
'OP'
],
SWAP_POPULAR_TOKENS: [
'ETH',
'UNI',
'1INCH',
'AAVE',
'SOL',
'ADA',
'AVAX',
'DOT',
'LINK',
'NITRO',
'GAIA',
'MILK',
'TRX',
'NEAR',
'GNO',
'WBTC',
'DAI',
'WETH',
'USDC',
'USDT',
'ARB',
'BAL',
'BICO',
'CRV',
'ENS',
'MATIC',
'OP',
'METAL',
'DAI',
'CHAMP',
'WOLF',
'SALE',
'BAL',
'BUSD',
'MUST',
'BTCpx',
'ROUTE',
'HEX',
'WELT',
'amDAI',
'VSQ',
'VISION',
'AURUM',
'pSP',
'SNX',
'VC',
'LINK',
'CHP',
'amUSDT',
'SPHERE',
'FOX',
'GIDDY',
'GFC',
'OMEN',
'OX_OLD',
'DE',
'WNT'
],
SWAP_SUPPORTED_NETWORKS: [
'eip155:1',
'eip155:42161',
'eip155:10',
'eip155:324',
'eip155:8453',
'eip155:56',
'eip155:137',
'eip155:100',
'eip155:43114',
'eip155:250',
'eip155:8217',
'eip155:1313161554'
],
NATIVE_TOKEN_ADDRESS: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
CONVERT_SLIPPAGE_TOLERANCE: 1
};
//# sourceMappingURL=ConstantsUtil.js.map

@@ -207,3 +207,3 @@ import { ConstantsUtil } from './ConstantsUtil.js';

for (const item of array) {
sum += item.value;
sum += item.value ?? 0;
}

@@ -210,0 +210,0 @@ return sum;

import { RouterController } from '../controllers/RouterController.js';
import { ModalController } from '../controllers/ModalController.js';
import { OptionsController } from '../controllers/OptionsController.js';
export const RouterUtil = {

@@ -21,4 +22,13 @@ goBackOrCloseModal() {

}
},
navigateAfterPreferredAccountTypeSelect() {
const { isSiweEnabled } = OptionsController.state;
if (isSiweEnabled) {
RouterController.push('ConnectingSiwe');
}
else {
RouterController.push('Account');
}
}
};
//# sourceMappingURL=RouterUtil.js.map

@@ -68,2 +68,10 @@ const WC_DEEPLINK = 'WALLETCONNECT_DEEPLINK_CHOICE';

},
removeConnectedWalletImageUrl() {
try {
localStorage.removeItem(W3M_CONNECTED_WALLET_IMAGE_URL);
}
catch {
console.info('Unable to remove Connected Wallet Image Url');
}
},
getConnectedWalletImageUrl() {

@@ -70,0 +78,0 @@ try {

@@ -8,5 +8,11 @@ import { describe, expect, it } from 'vitest';

const profileImage = 'https://ipfs.com/0x123.png';
const explorerUrl = 'https://some.explorer.com/explore';
describe('AccountController', () => {
it('should have valid default state', () => {
expect(AccountController.state).toEqual({ isConnected: false });
expect(AccountController.state).toEqual({
isConnected: false,
smartAccountDeployed: false,
currentTab: 0,
tokenBalance: []
});
});

@@ -35,7 +41,33 @@ it('should update state correctly on setIsConnected()', () => {

});
it('should update state correctly on setAddressExplorerUrl()', () => {
AccountController.setAddressExplorerUrl(explorerUrl);
expect(AccountController.state.addressExplorerUrl).toEqual(explorerUrl);
});
it('shuold update state correctly on setSmartAccountDeployed()', () => {
AccountController.setSmartAccountDeployed(true);
expect(AccountController.state.smartAccountDeployed).toEqual(true);
});
it('should update state correctly on setPreferredAccountType()', () => {
AccountController.setPreferredAccountType('eoa');
expect(AccountController.state.preferredAccountType).toEqual('eoa');
AccountController.setPreferredAccountType('smartAccount');
expect(AccountController.state.preferredAccountType).toEqual('smartAccount');
});
it('should update state correctly on resetAccount()', () => {
AccountController.resetAccount();
expect(AccountController.state).toEqual({ isConnected: false });
expect(AccountController.state).toEqual({
isConnected: false,
smartAccountDeployed: false,
currentTab: 0,
caipAddress: undefined,
address: undefined,
balance: undefined,
balanceSymbol: undefined,
profileName: undefined,
profileImage: undefined,
addressExplorerUrl: undefined,
tokenBalance: []
});
});
});
//# sourceMappingURL=AccountController.test.js.map

@@ -97,3 +97,3 @@ import { describe, expect, it, vi } from 'vitest';

});
it('should fetch network images', async () => {
it('should only fetch network images for networks with imageIds', async () => {
NetworkController.setRequestedCaipNetworks([

@@ -315,2 +315,78 @@ {

});
it('should search wallet with search term', async () => {
const includeWalletIds = ['12341', '12342'];
const excludeWalletIds = ['12343'];
let data = [
{
id: '12341',
name: 'MetaMask',
image_id: '12341'
}
];
OptionsController.setIncludeWalletIds(includeWalletIds);
OptionsController.setExcludeWalletIds(excludeWalletIds);
let fetchSpy = vi.spyOn(api, 'get').mockResolvedValue({ data });
const fetchImageSpy = vi.spyOn(ApiController, '_fetchWalletImage').mockResolvedValue();
await ApiController.searchWallet({ search: 'MetaMask ' });
expect(fetchSpy).toHaveBeenCalledWith({
path: '/getWallets',
headers: ApiController._getApiHeaders(),
params: {
page: '1',
entries: '100',
search: 'MetaMask',
include: '12341,12342',
exclude: '12343'
}
});
expect(fetchImageSpy).toHaveBeenCalledOnce();
expect(ApiController.state.search).toEqual(data);
await ApiController.searchWallet({ search: ' Metamask' });
expect(fetchSpy).toHaveBeenCalledWith({
path: '/getWallets',
headers: ApiController._getApiHeaders(),
params: {
page: '1',
entries: '100',
search: 'MetaMask',
include: '12341,12342',
exclude: '12343'
}
});
expect(ApiController.state.search).toEqual(data);
await ApiController.searchWallet({ search: ' Metamask ' });
expect(fetchSpy).toHaveBeenCalledWith({
path: '/getWallets',
headers: ApiController._getApiHeaders(),
params: {
page: '1',
entries: '100',
search: 'MetaMask',
include: '12341,12342',
exclude: '12343'
}
});
expect(ApiController.state.search).toEqual(data);
data = [
{
id: '12341',
name: 'Safe Wallet',
image_id: '12341'
}
];
fetchSpy = vi.spyOn(api, 'get').mockResolvedValue({ data });
await ApiController.searchWallet({ search: 'Safe Wallet' });
expect(fetchSpy).toHaveBeenCalledWith({
path: '/getWallets',
headers: ApiController._getApiHeaders(),
params: {
page: '1',
entries: '100',
search: 'Safe Wallet',
include: '12341,12342',
exclude: '12343'
}
});
expect(ApiController.state.search).toEqual(data);
});
it('should prefetch without analytics', () => {

@@ -317,0 +393,0 @@ OptionsController.state.enableAnalytics = false;

import { describe, expect, it } from 'vitest';
import { AssetController } from '../../index.js';
const walletImage = 'w3mWallet.png';
const walletImage2 = 'w3mWallet2.png';
const networkImage = 'ethereum.png';
const networkImage2 = 'polygon.png';
const connectorImage = 'email-connector.png';
const connectorImage2 = 'metamask-connector.png';
const tokenImage = 'eth.png';
const tokenImage2 = 'usdc.png';
const currencyImage = 'usd.png';
const currencyImage2 = 'eur.png';
const wallet = 'w3m';
const wallet2 = 'w4m';
const network = 'ethereum';
const network2 = 'polygon';
const connector = 'w3m-email';
const connector2 = 'mm-connector';
const token = 'ETH';
const token2 = 'MATIC';
const currency = 'USD';
const currency2 = 'EUR';
describe('AssetController', () => {

@@ -13,3 +33,58 @@ it('should have valid default state', () => {

});
it('should update state properly on setWalletImage()', () => {
AssetController.setWalletImage(wallet, walletImage);
expect(AssetController.state.walletImages).toEqual({ [wallet]: walletImage });
AssetController.setWalletImage(wallet, walletImage2);
expect(AssetController.state.walletImages).toEqual({ [wallet]: walletImage2 });
AssetController.setWalletImage(wallet2, walletImage2);
expect(AssetController.state.walletImages).toEqual({
[wallet]: walletImage2,
[wallet2]: walletImage2
});
});
it('should update state properly on setNetworkImage()', () => {
AssetController.setNetworkImage(network, networkImage);
expect(AssetController.state.networkImages).toEqual({ [network]: networkImage });
AssetController.setNetworkImage(network, networkImage2);
expect(AssetController.state.networkImages).toEqual({ [network]: networkImage2 });
AssetController.setNetworkImage(network2, networkImage2);
expect(AssetController.state.networkImages).toEqual({
[network]: networkImage2,
[network2]: networkImage2
});
});
it('should update state properly on setConnectorImage()', () => {
AssetController.setConnectorImage(connector, connectorImage);
expect(AssetController.state.connectorImages).toEqual({ [connector]: connectorImage });
AssetController.setConnectorImage(connector, connectorImage2);
expect(AssetController.state.connectorImages).toEqual({ [connector]: connectorImage2 });
AssetController.setConnectorImage(connector2, connectorImage2);
expect(AssetController.state.connectorImages).toEqual({
[connector]: connectorImage2,
[connector2]: connectorImage2
});
});
it('should update state properly on setTokenImage()', () => {
AssetController.setTokenImage(token, tokenImage);
expect(AssetController.state.tokenImages).toEqual({ [token]: tokenImage });
AssetController.setTokenImage(token, tokenImage2);
expect(AssetController.state.tokenImages).toEqual({ [token]: tokenImage2 });
AssetController.setTokenImage(token2, tokenImage2);
expect(AssetController.state.tokenImages).toEqual({
[token]: tokenImage2,
[token2]: tokenImage2
});
});
it('should update state properly on setCurrencyImage()', () => {
AssetController.setCurrencyImage(currency, currencyImage);
expect(AssetController.state.currencyImages).toEqual({ [currency]: currencyImage });
AssetController.setCurrencyImage(currency, currencyImage2);
expect(AssetController.state.currencyImages).toEqual({ [currency]: currencyImage2 });
AssetController.setCurrencyImage(currency2, currencyImage2);
expect(AssetController.state.currencyImages).toEqual({
[currency]: currencyImage2,
[currency2]: currencyImage2
});
});
});
//# sourceMappingURL=AssetController.test.js.map

@@ -1,20 +0,37 @@

import { describe, expect, it } from 'vitest';
import { ConnectionController } from '../../index.js';
import { describe, expect, it, vi } from 'vitest';
import { ConnectionController, ConstantsUtil, StorageUtil } from '../../index.js';
const walletConnectUri = 'wc://uri?=123';
const externalId = 'coinbaseWallet';
const type = 'EMAIL';
const storageSpy = vi.spyOn(StorageUtil, 'setConnectedConnector');
const client = {
connectWalletConnect: async (onUri) => {
onUri(walletConnectUri);
await Promise.resolve();
await Promise.resolve(walletConnectUri);
},
disconnect: async () => Promise.resolve(),
signMessage: async (message) => Promise.resolve(message),
estimateGas: async () => Promise.resolve(BigInt(0)),
connectExternal: async (_id) => Promise.resolve(),
checkInstalled: _id => true
checkInstalled: _id => true,
parseUnits: value => BigInt(value),
formatUnits: value => value.toString(),
sendTransaction: () => Promise.resolve('0x'),
writeContract: () => Promise.resolve('0x'),
getEnsAddress: async (value) => Promise.resolve(value),
getEnsAvatar: async (value) => Promise.resolve(value)
};
const clientConnectExternalSpy = vi.spyOn(client, 'connectExternal');
const clientCheckInstalledSpy = vi.spyOn(client, 'checkInstalled');
const partialClient = {
connectWalletConnect: async () => Promise.resolve(),
disconnect: async () => Promise.resolve(),
signMessage: async (message) => Promise.resolve(message)
estimateGas: async () => Promise.resolve(BigInt(0)),
signMessage: async (message) => Promise.resolve(message),
parseUnits: value => BigInt(value),
formatUnits: value => value.toString(),
sendTransaction: () => Promise.resolve('0x'),
writeContract: () => Promise.resolve('0x'),
getEnsAddress: async (value) => Promise.resolve(value),
getEnsAvatar: async (value) => Promise.resolve(value)
};

@@ -39,13 +56,27 @@ describe('ConnectionController', () => {

});
it('should not throw on connectWalletConnect()', () => {
it('should update state correctly and set wcPromise on connectWalletConnect()', async () => {
const fakeDate = new Date(0);
vi.useFakeTimers();
vi.setSystemTime(fakeDate);
ConnectionController.connectWalletConnect();
expect(ConnectionController.state.wcPromise).toBeDefined();
await ConnectionController.state.wcPromise;
expect(ConnectionController.state.wcUri).toEqual(walletConnectUri);
expect(ConnectionController.state.wcPairingExpiry).toEqual(ConstantsUtil.FOUR_MINUTES_MS);
expect(storageSpy).toHaveBeenCalledWith('WALLET_CONNECT');
vi.useRealTimers();
});
it('should not throw on connectExternal()', async () => {
await ConnectionController.connectExternal({ id: externalId, type });
it('connectExternal() should trigger internal client call and set connector in storage', async () => {
const options = { id: externalId, type };
await ConnectionController.connectExternal(options);
expect(storageSpy).toHaveBeenCalledWith(type);
expect(clientConnectExternalSpy).toHaveBeenCalledWith(options);
});
it('should not throw on checkInstalled()', () => {
it('checkInstalled() should trigger internal client call', () => {
ConnectionController.checkInstalled([externalId]);
expect(clientCheckInstalledSpy).toHaveBeenCalledWith([externalId]);
});
it('should not throw on checkInstalled() without ids', () => {
ConnectionController.checkInstalled();
expect(clientCheckInstalledSpy).toHaveBeenCalledWith(undefined);
});

@@ -56,2 +87,5 @@ it('should not throw when optional methods are undefined', async () => {

ConnectionController.checkInstalled([externalId]);
expect(clientCheckInstalledSpy).toHaveBeenCalledWith([externalId]);
expect(clientCheckInstalledSpy).toHaveBeenCalledWith(undefined);
expect(ConnectionController.state._client).toEqual(partialClient);
});

@@ -58,0 +92,0 @@ it('should update state correctly on resetWcConnection()', () => {

@@ -1,5 +0,32 @@

import { describe, expect, it } from 'vitest';
import { ConnectorController } from '../../index.js';
const walletConnectConnector = { id: 'walletConnect', type: 'WALLET_CONNECT' };
import { describe, expect, it, vi } from 'vitest';
import { ConnectorController, OptionsController } from '../../index.js';
import { getW3mThemeVariables } from '@web3modal/common';
const emailProvider = {
syncDappData: (_args) => Promise.resolve(),
syncTheme: (_args) => Promise.resolve()
};
const walletConnectConnector = {
id: 'walletConnect',
explorerId: 'walletConnectId',
type: 'WALLET_CONNECT'
};
const externalConnector = { id: 'external', type: 'EXTERNAL' };
const emailConnector = { id: 'w3mEmail', type: 'EMAIL', provider: emailProvider };
const announcedConnector = {
id: 'announced',
type: 'ANNOUNCED',
info: { rdns: 'announced.io' }
};
const syncDappDataSpy = vi.spyOn(emailProvider, 'syncDappData');
const syncThemeSpy = vi.spyOn(emailProvider, 'syncTheme');
const mockDappData = {
metadata: {
description: 'Desc',
name: 'Name',
url: 'url.com',
icons: ['icon.png']
},
projectId: '1234',
sdkVersion: 'react-wagmi-4.0.13'
};
const metamaskConnector = {

@@ -10,2 +37,6 @@ id: 'metamask',

};
const zerionConnector = {
id: 'ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18',
type: 'INJECTED'
};
describe('ConnectorController', () => {

@@ -33,7 +64,51 @@ it('should have valid default state', () => {

it('should return the correct connector on getConnector', () => {
expect(ConnectorController.getConnector('walletConnect', '')).toBe(walletConnectConnector);
ConnectorController.addConnector(zerionConnector);
expect(ConnectorController.getConnector('walletConnectId', '')).toBe(walletConnectConnector);
expect(ConnectorController.getConnector('', 'io.metamask.com')).toBe(metamaskConnector);
expect(ConnectorController.getConnector(zerionConnector.id, '')).toBeUndefined();
expect(ConnectorController.getConnector('unknown', '')).toBeUndefined();
});
it('getEmailConnector() should not throw when email connector is not set', () => {
expect(ConnectorController.getEmailConnector()).toEqual(undefined);
});
it('should trigger corresponding sync methods when adding email connector', () => {
OptionsController.setMetadata(mockDappData.metadata);
OptionsController.setSdkVersion(mockDappData.sdkVersion);
OptionsController.setProjectId(mockDappData.projectId);
ConnectorController.addConnector(emailConnector);
expect(ConnectorController.state.connectors).toEqual([
walletConnectConnector,
externalConnector,
metamaskConnector,
zerionConnector,
emailConnector
]);
expect(syncDappDataSpy).toHaveBeenCalledWith(mockDappData);
expect(syncThemeSpy).toHaveBeenCalledWith({
themeMode: 'dark',
themeVariables: {},
w3mThemeVariables: getW3mThemeVariables({}, 'dark')
});
});
it('getEmailConnector() should return emailconnector when already added', () => {
expect(ConnectorController.getEmailConnector()).toEqual(emailConnector);
});
it('getAnnouncedConnectorRdns() should not throw when no announced connector is not set', () => {
expect(ConnectorController.getAnnouncedConnectorRdns()).toEqual([]);
});
it('getAnnouncedConnectorRdns() should return corresponding info array', () => {
ConnectorController.addConnector(announcedConnector);
expect(ConnectorController.getAnnouncedConnectorRdns()).toEqual(['announced.io']);
});
it('getConnnectors() should return all connectors', () => {
expect(ConnectorController.getConnectors()).toEqual([
walletConnectConnector,
externalConnector,
metamaskConnector,
zerionConnector,
emailConnector,
announcedConnector
]);
});
});
//# sourceMappingURL=ConnectorController.test.js.map

@@ -28,3 +28,4 @@ import { describe, expect, it } from 'vitest';

supportsAllNetworks: true,
isDefaultCaipNetwork: false
isDefaultCaipNetwork: false,
smartAccountEnabledNetworks: []
});

@@ -54,2 +55,3 @@ });

expect(NetworkController.state.requestedCaipNetworks).toEqual(requestedCaipNetworks);
expect(NetworkController.state.smartAccountEnabledNetworks).toEqual([]);
});

@@ -67,3 +69,13 @@ it('should update state correctly on setDefaultCaipNetwork()', () => {

});
it('should check correctly if smart accounts are enabled on the network', () => {
NetworkController.setSmartAccountEnabledNetworks([1]);
expect(NetworkController.checkIfSmartAccountEnabled()).toEqual(true);
NetworkController.setSmartAccountEnabledNetworks([]);
expect(NetworkController.checkIfSmartAccountEnabled()).toEqual(false);
NetworkController.setSmartAccountEnabledNetworks([2]);
expect(NetworkController.checkIfSmartAccountEnabled()).toEqual(false);
NetworkController.setCaipNetwork({ id: 'eip155:2', name: 'Ethereum' });
expect(NetworkController.checkIfSmartAccountEnabled()).toEqual(true);
});
});
//# sourceMappingURL=NetworkController.test.js.map

@@ -6,2 +6,3 @@ import { describe, expect, it } from 'vitest';

expect(PublicStateController.state).toEqual({
loading: false,
open: false,

@@ -14,2 +15,3 @@ selectedNetworkId: undefined

expect(PublicStateController.state).toEqual({
loading: false,
open: true,

@@ -20,2 +22,3 @@ selectedNetworkId: undefined

expect(PublicStateController.state).toEqual({
loading: false,
open: true,

@@ -22,0 +25,0 @@ selectedNetworkId: 'eip155:1'

@@ -7,3 +7,4 @@ import { describe, expect, it } from 'vitest';

view: 'Connect',
history: ['Connect']
history: ['Connect'],
transactionStack: []
});

@@ -15,3 +16,4 @@ });

view: 'Account',
history: ['Connect', 'Account']
history: ['Connect', 'Account'],
transactionStack: []
});

@@ -23,3 +25,4 @@ });

view: 'Account',
history: ['Connect', 'Account']
history: ['Connect', 'Account'],
transactionStack: []
});

@@ -31,3 +34,4 @@ });

view: 'Connect',
history: ['Connect']
history: ['Connect'],
transactionStack: []
});

@@ -39,3 +43,4 @@ });

view: 'Connect',
history: ['Connect']
history: ['Connect'],
transactionStack: []
});

@@ -47,3 +52,4 @@ });

view: 'Account',
history: ['Account']
history: ['Account'],
transactionStack: []
});

@@ -56,3 +62,4 @@ });

view: 'Networks',
history: ['Account', 'Networks']
history: ['Account', 'Networks'],
transactionStack: []
});

@@ -69,3 +76,4 @@ });

connector: { id: 'test', type: 'WALLET_CONNECT' }
}
},
transactionStack: []
});

@@ -72,0 +80,0 @@ });

@@ -5,2 +5,3 @@ import { describe, expect, it } from 'vitest';

name: 'Optimism',
address: 'eip155:10:0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
symbol: 'OP',

@@ -22,3 +23,3 @@ chainId: 'eip155:10',

it('should have valid default state', () => {
expect(SendController.state).toEqual({});
expect(SendController.state).toEqual({ loading: false });
});

@@ -47,5 +48,5 @@ it('should update state correctly on setToken()', () => {

SendController.resetSend();
expect(SendController.state).toEqual({});
expect(SendController.state).toEqual({ loading: false });
});
});
//# sourceMappingURL=SendController.test.js.map

@@ -182,3 +182,23 @@ import { describe, expect, it, vi } from 'vitest';

});
it('should clear cursor correctly', async () => {
const fetchTransactions = vi
.spyOn(BlockchainApiController, 'fetchTransactions')
.mockResolvedValue({
data: [],
next: 'cursor'
});
await TransactionsController.fetchTransactions('0x123');
expect(TransactionsController.state.next).toBe('cursor');
TransactionsController.clearCursor();
expect(TransactionsController.state.next).toBeUndefined();
await TransactionsController.fetchTransactions('0x123');
expect(fetchTransactions).toHaveBeenCalledWith({
account: '0x123',
projectId,
cursor: undefined,
onramp: undefined
});
expect(TransactionsController.state.next).toBe('cursor');
});
});
//# sourceMappingURL=TransactionsController.test.js.map

@@ -32,4 +32,8 @@ export { ModalController } from './src/controllers/ModalController.js';

export type { TransactionsControllerState } from './src/controllers/TransactionsController.js';
export { SwapController } from './src/controllers/SwapController.js';
export type { SwapControllerState, SwapInputTarget } from './src/controllers/SwapController.js';
export { SendController } from './src/controllers/SendController.js';
export type { SendControllerState } from './src/controllers/SendController.js';
export { TooltipController } from './src/controllers/TooltipController.js';
export type { TooltipControllerState } from './src/controllers/TooltipController.js';
export { AssetUtil } from './src/utils/AssetUtil.js';

@@ -36,0 +40,0 @@ export { ConstantsUtil } from './src/utils/ConstantsUtil.js';

@@ -1,3 +0,4 @@

import type { CaipAddress } from '../utils/TypeUtil.js';
import type { CaipAddress, ConnectedWalletInfo } from '../utils/TypeUtil.js';
import type { Balance } from '@web3modal/common';
import type { W3mFrameTypes } from '@web3modal/wallet';
export interface AccountControllerState {

@@ -15,2 +16,4 @@ isConnected: boolean;

tokenBalance?: Balance[];
connectedWalletInfo?: ConnectedWalletInfo;
preferredAccountType?: W3mFrameTypes.AccountType;
}

@@ -30,4 +33,6 @@ export declare const AccountController: {

setTokenBalance(tokenBalance: AccountControllerState['tokenBalance']): void;
setConnectedWalletInfo(connectedWalletInfo: AccountControllerState['connectedWalletInfo']): void;
setPreferredAccountType(preferredAccountType: AccountControllerState['preferredAccountType']): void;
fetchTokenBalance(): Promise<void>;
resetAccount(): void;
};

@@ -1,6 +0,12 @@

import type { BlockchainApiTransactionsRequest, BlockchainApiTransactionsResponse, BlockchainApiIdentityRequest, BlockchainApiIdentityResponse, GenerateOnRampUrlArgs, GetQuoteArgs, OnrampQuote, BlockchainApiBalanceResponse } from '../utils/TypeUtil.js';
import type { BlockchainApiTransactionsRequest, BlockchainApiTransactionsResponse, BlockchainApiSwapTokensRequest, BlockchainApiSwapTokensResponse, BlockchainApiGenerateSwapCalldataRequest, BlockchainApiGenerateSwapCalldataResponse, BlockchainApiGenerateApproveCalldataRequest, BlockchainApiGenerateApproveCalldataResponse, BlockchainApiSwapAllowanceRequest, BlockchainApiSwapAllowanceResponse, BlockchainApiGasPriceRequest, BlockchainApiGasPriceResponse, BlockchainApiTokenPriceRequest, BlockchainApiTokenPriceResponse, BlockchainApiIdentityRequest, BlockchainApiIdentityResponse, GenerateOnRampUrlArgs, GetQuoteArgs, OnrampQuote, BlockchainApiBalanceResponse } from '../utils/TypeUtil.js';
export declare const BlockchainApiController: {
fetchIdentity({ caipChainId, address }: BlockchainApiIdentityRequest): Promise<BlockchainApiIdentityResponse>;
fetchIdentity({ address }: BlockchainApiIdentityRequest): Promise<BlockchainApiIdentityResponse>;
fetchTransactions({ account, projectId, cursor, onramp, signal }: BlockchainApiTransactionsRequest): Promise<BlockchainApiTransactionsResponse>;
getBalance(address: string): Promise<BlockchainApiBalanceResponse>;
fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest): Promise<BlockchainApiSwapTokensResponse>;
fetchTokenPrice({ projectId, addresses }: BlockchainApiTokenPriceRequest): Promise<BlockchainApiTokenPriceResponse>;
fetchSwapAllowance({ projectId, tokenAddress, userAddress }: BlockchainApiSwapAllowanceRequest): Promise<BlockchainApiSwapAllowanceResponse>;
fetchGasPrice({ projectId, chainId }: BlockchainApiGasPriceRequest): Promise<BlockchainApiGasPriceResponse>;
generateSwapCalldata({ amount, from, projectId, to, userAddress }: BlockchainApiGenerateSwapCalldataRequest): Promise<BlockchainApiGenerateSwapCalldataResponse>;
generateApproveCalldata({ from, projectId, to, userAddress }: BlockchainApiGenerateApproveCalldataRequest): Promise<BlockchainApiGenerateApproveCalldataResponse>;
getBalance(address: string, chainId?: string): Promise<BlockchainApiBalanceResponse>;
generateOnRampURL({ destinationWallets, partnerUserId, defaultNetwork, purchaseAmount, paymentAmount }: GenerateOnRampUrlArgs): Promise<string>;

@@ -7,0 +13,0 @@ getOnrampOptions(): Promise<{

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

import type { Connector, WcWallet } from '../utils/TypeUtil.js';
import type { Connector, EstimateGasTransactionArgs, SendTransactionArgs, WcWallet, WriteContractArgs } from '../utils/TypeUtil.js';
export interface ConnectExternalOptions {

@@ -12,4 +12,12 @@ id: Connector['id'];

signMessage: (message: string) => Promise<string>;
sendTransaction: (args: SendTransactionArgs) => Promise<`0x${string}` | null>;
estimateGas: (args: EstimateGasTransactionArgs) => Promise<bigint>;
parseUnits: (value: string, decimals: number) => bigint;
formatUnits: (value: bigint, decimals: number) => string;
connectExternal?: (options: ConnectExternalOptions) => Promise<void>;
reconnectExternal?: (options: ConnectExternalOptions) => Promise<void>;
checkInstalled?: (ids?: string[]) => boolean;
writeContract: (args: WriteContractArgs) => Promise<`0x${string}` | null>;
getEnsAddress: (value: string) => Promise<false | string>;
getEnsAvatar: (value: string) => Promise<false | string>;
}

@@ -36,3 +44,11 @@ export interface ConnectionControllerState {

connectExternal(options: ConnectExternalOptions): Promise<void>;
reconnectExternal(options: ConnectExternalOptions): Promise<void>;
signMessage(message: string): Promise<string>;
parseUnits(value: string, decimals: number): bigint;
formatUnits(value: bigint, decimals: number): string;
sendTransaction(args: SendTransactionArgs): Promise<`0x${string}` | null>;
estimateGas(args: EstimateGasTransactionArgs): Promise<bigint>;
writeContract(args: WriteContractArgs): Promise<`0x${string}` | null>;
getEnsAddress(value: string): Promise<string | false>;
getEnsAvatar(value: string): Promise<string | false>;
checkInstalled(ids?: string[]): boolean | undefined;

@@ -39,0 +55,0 @@ resetWcConnection(): void;

@@ -18,5 +18,7 @@ import type { CaipNetwork, CaipNetworkId } from '../utils/TypeUtil.js';

allowUnsupportedChain?: boolean;
smartAccountEnabledNetworks?: number[];
}
export declare const NetworkController: {
state: NetworkControllerState;
subscribe(callback: (newState: NetworkControllerState) => void): () => void;
subscribeKey<K extends keyof NetworkControllerState>(key: K, callback: (value: NetworkControllerState[K]) => void): () => void;

@@ -29,2 +31,3 @@ _getClient(): NetworkControllerClient;

setAllowUnsupportedChain(allowUnsupportedChain: NetworkControllerState['allowUnsupportedChain']): void;
setSmartAccountEnabledNetworks(smartAccountEnabledNetworks: NetworkControllerState['smartAccountEnabledNetworks']): void;
getRequestedCaipNetworks(): CaipNetwork[];

@@ -34,4 +37,5 @@ getApprovedCaipNetworksData(): Promise<void>;

checkIfSupportedNetwork(): void;
checkIfSmartAccountEnabled(): boolean;
resetNetwork(): void;
showUnsupportedChainUI(): void;
};

@@ -38,2 +38,40 @@ import type { CustomWallet, Metadata, ProjectId, SdkVersion, Tokens } from '../utils/TypeUtil.js';

setWalletFeaturesEnabled(enableWalletFeatures: OptionsControllerState['enableWalletFeatures']): void;
getSnapshot(): {
readonly projectId: ProjectId;
readonly sdkType: 'w3m';
readonly sdkVersion: SdkVersion;
readonly allWallets?: "SHOW" | "HIDE" | "ONLY_MOBILE" | undefined;
readonly featuredWalletIds?: readonly string[] | undefined;
readonly includeWalletIds?: readonly string[] | undefined;
readonly excludeWalletIds?: readonly string[] | undefined;
readonly tokens?: {
readonly [x: `${string}:${string}`]: {
readonly address: string;
readonly image?: string | undefined;
};
} | undefined;
readonly customWallets?: readonly {
readonly name: string;
readonly id: string;
readonly homepage?: string | undefined;
readonly image_url?: string | undefined;
readonly mobile_link?: string | null | undefined;
readonly desktop_link?: string | null | undefined;
readonly webapp_link?: string | null | undefined;
readonly app_store?: string | null | undefined;
readonly play_store?: string | null | undefined;
}[] | undefined;
readonly termsConditionsUrl?: string | undefined;
readonly privacyPolicyUrl?: string | undefined;
readonly isSiweEnabled?: boolean | undefined;
readonly enableAnalytics?: boolean | undefined;
readonly metadata?: {
readonly name: string;
readonly description: string;
readonly url: string;
readonly icons: readonly string[];
} | undefined;
readonly enableOnramp?: boolean | undefined;
readonly enableWalletFeatures?: boolean | undefined;
};
};
import type { CaipNetworkId } from '../utils/TypeUtil.js';
export interface PublicStateControllerState {
loading: boolean;
open: boolean;

@@ -4,0 +5,0 @@ selectedNetworkId?: CaipNetworkId;

import type { CaipNetwork, Connector, WcWallet } from '../utils/TypeUtil.js';
import type { SwapInputTarget } from './SwapController.js';
type TransactionAction = {
goBack: boolean;
view: RouterControllerState['view'] | null;
close?: boolean;
replace?: boolean;
onSuccess?: () => void;
onCancel?: () => void;
};
export interface RouterControllerState {
view: 'Account' | 'AccountSettings' | 'AllWallets' | 'ApproveTransaction' | 'BuyInProgress' | 'WalletCompatibleNetworks' | 'Connect' | 'ConnectingExternal' | 'ConnectingWalletConnect' | 'ConnectingSiwe' | 'Downloads' | 'EmailVerifyOtp' | 'EmailVerifyDevice' | 'GetWallet' | 'Networks' | 'OnRampActivity' | 'OnRampFiatSelect' | 'OnRampProviders' | 'OnRampTokenSelect' | 'SwitchNetwork' | 'Transactions' | 'UnsupportedChain' | 'UpdateEmailWallet' | 'UpdateEmailPrimaryOtp' | 'UpdateEmailSecondaryOtp' | 'UpgradeEmailWallet' | 'UpgradeToSmartAccount' | 'WalletReceive' | 'WalletSend' | 'WalletSendPreview' | 'WalletSendSelectToken' | 'WhatIsANetwork' | 'WhatIsAWallet' | 'WhatIsABuy';
view: 'Account' | 'AccountSettings' | 'AllWallets' | 'ApproveTransaction' | 'BuyInProgress' | 'WalletCompatibleNetworks' | 'Connect' | 'ConnectingExternal' | 'ConnectingWalletConnect' | 'ConnectingSiwe' | 'Downloads' | 'EmailVerifyOtp' | 'EmailVerifyDevice' | 'GetWallet' | 'Networks' | 'OnRampActivity' | 'OnRampFiatSelect' | 'OnRampProviders' | 'OnRampTokenSelect' | 'SwitchNetwork' | 'Transactions' | 'UnsupportedChain' | 'UpdateEmailWallet' | 'UpdateEmailPrimaryOtp' | 'UpdateEmailSecondaryOtp' | 'UpgradeEmailWallet' | 'UpgradeToSmartAccount' | 'WalletReceive' | 'WalletSend' | 'WalletSendPreview' | 'WalletSendSelectToken' | 'WhatIsANetwork' | 'WhatIsAWallet' | 'WhatIsABuy' | 'Swap' | 'SwapSelectToken' | 'SwapPreview';
history: RouterControllerState['view'][];

@@ -11,3 +20,6 @@ data?: {

newEmail?: string;
target?: SwapInputTarget;
swapUnsupportedChain?: boolean;
};
transactionStack: TransactionAction[];
}

@@ -17,2 +29,4 @@ export declare const RouterController: {

subscribeKey<K extends keyof RouterControllerState>(key: K, callback: (value: RouterControllerState[K]) => void): () => void;
pushTransactionStack(action: TransactionAction): void;
popTransactionStack(cancel?: boolean): void;
push(view: RouterControllerState['view'], data?: RouterControllerState['data']): void;

@@ -24,1 +38,2 @@ reset(view: RouterControllerState['view']): void;

};
export {};

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

import type { Balance } from '@web3modal/common';
import { type Balance } from '@web3modal/common';
export interface TxParams {
receiverAddress: string;
sendTokenAmount: number;
gasPrice: bigint;
decimals: string;
}
export interface ContractWriteParams {
receiverAddress: string;
tokenAddress: string;
sendTokenAmount: number;
decimals: string;
}
export interface SendControllerState {

@@ -8,2 +20,5 @@ token?: Balance;

receiverProfileImageUrl?: string;
gasPrice?: bigint;
gasPriceInUSD?: number;
loading: boolean;
}

@@ -19,3 +34,9 @@ export declare const SendController: {

setReceiverProfileName(receiverProfileName: SendControllerState['receiverProfileName']): void;
setGasPrice(gasPrice: SendControllerState['gasPrice']): void;
setGasPriceInUsd(gasPriceInUSD: SendControllerState['gasPriceInUSD']): void;
setLoading(loading: SendControllerState['loading']): void;
sendToken(): void;
sendNativeToken(params: TxParams): Promise<void>;
sendERC20Token(params: ContractWriteParams): Promise<void>;
resetSend(): void;
};
import type { ThemeMode, ThemeVariables } from '../utils/TypeUtil.js';
import type { W3mThemeVariables } from '@web3modal/common';
export interface ThemeControllerState {
themeMode: ThemeMode;
themeVariables: ThemeVariables;
w3mThemeVariables: W3mThemeVariables | undefined;
}

@@ -22,3 +24,7 @@ export declare const ThemeController: {

};
readonly w3mThemeVariables: {
readonly '--w3m-accent': string;
readonly '--w3m-background': string;
} | undefined;
};
};

@@ -18,4 +18,5 @@ import type { Transaction } from '@web3modal/common';

filterSpamTransactions(transactions: Transaction[]): Transaction[];
clearCursor(): void;
resetTransactions(): void;
};
export {};

@@ -15,3 +15,2 @@ export declare const ONRAMP_PROVIDERS: {

RESTRICTED_TIMEZONES: string[];
CONNECTOR_RDNS_MAP: Record<string, string>;
WC_COINBASE_PAY_SDK_CHAINS: string[];

@@ -29,3 +28,8 @@ WC_COINBASE_PAY_SDK_FALLBACK_CHAIN: string;

WC_COINBASE_ONRAMP_APP_ID: string;
SWAP_SUGGESTED_TOKENS: string[];
SWAP_POPULAR_TOKENS: string[];
SWAP_SUPPORTED_NETWORKS: string[];
NATIVE_TOKEN_ADDRESS: string;
CONVERT_SLIPPAGE_TOLERANCE: number;
};
export type CoinbasePaySDKChainNameValues = keyof typeof ConstantsUtil.WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP;
export declare const RouterUtil: {
goBackOrCloseModal(): void;
navigateAfterNetworkSwitch(): void;
navigateAfterPreferredAccountTypeSelect(): void;
};

@@ -12,2 +12,3 @@ import type { WcWallet, ConnectorType } from './TypeUtil.js';

setConnectedWalletImageUrl(imageUrl: string): void;
removeConnectedWalletImageUrl(): void;
getConnectedWalletImageUrl(): string | null | undefined;

@@ -14,0 +15,0 @@ setConnectedConnector(connectorType: ConnectorType): void;

@@ -12,2 +12,7 @@ import type { W3mFrameProvider } from '@web3modal/wallet';

}
export type ConnectedWalletInfo = {
name?: string;
icon?: string;
[key: string]: unknown;
} | undefined;
export interface LinkingRecord {

@@ -28,2 +33,5 @@ redirect: string;

info?: {
uuid?: string;
name?: string;
icon?: string;
rdns?: string;

@@ -95,3 +103,2 @@ };

export interface BlockchainApiIdentityRequest {
caipChainId: CaipNetworkId;
address: string;

@@ -114,2 +121,97 @@ }

}
export type SwapToken = {
name: string;
symbol: string;
address: `${string}:${string}:${string}`;
decimals: number;
logoUri: string;
eip2612?: boolean;
};
export type SwapTokenWithBalance = SwapToken & {
quantity: {
decimals: string;
numeric: string;
};
price: number;
value: number;
};
export interface BlockchainApiSwapTokensRequest {
projectId: string;
chainId?: string;
}
export interface BlockchainApiSwapTokensResponse {
tokens: SwapToken[];
}
export interface BlockchainApiTokenPriceRequest {
projectId: string;
currency?: 'usd' | 'eur' | 'gbp' | 'aud' | 'cad' | 'inr' | 'jpy' | 'btc' | 'eth';
addresses: string[];
}
export interface BlockchainApiTokenPriceResponse {
fungibles: {
name: string;
symbol: string;
iconUrl: string;
price: string;
}[];
}
export interface BlockchainApiSwapAllowanceRequest {
projectId: string;
tokenAddress: string;
userAddress: string;
}
export interface BlockchainApiSwapAllowanceResponse {
allowance: string;
}
export interface BlockchainApiGasPriceRequest {
projectId: string;
chainId: string;
}
export interface BlockchainApiGasPriceResponse {
standard: string;
fast: string;
instant: string;
}
export interface BlockchainApiGenerateSwapCalldataRequest {
projectId: string;
userAddress: string;
from: string;
to: string;
amount: string;
eip155?: {
slippage: string;
permit?: string;
};
}
export interface BlockchainApiGenerateSwapCalldataResponse {
tx: {
from: `${string}:${string}:${string}`;
to: `${string}:${string}:${string}`;
data: `0x${string}`;
amount: string;
eip155: {
gas: string;
gasPrice: string;
};
};
}
export interface BlockchainApiGenerateApproveCalldataRequest {
projectId: string;
userAddress: string;
from: string;
to: string;
amount?: number;
}
export interface BlockchainApiGenerateApproveCalldataResponse {
tx: {
from: `${string}:${string}:${string}`;
to: `${string}:${string}:${string}`;
data: `0x${string}`;
value: string;
eip155: {
gas: number;
gasPrice: string;
};
};
}
export interface BlockchainApiBalanceResponse {

@@ -244,2 +346,11 @@ balances: Balance[];

};
} | {
type: 'track';
event: 'CLICK_CONVERT';
} | {
type: 'track';
event: 'CLICK_SELECT_TOKEN_TO_SWAP';
} | {
type: 'track';
event: 'CLICK_SELECT_NETWORK_TO_SWAP';
};

@@ -297,1 +408,22 @@ export type DestinationWallet = {

};
export interface SendTransactionArgs {
to: `0x${string}`;
data: `0x${string}`;
value: bigint;
gas?: bigint;
gasPrice: bigint;
address: `0x${string}`;
}
export interface EstimateGasTransactionArgs {
address: `0x${string}`;
to: `0x${string}`;
data: `0x${string}`;
}
export interface WriteContractArgs {
receiverAddress: `0x${string}`;
tokenAmount: bigint;
tokenAddress: `0x${string}`;
fromAddress: `0x${string}`;
method: 'send' | 'transfer' | 'call';
abi: any;
}
{
"name": "@web3modal/core",
"version": "4.2.0-65f3d27d.0",
"version": "4.2.0-alpha.0",
"type": "module",

@@ -16,8 +16,8 @@ "main": "./dist/esm/index.js",

"typecheck": "tsc --noEmit",
"test": "vitest run --dir tests --coverage.enabled --reporter=junit --coverage.reporter=json-summary --coverage.reporter=html",
"test": "vitest run --dir tests --coverage.enabled=true --coverage.reporter=json --coverage.reporter=json-summary --coverage.reportOnFailure=true",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@web3modal/common": "4.2.0-65f3d27d.0",
"@web3modal/wallet": "4.2.0-65f3d27d.0",
"@web3modal/common": "4.2.0-alpha.0",
"@web3modal/wallet": "4.2.0-alpha.0",
"valtio": "1.11.2"

@@ -24,0 +24,0 @@ },

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

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

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

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