@psalomo/jsonrpc-client 0.5.0 → 1.0.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 +12 -12
- package/dist/browser-standalone.js +1685 -3655
- package/dist/browser-standalone.min.js +1 -1
- package/dist/client.d.ts +21 -20
- package/dist/client.d.ts.map +1 -1
- package/dist/{convenience.mini.d.ts → convenience.d.ts} +3 -3
- package/dist/convenience.d.ts.map +1 -0
- package/dist/{generated-functions.mini.d.ts → generated-functions.d.ts} +3 -3
- package/dist/generated-functions.d.ts.map +1 -0
- package/dist/generated-types.d.ts +29 -0
- package/dist/generated-types.d.ts.map +1 -1
- package/dist/index.d.mts +133 -71
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +335 -104
- package/dist/index.mjs +307 -109
- package/dist/{validation.mini.d.ts → validation.d.ts} +5 -3
- package/dist/validation.d.ts.map +1 -0
- package/package.json +1 -6
- package/dist/browser-standalone-mini.js +0 -1245
- package/dist/browser-standalone-mini.min.js +0 -1
- package/dist/client.mini.d.ts +0 -58
- package/dist/client.mini.d.ts.map +0 -1
- package/dist/convenience.mini.d.ts.map +0 -1
- package/dist/generated-functions.mini.d.ts.map +0 -1
- package/dist/generated-types.mini.d.ts +0 -84
- package/dist/generated-types.mini.d.ts.map +0 -1
- package/dist/index.mini.cjs +0 -421
- package/dist/index.mini.d.mts +0 -198
- package/dist/index.mini.d.ts +0 -10
- package/dist/index.mini.d.ts.map +0 -1
- package/dist/index.mini.mjs +0 -361
- package/dist/validation.mini.d.ts.map +0 -1
package/README.md
CHANGED
@@ -10,18 +10,18 @@ pnpm add @near-js/jsonrpc-client
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
Create a new client instance and
|
13
|
+
Create a new client instance and use the available RPC functions:
|
14
14
|
|
15
15
|
```typescript
|
16
|
-
import { NearRpcClient } from '@near-js/jsonrpc-client';
|
16
|
+
import { NearRpcClient, status } from '@near-js/jsonrpc-client';
|
17
17
|
|
18
18
|
const client = new NearRpcClient({
|
19
|
-
endpoint: 'https://rpc.mainnet.near.org'
|
19
|
+
endpoint: 'https://rpc.mainnet.near.org',
|
20
20
|
});
|
21
21
|
|
22
22
|
async function getNetworkStatus() {
|
23
|
-
const
|
24
|
-
console.log('Network status:',
|
23
|
+
const result = await status(client);
|
24
|
+
console.log('Network status:', result);
|
25
25
|
}
|
26
26
|
|
27
27
|
getNetworkStatus();
|
@@ -32,15 +32,15 @@ getNetworkStatus();
|
|
32
32
|
All method calls return a promise that resolves to a fully typed result object based on the JSON-RPC API specification.
|
33
33
|
|
34
34
|
```typescript
|
35
|
-
import { NearRpcClient } from '@near-js/jsonrpc-client';
|
35
|
+
import { NearRpcClient, block } from '@near-js/jsonrpc-client';
|
36
36
|
|
37
37
|
const client = new NearRpcClient({
|
38
|
-
endpoint: 'https://rpc.mainnet.near.org'
|
38
|
+
endpoint: 'https://rpc.mainnet.near.org',
|
39
39
|
});
|
40
40
|
|
41
41
|
async function getLatestBlock() {
|
42
|
-
const
|
43
|
-
console.log('Latest block height:',
|
42
|
+
const result = await block(client, { finality: 'final' });
|
43
|
+
console.log('Latest block height:', result.header?.height);
|
44
44
|
}
|
45
45
|
|
46
46
|
getLatestBlock();
|
@@ -54,7 +54,7 @@ The client includes convenience methods for common query operations:
|
|
54
54
|
// View account information
|
55
55
|
const account = await client.viewAccount({
|
56
56
|
accountId: 'example.near',
|
57
|
-
finality: 'final'
|
57
|
+
finality: 'final',
|
58
58
|
});
|
59
59
|
console.log('Account balance:', account.amount);
|
60
60
|
console.log('Storage used:', account.storageUsage);
|
@@ -63,14 +63,14 @@ console.log('Storage used:', account.storageUsage);
|
|
63
63
|
const result = await client.viewFunction({
|
64
64
|
accountId: 'contract.near',
|
65
65
|
methodName: 'get_balance',
|
66
|
-
finality: 'final'
|
66
|
+
finality: 'final',
|
67
67
|
});
|
68
68
|
|
69
69
|
// View access keys
|
70
70
|
const accessKey = await client.viewAccessKey({
|
71
71
|
accountId: 'example.near',
|
72
72
|
publicKey: 'ed25519:...',
|
73
|
-
finality: 'final'
|
73
|
+
finality: 'final',
|
74
74
|
});
|
75
75
|
```
|
76
76
|
|