11import type { Asset , gtxn , uint64 } from '@algorandfoundation/algorand-typescript'
2- import { arc4 , assert , BoxMap , Global , itxn , op , Txn } from '@algorandfoundation/algorand-typescript'
2+ import { arc4 , assert , BoxMap , clone , Global , itxn , op , Txn } from '@algorandfoundation/algorand-typescript'
33
44export class ListingKey extends arc4 . Struct < {
55 owner : arc4 . Address
@@ -111,7 +111,7 @@ export default class DigitalMarketplace extends arc4.Contract {
111111 assert ( xfer . assetReceiver === Global . currentApplicationAddress )
112112 assert ( xfer . assetAmount > 0 )
113113
114- const existing = this . listings ( key ) . value . copy ( )
114+ const existing = clone ( this . listings ( key ) . value )
115115 this . listings ( key ) . value = new ListingValue ( {
116116 bid : existing . bid ,
117117 bidUnitaryPrice : existing . bidUnitaryPrice ,
@@ -129,7 +129,7 @@ export default class DigitalMarketplace extends arc4.Contract {
129129 nonce : nonce ,
130130 } )
131131
132- const existing = this . listings ( key ) . value . copy ( )
132+ const existing = clone ( this . listings ( key ) . value )
133133 this . listings ( key ) . value = new ListingValue ( {
134134 bid : existing . bid ,
135135 bidUnitaryPrice : existing . bidUnitaryPrice ,
@@ -147,7 +147,7 @@ export default class DigitalMarketplace extends arc4.Contract {
147147 nonce : nonce ,
148148 } )
149149
150- const listing = this . listings ( key ) . value . copy ( )
150+ const listing = clone ( this . listings ( key ) . value )
151151
152152 const amountToBePaid = this . quantityPrice ( quantity , listing . unitaryPrice . native , asset . decimals )
153153
@@ -180,7 +180,7 @@ export default class DigitalMarketplace extends arc4.Contract {
180180 nonce : nonce ,
181181 } )
182182
183- const listing = this . listings ( key ) . value . copy ( )
183+ const listing = clone ( this . listings ( key ) . value )
184184 if ( listing . bidder !== new arc4 . Address ( ) ) {
185185 const currentBidDeposit = this . quantityPrice ( listing . bid . native , listing . bidUnitaryPrice . native , asset . decimals )
186186 itxn . payment ( { receiver : listing . bidder . native , amount : currentBidDeposit } ) . submit ( )
@@ -203,7 +203,7 @@ export default class DigitalMarketplace extends arc4.Contract {
203203 bid ( owner : arc4 . Address , asset : Asset , nonce : arc4 . UintN64 , bidPay : gtxn . PaymentTxn , quantity : arc4 . UintN64 , unitaryPrice : arc4 . UintN64 ) {
204204 const key = new ListingKey ( { owner, asset : new arc4 . UintN64 ( asset . id ) , nonce } )
205205
206- const listing = this . listings ( key ) . value . copy ( )
206+ const listing = clone ( this . listings ( key ) . value )
207207 if ( listing . bidder !== new arc4 . Address ( ) ) {
208208 assert ( unitaryPrice . native > listing . bidUnitaryPrice . native )
209209
@@ -231,7 +231,7 @@ export default class DigitalMarketplace extends arc4.Contract {
231231 acceptBid ( asset : Asset , nonce : arc4 . UintN64 ) {
232232 const key = new ListingKey ( { owner : new arc4 . Address ( Txn . sender ) , asset : new arc4 . UintN64 ( asset . id ) , nonce } )
233233
234- const listing = this . listings ( key ) . value . copy ( )
234+ const listing = clone ( this . listings ( key ) . value )
235235 assert ( listing . bidder !== new arc4 . Address ( ) )
236236
237237 const minQuantity = listing . deposited . native < listing . bid . native ? listing . deposited . native : listing . bid . native
0 commit comments