@edgeandnode/common
Advanced tools
Comparing version 1.0.2 to 1.0.3-alpha
export { generateExampleQuery, connectProvider, getContract, getTxLink, formatUnitsOriginal, formatWithNumeral } from './utils'; |
@@ -1,7 +0,17 @@ | ||
import gql from 'graphql-tag'; | ||
import { parse, print } from 'graphql'; | ||
import pluralize from 'pluralize'; | ||
import { ethers, utils } from 'ethers'; | ||
import numeral from 'numeral'; | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var gql = require('graphql-tag'); | ||
var graphql = require('graphql'); | ||
var pluralize = require('pluralize'); | ||
var ethers = require('ethers'); | ||
var numeral = require('numeral'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var gql__default = /*#__PURE__*/_interopDefaultLegacy(gql); | ||
var pluralize__default = /*#__PURE__*/_interopDefaultLegacy(pluralize); | ||
var numeral__default = /*#__PURE__*/_interopDefaultLegacy(numeral); | ||
// Example query for a subgraph, generated from its schema | ||
@@ -32,3 +42,3 @@ const pickExampleTypes = (definitions) => { | ||
// Generate collection query field | ||
let rootField = pluralize.plural(typeDef.name.value); | ||
let rootField = pluralize__default['default'].plural(typeDef.name.value); | ||
if (rootField === typeDef.name.value) { | ||
@@ -42,3 +52,3 @@ return null; | ||
try { | ||
const doc = parse(schema); | ||
const doc = graphql.parse(schema); | ||
const typeDefs = pickExampleTypes(doc.definitions); | ||
@@ -48,3 +58,3 @@ const typeQueries = typeDefs | ||
.filter((query) => query !== null); | ||
const query = gql ` | ||
const query = gql__default['default'] ` | ||
{ | ||
@@ -54,3 +64,3 @@ ${typeQueries.join('\n')} | ||
`; | ||
return print(query); | ||
return graphql.print(query); | ||
} | ||
@@ -66,3 +76,3 @@ catch (e) { | ||
try { | ||
const provider = new ethers.providers.StaticJsonRpcProvider(rpcEndpoint); | ||
const provider = new ethers.ethers.providers.StaticJsonRpcProvider(rpcEndpoint); | ||
providerWithSigner = provider.getSigner(ethAddress); | ||
@@ -79,3 +89,3 @@ } | ||
try { | ||
contract = new ethers.Contract(contractAddress, contractABI, providerOrSigner); | ||
contract = new ethers.ethers.Contract(contractAddress, contractABI, providerOrSigner); | ||
} | ||
@@ -88,3 +98,3 @@ catch (e) { | ||
}; | ||
const formatUnitsOriginal = (num, power) => power ? utils.formatUnits(num, power) : utils.formatUnits(num, 18); | ||
const formatUnitsOriginal = (num, power) => power ? ethers.utils.formatUnits(num, power) : ethers.utils.formatUnits(num, 18); | ||
const getTxLink = (transactionId, networkName) => { | ||
@@ -109,18 +119,2 @@ let txLink = ''; | ||
? '~ 0' | ||
: numeral(num).format(format ? format : '0.0a'); | ||
return result; | ||
}; | ||
export { connectProvider, formatUnitsOriginal, formatWithNumeral, generateExampleQuery, getContract, getTxLink }; | ||
//# sourceMappingURL=index.js.map | ||
`https://${networkName}.etherscan.io/tx/${transactionId}`; | ||
} | ||
return txLink; | ||
}; | ||
const formatWithNumeral = (num, format) => { | ||
const result = num === 0 || num === '0' | ||
? '0' | ||
: num > 0 && num < 0.5 | ||
? '~ 0' | ||
: numeral__default['default'](num).format(format ? format : '0.0a'); | ||
@@ -127,0 +121,0 @@ return result; |
@@ -0,0 +0,0 @@ import { ethers, ContractInterface } from 'ethers'; |
export {}; |
export declare const formatWithNumeral: (num: number | string, format?: string) => string; |
export {}; |
@@ -0,0 +0,0 @@ import { DefinitionNode, ObjectTypeDefinitionNode, FieldDefinitionNode, TypeNode, DocumentNode } from 'graphql'; |
export {}; |
export * from './graphql.utils'; | ||
export * from './ethers.utils'; | ||
export * from './formatters.utils'; |
{ | ||
"name": "@edgeandnode/common", | ||
"version": "1.0.2", | ||
"version": "1.0.3-alpha", | ||
"description": "Common Edge & Node utils and types", | ||
@@ -37,2 +37,3 @@ "main": "build/index.js", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^19.0.0", | ||
"@rollup/plugin-eslint": "^8.0.1", | ||
@@ -55,2 +56,3 @@ "@rollup/plugin-json": "^4.1.0", | ||
"rollup": "^2.51.2", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"ts-jest": "^27.0.3", | ||
@@ -57,0 +59,0 @@ "typescript": "^4.3.2" |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
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
30985
14
238
0
21
2