Skip to content

Commit 308c857

Browse files
authored
Merge pull request #5 from kleros/feat/curate-integration-no-badges
T2CR migration to Curate
2 parents fe9c82b + 32bc998 commit 308c857

File tree

19 files changed

+2023
-9891
lines changed

19 files changed

+2023
-9891
lines changed

.env.example

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
1-
T2CR_GRAPH_URL=https://api.thegraph.com/subgraphs/name/kleros/t2cr
2-
3-
T2CR_ADDRESS=0xebcf3bca271b26ae4b162ba560e243055af0e679
4-
TOKEN_DECIMALS_TCR_ADDRESS=0x8eFfF9BB64ED3d766a26a18e873cf171E67BeCf2
5-
6-
ERC20_BADGE_ADDRESS=0xcb4aae35333193232421e86cd2e9b6c91f3b125f
7-
STABLECOIN_BADGE_ADDRESS=0xbc65204861f5776564fc3f61c04ec6ea8bea13be
8-
TRUECRYPTOSYSTEM_BADGE_ADDRESS=0xe0cf18e8630545aa553f88079c75dae56b8fb304
9-
DUTCHX_BADGE_ADDRESS=0x6e06861cefc3d6ea24483d3f1fe80759a73524b4
10-
11-
TOKEN_DECIMALS_VIEW_ADDRESS=0x5918705f9a172d5caabbd2e2ddb5086ae033dfe8
12-
GTCR_VIEW_ADDRESS=0xe75a12f40da77d285c08a44f499e597bc5085658
1+
CURATE_GRAPH_URL=https://api.thegraph.com/subgraphs/name/greenlucid/legacy-curate-xdai
2+
KLEROS_TOKENS_REGISTRY_ADDRESS=0xee1502e29795ef6c2d60f8d7120596abe3bad990
133

144
ENS_CONTRACT=0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e
155
ENS_TOKEN_LIST_NAME=t2crtokens.eth
16-
ENS_NFT_LIST_NAME=t2crnfts.eth
176

18-
LATEST_TOKEN_LIST_URL=https://t2crtokens.eth.link
19-
LATEST_NFT_LIST_URL=https://t2crnfts.eth.link
7+
LATEST_TOKEN_LIST_URL=https://t2crtokens.eth.limo
208

219
PROVIDER_URL=https://mainnet.infura.io/v3/<api-key>
2210
IPFS_GATEWAY=https://ipfs.kleros.io
2311
WALLET_KEY=
2412

2513
# Optional. If not provided, 300 seconds (5 minutes will be used).
26-
POLL_PERIOD_SECONDS=
27-
28-
# Optional. If provided will also pin content on pinata.cloud.
29-
PINATA_API_KEY=
30-
PINATA_SECRET_API_KEY=
14+
POLL_PERIOD_SECONDS=300

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
dist
2+
build

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
node_modules
2-
dist
2+
build
33
yarn-error.log
44
.env
55
.vscode
66
!.gitkeep
7-
images
7+
images
8+
db

images/.gitkeep

Whitespace-only changes.

package.json

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,15 @@
11
{
22
"name": "t2cr-to-ipfs",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Pulls token information from the kleros t2cr and publishes them to ipfs following uniswap/token-lists schema.",
55
"main": "src/index.ts",
66
"repository": "git+https://github.com/kleros/t2cr-to-ipfs",
77
"author": "Kleros",
88
"license": "MIT",
99
"private": false,
1010
"scripts": {
11-
"start": "ts-node --files src/index.ts",
12-
"dev": "ts-node-dev --inspect=4321 --respawn --transpile-only src/index.ts",
13-
"lint:secrets": "secretlint \"**/*\"",
14-
"lint:fix": "eslint 'src/**/*.{js,ts}' --fix && tsc --noEmit && npm run lint:secrets",
15-
"release": "standard-version",
16-
"test": "jest"
17-
},
18-
"jest": {
19-
"transform": {
20-
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
21-
},
22-
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
23-
"moduleFileExtensions": [
24-
"ts",
25-
"tsx",
26-
"js"
27-
]
28-
},
29-
"commitlint": {
30-
"extends": [
31-
"@commitlint/config-conventional"
32-
]
33-
},
34-
"husky": {
35-
"hooks": {
36-
"pre-commit": "npm run lint:fix",
37-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
38-
}
11+
"start": "node ./build/index.js",
12+
"build": "rm -rf ./build && tsc"
3913
},
4014
"devDependencies": {
4115
"@commitlint/cli": "^9.0.1",
@@ -45,43 +19,29 @@
4519
"@types/jest": "^26.0.4",
4620
"@typescript-eslint/eslint-plugin": "^3.6.0",
4721
"@typescript-eslint/parser": "^3.6.0",
48-
"concurrently": "^5.2.0",
22+
"@types/level": "^6.0.2",
23+
"@types/lodash": "^4.14.157",
24+
"@types/node": "^14.0.23",
25+
"@types/node-fetch": "^2.5.7",
26+
"@types/sharp": "^0.28.0",
4927
"eslint": "^7.4.0",
5028
"eslint-config-prettier": "^6.11.0",
5129
"eslint-plugin-prettier": "^3.1.4",
52-
"husky": "^4.2.5",
53-
"jest": "^26.1.0",
54-
"nodemon": "^2.0.4",
5530
"prettier": "^2.0.5",
56-
"rimraf": "^3.0.2",
5731
"secretlint": "^2.1.0",
58-
"standard-version": "^8.0.1",
59-
"ts-jest": "^26.1.2",
60-
"ts-node": "^9.1.1",
61-
"ts-node-dev": "^1.1.1",
6232
"typescript": "^3.9.6"
6333
},
6434
"dependencies": {
65-
"@0xsequence/collectible-lists": "^1.1.0",
66-
"@ensdomains/resolver": "^0.2.4",
67-
"@kleros/gtcr-sdk": "^1.8.0",
68-
"@pinata/sdk": "^1.1.10",
69-
"@types/lodash": "^4.14.157",
70-
"@types/node": "^14.0.23",
71-
"@types/node-fetch": "^2.5.7",
72-
"@types/sharp": "^0.25.0",
73-
"@uniswap/token-lists": "^1.0.0-beta.17",
35+
"@ensdomains/ens-contracts": "^0.0.22",
36+
"@uniswap/token-lists": "^1.0.0-beta.33",
7437
"ajv": "^6.12.3",
7538
"content-hash": "^2.5.2",
7639
"dotenv-safe": "^8.2.0",
7740
"eth-ens-namehash": "^2.0.8",
7841
"ethers": "^5.0.26",
79-
"ipfs-only-hash": "^2.0.1",
42+
"level": "^8.0.0",
8043
"lodash": "^4.17.19",
8144
"node-fetch": "^2.6.0",
82-
"sharp": "^0.25.4"
83-
},
84-
"volta": {
85-
"node": "10.23.2"
45+
"sharp": "^0.32.6"
8646
}
8747
}

