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.0.14-b3fbdad8.0 to 4.1.0

28

dist/esm/src/controllers/AccountController.js
import { subscribeKey as subKey } from 'valtio/utils';
import { proxy, subscribe as sub } from 'valtio/vanilla';
import { proxy, ref, subscribe as sub } from 'valtio/vanilla';
import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';
import { BlockchainApiController } from './BlockchainApiController.js';
import { SnackController } from './SnackController.js';
const state = proxy({
isConnected: false
isConnected: false,
currentTab: 0,
tokenBalance: []
});

@@ -38,2 +42,21 @@ export const AccountController = {

},
setCurrentTab(currentTab) {
state.currentTab = currentTab;
},
setTokenBalance(tokenBalance) {
if (tokenBalance) {
state.tokenBalance = ref(tokenBalance);
}
},
async fetchTokenBalance() {
try {
if (state.address) {
const response = await BlockchainApiController.getBalance(state.address);
this.setTokenBalance(response.balances);
}
}
catch (error) {
SnackController.showError('Failed to fetch token balance');
}
},
resetAccount() {

@@ -49,4 +72,5 @@ state.isConnected = false;

state.smartAccountDeployed = undefined;
state.currentTab = 0;
}
};
//# sourceMappingURL=AccountController.js.map

@@ -98,2 +98,11 @@ import { CoreHelperUtil } from '../utils/CoreHelperUtil.js';

},
async getBalance(address) {
return api.get({
path: `/v1/account/${address}/balance`,
params: {
currency: 'usd',
projectId: OptionsController.state.projectId
}
});
},
async generateOnRampURL({ destinationWallets, partnerUserId, defaultNetwork, purchaseAmount, paymentAmount }) {

@@ -100,0 +109,0 @@ const response = await api.post({

12

dist/esm/src/controllers/NetworkController.js
import { subscribeKey as subKey } from 'valtio/utils';
import { proxy, ref, subscribe as sub } from 'valtio/vanilla';
import { proxy, ref } from 'valtio/vanilla';
import { PublicStateController } from './PublicStateController.js';

@@ -13,5 +13,2 @@ import { EventsController } from './EventsController.js';

state,
subscribe(callback) {
return sub(state, () => callback(state));
},
subscribeKey(key, callback) {

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

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

@@ -79,6 +73,2 @@ const { approvedCaipNetworkIds, requestedCaipNetworks } = state;

},
checkIfSmartAccountEnabled() {
const networkId = Number(state.caipNetwork?.id?.split(':')?.[1]);
return Boolean(state.smartAccountEnabledNetworks?.includes(networkId));
},
resetNetwork() {

@@ -85,0 +75,0 @@ if (!state.isDefaultCaipNetwork) {

@@ -200,4 +200,16 @@ import { ConstantsUtil } from './ConstantsUtil.js';

return requestedNetworks;
},
calculateBalance(array) {
let sum = 0;
for (const item of array) {
sum += item.value;
}
return sum;
},
formatTokenBalance(number) {
const roundedNumber = number.toFixed(2);
const [dollars, pennies] = roundedNumber.split('.');
return { dollars, pennies };
}
};
//# sourceMappingURL=CoreHelperUtil.js.map
import type { CaipAddress } from '../utils/TypeUtil.js';
import type { Balance } from '@web3modal/common';
export interface AccountControllerState {
isConnected: boolean;
currentTab: number;
caipAddress?: CaipAddress;

@@ -12,2 +14,3 @@ address?: string;

smartAccountDeployed?: boolean;
tokenBalance?: Balance[];
}

@@ -25,3 +28,6 @@ export declare const AccountController: {

setSmartAccountDeployed(isDeployed: boolean): void;
setCurrentTab(currentTab: AccountControllerState['currentTab']): void;
setTokenBalance(tokenBalance: AccountControllerState['tokenBalance']): void;
fetchTokenBalance(): Promise<void>;
resetAccount(): void;
};

@@ -1,5 +0,6 @@

import type { BlockchainApiTransactionsRequest, BlockchainApiTransactionsResponse, BlockchainApiIdentityRequest, BlockchainApiIdentityResponse, GenerateOnRampUrlArgs, GetQuoteArgs, OnrampQuote } from '../utils/TypeUtil.js';
import type { BlockchainApiTransactionsRequest, BlockchainApiTransactionsResponse, BlockchainApiIdentityRequest, BlockchainApiIdentityResponse, GenerateOnRampUrlArgs, GetQuoteArgs, OnrampQuote, BlockchainApiBalanceResponse } from '../utils/TypeUtil.js';
export declare const BlockchainApiController: {
fetchIdentity({ caipChainId, address }: BlockchainApiIdentityRequest): Promise<BlockchainApiIdentityResponse>;
fetchTransactions({ account, projectId, cursor, onramp, signal }: BlockchainApiTransactionsRequest): Promise<BlockchainApiTransactionsResponse>;
getBalance(address: string): Promise<BlockchainApiBalanceResponse>;
generateOnRampURL({ destinationWallets, partnerUserId, defaultNetwork, purchaseAmount, paymentAmount }: GenerateOnRampUrlArgs): Promise<string>;

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

@@ -18,7 +18,5 @@ 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;

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

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

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

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

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

import type { Balance } from '@web3modal/common';
import type { CaipAddress, LinkingRecord, CaipNetwork } from './TypeUtil.js';

@@ -32,2 +33,7 @@ export declare const CoreHelperUtil: {

sortRequestedNetworks(approvedIds: `${string}:${string}`[] | undefined, requestedNetworks?: CaipNetwork[]): CaipNetwork[];
calculateBalance(array: Balance[]): number;
formatTokenBalance(number: number): {
dollars: string | undefined;
pennies: string | undefined;
};
};
import type { W3mFrameProvider } from '@web3modal/wallet';
import type { Transaction } from '@web3modal/common';
import type { Balance, Transaction } from '@web3modal/common';
export type CaipAddress = `${string}:${string}:${string}`;

@@ -111,2 +111,5 @@ export type CaipNetworkId = `${string}:${string}`;

}
export interface BlockchainApiBalanceResponse {
balances: Balance[];
}
export interface Token {

@@ -113,0 +116,0 @@ address: string;

{
"name": "@web3modal/core",
"version": "4.0.14-b3fbdad8.0",
"version": "4.1.0",
"type": "module",

@@ -20,4 +20,4 @@ "main": "./dist/esm/index.js",

"dependencies": {
"@web3modal/common": "4.0.14-b3fbdad8.0",
"@web3modal/wallet": "4.0.14-b3fbdad8.0",
"@web3modal/common": "4.1.0",
"@web3modal/wallet": "4.1.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

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