Skip to content

Commit

Permalink
Merge pull request #3077 from moreal/feat/js/tx-metadata-provider
Browse files Browse the repository at this point in the history
feat(js): introduce `@planetarium/9c-headless-provider`
  • Loading branch information
moreal authored Dec 9, 2024
2 parents b0e1829 + b405a8d commit c53a061
Show file tree
Hide file tree
Showing 23 changed files with 7,055 additions and 103 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ jobs:
cwd: "integrations/javascript/@planetarium"
- name: Build Lib9c.Tools
run: dotnet build .Lib9c.Tools/Lib9c.Tools.csproj
- run: pnpm -r codegen
working-directory: "integrations/javascript/@planetarium"
- run: pnpm -r build
working-directory: "integrations/javascript/@planetarium/lib9c"
working-directory: "integrations/javascript/@planetarium"
- run: pnpm -r fmt:ci
working-directory: "integrations/javascript/@planetarium/lib9c"
working-directory: "integrations/javascript/@planetarium"
- run: pnpm -r test
working-directory: "integrations/javascript/@planetarium/lib9c"
working-directory: "integrations/javascript/@planetarium"

release:
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ jobs:
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
jsr:
strategy:
matrix:
package: [ "lib9c", "9c-headless-provider" ]
name: "jsr (@planetarium/${{ matrix.package }})"
uses: planetarium/.github/.github/workflows/publish_jsr.yaml@bfb34283b538003768d19bff9ea05bcbd709d643
with:
workspace_directory: "integrations/javascript/@planetarium"
working_directory: "integrations/javascript/@planetarium/lib9c"
working_directory: "integrations/javascript/@planetarium/${{ matrix.package }}"
pnpm_version: "9"
3 changes: 3 additions & 0 deletions integrations/javascript/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/generated
661 changes: 661 additions & 0 deletions integrations/javascript/@planetarium/9c-headless-provider/LICENSE

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @planetarium/9c-headless-provider

A library to provide `TxMetadataProvider` implementation for [NineChronicles.Headless][9c-headless].

[9c-headless]: https://github.com/planetarium/NineChronicles

## Usage Example

```typescript
import { HeadlessClient } from "@planetarium/9c-headless-provider";
import { RawPrivateKey, Address } from "@planetarium/account";
import { signTx } from "@planetarium/tx";
import { makeTx, ClaimStakeReward } from "@planetarium/lib9c";

const headlessClient = new HeadlessClient("https://9c-main-full-state.nine-chronicles.com/graphql");
const account = RawPrivateKey.generate(); // Temporary private key key.

const unsignedTx = await makeTx(account, headlessClient, new ClaimStakeReward({
avatarAddress: Address.fromHex('<ADDRESS>'),
}));

console.log(unsignedTx);

const signedTx = await signTx(unsignedTx, account);

console.log(signedTx);

const txId = await headlessClient.stageTransaction(signedTx);

console.log(txId);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"linter": {
"enabled": true,
"rules": {
"style": {
"useNodejsImportProtocol": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"files": {
"ignore": [
"src/generated"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mutation StageTransaction($tx: String!) {
stageTransaction(payload: $tx)
}

query GetNextNonce($address: Address!) {
nextTxNonce(address: $address)
}

query GetGenesisHash {
nodeStatus {
genesis {
hash
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
overwrite: true
schema: ./graphql/headless/schema.graphql
documents: ./graphql/headless/api.graphql
generates:
src/generated/headless/graphql-request.ts:
plugins:
- typescript
- typescript-operations
- typescript-graphql-request
Loading

0 comments on commit c53a061

Please sign in to comment.