Skip to content

Commit

Permalink
add script.sh and file systems
Browse files Browse the repository at this point in the history
  • Loading branch information
virjilakrum committed Jun 15, 2024
1 parent c58fa89 commit 67d92b8
Show file tree
Hide file tree
Showing 19,620 changed files with 2,885,027 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
33 changes: 33 additions & 0 deletions .github/workflows/build_and_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Lint (frontend)

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm frontend:build
- run: pnpm frontend:lint
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
Move.lock
Suibase.toml
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recommendations": [
// Backend
"mysten.move",
"damirka.move-syntax",
"tamasfe.even-better-toml",

// Frontend
"esbenp.prettier-vscode"
]
}
7 changes: 7 additions & 0 deletions HelloWorld.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module zk_lokomotive::HelloWorld {
use sui::tx_context::TxContext;

public entry fun hello(ctx: &mut TxContext) {
sui::debug::print("Hello, World!");
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Konstantin Komelin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "zk-lokomotive"
edition = "2024.beta"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/devnet" }

[addresses]
greeting = "0x0"

[dev-dependencies]
Local = { local = "../path/to/dev-build" }

[dev-addresses]
alice = "0xB0B"
3 changes: 3 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sui dApp Starter: Backend

Please find the root project [README](../../README.md).
17 changes: 17 additions & 0 deletions backend/node_modules/.bin/sui-explorer-local

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

1 change: 1 addition & 0 deletions backend/node_modules/env-file-rw

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

1 change: 1 addition & 0 deletions backend/node_modules/sui-explorer-local

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

47 changes: 47 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "backend",
"private": true,
"version": "0.0.0",
"scripts": {
"build": "lsui move build -d -p ./move/greeting",
"test": "lsui move test -d -p ./move/greeting",
"copy-package-id": "node ./scripts/copy-package-id",
"localnet:start": "localnet start",
"localnet:stop": "localnet stop",
"localnet:status": "localnet status",
"localnet:faucet": "localnet faucet",
"localnet:regen": "localnet regen",
"localnet:update": "localnet update",
"localnet:address": "lsui client active-address",
"localnet:deploy": "localnet publish --path ${PWD}/move/greeting && pnpm copy-package-id -n localnet",
"localnet:explorer:start": "sui-explorer-local start",
"localnet:explorer:stop": "sui-explorer-local stop",
"localnet:explorer:restart": "sui-explorer-local restart",
"localnet:explorer:rebuild": "sui-explorer-local rebuild",
"devnet:start": "devnet start",
"devnet:stop": "devnet stop",
"devnet:status": "devnet status",
"devnet:update": "devnet update",
"devnet:links": "devnet links",
"devnet:address": "dsui client active-address",
"devnet:deploy": "devnet publish --path ${PWD}/move/greeting && pnpm copy-package-id -n devnet",
"testnet:start": "testnet start",
"testnet:stop": "testnet stop",
"testnet:status": "testnet status",
"testnet:update": "testnet update",
"testnet:links": "testnet links",
"testnet:address": "tsui client active-address",
"testnet:deploy": "testnet publish --path ${PWD}/move/greeting && pnpm copy-package-id -n testnet",
"mainnet:start": "mainnet start",
"mainnet:stop": "mainnet stop",
"mainnet:status": "mainnet status",
"mainnet:update": "mainnet update",
"mainnet:links": "mainnet links",
"mainnet:address": "msui client active-address",
"mainnet:deploy": "mainnet publish --path ${PWD}/move/greeting && pnpm copy-package-id -n mainnet"
},
"devDependencies": {
"env-file-rw": "^1.0.0",
"sui-explorer-local": "^0.4.0"
}
}
100 changes: 100 additions & 0 deletions copy-package-id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env node

/**
* The script copies the deployed package ID from the corresponding Suibase network file to .env.local of the frontend package,
* which is then read by the app.
*
* The default network is localnet. To change it, pass "-n [NETWORK_TYPE]" through console.
*/

const { promises } = require("node:fs");
const { homedir } = require("node:os");
const path = require("node:path");
const EnvFileWriter = require("env-file-rw").default;

const DEPLOYED_MODULE_NAME = "greeting";

const main = async () => {
const network = getNetworkFromArgs();
const sourceFile = sourceFilePath(network, DEPLOYED_MODULE_NAME);
const targetFile = targetFilePath();

// Read package ID from SuiBase packageId file.
const packageId = await readPackageId(sourceFile);

// Create .env.local file if it doesn't exist.
await createFileIfNecessary(targetFile);

// Add VITE_[network]_CONTRACT_PACKAGE_ID variable to .env.local or update its value if it exists.
await setEnvVar(
targetFile,
`VITE_${network.toUpperCase()}_CONTRACT_PACKAGE_ID`,
packageId
);
};

const sourceFilePath = (network, deployedModuleName) => {
return path.join(
homedir(),
`/suibase/workdirs/${network}/published-data/${deployedModuleName}/most-recent/package-id.json`
);
};

const targetFilePath = () => {
return path.join(process.cwd(), "../frontend/.env.local");
};

const getNetworkFromArgs = () => {
const arg = process.argv.slice(2);

switch (arg[0]) {
case "-n":
return arg[1];

default:
return "localnet";
}
};

/**
* Read package ID from SuiBase packageId file.
*
* @param {string} sourceFile
* @returns
*/
const readPackageId = async (sourceFile) => {
const data = await promises.readFile(sourceFile, "utf8");
return JSON.parse(data)[0];
};

/**
* Create a file if it doesn't exist.
*
* @param {string} filePath
* @returns
*/
const createFileIfNecessary = async (filePath) => {
try {
await promises.writeFile(filePath, "", { flag: "wx" });
} catch {}
};

/**
* Set the environment variable in the .env.local file.
*
* @param {string} envFilePath
* @param {string} name
* @param {string} value
* @returns
*/
const setEnvVar = async (envFilePath, name, value) => {
const envFileWriter = new EnvFileWriter(envFilePath, false);
await envFileWriter.parse();
envFileWriter.set(name, value);
await envFileWriter.save();
};

// Main entry point.
main().catch((e) => {
console.error(e);
});
7 changes: 7 additions & 0 deletions dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly

3 changes: 3 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
pnpm localnet:start
pnpm localnet:deploy
2 changes: 2 additions & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_APP_NAME="Sui dApp Starter"
VITE_APP_DESCRIPTION="Full-Stack Sui Starter on Steroids"
19 changes: 19 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'prettier',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
5 changes: 5 additions & 0 deletions frontend/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "sui-dapp-starter"
}
}
27 changes: 27 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Firebase
.firebase/*
3 changes: 3 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
public
dist
13 changes: 13 additions & 0 deletions frontend/.prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import("prettier").Config} */
const config = {
trailingComma: 'es5',
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: true,
tailwindConfig: './tailwind.config.mjs',
plugins: ['prettier-plugin-tailwindcss'],
tailwindFunctions: ['clsx', 'c', 'cn'],
}

export default config;
3 changes: 3 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sui dApp Starter: Frontend

Please find the root project [README](../../README.md).
22 changes: 22 additions & 0 deletions frontend/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"hosting": {
"predeploy": "pnpm build",
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"emulators": {
"hosting": {
"port": 5000
}
}
}
Loading

0 comments on commit 67d92b8

Please sign in to comment.