-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3077 from moreal/feat/js/tx-metadata-provider
feat(js): introduce `@planetarium/9c-headless-provider`
- Loading branch information
Showing
23 changed files
with
7,055 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"deno.enable": true | ||
} |
1 change: 1 addition & 0 deletions
1
integrations/javascript/@planetarium/9c-headless-provider/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/generated |
661 changes: 661 additions & 0 deletions
661
integrations/javascript/@planetarium/9c-headless-provider/LICENSE
Large diffs are not rendered by default.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
integrations/javascript/@planetarium/9c-headless-provider/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
21 changes: 21 additions & 0 deletions
21
integrations/javascript/@planetarium/9c-headless-provider/biome.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
integrations/javascript/@planetarium/9c-headless-provider/graphql/headless/api.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
integrations/javascript/@planetarium/9c-headless-provider/graphql/headless/codegen.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.