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