@medialane/sdk 0.6.8 → 0.7.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
@@ -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 = "0x0459a9a3c04be5d884a038744f977dff019897264d4a281f9e0f87af417b3bec";
51
+ var ERC1155_COLLECTION_CLASS_HASH_MAINNET = "0x02da5e81be7a1ca493b9441522c450f8ff4c54b14ec16a0c2349f5e6e6fdc5d7";
50
52
 
51
53
  // src/config.ts
52
54
  var MedialaneConfigSchema = z.object({
@@ -1718,6 +1720,126 @@ 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
+ ],
1738
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1739
+ state_mutability: "external"
1740
+ },
1741
+ {
1742
+ type: "function",
1743
+ name: "owner",
1744
+ inputs: [],
1745
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1746
+ state_mutability: "view"
1747
+ }
1748
+ ];
1749
+ var IPCollection1155ABI = [
1750
+ {
1751
+ type: "function",
1752
+ name: "mint_item",
1753
+ inputs: [
1754
+ { name: "to", type: "core::starknet::contract_address::ContractAddress" },
1755
+ { name: "token_id", type: "core::integer::u256" },
1756
+ { name: "value", type: "core::integer::u256" },
1757
+ { name: "token_uri", type: "core::byte_array::ByteArray" }
1758
+ ],
1759
+ outputs: [],
1760
+ state_mutability: "external"
1761
+ },
1762
+ {
1763
+ type: "function",
1764
+ name: "batch_mint_item",
1765
+ inputs: [
1766
+ { name: "to", type: "core::starknet::contract_address::ContractAddress" },
1767
+ { name: "token_ids", type: "core::array::Span::<core::integer::u256>" },
1768
+ { name: "values", type: "core::array::Span::<core::integer::u256>" },
1769
+ { name: "token_uris", type: "core::array::Array::<core::byte_array::ByteArray>" }
1770
+ ],
1771
+ outputs: [],
1772
+ state_mutability: "external"
1773
+ },
1774
+ {
1775
+ type: "function",
1776
+ name: "uri",
1777
+ inputs: [{ name: "token_id", type: "core::integer::u256" }],
1778
+ outputs: [{ type: "core::byte_array::ByteArray" }],
1779
+ state_mutability: "view"
1780
+ },
1781
+ {
1782
+ type: "function",
1783
+ name: "get_collection_creator",
1784
+ inputs: [],
1785
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1786
+ state_mutability: "view"
1787
+ },
1788
+ {
1789
+ type: "function",
1790
+ name: "get_token_creator",
1791
+ inputs: [{ name: "token_id", type: "core::integer::u256" }],
1792
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1793
+ state_mutability: "view"
1794
+ },
1795
+ {
1796
+ type: "function",
1797
+ name: "owner",
1798
+ inputs: [],
1799
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
1800
+ state_mutability: "view"
1801
+ },
1802
+ {
1803
+ type: "function",
1804
+ name: "balance_of",
1805
+ inputs: [
1806
+ { name: "account", type: "core::starknet::contract_address::ContractAddress" },
1807
+ { name: "token_id", type: "core::integer::u256" }
1808
+ ],
1809
+ outputs: [{ type: "core::integer::u256" }],
1810
+ state_mutability: "view"
1811
+ },
1812
+ {
1813
+ type: "function",
1814
+ name: "set_approval_for_all",
1815
+ inputs: [
1816
+ { name: "operator", type: "core::starknet::contract_address::ContractAddress" },
1817
+ { name: "approved", type: "core::bool" }
1818
+ ],
1819
+ outputs: [],
1820
+ state_mutability: "external"
1821
+ },
1822
+ {
1823
+ type: "function",
1824
+ name: "is_approved_for_all",
1825
+ inputs: [
1826
+ { name: "owner", type: "core::starknet::contract_address::ContractAddress" },
1827
+ { name: "operator", type: "core::starknet::contract_address::ContractAddress" }
1828
+ ],
1829
+ outputs: [{ type: "core::bool" }],
1830
+ state_mutability: "view"
1831
+ },
1832
+ {
1833
+ type: "function",
1834
+ name: "set_royalty",
1835
+ inputs: [
1836
+ { name: "receiver", type: "core::starknet::contract_address::ContractAddress" },
1837
+ { name: "fee_numerator", type: "core::integer::u128" }
1838
+ ],
1839
+ outputs: [],
1840
+ state_mutability: "external"
1841
+ }
1842
+ ];
1721
1843
 
