Skip to content

Commit

Permalink
new project: UI and data
Browse files Browse the repository at this point in the history
  • Loading branch information
rueshyna committed Dec 21, 2023
1 parent 3b44eaa commit 4fc2e1a
Show file tree
Hide file tree
Showing 56 changed files with 6,262 additions and 2,579 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- master

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- run: |
find .
pwd
- name: Install dependencies
run: npm install
working-directory: ./chart

- name: Build
run: |
pwd
npm run build
working-directory: ./chart

- name: Deploy
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: ./chart/build
CLEAN: true

9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
*/node_modules
*/.pnp
.pnp.js
*/tmp

# testing
/coverage
*/coverage

# production
/build
*/build

# misc
.DS_Store
Expand Down
204 changes: 204 additions & 0 deletions data/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions data/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "analysis",
"type": "module",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node-fetch": "^2.6.9",
"typescript": "^5.3.3"
},
"dependencies": {
"node-fetch": "^3.3.2"
}
}
19 changes: 19 additions & 0 deletions data/src/context/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const DEFAULT_RPC = "https://tezos.marigold.dev";
export const TZKT_API = "https://api.tzkt.io/v1";
export const OUTPUT_PATH = "../chart/src/data"
export const TEMP_FOLDER_PATH = "../tmp"
export const OVERWRITE = true;

export const VERSIONS : Record<string, string> = {
"471411811": "0.0.6",
"-1526481454": "0.0.8",
"735333822": "0.0.9",
"2102290129": "0.0.10",
"521053333": "0.0.11",
"793087855": "0.0.11b",
"-426350137": "0.1.1",
"1358594366": "0.3.0",
"46756700": "0.3.1",
"-1892417854": "0.3.2",
"1866000220": "0.3.3",
};
37 changes: 37 additions & 0 deletions data/src/fetchContract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { TEMP_FOLDER_PATH, TZKT_API, VERSIONS } from './context/config';
import { fetchWithRetry } from './util';
import * as fs from 'fs';
import * as path from 'path';

const allVersion = () => Object.keys(VERSIONS).join(",");
const tempFolderPath = path.join(TEMP_FOLDER_PATH, 'contracts');

const fetchContracts = async () => {
if (!fs.existsSync(tempFolderPath)) {
fs.mkdirSync(tempFolderPath, { recursive: true });
}

let offset = 0;
let shouldContinue = false;
const limit = 100;

do {
const query = `${TZKT_API}/contracts?codeHash.in=${allVersion()}&limit=${limit}&offset=${offset}&sort.desc=lastActivity&includeStorage=true`;
const result = await fetchWithRetry(query);

if (result && result.length > 0) {
const filePath = path.join(tempFolderPath, `contracts_${offset}.json`);
fs.writeFileSync(filePath, JSON.stringify(result, null, 2));
console.log(`Data written to ${filePath}`);

shouldContinue = result.length === limit;
offset += 1;
} else {
shouldContinue = false;
}
} while (shouldContinue);
};

fetchContracts().catch(console.error);
console.log('Finish fetching all contracts');

Loading

0 comments on commit 4fc2e1a

Please sign in to comment.