Skip to content

Commit

Permalink
add inkathon boilerplate files
Browse files Browse the repository at this point in the history
  • Loading branch information
Peixer committed Jan 12, 2024
0 parents commit 93e8e09
Show file tree
Hide file tree
Showing 99 changed files with 12,402 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "scio-labs/inkathon" }],
"commit": false,
"fixed": [],
"privatePackages": { "version": true, "tag": true },
"linked": [["@inkathon/*"]],
"baseBranch": "main",
"updateInternalDependencies": "patch"
}
22 changes: 22 additions & 0 deletions .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Add issue or pull request to project

on:
issues:
types:
- opened
- reopened
# pull_request:
# types:
# - opened
# - reopened

jobs:
add-to-project:
name: Add issue or pull request to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
project-url: https://github.com/orgs/scio-labs/projects/3
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
pnpm-version: [8.11]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
submodules: true

- name: Set up pnpm action ${{ matrix.pnpm-version }}
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm-version }}

- name: Set up Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: 'pnpm'
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Create Release Pull Request
uses: changesets/action@v1
with:
title: 'chore(changeset): Bump package version'
commit: 'chore(changeset): Bump package version'
version: pnpm changeset version
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.CHANGESETS_PAT }}
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# package management
**/node_modules
**/.pnp
.pnp.js
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env*.local

# vercel
.vercel
.gitsigners

# typescript
*.tsbuildinfo
dist

# turbo
.turbo

# coverage
coverage
coverage.json

# VSCode
.history/
10 changes: 10 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
init-author-name=Scio Labs
init-author-email=[email protected]
init-author-url=https://scio.xyz/
init-license=GPL-3.0

auto-install-peers = true
enable-pre-post-scripts = true

public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*prettier*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package-lock.json
pnpm-lock.yaml
node_modules
LICENSE
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
semi: false,
singleQuote: true,
trailingComma: 'all',
printWidth: 100,
tabWidth: 2,
useTabs: false,
}
8 changes: 8 additions & 0 deletions .simple-git-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
'pre-commit': `
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
pnpm lint-staged
`,
}
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"wayou.vscode-todo-highlight",
"tamasfe.even-better-toml",
"rust-lang.rust-analyzer",
"ink-analyzer.ink-analyzer",
"gruntfuggly.todo-tree",
"mikestead.dotenv",
"bradlc.vscode-tailwindcss"
]
}
47 changes: 47 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"search.exclude": {
"**/*.{jpg,jpeg,png,svg,webm,mp4,ttf,woff,woff2}": true
},
"search.useIgnoreFiles": true,
"search.useGlobalIgnoreFiles": true,
"search.useParentIgnoreFiles": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll.eslint": "always"
},
"files.associations": {
".env.*": "dotenv",
"*.css": "tailwindcss"
},
"[javascriptreact][typescriptreact][javascript][typescript][markdown][html][css][scss][sass][json][jsonc][yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact][typescriptreact][javascript][typescript]": {
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
]
},
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.updateImportsOnFileMove.enabled": "always",
"javascript.preferences.importModuleSpecifier": "shortest",
"typescript.preferences.importModuleSpecifier": "shortest",
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"evenBetterToml.formatter.indentString": " ",
"evenBetterToml.formatter.columnWidth": 120,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"peacock.color": "#8758FF",
"workbench.colorCustomizations": {
"sash.hoverBorder": "#ac8bff",
"statusBar.background": "#8758ff",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#ac8bff",
"statusBarItem.remoteBackground": "#8758ff",
"statusBarItem.remoteForeground": "#e7e7e7"
}
}
109 changes: 109 additions & 0 deletions .vscode/workshop.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"Workshop Contracts Snippet #1": {
"scope": "rust",
"prefix": "Workshop Contracts Snippet #1",
"body": [
"/// Reverses and stores the `message` string",
"#[ink(message)]",
"pub fn reverse_message(&mut self) {",
" self.message = self.message.chars().rev().collect::<String>();",
"}"
]
},
"Workshop Contracts Snippet #2": {
"scope": "rust",
"prefix": "Workshop Contracts Snippet #2",
"body": [
"#[ink::test]",
"fn reverse_message_works() {",
" let message_1 = String::from(\"gm ink!\");",
" let message_1_reversed = String::from(\"!kni mg\");",
" let mut greeter = Greeter::new(message_1.clone());",
" assert_eq!(greeter.greet(), message_1);",
" greeter.reverse_message();",
" assert_eq!(greeter.greet(), message_1_reversed);",
"}"
]
},
"Workshop Frontend Snippet #1": {
"scope": "typescriptreact",
"prefix": "Workshop Frontend Snippet #1",
"body": [
"// Reverse Greeting",
"const reverseGreeting = async () => {",
" if (!activeAccount || !contract || !activeSigner || !api) {",
" toast.error('Wallet not connected. Try again…')",
" return",
" }",
"",
" setUpdateIsLoading(true)",
" try {",
" await contractTxWithToast(api, activeAccount.address, contract, 'reverseMessage', {}, [])",
" } catch (e) {",
" console.error(e)",
" } finally {",
" setUpdateIsLoading(false)",
" await fetchGreeting()",
" }",
"}",
]
},
"Workshop Frontend Snippet #2": {
"scope": "typescriptreact",
"prefix": "Workshop Frontend Snippet #2",
"body": [
"{/* Reverse Greeting */}",
"<Card>",
" <CardContent className=\"pt-6\">",
" <Button",
" type=\"button\"",
" onClick={reverseGreeting}",
" className=\"w-full bg-primary font-bold\"",
" disabled={fetchIsLoading || updateIsLoading}",
" isLoading={updateIsLoading}",
" >",
" Submit",
" </Button>",
" </CardContent>",
"</Card>",
]
}
"Workshop Scripts Snippet #1": {
"scope": "typescript",
"prefix": "Workshop Scripts Snippet #1",
"body": [
"import { transferBalance } from '@scio-labs/use-inkathon'",
"import { initPolkadotJs } from './utils/initPolkadotJs'",
"",
"/**",
" * Example script that transfers tokens to the passed address from Alice.",
" *",
" * Parameters:",
" * - `ACCOUNT_URI`: Sender address URI (i.e. `//Alice`)",
" * - `ADDRESS`: Receiver address",
" * - `AMOUNT`: Token amount to transfer (optional, defaults to `100`)",
" * - `CHAIN`: Chain ID (optional, defaults to `development`)",
" *",
" * Example usage:",
" * - `ADDRESS=5fei… pnpm run script make-it-rain`",
" */",
"const main = async () => {",
" const { api, account, toBNWithDecimals } = await initPolkadotJs()",
"",
" const receiverAddress = process.env.ADDRESS",
" if (!receiverAddress) throw new Error('Missing `ADDRESS` variable')",
" const tokenAmount = toBNWithDecimals(process.env.AMOUNT ? parseInt(process.env.AMOUNT) : 100)",
"",
" console.log(`\nTransferring ${tokenAmount} tokens to ${receiverAddress}…`)",
" await transferBalance(api, account, receiverAddress, tokenAmount)",
"}",
"",
"main()",
" .catch((error) => {",
" console.error(error)",
" process.exit(1)",
" })",
" .finally(() => process.exit(0))",
]
}
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Contributing Guidelines

