@algorandfoundation/algokit-client-generator 2.4.0-beta.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,31 @@ The cli can be used to generate a client via the following command.
|
|
|
20
20
|
npx --yes @algorandfoundation/algokit-client-generator generate -a ./application.json -o ./client.generated.ts
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
Alternatively, a client can be generated from code by invoking the `generate` function paired with either `writeDocumentPartsToString` or `writeDocumentPartsToStream` depending on your needs. We also expose helpers to optionally load and validate an application.json file.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import fs from 'fs
|
|
27
|
+
import {
|
|
28
|
+
writeDocumentPartsToStream,
|
|
29
|
+
writeDocumentPartsToString,
|
|
30
|
+
generate,
|
|
31
|
+
loadApplicationJson,
|
|
32
|
+
validateApplicationJson
|
|
33
|
+
} from '@algorandfoundation/algokit-client-generator'
|
|
34
|
+
import appJson from './application.json'
|
|
35
|
+
|
|
36
|
+
const appJsonFromFile = loadApplicationJson('./application.json')
|
|
37
|
+
const appJsonFromObject = validateApplicationJson(appJson)
|
|
38
|
+
|
|
39
|
+
const fileStream = fs.createWriteStream('./client.ts', {
|
|
40
|
+
flags: 'w',
|
|
41
|
+
})
|
|
42
|
+
writeDocumentPartsToStream(generate(appJsonFromFile, fileStream)
|
|
43
|
+
|
|
44
|
+
const clientAsString = writeDocumentPartsToString(appJsonFromObject)
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
23
48
|
For details on how to use the generated client see the more detailed [usage docs](./docs/usage.md)
|
|
24
49
|
|
|
25
50
|
## Examples
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"main": "index.js",
|
|
3
3
|
"types": "index.d.ts",
|
|
4
4
|
"name": "@algorandfoundation/algokit-client-generator",
|
|
5
|
-
"version": "2.4.0
|
|
5
|
+
"version": "2.4.0",
|
|
6
6
|
"description": "Generates a TypeScript client for interacting with, and deploying ARC-0032 smart contracts on the Algorand Blockchain.",
|
|
7
7
|
"private": false,
|
|
8
8
|
"bin": {
|