Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

@rainbow-me/kit-utils

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rainbow-me/kit-utils - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

13

dist/address.d.ts

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

export declare function isAddress(value: any): string | false;
/**
* Check an Ethereum address for validity
* @param address blockchain address
* @returns original address or "false"
*/
export declare function isAddress(value: string): string | false;
/**
* Shortens an Ethereum address by N characters
* @param address blockchain address
* @param chars amount of character t shorten
* @returns formatted string
*/
export declare function shortenAddress(address: string, chars?: number): string;

@@ -1,4 +0,14 @@

export declare const connectorByWallet: (name: string) => "Injected" | "WalletLink" | "Frame" | "Torus" | "WalletConnect";
export declare const walletByConnector: (connector: string) => "metamask" | "coinbase" | "torus" | "walletconnect";
export declare const chainNametoID: (name: string) => number;
/**
* Finds a connector name by wallet name
* @param wallet wallet name
* @returns connector name
*/
export declare const connectorByWallet: (wallet: string) => "Injected" | "WalletLink" | "Frame" | "WalletConnect";
/**
* Finds a wallet name by connector name
* @param connector connect name
* @returns wallet name
*/
export declare const walletByConnector: (connector: string) => "metamask" | "walletlink" | "frame" | "walletconnect";
export declare const chainNametoId: (name: string) => number;
export declare const chainIdToName: (id: number) => string;

@@ -5,0 +15,0 @@ export declare const chainIdToAlias: (id: number) => string;

52

dist/index.js

@@ -506,3 +506,3 @@ import React from 'react';

chainId: 43113,
aliases: ['avax testnet', 'avalanche testnet', 'avax fuji', 'avalanche fuji']
aliases: ['avax testnet', 'avalanche testnet', 'avax fuji', 'avalanche fuji', 'fuji', 'fuji testnet']
},

@@ -569,4 +569,9 @@ {

const connectorByWallet = (name) => {
switch (name) {
/**
* Finds a connector name by wallet name
* @param wallet wallet name
* @returns connector name
*/
const connectorByWallet = (wallet) => {
switch (wallet) {
case 'metamask':

@@ -579,9 +584,13 @@ return 'Injected';

return 'Frame';
case 'torus':
return 'Torus';
case 'walletconnect':
case 'rainbow':
case 'argent':
return 'WalletConnect';
}
};
/**
* Finds a wallet name by connector name
* @param connector connect name
* @returns wallet name
*/
const walletByConnector = (connector) => {

@@ -592,10 +601,10 @@ switch (connector) {

case 'WalletLinkConnector':
return 'coinbase';
case 'TorusConnector':
return 'torus';
return 'walletlink';
case 'WalletConnectConnector':
return 'walletconnect';
case 'FrameConnector':
return 'frame';
}
};
const chainNametoID = (name) => { var _a; return ((_a = chains.find((chain) => chain.aliases.includes(name))) === null || _a === void 0 ? void 0 : _a.chainId) || 1; };
const chainNametoId = (name) => { var _a; return ((_a = chains.find((chain) => chain.aliases.includes(name))) === null || _a === void 0 ? void 0 : _a.chainId) || 1; };
const chainIdToName = (id) => { var _a; return ((_a = chains.find((chain) => chain.chainId === id)) === null || _a === void 0 ? void 0 : _a.name) || 'Ethereum'; };

@@ -612,2 +621,7 @@ const chainIdToAlias = (id) => { var _a; return ((_a = chains.find((chain) => chain.chainId === id)) === null || _a === void 0 ? void 0 : _a.aliases[0]) || 'ethereum'; };

/**
* Check an Ethereum address for validity
* @param address blockchain address
* @returns original address or "false"
*/
function isAddress(value) {

@@ -621,7 +635,12 @@ try {

}
/**
* Shortens an Ethereum address by N characters
* @param address blockchain address
* @param chars amount of character t shorten
* @returns formatted string
*/
function shortenAddress(address, chars = 4) {
const parsed = isAddress(address);
if (!parsed) {
if (!parsed)
throw Error(`Invalid 'address' parameter '${address}'.`);
}
return `${parsed.substring(0, chars + 2)}...${parsed.substring(42 - chars)}`;

@@ -811,7 +830,7 @@ }

function hashCode(text) {
let hash = 0, i, chr;
let hash = 0;
if (text.length === 0)
return hash;
for (i = 0; i < text.length; i++) {
chr = text.charCodeAt(i);
for (let i = 0; i < text.length; i++) {
const chr = text.charCodeAt(i);
hash = (hash << 5) - hash + chr;

@@ -841,5 +860,4 @@ hash |= 0;

return 0;
if (colors.includes(colorHex)) {
if (colors.includes(colorHex))
return colors.indexOf(colorHex);
}
return 0;

@@ -862,2 +880,2 @@ }

export { ChainId, addressHashedColorIndex, addressHashedEmoji, addressHashedIndex, avatarColor, avatars, chainIDToExplorer, chainIDToToken, chainIdToAlias, chainIdToName, chainNametoID, chains, colorHexToIndex, colors, connectorByWallet, emojiColorIndexes, etherscanFetcher, getWalletInfo, guessTitle, hashCode, isAddress, isAuthorized, logsFetcher, popularEmojis, resolveAddress, setupProvider, shortenAddress, switchNetwork, toSignificant, walletByConnector, walletConnectRPCs, withWeb3React };
export { ChainId, addressHashedColorIndex, addressHashedEmoji, addressHashedIndex, avatarColor, avatars, chainIDToExplorer, chainIDToToken, chainIdToAlias, chainIdToName, chainNametoId, chains, colorHexToIndex, colors, connectorByWallet, emojiColorIndexes, etherscanFetcher, getWalletInfo, guessTitle, hashCode, isAddress, isAuthorized, logsFetcher, popularEmojis, resolveAddress, setupProvider, shortenAddress, switchNetwork, toSignificant, walletByConnector, walletConnectRPCs, withWeb3React };
{
"name": "@rainbow-me/kit-utils",
"type": "module",
"version": "0.0.4",
"version": "0.0.5",
"exports": "./dist/index.js",

@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts",

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