@medialane/sdk 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,12 +4,12 @@ import { cairo, num, Contract, TypedDataRevision, shortString, constants, RpcPro
4
4
  // src/config.ts
5
5
 
6
6
  // src/constants.ts
7
- var MARKETPLACE_721_CONTRACT_MAINNET = "0x00f8ccaae0bc811c79605974cc1dab769b9cea8877f033f8e3c17f30457caba6";
8
- var MARKETPLACE_721_CLASS_HASH_MAINNET = "0x03dff4f34b976207246207954263be9a28b51390321702443291088dcdf4b2e6";
9
- var MARKETPLACE_721_START_BLOCK_MAINNET = 9196722;
10
- var MARKETPLACE_1155_CONTRACT_MAINNET = "0x02bfa521c25461a09d735889b469418608d7d92f8b26e3d37ef174a4c2e22f99";
11
- var MARKETPLACE_1155_CLASS_HASH_MAINNET = "0x01b674aad934be85abc7c1970265cbf7e9bc7d586a90f0a67112c201636dbdd3";
12
- var MARKETPLACE_1155_START_BLOCK_MAINNET = 9260304;
7
+ var MARKETPLACE_721_CONTRACT_MAINNET = "0x069cf5391077e3ebdd9cb6aebf90ed530d29f0d6aa34a43f5afae938c0fb565e";
8
+ var MARKETPLACE_721_CLASS_HASH_MAINNET = "0x04c6f952d747ad7ead1b3dad4c1d587837d38f8ec29d6c095a4afa5b5ece5957";
9
+ var MARKETPLACE_721_START_BLOCK_MAINNET = 10350340;
10
+ var MARKETPLACE_1155_CONTRACT_MAINNET = "0x040cd7b3e73bb3c892166e34bdc01d1797f97ecbc356c23f1cf38033cacf0077";
11
+ var MARKETPLACE_1155_CLASS_HASH_MAINNET = "0x02600bb720908f119afe482309d36c39d087587f0df9576454acfb6363e78cd8";
12
+ var MARKETPLACE_1155_START_BLOCK_MAINNET = 10350855;
13
13
  var COLLECTION_721_CONTRACT_MAINNET = "0x0322cb7119955e01ac778d40976eb3ba50540bb0899f812d612f9c7e63e49fd2";
14
14
  var IPNFT_CLASS_HASH_MAINNET = "0x27ee4ded786d51bced1e94afec3034d6ffce71c032c45ee1ff283ccfa9db12e";
15
15
  var IPCOLLECTION_CLASS_HASH_MAINNET = "0x287ccdff8b6655a2248cfe170d82eae3a35303cd00ef3e751b25ddca26d9095";
@@ -136,34 +136,33 @@ var OFFER_ITEM = [
136
136
  { name: "item_type", type: "shortstring" },
137
137
  { name: "token", type: "ContractAddress" },
138
138
  { name: "identifier_or_criteria", type: "felt" },
139
- { name: "start_amount", type: "felt" },
140
- { name: "end_amount", type: "felt" }
139
+ { name: "amount", type: "felt" }
141
140
  ];
142
141
  var CONSIDERATION_ITEM = [
143
142
  { name: "item_type", type: "shortstring" },
144
143
  { name: "token", type: "ContractAddress" },
145
144
  { name: "identifier_or_criteria", type: "felt" },
146
- { name: "start_amount", type: "felt" },
147
- { name: "end_amount", type: "felt" },
145
+ { name: "amount", type: "felt" },
148
146
  { name: "recipient", type: "ContractAddress" }
149
147
  ];
150
148
  var ORDER_PARAMETERS = [
151
149
  { name: "offerer", type: "ContractAddress" },
150
+ { name: "marketplace", type: "ContractAddress" },
152
151
  { name: "offer", type: "OfferItem" },
153
152
  { name: "consideration", type: "ConsiderationItem" },
153
+ { name: "royalty_max_bps", type: "felt" },
154
154
  { name: "start_time", type: "felt" },
155
155
  { name: "end_time", type: "felt" },
156
156
  { name: "salt", type: "felt" },
157
- { name: "nonce", type: "felt" }
157
+ { name: "counter", type: "felt" }
158
158
  ];
159
159
  var ORDER_CANCELLATION = [
160
160
  { name: "order_hash", type: "felt" },
161
- { name: "offerer", type: "ContractAddress" },
162
- { name: "nonce", type: "felt" }
161
+ { name: "offerer", type: "ContractAddress" }
163
162
  ];
164
163
  var DOMAIN_VERSION = {
165
- erc721: "1",
166
- erc1155: "2"
164
+ erc721: "4",
165
+ erc1155: "3"
167
166
  };
168
167
  function buildDomain(standard, chainId) {
169
168
  return {
@@ -199,37 +198,6 @@ function build1155OrderTypedData(message, chainId) {
199
198
  message
200
199
  };
201
200
  }
202
- function buildFulfillmentTypedData(message, chainId) {
203
- return {
204
- domain: buildDomain("erc721", chainId),
205
- primaryType: "OrderFulfillment",
206
- types: {
207
- StarknetDomain: STARKNET_DOMAIN,
208
- OrderFulfillment: [
209
- { name: "order_hash", type: "felt" },
210
- { name: "fulfiller", type: "ContractAddress" },
211
- { name: "nonce", type: "felt" }
212
- ]
213
- },
214
- message
215
- };
216
- }
217
- function build1155FulfillmentTypedData(message, chainId) {
218
- return {
219
- domain: buildDomain("erc1155", chainId),
220
- primaryType: "OrderFulfillment",
221
- types: {
222
- StarknetDomain: STARKNET_DOMAIN,
223
- OrderFulfillment: [
224
- { name: "order_hash", type: "felt" },
225
- { name: "fulfiller", type: "ContractAddress" },
226
- { name: "quantity", type: "felt" },
227
- { name: "nonce", type: "felt" }
228
- ]
229
- },
230
- message
231
- };
232
- }
233
201
  function buildCancellationTypedData(message, chainId) {
234
202
  return {
235
203
  domain: buildDomain("erc721", chainId),
@@ -280,306 +248,466 @@ function encodeByteArray(str) {
280
248
  // src/abis/ipMarketplace.ts
281
249
  var IPMarketplaceABI = [
282
250
  {
283
- type: "impl",
284
- name: "UpgradeableImpl",
285
- interface_name: "openzeppelin_upgrades::interface::IUpgradeable"
251
+ "type": "impl",
252
+ "name": "Medialane721Impl",
253
+ "interface_name": "medialane_marketplace_erc721::core::interface::IMedialane"
286
254
  },
287
255
  {
288
- type: "interface",
289
- name: "openzeppelin_upgrades::interface::IUpgradeable",
290
- items: [
256
+ "type": "struct",
257
+ "name": "medialane_marketplace_erc721::core::types::OfferItem",
258
+ "members": [
259
+ {
260
+ "name": "item_type",
261
+ "type": "core::felt252"
262
+ },
291
263
  {
292
- type: "function",
293
- name: "upgrade",
294
- inputs: [{ name: "new_class_hash", type: "core::starknet::class_hash::ClassHash" }],
295
- outputs: [],
296
- state_mutability: "external"
264
+ "name": "token",
265
+ "type": "core::starknet::contract_address::ContractAddress"
266
+ },
267
+ {
268
+ "name": "identifier_or_criteria",
269
+ "type": "core::felt252"
270
+ },
271
+ {
272
+ "name": "amount",
273
+ "type": "core::felt252"
297
274
  }
298
275
  ]
299
276
  },
300
277
  {
301
- type: "impl",
302
- name: "MedialaneImpl",
303
- interface_name: "mediolano_core::core::interface::IMedialane"
304
- },
305
- {
306
- type: "struct",
307
- name: "mediolano_core::core::types::OfferItem",
308
- members: [
309
- { name: "item_type", type: "core::felt252" },
310
- { name: "token", type: "core::starknet::contract_address::ContractAddress" },
311
- { name: "identifier_or_criteria", type: "core::felt252" },
312
- { name: "start_amount", type: "core::felt252" },
313
- { name: "end_amount", type: "core::felt252" }
278
+ "type": "struct",
279
+ "name": "medialane_marketplace_erc721::core::types::ConsiderationItem",
280
+ "members": [
281
+ {
282
+ "name": "item_type",
283
+ "type": "core::felt252"
284
+ },
285
+ {
286
+ "name": "token",
287
+ "type": "core::starknet::contract_address::ContractAddress"
288
+ },
289
+ {
290
+ "name": "identifier_or_criteria",
291
+ "type": "core::felt252"
292
+ },
293
+ {
294
+ "name": "amount",
295
+ "type": "core::felt252"
296
+ },
297
+ {
298
+ "name": "recipient",
299
+ "type": "core::starknet::contract_address::ContractAddress"
300
+ }
314
301
  ]
315
302
  },
316
303
  {
317
- type: "struct",
318
- name: "mediolano_core::core::types::ConsiderationItem",
319
- members: [
320
- { name: "item_type", type: "core::felt252" },
321
- { name: "token", type: "core::starknet::contract_address::ContractAddress" },
322
- { name: "identifier_or_criteria", type: "core::felt252" },
323
- { name: "start_amount", type: "core::felt252" },
324
- { name: "end_amount", type: "core::felt252" },
325
- { name: "recipient", type: "core::starknet::contract_address::ContractAddress" }
304
+ "type": "struct",
305
+ "name": "medialane_marketplace_erc721::core::types::OrderParameters",
306
+ "members": [
307
+ {
308
+ "name": "offerer",
309
+ "type": "core::starknet::contract_address::ContractAddress"
310
+ },
311
+ {
312
+ "name": "marketplace",
313
+ "type": "core::starknet::contract_address::ContractAddress"
314
+ },
315
+ {
316
+ "name": "offer",
317
+ "type": "medialane_marketplace_erc721::core::types::OfferItem"
318
+ },
319
+ {
320
+ "name": "consideration",
321
+ "type": "medialane_marketplace_erc721::core::types::ConsiderationItem"
322
+ },
323
+ {
324
+ "name": "royalty_max_bps",
325
+ "type": "core::felt252"
326
+ },
327
+ {
328
+ "name": "start_time",
329
+ "type": "core::felt252"
330
+ },
331
+ {
332
+ "name": "end_time",
333
+ "type": "core::felt252"
334
+ },
335
+ {
336
+ "name": "salt",
337
+ "type": "core::felt252"
338
+ },
339
+ {
340
+ "name": "counter",
341
+ "type": "core::felt252"
342
+ }
326
343
  ]
327
344
  },
328
345
  {
329
- type: "struct",
330
- name: "mediolano_core::core::types::OrderParameters",
331
- members: [
332
- { name: "offerer", type: "core::starknet::contract_address::ContractAddress" },
333
- { name: "offer", type: "mediolano_core::core::types::OfferItem" },
334
- { name: "consideration", type: "mediolano_core::core::types::ConsiderationItem" },
335
- { name: "start_time", type: "core::felt252" },
336
- { name: "end_time", type: "core::felt252" },
337
- { name: "salt", type: "core::felt252" },
338
- { name: "nonce", type: "core::felt252" }
346
+ "type": "struct",
347
+ "name": "medialane_marketplace_erc721::core::types::Order",
348
+ "members": [
349
+ {
350
+ "name": "parameters",
351
+ "type": "medialane_marketplace_erc721::core::types::OrderParameters"
352
+ },
353
+ {
354
+ "name": "signature",
355
+ "type": "core::array::Array::<core::felt252>"
356
+ }
339
357
  ]
340
358
  },
341
359
  {
342
- type: "struct",
343
- name: "mediolano_core::core::types::Order",
344
- members: [
345
- { name: "parameters", type: "mediolano_core::core::types::OrderParameters" },
346
- { name: "signature", type: "core::array::Array::<core::felt252>" }
360
+ "type": "struct",
361
+ "name": "medialane_marketplace_erc721::core::types::OrderCancellation",
362
+ "members": [
363
+ {
364
+ "name": "order_hash",
365
+ "type": "core::felt252"
366
+ },
367
+ {
368
+ "name": "offerer",
369
+ "type": "core::starknet::contract_address::ContractAddress"
370
+ }
347
371
  ]
348
372
  },
349
373
  {
350
- type: "struct",
351
- name: "mediolano_core::core::types::OrderFulfillment",
352
- members: [
353
- { name: "order_hash", type: "core::felt252" },
354
- { name: "fulfiller", type: "core::starknet::contract_address::ContractAddress" },
355
- { name: "nonce", type: "core::felt252" }
374
+ "type": "struct",
375
+ "name": "medialane_marketplace_erc721::core::types::CancelRequest",
376
+ "members": [
377
+ {
378
+ "name": "cancelation",
379
+ "type": "medialane_marketplace_erc721::core::types::OrderCancellation"
380
+ },
381
+ {
382
+ "name": "signature",
383
+ "type": "core::array::Array::<core::felt252>"
384
+ }
356
385
  ]
357
386
  },
358
387
  {
359
- type: "struct",
360
- name: "mediolano_core::core::types::FulfillmentRequest",
361
- members: [
362
- { name: "fulfillment", type: "mediolano_core::core::types::OrderFulfillment" },
363
- { name: "signature", type: "core::array::Array::<core::felt252>" }
388
+ "type": "enum",
389
+ "name": "medialane_marketplace_erc721::core::types::OrderStatus",
390
+ "variants": [
391
+ {
392
+ "name": "None",
393
+ "type": "()"
394
+ },
395
+ {
396
+ "name": "Created",
397
+ "type": "()"
398
+ },
399
+ {
400
+ "name": "Filled",
401
+ "type": "()"
402
+ },
403
+ {
404
+ "name": "Cancelled",
405
+ "type": "()"
406
+ }
364
407
  ]
365
408
  },
366
409
  {
367
- type: "struct",
368
- name: "mediolano_core::core::types::OrderCancellation",
369
- members: [
370
- { name: "order_hash", type: "core::felt252" },
371
- { name: "offerer", type: "core::starknet::contract_address::ContractAddress" },
372
- { name: "nonce", type: "core::felt252" }
410
+ "type": "struct",
411
+ "name": "medialane_marketplace_erc721::core::types::OrderDetails",
412
+ "members": [
413
+ {
414
+ "name": "offerer",
415
+ "type": "core::starknet::contract_address::ContractAddress"
416
+ },
417
+ {
418
+ "name": "offer",
419
+ "type": "medialane_marketplace_erc721::core::types::OfferItem"
420
+ },
421
+ {
422
+ "name": "consideration",
423
+ "type": "medialane_marketplace_erc721::core::types::ConsiderationItem"
424
+ },
425
+ {
426
+ "name": "royalty_max_bps",
427
+ "type": "core::felt252"
428
+ },
429
+ {
430
+ "name": "start_time",
431
+ "type": "core::integer::u64"
432
+ },
433
+ {
434
+ "name": "end_time",
435
+ "type": "core::integer::u64"
436
+ },
437
+ {
438
+ "name": "order_status",
439
+ "type": "medialane_marketplace_erc721::core::types::OrderStatus"
440
+ }
373
441
  ]
374
442
  },
375
443
  {
376
- type: "struct",
377
- name: "mediolano_core::core::types::CancelRequest",
378
- members: [
379
- { name: "cancelation", type: "mediolano_core::core::types::OrderCancellation" },
380
- { name: "signature", type: "core::array::Array::<core::felt252>" }
444
+ "type": "interface",
445
+ "name": "medialane_marketplace_erc721::core::interface::IMedialane",
446
+ "items": [
447
+ {
448
+ "type": "function",
449
+ "name": "register_order",
450
+ "inputs": [
451
+ {
452
+ "name": "order",
453
+ "type": "medialane_marketplace_erc721::core::types::Order"
454
+ }
455
+ ],
456
+ "outputs": [],
457
+ "state_mutability": "external"
458
+ },
459
+ {
460
+ "type": "function",
461
+ "name": "fulfill_order",
462
+ "inputs": [
463
+ {
464
+ "name": "order_hash",
465
+ "type": "core::felt252"
466
+ }
467
+ ],
468
+ "outputs": [],
469
+ "state_mutability": "external"
470
+ },
471
+ {
472
+ "type": "function",
473
+ "name": "cancel_order",
474
+ "inputs": [
475
+ {
476
+ "name": "cancel_request",
477
+ "type": "medialane_marketplace_erc721::core::types::CancelRequest"
478
+ }
479
+ ],
480
+ "outputs": [],
481
+ "state_mutability": "external"
482
+ },
483
+ {
484
+ "type": "function",
485
+ "name": "increment_counter",
486
+ "inputs": [],
487
+ "outputs": [],
488
+ "state_mutability": "external"
489
+ },
490
+ {
491
+ "type": "function",
492
+ "name": "get_order_details",
493
+ "inputs": [
494
+ {
495
+ "name": "order_hash",
496
+ "type": "core::felt252"
497
+ }
498
+ ],
499
+ "outputs": [
500
+ {
501
+ "type": "medialane_marketplace_erc721::core::types::OrderDetails"
502
+ }
503
+ ],
504
+ "state_mutability": "view"
505
+ },
506
+ {
507
+ "type": "function",
508
+ "name": "get_order_hash",
509
+ "inputs": [
510
+ {
511
+ "name": "parameters",
512
+ "type": "medialane_marketplace_erc721::core::types::OrderParameters"
513
+ },
514
+ {
515
+ "name": "signer",
516
+ "type": "core::starknet::contract_address::ContractAddress"
517
+ }
518
+ ],
519
+ "outputs": [
520
+ {
521
+ "type": "core::felt252"
522
+ }
523
+ ],
524
+ "state_mutability": "view"
525
+ },
526
+ {
527
+ "type": "function",
528
+ "name": "get_cancellation_hash",
529
+ "inputs": [
530
+ {
531
+ "name": "cancellation",
532
+ "type": "medialane_marketplace_erc721::core::types::OrderCancellation"
533
+ },
534
+ {
535
+ "name": "signer",
536
+ "type": "core::starknet::contract_address::ContractAddress"
537
+ }
538
+ ],
539
+ "outputs": [
540
+ {
541
+ "type": "core::felt252"
542
+ }
543
+ ],
544
+ "state_mutability": "view"
545
+ },
546
+ {
547
+ "type": "function",
548
+ "name": "get_counter",
549
+ "inputs": [
550
+ {
551
+ "name": "offerer",
552
+ "type": "core::starknet::contract_address::ContractAddress"
553
+ }
554
+ ],
555
+ "outputs": [
556
+ {
557
+ "type": "core::felt252"
558
+ }
559
+ ],
560
+ "state_mutability": "view"
561
+ },
562
+ {
563
+ "type": "function",
564
+ "name": "get_native_token_address",
565
+ "inputs": [],
566
+ "outputs": [
567
+ {
568
+ "type": "core::starknet::contract_address::ContractAddress"
569
+ }
570
+ ],
571
+ "state_mutability": "view"
572
+ }
381
573
  ]
382
574
  },
383
575
  {
384
- type: "enum",
385
- name: "mediolano_core::core::types::OrderStatus",
386
- variants: [
387
- { name: "None", type: "()" },
388
- { name: "Created", type: "()" },
389
- { name: "Filled", type: "()" },
390
- { name: "Cancelled", type: "()" }
576
+ "type": "constructor",
577
+ "name": "constructor",
578
+ "inputs": [
579
+ {
580
+ "name": "native_token_address",
581
+ "type": "core::starknet::contract_address::ContractAddress"
582
+ }
391
583
  ]
392
584
  },
393
585
  {
394
- type: "enum",
395
- name: "core::option::Option::<core::starknet::contract_address::ContractAddress>",
396
- variants: [
397
- { name: "Some", type: "core::starknet::contract_address::ContractAddress" },
398
- { name: "None", type: "()" }
586
+ "type": "event",
587
+ "name": "medialane_marketplace_erc721::core::events::OrderCreated",
588
+ "kind": "struct",
589
+ "members": [
590
+ {
591
+ "name": "order_hash",
592
+ "type": "core::felt252",
593
+ "kind": "key"
594
+ },
595
+ {
596
+ "name": "offerer",
597
+ "type": "core::starknet::contract_address::ContractAddress",
598
+ "kind": "key"
599
+ }
399
600
  ]
400
601
  },
401
602
  {
402
- type: "struct",
403
- name: "mediolano_core::core::types::OrderDetails",
404
- members: [
405
- { name: "offerer", type: "core::starknet::contract_address::ContractAddress" },
406
- { name: "offer", type: "mediolano_core::core::types::OfferItem" },
407
- { name: "consideration", type: "mediolano_core::core::types::ConsiderationItem" },
408
- { name: "start_time", type: "core::integer::u64" },
409
- { name: "end_time", type: "core::integer::u64" },
410
- { name: "order_status", type: "mediolano_core::core::types::OrderStatus" },
603
+ "type": "struct",
604
+ "name": "core::integer::u256",
605
+ "members": [
606
+ {
607
+ "name": "low",
608
+ "type": "core::integer::u128"
609
+ },
411
610
  {
412
- name: "fulfiller",
413
- type: "core::option::Option::<core::starknet::contract_address::ContractAddress>"
611
+ "name": "high",
612
+ "type": "core::integer::u128"
414
613
  }
415
614
  ]
416
615
  },
417
616
  {
418
- type: "interface",
419
- name: "mediolano_core::core::interface::IMedialane",
420
- items: [
617
+ "type": "event",
618
+ "name": "medialane_marketplace_erc721::core::events::OrderFulfilled",
619
+ "kind": "struct",
620
+ "members": [
421
621
  {
422
- type: "function",
423
- name: "register_order",
424
- inputs: [{ name: "order", type: "mediolano_core::core::types::Order" }],
425
- outputs: [],
426
- state_mutability: "external"
622
+ "name": "order_hash",
623
+ "type": "core::felt252",
624
+ "kind": "key"
427
625
  },
428
626
  {
429
- type: "function",
430
- name: "fulfill_order",
431
- inputs: [
432
- {
433
- name: "fulfillment_request",
434
- type: "mediolano_core::core::types::FulfillmentRequest"
435
- }
436
- ],
437
- outputs: [],
438
- state_mutability: "external"
627
+ "name": "offerer",
628
+ "type": "core::starknet::contract_address::ContractAddress",
629
+ "kind": "key"
439
630
  },
440
631
  {
441
- type: "function",
442
- name: "cancel_order",
443
- inputs: [{ name: "cancel_request", type: "mediolano_core::core::types::CancelRequest" }],
444
- outputs: [],
445
- state_mutability: "external"
632
+ "name": "fulfiller",
633
+ "type": "core::starknet::contract_address::ContractAddress",
634
+ "kind": "key"
446
635
  },
447
636
  {
448
- type: "function",
449
- name: "get_order_details",
450
- inputs: [{ name: "order_hash", type: "core::felt252" }],
451
- outputs: [{ type: "mediolano_core::core::types::OrderDetails" }],
452
- state_mutability: "view"
637
+ "name": "sale_amount",
638
+ "type": "core::integer::u256",
639
+ "kind": "data"
453
640
  },
454
641
  {
455
- type: "function",
456
- name: "get_order_hash",
457
- inputs: [
458
- { name: "parameters", type: "mediolano_core::core::types::OrderParameters" },
459
- { name: "signer", type: "core::starknet::contract_address::ContractAddress" }
460
- ],
461
- outputs: [{ type: "core::felt252" }],
462
- state_mutability: "view"
463
- }
464
- ]
465
- },
466
- {
467
- type: "impl",
468
- name: "NoncesImpl",
469
- interface_name: "openzeppelin_utils::cryptography::interface::INonces"
470
- },
471
- {
472
- type: "interface",
473
- name: "openzeppelin_utils::cryptography::interface::INonces",
474
- items: [
642
+ "name": "royalty_receiver",
643
+ "type": "core::starknet::contract_address::ContractAddress",
644
+ "kind": "data"
645
+ },
475
646
  {
476
- type: "function",
477
- name: "nonces",
478
- inputs: [
479
- { name: "owner", type: "core::starknet::contract_address::ContractAddress" }
480
- ],
481
- outputs: [{ type: "core::felt252" }],
482
- state_mutability: "view"
647
+ "name": "royalty_amount",
648
+ "type": "core::integer::u256",
649
+ "kind": "data"
483
650
  }
484
651
  ]
485
652
  },
486
653
  {
487
- type: "impl",
488
- name: "SRC5Impl",
489
- interface_name: "openzeppelin_introspection::interface::ISRC5"
490
- },
491
- {
492
- type: "enum",
493
- name: "core::bool",
494
- variants: [
495
- { name: "False", type: "()" },
496
- { name: "True", type: "()" }
497
- ]
498
- },
499
- {
500
- type: "interface",
501
- name: "openzeppelin_introspection::interface::ISRC5",
502
- items: [
654
+ "type": "event",
655
+ "name": "medialane_marketplace_erc721::core::events::OrderCancelled",
656
+ "kind": "struct",
657
+ "members": [
503
658
  {
504
- type: "function",
505
- name: "supports_interface",
506
- inputs: [{ name: "interface_id", type: "core::felt252" }],
507
- outputs: [{ type: "core::bool" }],
508
- state_mutability: "view"
509
- }
510
- ]
511
- },
512
- {
513
- type: "constructor",
514
- name: "constructor",
515
- inputs: [
516
- { name: "manager", type: "core::starknet::contract_address::ContractAddress" },
517
- { name: "native_token_address", type: "core::starknet::contract_address::ContractAddress" }
518
- ]
519
- },
520
- {
521
- type: "event",
522
- name: "mediolano_core::core::events::OrderCreated",
523
- kind: "struct",
524
- members: [
525
- { name: "order_hash", type: "core::felt252", kind: "key" },
659
+ "name": "order_hash",
660
+ "type": "core::felt252",
661
+ "kind": "key"
662
+ },
526
663
  {
527
- name: "offerer",
528
- type: "core::starknet::contract_address::ContractAddress",
529
- kind: "key"
664
+ "name": "offerer",
665
+ "type": "core::starknet::contract_address::ContractAddress",
666
+ "kind": "key"
530
667
  }
531
668
  ]
532
669
  },
533
670
  {
534
- type: "event",
535
- name: "mediolano_core::core::events::OrderFulfilled",
536
- kind: "struct",
537
- members: [
538
- { name: "order_hash", type: "core::felt252", kind: "key" },
671
+ "type": "event",
672
+ "name": "medialane_marketplace_erc721::core::events::CounterIncremented",
673
+ "kind": "struct",
674
+ "members": [
539
675
  {
540
- name: "offerer",
541
- type: "core::starknet::contract_address::ContractAddress",
542
- kind: "key"
676
+ "name": "offerer",
677
+ "type": "core::starknet::contract_address::ContractAddress",
678
+ "kind": "key"
543
679
  },
544
680
  {
545
- name: "fulfiller",
546
- type: "core::starknet::contract_address::ContractAddress",
547
- kind: "key"
681
+ "name": "new_counter",
682
+ "type": "core::felt252",
683
+ "kind": "data"
548
684
  }
549
685
  ]
550
686
  },
551
687
  {
552
- type: "event",
553
- name: "mediolano_core::core::events::OrderCancelled",
554
- kind: "struct",
555
- members: [
556
- { name: "order_hash", type: "core::felt252", kind: "key" },
688
+ "type": "event",
689
+ "name": "medialane_marketplace_erc721::core::medialane::Medialane721::Event",
690
+ "kind": "enum",
691
+ "variants": [
557
692
  {
558
- name: "offerer",
559
- type: "core::starknet::contract_address::ContractAddress",
560
- kind: "key"
561
- }
562
- ]
563
- },
564
- {
565
- type: "event",
566
- name: "mediolano_core::core::medialane::Medialane::Event",
567
- kind: "enum",
568
- variants: [
693
+ "name": "OrderCreated",
694
+ "type": "medialane_marketplace_erc721::core::events::OrderCreated",
695
+ "kind": "nested"
696
+ },
569
697
  {
570
- name: "OrderCreated",
571
- type: "mediolano_core::core::events::OrderCreated",
572
- kind: "nested"
698
+ "name": "OrderFulfilled",
699
+ "type": "medialane_marketplace_erc721::core::events::OrderFulfilled",
700
+ "kind": "nested"
573
701
  },
574
702
  {
575
- name: "OrderFulfilled",
576
- type: "mediolano_core::core::events::OrderFulfilled",
577
- kind: "nested"
703
+ "name": "OrderCancelled",
704
+ "type": "medialane_marketplace_erc721::core::events::OrderCancelled",
705
+ "kind": "nested"
578
706
  },
579
707
  {
580
- name: "OrderCancelled",
581
- type: "mediolano_core::core::events::OrderCancelled",
582
- kind: "nested"
708
+ "name": "CounterIncremented",
709
+ "type": "medialane_marketplace_erc721::core::events::CounterIncremented",
710
+ "kind": "nested"
583
711
  }
584
712
  ]
585
713
  }
@@ -1033,12 +1161,12 @@ var CollectionRegistryABI = [
1033
1161
  var Medialane1155ABI = [
1034
1162
  {
1035
1163
  "type": "impl",
1036
- "name": "Medialane1155V2Impl",
1037
- "interface_name": "medialane_erc1155::core::interface::IMedialane1155V2"
1164
+ "name": "Medialane1155Impl",
1165
+ "interface_name": "medialane_marketplace_erc1155::core::interface::IMedialane1155"
1038
1166
  },
1039
1167
  {
1040
1168
  "type": "struct",
1041
- "name": "medialane_erc1155::core::types::OfferItem",
1169
+ "name": "medialane_marketplace_erc1155::core::types::OfferItem",
1042
1170
  "members": [
1043
1171
  {
1044
1172
  "name": "item_type",
@@ -1053,18 +1181,14 @@ var Medialane1155ABI = [
1053
1181
  "type": "core::felt252"
1054
1182
  },
1055
1183
  {
1056
- "name": "start_amount",
1057
- "type": "core::felt252"
1058
- },
1059
- {
1060
- "name": "end_amount",
1184
+ "name": "amount",
1061
1185
  "type": "core::felt252"
1062
1186
  }
1063
1187
  ]
1064
1188
  },
1065
1189
  {
1066
1190
  "type": "struct",
1067
- "name": "medialane_erc1155::core::types::ConsiderationItem",
1191
+ "name": "medialane_marketplace_erc1155::core::types::ConsiderationItem",
1068
1192
  "members": [
1069
1193
  {
1070
1194
  "name": "item_type",
@@ -1079,11 +1203,7 @@ var Medialane1155ABI = [
1079
1203
  "type": "core::felt252"
1080
1204
  },
1081
1205
  {
1082
- "name": "start_amount",
1083
- "type": "core::felt252"
1084
- },
1085
- {
1086
- "name": "end_amount",
1206
+ "name": "amount",
1087
1207
  "type": "core::felt252"
1088
1208
  },
1089
1209
  {
@@ -1094,19 +1214,27 @@ var Medialane1155ABI = [
1094
1214
  },
1095
1215
  {
1096
1216
  "type": "struct",
1097
- "name": "medialane_erc1155::core::types::OrderParameters",
1217
+ "name": "medialane_marketplace_erc1155::core::types::OrderParameters",
1098
1218
  "members": [
1099
1219
  {
1100
1220
  "name": "offerer",
1101
1221
  "type": "core::starknet::contract_address::ContractAddress"
1102
1222
  },
1223
+ {
1224
+ "name": "marketplace",
1225
+ "type": "core::starknet::contract_address::ContractAddress"
1226
+ },
1103
1227
  {
1104
1228
  "name": "offer",
1105
- "type": "medialane_erc1155::core::types::OfferItem"
1229
+ "type": "medialane_marketplace_erc1155::core::types::OfferItem"
1106
1230
  },
1107
1231
  {
1108
1232
  "name": "consideration",
1109
- "type": "medialane_erc1155::core::types::ConsiderationItem"
1233
+ "type": "medialane_marketplace_erc1155::core::types::ConsiderationItem"
1234
+ },
1235
+ {
1236
+ "name": "royalty_max_bps",
1237
+ "type": "core::felt252"
1110
1238
  },
1111
1239
  {
1112
1240
  "name": "start_time",
@@ -1121,18 +1249,18 @@ var Medialane1155ABI = [
1121
1249
  "type": "core::felt252"
1122
1250
  },
1123
1251
  {
1124
- "name": "nonce",
1252
+ "name": "counter",
1125
1253
  "type": "core::felt252"
1126
1254
  }
1127
1255
  ]
1128
1256
  },
1129
1257
  {
1130
1258
  "type": "struct",
1131
- "name": "medialane_erc1155::core::types::Order",
1259
+ "name": "medialane_marketplace_erc1155::core::types::Order",
1132
1260
  "members": [
1133
1261
  {
1134
1262
  "name": "parameters",
1135
- "type": "medialane_erc1155::core::types::OrderParameters"
1263
+ "type": "medialane_marketplace_erc1155::core::types::OrderParameters"
1136
1264
  },
1137
1265
  {
1138
1266
  "name": "signature",
@@ -1142,43 +1270,7 @@ var Medialane1155ABI = [
1142
1270
  },
1143
1271
  {
1144
1272
  "type": "struct",
1145
- "name": "medialane_erc1155::core::types::OrderFulfillment",
1146
- "members": [
1147
- {
1148
- "name": "order_hash",
1149
- "type": "core::felt252"
1150
- },
1151
- {
1152
- "name": "fulfiller",
1153
- "type": "core::starknet::contract_address::ContractAddress"
1154
- },
1155
- {
1156
- "name": "quantity",
1157
- "type": "core::felt252"
1158
- },
1159
- {
1160
- "name": "nonce",
1161
- "type": "core::felt252"
1162
- }
1163
- ]
1164
- },
1165
- {
1166
- "type": "struct",
1167
- "name": "medialane_erc1155::core::types::FulfillmentRequest",
1168
- "members": [
1169
- {
1170
- "name": "fulfillment",
1171
- "type": "medialane_erc1155::core::types::OrderFulfillment"
1172
- },
1173
- {
1174
- "name": "signature",
1175
- "type": "core::array::Array::<core::felt252>"
1176
- }
1177
- ]
1178
- },
1179
- {
1180
- "type": "struct",
1181
- "name": "medialane_erc1155::core::types::OrderCancellation",
1273
+ "name": "medialane_marketplace_erc1155::core::types::OrderCancellation",
1182
1274
  "members": [
1183
1275
  {
1184
1276
  "name": "order_hash",
@@ -1187,20 +1279,16 @@ var Medialane1155ABI = [
1187
1279
  {
1188
1280
  "name": "offerer",
1189
1281
  "type": "core::starknet::contract_address::ContractAddress"
1190
- },
1191
- {
1192
- "name": "nonce",
1193
- "type": "core::felt252"
1194
1282
  }
1195
1283
  ]
1196
1284
  },
1197
1285
  {
1198
1286
  "type": "struct",
1199
- "name": "medialane_erc1155::core::types::CancelRequest",
1287
+ "name": "medialane_marketplace_erc1155::core::types::CancelRequest",
1200
1288
  "members": [
1201
1289
  {
1202
1290
  "name": "cancelation",
1203
- "type": "medialane_erc1155::core::types::OrderCancellation"
1291
+ "type": "medialane_marketplace_erc1155::core::types::OrderCancellation"
1204
1292
  },
1205
1293
  {
1206
1294
  "name": "signature",
@@ -1210,7 +1298,7 @@ var Medialane1155ABI = [
1210
1298
  },
1211
1299
  {
1212
1300
  "type": "enum",
1213
- "name": "medialane_erc1155::core::types::OrderStatus",
1301
+ "name": "medialane_marketplace_erc1155::core::types::OrderStatus",
1214
1302
  "variants": [
1215
1303
  {
1216
1304
  "name": "None",
@@ -1232,7 +1320,7 @@ var Medialane1155ABI = [
1232
1320
  },
1233
1321
  {
1234
1322
  "type": "struct",
1235
- "name": "medialane_erc1155::core::types::OrderDetails",
1323
+ "name": "medialane_marketplace_erc1155::core::types::OrderDetails",
1236
1324
  "members": [
1237
1325
  {
1238
1326
  "name": "offerer",
@@ -1240,11 +1328,15 @@ var Medialane1155ABI = [
1240
1328
  },
1241
1329
  {
1242
1330
  "name": "offer",
1243
- "type": "medialane_erc1155::core::types::OfferItem"
1331
+ "type": "medialane_marketplace_erc1155::core::types::OfferItem"
1244
1332
  },
1245
1333
  {
1246
1334
  "name": "consideration",
1247
- "type": "medialane_erc1155::core::types::ConsiderationItem"
1335
+ "type": "medialane_marketplace_erc1155::core::types::ConsiderationItem"
1336
+ },
1337
+ {
1338
+ "name": "royalty_max_bps",
1339
+ "type": "core::felt252"
1248
1340
  },
1249
1341
  {
1250
1342
  "name": "start_time",
@@ -1256,11 +1348,7 @@ var Medialane1155ABI = [
1256
1348
  },
1257
1349
  {
1258
1350
  "name": "order_status",
1259
- "type": "medialane_erc1155::core::types::OrderStatus"
1260
- },
1261
- {
1262
- "name": "total_amount",
1263
- "type": "core::felt252"
1351
+ "type": "medialane_marketplace_erc1155::core::types::OrderStatus"
1264
1352
  },
1265
1353
  {
1266
1354
  "name": "remaining_amount",
@@ -1270,7 +1358,7 @@ var Medialane1155ABI = [
1270
1358
  },
1271
1359
  {
1272
1360
  "type": "interface",
1273
- "name": "medialane_erc1155::core::interface::IMedialane1155V2",
1361
+ "name": "medialane_marketplace_erc1155::core::interface::IMedialane1155",
1274
1362
  "items": [
1275
1363
  {
1276
1364
  "type": "function",
@@ -1278,7 +1366,7 @@ var Medialane1155ABI = [
1278
1366
  "inputs": [
1279
1367
  {
1280
1368
  "name": "order",
1281
- "type": "medialane_erc1155::core::types::Order"
1369
+ "type": "medialane_marketplace_erc1155::core::types::Order"
1282
1370
  }
1283
1371
  ],
1284
1372
  "outputs": [],
@@ -1289,8 +1377,12 @@ var Medialane1155ABI = [
1289
1377
  "name": "fulfill_order",
1290
1378
  "inputs": [
1291
1379
  {
1292
- "name": "fulfillment_request",
1293
- "type": "medialane_erc1155::core::types::FulfillmentRequest"
1380
+ "name": "order_hash",
1381
+ "type": "core::felt252"
1382
+ },
1383
+ {
1384
+ "name": "quantity",
1385
+ "type": "core::felt252"
1294
1386
  }
1295
1387
  ],
1296
1388
  "outputs": [],
@@ -1302,12 +1394,19 @@ var Medialane1155ABI = [
1302
1394
  "inputs": [
1303
1395
  {
1304
1396
  "name": "cancel_request",
1305
- "type": "medialane_erc1155::core::types::CancelRequest"
1397
+ "type": "medialane_marketplace_erc1155::core::types::CancelRequest"
1306
1398
  }
1307
1399
  ],
1308
1400
  "outputs": [],
1309
1401
  "state_mutability": "external"
1310
1402
  },
1403
+ {
1404
+ "type": "function",
1405
+ "name": "increment_counter",
1406
+ "inputs": [],
1407
+ "outputs": [],
1408
+ "state_mutability": "external"
1409
+ },
1311
1410
  {
1312
1411
  "type": "function",
1313
1412
  "name": "get_order_details",
@@ -1319,7 +1418,7 @@ var Medialane1155ABI = [
1319
1418
  ],
1320
1419
  "outputs": [
1321
1420
  {
1322
- "type": "medialane_erc1155::core::types::OrderDetails"
1421
+ "type": "medialane_marketplace_erc1155::core::types::OrderDetails"
1323
1422
  }
1324
1423
  ],
1325
1424
  "state_mutability": "view"
@@ -1330,7 +1429,7 @@ var Medialane1155ABI = [
1330
1429
  "inputs": [
1331
1430
  {
1332
1431
  "name": "parameters",
1333
- "type": "medialane_erc1155::core::types::OrderParameters"
1432
+ "type": "medialane_marketplace_erc1155::core::types::OrderParameters"
1334
1433
  },
1335
1434
  {
1336
1435
  "name": "signer",
@@ -1346,32 +1445,30 @@ var Medialane1155ABI = [
1346
1445
  },
1347
1446
  {
1348
1447
  "type": "function",
1349
- "name": "get_native_token_address",
1350
- "inputs": [],
1351
- "outputs": [
1448
+ "name": "get_cancellation_hash",
1449
+ "inputs": [
1450
+ {
1451
+ "name": "cancellation",
1452
+ "type": "medialane_marketplace_erc1155::core::types::OrderCancellation"
1453
+ },
1352
1454
  {
1455
+ "name": "signer",
1353
1456
  "type": "core::starknet::contract_address::ContractAddress"
1354
1457
  }
1355
1458
  ],
1459
+ "outputs": [
1460
+ {
1461
+ "type": "core::felt252"
1462
+ }
1463
+ ],
1356
1464
  "state_mutability": "view"
1357
- }
1358
- ]
1359
- },
1360
- {
1361
- "type": "impl",
1362
- "name": "NoncesImpl",
1363
- "interface_name": "openzeppelin_utils::cryptography::interface::INonces"
1364
- },
1365
- {
1366
- "type": "interface",
1367
- "name": "openzeppelin_utils::cryptography::interface::INonces",
1368
- "items": [
1465
+ },
1369
1466
  {
1370
1467
  "type": "function",
1371
- "name": "nonces",
1468
+ "name": "get_counter",
1372
1469
  "inputs": [
1373
1470
  {
1374
- "name": "owner",
1471
+ "name": "offerer",
1375
1472
  "type": "core::starknet::contract_address::ContractAddress"
1376
1473
  }
1377
1474
  ],
@@ -1381,6 +1478,17 @@ var Medialane1155ABI = [
1381
1478
  }
1382
1479
  ],
1383
1480
  "state_mutability": "view"
1481
+ },
1482
+ {
1483
+ "type": "function",
1484
+ "name": "get_native_token_address",
1485
+ "inputs": [],
1486
+ "outputs": [
1487
+ {
1488
+ "type": "core::starknet::contract_address::ContractAddress"
1489
+ }
1490
+ ],
1491
+ "state_mutability": "view"
1384
1492
  }
1385
1493
  ]
1386
1494
  },
@@ -1396,7 +1504,7 @@ var Medialane1155ABI = [
1396
1504
  },
1397
1505
  {
1398
1506
  "type": "event",
1399
- "name": "medialane_erc1155::core::events::OrderCreated",
1507
+ "name": "medialane_marketplace_erc1155::core::events::OrderCreated",
1400
1508
  "kind": "struct",
1401
1509
  "members": [
1402
1510
  {
@@ -1427,7 +1535,7 @@ var Medialane1155ABI = [
1427
1535
  },
1428
1536
  {
1429
1537
  "type": "event",
1430
- "name": "medialane_erc1155::core::events::OrderFulfilled",
1538
+ "name": "medialane_marketplace_erc1155::core::events::OrderFulfilled",
1431
1539
  "kind": "struct",
1432
1540
  "members": [
1433
1541
  {
@@ -1474,7 +1582,7 @@ var Medialane1155ABI = [
1474
1582
  },
1475
1583
  {
1476
1584
  "type": "event",
1477
- "name": "medialane_erc1155::core::events::OrderCancelled",
1585
+ "name": "medialane_marketplace_erc1155::core::events::OrderCancelled",
1478
1586
  "kind": "struct",
1479
1587
  "members": [
1480
1588
  {
@@ -1491,34 +1599,45 @@ var Medialane1155ABI = [
1491
1599
  },
1492
1600
  {
1493
1601
  "type": "event",
1494
- "name": "openzeppelin_utils::cryptography::nonces::NoncesComponent::Event",
1495
- "kind": "enum",
1496
- "variants": []
1602
+ "name": "medialane_marketplace_erc1155::core::events::CounterIncremented",
1603
+ "kind": "struct",
1604
+ "members": [
1605
+ {
1606
+ "name": "offerer",
1607
+ "type": "core::starknet::contract_address::ContractAddress",
1608
+ "kind": "key"
1609
+ },
1610
+ {
1611
+ "name": "new_counter",
1612
+ "type": "core::felt252",
1613
+ "kind": "data"
1614
+ }
1615
+ ]
1497
1616
  },
1498
1617
  {
1499
1618
  "type": "event",
1500
- "name": "medialane_erc1155::core::medialane::Medialane1155V2::Event",
1619
+ "name": "medialane_marketplace_erc1155::core::medialane::Medialane1155::Event",
1501
1620
  "kind": "enum",
1502
1621
  "variants": [
1503
1622
  {
1504
1623
  "name": "OrderCreated",
1505
- "type": "medialane_erc1155::core::events::OrderCreated",
1624
+ "type": "medialane_marketplace_erc1155::core::events::OrderCreated",
1506
1625
  "kind": "nested"
1507
1626
  },
1508
1627
  {
1509
1628
  "name": "OrderFulfilled",
1510
- "type": "medialane_erc1155::core::events::OrderFulfilled",
1629
+ "type": "medialane_marketplace_erc1155::core::events::OrderFulfilled",
1511
1630
  "kind": "nested"
1512
1631
  },
1513
1632
  {
1514
1633
  "name": "OrderCancelled",
1515
- "type": "medialane_erc1155::core::events::OrderCancelled",
1634
+ "type": "medialane_marketplace_erc1155::core::events::OrderCancelled",
1516
1635
  "kind": "nested"
1517
1636
  },
1518
1637
  {
1519
- "name": "NoncesEvent",
1520
- "type": "openzeppelin_utils::cryptography::nonces::NoncesComponent::Event",
1521
- "kind": "flat"
1638
+ "name": "CounterIncremented",
1639
+ "type": "medialane_marketplace_erc1155::core::events::CounterIncremented",
1640
+ "kind": "nested"
1522
1641
  }
1523
1642
  ]
1524
1643
  }
@@ -4566,6 +4685,26 @@ var MedialaneError = class extends Error {
4566
4685
  }
4567
4686
  };
4568
4687
  var START_TIME_BUFFER_SECS = 30;
4688
+ function generateSalt() {
4689
+ const bytes = new Uint8Array(31);
4690
+ crypto.getRandomValues(bytes);
4691
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
4692
+ return num.toHex(BigInt("0x" + hex));
4693
+ }
4694
+ async function resolveRoyaltyMaxBps(provider, nft, tokenId, override) {
4695
+ if (override !== void 0) return override;
4696
+ try {
4697
+ const id = cairo.uint256(tokenId);
4698
+ const res = await provider.callContract({
4699
+ contractAddress: nft,
4700
+ entrypoint: "royalty_info",
4701
+ calldata: [id.low.toString(), id.high.toString(), "10000", "0"]
4702
+ });
4703
+ return BigInt(res[1] ?? "0").toString();
4704
+ } catch {
4705
+ return "0";
4706
+ }
4707
+ }
4569
4708
  function toSignatureArray(sig) {
4570
4709
  if (Array.isArray(sig)) return sig;
4571
4710
  const s = sig;
@@ -4613,31 +4752,29 @@ async function createListing(account, params, config) {
4613
4752
  const now = Math.floor(Date.now() / 1e3);
4614
4753
  const startTime = now + START_TIME_BUFFER_SECS;
4615
4754
  const endTime = now + durationSeconds;
4616
- const saltBytes = new Uint8Array(4);
4617
- crypto.getRandomValues(saltBytes);
4618
- const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
4619
- const currentNonce = await contract.nonces(account.address);
4755
+ const counter = (await contract.get_counter(account.address)).toString();
4756
+ const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
4620
4757
  const orderParams = {
4621
4758
  offerer: account.address,
4759
+ marketplace: config.marketplaceContract,
4622
4760
  offer: {
4623
4761
  item_type: "ERC721",
4624
4762
  token: nftContract,
4625
4763
  identifier_or_criteria: tokenId,
4626
- start_amount: "1",
4627
- end_amount: "1"
4764
+ amount: "1"
4628
4765
  },
4629
4766
  consideration: {
4630
4767
  item_type: "ERC20",
4631
4768
  token: token.address,
4632
4769
  identifier_or_criteria: "0",
4633
- start_amount: priceWei,
4634
- end_amount: priceWei,
4770
+ amount: priceWei,
4635
4771
  recipient: account.address
4636
4772
  },
4773
+ royalty_max_bps: royaltyMaxBps,
4637
4774
  start_time: startTime.toString(),
4638
4775
  end_time: endTime.toString(),
4639
- salt,
4640
- nonce: currentNonce.toString()
4776
+ salt: generateSalt(),
4777
+ counter
4641
4778
  };
4642
4779
  const chainId = getChainId();
4643
4780
  const typedData = stringifyBigInts(buildOrderTypedData(orderParams, chainId));
@@ -4697,31 +4834,29 @@ async function makeOffer(account, params, config) {
4697
4834
  const now = Math.floor(Date.now() / 1e3);
4698
4835
  const startTime = now + START_TIME_BUFFER_SECS;
4699
4836
  const endTime = now + durationSeconds;
4700
- const saltBytes = new Uint8Array(4);
4701
- crypto.getRandomValues(saltBytes);
4702
- const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
4703
- const currentNonce = await contract.nonces(account.address);
4837
+ const counter = (await contract.get_counter(account.address)).toString();
4838
+ const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
4704
4839
  const orderParams = {
4705
4840
  offerer: account.address,
4841
+ marketplace: config.marketplaceContract,
4706
4842
  offer: {
4707
4843
  item_type: "ERC20",
4708
4844
  token: token.address,
4709
4845
  identifier_or_criteria: "0",
4710
- start_amount: priceWei,
4711
- end_amount: priceWei
4846
+ amount: priceWei
4712
4847
  },
4713
4848
  consideration: {
4714
4849
  item_type: "ERC721",
4715
4850
  token: nftContract,
4716
4851
  identifier_or_criteria: tokenId,
4717
- start_amount: "1",
4718
- end_amount: "1",
4852
+ amount: "1",
4719
4853
  recipient: account.address
4720
4854
  },
4855
+ royalty_max_bps: royaltyMaxBps,
4721
4856
  start_time: startTime.toString(),
4722
4857
  end_time: endTime.toString(),
4723
- salt,
4724
- nonce: currentNonce.toString()
4858
+ salt: generateSalt(),
4859
+ counter
4725
4860
  };
4726
4861
  const chainId = getChainId();
4727
4862
  const typedData = stringifyBigInts(buildOrderTypedData(orderParams, chainId));
@@ -4763,22 +4898,6 @@ async function makeOffer(account, params, config) {
4763
4898
  async function fulfillOrder(account, params, config) {
4764
4899
  const { orderHash, paymentToken, totalPrice } = params;
4765
4900
  const { contract, provider } = makeContract(config);
4766
- const currentNonce = await contract.nonces(account.address);
4767
- const chainId = getChainId();
4768
- const fulfillmentParams = {
4769
- order_hash: orderHash,
4770
- fulfiller: account.address,
4771
- nonce: currentNonce.toString()
4772
- };
4773
- const typedData = stringifyBigInts(
4774
- buildFulfillmentTypedData(fulfillmentParams, chainId)
4775
- );
4776
- const signature = await account.signMessage(typedData);
4777
- const signatureArray = toSignatureArray(signature);
4778
- const fulfillPayload = stringifyBigInts({
4779
- fulfillment: fulfillmentParams,
4780
- signature: signatureArray
4781
- });
4782
4901
  const totalPriceU256 = cairo.uint256(totalPrice);
4783
4902
  const approveCall = {
4784
4903
  contractAddress: paymentToken,
@@ -4789,7 +4908,7 @@ async function fulfillOrder(account, params, config) {
4789
4908
  totalPriceU256.high.toString()
4790
4909
  ]
4791
4910
  };
4792
- const fulfillCall = contract.populate("fulfill_order", [fulfillPayload]);
4911
+ const fulfillCall = contract.populate("fulfill_order", [orderHash]);
4793
4912
  const feeCall = buildFeeCall(
4794
4913
  { surface: "marketplace", token: paymentToken, grossAmount: BigInt(totalPrice) },
4795
4914
  config.feeConfig
@@ -4806,12 +4925,10 @@ async function fulfillOrder(account, params, config) {
4806
4925
  async function cancelOrder(account, params, config) {
4807
4926
  const { orderHash } = params;
4808
4927
  const { contract, provider } = makeContract(config);
4809
- const currentNonce = await contract.nonces(account.address);
4810
4928
  const chainId = getChainId();
4811
4929
  const cancelParams = {
4812
4930
  order_hash: orderHash,
4813
- offerer: account.address,
4814
- nonce: currentNonce.toString()
4931
+ offerer: account.address
4815
4932
  };
4816
4933
  const typedData = stringifyBigInts(
4817
4934
  buildCancellationTypedData(cancelParams, chainId)
@@ -4882,29 +4999,9 @@ async function checkoutCart(account, items, config) {
4882
4999
  ]
4883
5000
  };
4884
5001
  });
4885
- const currentNonce = await contract.nonces(account.address);
4886
- const baseNonce = BigInt(currentNonce.toString());
4887
- const chainId = getChainId();
4888
- const fulfillCalls = [];
4889
- for (let i = 0; i < items.length; i++) {
4890
- const item = items[i];
4891
- const nonce = (baseNonce + BigInt(i)).toString();
4892
- const fulfillmentParams = {
4893
- order_hash: item.orderHash,
4894
- fulfiller: account.address,
4895
- nonce
4896
- };
4897
- const typedData = stringifyBigInts(
4898
- buildFulfillmentTypedData(fulfillmentParams, chainId)
4899
- );
4900
- const signature = await account.signMessage(typedData);
4901
- const signatureArray = toSignatureArray(signature);
4902
- const fulfillPayload = stringifyBigInts({
4903
- fulfillment: fulfillmentParams,
4904
- signature: signatureArray
4905
- });
4906
- fulfillCalls.push(contract.populate("fulfill_order", [fulfillPayload]));
4907
- }
5002
+ const fulfillCalls = items.map(
5003
+ (item) => contract.populate("fulfill_order", [item.orderHash])
5004
+ );
4908
5005
  const feeCalls = Array.from(tokenTotals.entries()).map(
4909
5006
  ([tokenAddr, totalWei]) => buildFeeCall(
4910
5007
  { surface: "marketplace", token: tokenAddr, grossAmount: totalWei },
@@ -4923,9 +5020,20 @@ async function getOrderDetails(orderHash, config) {
4923
5020
  const { contract } = makeContract(config);
4924
5021
  return contract.get_order_details(orderHash);
4925
5022
  }
4926
- async function getNonce(address, config) {
5023
+ async function getCounter(address, config) {
4927
5024
  const { contract } = makeContract(config);
4928
- return BigInt((await contract.nonces(address)).toString());
5025
+ return BigInt((await contract.get_counter(address)).toString());
5026
+ }
5027
+ async function incrementCounter(account, config) {
5028
+ const { contract, provider } = makeContract(config);
5029
+ const call = contract.populate("increment_counter", []);
5030
+ try {
5031
+ const tx = await account.execute(call);
5032
+ await provider.waitForTransaction(tx.transaction_hash);
5033
+ return { txHash: tx.transaction_hash };
5034
+ } catch (err) {
5035
+ throw new MedialaneError("Failed to increment counter", "TRANSACTION_FAILED", err);
5036
+ }
4929
5037
  }
4930
5038
 
4931
5039
  // src/marketplace/index.ts
@@ -4955,20 +5063,21 @@ var MarketplaceModule = class {
4955
5063
  createCollection(account, params) {
4956
5064
  return createCollection(account, params, this.config);
4957
5065
  }
5066
+ /** Bulk-cancel: bump the caller's counter, invalidating all their open orders. */
5067
+ incrementCounter(account) {
5068
+ return incrementCounter(account, this.config);
5069
+ }
4958
5070
  // ─── View calls ───────────────────────────────────────────────────────────
4959
5071
  getOrderDetails(orderHash) {
4960
5072
  return getOrderDetails(orderHash, this.config);
4961
5073
  }
4962
- getNonce(address) {
4963
- return getNonce(address, this.config);
5074
+ getCounter(address) {
5075
+ return getCounter(address, this.config);
4964
5076
  }
4965
5077
  // ─── Typed data builders (for ChipiPay / custom signing flows) ───────────
4966
5078
  buildListingTypedData(params, chainId) {
4967
5079
  return buildOrderTypedData(params, chainId);
4968
5080
  }
4969
- buildFulfillmentTypedData(params, chainId) {
4970
- return buildFulfillmentTypedData(params, chainId);
4971
- }
4972
5081
  buildCancellationTypedData(params, chainId) {
4973
5082
  return buildCancellationTypedData(params, chainId);
4974
5083
  }
@@ -5002,32 +5111,32 @@ async function createListing1155(account, params, config) {
5002
5111
  const priceWei = parseAmount(pricePerUnit, token.decimals);
5003
5112
  const now = Math.floor(Date.now() / 1e3);
5004
5113
  const endTime = now + durationSeconds;
5005
- const saltBytes = new Uint8Array(4);
5006
- crypto.getRandomValues(saltBytes);
5007
- const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
5008
- const currentNonce = await contract.nonces(account.address);
5009
5114
  const chainId = getChainId();
5115
+ const counter = (await contract.get_counter(account.address)).toString();
5116
+ const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
5010
5117
  const orderParams = {
5011
5118
  offerer: account.address,
5119
+ marketplace: config.marketplace1155Contract,
5012
5120
  offer: {
5013
5121
  item_type: "ERC1155",
5014
5122
  token: nftContract,
5015
5123
  identifier_or_criteria: tokenId,
5016
- start_amount: amount,
5017
- end_amount: amount
5124
+ amount
5125
+ // ERC-1155 leg amount = unit quantity
5018
5126
  },
5019
5127
  consideration: {
5020
5128
  item_type: "ERC20",
5021
5129
  token: token.address,
5022
5130
  identifier_or_criteria: "0",
5023
- start_amount: priceWei,
5024
- end_amount: priceWei,
5131
+ amount: priceWei,
5132
+ // payment leg amount = price PER UNIT
5025
5133
  recipient: account.address
5026
5134
  },
5135
+ royalty_max_bps: royaltyMaxBps,
5027
5136
  start_time: (now + START_TIME_BUFFER_SECS).toString(),
5028
5137
  end_time: endTime.toString(),
5029
- salt,
5030
- nonce: currentNonce.toString()
5138
+ salt: generateSalt(),
5139
+ counter
5031
5140
  };
5032
5141
  const typedData = stringifyBigInts(
5033
5142
  build1155OrderTypedData(orderParams, chainId)
@@ -5079,23 +5188,6 @@ async function fulfillOrder1155(account, params, config) {
5079
5188
  const { orderHash, paymentToken, totalPrice, quantity = "1" } = params;
5080
5189
  const contract = getContract(config);
5081
5190
  const provider = getProvider(config);
5082
- const chainId = getChainId();
5083
- const currentNonce = await contract.nonces(account.address);
5084
- const fulfillmentParams = {
5085
- order_hash: orderHash,
5086
- fulfiller: account.address,
5087
- quantity,
5088
- nonce: currentNonce.toString()
5089
- };
5090
- const typedData = stringifyBigInts(
5091
- build1155FulfillmentTypedData(fulfillmentParams, chainId)
5092
- );
5093
- const signature = await account.signMessage(typedData);
5094
- const signatureArray = toSignatureArray(signature);
5095
- const fulfillPayload = stringifyBigInts({
5096
- fulfillment: fulfillmentParams,
5097
- signature: signatureArray
5098
- });
5099
5191
  const totalPriceU256 = cairo.uint256(totalPrice);
5100
5192
  const approveCall = {
5101
5193
  contractAddress: paymentToken,
@@ -5106,7 +5198,7 @@ async function fulfillOrder1155(account, params, config) {
5106
5198
  totalPriceU256.high.toString()
5107
5199
  ]
5108
5200
  };
5109
- const fulfillCall = contract.populate("fulfill_order", [fulfillPayload]);
5201
+ const fulfillCall = contract.populate("fulfill_order", [orderHash, quantity]);
5110
5202
  try {
5111
5203
  const tx = await account.execute([approveCall, fulfillCall]);
5112
5204
  await provider.waitForTransaction(tx.transaction_hash);
@@ -5120,11 +5212,9 @@ async function cancelOrder1155(account, params, config) {
5120
5212
  const contract = getContract(config);
5121
5213
  const provider = getProvider(config);
5122
5214
  const chainId = getChainId();
5123
- const currentNonce = await contract.nonces(account.address);
5124
5215
  const cancelParams = {
5125
5216
  order_hash: orderHash,
5126
- offerer: account.address,
5127
- nonce: currentNonce.toString()
5217
+ offerer: account.address
5128
5218
  };
5129
5219
  const typedData = stringifyBigInts(
5130
5220
  build1155CancellationTypedData(cancelParams, chainId)
@@ -5160,31 +5250,31 @@ async function makeOffer1155(account, params, config) {
5160
5250
  const priceWei = parseAmount(price, token.decimals);
5161
5251
  const now = Math.floor(Date.now() / 1e3);
5162
5252
  const endTime = now + durationSeconds;
5163
- const saltBytes = new Uint8Array(4);
5164
- crypto.getRandomValues(saltBytes);
5165
- const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
5166
- const currentNonce = await contract.nonces(account.address);
5253
+ const counter = (await contract.get_counter(account.address)).toString();
5254
+ const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
5167
5255
  const orderParams = {
5168
5256
  offerer: account.address,
5257
+ marketplace: config.marketplace1155Contract,
5169
5258
  offer: {
5170
5259
  item_type: "ERC20",
5171
5260
  token: token.address,
5172
5261
  identifier_or_criteria: "0",
5173
- start_amount: priceWei,
5174
- end_amount: priceWei
5262
+ amount: priceWei
5263
+ // price PER UNIT
5175
5264
  },
5176
5265
  consideration: {
5177
5266
  item_type: "ERC1155",
5178
5267
  token: nftContract,
5179
5268
  identifier_or_criteria: tokenId,
5180
- start_amount: amount,
5181
- end_amount: amount,
5269
+ amount,
5270
+ // unit quantity
5182
5271
  recipient: account.address
5183
5272
  },
5273
+ royalty_max_bps: royaltyMaxBps,
5184
5274
  start_time: (now + START_TIME_BUFFER_SECS).toString(),
5185
5275
  end_time: endTime.toString(),
5186
- salt,
5187
- nonce: currentNonce.toString()
5276
+ salt: generateSalt(),
5277
+ counter
5188
5278
  };
5189
5279
  const typedData = stringifyBigInts(
5190
5280
  build1155OrderTypedData(orderParams, chainId)
@@ -5205,7 +5295,8 @@ async function makeOffer1155(account, params, config) {
5205
5295
  },
5206
5296
  signature: signatureArray
5207
5297
  });
5208
- const amountU256 = cairo.uint256(priceWei);
5298
+ const totalWei = BigInt(priceWei) * BigInt(amount);
5299
+ const amountU256 = cairo.uint256(totalWei.toString());
5209
5300
  const approveCall = {
5210
5301
  contractAddress: token.address,
5211
5302
  entrypoint: "approve",
@@ -5245,31 +5336,9 @@ async function checkoutCart1155(account, items, config) {
5245
5336
  ]
5246
5337
  };
5247
5338
  });
5248
- const currentNonce = await contract.nonces(account.address);
5249
- const baseNonce = BigInt(currentNonce.toString());
5250
- const chainId = getChainId();
5251
- const fulfillCalls = [];
5252
- for (let i = 0; i < items.length; i++) {
5253
- const item = items[i];
5254
- const nonce = (baseNonce + BigInt(i)).toString();
5255
- const quantity = item.quantity ?? "1";
5256
- const fulfillmentParams = {
5257
- order_hash: item.orderHash,
5258
- fulfiller: account.address,
5259
- quantity,
5260
- nonce
5261
- };
5262
- const typedData = stringifyBigInts(
5263
- build1155FulfillmentTypedData(fulfillmentParams, chainId)
5264
- );
5265
- const signature = await account.signMessage(typedData);
5266
- const signatureArray = toSignatureArray(signature);
5267
- const fulfillPayload = stringifyBigInts({
5268
- fulfillment: fulfillmentParams,
5269
- signature: signatureArray
5270
- });
5271
- fulfillCalls.push(contract.populate("fulfill_order", [fulfillPayload]));
5272
- }
5339
+ const fulfillCalls = items.map(
5340
+ (item) => contract.populate("fulfill_order", [item.orderHash, item.quantity ?? "1"])
5341
+ );
5273
5342
  try {
5274
5343
  const tx = await account.execute([...approveCalls, ...fulfillCalls]);
5275
5344
  await provider.waitForTransaction(tx.transaction_hash);
@@ -5282,9 +5351,21 @@ async function getOrderDetails1155(orderHash, config) {
5282
5351
  const contract = getContract(config);
5283
5352
  return contract.get_order_details(orderHash);
5284
5353
  }
5285
- async function getNonce1155(address, config) {
5354
+ async function getCounter1155(address, config) {
5355
+ const contract = getContract(config);
5356
+ return BigInt((await contract.get_counter(address)).toString());
5357
+ }
5358
+ async function incrementCounter1155(account, config) {
5286
5359
  const contract = getContract(config);
5287
- return BigInt((await contract.nonces(address)).toString());
5360
+ const provider = getProvider(config);
5361
+ const call = contract.populate("increment_counter", []);
5362
+ try {
5363
+ const tx = await account.execute(call);
5364
+ await provider.waitForTransaction(tx.transaction_hash);
5365
+ return { txHash: tx.transaction_hash };
5366
+ } catch (err) {
5367
+ throw new MedialaneError("Failed to increment counter (1155)", "TRANSACTION_FAILED", err);
5368
+ }
5288
5369
  }
5289
5370
 
5290
5371
  // src/marketplace1155/index.ts
@@ -5327,20 +5408,21 @@ var Medialane1155Module = class {
5327
5408
  checkoutCart(account, items) {
5328
5409
  return checkoutCart1155(account, items, this.config);
5329
5410
  }
5411
+ /** Bulk-cancel on the 1155 venue: bump the caller's counter. */
5412
+ incrementCounter(account) {
5413
+ return incrementCounter1155(account, this.config);
5414
+ }
5330
5415
  // ─── View calls ───────────────────────────────────────────────────────────
5331
5416
  getOrderDetails(orderHash) {
5332
5417
  return getOrderDetails1155(orderHash, this.config);
5333
5418
  }
5334
- getNonce(address) {
5335
- return getNonce1155(address, this.config);
5419
+ getCounter(address) {
5420
+ return getCounter1155(address, this.config);
5336
5421
  }
5337
5422
  // ─── Typed data builders (for ChipiPay / custom signing flows) ───────────
5338
5423
  buildListingTypedData(params, chainId) {
5339
5424
  return build1155OrderTypedData(params, chainId);
5340
5425
  }
5341
- buildFulfillmentTypedData(params, chainId) {
5342
- return build1155FulfillmentTypedData(params, chainId);
5343
- }
5344
5426
  buildCancellationTypedData(params, chainId) {
5345
5427
  return build1155CancellationTypedData(params, chainId);
5346
5428
  }
@@ -6438,6 +6520,6 @@ function getServicesByCapability(cap) {
6438
6520
  );
6439
6521
  }
6440
6522
 
6441
- export { ApiClient, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CollectionRegistryABI, DEFAULT_RPC_URL, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, ERC1155CollectionService, FeeConfigSchema, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PopService, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, build1155CancellationTypedData, build1155FulfillmentTypedData, build1155OrderTypedData, buildCancellationTypedData, buildFeeCall, buildFulfillmentTypedData, buildOrderTypedData, encodeByteArray, formatAmount, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, listServices, normalizeAddress, normalizeHash, parseAmount, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, u256ToBigInt };
6523
+ export { ApiClient, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CollectionRegistryABI, DEFAULT_RPC_URL, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, ERC1155CollectionService, FeeConfigSchema, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PopService, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, build1155CancellationTypedData, build1155OrderTypedData, buildCancellationTypedData, buildFeeCall, buildOrderTypedData, encodeByteArray, formatAmount, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, listServices, normalizeAddress, normalizeHash, parseAmount, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, u256ToBigInt };
6442
6524
  //# sourceMappingURL=index.js.map
6443
6525
  //# sourceMappingURL=index.js.map