@medialane/sdk 0.6.9 → 0.7.1

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
@@ -49,6 +49,8 @@ var SUPPORTED_NETWORKS = ["mainnet"];
49
49
  var DEFAULT_RPC_URL = "https://rpc.starknet.lava.build";
50
50
  var POP_COLLECTION_CLASS_HASH_MAINNET = "0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f";
51
51
  var DROP_COLLECTION_CLASS_HASH_MAINNET = "0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282";
52
+ var ERC1155_FACTORY_CONTRACT_MAINNET = "0x006b2dc7ca7c4f466bb4575ba043d934310f052074f849caf853a86bcb819fd6";
53
+ var ERC1155_COLLECTION_CLASS_HASH_MAINNET = "0x39a85126c6627db263617e5bce2bb72e49d2bb1f20961efc8b8954665bcfd25";
52
54
 
53
55
  // src/config.ts
54
56
  var MedialaneConfigSchema = zod.z.object({
@@ -1720,6 +1722,206 @@ var Medialane1155ABI = [
1720
1722
  ]
1721
1723
  }
1722
1724
  ];
1725
+ var IPCollection1155FactoryABI = [
1726
+ {
1727
+ type: "function",
1728
+ name: "collection_class_hash",
1729
+ inputs: [],
1730
+ outputs: [{ type: "core::starknet::class_hash::ClassHash" }],
1731
+ state_mutability: "view"
1732
+ },
1733
+ {
1734
+ type: "function",
1735
+ name: "deploy_collection",
1736
+ inputs: [
1737
+ { name: "name", type: "core::byte_array::ByteArray" },
1738
+ { name: "symbol", type: "core::byte_array::ByteArray" },
1739
+ { name: "base_uri", type: "core::byte_array::ByteArray" }
1740
+ ],
1741
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1742
+ state_mutability: "external"
1743
+ },
1744
+ {
1745
+ type: "function",
1746
+ name: "update_collection_class_hash",
1747
+ inputs: [{ name: "new_class_hash", type: "core::starknet::class_hash::ClassHash" }],
1748
+ outputs: [],
1749
+ state_mutability: "external"
1750
+ },
1751
+ {
1752
+ type: "function",
1753
+ name: "owner",
1754
+ inputs: [],
1755
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1756
+ state_mutability: "view"
1757
+ }
1758
+ ];
1759
+ var IPCollection1155ABI = [
1760
+ // ── Metadata views ──────────────────────────────────────────────────────────
1761
+ {
1762
+ type: "function",
1763
+ name: "name",
1764
+ inputs: [],
1765
+ outputs: [{ type: "core::byte_array::ByteArray" }],
1766
+ state_mutability: "view"
1767
+ },
1768
+ {
1769
+ type: "function",
1770
+ name: "symbol",
1771
+ inputs: [],
1772
+ outputs: [{ type: "core::byte_array::ByteArray" }],
1773
+ state_mutability: "view"
1774
+ },
1775
+ {
1776
+ type: "function",
1777
+ name: "base_uri",
1778
+ inputs: [],
1779
+ outputs: [{ type: "core::byte_array::ByteArray" }],
1780
+ state_mutability: "view"
1781
+ },
1782
+ {
1783
+ type: "function",
1784
+ name: "uri",
1785
+ inputs: [{ name: "token_id", type: "core::integer::u256" }],
1786
+ outputs: [{ type: "core::byte_array::ByteArray" }],
1787
+ state_mutability: "view"
1788
+ },
1789
+ // ── Minting ─────────────────────────────────────────────────────────────────
1790
+ {
1791
+ type: "function",
1792
+ name: "mint_item",
1793
+ inputs: [
1794
+ { name: "to", type: "core::starknet::contract_address::ContractAddress" },
1795
+ { name: "token_id", type: "core::integer::u256" },
1796
+ { name: "value", type: "core::integer::u256" },
1797
+ { name: "token_uri", type: "core::byte_array::ByteArray" }
1798
+ ],
1799
+ outputs: [],
1800
+ state_mutability: "external"
1801
+ },
1802
+ {
1803
+ type: "function",
1804
+ name: "batch_mint_item",
1805
+ inputs: [
1806
+ { name: "to", type: "core::starknet::contract_address::ContractAddress" },
1807
+ { name: "token_ids", type: "core::array::Span::<core::integer::u256>" },
1808
+ { name: "values", type: "core::array::Span::<core::integer::u256>" },
1809
+ { name: "token_uris", type: "core::array::Array::<core::byte_array::ByteArray>" }
1810
+ ],
1811
+ outputs: [],
1812
+ state_mutability: "external"
1813
+ },
1814
+ // ── Provenance queries ───────────────────────────────────────────────────────
1815
+ {
1816
+ type: "function",
1817
+ name: "get_collection_creator",
1818
+ inputs: [],
1819
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1820
+ state_mutability: "view"
1821
+ },
1822
+ {
1823
+ type: "function",
1824
+ name: "get_token_creator",
1825
+ inputs: [{ name: "token_id", type: "core::integer::u256" }],
1826
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1827
+ state_mutability: "view"
1828
+ },
1829
+ {
1830
+ type: "function",
1831
+ name: "get_token_registered_at",
1832
+ inputs: [{ name: "token_id", type: "core::integer::u256" }],
1833
+ outputs: [{ type: "core::integer::u64" }],
1834
+ state_mutability: "view"
1835
+ },
1836
+ // ── Ownership ────────────────────────────────────────────────────────────────
1837
+ {
1838
+ type: "function",
1839
+ name: "owner",
1840
+ inputs: [],
1841
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1842
+ state_mutability: "view"
1843
+ },
1844
+ // ── ERC-1155 standard ────────────────────────────────────────────────────────
1845
+ {
1846
+ type: "function",
1847
+ name: "balance_of",
1848
+ inputs: [
1849
+ { name: "account", type: "core::starknet::contract_address::ContractAddress" },
1850
+ { name: "token_id", type: "core::integer::u256" }
1851
+ ],
1852
+ outputs: [{ type: "core::integer::u256" }],
1853
+ state_mutability: "view"
1854
+ },
1855
+ {
1856
+ type: "function",
1857
+ name: "set_approval_for_all",
1858
+ inputs: [
1859
+ { name: "operator", type: "core::starknet::contract_address::ContractAddress" },
1860
+ { name: "approved", type: "core::bool" }
1861
+ ],
1862
+ outputs: [],
1863
+ state_mutability: "external"
1864
+ },
1865
+ {
1866
+ type: "function",
1867
+ name: "is_approved_for_all",
1868
+ inputs: [
1869
+ { name: "owner", type: "core::starknet::contract_address::ContractAddress" },
1870
+ { name: "operator", type: "core::starknet::contract_address::ContractAddress" }
1871
+ ],
1872
+ outputs: [{ type: "core::bool" }],
1873
+ state_mutability: "view"
1874
+ },
1875
+ // ── ERC-2981 royalties ───────────────────────────────────────────────────────
1876
+ {
1877
+ type: "function",
1878
+ name: "royalty_info",
1879
+ inputs: [
1880
+ { name: "token_id", type: "core::integer::u256" },
1881
+ { name: "sale_price", type: "core::integer::u256" }
1882
+ ],
1883
+ outputs: [
1884
+ { type: "core::starknet::contract_address::ContractAddress" },
1885
+ { type: "core::integer::u256" }
1886
+ ],
1887
+ state_mutability: "view"
1888
+ },
1889
+ {
1890
+ type: "function",
1891
+ name: "set_default_royalty",
1892
+ inputs: [
1893
+ { name: "receiver", type: "core::starknet::contract_address::ContractAddress" },
1894
+ { name: "fee_numerator", type: "core::integer::u128" }
1895
+ ],
1896
+ outputs: [],
1897
+ state_mutability: "external"
1898
+ },
1899
+ {
1900
+ type: "function",
1901
+ name: "set_token_royalty",
1902
+ inputs: [
1903
+ { name: "token_id", type: "core::integer::u256" },
1904
+ { name: "receiver", type: "core::starknet::contract_address::ContractAddress" },
1905
+ { name: "fee_numerator", type: "core::integer::u128" }
1906
+ ],
1907
+ outputs: [],
1908
+ state_mutability: "external"
1909
+ },
1910
+ {
1911
+ type: "function",
1912
+ name: "delete_default_royalty",
1913
+ inputs: [],
1914
+ outputs: [],
1915
+ state_mutability: "external"
1916
+ },
1917
+ {
1918
+ type: "function",
1919
+ name: "reset_token_royalty",
1920
+ inputs: [{ name: "token_id", type: "core::integer::u256" }],
1921
+ outputs: [],
1922
+ state_mutability: "external"
1923
+ }
1924
+ ];
1723
1925
 
