Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aryzing committed Sep 2, 2024
0 parents commit afcc640
Show file tree
Hide file tree
Showing 40 changed files with 1,771 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI Main

on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install

- name: Run CI
run: bun run ci

- name: Publish to NPM package registry
run: npm publish --access=public --tag=latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PACKAGE_REGISTRY_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/ci-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI PR

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install

- name: Run CI
run: bun run ci

- id: current-version
name: Get current version
run: echo "CURRENT_VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_OUTPUT

- id: sha
name: Get commit sha
run: echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Set publish version
# https://github.com/oven-sh/bun/issues/1976
run: bunx npm@latest version --no-git-tag-version $CURRENT_VERSION-$SHA
env:
SHA: ${{ steps.sha.outputs.SHA }}
CURRENT_VERSION: ${{ steps.current-version.outputs.CURRENT_VERSION }}

- name: Publish to NPM package registry
# https://github.com/oven-sh/bun/issues/1976
run: bunx npm@latest publish --access=public --tag pr-$PR_NUMBER
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PACKAGE_REGISTRY_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
175 changes: 175 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# pool-tools

A collection of methods to help interact with the Stacks API and manage pools.

Supports ESM imports only.
Binary file added bun.lockb
Binary file not shown.
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "stacks-tools",
"version": "0.1.0",
"type": "module",
"files": [
"dist"
],
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"check-format": "prettier --check .",
"format": "prettier --write .",
"check-types": "tsc --noEmit",
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
"ci": "bun run check-format && bun run check-exports && bun run build"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.15.4",
"@types/bun": "latest",
"prettier": "^3.3.3"
},
"peerDependencies": {
"typescript": "^5.0.0",
"valibot": "^0.41.0"
},
"dependencies": {
"exponential-backoff": "3.1.1"
},
"license": "MIT"
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { stacksApi } from "./stacks-api/index.js";
export { queries } from "./queries/index.js";
29 changes: 29 additions & 0 deletions src/pox4-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Pool API

## Public

- delegate-stx
- delegate-stack-stx
- delegate-stack-stx-simple
- set-metadata
- set-metadata-many
- allow-contract-caller
- disallow-contract-caller

## Read only

- burn-height-to-reward-cycle
- reward-cycle-to-burn-height
- current-pox-reward-cycle
- get-status
- get-status-lists-last-index
- get-status-list
- get-delegated-amount
- get-user-data
- get-stx-account
- get-total
- not-locked-for-cycle
- get-metadata
- get-metadata-many
- check-caller-allowed
- get-allowance-contract-callers
13 changes: 13 additions & 0 deletions src/pox4-api/burn-height-to-reward-cycle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ApiRequestOptions } from "../stacks-api/types.js";
import { success, type Result } from "../utils/safe.js";

type Args = {
burnHeight: number;
} & ApiRequestOptions;

export async function burnHeightToRewardCycle(
_args: Args,
): Promise<Result<number>> {
// TODO
return success(0);
}
1 change: 1 addition & 0 deletions src/pox4-api/current-pox-reward-cycle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO
1 change: 1 addition & 0 deletions src/pox4-api/get-stacker-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO
1 change: 1 addition & 0 deletions src/pox4-api/reward-cycle-to-burn-height.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO
Loading

0 comments on commit afcc640

Please sign in to comment.