1722
1844
  // src/utils/bigint.ts
1723
1845
  function stringifyBigInts(obj) {
@@ -3167,7 +3289,100 @@ var MedialaneClient = class {
3167
3289
 
3168
3290
  // src/types/api.ts
3169
3291
  var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
3292
+ var ERC1155CollectionService = class {
3293
+ constructor(_config) {
3294
+ this.factoryAddress = ERC1155_FACTORY_CONTRACT_MAINNET;
3295
+ }
3296
+ _factory(account) {
3297
+ return new Contract(
3298
+ IPCollection1155FactoryABI,
3299
+ normalizeAddress(this.factoryAddress),
3300
+ account
3301
+ );
3302
+ }
3303
+ _collection(address, account) {
3304
+ return new Contract(
3305
+ IPCollection1155ABI,
3306
+ normalizeAddress(address),
3307
+ account
3308
+ );
3309
+ }
3310
+ /**
3311
+ * Deploy a new ERC-1155 IP collection.
3312
+ * Caller becomes the collection owner and can mint items.
3313
+ * Returns the transaction hash; the deployed collection address is emitted
3314
+ * in the `CollectionDeployed` event of the factory.
3315
+ */
3316
+ async deployCollection(account, params) {
3317
+ const factory = this._factory(account);
3318
+ const call = factory.populate("deploy_collection", [params.name, params.symbol]);
3319
+ const res = await account.execute([call]);
3320
+ return { txHash: res.transaction_hash };
3321
+ }
3322
+ /**
3323
+ * Mint a single token into an existing ERC-1155 collection.
3324
+ * Caller must be the collection owner.
3325
+ * The `tokenUri` is immutable — validated and stored on the first mint only.
3326
+ */
3327
+ async mintItem(account, params) {
3328
+ const collection = this._collection(params.collection, account);
3329
+ const call = collection.populate("mint_item", [
3330
+ params.to,
3331
+ BigInt(params.tokenId),
3332
+ BigInt(params.value),
3333
+ params.tokenUri
3334
+ ]);
3335
+ const res = await account.execute([call]);
3336
+ return { txHash: res.transaction_hash };
3337
+ }
3338
+ /**
3339
+ * Batch-mint multiple token IDs into an existing ERC-1155 collection.
3340
+ * All items go to the same `to` address.
3341
+ * Caller must be the collection owner.
3342
+ */
3343
+ async batchMintItem(account, params) {
3344
+ const collection = this._collection(params.collection, account);
3345
+ const tokenIds = params.items.map((i) => BigInt(i.tokenId));
3346
+ const values = params.items.map((i) => BigInt(i.value));
3347
+ const tokenUris = params.items.map((i) => i.tokenUri);
3348
+ const call = collection.populate("batch_mint_item", [
3349
+ params.to,
3350
+ tokenIds,
3351
+ values,
3352
+ tokenUris
3353
+ ]);
3354
+ const res = await account.execute([call]);
3355
+ return { txHash: res.transaction_hash };
3356
+ }
3357
+ /**
3358
+ * Set ERC-2981 royalties for the collection.
3359
+ * `feeNumerator` is out of 10 000 (e.g. 500 = 5%).
3360
+ * Caller must be the collection owner.
3361
+ */
3362
+ async setRoyalty(account, params) {
3363
+ const collection = this._collection(params.collection, account);
3364
+ const call = collection.populate("set_royalty", [
3365
+ params.receiver,
3366
+ BigInt(params.feeNumerator)
3367
+ ]);
3368
+ const res = await account.execute([call]);
3369
+ return { txHash: res.transaction_hash };
3370
+ }
3371
+ /**
3372
+ * Approve the Medialane1155 marketplace (or any operator) to transfer
3373
+ * all tokens on behalf of `account`. Required before listing.
3374
+ */
3375
+ async setApprovalForAll(account, params) {
3376
+ const collection = this._collection(params.collection, account);
3377
+ const call = collection.populate("set_approval_for_all", [
3378
+ params.operator,
3379
+ params.approved
3380
+ ]);
3381
+ const res = await account.execute([call]);
3382
+ return { txHash: res.transaction_hash };
3383
+ }
3384
+ };
3170
3385
 
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 };
3386
+ 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
3387
  //# sourceMappingURL=index.js.map
3173
3388
  //# sourceMappingURL=index.js.map