@@ -14,11 +14,37 @@ mergeInto(LibraryManager.library, {
1414
1515 dynCall_vi ( cb , client . __destroy_into_raw ( ) ) ;
1616 } ,
17+ // Returns an array of all tokens
18+ GetTokens : async function ( clientPtr , contractAddresses , tokenIds , cb ) {
19+ const client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
20+ const tokens = await client . getTokens ( JSON . parse ( UTF8ToString ( contractAddresses ) ) , JSON . parse ( UTF8ToString ( tokenIds ) ) ) ;
21+
22+ const tokensString = JSON . stringify ( tokens ) ;
23+ const bufferSize = lengthBytesUTF8 ( tokensString ) + 1 ;
24+ const buffer = _malloc ( bufferSize ) ;
25+ stringToUTF8 ( tokensString , buffer , bufferSize ) ;
26+
27+ client . __destroy_into_raw ( ) ;
28+ dynCall_vi ( cb , buffer ) ;
29+ } ,
30+ // Returns an array of all token balances
31+ GetTokenBalances : async function ( clientPtr , contractAddresses , accountAddresses , tokenIds , cb ) {
32+ const client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
33+ const balances = await client . getTokenBalances ( JSON . parse ( UTF8ToString ( contractAddresses ) ) , JSON . parse ( UTF8ToString ( accountAddresses ) ) , JSON . parse ( UTF8ToString ( tokenIds ) ) ) ;
34+
35+ const balancesString = JSON . stringify ( balances ) ;
36+ const bufferSize = lengthBytesUTF8 ( balancesString ) + 1 ;
37+ const buffer = _malloc ( bufferSize ) ;
38+ stringToUTF8 ( balancesString , buffer , bufferSize ) ;
39+
40+ client . __destroy_into_raw ( ) ;
41+ dynCall_vi ( cb , buffer ) ;
42+ } ,
1743 // Returns a dictionary of all of the entities
18- GetEntities : async function ( clientPtr , queryString , cb ) {
44+ GetEntities : async function ( clientPtr , queryString , historical , cb ) {
1945 const client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
2046 const query = JSON . parse ( UTF8ToString ( queryString ) ) ;
21- let entities = await client . getEntities ( query ) ;
47+ let entities = await client . getEntities ( query , historical ) ;
2248
2349 // stringify the entities
2450 let entitiesString = JSON . stringify ( entities ) ;
@@ -31,10 +57,10 @@ mergeInto(LibraryManager.library, {
3157 dynCall_vi ( cb , buffer ) ;
3258 } ,
3359 // Returns a dictionary of all of the eventmessages
34- GetEventMessages : async function ( clientPtr , queryString , cb ) {
60+ GetEventMessages : async function ( clientPtr , queryString , historical , cb ) {
3561 const client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
3662 const query = JSON . parse ( UTF8ToString ( queryString ) ) ;
37- let entities = await client . getEventMessages ( query ) ;
63+ let entities = await client . getEventMessages ( query , historical ) ;
3864
3965 // stringify the entities
4066 let entitiesString = JSON . stringify ( entities ) ;
@@ -64,6 +90,43 @@ mergeInto(LibraryManager.library, {
6490 client . __destroy_into_raw ( ) ;
6591 dynCall_vi ( cb , buffer ) ;
6692 } ,
93+ OnTokenUpdated : async function ( clientPtr , contractAddresses , tokenIds , cb , subCb ) {
94+ const client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
95+ const subscription = await client . onTokenUpdated (
96+ JSON . parse ( UTF8ToString ( contractAddresses ) ) ,
97+ JSON . parse ( UTF8ToString ( tokenIds ) ) ,
98+ ( token ) => {
99+ const tokenString = JSON . stringify ( token ) ;
100+ const bufferSize = lengthBytesUTF8 ( tokenString ) + 1 ;
101+ const buffer = _malloc ( bufferSize ) ;
102+ stringToUTF8 ( tokenString , buffer , bufferSize ) ;
103+
104+ client . __destroy_into_raw ( ) ;
105+ dynCall_vi ( cb , buffer ) ;
106+ } ) ;
107+
108+ client . __destroy_into_raw ( ) ;
109+ dynCall_vi ( subCb , subscription . __destroy_into_raw ( ) ) ;
110+ } ,
111+ OnTokenBalanceUpdated : async function ( clientPtr , contractAddresses , accountAddresses , tokenIds , cb , subCb ) {
112+ const client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
113+ const subscription = await client . onTokenBalanceUpdated (
114+ JSON . parse ( UTF8ToString ( contractAddresses ) ) ,
115+ JSON . parse ( UTF8ToString ( accountAddresses ) ) ,
116+ JSON . parse ( UTF8ToString ( tokenIds ) ) ,
117+ ( balance ) => {
118+ const balanceString = JSON . stringify ( balance ) ;
119+ const bufferSize = lengthBytesUTF8 ( balanceString ) + 1 ;
120+ const buffer = _malloc ( bufferSize ) ;
121+ stringToUTF8 ( balanceString , buffer , bufferSize ) ;
122+
123+ client . __destroy_into_raw ( ) ;
124+ dynCall_vi ( cb , buffer ) ;
125+ } ) ;
126+
127+ client . __destroy_into_raw ( ) ;
128+ dynCall_vi ( subCb , subscription . __destroy_into_raw ( ) ) ;
129+ } ,
67130 OnEntityUpdated : async function ( clientPtr , clausesStr , cb , subCb ) {
68131 let client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
69132 let clauses = JSON . parse ( UTF8ToString ( clausesStr ) ) ;
@@ -95,14 +158,12 @@ mergeInto(LibraryManager.library, {
95158 client . __destroy_into_raw ( ) ;
96159 subscription . __destroy_into_raw ( ) ;
97160 } ,
98- OnEventMessageUpdated : async function ( clientPtr , clausesStr , historical , cb , subCb ) {
161+ OnEventMessageUpdated : async function ( clientPtr , clausesStr , cb , subCb ) {
99162 let client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
100163 let clauses = JSON . parse ( UTF8ToString ( clausesStr ) ) ;
101- console . log ( clauses ) ;
102164
103165 const subscription = await client . onEventMessageUpdated (
104166 clauses ,
105- historical ,
106167 ( hashed_keys , models ) => {
107168 // stringify the entities
108169 let modelsString = JSON . stringify ( models ) ;
@@ -121,12 +182,12 @@ mergeInto(LibraryManager.library, {
121182 client . __destroy_into_raw ( ) ;
122183 dynCall_vi ( subCb , subscription . __destroy_into_raw ( ) ) ;
123184 } ,
124- UpdateEventMessageSubscription : async function ( clientPtr , subPtr , clausesStr , historical ) {
185+ UpdateEventMessageSubscription : async function ( clientPtr , subPtr , clausesStr ) {
125186 let client = wasm_bindgen . ToriiClient . __wrap ( clientPtr ) ;
126187 let subscription = wasm_bindgen . Subscription . __wrap ( subPtr ) ;
127188 let clauses = JSON . parse ( UTF8ToString ( clausesStr ) ) ;
128189
129- await client . updateEventMessageSubscription ( subscription , clauses , historical ) ;
190+ await client . updateEventMessageSubscription ( subscription , clauses ) ;
130191
131192 client . __destroy_into_raw ( ) ;
132193 subscription . __destroy_into_raw ( ) ;
0 commit comments