@@ -33,7 +33,7 @@ yarn add @windingtree/sdk ethers
3333The peer key is part of p2p security schema. It uses for peer identification and establishing secured connections between peers.
3434
3535``` typescript
36- import { generatePeerKey } from ' @windingtree. sdk' ;
36+ import { generatePeerKey } from ' @windingtree/ sdk' ;
3737
3838await generatePeerKey ();
3939/*
@@ -74,7 +74,7 @@ const options: ServerOptions = {
7474 address: ' 0.0.0.0' ,
7575 port: 33333 ,
7676 peerKey ,
77- messagesStorageInit: storage .memoryStorage .init (),
77+ messagesStorageInit: storage .memoryStorage .createInitializer (),
7878};
7979```
8080
@@ -83,19 +83,23 @@ const options: ServerOptions = {
8383A base options type definitions:
8484
8585``` 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 = {
9099 /** Period while the node waits and accepting requests with the same Id */
91100 noncePeriod: number ;
92101 /** 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 ;
99103 /** Multiaddr of the coordination server */
100104 serverAddress: string ;
101105 /** Seed phrase of the node signer wallet */
@@ -104,14 +108,10 @@ type NodeOptions<
104108 topics: string [];
105109 /** Unique supplier Id */
106110 supplierId: string ;
107- /** Query validation schema */
108- querySchema: ZodType <CustomRequestQuery >;
109- /** Offer options validation schema instance */
110- offerOptionsSchema: ZodType <CustomOfferOptions >;
111111 /** Ethers.js provider instance */
112- provider? : AbstractProvider | undefined ;
112+ provider? : AbstractProvider ;
113113 /** Additional Libp2p initialization options */
114- libp2p? : Libp2pOptions | undefined ;
114+ libp2p? : Libp2pInit ;
115115};
116116```
117117
@@ -120,19 +120,9 @@ Here is an example of a supplier node configuration:
120120``` typescript
121121import { NodeOptions } from ' @windingtree/sdk' ;
122122import { 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' ;
132124
133- const options: NodeOptions <RequestQuery , OfferOptions > = {
134- querySchema: RequestQuerySchema , // zod schema
135- offerOptionsSchema: OfferOptionsSchema , // zod schema
125+ const options: NodeOptions = {
136126 topics: [' hello' , latLngToCell (coordinates )],
137127 contractConfig: {
138128 name: ' WtMarket' ,
@@ -150,31 +140,19 @@ const options: NodeOptions<RequestQuery, OfferOptions> = {
150140### Client node
151141
152142``` typescript
153- type ClientOptionsClientOptions <
154- CustomRequestQuery extends GenericQuery ,
155- CustomOfferOptions extends GenericOfferOptions ,
156- > = {
143+ type ClientOptions = {
157144 /** 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
164146 /** Multiaddr of the coordination server */
165147 serverAddress: string ;
166- /** Query validation schema */
167- querySchema: ZodType <CustomRequestQuery >;
168- /** Offer options validation schema instance */
169- offerOptionsSchema: ZodType <CustomOfferOptions >;
170148 /** Client key-value storage initializer */
171149 storageInitializer: (... args : unknown []) => Promise <Storage >;
172150 /** Request registry keys prefix */
173151 requestRegistryPrefix: string ;
174152 /** Ethers.js provider instance */
175- provider? : AbstractProvider | undefined ;
153+ provider? : AbstractProvider ;
176154 /** Additional Libp2p initialization options */
177- libp2p? : Libp2pOptions | undefined ;
155+ libp2p? : Libp2pInit ;
178156};
179157```
180158
@@ -183,19 +161,16 @@ Here is an example of a client configuration:
183161``` typescript
184162import { Wallet } from ' ethers' ;
185163import { ClientOptions , storage } from ' @windingtree/sdk' ;
186- import { RequestQuerySchema , OfferOptionsSchema , RequestQuery , OfferOptions } from ' ./config.js' ;
187164
188- const options: ClientOptions <RequestQuery , OfferOptions > = {
189- querySchema: RequestQuerySchema ,
190- offerOptionsSchema: OfferOptionsSchema ,
165+ const options: ClientOptions = {
191166 contractConfig: {
192167 name: ' WtMarket' ,
193168 version: ' 1' ,
194169 chainId: ' 1' ,
195170 address: ' 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266' ,
196171 },
197172 serverAddress: ' /ip4/127.0.0.1/tcp/33333/ws/p2p/QmcXbDr...jgEuWPCf' ,
198- storageInitializer: storage .localStorage .init ({
173+ storageInitializer: storage .localStorage .createInitializer ({
199174 session: true ,
200175 }),
201176 requestRegistryPrefix: ' requestsRegistry' ,
@@ -204,6 +179,6 @@ const options: ClientOptions<RequestQuery, OfferOptions> = {
204179
205180## SDK development
206181
207- - WindingTree Discord server, [ developers channel ] ( https://discord .com/channels/898350336069218334/956614058323370014 )
182+ - [ WindingTree protocol discussions ] ( https://github .com/windingtree/sdk/discussions )
208183- Bug tracker: [ https://github.com/windingtree/sdk/issues ] ( https://github.com/windingtree/sdk/issues )
209184- [ Contribution] ( /docs/contribution.md )
0 commit comments