@edgeandnode/common
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -1,3 +0,3 @@ | ||
export { generateExampleQuery, connectProvider, getContract, getTxLink, formatWithNumeral, buildEnsDataLoader, ensLookup, ensLookups, unixDateFromNow, dateFromNow, dateStringFromNow, dateUntilNow, formatDuration, formatHourMin, getDate, blocksToDays, delegatorCooldownToDays, formatDayHourMin, formatDays, formatUnits, formatUnitsToNumber, toGRT, formatNameHash, bigNumberify, decToBigNumber, overrides, FormatNumeralOptions, FormatUnitsOptions, ToGRTOptions, toWei, addrShortener, checkAllowance, purchaseTargetAmount, saleTargetAmount, tokensToSignal, TokensToSignalPair, vSignalToNSignal, signalToTokens, TokensToNSignalTriple, tokensToNSignal, NSignalToTokensPair, nSignalToTokens, nSignalToVSignal, getEventTypeFromTypename, getEventInterface, buildEventInterfaceList } from './utils'; | ||
export { generateExampleQuery, connectProvider, getContract, getTxLink, formatWithNumeral, buildEnsDataLoader, ensLookup, ensLookups, unixDateFromNow, dateFromNow, dateStringFromNow, dateUntilNow, formatDuration, formatHourMin, getDate, blocksToDays, delegatorCooldownToDays, formatDayHourMin, formatDays, formatUnits, formatUnitsToNumber, toGRT, formatNameHash, bigNumberify, decToBigNumber, overrides, FormatNumeralOptions, FormatUnitsOptions, ToGRTOptions, toWei, addrShortener, checkAllowance, purchaseTargetAmount, saleTargetAmount, tokensToSignal, TokensToSignalPair, vSignalToNSignal, signalToTokens, TokensToNSignalTriple, tokensToNSignal, NSignalToTokensPair, nSignalToTokens, nSignalToVSignal, getEventTypeFromTypename, getEventInterface, buildEventInterfaceList, getERC20Balance } from './utils'; | ||
export * from './models'; | ||
export { SECONDS_IN_DAY, ETHEREUM_BLOCK_TIME, NETWORKS } from './constants'; |
@@ -63,2 +63,10 @@ import gql from 'graphql-tag'; | ||
var erc20Abi = [ | ||
'function balanceOf(address owner) view returns (uint256)', | ||
'function decimals() view returns (uint8)', | ||
'function symbol() view returns (string)', | ||
'function transfer(address to, uint amount) returns (bool)', | ||
'event Transfer(address indexed from, address indexed to, uint amount)' | ||
]; | ||
/** | ||
@@ -206,2 +214,13 @@ * Get provider | ||
}; | ||
/** | ||
* Get ERC20 balance of a wallet | ||
* @param walletAddress Address of interest | ||
* @param tokenAddress Address of ERC20 | ||
* @param provider Web3 provider | ||
* @returns Balance of ERC20 in provided wallet | ||
*/ | ||
const getERC20Balance = async (walletAddress, tokenAddress, provider) => { | ||
const contract = new Contract(tokenAddress, erc20Abi, provider); | ||
return contract.balanceOf(walletAddress); | ||
}; | ||
@@ -816,3 +835,3 @@ Object.assign(numeral.localeData('en'), { | ||
export { AllocationStatus, DisputeStatus, DisputeType, ETHEREUM_BLOCK_TIME, EventType, NETWORKS, Revocability, SECONDS_IN_DAY, SubgraphIndexHealth, TransactionType, addrShortener, bigNumberify, blocksToDays, buildEnsDataLoader, buildEventInterfaceList, checkAllowance, connectProvider, dateFromNow, dateStringFromNow, dateUntilNow, decToBigNumber, delegatorCooldownToDays, ensLookup, ensLookups, formatDayHourMin, formatDays, formatDuration, formatHourMin, formatNameHash, formatUnits, formatUnitsToNumber, formatWithNumeral, generateExampleQuery, getContract, getDate, getEventInterface, getEventTypeFromTypename, getTxLink, nSignalToTokens, nSignalToVSignal, overrides, purchaseTargetAmount, saleTargetAmount, signalToTokens, toGRT, toWei, tokensToNSignal, tokensToSignal, unixDateFromNow, vSignalToNSignal }; | ||
export { AllocationStatus, DisputeStatus, DisputeType, ETHEREUM_BLOCK_TIME, EventType, NETWORKS, Revocability, SECONDS_IN_DAY, SubgraphIndexHealth, TransactionType, addrShortener, bigNumberify, blocksToDays, buildEnsDataLoader, buildEventInterfaceList, checkAllowance, connectProvider, dateFromNow, dateStringFromNow, dateUntilNow, decToBigNumber, delegatorCooldownToDays, ensLookup, ensLookups, formatDayHourMin, formatDays, formatDuration, formatHourMin, formatNameHash, formatUnits, formatUnitsToNumber, formatWithNumeral, generateExampleQuery, getContract, getDate, getERC20Balance, getEventInterface, getEventTypeFromTypename, getTxLink, nSignalToTokens, nSignalToVSignal, overrides, purchaseTargetAmount, saleTargetAmount, signalToTokens, toGRT, toWei, tokensToNSignal, tokensToSignal, unixDateFromNow, vSignalToNSignal }; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -77,2 +77,10 @@ 'use strict'; | ||
var erc20Abi = [ | ||
'function balanceOf(address owner) view returns (uint256)', | ||
'function decimals() view returns (uint8)', | ||
'function symbol() view returns (string)', | ||
'function transfer(address to, uint amount) returns (bool)', | ||
'event Transfer(address indexed from, address indexed to, uint amount)' | ||
]; | ||
/** | ||
@@ -220,2 +228,13 @@ * Get provider | ||
}; | ||
/** | ||
* Get ERC20 balance of a wallet | ||
* @param walletAddress Address of interest | ||
* @param tokenAddress Address of ERC20 | ||
* @param provider Web3 provider | ||
* @returns Balance of ERC20 in provided wallet | ||
*/ | ||
const getERC20Balance = async (walletAddress, tokenAddress, provider) => { | ||
const contract = new ethers.Contract(tokenAddress, erc20Abi, provider); | ||
return contract.balanceOf(walletAddress); | ||
}; | ||
@@ -858,2 +877,3 @@ Object.assign(numeral__default['default'].localeData('en'), { | ||
exports.getDate = getDate; | ||
exports.getERC20Balance = getERC20Balance; | ||
exports.getEventInterface = getEventInterface; | ||
@@ -860,0 +880,0 @@ exports.getEventTypeFromTypename = getEventTypeFromTypename; |
@@ -68,1 +68,9 @@ import DataLoader from 'dataloader'; | ||
}>; | ||
/** | ||
* Get ERC20 balance of a wallet | ||
* @param walletAddress Address of interest | ||
* @param tokenAddress Address of ERC20 | ||
* @param provider Web3 provider | ||
* @returns Balance of ERC20 in provided wallet | ||
*/ | ||
export declare const getERC20Balance: (walletAddress: string, tokenAddress: string, provider: providers.BaseProvider | Signer) => Promise<BigNumber>; |
{ | ||
"name": "@edgeandnode/common", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Common Edge & Node utils and types", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
240438
55
2881