Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: tt 117 tradetrust core node 18 #5

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ed76d5c
chore: test ci
MinHtet-O Feb 5, 2024
6433781
chore: add public publish config to npm
MinHtet-O Feb 5, 2024
41b18db
1.0.4
MinHtet-O Feb 5, 2024
60a4ffd
chore: commitizen init
MinHtet-O Feb 5, 2024
6676977
fix: remove ! from greet method response
MinHtet-O Feb 5, 2024
ab220f1
debug: 1.0.5
MinHtet-O Feb 5, 2024
ee2634b
fix: 1.0.6
MinHtet-O Feb 5, 2024
4a4d13b
fix: test
MinHtet-O Feb 5, 2024
93ceb7b
fix: test
MinHtet-O Feb 5, 2024
fa4787a
fix: remove !
MinHtet-O Feb 5, 2024
48152f6
fix: add commitlint config
MinHtet-O Feb 5, 2024
43ecf41
fix: add dependencies for conventional commitlint
MinHtet-O Feb 5, 2024
9d18d58
ci: remove commit lint
MinHtet-O Feb 5, 2024
5dda7cb
Merge pull request #1 from TradeTrust/feat/test-release
MinHtet-O Feb 5, 2024
7ea17d9
chore: add to ignore coverage folder
MinHtet-O Feb 5, 2024
f4af289
feat: delete coverage folder
MinHtet-O Feb 5, 2024
43c2219
fix: lint test
MinHtet-O Feb 5, 2024
af4add4
fix: lint test
MinHtet-O Feb 5, 2024
2c830ae
fix: remove @commitlint/config-conventional
MinHtet-O Feb 5, 2024
9fa5569
chore: change github actions from v3 to v4
MinHtet-O Feb 5, 2024
6befbdd
chore: downgrade @commitlint/config-conventional
MinHtet-O Feb 6, 2024
2b04589
chore: update dependencies
MinHtet-O Feb 6, 2024
e3ed2af
feat: wrap & export tt verificationBuilder,verify and interpret fragm…
MinHtet-O Feb 7, 2024
6fa4140
chore: add v2 & v3 test data documents
MinHtet-O Feb 7, 2024
946f151
test: verify dns-txt with document store
MinHtet-O Feb 20, 2024
dbea4f2
test: verify dns-did
MinHtet-O Feb 20, 2024
024009b
test: verify dns-txt-token reg for v2 and dns-did, dns-txt-doc-store …
MinHtet-O Feb 21, 2024
49fdd76
test: verify dns-txt-token-reg for v3 documents
MinHtet-O Feb 21, 2024
005c7e7
ci: run tests
MinHtet-O Feb 21, 2024
ebea287
feat: migrate interpretFragments function from tradetrust-utils
MinHtet-O Feb 21, 2024
d6aeace
ci: make test blockchain exits after tests hv been executed
MinHtet-O Feb 21, 2024
255f9d5
ci: trigger build
MinHtet-O Feb 21, 2024
0c69f63
docs: link modules heading
MinHtet-O Feb 22, 2024
75552bc
ci: change branch name to main to setup trigger semantic release
MinHtet-O Feb 22, 2024
0221b37
Merge pull request #3 from TradeTrust/feat/tt-6-verify
MinHtet-O May 2, 2024
9259d05
chore: specificy strict node 18
MinHtet-O May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
dist
dist
**/__snapshots__/
# **/*.test.ts
# **/*.test.js
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/consistent-type-definitions": ["error", "type"]
"no-duplicate-imports": "error",
"@typescript-eslint/no-explicit-any": "warn"
}
}
6 changes: 3 additions & 3 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
name: Code Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: npm ci --ignore-scripts
Expand All @@ -22,7 +22,7 @@ jobs:
name: Commit Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Commit Lint Dependencies
run: npm install @commitlint/config-conventional
- uses: JulienKode/[email protected]
2 changes: 1 addition & 1 deletion .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 2 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
on:
push:
branches:
- master
- main
- beta
- +([0-9])?(.{+([0-9]),x}).x

