diff --git a/package-lock.json b/package-lock.json index 8aaa3b4c7..cd90395c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2154,12 +2154,6 @@ "web3": "1.2.1" } }, - "@typechain/web3-v1": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@typechain/web3-v1/-/web3-v1-1.0.0.tgz", - "integrity": "sha512-MM8PmsblePaxy5BCYEuPtR4ajigPf504VRQzZgFYqs6KuFnJxbOjF8jNYT12P6UvUX7us75Wc78QdbvOHbb4hA==", - "dev": true - }, "@types/bn.js": { "version": "4.11.6", "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", @@ -31209,10 +31203,10 @@ } } }, - "typechain-target-ethers-v5": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/typechain-target-ethers-v5/-/typechain-target-ethers-v5-1.2.0.tgz", - "integrity": "sha512-ujrMxrf0trvPEGF502TrFvNppkNBzR2zTfc7CgnVpbjrA+10DR0uKCIlzYjVoIDK6/EOJtSyz7kJ5+O1C5DAFQ==", + "typechain-target-abarmat-ethers-v5": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typechain-target-abarmat-ethers-v5/-/typechain-target-abarmat-ethers-v5-1.0.0.tgz", + "integrity": "sha512-FZq4oimQCJrOqaPI5/+gxf7RJEG+zyvRpi4mKFdGjTcOhovFKbA10LXVrnUOa0bLvkEn3mcHCLMV1zo4dA8Rqw==", "dev": true, "requires": { "ethers": "^5.0.2" diff --git a/package.json b/package.json index 06bcc86d6..7e63de59b 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "@nomiclabs/buidler-ethers": "^2.0.0-alpha.1", "@nomiclabs/buidler-waffle": "^2.0.0-alpha.1", "@openzeppelin/contracts": "3.0.1", - "@typechain/web3-v1": "^1.0.0", "@types/bs58": "^4.0.1", "@types/dotenv": "^8.2.0", "@types/minimist": "^1.2.0", @@ -50,7 +49,7 @@ "ts-generator": "0.0.8", "ts-node": "^8.10.1", "typechain": "^2.0.0", - "typechain-target-ethers-v5": "^1.2.0", + "typechain-target-abarmat-ethers-v5": "^1.0.0", "typescript": "^3.9.3", "yaml": "^1.10.0", "yargs": "^15.3.1" @@ -58,7 +57,7 @@ "scripts": { "prepublishOnly": "npm run build && rm -rf dist && cp -R build dist", "build": "npm run compile && npm run flatten && npm run abi:extract && npm run typechain", - "clean": "rm -rf build/ cache/", + "clean": "rm -rf build/ cache/ dist/", "compile": "buidler compile", "deploy": "npm run migrate", "deploy-kovan": "npm run migrate -- --force --network kovan", @@ -77,7 +76,7 @@ "prettier:sol": "prettier --write 'contracts/*.sol'", "flatten": "scripts/flatten.sh", "abi:extract": "truffle-abi -d ./build/contracts -o ./build/abis/ -v", - "typechain": "typechain --target ethers-v5 --outDir build/typechain/contracts 'build/abis/*.json'" + "typechain": "typechain --target abarmat-ethers-v5 --outDir build/typechain/contracts 'build/abis/*.json'" }, "lint-staged": { "contracts/*.sol": [ diff --git a/scripts/data/metadata.json b/scripts/data/metadata.json deleted file mode 100644 index a281c2da7..000000000 --- a/scripts/data/metadata.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "displayName": "Good graph developer", - "image": "none", - "description": "Wow this is long", - "codeRepository": "github.com/davekaj", - "websiteURL": "thegraph.com" -} diff --git a/scripts/ens.ts b/scripts/ens.ts index e83f66fa0..3aada98db 100755 --- a/scripts/ens.ts +++ b/scripts/ens.ts @@ -10,15 +10,15 @@ import { contracts, executeTransaction, overrides, checkFuncInputs } from './hel // Set up the script // /////////////////////// -const { func, name, node } = minimist.default(process.argv.slice(2), { - string: ['func', 'name', 'node'], +const { func, name } = minimist.default(process.argv.slice(2), { + string: ['func', 'name'], }) -if (!func) { +if (!func || !name) { console.error( ` Usage: ${path.basename(process.argv[1])} - --func - options: setRecord, setText, checkOwner + --func - options: registerName, setRecord, setText, checkOwner, nameHash Function arguments: setRecord @@ -58,28 +58,42 @@ Function arguments: // ) // } -const setTestRecord = async (labelName: string) => { - checkFuncInputs([labelName], ['labelName'], 'setTestRecord') - const node = utils.namehash('test') - const labelNameFull = `${labelName}.${'test'}` - const label = utils.keccak256(utils.toUtf8Bytes(labelName)) - console.log(label) +// Must normalize name to lower case to get script to work with ethers namehash +// This is because in setTestRecord() - label uses the normal keccak +// TODO - follow UTS46 in scripts https://docs.ens.domains/contract-api-reference/name-processing +const normalizedName = name.toLowerCase() + +const setTestRecord = async () => { + // const node = utils.namehash('test') + // console.log('Namehash node for "test": ', node) + const labelNameFull = `${normalizedName}.${'test'}` const labelHashFull = utils.namehash(labelNameFull) - const signerAddress = await contracts.ens.signer.getAddress() - const ensOverrides = overrides('ens', 'register') - console.log('Namehash node for "test": ', node) - console.log(`Hash of label ${labelName}: `, label) console.log(`Namehash for ${labelNameFull}: ${labelHashFull}`) + const signerAddress = await contracts.ens.signer.getAddress() + const ensOverrides = overrides('ens', 'register') + const label = utils.keccak256(utils.toUtf8Bytes(normalizedName)) + // console.log(`Hash of label being registered on ens ${name}: `, label) await executeTransaction(contracts.testRegistrar.register(label, signerAddress, ensOverrides)) } const setText = async () => { - checkFuncInputs([node], ['node'], 'setText') + const labelNameFull = `${normalizedName}.${'test'}` + const labelHashFull = utils.namehash(labelNameFull) + console.log(`Setting text name: ${labelNameFull} with node: ${labelHashFull}`) + const key = 'GRAPH NAME SERVICE' const ensOverrides = overrides('ens', 'setText') const signerAddress = await contracts.publicResolver.signer.getAddress() - await executeTransaction(contracts.publicResolver.setText(node, key, signerAddress, ensOverrides)) + await executeTransaction( + contracts.publicResolver.setText(labelHashFull, key, signerAddress, ensOverrides), + ) +} + +// does everything in one func call +const registerName = async () => { + await setTestRecord() + await setText() } const checkOwner = async () => { @@ -100,15 +114,15 @@ const checkOwner = async () => { const main = async () => { try { - if (func == 'setTestRecord') { + if (func == 'registerName') { + console.log(`Registering ownership and text record for ${name} ...`) + registerName() + } else if (func == 'setTestRecord') { console.log(`Setting owner for ${name} ...`) - setTestRecord(name) + setTestRecord() } else if (func == 'setText') { console.log(`Setting text record of 'GRAPH NAME SERVICE' for caller ...`) setText() - // } else if (func == 'setEthDomain') { NOT IN USE - // console.log(`Setting '.eth' domain ...`) - // setSubnodeRecord('', 'eth') } else if (func == 'checkOwner') { console.log(`Checking owner of ${name} ...`) checkOwner() diff --git a/scripts/ethereumDIDRegistry.ts b/scripts/ethereumDIDRegistry.ts index 71769b745..9fcab9491 100755 --- a/scripts/ethereumDIDRegistry.ts +++ b/scripts/ethereumDIDRegistry.ts @@ -4,7 +4,7 @@ import * as path from 'path' import * as minimist from 'minimist' import * as fs from 'fs' -import { contracts, executeTransaction, overrides, IPFS, checkFuncInputs } from './helpers' +import { contracts, executeTransaction, overrides, IPFS } from './helpers' /////////////////////// // Set up the script // diff --git a/scripts/gns.ts b/scripts/gns.ts index f2c5516e1..20ec95eff 100755 --- a/scripts/gns.ts +++ b/scripts/gns.ts @@ -140,13 +140,24 @@ interface GNSMetadata { const handleMetadata = async (ipfs: string, path: string): Promise => { const metadata: GNSMetadata = JSON.parse(fs.readFileSync(__dirname + path).toString()) + if ( + !metadata.subgraphDescription || + !metadata.subgraphImage || + !metadata.subgraphCodeRepository || + !metadata.subgraphWebsite || + !metadata.versionDescription || + !metadata.versionLabel + ) { + console.log(`One or more fields for metadata are missing`) + process.exit(1) + } console.log('Meta data:') - console.log(' Subgraph Description: ', metadata.subgraphDescription || '') - console.log(' Subgraph Image: ', metadata.subgraphImage || '') - console.log(' Subgraph Code Repository: ', metadata.subgraphCodeRepository || '') - console.log(' Subgraph Website: ', metadata.subgraphWebsite || '') - console.log(' Version Description: ', metadata.versionDescription || '') - console.log(' Version Label: ', metadata.versionLabel || '') + console.log(' Subgraph Description: ', metadata.subgraphDescription) + console.log(' Subgraph Image: ', metadata.subgraphImage) + console.log(' Subgraph Code Repository: ', metadata.subgraphCodeRepository) + console.log(' Subgraph Website: ', metadata.subgraphWebsite) + console.log(' Version Description: ', metadata.versionDescription) + console.log(' Version Label: ', metadata.versionLabel) const ipfsClient = IPFS.createIpfsClient(ipfs) diff --git a/scripts/helpers.ts b/scripts/helpers.ts index 54dce2583..a9a945321 100644 --- a/scripts/helpers.ts +++ b/scripts/helpers.ts @@ -2,21 +2,19 @@ import * as fs from 'fs' import * as path from 'path' import * as dotenv from 'dotenv' -import { ContractTransaction, ethers, utils, Wallet } from 'ethers' -import { ContractReceipt } from 'ethers/contract' +import { ContractTransaction, ethers, utils, Wallet, ContractReceipt, Overrides } from 'ethers' import ipfsHttpClient from 'ipfs-http-client' import * as bs58 from 'bs58' -import { GnsFactory } from '../build/typechain/contracts/GnsFactory' -import { StakingFactory } from '../build/typechain/contracts/StakingFactory' -import { ServiceRegistryFactory } from '../build/typechain/contracts/ServiceRegistryFactory' -import { GraphTokenFactory } from '../build/typechain/contracts/GraphTokenFactory' -import { CurationFactory } from '../build/typechain/contracts/CurationFactory' -import { IensFactory } from '../build/typechain/contracts/IensFactory' -import { IPublicResolverFactory } from '../build/typechain/contracts/IPublicResolverFactory' -import { IEthereumDidRegistryFactory } from '../build/typechain/contracts/IEthereumDidRegistryFactory' -import { ITestRegistrarFactory } from '../build/typechain/contracts/ITestRegistrarFactory' -import { TransactionOverrides } from '../build/typechain/contracts' +import { GnsFactory } from '../build/typechain/contracts/GnsContract' +import { StakingFactory } from '../build/typechain/contracts/StakingContract' +import { ServiceRegistryFactory } from '../build/typechain/contracts/ServiceRegistryContract' +import { GraphTokenFactory } from '../build/typechain/contracts/GraphTokenContract' +import { CurationFactory } from '../build/typechain/contracts/CurationContract' +import { IensFactory } from '../build/typechain/contracts/IensContract' +import { IPublicResolverFactory } from '../build/typechain/contracts/IPublicResolverContract' +import { IEthereumDidRegistryFactory } from '../build/typechain/contracts/IEthereumDidRegistryContract' +import { ITestRegistrarFactory } from '../build/typechain/contracts/ITestRegistrarContract' dotenv.config() const addresses = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'addresses.json'), 'utf-8')) @@ -61,12 +59,7 @@ export const executeTransaction = async ( } } -type Overrides = { - address?: string - topics?: Array -} - -export const overrides = (contract: string, func: string): TransactionOverrides => { +export const overrides = (contract: string, func: string): Overrides => { const gasPrice = utils.parseUnits('25', 'gwei') const gasLimit = 1000000 // console.log(`\ntx gas price: '${gasPrice}'`); diff --git a/truffle.js b/truffle.js new file mode 100644 index 000000000..839b3dde1 --- /dev/null +++ b/truffle.js @@ -0,0 +1,14 @@ +// Needed for truffle flattener +module.exports = { + compilers: { + solc: { + version: '0.6.4', + settings: { + optimizer: { + enabled: true, + runs: 500, + }, + }, + }, + }, +}