@@ -33,7 +33,7 @@ yarn add @windingtree/sdk ethers
33
33
The peer key is part of p2p security schema. It uses for peer identification and establishing secured connections between peers.
34
34
35
35
``` typescript
36
- import { generatePeerKey } from ' @windingtree. sdk' ;
36
+ import { generatePeerKey } from ' @windingtree/ sdk' ;
37
37
38
38
await generatePeerKey ();
39
39
/*
@@ -74,7 +74,7 @@ const options: ServerOptions = {
74
74
address: ' 0.0.0.0' ,
75
75
port: 33333 ,
76
76
peerKey ,
77
- messagesStorageInit: storage .memoryStorage .init (),
77
+ messagesStorageInit: storage .memoryStorage .createInitializer (),
78
78
};
79
79
```
80
80
@@ -83,19 +83,23 @@ const options: ServerOptions = {
83
83
A base options type definitions:
84
84
85
85
``` typescript
86
- type NodeOptions <
87
- CustomRequestQuery extends GenericQuery ,
88
- CustomOfferOptions extends GenericOfferOptions ,
89
- > = {
86
+ /** smart contract configuration */
87
+ interface ContractConfig {
88
+ /** Smart contract name */
89
+ name: string ;
90
+ /** Internal smart contract version */
91
+ version: string ;
92
+ /** Chain Id */
93
+ chainId: BigNumberish ;
94
+ /** Smart contract address */
95
+ address: string ;
96
+ }
97
+
98
+ type NodeOptions = {
90
99
/** Period while the node waits and accepting requests with the same Id */
91
100
noncePeriod: number ;
92
101
/** The protocol smart contract configuration */
93
- contractConfig: {
94
- address: string ;
95
- name: string ;
96
- version: string ;
97
- chainId: string | number | bigint ;
98
- };
102
+ contractConfig: ContractConfig ;
99
103
/** Multiaddr of the coordination server */
100
104
serverAddress: string ;
101
105
/** Seed phrase of the node signer wallet */
@@ -104,14 +108,10 @@ type NodeOptions<
104
108
topics: string [];
105
109
/** Unique supplier Id */
106
110
supplierId: string ;
107
- /** Query validation schema */
108
- querySchema: ZodType <CustomRequestQuery >;
109
- /** Offer options validation schema instance */
110
- offerOptionsSchema: ZodType <CustomOfferOptions >;
111
111
/** Ethers.js provider instance */
112
- provider? : AbstractProvider | undefined ;
112
+ provider? : AbstractProvider ;
113
113
/** Additional Libp2p initialization options */
114
- libp2p? : Libp2pOptions | undefined ;
114
+ libp2p? : Libp2pInit ;
115
115
};
116
116
```
117
117
@@ -120,19 +120,9 @@ Here is an example of a supplier node configuration:
120
120
``` typescript
121
121
import { NodeOptions } from ' @windingtree/sdk' ;
122
122
import { latLngToCell } from ' @windingtree/sdk/utils' ;
123
- import {
124
- RequestQuerySchema ,
125
- OfferOptionsSchema ,
126
- RequestQuery ,
127
- OfferOptions ,
128
- supplierId ,
129
- signerSeedPhrase ,
130
- coordinates ,
131
- } from ' ./config.js' ;
123
+ import { supplierId , signerSeedPhrase , coordinates } from ' ./config.js' ;
132
124
133
- const options: NodeOptions <RequestQuery , OfferOptions > = {
134
- querySchema: RequestQuerySchema , // zod schema
135
- offerOptionsSchema: OfferOptionsSchema , // zod schema
125
+ const options: NodeOptions = {
136
126
topics: [' hello' , latLngToCell (coordinates )],
137
127
contractConfig: {
138
128
name: ' WtMarket' ,
@@ -150,31 +140,19 @@ const options: NodeOptions<RequestQuery, OfferOptions> = {
150
140
### Client node
151
141
152
142
``` typescript
153
- type ClientOptionsClientOptions <
154
- CustomRequestQuery extends GenericQuery ,
155
- CustomOfferOptions extends GenericOfferOptions ,
156
- > = {
143
+ type ClientOptions = {
157
144
/** The protocol smart contract configuration */
158
- contractConfig: {
159
- address: string ;
160
- name: string ;
161
- version: string ;
162
- chainId: string | number | bigint ;
163
- };
145
+ contractConfig: ContractConfig ; // See details in the supplier node section
164
146
/** Multiaddr of the coordination server */
165
147
serverAddress: string ;
166
- /** Query validation schema */
167
- querySchema: ZodType <CustomRequestQuery >;
168
- /** Offer options validation schema instance */
169
- offerOptionsSchema: ZodType <CustomOfferOptions >;
170
148
/** Client key-value storage initializer */
171
149
storageInitializer: (... args : unknown []) => Promise <Storage >;
172
150
/** Request registry keys prefix */
173
151
requestRegistryPrefix: string ;
174
152
/** Ethers.js provider instance */
175
- provider? : AbstractProvider | undefined ;
153
+ provider? : AbstractProvider ;
176
154
/** Additional Libp2p initialization options */
177
- libp2p? : Libp2pOptions | undefined ;
155
+ libp2p? : Libp2pInit ;
178
156
};
179
157
```
180
158
@@ -183,19 +161,16 @@ Here is an example of a client configuration:
183
161
``` typescript
184
162
import { Wallet } from ' ethers' ;
185
163
import { ClientOptions , storage } from ' @windingtree/sdk' ;
186
- import { RequestQuerySchema , OfferOptionsSchema , RequestQuery , OfferOptions } from ' ./config.js' ;
187
164
188
- const options: ClientOptions <RequestQuery , OfferOptions > = {
189
- querySchema: RequestQuerySchema ,
190
- offerOptionsSchema: OfferOptionsSchema ,
165
+ const options: ClientOptions = {
191
166
contractConfig: {
192
167
name: ' WtMarket' ,
193
168
version: ' 1' ,
194
169
chainId: ' 1' ,
195
170
address: ' 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266' ,
196
171
},
197
172
serverAddress: ' /ip4/127.0.0.1/tcp/33333/ws/p2p/QmcXbDr...jgEuWPCf' ,
198
- storageInitializer: storage .localStorage .init ({
173
+ storageInitializer: storage .localStorage .createInitializer ({
199
174
session: true ,
200
175
}),
201
176
requestRegistryPrefix: ' requestsRegistry' ,
@@ -204,6 +179,6 @@ const options: ClientOptions<RequestQuery, OfferOptions> = {
204
179
205
180
## SDK development
206
181
207
- - WindingTree Discord server, [ developers channel ] ( https://discord .com/channels/898350336069218334/956614058323370014 )
182
+ - [ WindingTree protocol discussions ] ( https://github .com/windingtree/sdk/discussions )
208
183
- Bug tracker: [ https://github.com/windingtree/sdk/issues ] ( https://github.com/windingtree/sdk/issues )
209
184
- [ Contribution] ( /docs/contribution.md )
0 commit comments