@medialane/sdk 0.8.2 → 0.9.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.cjs CHANGED
@@ -12,9 +12,9 @@ var MARKETPLACE_721_CLASS_HASH_MAINNET = "0x03dff4f34b976207246207954263be9a28b5
12
12
  var MARKETPLACE_CLASS_HASH_MAINNET = MARKETPLACE_721_CLASS_HASH_MAINNET;
13
13
  var MARKETPLACE_721_START_BLOCK_MAINNET = 9196722;
14
14
  var MARKETPLACE_START_BLOCK_MAINNET = MARKETPLACE_721_START_BLOCK_MAINNET;
15
- var MARKETPLACE_1155_CONTRACT_MAINNET = "0x04a0a65bd13e1ec9a2ce92c36115578486331e941b395f97d49fe488baac8309";
16
- var MARKETPLACE_1155_CLASS_HASH_MAINNET = "0x03e1b84f1058dd5c9c766634e638d02756b59910080492983a5168c99856efd0";
17
- var MARKETPLACE_1155_START_BLOCK_MAINNET = 9197091;
15
+ var MARKETPLACE_1155_CONTRACT_MAINNET = "0x02bfa521c25461a09d735889b469418608d7d92f8b26e3d37ef174a4c2e22f99";
16
+ var MARKETPLACE_1155_CLASS_HASH_MAINNET = "0x01b674aad934be85abc7c1970265cbf7e9bc7d586a90f0a67112c201636dbdd3";
17
+ var MARKETPLACE_1155_START_BLOCK_MAINNET = 9260304;
18
18
  var COLLECTION_721_CONTRACT_MAINNET = "0x05c49ee5d3208a2c2e150fdd0c247d1195ed9ab54fa2d5dea7a633f39e4b205b";
19
19
  var COLLECTION_CONTRACT_MAINNET = COLLECTION_721_CONTRACT_MAINNET;
20
20
  var DROP_FACTORY_CONTRACT_MAINNET = "0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800";
@@ -194,6 +194,30 @@ function buildCancellationTypedData(message, chainId) {
194
194
  message
195
195
  };
196
196
  }
197
+ function encodeByteArray(str) {
198
+ const bytes = new TextEncoder().encode(str);
199
+ const fullChunks = [];
200
+ let i = 0;
201
+ while (i + 31 <= bytes.length) {
202
+ let val = 0n;
203
+ for (const b of bytes.slice(i, i + 31)) {
204
+ val = val << 8n | BigInt(b);
205
+ }
206
+ fullChunks.push(starknet.num.toHex(val));
207
+ i += 31;
208
+ }
209
+ const remaining = bytes.slice(i);
210
+ let pendingVal = 0n;
211
+ for (const b of remaining) {
212
+ pendingVal = pendingVal << 8n | BigInt(b);
213
+ }
214
+ return [
215
+ fullChunks.length.toString(),
216
+ ...fullChunks,
217
+ starknet.num.toHex(pendingVal),
218
+ remaining.length.toString()
219
+ ];
220
+ }
197
221
 
198
222
  // src/abis.ts
