@@ -35,7 +35,6 @@ $ npm install verto-cace-interface
35
35
36
36
** Usage** :
37
37
``` typescript
38
-
39
38
import { fetchContract } from ' verto-cace-interface' ;
40
39
41
40
fetchContract (' t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y-BPZgKE' ).then ((result ) => {
@@ -55,7 +54,6 @@ fetchContract('t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y-BPZgKE').then((result) => {
55
54
56
55
** Usage** :
57
56
``` typescript
58
-
59
57
import { fetchBalanceByUserAddress } from ' verto-cace-interface' ;
60
58
61
59
fetchBalanceByUserAddress (' vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU' ).then ((result ) => {
@@ -96,7 +94,6 @@ fetchBalancesForAddress('vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU').then((res
96
94
97
95
** Usage** :
98
96
``` typescript
99
-
100
97
import { fetchBalancesInContract } from ' verto-cace-interface' ;
101
98
102
99
fetchBalancesInContract (' bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY' ).then ((result ) => {
@@ -118,7 +115,6 @@ fetchBalancesInContract('bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY').then((res
118
115
119
116
** Usage** :
120
117
``` typescript
121
-
122
118
import { fetchCollectionById } from ' verto-cace-interface' ;
123
119
124
120
fetchCollectionById (' GirFtyB_PI4oQXhEFrHZLpFUqincHrDdDxPaQ1M8r00' ).then ((result ) => {
@@ -141,7 +137,6 @@ fetchCollectionById('GirFtyB_PI4oQXhEFrHZLpFUqincHrDdDxPaQ1M8r00').then((result)
141
137
142
138
** Usage** :
143
139
``` typescript
144
-
145
140
import { fetchContractsInUser } from ' verto-cace-interface' ;
146
141
147
142
fetchContractsInUser (' vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU' ).then ((result ) => {
@@ -160,7 +155,6 @@ fetchContractsInUser('vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU').then((result
160
155
161
156
** Usage** :
162
157
``` typescript
163
-
164
158
import { fetchOwnershipByUsername } from ' verto-cace-interface' ;
165
159
166
160
fetchOwnershipByUsername (' t8' ).then ((result ) => {
@@ -180,7 +174,6 @@ fetchOwnershipByUsername('t8').then((result) => {
180
174
181
175
** Usage** :
182
176
``` typescript
183
-
184
177
import { fetchTokenMetadata } from ' verto-cace-interface' ;
185
178
186
179
fetchTokenMetadata (' bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY' ).then ((result ) => {
@@ -200,7 +193,6 @@ fetchTokenMetadata('bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY').then((result)
200
193
201
194
** Usage** :
202
195
``` typescript
203
-
204
196
import { fetchTokenStateMetadata } from ' verto-cace-interface' ;
205
197
206
198
fetchTokenStateMetadata (' bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY' ).then ((result ) => {
@@ -222,7 +214,6 @@ fetchTokenStateMetadata('bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY').then((res
222
214
** Usage** :
223
215
224
216
``` typescript
225
-
226
217
import { fetchTokens } from ' verto-cace-interface' ;
227
218
228
219
fetchTokens ().then ((result ) => {
@@ -245,7 +236,6 @@ fetchTokens().then((result) => {
245
236
246
237
** Usage** :
247
238
``` typescript
248
-
249
239
import { fetchRandomArtwork } from ' verto-cace-interface' ;
250
240
251
241
fetchRandomArtwork ().then ((result ) => {
@@ -269,7 +259,6 @@ fetchRandomArtwork().then((result) => {
269
259
270
260
** Usage** :
271
261
``` typescript
272
-
273
262
import { fetchUserCreations } from ' verto-cace-interface' ;
274
263
275
264
fetchUserCreations (' t8' ).then ((result ) => {
@@ -288,7 +277,6 @@ fetchUserCreations('t8').then((result) => {
288
277
289
278
** Usage** :
290
279
``` typescript
291
-
292
280
import { fetchUserMetadataByUsername } from ' verto-cace-interface' ;
293
281
294
282
fetchUserMetadataByUsername (' t8' ).then ((result ) => {
@@ -304,7 +292,6 @@ fetchUserMetadataByUsername('t8').then((result) => {
304
292
305
293
** Usage** :
306
294
``` typescript
307
-
308
295
import { fetchUsers } from ' verto-cace-interface' ;
309
296
310
297
fetchUsers ().then ((result ) => {
@@ -319,3 +306,40 @@ fetchUsers().then((result) => {
319
306
})
320
307
```
321
308
309
+
310
+ ## Hooks
311
+ Hooks are a way to invoke functions and then invoke certain behaviors inside the cache system.
312
+
313
+
314
+ ### ` cacheContractHook `
315
+
316
+ ** Signature** :
317
+ `cacheContractHook = async (action: () => Promise<any > | any,
318
+ contractId?: string,
319
+ refreshCommunityContract?: boolean)`
320
+
321
+ ** Parameters** :
322
+ * action* : Action to be called inside before executing the hook
323
+ * contractId* : Contract to be cached right after ` action ` has finished its execution
324
+ * refreshCommunityContract* : Whether the community contract should be updated after ` action ` has finished its execution
325
+
326
+ ** Usage** :
327
+
328
+ ``` typescript
329
+ import { cacheContractHook } from ' verto-cace-interface' ;
330
+
331
+ const currentContract: string = ' ABCD1234'
332
+
333
+ const executeOrder = await cacheContractHook (async () => {
334
+ // Execute an order inside the exchange
335
+ // Or do something different, maybe buy a car.
336
+ return ' ORDER_SENT' ;
337
+ }, currentContract , true );
338
+
339
+ assert (executeOrder === ' ORDER_SENT' );
340
+ ```
341
+
342
+ ** Lifecycle** :
343
+ 1 ) Execute ` action ` (if asynchronous, it will be awaited)
344
+ 2 ) Call Cache API to invoke caching of ` contractId `
345
+ 3 ) if ` refreshCommunityContract ` is ` true ` , call Cache API to invoke caching of community contract
0 commit comments