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