199
223
  var IPMarketplaceABI = [
@@ -940,59 +964,80 @@ var CollectionRegistryABI = [
940
964
  var Medialane1155ABI = [
941
965
  {
942
966
  "type": "impl",
943
- "name": "UpgradeableImpl",
944
- "interface_name": "openzeppelin_upgrades::interface::IUpgradeable"
967
+ "name": "Medialane1155V2Impl",
968
+ "interface_name": "medialane_erc1155::core::interface::IMedialane1155V2"
945
969
  },
946
970
  {
947
- "type": "interface",
948
- "name": "openzeppelin_upgrades::interface::IUpgradeable",
949
- "items": [
971
+ "type": "struct",
972
+ "name": "medialane_erc1155::core::types::OfferItem",
973
+ "members": [
950
974
  {
951
- "type": "function",
952
- "name": "upgrade",
953
- "inputs": [
954
- {
955
- "name": "new_class_hash",
956
- "type": "core::starknet::class_hash::ClassHash"
957
- }
958
- ],
959
- "outputs": [],
960
- "state_mutability": "external"
975
+ "name": "item_type",
976
+ "type": "core::felt252"
977
+ },
978
+ {
979
+ "name": "token",
980
+ "type": "core::starknet::contract_address::ContractAddress"
981
+ },
982
+ {
983
+ "name": "identifier_or_criteria",
984
+ "type": "core::felt252"
985
+ },
986
+ {
987
+ "name": "start_amount",
988
+ "type": "core::felt252"
989
+ },
990
+ {
991
+ "name": "end_amount",
992
+ "type": "core::felt252"
961
993
  }
962
994
  ]
963
995
  },
964
- {
965
- "type": "impl",
966
- "name": "Medialane1155Impl",
967
- "interface_name": "medialane_erc1155::core::interface::IMedialane1155"
968
- },
969
996
  {
970
997
  "type": "struct",
971
- "name": "medialane_erc1155::core::types::OrderParameters",
998
+ "name": "medialane_erc1155::core::types::ConsiderationItem",
972
999
  "members": [
973
1000
  {
974
- "name": "offerer",
975
- "type": "core::starknet::contract_address::ContractAddress"
1001
+ "name": "item_type",
1002
+ "type": "core::felt252"
976
1003
  },
977
1004
  {
978
- "name": "nft_contract",
1005
+ "name": "token",
979
1006
  "type": "core::starknet::contract_address::ContractAddress"
980
1007
  },
981
1008
  {
982
- "name": "token_id",
1009
+ "name": "identifier_or_criteria",
1010
+ "type": "core::felt252"
1011
+ },
1012
+ {
1013
+ "name": "start_amount",
983
1014
  "type": "core::felt252"
984
1015
  },
985
1016
  {
986
- "name": "amount",
1017
+ "name": "end_amount",
987
1018
  "type": "core::felt252"
988
1019
  },
989
1020
  {
990
- "name": "payment_token",
1021
+ "name": "recipient",
1022
+ "type": "core::starknet::contract_address::ContractAddress"
1023
+ }
1024
+ ]
1025
+ },
1026
+ {
1027
+ "type": "struct",
1028
+ "name": "medialane_erc1155::core::types::OrderParameters",
1029
+ "members": [
1030
+ {
1031
+ "name": "offerer",
991
1032
  "type": "core::starknet::contract_address::ContractAddress"
992
1033
  },
993
1034
  {
994
- "name": "price_per_unit",
995
- "type": "core::felt252"
1035
+ "name": "offer",
1036
+ "type": "medialane_erc1155::core::types::OfferItem"
1037
+ },
1038
+ {
1039
+ "name": "consideration",
1040
+ "type": "medialane_erc1155::core::types::ConsiderationItem"
996
1041
  },
997
1042
  {
998
1043
  "name": "start_time",
@@ -1038,6 +1083,10 @@ var Medialane1155ABI = [
1038
1083
  "name": "fulfiller",
1039
1084
  "type": "core::starknet::contract_address::ContractAddress"
1040
1085
  },
1086
+ {
1087
+ "name": "quantity",
1088
+ "type": "core::felt252"
1089
+ },
1041
1090
  {
1042
1091
  "name": "nonce",
1043
1092
  "type": "core::felt252"
@@ -1112,20 +1161,6 @@ var Medialane1155ABI = [
1112
1161
  }
1113
1162
  ]
1114
1163
  },
1115
- {
1116
- "type": "enum",
1117
- "name": "core::option::Option::<core::starknet::contract_address::ContractAddress>",
1118
- "variants": [
1119
- {
1120
- "name": "Some",
1121
- "type": "core::starknet::contract_address::ContractAddress"
1122
- },
1123
- {
1124
- "name": "None",
1125
- "type": "()"
1126
- }
1127
- ]
1128
- },
1129
1164
  {
1130
1165
  "type": "struct",
1131
1166
  "name": "medialane_erc1155::core::types::OrderDetails",
@@ -1135,24 +1170,12 @@ var Medialane1155ABI = [
1135
1170
  "type": "core::starknet::contract_address::ContractAddress"
1136
1171
  },
1137
1172
  {
1138
- "name": "nft_contract",
1139
- "type": "core::starknet::contract_address::ContractAddress"
1140
- },
1141
- {
1142
- "name": "token_id",
1143
- "type": "core::felt252"
1144
- },
1145
- {
1146
- "name": "amount",
1147
- "type": "core::felt252"
1173
+ "name": "offer",
1174
+ "type": "medialane_erc1155::core::types::OfferItem"
1148
1175
  },
1149
1176
  {
1150
- "name": "payment_token",
1151
- "type": "core::starknet::contract_address::ContractAddress"
1152
- },
1153
- {
1154
- "name": "price_per_unit",
1155
- "type": "core::felt252"
1177
+ "name": "consideration",
1178
+ "type": "medialane_erc1155::core::types::ConsiderationItem"
1156
1179
  },
1157
1180
  {
1158
1181
  "name": "start_time",
@@ -1167,14 +1190,18 @@ var Medialane1155ABI = [
1167
1190
  "type": "medialane_erc1155::core::types::OrderStatus"
1168
1191
  },
1169
1192
  {
1170
- "name": "fulfiller",
1171
- "type": "core::option::Option::<core::starknet::contract_address::ContractAddress>"
1193
+ "name": "total_amount",
1194
+ "type": "core::felt252"
1195
+ },
1196
+ {
1197
+ "name": "remaining_amount",
1198
+ "type": "core::felt252"
1172
1199
  }
1173
1200
  ]
1174
1201
  },
1175
1202
  {
1176
1203
  "type": "interface",
1177
- "name": "medialane_erc1155::core::interface::IMedialane1155",
1204
+ "name": "medialane_erc1155::core::interface::IMedialane1155V2",
1178
1205
  "items": [
1179
1206
  {
1180
1207
  "type": "function",
@@ -1250,7 +1277,7 @@ var Medialane1155ABI = [
1250
1277
  },
1251
1278
  {
1252
1279
  "type": "function",
1253
- "name": "get_native_token",
1280
+ "name": "get_native_token_address",
1254
1281
  "inputs": [],
1255
1282
  "outputs": [
1256
1283
  {
@@ -1288,150 +1315,10 @@ var Medialane1155ABI = [
1288
1315
  }
1289
1316
  ]
1290
1317
  },
1291
- {
1292
- "type": "impl",
1293
- "name": "SRC5Impl",
1294
- "interface_name": "openzeppelin_introspection::interface::ISRC5"
1295
- },
1296
- {
1297
- "type": "enum",
1298
- "name": "core::bool",
1299
- "variants": [
1300
- {
1301
- "name": "False",
1302
- "type": "()"
1303
- },
1304
- {
1305
- "name": "True",
1306
- "type": "()"
1307
- }
1308
- ]
1309
- },
1310
- {
1311
- "type": "interface",
1312
- "name": "openzeppelin_introspection::interface::ISRC5",
1313
- "items": [
1314
- {
1315
- "type": "function",
1316
- "name": "supports_interface",
1317
- "inputs": [
1318
- {
1319
- "name": "interface_id",
1320
- "type": "core::felt252"
1321
- }
1322
- ],
1323
- "outputs": [
1324
- {
1325
- "type": "core::bool"
1326
- }
1327
- ],
1328
- "state_mutability": "view"
1329
- }
1330
- ]
1331
- },
1332
- {
1333
- "type": "impl",
1334
- "name": "AccessControlImpl",
1335
- "interface_name": "openzeppelin_access::accesscontrol::interface::IAccessControl"
1336
- },
1337
- {
1338
- "type": "interface",
1339
- "name": "openzeppelin_access::accesscontrol::interface::IAccessControl",
1340
- "items": [
1341
- {
1342
- "type": "function",
1343
- "name": "has_role",
1344
- "inputs": [
1345
- {
1346
- "name": "role",
1347
- "type": "core::felt252"
1348
- },
1349
- {
1350
- "name": "account",
1351
- "type": "core::starknet::contract_address::ContractAddress"
1352
- }
1353
- ],
1354
- "outputs": [
1355
- {
1356
- "type": "core::bool"
1357
- }
1358
- ],
1359
- "state_mutability": "view"
1360
- },
1361
- {
1362
- "type": "function",
1363
- "name": "get_role_admin",
1364
- "inputs": [
1365
- {
1366
- "name": "role",
1367
- "type": "core::felt252"
1368
- }
1369
- ],
1370
- "outputs": [
1371
- {
1372
- "type": "core::felt252"
1373
- }
1374
- ],
1375
- "state_mutability": "view"
1376
- },
1377
- {
1378
- "type": "function",
1379
- "name": "grant_role",
1380
- "inputs": [
1381
- {
1382
- "name": "role",
1383
- "type": "core::felt252"
1384
- },
1385
- {
1386
- "name": "account",
1387
- "type": "core::starknet::contract_address::ContractAddress"
1388
- }
1389
- ],
1390
- "outputs": [],
1391
- "state_mutability": "external"
1392
- },
1393
- {
1394
- "type": "function",
1395
- "name": "revoke_role",
1396
- "inputs": [
1397
- {
1398
- "name": "role",
1399
- "type": "core::felt252"
1400
- },
1401
- {
1402
- "name": "account",
1403
- "type": "core::starknet::contract_address::ContractAddress"
1404
- }
1405
- ],
1406
- "outputs": [],
1407
- "state_mutability": "external"
1408
- },
1409
- {
1410
- "type": "function",
1411
- "name": "renounce_role",
1412
- "inputs": [
1413
- {
1414
- "name": "role",
1415
- "type": "core::felt252"
1416
- },
1417
- {
1418
- "name": "account",
1419
- "type": "core::starknet::contract_address::ContractAddress"
1420
- }
1421
- ],
1422
- "outputs": [],
1423
- "state_mutability": "external"
1424
- }
1425
- ]
1426
- },
1427
1318
  {
1428
1319
  "type": "constructor",
1429
1320
  "name": "constructor",
1430
1321
  "inputs": [
1431
- {
1432
- "name": "manager",
1433
- "type": "core::starknet::contract_address::ContractAddress"
1434
- },
1435
1322
  {
1436
1323
  "name": "native_token_address",
1437
1324
  "type": "core::starknet::contract_address::ContractAddress"
@@ -1452,31 +1339,6 @@ var Medialane1155ABI = [
1452
1339
  "name": "offerer",
1453
1340
  "type": "core::starknet::contract_address::ContractAddress",
1454
1341
  "kind": "key"
1455
- },
1456
- {
1457
- "name": "nft_contract",
1458
- "type": "core::starknet::contract_address::ContractAddress",
1459
- "kind": "data"
1460
- },
1461
- {
1462
- "name": "token_id",
1463
- "type": "core::felt252",
1464
- "kind": "data"
1465
- },
1466
- {
1467
- "name": "amount",
1468
- "type": "core::felt252",
1469
- "kind": "data"
1470
- },
1471
- {
1472
- "name": "price_per_unit",
1473
- "type": "core::felt252",
1474
- "kind": "data"
1475
- },
1476
- {
1477
- "name": "payment_token",
1478
- "type": "core::starknet::contract_address::ContractAddress",
1479
- "kind": "data"
1480
1342
  }
1481
1343
  ]
1482
1344
  },
@@ -1514,6 +1376,21 @@ var Medialane1155ABI = [
1514
1376
  "type": "core::starknet::contract_address::ContractAddress",
1515
1377
  "kind": "key"
1516
1378
  },
1379
+ {
1380
+ "name": "quantity",
1381
+ "type": "core::felt252",
1382
+ "kind": "data"
1383
+ },
1384
+ {
1385
+ "name": "remaining_amount",
1386
+ "type": "core::felt252",
1387
+ "kind": "data"
1388
+ },
1389
+ {
1390
+ "name": "sale_amount",
1391
+ "type": "core::integer::u256",
1392
+ "kind": "data"
1393
+ },
1517
1394
  {
1518
1395
  "name": "royalty_receiver",
1519
1396
  "type": "core::starknet::contract_address::ContractAddress",
@@ -1551,162 +1428,12 @@ var Medialane1155ABI = [
1551
1428
  },
1552
1429
  {
1553
1430
  "type": "event",
1554
- "name": "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
1555
- "kind": "struct",
1556
- "members": [
1557
- {
1558
- "name": "class_hash",
1559
- "type": "core::starknet::class_hash::ClassHash",
1560
- "kind": "data"
1561
- }
1562
- ]
1563
- },
1564
- {
1565
- "type": "event",
1566
- "name": "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
1431
+ "name": "medialane_erc1155::core::medialane::Medialane1155V2::Event",
1567
1432
  "kind": "enum",
1568
1433
  "variants": [
1569
1434
  {
1570
- "name": "Upgraded",
1571
- "type": "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
1572
- "kind": "nested"
1573
- }
1574
- ]
1575
- },
1576
- {
1577
- "type": "event",
1578
- "name": "openzeppelin_introspection::src5::SRC5Component::Event",
1579
- "kind": "enum",
1580
- "variants": []
1581
- },
1582
- {
1583
- "type": "event",
1584
- "name": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
1585
- "kind": "struct",
1586
- "members": [
1587
- {
1588
- "name": "role",
1589
- "type": "core::felt252",
1590
- "kind": "data"
1591
- },
1592
- {
1593
- "name": "account",
1594
- "type": "core::starknet::contract_address::ContractAddress",
1595
- "kind": "data"
1596
- },
1597
- {
1598
- "name": "sender",
1599
- "type": "core::starknet::contract_address::ContractAddress",
1600
- "kind": "data"
1601
- }
1602
- ]
1603
- },
1604
- {
1605
- "type": "event",
1606
- "name": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
1607
- "kind": "struct",
1608
- "members": [
1609
- {
1610
- "name": "role",
1611
- "type": "core::felt252",
1612
- "kind": "data"
1613
- },
1614
- {
1615
- "name": "account",
1616
- "type": "core::starknet::contract_address::ContractAddress",
1617
- "kind": "data"
1618
- },
1619
- {
1620
- "name": "sender",
1621
- "type": "core::starknet::contract_address::ContractAddress",
1622
- "kind": "data"
1623
- },
1624
- {
1625
- "name": "delay",
1626
- "type": "core::integer::u64",
1627
- "kind": "data"
1628
- }
1629
- ]
1630
- },
1631
- {
1632
- "type": "event",
1633
- "name": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
1634
- "kind": "struct",
1635
- "members": [
1636
- {
1637
- "name": "role",
1638
- "type": "core::felt252",
1639
- "kind": "data"
1640
- },
1641
- {
1642
- "name": "account",
1643
- "type": "core::starknet::contract_address::ContractAddress",
1644
- "kind": "data"
1645
- },
1646
- {
1647
- "name": "sender",
1648
- "type": "core::starknet::contract_address::ContractAddress",
1649
- "kind": "data"
1650
- }
1651
- ]
1652
- },
1653
- {
1654
- "type": "event",
1655
- "name": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
1656
- "kind": "struct",
1657
- "members": [
1658
- {
1659
- "name": "role",
1660
- "type": "core::felt252",
1661
- "kind": "data"
1662
- },
1663
- {
1664
- "name": "previous_admin_role",
1665
- "type": "core::felt252",
1666
- "kind": "data"
1667
- },
1668
- {
1669
- "name": "new_admin_role",
1670
- "type": "core::felt252",
1671
- "kind": "data"
1672
- }
1673
- ]
1674
- },
1675
- {
1676
- "type": "event",
1677
- "name": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
1678
- "kind": "enum",
1679
- "variants": [
1680
- {
1681
- "name": "RoleGranted",
1682
- "type": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
1683
- "kind": "nested"
1684
- },
1685
- {
1686
- "name": "RoleGrantedWithDelay",
1687
- "type": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
1688
- "kind": "nested"
1689
- },
1690
- {
1691
- "name": "RoleRevoked",
1692
- "type": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
1693
- "kind": "nested"
1694
- },
1695
- {
1696
- "name": "RoleAdminChanged",
1697
- "type": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
1698
- "kind": "nested"
1699
- }
1700
- ]
1701
- },
1702
- {
1703
- "type": "event",
1704
- "name": "medialane_erc1155::core::medialane::Medialane1155::Event",
1705
- "kind": "enum",
1706
- "variants": [
1707
- {
1708
- "name": "OrderCreated",
1709
- "type": "medialane_erc1155::core::events::OrderCreated",
1435
+ "name": "OrderCreated",
1436
+ "type": "medialane_erc1155::core::events::OrderCreated",
1710
1437
  "kind": "nested"
1711
1438
  },
1712
1439
  {
@@ -1723,21 +1450,6 @@ var Medialane1155ABI = [
1723
1450
  "name": "NoncesEvent",
1724
1451
  "type": "openzeppelin_utils::cryptography::nonces::NoncesComponent::Event",
1725
1452
  "kind": "flat"
1726
- },
1727
- {
1728
- "name": "UpgradeableEvent",
1729
- "type": "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
1730
- "kind": "flat"
1731
- },
1732
- {
1733
- "name": "SRC5Event",
1734
- "type": "openzeppelin_introspection::src5::SRC5Component::Event",
1735
- "kind": "flat"
1736
- },
1737
- {
1738
- "name": "AccessControlEvent",
1739
- "type": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
1740
- "kind": "flat"
1741
1453
  }
1742
1454
  ]
1743
1455
  }
@@ -1991,7 +1703,7 @@ function getListableTokens() {
1991
1703
  return SUPPORTED_TOKENS.filter((t) => t.listable);
1992
1704
  }
1993
1705
 
1994
- // src/marketplace/orders.ts
1706
+ // src/marketplace/errors.ts
1995
1707
  var MedialaneError = class extends Error {
1996
1708
  constructor(message, code = "UNKNOWN", cause) {
1997
1709
  super(message);
@@ -2000,6 +1712,7 @@ var MedialaneError = class extends Error {
2000
1712
  this.name = "MedialaneError";
2001
1713
  }
2002
1714
  };
1715
+ var START_TIME_BUFFER_SECS = 30;
2003
1716
  function toSignatureArray(sig) {
2004
1717
  if (Array.isArray(sig)) return sig;
2005
1718
  const s = sig;
@@ -2008,35 +1721,36 @@ function toSignatureArray(sig) {
2008
1721
  function getChainId(_config) {
2009
1722
  return starknet.constants.StarknetChainId.SN_MAIN;
2010
1723
  }
2011
- var _contractCache = /* @__PURE__ */ new WeakMap();
1724
+ function resolveToken(currency) {
1725
+ const token = SUPPORTED_TOKENS.find(
1726
+ (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
1727
+ );
1728
+ if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
1729
+ return token;
1730
+ }
2012
1731
  var _providerCache = /* @__PURE__ */ new WeakMap();
2013
1732
  function getProvider(config) {
2014
- let provider = _providerCache.get(config);
2015
- if (!provider) {
2016
- provider = new starknet.RpcProvider({ nodeUrl: config.rpcUrl });
2017
- _providerCache.set(config, provider);
1733
+ let p = _providerCache.get(config);
1734
+ if (!p) {
1735
+ p = new starknet.RpcProvider({ nodeUrl: config.rpcUrl });
1736
+ _providerCache.set(config, p);
2018
1737
  }
2019
- return provider;
1738
+ return p;
2020
1739
  }
1740
+
1741
+ // src/marketplace/orders.ts
1742
+ var _contractCache = /* @__PURE__ */ new WeakMap();
2021
1743
  function makeContract(config) {
2022
1744
  const cached = _contractCache.get(config);
2023
- if (cached) return cached;
2024
1745
  const provider = getProvider(config);
1746
+ if (cached) return { ...cached, provider };
2025
1747
  const contract = new starknet.Contract(
2026
1748
  IPMarketplaceABI,
2027
1749
  config.marketplaceContract,
2028
1750
  provider
2029
1751
  );
2030
- const result = { contract, provider };
2031
- _contractCache.set(config, result);
2032
- return result;
2033
- }
2034
- function resolveToken(currency) {
2035
- const token = SUPPORTED_TOKENS.find(
2036
- (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
2037
- );
2038
- if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
2039
- return token;
1752
+ _contractCache.set(config, { contract });
1753
+ return { contract, provider };
2040
1754
  }
2041
1755
  async function createListing(account, params, config) {
2042
1756
  const { nftContract, tokenId, price, currency = DEFAULT_CURRENCY, durationSeconds } = params;
@@ -2044,7 +1758,7 @@ async function createListing(account, params, config) {
2044
1758
  const token = resolveToken(currency);
2045
1759
  const priceWei = parseAmount(price, token.decimals);
2046
1760
  const now = Math.floor(Date.now() / 1e3);
2047
- const startTime = now + 300;
1761
+ const startTime = now + START_TIME_BUFFER_SECS;
2048
1762
  const endTime = now + durationSeconds;
2049
1763
  const saltBytes = new Uint8Array(4);
2050
1764
  crypto.getRandomValues(saltBytes);
@@ -2128,7 +1842,7 @@ async function makeOffer(account, params, config) {
2128
1842
  const token = resolveToken(currency);
2129
1843
  const priceWei = parseAmount(price, token.decimals);
2130
1844
  const now = Math.floor(Date.now() / 1e3);
2131
- const startTime = now + 300;
1845
+ const startTime = now + START_TIME_BUFFER_SECS;
2132
1846
  const endTime = now + durationSeconds;
2133
1847
  const saltBytes = new Uint8Array(4);
2134
1848
  crypto.getRandomValues(saltBytes);
@@ -2194,7 +1908,7 @@ async function makeOffer(account, params, config) {
2194
1908
  }
2195
1909
  }
2196
1910
  async function fulfillOrder(account, params, config) {
2197
- const { orderHash } = params;
1911
+ const { orderHash, paymentToken, totalPrice } = params;
2198
1912
  const { contract, provider } = makeContract(config);
2199
1913
  const currentNonce = await contract.nonces(account.address);
2200
1914
  const chainId = getChainId();
@@ -2212,9 +1926,19 @@ async function fulfillOrder(account, params, config) {
2212
1926
  fulfillment: fulfillmentParams,
2213
1927
  signature: signatureArray
2214
1928
  });
2215
- const call = contract.populate("fulfill_order", [fulfillPayload]);
1929
+ const totalPriceU256 = starknet.cairo.uint256(totalPrice);
1930
+ const approveCall = {
1931
+ contractAddress: paymentToken,
1932
+ entrypoint: "approve",
1933
+ calldata: [
1934
+ config.marketplaceContract,
1935
+ totalPriceU256.low.toString(),
1936
+ totalPriceU256.high.toString()
1937
+ ]
1938
+ };
1939
+ const fulfillCall = contract.populate("fulfill_order", [fulfillPayload]);
2216
1940
  try {
2217
- const tx = await account.execute(call);
1941
+ const tx = await account.execute([approveCall, fulfillCall]);
2218
1942
  await provider.waitForTransaction(tx.transaction_hash);
2219
1943
  return { txHash: tx.transaction_hash };
2220
1944
  } catch (err) {
@@ -2249,15 +1973,6 @@ async function cancelOrder(account, params, config) {
2249
1973
  throw new MedialaneError("Failed to cancel order", "TRANSACTION_FAILED", err);
2250
1974
  }
2251
1975
  }
2252
- function encodeByteArray(str) {
2253
- const ba = starknet.byteArray.byteArrayFromString(str);
2254
- return [
2255
- ba.data.length.toString(),
2256
- ...ba.data.map((d) => starknet.num.toHex(d)),
2257
- starknet.num.toHex(ba.pending_word),
2258
- ba.pending_word_len.toString()
2259
- ];
2260
- }
2261
1976
  async function mint(account, params, config) {
2262
1977
  const { collectionId, recipient, tokenUri, collectionContract } = params;
2263
1978
  const provider = getProvider(config);
@@ -2340,6 +2055,14 @@ async function checkoutCart(account, items, config) {
2340
2055
  throw new MedialaneError("Cart checkout failed", "TRANSACTION_FAILED", err);
2341
2056
  }
2342
2057
  }
2058
+ async function getOrderDetails(orderHash, config) {
2059
+ const { contract } = makeContract(config);
2060
+ return contract.get_order_details(orderHash);
2061
+ }
2062
+ async function getNonce(address, config) {
2063
+ const { contract } = makeContract(config);
2064
+ return BigInt((await contract.nonces(address)).toString());
2065
+ }
2343
2066
 
2344
2067
  // src/marketplace/index.ts
2345
2068
  var MarketplaceModule = class {
@@ -2368,6 +2091,13 @@ var MarketplaceModule = class {
2368
2091
  createCollection(account, params) {
2369
2092
  return createCollection(account, params, this.config);
2370
2093
  }
2094
+ // ─── View calls ───────────────────────────────────────────────────────────
2095
+ getOrderDetails(orderHash) {
2096
+ return getOrderDetails(orderHash, this.config);
2097
+ }
2098
+ getNonce(address) {
2099
+ return getNonce(address, this.config);
2100
+ }
2371
2101
  // ─── Typed data builders (for ChipiPay / custom signing flows) ───────────
2372
2102
  buildListingTypedData(params, chainId) {
2373
2103
  return buildOrderTypedData(params, chainId);
@@ -2387,8 +2117,8 @@ var STARKNET_DOMAIN = [
2387
2117
  ];
2388
2118
  function domain1155(chainId) {
2389
2119
  return {
2390
- name: "Medialane1155",
2391
- version: "1",
2120
+ name: "Medialane",
2121
+ version: "2",
2392
2122
  chainId,
2393
2123
  revision: starknet.TypedDataRevision.ACTIVE
2394
2124
  };
@@ -2399,13 +2129,25 @@ function build1155OrderTypedData(message, chainId) {
2399
2129
  primaryType: "OrderParameters",
2400
2130
  types: {
2401
2131
  StarknetDomain: STARKNET_DOMAIN,
2132
+ OfferItem: [
2133
+ { name: "item_type", type: "shortstring" },
2134
+ { name: "token", type: "ContractAddress" },
2135
+ { name: "identifier_or_criteria", type: "felt" },
2136
+ { name: "start_amount", type: "felt" },
2137
+ { name: "end_amount", type: "felt" }
2138
+ ],
2139
+ ConsiderationItem: [
2140
+ { name: "item_type", type: "shortstring" },
2141
+ { name: "token", type: "ContractAddress" },
2142
+ { name: "identifier_or_criteria", type: "felt" },
2143
+ { name: "start_amount", type: "felt" },
2144
+ { name: "end_amount", type: "felt" },
2145
+ { name: "recipient", type: "ContractAddress" }
2146
+ ],
2402
2147
  OrderParameters: [
2403
2148
  { name: "offerer", type: "ContractAddress" },
2404
- { name: "nft_contract", type: "ContractAddress" },
2405
- { name: "token_id", type: "felt" },
2406
- { name: "amount", type: "felt" },
2407
- { name: "payment_token", type: "ContractAddress" },
2408
- { name: "price_per_unit", type: "felt" },
2149
+ { name: "offer", type: "OfferItem" },
2150
+ { name: "consideration", type: "ConsiderationItem" },
2409
2151
  { name: "start_time", type: "felt" },
2410
2152
  { name: "end_time", type: "felt" },
2411
2153
  { name: "salt", type: "felt" },
@@ -2446,28 +2188,11 @@ function build1155CancellationTypedData(message, chainId) {
2446
2188
  message
2447
2189
  };
2448
2190
  }
2449
- function toSignatureArray2(sig) {
2450
- if (Array.isArray(sig)) return sig;
2451
- const s = sig;
2452
- return [s.r.toString(), s.s.toString()];
2453
- }
2454
- function getChainId2(_config) {
2455
- return starknet.constants.StarknetChainId.SN_MAIN;
2456
- }
2457
- var _providerCache2 = /* @__PURE__ */ new WeakMap();
2458
2191
  var _contractCache2 = /* @__PURE__ */ new WeakMap();
2459
- function getProvider2(config) {
2460
- let p = _providerCache2.get(config);
2461
- if (!p) {
2462
- p = new starknet.RpcProvider({ nodeUrl: config.rpcUrl });
2463
- _providerCache2.set(config, p);
2464
- }
2465
- return p;
2466
- }
2467
2192
  function getContract(config) {
2468
2193
  let c = _contractCache2.get(config);
2469
2194
  if (!c) {
2470
- const provider = getProvider2(config);
2195
+ const provider = getProvider(config);
2471
2196
  c = new starknet.Contract(
2472
2197
  Medialane1155ABI,
2473
2198
  config.marketplace1155Contract,
@@ -2477,13 +2202,6 @@ function getContract(config) {
2477
2202
  }
2478
2203
  return c;
2479
2204
  }
2480
- function resolveToken2(currency) {
2481
- const token = SUPPORTED_TOKENS.find(
2482
- (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
2483
- );
2484
- if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
2485
- return token;
2486
- }
2487
2205
  async function createListing1155(account, params, config) {
2488
2206
  const {
2489
2207
  nftContract,
@@ -2494,8 +2212,8 @@ async function createListing1155(account, params, config) {
2494
2212
  durationSeconds
2495
2213
  } = params;
2496
2214
  const contract = getContract(config);
2497
- const provider = getProvider2(config);
2498
- const token = resolveToken2(currency);
2215
+ const provider = getProvider(config);
2216
+ const token = resolveToken(currency);
2499
2217
  const priceWei = parseAmount(pricePerUnit, token.decimals);
2500
2218
  const now = Math.floor(Date.now() / 1e3);
2501
2219
  const endTime = now + durationSeconds;
@@ -2503,15 +2221,25 @@ async function createListing1155(account, params, config) {
2503
2221
  crypto.getRandomValues(saltBytes);
2504
2222
  const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
2505
2223
  const currentNonce = await contract.nonces(account.address);
2506
- const chainId = getChainId2();
2224
+ const chainId = getChainId();
2507
2225
  const orderParams = {
2508
2226
  offerer: account.address,
2509
- nft_contract: nftContract,
2510
- token_id: tokenId,
2511
- amount,
2512
- payment_token: token.address,
2513
- price_per_unit: priceWei,
2514
- start_time: now.toString(),
2227
+ offer: {
2228
+ item_type: "ERC1155",
2229
+ token: nftContract,
2230
+ identifier_or_criteria: tokenId,
2231
+ start_amount: amount,
2232
+ end_amount: amount
2233
+ },
2234
+ consideration: {
2235
+ item_type: "ERC20",
2236
+ token: token.address,
2237
+ identifier_or_criteria: "0",
2238
+ start_amount: priceWei,
2239
+ end_amount: priceWei,
2240
+ recipient: account.address
2241
+ },
2242
+ start_time: (now + START_TIME_BUFFER_SECS).toString(),
2515
2243
  end_time: endTime.toString(),
2516
2244
  salt,
2517
2245
  nonce: currentNonce.toString()
@@ -2520,9 +2248,19 @@ async function createListing1155(account, params, config) {
2520
2248
  build1155OrderTypedData(orderParams, chainId)
2521
2249
  );
2522
2250
  const signature = await account.signMessage(typedData);
2523
- const signatureArray = toSignatureArray2(signature);
2251
+ const signatureArray = toSignatureArray(signature);
2524
2252
  const orderPayload = stringifyBigInts({
2525
- parameters: orderParams,
2253
+ parameters: {
2254
+ ...orderParams,
2255
+ offer: {
2256
+ ...orderParams.offer,
2257
+ item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type)
2258
+ },
2259
+ consideration: {
2260
+ ...orderParams.consideration,
2261
+ item_type: starknet.shortString.encodeShortString(orderParams.consideration.item_type)
2262
+ }
2263
+ },
2526
2264
  signature: signatureArray
2527
2265
  });
2528
2266
  let isApproved = false;
@@ -2555,8 +2293,8 @@ async function createListing1155(account, params, config) {
2555
2293
  async function fulfillOrder1155(account, params, config) {
2556
2294
  const { orderHash, paymentToken, totalPrice, quantity = "1" } = params;
2557
2295
  const contract = getContract(config);
2558
- const provider = getProvider2(config);
2559
- const chainId = getChainId2();
2296
+ const provider = getProvider(config);
2297
+ const chainId = getChainId();
2560
2298
  const currentNonce = await contract.nonces(account.address);
2561
2299
  const fulfillmentParams = {
2562
2300
  order_hash: orderHash,
@@ -2568,7 +2306,7 @@ async function fulfillOrder1155(account, params, config) {
2568
2306
  build1155FulfillmentTypedData(fulfillmentParams, chainId)
2569
2307
  );
2570
2308
  const signature = await account.signMessage(typedData);
2571
- const signatureArray = toSignatureArray2(signature);
2309
+ const signatureArray = toSignatureArray(signature);
2572
2310
  const fulfillPayload = stringifyBigInts({
2573
2311
  fulfillment: fulfillmentParams,
2574
2312
  signature: signatureArray
@@ -2595,8 +2333,8 @@ async function fulfillOrder1155(account, params, config) {
2595
2333
  async function cancelOrder1155(account, params, config) {
2596
2334
  const { orderHash } = params;
2597
2335
  const contract = getContract(config);
2598
- const provider = getProvider2(config);
2599
- const chainId = getChainId2();
2336
+ const provider = getProvider(config);
2337
+ const chainId = getChainId();
2600
2338
  const currentNonce = await contract.nonces(account.address);
2601
2339
  const cancelParams = {
2602
2340
  order_hash: orderHash,
@@ -2607,7 +2345,7 @@ async function cancelOrder1155(account, params, config) {
2607
2345
  build1155CancellationTypedData(cancelParams, chainId)
2608
2346
  );
2609
2347
  const signature = await account.signMessage(typedData);
2610
- const signatureArray = toSignatureArray2(signature);
2348
+ const signatureArray = toSignatureArray(signature);
2611
2349
  const cancelPayload = stringifyBigInts({
2612
2350
  cancelation: cancelParams,
2613
2351
  signature: signatureArray
@@ -2621,6 +2359,148 @@ async function cancelOrder1155(account, params, config) {
2621
2359
  throw new MedialaneError("Failed to cancel ERC-1155 order", "TRANSACTION_FAILED", err);
2622
2360
  }
2623
2361
  }
2362
+ async function makeOffer1155(account, params, config) {
2363
+ const {
2364
+ nftContract,
2365
+ tokenId,
2366
+ amount,
2367
+ price,
2368
+ currency = DEFAULT_CURRENCY,
2369
+ durationSeconds
2370
+ } = params;
2371
+ const contract = getContract(config);
2372
+ const provider = getProvider(config);
2373
+ const chainId = getChainId();
2374
+ const token = resolveToken(currency);
2375
+ const priceWei = parseAmount(price, token.decimals);
2376
+ const now = Math.floor(Date.now() / 1e3);
2377
+ const endTime = now + durationSeconds;
2378
+ const saltBytes = new Uint8Array(4);
2379
+ crypto.getRandomValues(saltBytes);
2380
+ const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
2381
+ const currentNonce = await contract.nonces(account.address);
2382
+ const orderParams = {
2383
+ offerer: account.address,
2384
+ offer: {
2385
+ item_type: "ERC20",
2386
+ token: token.address,
2387
+ identifier_or_criteria: "0",
2388
+ start_amount: priceWei,
2389
+ end_amount: priceWei
2390
+ },
2391
+ consideration: {
2392
+ item_type: "ERC1155",
2393
+ token: nftContract,
2394
+ identifier_or_criteria: tokenId,
2395
+ start_amount: amount,
2396
+ end_amount: amount,
2397
+ recipient: account.address
2398
+ },
2399
+ start_time: (now + START_TIME_BUFFER_SECS).toString(),
2400
+ end_time: endTime.toString(),
2401
+ salt,
2402
+ nonce: currentNonce.toString()
2403
+ };
2404
+ const typedData = stringifyBigInts(
2405
+ build1155OrderTypedData(orderParams, chainId)
2406
+ );
2407
+ const signature = await account.signMessage(typedData);
2408
+ const signatureArray = toSignatureArray(signature);
2409
+ const registerPayload = stringifyBigInts({
2410
+ parameters: {
2411
+ ...orderParams,
2412
+ offer: {
2413
+ ...orderParams.offer,
2414
+ item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type)
2415
+ },
2416
+ consideration: {
2417
+ ...orderParams.consideration,
2418
+ item_type: starknet.shortString.encodeShortString(orderParams.consideration.item_type)
2419
+ }
2420
+ },
2421
+ signature: signatureArray
2422
+ });
2423
+ const amountU256 = starknet.cairo.uint256(priceWei);
2424
+ const approveCall = {
2425
+ contractAddress: token.address,
2426
+ entrypoint: "approve",
2427
+ calldata: [
2428
+ config.marketplace1155Contract,
2429
+ amountU256.low.toString(),
2430
+ amountU256.high.toString()
2431
+ ]
2432
+ };
2433
+ const registerCall = contract.populate("register_order", [registerPayload]);
2434
+ try {
2435
+ const tx = await account.execute([approveCall, registerCall]);
2436
+ await provider.waitForTransaction(tx.transaction_hash);
2437
+ return { txHash: tx.transaction_hash };
2438
+ } catch (err) {
2439
+ throw new MedialaneError("Failed to make ERC-1155 offer", "TRANSACTION_FAILED", err);
2440
+ }
2441
+ }
2442
+ async function checkoutCart1155(account, items, config) {
2443
+ if (items.length === 0) throw new MedialaneError("Cart is empty", "INVALID_PARAMS");
2444
+ const contract = getContract(config);
2445
+ const provider = getProvider(config);
2446
+ const tokenTotals = /* @__PURE__ */ new Map();
2447
+ for (const item of items) {
2448
+ const prev = tokenTotals.get(item.considerationToken) ?? 0n;
2449
+ tokenTotals.set(item.considerationToken, prev + BigInt(item.considerationAmount));
2450
+ }
2451
+ const approveCalls = Array.from(tokenTotals.entries()).map(([tokenAddr, totalWei]) => {
2452
+ const amount = starknet.cairo.uint256(totalWei.toString());
2453
+ return {
2454
+ contractAddress: tokenAddr,
2455
+ entrypoint: "approve",
2456
+ calldata: [
2457
+ config.marketplace1155Contract,
2458
+ amount.low.toString(),
2459
+ amount.high.toString()
2460
+ ]
2461
+ };
2462
+ });
2463
+ const currentNonce = await contract.nonces(account.address);
2464
+ const baseNonce = BigInt(currentNonce.toString());
2465
+ const chainId = getChainId();
2466
+ const fulfillCalls = [];
2467
+ for (let i = 0; i < items.length; i++) {
2468
+ const item = items[i];
2469
+ const nonce = (baseNonce + BigInt(i)).toString();
2470
+ const quantity = item.quantity ?? "1";
2471
+ const fulfillmentParams = {
2472
+ order_hash: item.orderHash,
2473
+ fulfiller: account.address,
2474
+ quantity,
2475
+ nonce
2476
+ };
2477
+ const typedData = stringifyBigInts(
2478
+ build1155FulfillmentTypedData(fulfillmentParams, chainId)
2479
+ );
2480
+ const signature = await account.signMessage(typedData);
2481
+ const signatureArray = toSignatureArray(signature);
2482
+ const fulfillPayload = stringifyBigInts({
2483
+ fulfillment: fulfillmentParams,
2484
+ signature: signatureArray
2485
+ });
2486
+ fulfillCalls.push(contract.populate("fulfill_order", [fulfillPayload]));
2487
+ }
2488
+ try {
2489
+ const tx = await account.execute([...approveCalls, ...fulfillCalls]);
2490
+ await provider.waitForTransaction(tx.transaction_hash);
2491
+ return { txHash: tx.transaction_hash };
2492
+ } catch (err) {
2493
+ throw new MedialaneError("ERC-1155 cart checkout failed", "TRANSACTION_FAILED", err);
2494
+ }
2495
+ }
2496
+ async function getOrderDetails1155(orderHash, config) {
2497
+ const contract = getContract(config);
2498
+ return contract.get_order_details(orderHash);
2499
+ }
2500
+ async function getNonce1155(address, config) {
2501
+ const contract = getContract(config);
2502
+ return BigInt((await contract.nonces(address)).toString());
2503
+ }
2624
2504
 
2625
2505
  // src/marketplace1155/index.ts
2626
2506
  var Medialane1155Module = class {
@@ -2635,6 +2515,13 @@ var Medialane1155Module = class {
2635
2515
  createListing(account, params) {
2636
2516
  return createListing1155(account, params, this.config);
2637
2517
  }
2518
+ /**
2519
+ * Make an offer (bid) on an ERC-1155 token.
2520
+ * Approves the ERC-20 spend then calls `register_order` atomically.
2521
+ */
2522
+ makeOffer(account, params) {
2523
+ return makeOffer1155(account, params, this.config);
2524
+ }
2638
2525
  /**
2639
2526
  * Fulfill (buy) an ERC-1155 listing.
2640
2527
  * Approves the payment token then calls `fulfill_order` atomically.
@@ -2648,6 +2535,20 @@ var Medialane1155Module = class {
2648
2535
  cancelOrder(account, params) {
2649
2536
  return cancelOrder1155(account, params, this.config);
2650
2537
  }
2538
+ /**
2539
+ * Checkout a cart of ERC-1155 orders atomically.
2540
+ * Signs one fulfillment per item (with quantity), sums ERC-20 approvals by token.
2541
+ */
2542
+ checkoutCart(account, items) {
2543
+ return checkoutCart1155(account, items, this.config);
2544
+ }
2545
+ // ─── View calls ───────────────────────────────────────────────────────────
2546
+ getOrderDetails(orderHash) {
2547
+ return getOrderDetails1155(orderHash, this.config);
2548
+ }
2549
+ getNonce(address) {
2550
+ return getNonce1155(address, this.config);
2551
+ }
2651
2552
  // ─── Typed data builders (for ChipiPay / custom signing flows) ───────────
2652
2553
  buildListingTypedData(params, chainId) {
2653
2554
  return build1155OrderTypedData(params, chainId);
@@ -3355,44 +3256,6 @@ var DropService = class {
3355
3256
  return { txHash: res.transaction_hash };
3356
3257
  }
3357
3258
  };
3358
-
3359
- // src/client.ts
3360
- var MedialaneClient = class {
3361
- constructor(rawConfig = {}) {
3362
- this.config = resolveConfig(rawConfig);
3363
- this.marketplace = new MarketplaceModule(this.config);
3364
- this.marketplace1155 = new Medialane1155Module(this.config);
3365
- this.services = {
3366
- pop: new PopService(this.config),
3367
- drop: new DropService(this.config)
3368
- };
3369
- if (!this.config.backendUrl) {
3370
- this.api = new Proxy({}, {
3371
- get(_target, prop) {
3372
- return () => {
3373
- throw new Error(
3374
- `backendUrl not configured. Pass backendUrl to MedialaneClient to use .api.${String(prop)}()`
3375
- );
3376
- };
3377
- }
3378
- });
3379
- } else {
3380
- this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions);
3381
- }
3382
- }
3383
- get network() {
3384
- return this.config.network;
3385
- }
3386
- get rpcUrl() {
3387
- return this.config.rpcUrl;
3388
- }
3389
- get marketplaceContract() {
3390
- return this.config.marketplaceContract;
3391
- }
3392
- };
3393
-
3394
- // src/types/api.ts
3395
- var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
3396
3259
  var ERC1155CollectionService = class {
3397
3260
  constructor(config) {
3398
3261
  this.factoryAddress = config.collection1155Contract ?? COLLECTION_1155_CONTRACT_MAINNET;
@@ -3501,6 +3364,45 @@ var ERC1155CollectionService = class {
3501
3364
  }
3502
3365
  };
3503
3366
 
3367
+ // src/client.ts
3368
+ var MedialaneClient = class {
3369
+ constructor(rawConfig = {}) {
3370
+ this.config = resolveConfig(rawConfig);
3371
+ this.marketplace = new MarketplaceModule(this.config);
3372
+ this.marketplace1155 = new Medialane1155Module(this.config);
3373
+ this.services = {
3374
+ pop: new PopService(this.config),
3375
+ drop: new DropService(this.config),
3376
+ erc1155Collection: new ERC1155CollectionService(this.config)
3377
+ };
3378
+ if (!this.config.backendUrl) {
3379
+ this.api = new Proxy({}, {
3380
+ get(_target, prop) {
3381
+ return () => {
3382
+ throw new Error(
3383
+ `backendUrl not configured. Pass backendUrl to MedialaneClient to use .api.${String(prop)}()`
3384
+ );
3385
+ };
3386
+ }
3387
+ });
3388
+ } else {
3389
+ this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions);
3390
+ }
3391
+ }
3392
+ get network() {
3393
+ return this.config.network;
3394
+ }
3395
+ get rpcUrl() {
3396
+ return this.config.rpcUrl;
3397
+ }
3398
+ get marketplaceContract() {
3399
+ return this.config.marketplaceContract;
3400
+ }
3401
+ };
3402
+
3403
+ // src/types/api.ts
3404
+ var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
3405
+
3504
3406
  exports.ApiClient = ApiClient;
3505
3407
  exports.COLLECTION_1155_CLASS_HASH_MAINNET = COLLECTION_1155_CLASS_HASH_MAINNET;
3506
3408
  exports.COLLECTION_1155_CONTRACT_MAINNET = COLLECTION_1155_CONTRACT_MAINNET;
@@ -3550,6 +3452,7 @@ exports.build1155OrderTypedData = build1155OrderTypedData;
3550
3452
  exports.buildCancellationTypedData = buildCancellationTypedData;
3551
3453
  exports.buildFulfillmentTypedData = buildFulfillmentTypedData;
3552
3454
  exports.buildOrderTypedData = buildOrderTypedData;
3455
+ exports.encodeByteArray = encodeByteArray;
3553
3456
  exports.formatAmount = formatAmount;
3554
3457
  exports.getListableTokens = getListableTokens;
3555
3458
  exports.getTokenByAddress = getTokenByAddress;