script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export NVM_DIR="/home/ubuntu/.nvm"
99

1010
# uncomment the line below if you need a specific version of node
1111
# other than the one specified as `default` alias in NVM (optional)
12-
# nvm use 4 1> /dev/null
12+
nvm use 14 1> /dev/null
1313

1414
echo "Using nvm version $(nvm --version)"
1515
echo "Using node version $(node --version)"

src/erc20.ts

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import namehash from 'eth-ens-namehash'
66
import { encode } from 'content-hash'
77
import fetch from 'node-fetch'
88
import { TextEncoder } from 'util'
9-
import { abi as resolverABI } from '@ensdomains/resolver/build/contracts/Resolver.json'
9+
import resolverABI from '@ensdomains/ens-contracts/build/contracts/Resolver.json'
1010

1111
import { ipfsPublish } from './utils'
1212
import { getNewErc20ListVersion } from './versioning'
1313

1414
const ajv = new Ajv({
1515
allErrors: true,
16-
format: 'full',
1716
$data: true,
1817
verbose: true,
1918
})
@@ -22,8 +21,6 @@ const validator = ajv.compile(schema)
2221

2322
export default async function checkPublishErc20(
2423
latestTokens: TokenInfo[],
25-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
26-
pinata: any,
2724
provider: ethers.providers.JsonRpcProvider,
2825
listURL = '',
2926
ensListName = '',
@@ -55,10 +52,12 @@ export default async function checkPublishErc20(
5552

5653
// Invalid names or tickers should not prevent a new list from being published.
5754
const nameRe = new RegExp(
58-
schema.definitions.TokenInfo.properties.name.pattern,
55+
//schema.definitions.TokenInfo.properties.name.pattern,
56+
"^[ \\w.'+\\-%/À-ÖØ-öø-ÿ:&\\[\\]\\(\\)]+$",
5957
)
6058
const tickerRe = new RegExp(
61-
schema.definitions.TokenInfo.properties.symbol.pattern,
59+
//schema.definitions.TokenInfo.properties.symbol.pattern,
60+
'^[a-zA-Z0-9+\\-%/$.]+$',
6261
)
6362
const invalidTokens: TokenInfo[] = []
6463
const validatedTokens = latestTokens
@@ -82,6 +81,12 @@ export default async function checkPublishErc20(
8281
invalidTokens.push(t)
8382
return false
8483
}
84+
if (t.symbol.length > 20) {
85+
console.warn(` ${t.symbol} longer than 20 chars, dropping it.`)
86+
console.warn(` Address: ${t.address}`)
87+
invalidTokens.push(t)
88+
return false
89+
}
8590
return true
8691
})
8792

@@ -110,24 +115,6 @@ export default async function checkPublishErc20(
110115
keywords: ['t2cr', 'kleros', 'list'],
111116
timestamp,
112117
version,
113-
tags: {
114-
erc20: {
115-
name: 'ERC20',
116-
description: `This token is verified to be ERC20 thus there should not be incompatibility issues with the Uniswap protocol.`,
117-
},
118-
stablecoin: {
119-
name: 'Stablecoin',
120-
description: `This token is verified to maintain peg against a target.`,
121-
},
122-
trueCrypto: {
123-
name: 'TrueCrypto',
124-
description: `TrueCryptosystem verifies the token is a necessary element of a self sustaining public utility.`,
125-
},
126-
dutchX: {
127-
name: 'DutchX',
128-
description: `This token is verified to comply with the DutchX exchange listing criteria.`,
129-
},
130-
},
131118
tokens: validatedTokens,
132119
}
133120

@@ -146,12 +133,6 @@ export default async function checkPublishErc20(
146133
const contentHash = ipfsResponse[0].hash
147134
console.info(`Done. ${process.env.IPFS_GATEWAY}/ipfs/${contentHash}`)
148135

149-
if (pinata) {
150-
console.info('Pinning list in pinata.cloud...')
151-
await pinata.pinByHash(contentHash)
152-
console.info('Done.')
153-
}
154-
155136
// As of v5.0.5, Ethers ENS API doesn't include managing ENS names, so we
156137
// can't use it directly. Neither does the ethjs API.
157138
// Web3js supports it via web3.eth.ens but it can't sign transactions

0 commit comments

Comments
 (0)