@@ -73,8 +73,8 @@ describe("Prediction Market Contract - Full Privacy", () => {
7373 } , TEST_TIMEOUT )
7474
7575 test ( "should have initial 50/50 prices" , async ( ) => {
76- const yesPrice = await market . methods . get_price ( true ) . simulate ( { from : adminAddress } )
77- const noPrice = await market . methods . get_price ( false ) . simulate ( { from : adminAddress } )
76+ const { result : yesPrice } = await market . methods . get_price ( true ) . simulate ( { from : adminAddress } )
77+ const { result : noPrice } = await market . methods . get_price ( false ) . simulate ( { from : adminAddress } )
7878
7979 expect ( yesPrice ) . toBe ( PRICE_PRECISION / 2n )
8080 expect ( noPrice ) . toBe ( PRICE_PRECISION / 2n )
@@ -87,13 +87,13 @@ describe("Prediction Market Contract - Full Privacy", () => {
8787 const depositAmount = 2000n
8888
8989 // deposit() is now a PRIVATE function - creates private collateral notes
90- const tx = await market . methods . deposit ( depositAmount )
90+ const { receipt : tx } = await market . methods . deposit ( depositAmount )
9191 . send ( { from : aliceAddress } )
9292
9393 expect ( tx . executionResult ) . toBe ( 'success' )
9494
9595 // Collateral balance is now private (sums private notes)
96- const balance = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
96+ const { result : balance } = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
9797 expect ( balance ) . toBe ( depositAmount )
9898
9999 console . log ( `Alice deposited ${ depositAmount } PRIVATELY, balance: ${ balance } ` )
@@ -105,7 +105,7 @@ describe("Prediction Market Contract - Full Privacy", () => {
105105
106106 // buy_outcome consumes private collateral, creates partial note for shares
107107 // The public function does NOT receive Alice's address - FULL PRIVACY!
108- const tx = await market . methods . buy_outcome (
108+ const { receipt : tx } = await market . methods . buy_outcome (
109109 true , // is_yes
110110 buyAmount ,
111111 minShares ,
@@ -115,20 +115,20 @@ describe("Prediction Market Contract - Full Privacy", () => {
115115 console . log ( "Alice bought YES with FULL PRIVACY (public function doesn't know who)" )
116116
117117 // Check private collateral was deducted
118- const collateralBalance = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
118+ const { result : collateralBalance } = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
119119 expect ( collateralBalance ) . toBe ( 1500n ) // 2000 - 500
120120
121121 // Check private YES balance
122- const yesBalance = await market . methods . get_yes_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
122+ const { result : yesBalance } = await market . methods . get_yes_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
123123 expect ( yesBalance ) . toBeGreaterThanOrEqual ( minShares )
124124
125125 console . log ( `Alice's private collateral: ${ collateralBalance } ` )
126126 console . log ( `Alice's private YES balance: ${ yesBalance } ` )
127127 } , TEST_TIMEOUT )
128128
129129 test ( "YES price should have increased after alice's purchase" , async ( ) => {
130- const yesPrice = await market . methods . get_price ( true ) . simulate ( { from : adminAddress } )
131- const noPrice = await market . methods . get_price ( false ) . simulate ( { from : adminAddress } )
130+ const { result : yesPrice } = await market . methods . get_price ( true ) . simulate ( { from : adminAddress } )
131+ const { result : noPrice } = await market . methods . get_price ( false ) . simulate ( { from : adminAddress } )
132132
133133 expect ( yesPrice ) . toBeGreaterThan ( PRICE_PRECISION / 2n )
134134 expect ( noPrice ) . toBeLessThan ( PRICE_PRECISION / 2n )
@@ -149,7 +149,7 @@ describe("Prediction Market Contract - Full Privacy", () => {
149149 . send ( { from : bobAddress } )
150150
151151 // Bob buys NO with full privacy
152- const tx = await market . methods . buy_outcome (
152+ const { receipt : tx } = await market . methods . buy_outcome (
153153 false , // is_yes = false (NO)
154154 buyAmount ,
155155 0n , // no slippage protection for this test
@@ -158,17 +158,17 @@ describe("Prediction Market Contract - Full Privacy", () => {
158158 expect ( tx . executionResult ) . toBe ( 'success' )
159159 console . log ( "Bob bought NO with FULL PRIVACY" )
160160
161- const noBalance = await market . methods . get_no_balance ( bobAddress ) . simulate ( { from : bobAddress } )
161+ const { result : noBalance } = await market . methods . get_no_balance ( bobAddress ) . simulate ( { from : bobAddress } )
162162 expect ( noBalance ) . toBeGreaterThan ( 0n )
163163
164164 console . log ( `Bob's private NO balance: ${ noBalance } ` )
165165 } , TEST_TIMEOUT )
166166
167167 test ( "alice and bob should have separate private balances" , async ( ) => {
168- const aliceYes = await market . methods . get_yes_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
169- const aliceNo = await market . methods . get_no_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
170- const bobYes = await market . methods . get_yes_balance ( bobAddress ) . simulate ( { from : bobAddress } )
171- const bobNo = await market . methods . get_no_balance ( bobAddress ) . simulate ( { from : bobAddress } )
168+ const { result : aliceYes } = await market . methods . get_yes_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
169+ const { result : aliceNo } = await market . methods . get_no_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
170+ const { result : bobYes } = await market . methods . get_yes_balance ( bobAddress ) . simulate ( { from : bobAddress } )
171+ const { result : bobNo } = await market . methods . get_no_balance ( bobAddress ) . simulate ( { from : bobAddress } )
172172
173173 expect ( aliceYes ) . toBeGreaterThan ( 0n )
174174 expect ( aliceNo ) . toBe ( 0n )
@@ -180,24 +180,24 @@ describe("Prediction Market Contract - Full Privacy", () => {
180180 } , TEST_TIMEOUT )
181181
182182 test ( "alice should be able to withdraw remaining collateral PRIVATELY" , async ( ) => {
183- const balanceBefore = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
183+ const { result : balanceBefore } = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
184184 const withdrawAmount = 500n
185185
186186 // withdraw() is now a PRIVATE function
187- const tx = await market . methods . withdraw ( withdrawAmount )
187+ const { receipt : tx } = await market . methods . withdraw ( withdrawAmount )
188188 . send ( { from : aliceAddress } )
189189
190190 expect ( tx . executionResult ) . toBe ( 'success' )
191191
192- const balanceAfter = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
192+ const { result : balanceAfter } = await market . methods . get_collateral_balance ( aliceAddress ) . simulate ( { from : aliceAddress } )
193193 expect ( balanceAfter ) . toBe ( balanceBefore - withdrawAmount )
194194
195195 console . log ( `Alice withdrew ${ withdrawAmount } PRIVATELY, balance: ${ balanceAfter } ` )
196196 } , TEST_TIMEOUT )
197197
198198 test ( "prices should always sum to ~100%" , async ( ) => {
199- const yesPrice = await market . methods . get_price ( true ) . simulate ( { from : adminAddress } )
200- const noPrice = await market . methods . get_price ( false ) . simulate ( { from : adminAddress } )
199+ const { result : yesPrice } = await market . methods . get_price ( true ) . simulate ( { from : adminAddress } )
200+ const { result : noPrice } = await market . methods . get_price ( false ) . simulate ( { from : adminAddress } )
201201 // Allow for small rounding error (integer division)
202202 const priceSum = yesPrice + noPrice
203203 expect ( priceSum ) . toBeGreaterThanOrEqual ( PRICE_PRECISION - 1n )
0 commit comments