@@ -47,7 +47,7 @@ impl Contract {
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
50- let signer_storage_required = storage_amount. saturating_mul ( ( self . get_supply_by_owner_id ( owner_id. clone ( ) ) + 1 ) . into ( ) ) ;
50+ 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 ! (
@@ -145,7 +145,7 @@ impl Contract {
145145 self . process_purchase (
146146 contract_id,
147147 token_id,
148- deposit,
148+ U128 ( deposit. as_yoctonear ( ) ) ,
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 : NearToken ,
160+ price : U128 ,
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 : NearToken ,
207- ) -> NearToken {
206+ price : U128 ,
207+ ) -> U128 {
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;
224+ let mut remainder = price. 0 ;
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) ?;
229+ remainder = remainder. checked_sub ( value. as_yoctonear ( ) ) ?;
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. is_zero ( ) || remainder. eq ( & ONE_YOCTONEAR ) {
234+ if remainder == 0 || remainder == 1 {
235235 //set the payout_option to be the payout because nothing went wrong
236236 Some ( payout_object. payout )
237237 } else {
@@ -247,7 +247,7 @@ 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 ( price) ;
250+ Promise :: new ( buyer_id) . transfer ( NearToken :: from_yoctonear ( u128 :: from ( price) ) ) ;
251251 // leave function and return the price that was refunded
252252 return price;
253253 } ;
0 commit comments