Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Envoy-VC committed Dec 13, 2023
0 parents commit 7032ca7
Show file tree
Hide file tree
Showing 25 changed files with 8,815 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"updateInternalDependencies": "patch",
"ignore": [],
"baseBranch": "main"
}
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['./config/eslint.js'],
};
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
branches:
- main

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

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup pnpm 8
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x

- name: Install Dependencies
run: pnpm i

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
.turbo
*.log
.next
dist
dist-ssr
*.local
.env
.cache
server/dist
public/dist
.turbo
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers = true
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "lf"
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
}
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Turborepo Design System starter with Changesets

This is an official React design system starter powered by Turborepo. Versioning and package publishing is handled by [Changesets](https://github.com/changesets/changesets) and fully automated with GitHub Actions.

## Using this example

Run the following command:

```sh
npx create-turbo@latest -e with-changesets
```

## What's inside?

This Turborepo includes the following:

### Apps and Packages

- `docs`: A placeholder documentation site powered by [Next.js](https://nextjs.org/)
- `@acme/core`: core React components
- `@acme/utils`: shared React utilities
- `@acme/tsconfig`: shared `tsconfig.json`s used throughout the monorepo
- `@acme/eslint-config`: ESLint preset

Each package and app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

This Turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting

### Useful commands

- `yarn build` - Build all packages and the docs site
- `yarn dev` - Develop all packages and the docs site
- `yarn lint` - Lint all packages
- `yarn changeset` - Generate a changeset
- `yarn clean` - Clean up all `node_modules` and `dist` folders (runs each package's clean script)

### Changing the npm organization scope

The npm organization scope for this design system starter is `@acme`. To change this, it's a bit manual at the moment, but you'll need to do the following:

- Rename folders in `packages/*` to replace `acme` with your desired scope
- Search and replace `acme` with your desired scope
- Re-run `yarn install`

## Versioning and Publishing packages

Package publishing has been configured using [Changesets](https://github.com/changesets/changesets). Please review their [documentation](https://github.com/changesets/changesets#documentation) to familiarize yourself with the workflow.

This example comes with automated npm releases setup in a [GitHub Action](https://github.com/changesets/action). To get this working, you will need to create an `NPM_TOKEN` and `GITHUB_TOKEN` in your repository settings. You should also install the [Changesets bot](https://github.com/apps/changeset-bot) on your GitHub repository as well.

For more information about this automation, refer to the official [changesets documentation](https://github.com/changesets/changesets/blob/main/docs/automating-changesets.md)

### npm

If you want to publish package to the public npm registry and make them publicly available, this is already setup.

To publish packages to a private npm organization scope, **remove** the following from each of the `package.json`'s

```diff
- "publishConfig": {
- "access": "public"
- },
```

### GitHub Package Registry

See [Working with the npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#publishing-a-package-using-publishconfig-in-the-packagejson-file)
34 changes: 34 additions & 0 deletions config/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { resolve } = require('node:path');

const project = resolve(process.cwd(), 'tsconfig.json');

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ['eslint:recommended', 'prettier', 'eslint-config-turbo'],
plugins: ['only-warn'],
globals: {
React: true,
JSX: true,
},
env: {
node: true,
},
settings: {
'import/resolver': {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
'.*.js',
'node_modules/',
'dist/',
],
overrides: [
{
files: ['*.js?(x)', '*.ts?(x)'],
},
],
};
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"private": true,
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"clean": "turbo clean && rm -rf node_modules",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"changeset": "changeset",
"version-packages": "changeset version",
"release": "turbo build && changeset publish"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
"eslint": "^8.54.0",
"prettier": "^2.8.8",
"turbo": "latest"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=18"
}
}
6 changes: 6 additions & 0 deletions packages/atomic-toolkit/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "lf"
}
21 changes: 21 additions & 0 deletions packages/atomic-toolkit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Vedant Chainani

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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions packages/atomic-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "atomic-toolkit",
"version": "0.0.0",
"description": "Toolkit for creating Atomic Assets on Arweave using Warp Contracts",
"private": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist/**"
],
"scripts": {
"dev": "vitest",
"test": "vitest run",
"build": "tsup src/index.ts --format cjs,esm --dts",
"lint": "tsc",
"ci": "pnpm run lint && pnpm run test && pnpm run build",
"release": "pnpm run lint && pnpm run test && pnpm run build && changeset publish"
},
"keywords": [
"arweave",
"atomic",
"assets",
"warp",
"contracts"
],
"author": "Vedant Chainani",
"license": "MIT",
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@irys/sdk": "^0.1.1",
"@types/node": "^18.19.3",
"arbundles": "^0.10.0",
"dotenv": "^16.3.1",
"ethers": "v5",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vitest": "^1.0.4",
"warp-contracts": "^1.4.26",
"warp-contracts-plugin-deploy": "^1.0.12"
},
"publishConfig": {
"access": "public"
}
}
83 changes: 83 additions & 0 deletions packages/atomic-toolkit/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Tag } from 'arbundles';

const ATOMIC_TOKEN_SRC = 'Of9pi--Gj7hCTawhgxOwbuWnFI1h24TTgO5pw8ENJNQ';

const getAtomicAssetTags = (tags?: Tag[]): Tag[] => {
const baseTags: Tag[] = [
// Contract Identifiers
{ name: 'App-Name', value: 'SmartWeaveContract' },
{ name: 'App-Version', value: '0.3.0' },
{ name: 'Contract-Src', value: ATOMIC_TOKEN_SRC },
{
name: 'Contract-Manifest',
value: '{"evaluationOptions":{"sourceType":"redstone-sequencer","allowBigInt":true,"internalWrites":true,"unsafeClient":"skip","useConstructor":true}}',
},
{ name: 'Indexed-By', value: 'ucm' },
// License
{ name: 'License', value: 'udlicense' },
];

const requiredTags = baseTags.map((tag) => tag.name);
const tagNames = tags?.map((tag) => tag.name);

tagNames?.forEach((t) => {
if (requiredTags.includes(t)) {
const index = requiredTags.indexOf(t);
baseTags[index] = tags?.find((tag) => tag.name === t) as Tag;
} else {
baseTags.push(tags?.find((tag) => tag.name === t) as Tag);
}
});

return baseTags;
};

const checkAssetDiscoverabilityTags = (tags: Tag[]) => {
const requiredTags = ['Type', 'Title', 'Description'];
const tagNames = tags.map((tag) => tag.name);
const missingTags = requiredTags.filter((tag) => !tagNames.includes(tag));
if (missingTags.length > 0) {
throw new Error(
`Missing required tags: ${missingTags.join(', ')} in tags array`,
);
}
};

const checkInitStateTag = (tags: Tag[]) => {
const initStateTag = tags.find((tag) => tag.name === 'Init-State');
if (!initStateTag) {
throw new Error('Init-State tag not found');
}
try {
const parsed = JSON.parse(initStateTag.value);
if (
!parsed.ticker ||
!parsed.name ||
!parsed.balances ||
!parsed.claimable
) {
throw new Error('Init-State tag value is not valid');
}
} catch (e) {
throw new Error('Init-State tag value is not valid JSON');
}
};

const checkAndAddContentTypeTag = (file: File, tags: Tag[]): Tag[] => {
const t = tags;
const tagNames = t.map((tag) => tag.name);
if (!tagNames.includes('Content-Type')) {
const contentType = file.type;
if (contentType) {
t.push({ name: 'Content-Type', value: contentType });
}
}
return t;
};

export {
getAtomicAssetTags,
checkAssetDiscoverabilityTags,
checkAndAddContentTypeTag,
checkInitStateTag,
};
Loading

0 comments on commit 7032ca7

Please sign in to comment.