@@ -35,7 +35,6 @@ $ npm install verto-cace-interface
3535
3636** Usage** :
3737``` typescript
38-
3938import { fetchContract } from ' verto-cace-interface' ;
4039
4140fetchContract (' t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y-BPZgKE' ).then ((result ) => {
@@ -55,7 +54,6 @@ fetchContract('t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y-BPZgKE').then((result) => {
5554
5655** Usage** :
5756``` typescript
58-
5957import { fetchBalanceByUserAddress } from ' verto-cace-interface' ;
6058
6159fetchBalanceByUserAddress (' vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU' ).then ((result ) => {
@@ -96,7 +94,6 @@ fetchBalancesForAddress('vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU').then((res
9694
9795** Usage** :
9896``` typescript
99-
10097import { fetchBalancesInContract } from ' verto-cace-interface' ;
10198
10299fetchBalancesInContract (' bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY' ).then ((result ) => {
@@ -118,7 +115,6 @@ fetchBalancesInContract('bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY').then((res
118115
119116** Usage** :
120117``` typescript
121-
122118import { fetchCollectionById } from ' verto-cace-interface' ;
123119
124120fetchCollectionById (' GirFtyB_PI4oQXhEFrHZLpFUqincHrDdDxPaQ1M8r00' ).then ((result ) => {
@@ -141,7 +137,6 @@ fetchCollectionById('GirFtyB_PI4oQXhEFrHZLpFUqincHrDdDxPaQ1M8r00').then((result)
141137
142138** Usage** :
143139``` typescript
144-
145140import { fetchContractsInUser } from ' verto-cace-interface' ;
146141
147142fetchContractsInUser (' vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU' ).then ((result ) => {
@@ -160,7 +155,6 @@ fetchContractsInUser('vxUdiv2fGHMiIoek5E4l3M5qSuKCZtSaOBYjMRc94JU').then((result
160155
161156** Usage** :
162157``` typescript
163-
164158import { fetchOwnershipByUsername } from ' verto-cace-interface' ;
165159
166160fetchOwnershipByUsername (' t8' ).then ((result ) => {
@@ -180,7 +174,6 @@ fetchOwnershipByUsername('t8').then((result) => {
180174
181175** Usage** :
182176``` typescript
183-
184177import { fetchTokenMetadata } from ' verto-cace-interface' ;
185178
186179fetchTokenMetadata (' bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY' ).then ((result ) => {
@@ -200,7 +193,6 @@ fetchTokenMetadata('bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY').then((result)
200193
201194** Usage** :
202195``` typescript
203-
204196import { fetchTokenStateMetadata } from ' verto-cace-interface' ;
205197
206198fetchTokenStateMetadata (' bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY' ).then ((result ) => {
@@ -222,7 +214,6 @@ fetchTokenStateMetadata('bQGRi3eO4p7S583mYYXDeVn5EvGPFMiMWd5WBWatteY').then((res
222214** Usage** :
223215
224216``` typescript
225-
226217import { fetchTokens } from ' verto-cace-interface' ;
227218
228219fetchTokens ().then ((result ) => {
@@ -245,7 +236,6 @@ fetchTokens().then((result) => {
245236
246237** Usage** :
247238``` typescript
248-
249239import { fetchRandomArtwork } from ' verto-cace-interface' ;
250240
251241fetchRandomArtwork ().then ((result ) => {
@@ -269,7 +259,6 @@ fetchRandomArtwork().then((result) => {
269259
270260** Usage** :
271261``` typescript
272-
273262import { fetchUserCreations } from ' verto-cace-interface' ;
274263
275264fetchUserCreations (' t8' ).then ((result ) => {
@@ -288,7 +277,6 @@ fetchUserCreations('t8').then((result) => {
288277
289278** Usage** :
290279``` typescript
291-
292280import { fetchUserMetadataByUsername } from ' verto-cace-interface' ;
293281
294282fetchUserMetadataByUsername (' t8' ).then ((result ) => {
@@ -304,7 +292,6 @@ fetchUserMetadataByUsername('t8').then((result) => {
304292
305293** Usage** :
306294``` typescript
307-
308295import { fetchUsers } from ' verto-cace-interface' ;
309296
310297fetchUsers ().then ((result ) => {
@@ -319,3 +306,40 @@ fetchUsers().then((result) => {
319306})
320307```
321308
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