Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 83b1d06

Browse files
feat: add gno-js-client docs (#25)
1 parent 73282d8 commit 83b1d06

File tree

9 files changed

+232
-7
lines changed

9 files changed

+232
-7
lines changed

docs/gno-js-client/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# To be added
1+
# gno-js-client
2+
3+
This section will provide an overview and basic features of `gno-js-client`.
4+
5+
* [Getting Started](getting-started.md)
6+
* [Provider](provider/)
7+
* [Wallet](wallet/)

docs/gno-js-client/getting-started.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Getting Started
2+
3+
`@gnolang/gno-js-client` is a JavaScript/TypeScript client implementation for Gno chains. It is an extension of the
4+
[tm2-js-client](https://github.com/gnolang/tm2-js-client), but with Gno-specific functionality.
5+
6+
## Key Features
7+
8+
- Provides the ability to interact with Gno Realms / Packages
9+
- Easy interaction with VM-specific ABCI queries
10+
11+
## Installation
12+
13+
To install `@gnolang/gno-js-client`, use your preferred package manager:
14+
15+
```bash
16+
yarn add @gnolang/gno-js-client
17+
```
18+
19+
```bash
20+
npm install @gnolang/gno-js-client
21+
```

docs/gno-js-client/provider/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Provider
2+
3+
* [Gno Provider](gno-provider.md)
+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
## Gno Provider
2+
3+
The `Gno Provider` is an extension on the `tm2-js-client` `Provider`,
4+
outlined [here](../../tm2-js-client/provider/provider.md). Both JSON-RPC and WS providers are included with the package.
5+
6+
## Realm Methods
7+
8+
### getRenderOutput
9+
10+
Executes the Render(<path>) method in read-only mode
11+
12+
#### Parameters
13+
14+
* `packagePath` **string** the gno package path
15+
* `path` **string** the render path
16+
* `height` **number** the height for querying.
17+
If omitted, the latest height is used (optional, default `0`)
18+
19+
Returns **Promise\<string>**
20+
21+
#### Usage
22+
23+
```ts
24+
await provider.getRenderOutput('gno.land/r/demo/demo_realm', '');
25+
// ## Hello World!
26+
```
27+
28+
### getFunctionSignatures
29+
30+
Fetches public facing function signatures
31+
32+
#### Parameters
33+
34+
* `packagePath` **string** the gno package path
35+
* `height` **number** the height for querying.
36+
If omitted, the latest height is used (optional, default `0`)
37+
38+
Returns **Promise\<FunctionSignature[]>**
39+
40+
#### Usage
41+
42+
```ts
43+
await provider.getFunctionSignatures('gno.land/r/demo/foo20');
44+
/*
45+
[
46+
{ FuncName: 'TotalSupply', Params: null, Results: [ [Object] ] },
47+
{
48+
FuncName: 'BalanceOf',
49+
Params: [ [Object] ],
50+
Results: [ [Object] ]
51+
},
52+
{
53+
FuncName: 'Allowance',
54+
Params: [ [Object], [Object] ],
55+
Results: [ [Object] ]
56+
},
57+
{
58+
FuncName: 'Transfer',
59+
Params: [ [Object], [Object] ],
60+
Results: null
61+
},
62+
{
63+
FuncName: 'Approve',
64+
Params: [ [Object], [Object] ],
65+
Results: null
66+
},
67+
{
68+
FuncName: 'TransferFrom',
69+
Params: [ [Object], [Object], [Object] ],
70+
Results: null
71+
},
72+
{ FuncName: 'Faucet', Params: null, Results: null },
73+
{ FuncName: 'Mint', Params: [ [Object], [Object] ], Results: null },
74+
{ FuncName: 'Burn', Params: [ [Object], [Object] ], Results: null },
75+
{ FuncName: 'Render', Params: [ [Object] ], Results: [ [Object] ] }
76+
]
77+
*/
78+
```
79+
80+
### evaluateExpression
81+
82+
Evaluates any expression in readonly mode and returns the results
83+
84+
#### Parameters
85+
86+
* `packagePath` **string** the gno package path
87+
* `expression` **string** the expression to be evaluated
88+
* `height` **number** the height for querying.
89+
If omitted, the latest height is used (optional, default `0`)
90+
91+
Returns **Promise\<string>**
92+
93+
#### Usage
94+
95+
```ts
96+
await provider.evaluateExpression('gno.land/r/demo/foo20', 'TotalSupply()')
97+
// (10100000000 uint64)
98+
```
99+
100+
### getFileContent
101+
102+
Fetches the file content, or the list of files if the path is a directory
103+
104+
#### Parameters
105+
106+
* `packagePath` **string** the gno package path
107+
* `height` **number** the height for querying.
108+
If omitted, the latest height is used (optional, default `0`)
109+
110+
Returns **Promise\<string>**
111+
112+
#### Usage
113+
114+
```ts
115+
await provider.getFileContent('gno.land/r/demo/foo20', 'TotalSupply()')
116+
/*
117+
foo20.gno
118+
foo20_test.gno
119+
*/
120+
```

docs/gno-js-client/wallet/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Wallet
2+
3+
* [Gno Wallet](gno-wallet.md)
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
## Gno Wallet
2+
3+
The `Gno Wallet` is an extension on the `tm2-js-client` `Wallet`, outlined [here](../../tm2-js-client/wallet/wallet.md).
4+
5+
## Account Methods
6+
7+
### transferFunds
8+
9+
Initiates a native currency transfer transaction between accounts
10+
11+
#### Parameters
12+
13+
* `to` **string** the bech32 address of the receiver
14+
* `funds` **Map\<string, number>** the denomination -> value map for funds
15+
* `fee` **TxFee** the custom transaction fee, if any
16+
17+
Returns **Promise\<string>**
18+
19+
#### Usage
20+
21+
```ts
22+
let fundsMap = new Map<string, number>([
23+
["ugnot", 10],
24+
]);
25+
26+
await wallet.transferFunds('g1flk9z2qmkgqeyrl654r3639rzgz7xczdfwwqw7', fundsMap);
27+
// returns the transaction hash
28+
```
29+
30+
### callMethod
31+
32+
Invokes the specified method on a GNO contract
33+
34+
#### Parameters
35+
36+
* `path` **string** the gno package / realm path
37+
* `method` **string** the method name
38+
* `args` **string[]** the method arguments, if any
39+
* `funds` **Map\<string, number>** the denomination -> value map for funds
40+
* `fee` **TxFee** the custom transaction fee, if any
41+
42+
Returns **Promise\<string>**
43+
44+
#### Usage
45+
46+
```ts
47+
let fundsMap = new Map<string, number>([
48+
["ugnot", 10],
49+
]);
50+
51+
await wallet.callMethod('gno.land/r/demo/foo20', 'TotalBalance', []);
52+
// returns the transaction hash
53+
```
54+
55+
### deployPackage
56+
57+
Deploys the specified package / realm
58+
59+
#### Parameters
60+
61+
* `gnoPackage` **MemPackage** the package / realm to be deployed
62+
* `funds` **Map\<string, number>** the denomination -> value map for funds
63+
* `fee` **TxFee** the custom transaction fee, if any
64+
65+
Returns **Promise\<string>**
66+
67+
#### Usage
68+
69+
```ts
70+
const memPackage: MemPackage = // ...
71+
72+
await wallet.deployPackage(memPackage);
73+
// returns the transaction hash
74+
```

docs/tm2-js-client/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tm2-js-client
22

3-
This section will provide an overview and basic features of tm2-js-client.
3+
This section will provide an overview and basic features of `tm2-js-client`.
44

55
* [Getting-Started](getting-started.md)
66
* [Provider](provider/)

docs/tm2-js-client/provider/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Provider
22

3-
* [json-rpc-provider](json-rpc-provider.md)
43
* [Provider](provider.md)
5-
* [Utility](utility.md)
6-
* [Ws-provider](ws-provider.md)
4+
* [JSON-RPC Provider](json-rpc-provider.md)
5+
* [WS Provider](ws-provider.md)
6+
* [Utility](utility.md)

docs/tm2-js-client/provider/provider.md

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ Currently, the `tm2-js-client` package provides support for two Provider impleme
1111
- [WS Provider](ws-provider.md): executes each call through an active WebSocket connection, which requires closing when
1212
not needed anymore.
1313

14-
Read-only abstraction for accessing blockchain data
15-
1614
## Account Methods
1715

1816
### getBalance

0 commit comments

Comments
 (0)