@@ -43,15 +43,15 @@ impl Contract {
4343 //we need to enforce that the user has enough storage for 1 EXTRA sale.
4444
4545 //get the storage for a sale
46- let storage_amount = self . storage_minimum_balance ( ) . 0 ;
46+ let storage_amount = self . storage_minimum_balance ( ) ;
4747 //get the total storage paid by the owner
4848 let owner_paid_storage = self . storage_deposits . get ( & owner_id) . unwrap_or ( ZERO_NEAR ) ;
4949 //get the storage required which is simply the storage for the number of sales they have + 1
5050 let signer_storage_required = storage_amount. saturating_mul ( ( self . get_supply_by_owner_id ( owner_id. clone ( ) ) . 0 + 1 ) . into ( ) ) ;
5151
5252 //make sure that the total paid is >= the required storage
5353 assert ! (
54- owner_paid_storage. ge( & NearToken :: from_yoctonear ( signer_storage_required) ) ,
54+ owner_paid_storage. ge( & signer_storage_required) ,
5555 "Insufficient storage paid: {}, for {} sales at {} rate of per sale" ,
5656 owner_paid_storage, signer_storage_required. saturating_div( storage_per_sale( ) . as_yoctonear( ) ) , storage_per_sale( )
5757 ) ;
@@ -92,7 +92,7 @@ impl Contract {
9292 & mut self ,
9393 nft_contract_id : AccountId ,
9494 token_id : String ,
95- price : U128 ,
95+ price : NearToken ,
9696 ) {
9797 //assert that the user has attached exactly 1 yoctoNEAR (for security reasons)
9898 assert_one_yocto ( ) ;
@@ -112,7 +112,7 @@ impl Contract {
112112 ) ;
113113
114114 //set the sale conditions equal to the passed in price
115- sale. sale_conditions = NearToken :: from_yoctonear ( price. 0 ) ;
115+ sale. sale_conditions = price;
116116 //insert the sale back into the map for the unique sale ID
117117 self . sales . insert ( & contract_and_token_id, & sale) ;
118118 }
@@ -145,7 +145,7 @@ impl Contract {
145145 self . process_purchase (
146146 contract_id,
147147 token_id,
148- U128 ( deposit. as_yoctonear ( ) ) ,
148+ deposit,
149149 buyer_id,
150150 ) ;
151151 }
@@ -157,7 +157,7 @@ impl Contract {
157157 & mut self ,
158158 nft_contract_id : AccountId ,
159159 token_id : String ,
160- price : U128 ,
160+ price : NearToken ,
161161 buyer_id : AccountId ,
162162 ) -> Promise {
163163 //get the sale object by removing the sale
@@ -203,8 +203,8 @@ impl Contract {
203203 pub fn resolve_purchase (
204204 & mut self ,
205205 buyer_id : AccountId ,
206- price : U128 ,
207- ) -> U128 {
206+ price : NearToken ,
207+ ) -> NearToken {
208208 // checking for payout information returned from the nft_transfer_payout method
209209 let payout_option = promise_result_as_success ( ) . and_then ( |value| {
210210 //if we set the payout_option to None, that means something went wrong and we should refund the buyer
@@ -221,17 +221,17 @@ impl Contract {
221221 //if the payout object is the correct length, we move forward
222222 } else {
223223 //we'll keep track of how much the nft contract wants us to payout. Starting at the full price payed by the buyer
224- let mut remainder = price. 0 ;
224+ let mut remainder = price;
225225
226226 //loop through the payout and subtract the values from the remainder.
227227 for & value in payout_object. payout . values ( ) {
228228 //checked sub checks for overflow or any errors and returns None if there are problems
229- remainder = remainder. checked_sub ( value. 0 ) ?;
229+ remainder = remainder. checked_sub ( value) ?;
230230 }
231231 //Check to see if the NFT contract sent back a faulty payout that requires us to pay more or too little.
232232 //The remainder will be 0 if the payout summed to the total price. The remainder will be 1 if the royalties
233233 //we something like 3333 + 3333 + 3333.
234- if remainder == 0 || remainder == 1 {
234+ if remainder. eq ( & ZERO_NEAR ) || remainder. eq ( & NearToken :: from_yoctonear ( 1 ) ) {
235235 //set the payout_option to be the payout because nothing went wrong
236236 Some ( payout_object. payout )
237237 } else {
@@ -247,14 +247,14 @@ impl Contract {
247247 payout_option
248248 //if the payout option was None, we refund the buyer for the price they payed and return
249249 } else {
250- Promise :: new ( buyer_id) . transfer ( NearToken :: from_yoctonear ( u128 :: from ( price) ) ) ;
250+ Promise :: new ( buyer_id) . transfer ( price) ;
251251 // leave function and return the price that was refunded
252252 return price;
253253 } ;
254254
255255 // NEAR payouts
256256 for ( receiver_id, amount) in payout {
257- Promise :: new ( receiver_id) . transfer ( NearToken :: from_yoctonear ( amount. 0 ) ) ;
257+ Promise :: new ( receiver_id) . transfer ( amount) ;
258258 }
259259
260260 //return the price payout out
0 commit comments