env:
NODE_ENV: ci
Expand All @@ -25,8 +22,8 @@ jobs:
runs-on: ubuntu-latest
needs: [tests, linters]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: npm ci
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: npm ci
Expand All @@ -22,8 +22,8 @@ jobs:
name: Test Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: npm ci
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ Thumbs.db
.prettiercache

# TypeScript type declaration files
*.d.ts
*.d.ts

# vitest reports
coverage/
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .npmrc
engine-strict=true

2 changes: 2 additions & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lts/hydrogen

88 changes: 66 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,81 @@
## TradeTrust Core
# TradeTrust Core

Unified interface for interacting with TradeTrust's various services.
Unified interface for interacting with TradeTrust's various services. This library contains a set of modules.

## Getting Started
| Module | Description |
| ----------------- | ------------------------------------------------------ |
| [Verify](#verify) | Verify TradeTrust issued document |
| [Utils](#utils) | Provide utility methods for TradeTrust functionalities |

To get started with this project, clone the repository and install the dependencies:
## Installation

### install
```sh
npm i @tradetrust-tt/tradetrust-core
```

Building the Project
You can build the project using the following command:
`npm i`
## Verify

#### build
`verify` allows you to verify issued document programmatically. After verification, use `isValid` method to answer some questions:

This will generate the necessary files in the dist directory.
`npm run build`
- Has the document been tampered with ?
- Is the issuance state of the document valid ?
- Is the document issuer identity valid ? (see [identity proof](https://docs.tradetrust.io/docs/topics/verifying-documents/issuer-identity))

#### Running Tests
Document can be either [verifiable document](https://docs.tradetrust.io/docs/tutorial/verifiable-documents/overview) or [transferrable record](https://docs.tradetrust.io/docs/tutorial/transferable-records/overview) which follows [TradeTrust document schema](https://docs.tradetrust.io/docs/topics/introduction/tradetrust-document-schema/)

To run the tests, use the following command:
`npm run test`
```ts
// verify document using network name
import { verify, isValid } from '@tradetrust-tt/tradetrust-core/verify'
let document = {
// your tradetrust document
}
const fragments = await verify(document, {
network: 'sepolia', // can also provide other networks such as homestead
})
console.log(isValid(fragments))
```

#### Linting
```ts
// verify document using provider
import { ethers } from 'ethers'
import { utils } from '@tradetrust-tt/tt-verify'

To lint the project, use the following command:
`npm run lint`
const providerOptions = {
// modify your provider options accordingly
network: 'sepolia',
providerType: 'infura',
apiKey: 'abdfddsfe23232',
}
const provider = utils.generateProvider(providerOptions)

#### lint fix
let document = {
// your tradetrust document
}
const fragments = await verify(document, { provider })
console.log(isValid(fragments))
```

To automatically fix linting errors, use the following command:
`npm run lint-fix`
For more information about building provider, visit [tt-verify repository](https://github.com/TradeTrust/tt-verify?tab=readme-ov-file#provider)

#### Contributing
## Utils

We welcome contributions to the TradeTrust Core project. Please feel free to submit a pull request or open an issue.
This module provides utility methods that supports the shared functionalities for other TradeTrust modules.

#### InterpretFragments

`interpretFragments` allows you to extract out the verified results from the fragments.

```ts
import {interpretFragments} from '@tradetrust-tt/tradetrust-core/utils`;

const fragments = await verify(document, {
network: 'sepolia',
});

const {hasValid, issuedValid, identityValid} = interpretFragments(fragments);
console.log({hasValid, issuedValid, identityValid});
```

## Contributing

We welcome contributions to the TradeTrust core library. Please feel free to submit a pull request or open an issue.
8 changes: 8 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: ['@commitlint/config-conventional'],

// Add your own rules. See http://marionebl.github.io/commitlint
rules: {
'body-max-line-length': [0], // disable
},
}
Loading
Loading