diff --git a/.github/stale.yml b/.github/stale.yml index f4a1843af..ef45d6b62 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -4,11 +4,9 @@ daysUntilStale: 1 daysUntilClose: 2 # Issues with these labels will never be considered stale exemptLabels: + - 'Payment: Paid' - pinned - security - - paid -# Label to use when marking an issue as stale -staleLabel: wontfix # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 000000000..d571441e8 --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,21 @@ +name: Danger + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + danger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install gems + run: sudo gem install bundler --no-document + - name: Bundle update + run: bundle update --bundler + - name: Run Danger + run: danger --verbose + env: + GITHUB_TOKEN: ${{ secrets.DANGER_TOKEN }} diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 000000000..39d7064bd --- /dev/null +++ b/Dangerfile @@ -0,0 +1,109 @@ +require 'find' +require 'image_size' +require 'json-schema' + +assets_folder = './blockchains' +allowed_extensions = ['png', 'json'] +allowed_file_names = ['info', 'list', 'logo', 'whitelist', 'blacklist'] + +# Failures +# Do not allow files in this directory +Dir.foreach(assets_folder) \ + .map { |x| File.expand_path("#{assets_folder}/#{x}") } \ + .select { |x| File.file?(x) } + .map { |x| + fail("Not allowed to have files inside blockchains folder itself. You have to add them inside specific blockchain folder as blockchain/ethereum or blockchain/binance for file: " + x) +} + +Find.find(assets_folder) do |file| + file_extension = File.extname(file).delete('.') + file_name = File.basename(file, File.extname(file)) + + # Skip if directory + if File.directory?(file) + next + end + + if !allowed_extensions.include? file_extension + fail("Extension not allowed for file: " + file) + end + + if !allowed_file_names.include? file_name + fail("Filename not allowed for file: " + file) + end + + # Validate JSON content + if file_extension == 'json' + value = nil + begin + value = JSON.parse(File.open(file).read) + rescue JSON::ParserError, TypeError => e + fail("Wrong JSON content in file: " + file) + end + + # Validate info.json + if file_name == 'info' + schema = { + "type": "object", + "required": ["name", "website", "short_description", "explorer"], + "properties": { + "name": {"type": "string"}, + "website": {"type": "string"}, + "short_description": {"type": "string"}, + "explorer": {"type": "string"} + } + } + errors = JSON::Validator.fully_validate(schema, value) + errors.each { |error| message("#{error} in file #{file}") } + end + + # Validate list.json for validators + if file_name == 'list' + schema = { + "type": "array", + "items": { + "properties": { + "id": { "type": "string" }, + "name": { "type": "string" }, + "description": { "type": "string" }, + "website": { "type": "string" } + }, + "required": ["id", "name", "description", "website"] + } + } + errors = JSON::Validator.fully_validate(schema, value) + errors.each { |error| message("#{error} in file #{file}") } + end + + # Validate whitelist, blacklist files + if file_name == 'whitelist' || file_name == 'blacklist' + schema = { + "type": "array", + "items": { + "type": "string" + } + } + errors = JSON::Validator.fully_validate(schema, value) + errors.each { |error| message("#{error} in file #{file}") } + end + + end + + # Validate images + if file_extension == 'png' + image_size = ImageSize.path(file) + + if image_size.width > 512 || image_size.height > 512 + fail("Image width or height is higher than 512px for file: " + file) + end + + if image_size.format == 'png' + fail("Image should be PNG for file: " + file) + end + + # Make sure file size only 100kb + if File.size(file).to_f / 1024 > 100 + fail("Image should less than 100kb for file: " + file) + end + end +end \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..814ec895f --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem 'danger' +gem 'image_size', '~> 2.0' +gem 'json-schema' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..d44e33fed --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,64 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + claide (1.0.3) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) + colored2 (3.1.2) + cork (0.3.0) + colored2 (~> 3.1) + danger (6.3.2) + claide (~> 1.0) + claide-plugins (>= 0.9.2) + colored2 (~> 3.1) + cork (~> 0.1) + faraday (~> 0.9) + faraday-http-cache (~> 2.0) + git (~> 1.6) + kramdown (~> 2.0) + kramdown-parser-gfm (~> 1.0) + no_proxy_fix + octokit (~> 4.7) + terminal-table (~> 1) + faraday (0.17.3) + multipart-post (>= 1.2, < 3) + faraday-http-cache (2.1.0) + faraday (~> 0.8) + git (1.6.0) + rchardet (~> 1.8) + image_size (2.0.2) + json-schema (2.8.1) + addressable (>= 2.4) + kramdown (2.1.0) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + multipart-post (2.1.1) + nap (1.1.0) + no_proxy_fix (0.1.2) + octokit (4.18.0) + faraday (>= 0.9) + sawyer (~> 0.8.0, >= 0.5.3) + open4 (1.3.4) + public_suffix (4.0.4) + rchardet (1.8.0) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + unicode-display_width (1.7.0) + +PLATFORMS + ruby + +DEPENDENCIES + danger + image_size (~> 2.0) + json-schema + +BUNDLED WITH + 1.17.2 diff --git a/blockchains/ethereum/assets/0x3453769b660b7EE4261AaA043479Aa3CA02243bf/logo.png b/blockchains/ethereum/assets/0x3453769b660b7EE4261AaA043479Aa3CA02243bf/logo.png index 742f6fa99..af1c52c38 100644 Binary files a/blockchains/ethereum/assets/0x3453769b660b7EE4261AaA043479Aa3CA02243bf/logo.png and b/blockchains/ethereum/assets/0x3453769b660b7EE4261AaA043479Aa3CA02243bf/logo.png differ diff --git a/blockchains/ethereum/assets/0xAdae61eaAb45Ac109C068E18e723d5F0436bEea1/logo.png b/blockchains/ethereum/assets/0xAdae61eaAb45Ac109C068E18e723d5F0436bEea1/logo.png index f3704aa3e..abd39b752 100644 Binary files a/blockchains/ethereum/assets/0xAdae61eaAb45Ac109C068E18e723d5F0436bEea1/logo.png and b/blockchains/ethereum/assets/0xAdae61eaAb45Ac109C068E18e723d5F0436bEea1/logo.png differ diff --git a/blockchains/ethereum/assets/0xbE8F047Fc2EB324911e8eF9040f175984DC2DC18/logo.png b/blockchains/ethereum/assets/0xbE8F047Fc2EB324911e8eF9040f175984DC2DC18/logo.png index 2d6afe2e4..65263e04d 100644 Binary files a/blockchains/ethereum/assets/0xbE8F047Fc2EB324911e8eF9040f175984DC2DC18/logo.png and b/blockchains/ethereum/assets/0xbE8F047Fc2EB324911e8eF9040f175984DC2DC18/logo.png differ diff --git a/blockchains/ethereum/assets/0xfA654D0702ffdAE6FE30272639c83eC4Cbfe6D7d/logo.png b/blockchains/ethereum/assets/0xfA654D0702ffdAE6FE30272639c83eC4Cbfe6D7d/logo.png index 6580a0fec..2af43844a 100644 Binary files a/blockchains/ethereum/assets/0xfA654D0702ffdAE6FE30272639c83eC4Cbfe6D7d/logo.png and b/blockchains/ethereum/assets/0xfA654D0702ffdAE6FE30272639c83eC4Cbfe6D7d/logo.png differ diff --git a/blockchains/tezos/validators/assets/tz1Vyuu4EJ5Nym4JcrfRLnp3hpaq1DSEp1Ke/Logo.png b/blockchains/tezos/validators/assets/tz1Vyuu4EJ5Nym4JcrfRLnp3hpaq1DSEp1Ke/Logo.png deleted file mode 100644 index 139ca9d1b..000000000 Binary files a/blockchains/tezos/validators/assets/tz1Vyuu4EJ5Nym4JcrfRLnp3hpaq1DSEp1Ke/Logo.png and /dev/null differ diff --git a/blockchains/tron/assets/TFPAuuQym78giRve6iHTf4y7dZJxAkkrUa/info.json b/blockchains/tron/assets/TFPAuuQym78giRve6iHTf4y7dZJxAkkrUa/info.json index 7d56e2b44..02a9f05af 100644 --- a/blockchains/tron/assets/TFPAuuQym78giRve6iHTf4y7dZJxAkkrUa/info.json +++ b/blockchains/tron/assets/TFPAuuQym78giRve6iHTf4y7dZJxAkkrUa/info.json @@ -10,5 +10,6 @@ "url":"https://twitter.com/streamixio", "handle":"Streamixio" } - ] + ], + "explorer": "https://tronscan.org/#/token20/TFPAuuQym78giRve6iHTf4y7dZJxAkkrUa" } diff --git a/src/test/helpers.ts b/src/test/helpers.ts index dca71defc..92ecb0777 100644 --- a/src/test/helpers.ts +++ b/src/test/helpers.ts @@ -260,7 +260,10 @@ export const rootDirAllowedFiles = [ "package.json", "README.md", ".git", - "pricing" + "pricing", + "Dangerfile", + "Gemfile", + "Gemfile.lock" ] export const assetFolderAllowedFiles = [