Skip to content

Commit 1d057e1

Browse files
committed
chore(init): migrate SDK to separate repo
0 parents  commit 1d057e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+13773
-0
lines changed

.env.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
## OR ##
3+
4+
5+
# Specifies the log level output threshold.
6+
# "error"
7+
# "warn"
8+
# "info"
9+
# "debug"
10+
LOG_LEVEL="debug"

.eslintignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# directories
2+
.yarn/
3+
**/cache
4+
**/dist
5+
**/node_modules
6+
**/src/__generated__
7+
8+
# files
9+
*.env
10+
*.log
11+
.pnp.*
12+
coverage.json
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*

.eslintrc.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
extends:
2+
- "eslint:recommended"
3+
- "plugin:@typescript-eslint/eslint-recommended"
4+
- "plugin:@typescript-eslint/recommended"
5+
- "prettier"
6+
parser: "@typescript-eslint/parser"
7+
parserOptions:
8+
project: "./sdk/tsconfig.json"
9+
plugins:
10+
- "@typescript-eslint"
11+
root: true
12+
ignorePatterns: ["rollup.config.js", "vitest.config.ts", "dist/", "__generated__/"]
13+
rules:
14+
"@typescript-eslint/semi":
15+
- warn
16+
"@typescript-eslint/switch-exhaustiveness-check":
17+
- warn
18+
"@typescript-eslint/no-floating-promises":
19+
- error
20+
- ignoreIIFE: true
21+
ignoreVoid: true
22+
"@typescript-eslint/no-inferrable-types": "off"
23+
"@typescript-eslint/no-unused-vars":
24+
- error
25+
- argsIgnorePattern: "_"
26+
varsIgnorePattern: "_"

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# directories
2+
.yarn/*
3+
!.yarn/patches
4+
!.yarn/releases
5+
!.yarn/plugins
6+
!.yarn/sdks
7+
!.yarn/versions
8+
**/node_modules
9+
**/dist
10+
11+
# files
12+
*.env
13+
*.log
14+
.pnp.*
15+
coverage.json
16+
npm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*
19+
.DS_Store
20+
/.idea
21+
stats.html

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/hypercerts-api"]
2+
path = lib/hypercerts-api
3+
url = http://github.com/hypercerts-org/hypercerts-api

.prettierignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# directories
2+
.yarn/
3+
**/.coverage_artifacts
4+
**/.coverage_cache
5+
**/.coverage_contracts
6+
**/artifacts
7+
**/broadcast
8+
**/build
9+
**/cache
10+
**/coverage
11+
**/dist
12+
**/lib
13+
**/node_modules
14+
**/out
15+
**/types
16+
**/deployments
17+
**/.openzeppelin
18+
**/.graphclient
19+
**/__generated__
20+
21+
# files
22+
*.env
23+
*.log
24+
.pnp.*
25+
coverage.json
26+
npm-debug.log*
27+
yarn-debug.log*
28+
yarn-error.log*

.prettierrc.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
bracketSpacing: true
2+
endOfLine: "auto"
3+
printWidth: 120
4+
proseWrap: "always"
5+
singleQuote: false
6+
tabWidth: 2
7+
trailingComma: "all"
8+
useTabs: false
9+
10+
overrides:
11+
- files: "*.sol"
12+
options:
13+
compiler: "0.8.17"
14+
tabWidth: 4
15+
- files: "*.ts"
16+
options:
17+
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]
18+
importOrderParserPlugins: ["importAssertions", "typescript"]
19+
importOrderSeparation: true
20+
importOrderSortSpecifiers: true

README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Hypercert SDK
2+
3+
## Quickstart Guide
4+
5+
1. Install the SDK using npm or yarn:
6+
7+
```bash
8+
pnpm install @hypercerts-org/sdk
9+
```
10+
11+
or
12+
13+
```bash
14+
pnpm add @hypercerts-org/sdk
15+
```
16+
17+
2. Import the SDK into your project:
18+
19+
```bash
20+
import { HypercertClient } from "@hypercerts-org/sdk";
21+
```
22+
23+
3. Create a new instance of the HypercertClient class with your configuration options:
24+
25+
```js
26+
const client = new HypercertClient({
27+
environment: "test",
28+
walletClient, // optional, client will default to read-only mode if not provided
29+
publicClient, // optional, can be infered from walletClient if present
30+
});
31+
```
32+
33+
> **Note** If there's no `walletClient` provided the client will run in [read-only mode](#read-only-mode)
34+
35+
4. Use the client object to interact with the Hypercert network.
36+
37+
For example, you can use the `client.mintClaim` method to create a new claim:
38+
39+
```ts
40+
const hash = await client.mintHypercert({
41+
metaData: { ... },
42+
totalUnits: 1000n,
43+
transferRestriction: TransferRestrictions.AllowAll,
44+
});
45+
```
46+
47+
This will validate the metadata, store it on IPFS, create a new hypercert on-chain and return a transaction receipt.
48+
49+
For more information on how to use the SDK, check out the
50+
[developer documentation](https://hypercerts.org/docs/developer/) and the
51+
[Graph playground](https://thegraph.com/hosted-service/subgraph/hypercerts-admin/hypercerts-testnet).
52+
53+
That's it! With these simple steps, you can start using the Hypercert SDK in your own projects.
54+
55+
## Config
56+
57+
HypercertClientConfig is a configuration object used when initializing a new instance of the HypercertClient. It allows
58+
you to customize the client by setting your own providers or deployments. At it's simplest, you only need to provide
59+
`chain.id` to initalize the client in `readonly` mode.
60+
61+
| Field | Type | Description |
62+
| -------------- | ------------------------ | -------------------------------------------------------------------------------------------- |
63+
| `environment` | `'test' \| 'production'` | Defines the environment the client will connect with. |
64+
| `deployments` | Object | The deployments of the contracts on various networks. |
65+
| `readOnly` | Boolean | Boolean to assert if the client is in read-only mode. |
66+
| `graphUrl` | String | The URL of the graph endpoint. |
67+
| `publicClient` | Object | The `PublicClient` is inherently read-only and is used for reading data from the blockchain. |
68+
| `walletClient` | Object | The `WalletClient` is used for signing and sending transactions. |
69+
70+
### Read-only mode
71+
72+
The SDK client will be in read-only mode if any of the following conditions are true:
73+
74+
- The client was initialized without a wallet client.
75+
- The client was initialized with a wallet client connected to a chain that is not supported in the environment.
76+
77+
### Logging
78+
79+
The logger for the SDK uses the log level based on the value of the LOG_LEVEL environment variable. The log level
80+
determines which log messages are printed to the console. By default, the logger is configured to log messages with a
81+
level of info or higher to the console.
82+
83+
## Modules
84+
85+
### Storage
86+
87+
The `storage` module is an utility service for easy access to the hypercerts API. It's built based on the OpenAPI spec
88+
exposed by the hypercerts API.
89+
90+
```js
91+
const client = new HypercertClient({
92+
environment: "test",
93+
walletClient, // optional, client will default to read-only mode if not provided
94+
publicClient, // optional, can be infered from walletClient if present
95+
});
96+
97+
const storage = client.storage;
98+
99+
const storageRequest = { metadata: {...}}
100+
const storageResponse = await client.storage.storeMetadata(storageRequest);
101+
```

0 commit comments

Comments
 (0)