@edgeandnode/common
Advanced tools
Comparing version 1.0.6 to 1.0.7
import gql from 'graphql-tag'; | ||
import { parse, print } from 'graphql'; | ||
import pluralize from 'pluralize'; | ||
import { ethers, utils } from 'ethers'; | ||
import 'dataloader'; | ||
import { providers, Contract, utils } from 'ethers'; | ||
import numeral from 'numeral'; | ||
@@ -60,6 +61,5 @@ | ||
const connectProvider = (rpcEndpoint, ethAddress) => { | ||
let providerWithSigner; | ||
try { | ||
const provider = new ethers.providers.StaticJsonRpcProvider(rpcEndpoint); | ||
providerWithSigner = provider.getSigner(ethAddress); | ||
const provider = new providers.StaticJsonRpcProvider(rpcEndpoint); | ||
return provider.getSigner(ethAddress); | ||
} | ||
@@ -69,9 +69,8 @@ catch (e) { | ||
} | ||
return providerWithSigner; | ||
return null; | ||
}; | ||
const getContract = (contractAddress, contractABI, providerOrSigner) => { | ||
let contract = null; | ||
if (contractAddress && contractABI && providerOrSigner) { | ||
try { | ||
contract = new ethers.Contract(contractAddress, contractABI, providerOrSigner); | ||
return new Contract(contractAddress, contractABI, providerOrSigner); | ||
} | ||
@@ -82,19 +81,18 @@ catch (e) { | ||
} | ||
return contract; | ||
return null; | ||
}; | ||
const formatUnitsOriginal = (num, power) => power ? utils.formatUnits(num, power) : utils.formatUnits(num, 18); | ||
const getTxLink = (transactionId, networkName) => { | ||
let txLink = ''; | ||
switch (networkName) { | ||
case 'mainnet': | ||
txLink = `https://etherscan.io/tx/${transactionId}`; | ||
break; | ||
case 'mainnet': { | ||
return `https://etherscan.io/tx/${transactionId}`; | ||
} | ||
case 'matic': | ||
case 'polygon': | ||
txLink = `https://polygonscan.com/tx/${transactionId}`; | ||
break; | ||
default: | ||
txLink = `https://${networkName}.etherscan.io/tx/${transactionId}`; | ||
case 'polygon': { | ||
return `https://polygonscan.com/tx/${transactionId}`; | ||
} | ||
default: { | ||
return `https://${networkName}.etherscan.io/tx/${transactionId}`; | ||
} | ||
} | ||
return txLink; | ||
}; | ||
@@ -101,0 +99,0 @@ |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var pluralize = require('pluralize'); | ||
require('dataloader'); | ||
var ethers = require('ethers'); | ||
@@ -71,6 +72,5 @@ var numeral = require('numeral'); | ||
const connectProvider = (rpcEndpoint, ethAddress) => { | ||
let providerWithSigner; | ||
try { | ||
const provider = new ethers.ethers.providers.StaticJsonRpcProvider(rpcEndpoint); | ||
providerWithSigner = provider.getSigner(ethAddress); | ||
const provider = new ethers.providers.StaticJsonRpcProvider(rpcEndpoint); | ||
return provider.getSigner(ethAddress); | ||
} | ||
@@ -80,9 +80,8 @@ catch (e) { | ||
} | ||
return providerWithSigner; | ||
return null; | ||
}; | ||
const getContract = (contractAddress, contractABI, providerOrSigner) => { | ||
let contract = null; | ||
if (contractAddress && contractABI && providerOrSigner) { | ||
try { | ||
contract = new ethers.ethers.Contract(contractAddress, contractABI, providerOrSigner); | ||
return new ethers.Contract(contractAddress, contractABI, providerOrSigner); | ||
} | ||
@@ -93,19 +92,18 @@ catch (e) { | ||
} | ||
return contract; | ||
return null; | ||
}; | ||
const formatUnitsOriginal = (num, power) => power ? ethers.utils.formatUnits(num, power) : ethers.utils.formatUnits(num, 18); | ||
const getTxLink = (transactionId, networkName) => { | ||
let txLink = ''; | ||
switch (networkName) { | ||
case 'mainnet': | ||
txLink = `https://etherscan.io/tx/${transactionId}`; | ||
break; | ||
case 'mainnet': { | ||
return `https://etherscan.io/tx/${transactionId}`; | ||
} | ||
case 'matic': | ||
case 'polygon': | ||
txLink = `https://polygonscan.com/tx/${transactionId}`; | ||
break; | ||
default: | ||
txLink = `https://${networkName}.etherscan.io/tx/${transactionId}`; | ||
case 'polygon': { | ||
return `https://polygonscan.com/tx/${transactionId}`; | ||
} | ||
default: { | ||
return `https://${networkName}.etherscan.io/tx/${transactionId}`; | ||
} | ||
} | ||
return txLink; | ||
}; | ||
@@ -112,0 +110,0 @@ |
@@ -1,5 +0,9 @@ | ||
import { ethers, ContractInterface } from 'ethers'; | ||
export declare const connectProvider: (rpcEndpoint: string, ethAddress?: string) => ethers.providers.JsonRpcSigner; | ||
export declare const getContract: (contractAddress: string, contractABI: ContractInterface, providerOrSigner: any) => ethers.Contract; | ||
import DataLoader from 'dataloader'; | ||
import { ethers, Contract, ContractInterface, providers } from 'ethers'; | ||
export declare const connectProvider: (rpcEndpoint: string, ethAddress?: string) => providers.JsonRpcSigner | null; | ||
export declare const getContract: (contractAddress: string, contractABI: ContractInterface, providerOrSigner: providers.Provider | ethers.Signer) => Contract; | ||
export declare const formatUnitsOriginal: (num: number | string, power?: number) => string; | ||
export declare const getTxLink: (transactionId: string, networkName: string) => string; | ||
export declare const ensLookup: (provider: providers.Web3Provider, address: string) => Promise<string | null>; | ||
export declare const ensLookups: (provider: providers.Web3Provider, addresses: readonly string[]) => Promise<(string | null)[]>; | ||
export declare const buildEnsDataLoader: (provider: providers.Web3Provider) => DataLoader<string, string | null>; |
{ | ||
"name": "@edgeandnode/common", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Common Edge & Node utils and types", | ||
@@ -60,3 +60,4 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"ethers": "^5.3.1", | ||
"dataloader": "^2.0.0", | ||
"ethers": "^5.4.3", | ||
"graphql": "^15.5.0", | ||
@@ -63,0 +64,0 @@ "graphql-tag": "^2.12.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
32601
0
6
+ Addeddataloader@^2.0.0
+ Addeddataloader@2.2.3(transitive)
Updatedethers@^5.4.3