1724
1926
  // src/utils/bigint.ts
1725
1927
  function stringifyBigInts(obj) {
@@ -3169,6 +3371,113 @@ var MedialaneClient = class {
3169
3371
 
3170
3372
  // src/types/api.ts
3171
3373
  var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
3374
+ var ERC1155CollectionService = class {
3375
+ constructor(_config) {
3376
+ this.factoryAddress = ERC1155_FACTORY_CONTRACT_MAINNET;
3377
+ }
3378
+ _factory(account) {
3379
+ return new starknet.Contract(
3380
+ IPCollection1155FactoryABI,
3381
+ normalizeAddress(this.factoryAddress),
3382
+ account
3383
+ );
3384
+ }
3385
+ _collection(address, account) {
3386
+ return new starknet.Contract(
3387
+ IPCollection1155ABI,
3388
+ normalizeAddress(address),
3389
+ account
3390
+ );
3391
+ }
3392
+ /**
3393
+ * Deploy a new ERC-1155 IP collection.
3394
+ * Caller becomes the collection owner and can mint items.
3395
+ * Returns the transaction hash; the deployed collection address is emitted
3396
+ * in the `CollectionDeployed` event of the factory.
3397
+ */
3398
+ async deployCollection(account, params) {
3399
+ const factory = this._factory(account);
3400
+ const call = factory.populate("deploy_collection", [params.name, params.symbol, params.baseUri]);
3401
+ const res = await account.execute([call]);
3402
+ return { txHash: res.transaction_hash };
3403
+ }
3404
+ /**
3405
+ * Mint a single token into an existing ERC-1155 collection.
3406
+ * Caller must be the collection owner.
3407
+ * The `tokenUri` is immutable — validated and stored on the first mint only.
3408
+ */
3409
+ async mintItem(account, params) {
3410
+ const collection = this._collection(params.collection, account);
3411
+ const call = collection.populate("mint_item", [
3412
+ params.to,
3413
+ BigInt(params.tokenId),
3414
+ BigInt(params.value),
3415
+ params.tokenUri
3416
+ ]);
3417
+ const res = await account.execute([call]);
3418
+ return { txHash: res.transaction_hash };
3419
+ }
3420
+ /**
3421
+ * Batch-mint multiple token IDs into an existing ERC-1155 collection.
3422
+ * All items go to the same `to` address.
3423
+ * Caller must be the collection owner.
3424
+ */
3425
+ async batchMintItem(account, params) {
3426
+ const collection = this._collection(params.collection, account);
3427
+ const tokenIds = params.items.map((i) => BigInt(i.tokenId));
3428
+ const values = params.items.map((i) => BigInt(i.value));
3429
+ const tokenUris = params.items.map((i) => i.tokenUri);
3430
+ const call = collection.populate("batch_mint_item", [
3431
+ params.to,
3432
+ tokenIds,
3433
+ values,
3434
+ tokenUris
3435
+ ]);
3436
+ const res = await account.execute([call]);
3437
+ return { txHash: res.transaction_hash };
3438
+ }
3439
+ /**
3440
+ * Set the default ERC-2981 royalty for the entire collection.
3441
+ * `feeNumerator` is out of 10 000 (e.g. 500 = 5%).
3442
+ * Caller must be the collection owner.
3443
+ */
3444
+ async setDefaultRoyalty(account, params) {
3445
+ const collection = this._collection(params.collection, account);
3446
+ const call = collection.populate("set_default_royalty", [
3447
+ params.receiver,
3448
+ BigInt(params.feeNumerator)
3449
+ ]);
3450
+ const res = await account.execute([call]);
3451
+ return { txHash: res.transaction_hash };
3452
+ }
3453
+ /**
3454
+ * Set a per-token ERC-2981 royalty override.
3455
+ * `feeNumerator` is out of 10 000. Caller must be the collection owner.
3456
+ */
3457
+ async setTokenRoyalty(account, params) {
3458
+ const collection = this._collection(params.collection, account);
3459
+ const call = collection.populate("set_token_royalty", [
3460
+ BigInt(params.tokenId),
3461
+ params.receiver,
3462
+ BigInt(params.feeNumerator)
3463
+ ]);
3464
+ const res = await account.execute([call]);
3465
+ return { txHash: res.transaction_hash };
3466
+ }
3467
+ /**
3468
+ * Approve the Medialane1155 marketplace (or any operator) to transfer
3469
+ * all tokens on behalf of `account`. Required before listing.
3470
+ */
3471
+ async setApprovalForAll(account, params) {
3472
+ const collection = this._collection(params.collection, account);
3473
+ const call = collection.populate("set_approval_for_all", [
3474
+ params.operator,
3475
+ params.approved
3476
+ ]);
3477
+ const res = await account.execute([call]);
3478
+ return { txHash: res.transaction_hash };
3479
+ }
3480
+ };
3172
3481
 
3173
3482
  exports.ApiClient = ApiClient;
3174
3483
  exports.COLLECTION_CONTRACT_MAINNET = COLLECTION_CONTRACT_MAINNET;
@@ -3179,6 +3488,11 @@ exports.DROP_FACTORY_CONTRACT_MAINNET = DROP_FACTORY_CONTRACT_MAINNET;
3179
3488
  exports.DropCollectionABI = DropCollectionABI;
3180
3489
  exports.DropFactoryABI = DropFactoryABI;
3181
3490
  exports.DropService = DropService;
3491
+ exports.ERC1155CollectionService = ERC1155CollectionService;
3492
+ exports.ERC1155_COLLECTION_CLASS_HASH_MAINNET = ERC1155_COLLECTION_CLASS_HASH_MAINNET;
3493
+ exports.ERC1155_FACTORY_CONTRACT_MAINNET = ERC1155_FACTORY_CONTRACT_MAINNET;
3494
+ exports.IPCollection1155ABI = IPCollection1155ABI;
3495
+ exports.IPCollection1155FactoryABI = IPCollection1155FactoryABI;
3182
3496
  exports.IPMarketplaceABI = IPMarketplaceABI;
3183
3497
  exports.MARKETPLACE_1155_CONTRACT_MAINNET = MARKETPLACE_1155_CONTRACT_MAINNET;
3184
3498
  exports.MARKETPLACE_CONTRACT_MAINNET = MARKETPLACE_CONTRACT_MAINNET;