Skip to content

Commit

Permalink
Merge branch 'ubiquity-os-marketplace:development' into admin-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ishowvel authored Nov 10, 2024
2 parents ac5a724 + 34dbd9f commit 7649094
Show file tree
Hide file tree
Showing 57 changed files with 1,311 additions and 11,148 deletions.
33 changes: 30 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
# Token used to use when calling GitHub API
GITHUB_TOKEN="<token>"

# Key for OpenAI usage
OPENAI_API_KEY="<api_key>"
# treasury fee applied to the final permits, ex: 100 = 100%, 0.1 = 0.1%

# Supabase URL
SUPABASE_URL=""

# Supabase key
SUPABASE_KEY=""

# X25519 private key
X25519_PRIVATE_KEY=""

# NFT minter private key
NFT_MINTER_PRIVATE_KEY=""

# NFT contract address
NFT_CONTRACT_ADDRESS=""

# Treasury fee applied to the final permits, ex: 100 = 100%, 0.1 = 0.1%
PERMIT_FEE_RATE=""
# github account associated with EVM treasury address allowed to claim permit fees, ex: "ubiquity-os-treasury"

# GitHub account associated with EVM treasury address allowed to claim permit fees, ex: "ubiquity-os-treasury"
PERMIT_TREASURY_GITHUB_USERNAME=""
# comma separated list of token addresses which should not incur any fees, ex: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d, 0x4ECaBa5870353805a9F068101A40E0f32ed605C6"

# Comma-separated list of token addresses which should not incur any fees, ex: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d, 0x4ECaBa5870353805a9F068101A40E0f32ed605C6"
PERMIT_ERC20_TOKENS_NO_FEE_WHITELIST=""

# Optional kernel public key
KERNEL_PUBLIC_KEY=""