[Scio Labs](https://scio.xyz) actively welcomes contributions from anyone to make this a community-driven effort. There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, or writing code.

Our ink! developer tooling initiative is made up of the following projects:

- `create-ink-app` CLI (_Coming soon_)
- [`ink!athon`](https://github.com/scio-labs/inkathon) Boilerplate
- [`useInkathon`](https://github.com/scio-labs/use-inkathon) Hooks & Utility Library
- [`zink!`](https://github.com/scio-labs/zink) Smart Contract Macros

_To ensure a smooth and efficient collaboration, please follow the guidelines below._

## Issues

- Before starting work, please check the existing issues for your planned feature or bug fix.
- If there isn't an existing issue, create one. This allows us to avoid duplicate work and discuss the implementation details upfront.
- If you want to work on an issue, please comment on it to let us know. This helps us keep track of who is working on what.

## Pull Requests

- All changes should be made through pull requests (PRs).
- Please ensure your PR is linked to the relevant issue.
- Include a clear and detailed description of the changes in your PR.
- Request a review once your PR is ready.

## Code Style

- Please follow the existing coding style.
- Make sure your changes pass the lint checks.

> [!IMPORTANT]
>
> - Please install all recommended VSCode extensions (see `.vscode/extensions.json`).
> - After installing dependencies, enable the `pre-commit` hook in your local repository via `pnpm simple-git-hooks`.
> - Make sure to always use the `inkathon.code-workspace` file when working on the project in VSCode.
## Communication

- Be respectful and considerate in all interactions.
- If you have questions or need help, don't hesitate to ask.
- For code, feature, or bug discussions, please use the relevant GitHub issue or PR.
- To chat with us or ask questions, join our [Telegram Group](https://t.me/inkathon). 💬

Thanks for your contributions! 🙏
Loading

0 comments on commit 93e8e09

Please sign in to comment.