Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from ar-io/PE-4987-open-source
Browse files Browse the repository at this point in the history
chore(license): prep for open source release
  • Loading branch information
dtfiedler authored Nov 13, 2023
2 parents a934f6c + 03c0cd8 commit b6340be
Show file tree
Hide file tree
Showing 26 changed files with 380 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"plugins": ["@typescript-eslint", "prettier", "header"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"no-console": 1,
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"]
"@typescript-eslint/no-unused-vars": ["error"],
"header/header": [2, "./resources/license.header.js"]
},
"ignorePatterns": ["dist", "node_modules", "*.js"]
}
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ docker run -p 3000:3000 arns-service
The service leverages `warp-sdk` to retrieve, evaluate and cache contract state. To request a contract state, run:

```shell
curl localhost:3000/v1/contract/CONTRACT_ID
curl localhost:3000/v1/contract/${CONTRACT_ID}
```

e.g.
Expand All @@ -49,6 +49,16 @@ e.g.
curl localhost:3000/v1/contract/bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U
```

For more advanced features of Warp caching and state evaluation (e.g. D.R.E nodes), refer to the [Warp] documentation.

### LMDB

This service uses the `warp-contracts-lmdb` for storing contract state. The LMDB is stored in the `./cache` directory. To clear the LMDB, run:

```shell
rm -rf ./cache
```

### Evaluation Options

By default, the service will load `Contract-Manifest` tags for state evaluation.
Expand Down Expand Up @@ -84,9 +94,29 @@ yarn docker:integration

## Swagger

TODO
[Swagger] is used for endpoint documentation and testing. When running the service, you can load the Swagger UI in your browser at:

```shell
http://localhost:3000/api-docs
```

For production, the Swagger UI is available at:

```shell
https://api.arns.app/api-docs
```

## Contributions

- Build to interfaces
- Integration tests take precedent over unit tests
- Use [conventional commits] for commit messages
- Use [prettier] for code formatting
- Use [eslint] for linting
- Use [swagger] for API documentation

[Swagger]: https://swagger.io/
[conventional commits]: https://www.conventionalcommits.org/en/v1.0.0/
[prettier]: https://prettier.io/
[eslint]: https://eslint.org/
[Warp]: https://academy.warp.cc/docs/docs-intro
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ services:
NODE_VERSION_SHORT: ${NODE_VERSION_SHORT:-18}
environment:
NODE_ENV: ${NODE_ENV:-dev}
GATEWAY_HOST: arlocal
GATEWAY_PORT: 1984
GATEWAY_PROTOCOL: http
GATEWAY_HOST: ${GATEWAY_HOST:-arlocal}
GATEWAY_PORT: ${GATEWAY_PORT:-1984}
GATEWAY_PROTOCOL: ${GATEWAY_PROTOCOL:-http}
ports:
- '3000:3000'

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"commitlint": "^17.7.1",
"dotenv": "^16.0.3",
"eslint": "^8.42.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.3",
"mocha": "^10.2.0",
Expand Down
16 changes: 16 additions & 0 deletions resources/license.header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
16 changes: 16 additions & 0 deletions src/api/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Arweave from 'arweave';
import { ArNSInteraction } from '../types.js';

Expand Down
16 changes: 16 additions & 0 deletions src/api/warp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { EvaluationManifest, EvaluationOptions, Warp } from 'warp-contracts';
import {
DEFAULT_EVALUATION_OPTIONS,
Expand Down
16 changes: 16 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Koa from 'koa';
import router from './router';
import cors from '@koa/cors';
Expand Down
16 changes: 16 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { EvaluationOptions } from 'warp-contracts';

export const ARNS_CONTRACT_ID_REGEX = '([a-zA-Z0-9-_s+]{43})';
Expand Down
16 changes: 16 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { EVALUATION_TIMEOUT_MS } from './constants';

// TODO: we could put a prometheus metric here to help fine tune what our evaluation limit should be
Expand Down
16 changes: 16 additions & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import winston, { format, transports } from 'winston';

const LOG_LEVEL = process.env.LOG_LEVEL ?? 'info';
Expand Down
16 changes: 16 additions & 0 deletions src/middleware/arweave.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Next } from 'koa';
import { KoaContext } from '../types.js';
import Arweave from 'arweave';
Expand Down
16 changes: 16 additions & 0 deletions src/middleware/errors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { KoaContext } from '../types';
import { Next } from 'koa';
import { BadRequestError, EvaluationError, NotFoundError } from '../types';
Expand Down
16 changes: 16 additions & 0 deletions src/middleware/headers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Next } from 'koa';
import { KoaContext } from '../types';

Expand Down
16 changes: 16 additions & 0 deletions src/middleware/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './arweave';
export * from './headers';
export * from './logger';
Expand Down
16 changes: 16 additions & 0 deletions src/middleware/logger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { KoaContext } from '../types.js';
import { Next } from 'koa';
import crypto from 'crypto';
Expand Down
16 changes: 16 additions & 0 deletions src/middleware/warp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Next } from 'koa';
import { KoaContext } from '../types.js';
import {
Expand Down
16 changes: 16 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Router from '@koa/router';
import {
ARNS_CONTRACT_FIELD_REGEX,
Expand Down
16 changes: 16 additions & 0 deletions src/routes/contract.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Next } from 'koa';

import {
Expand Down
Loading

0 comments on commit b6340be

Please sign in to comment.