# Logger level, default is INFO
LOG_LEVEL=""
3 changes: 3 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ jobs:
name: Rewards
runs-on: ubuntu-latest
permissions: write-all
environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }}

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLUGIN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
X25519_PRIVATE_KEY: ${{ secrets.X25519_PRIVATE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
Expand All @@ -35,6 +37,7 @@ jobs:
PERMIT_FEE_RATE: ${{ secrets.PERMIT_FEE_RATE }}
PERMIT_TREASURY_GITHUB_USERNAME: ${{ secrets.PERMIT_TREASURY_GITHUB_USERNAME }}
PERMIT_ERC20_TOKENS_NO_FEE_WHITELIST: ${{ secrets.PERMIT_ERC20_TOKENS_NO_FEE_WHITELIST }}
KERNEL_PUBLIC_KEY: ${{ secrets.KERNEL_PUBLIC_KEY }}

steps:
# Note: the checkout could potentially be avoided by calling the workflow on the repo/branch directly.
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ jobs:
with:
fetch-depth: 0

- uses: oven-sh/setup-bun@v2

- name: Jest With Coverage
run: yarn install --immutable --immutable-cache --check-cache && yarn test
# we install with bun but test with Jest because bun doesn't support network mocking yet
run: bun install && yarn test

- name: Add Jest Report to Summary
if: always()
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ jobs:
with:
node-version: 20.10.0

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

- name: Install toolchain
run: yarn install
run: bun install

- name: Store PR number
run: echo ${{ github.event.number }} > pr-number.txt
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:

steps:
- uses: ubiquity-os/action-deploy-plugin@main
with:
treatAsEsm: true
sourcemap: false
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ static/dist
junit.xml
coverage
test-dashboard.md
*.private.env.json
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit "$1"
bun commitlint --edit "$1"
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
bun lint-staged
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# `@ubiquity-os/text-conversation-rewards`

As of 28 February: test driven development to aggregate all necessary information based on a URL to an issue.

- pass in closed as complete issue URL and receive all the timeline events and activities of all humans who helped close the issue as complete.
- most importantly: this can inherit bot authentication and link pull requests to issues in private repositories.

Be sure to review all `*.test.*` files for implementation details.

## Data structure

```json
Expand Down Expand Up @@ -354,8 +347,8 @@ Partner private key (`evmPrivateEncrypted` config param in `conversation-rewards

Here `GITHUB_OWNER_ID` can be:

1. Github organization id (if ubiquity-os is used within an organization)
2. Github user id (if ubiquity-os is simply installed in a user's repository)
1. GitHub organization id (if ubiquity-os is used within an organization)
2. GitHub user id (if ubiquity-os is simply installed in a user's repository)

Format `PRIVATE_KEY:GITHUB_OWNER_ID` restricts in which particular organization (or user related repositories)
this private key can be used. It can be set either in the organization wide config either in the repository wide one.
Expand Down
Binary file added bun.lockb
Binary file not shown.
8 changes: 3 additions & 5 deletions dist/33.index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exports.id = 33;
exports.ids = [33];
exports.modules = {
export const id = 33;
export const ids = [33];
export const modules = {

/***/ 57666:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
Expand Down Expand Up @@ -28,7 +28,6 @@ module.exports = globalThis.DOMException
/***/ 42033:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {

"use strict";

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Expand Down Expand Up @@ -147,4 +146,3 @@ async function fileFromPath(path, filenameOrOptions, options) {
/***/ })

};
;
55 changes: 33 additions & 22 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
12 changes: 11 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import type { Config } from "jest";

const cfg: Config = {
transform: {
"^.+\\.tsx?$": "babel-jest",
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
coveragePathIgnorePatterns: ["node_modules", "mocks"],
Expand All @@ -12,6 +17,11 @@ const cfg: Config = {
coverageDirectory: "coverage",
testTimeout: 20000,
roots: ["<rootDir>", "tests"],
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
setupFilesAfterEnv: ["dotenv/config"],
};

export default cfg;
2 changes: 1 addition & 1 deletion knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const config: KnipConfig = {
project: ["src/**/*.ts"],
ignore: ["src/data-collection/examples/*.ts", "src/configuration/common-config-type.ts", "dist/**"],
ignoreExportsUsedInFile: true,
ignoreDependencies: ["ts-node", "msw", "@mswjs/data"],
ignoreDependencies: ["ts-node", "msw", "@mswjs/data", "@octokit/plugin-paginate-graphql"],
jest: {
config: ["jest.config.ts"],
entry: ["src/**/*.test.ts"],
Expand Down
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
"engines": {
"node": ">=20.10.0"
},
"type": "module",
"scripts": {
"test": "jest --setupFiles dotenv/config --coverage",
"test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --setupFiles dotenv/config --coverage",
"start": "tsx src/index.ts",
"format": "run-s format:lint format:prettier format:cspell",
"format:lint": "eslint --fix .",
"format:prettier": "prettier --write .",
"format:cspell": "cspell **/*",
"knip": "knip",
"prepare": "husky install"
"prepare": "husky install",
"dev": "bun --watch src/index.ts"
},
"keywords": [
"typescript",
Expand All @@ -25,27 +27,24 @@
"open-source"
],
"dependencies": {
"@actions/core": "1.11.1",
"@actions/github": "6.0.0",
"@actions/github": "^6.0.0",
"@octokit/graphql-schema": "^15.25.0",
"@octokit/plugin-paginate-graphql": "^5.2.3",
"@octokit/plugin-retry": "^6.0.1",
"@octokit/rest": "^20.1.0",
"@octokit/webhooks": "^13.2.7",
"@sinclair/typebox": "0.32.23",
"@octokit/rest": "^21.0.2",
"@sinclair/typebox": "^0.33.21",
"@supabase/supabase-js": "2.42.0",
"@ubiquity-dao/rpc-handler": "1.3.0",
"@ubiquity-os/permit-generation": "^2.0.5",
"@ubiquity-os/permit-generation": "^2.0.6",
"@ubiquity-os/plugin-sdk": "^1.0.8",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"@octokit/plugin-paginate-graphql": "^5.2.4",
"decimal.js": "10.4.3",
"dotenv": "16.4.5",
"ethers": "^5.7.2",
"js-tiktoken": "1.0.15",
"jsdom": "24.0.0",
"markdown-it": "14.1.0",
"openai": "4.56.0",
"ts-jest": "^29.2.5",
"tsx": "4.7.1",
"typebox-validators": "0.3.5",
"yaml": "2.4.1"
},
"devDependencies": {
Expand All @@ -64,26 +63,28 @@
"@types/markdown-it": "13.0.7",
"@types/node": "20.11.28",
"babel-jest": "29.7.0",
"cross-env": "^7.0.3",
"cspell": "8.15.2",
"dotenv": "^16.4.5",
"eslint": "9.12.0",
"eslint-plugin-check-file": "^2.8.0",
"eslint-plugin-sonarjs": "2.0.3",
"husky": "8.0.3",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"jest-md-dashboard": "0.8.0",
"knip": "5.7.0",
"knip": "^5.36.2",
"lint-staged": "15.2.2",
"msw": "2.4.9",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"ts-node": "10.9.2",
"typescript": "5.6.2",
"typescript-eslint": "^8.8.0"
"typescript": "^5.6.3",
"typescript-eslint": "^8.13.0"
},
"lint-staged": {
"*.ts": [
"yarn prettier --write",
"bun prettier --write",
"eslint --fix"
],
"src/**.{ts,json}": [
Expand Down
24 changes: 0 additions & 24 deletions src/configuration/config-reader.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/configuration/constants.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/data-collection/collect-linked-pulls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PullRequest, Repository, User } from "@octokit/graphql-schema";
import { getOctokitInstance } from "../octokit";
import { IssueParams } from "../start";
import { ContextPlugin } from "../types/plugin-input";
import { LINKED_PULL_REQUESTS } from "../types/requests";

type ClosedByPullRequestsReferences = {
Expand All @@ -20,8 +20,8 @@ type IssueWithClosedByPrs = {
};
};

export async function collectLinkedMergedPulls(issue: IssueParams) {
const octokit = getOctokitInstance();
export async function collectLinkedMergedPulls(context: ContextPlugin, issue: IssueParams) {
const { octokit } = context;
const { owner, repo, issue_number } = issue;

const result = await octokit.graphql.paginate<IssueWithClosedByPrs>(LINKED_PULL_REQUESTS, {
Expand Down
10 changes: 5 additions & 5 deletions src/helpers/get-comment-details.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { GitHubIssueComment } from "../github-types";
import { getOctokitInstance } from "../octokit";
import { IssueComment } from "@octokit/graphql-schema";
import { GitHubIssueComment } from "../github-types";
import { ContextPlugin } from "../types/plugin-input";
import { QUERY_COMMENT_DETAILS } from "../types/requests";

export async function getMinimizedCommentStatus(comments: GitHubIssueComment[]) {
const octokit = getOctokitInstance();
export async function getMinimizedCommentStatus(context: ContextPlugin, comments: GitHubIssueComment[]) {
const { octokit } = context;
const commentsData = await octokit.graphql<{ nodes?: IssueComment[] }>(QUERY_COMMENT_DETAILS, {
node_ids: comments.map((o) => o.node_id),
});

if (commentsData.nodes?.length) {
if (commentsData?.nodes?.length) {
for (const commentNode of commentsData.nodes) {
const comment = comments.find((o) => o.node_id === commentNode.id);
// For each comment we add the 'isMinimized' info, which corresponds to a collapsed comment
Expand Down
5 changes: 0 additions & 5 deletions src/helpers/github-comment-module-instance.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/helpers/logger.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/helpers/validator.ts

This file was deleted.

Loading

0 comments on commit 7649094

Please sign in to comment.