@@ -3,12 +3,12 @@ This is a JS SDK is intended for browser based applications that need to interac
3
3
4
4
## Initialization
5
5
```
6
- npm i --save three0- js-sdk
6
+ npm i --save @three0dev/ js-sdk
7
7
```
8
8
## Usage
9
9
1 . Import Three0 and prepare configuration
10
10
```
11
- import init from 'three0- js-sdk'
11
+ import { init } from '@three0dev/ js-sdk'
12
12
13
13
const config = {
14
14
"contractName": "myTestContract",
@@ -19,6 +19,7 @@ const config = {
19
19
2 . Initialize SDK
20
20
- - - -
21
21
### React
22
+ #### React >=18
22
23
```
23
24
import React from 'react'
24
25
import { createRoot } from 'react-dom/client'
@@ -30,6 +31,20 @@ init(config).then(() => {
30
31
root.render(<App />)
31
32
}).catch(console.error)
32
33
```
34
+ #### React <18
35
+ ```
36
+ import React from 'react'
37
+ import { render } from 'react-dom'
38
+ import App from './App'
39
+
40
+ init(env.config)
41
+ .then(() => {
42
+ render(
43
+ <App />,
44
+ document.getElementById("root")
45
+ );
46
+ }).catch(console.error)
47
+ ```
33
48
### Vue
34
49
```
35
50
import { createApp } from 'vue';
@@ -52,24 +67,22 @@ WIP: Pending Bug Fixes and CDN Compatibility
52
67
## Services
53
68
### Auth
54
69
```
55
- import { login, logout, isloggedIn, getAccountId } from 'three0- js-sdk'
70
+ import { Auth } from '@three0dev/ js-sdk'
56
71
```
57
- * ` login():Promise<void> `
72
+ * ` Auth. login():Promise<void>`
58
73
* Logs into dApp using NEAR Wallet
59
74
* Creates new user on NEAR blockchain if user doesn't exist
60
- * ` logout():Promise<void> `
75
+ * ` Auth. logout():Promise<void>`
61
76
* Logs out of dApp
62
- * ` isLoggedIn():boolean `
77
+ * ` Auth. isLoggedIn():boolean`
63
78
* Returns ` true ` if user is logged in
64
- * ` getAccountId():string `
79
+ * ` Auth. getAccountId():string`
65
80
* Returns user account ID
66
81
### Database
67
-
82
+ import { Database } from 'three0-js-sdk'
68
83
#### ** DocStore** :
69
84
```
70
- import { DocStore } from 'three0-js-sdk'
71
-
72
- const docstore = await DocStore([address])
85
+ const docstore = await Database.DocStore([address])
73
86
```
74
87
* ` docstore.get(key:string):any `
75
88
* Gets value from docstore
@@ -88,9 +101,7 @@ const docstore = await DocStore([address])
88
101
* Deletes value from docstore
89
102
#### ** KeyValue** :
90
103
```
91
- import { KeyValue } from 'three0-js-sdk/database'
92
-
93
- const keyvalue = await KeyValue([address])
104
+ const keyvalue = await Database.KeyValue([address])
94
105
```
95
106
* ` keyvalue.get(key:string):any `
96
107
* Gets value from database
@@ -103,9 +114,7 @@ const keyvalue = await KeyValue([address])
103
114
* Deletes value from database
104
115
#### ** Counter** :
105
116
```
106
- import { Counter } from 'three0-js-sdk/database'
107
-
108
- const counter = await Counter([address])
117
+ const counter = await Database.Counter([address])
109
118
```
110
119
* ` counter.get():number `
111
120
* Gets current value of counter
0 commit comments