@medialane/sdk 0.6.0 → 0.6.2

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
@@ -49,6 +49,8 @@ var DEFAULT_RPC_URLS = {
49
49
  };
50
50
  var POP_FACTORY_CONTRACT_MAINNET = "0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111";
51
51
  var POP_COLLECTION_CLASS_HASH_MAINNET = "0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f";
52
+ var DROP_FACTORY_CONTRACT_MAINNET = "0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800";
53
+ var DROP_COLLECTION_CLASS_HASH_MAINNET = "0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282";
52
54
 
53
55
  // src/abis.ts
54
56
  var IPMarketplaceABI = [
@@ -499,6 +501,262 @@ var POPFactoryABI = [
499
501
  state_mutability: "external"
500
502
  }
501
503
  ];
504
+ var DropCollectionABI = [
505
+ {
506
+ type: "struct",
507
+ name: "core::byte_array::ByteArray",
508
+ members: [
509
+ { name: "data", type: "core::array::Array::<core::felt252>" },
510
+ { name: "pending_word", type: "core::felt252" },
511
+ { name: "pending_word_len", type: "core::integer::u32" }
512
+ ]
513
+ },
514
+ {
515
+ type: "struct",
516
+ name: "collection_drop::types::ClaimConditions",
517
+ members: [
518
+ { name: "start_time", type: "core::integer::u64" },
519
+ { name: "end_time", type: "core::integer::u64" },
520
+ { name: "price", type: "core::integer::u256" },
521
+ { name: "payment_token", type: "core::starknet::contract_address::ContractAddress" },
522
+ { name: "max_quantity_per_wallet", type: "core::integer::u256" }
523
+ ]
524
+ },
525
+ {
526
+ type: "function",
527
+ name: "claim",
528
+ inputs: [{ name: "quantity", type: "core::integer::u256" }],
529
+ outputs: [],
530
+ state_mutability: "external"
531
+ },
532
+ {
533
+ type: "function",
534
+ name: "admin_mint",
535
+ inputs: [
536
+ { name: "recipient", type: "core::starknet::contract_address::ContractAddress" },
537
+ { name: "quantity", type: "core::integer::u256" },
538
+ { name: "custom_uri", type: "core::byte_array::ByteArray" }
539
+ ],
540
+ outputs: [],
541
+ state_mutability: "external"
542
+ },
543
+ {
544
+ type: "function",
545
+ name: "set_claim_conditions",
546
+ inputs: [{ name: "conditions", type: "collection_drop::types::ClaimConditions" }],
547
+ outputs: [],
548
+ state_mutability: "external"
549
+ },
550
+ {
551
+ type: "function",
552
+ name: "get_claim_conditions",
553
+ inputs: [],
554
+ outputs: [{ type: "collection_drop::types::ClaimConditions" }],
555
+ state_mutability: "view"
556
+ },
557
+ {
558
+ type: "function",
559
+ name: "set_allowlist_enabled",
560
+ inputs: [{ name: "enabled", type: "core::bool" }],
561
+ outputs: [],
562
+ state_mutability: "external"
563
+ },
564
+ {
565
+ type: "function",
566
+ name: "is_allowlist_enabled",
567
+ inputs: [],
568
+ outputs: [{ type: "core::bool" }],
569
+ state_mutability: "view"
570
+ },
571
+ {
572
+ type: "function",
573
+ name: "add_to_allowlist",
574
+ inputs: [{ name: "address", type: "core::starknet::contract_address::ContractAddress" }],
575
+ outputs: [],
576
+ state_mutability: "external"
577
+ },
578
+ {
579
+ type: "function",
580
+ name: "batch_add_to_allowlist",
581
+ inputs: [{ name: "addresses", type: "core::array::Array::<core::starknet::contract_address::ContractAddress>" }],
582
+ outputs: [],
583
+ state_mutability: "external"
584
+ },
585
+ {
586
+ type: "function",
587
+ name: "remove_from_allowlist",
588
+ inputs: [{ name: "address", type: "core::starknet::contract_address::ContractAddress" }],
589
+ outputs: [],
590
+ state_mutability: "external"
591
+ },
592
+ {
593
+ type: "function",
594
+ name: "is_allowlisted",
595
+ inputs: [{ name: "address", type: "core::starknet::contract_address::ContractAddress" }],
596
+ outputs: [{ type: "core::bool" }],
597
+ state_mutability: "view"
598
+ },
599
+ {
600
+ type: "function",
601
+ name: "set_base_uri",
602
+ inputs: [{ name: "new_uri", type: "core::byte_array::ByteArray" }],
603
+ outputs: [],
604
+ state_mutability: "external"
605
+ },
606
+ {
607
+ type: "function",
608
+ name: "set_token_uri",
609
+ inputs: [
610
+ { name: "token_id", type: "core::integer::u256" },
611
+ { name: "uri", type: "core::byte_array::ByteArray" }
612
+ ],
613
+ outputs: [],
614
+ state_mutability: "external"
615
+ },
616
+ {
617
+ type: "function",
618
+ name: "set_paused",
619
+ inputs: [{ name: "paused", type: "core::bool" }],
620
+ outputs: [],
621
+ state_mutability: "external"
622
+ },
623
+ {
624
+ type: "function",
625
+ name: "withdraw_payments",
626
+ inputs: [],
627
+ outputs: [],
628
+ state_mutability: "external"
629
+ },
630
+ {
631
+ type: "function",
632
+ name: "get_drop_id",
633
+ inputs: [],
634
+ outputs: [{ type: "core::integer::u256" }],
635
+ state_mutability: "view"
636
+ },
637
+ {
638
+ type: "function",
639
+ name: "get_max_supply",
640
+ inputs: [],
641
+ outputs: [{ type: "core::integer::u256" }],
642
+ state_mutability: "view"
643
+ },
644
+ {
645
+ type: "function",
646
+ name: "total_minted",
647
+ inputs: [],
648
+ outputs: [{ type: "core::integer::u256" }],
649
+ state_mutability: "view"
650
+ },
651
+ {
652
+ type: "function",
653
+ name: "remaining_supply",
654
+ inputs: [],
655
+ outputs: [{ type: "core::integer::u256" }],
656
+ state_mutability: "view"
657
+ },
658
+ {
659
+ type: "function",
660
+ name: "minted_by_wallet",
661
+ inputs: [{ name: "wallet", type: "core::starknet::contract_address::ContractAddress" }],
662
+ outputs: [{ type: "core::integer::u256" }],
663
+ state_mutability: "view"
664
+ },
665
+ {
666
+ type: "function",
667
+ name: "is_paused",
668
+ inputs: [],
669
+ outputs: [{ type: "core::bool" }],
670
+ state_mutability: "view"
671
+ }
672
+ ];
673
+ var DropFactoryABI = [
674
+ {
675
+ type: "struct",
676
+ name: "core::byte_array::ByteArray",
677
+ members: [
678
+ { name: "data", type: "core::array::Array::<core::felt252>" },
679
+ { name: "pending_word", type: "core::felt252" },
680
+ { name: "pending_word_len", type: "core::integer::u32" }
681
+ ]
682
+ },
683
+ {
684
+ type: "struct",
685
+ name: "collection_drop::types::ClaimConditions",
686
+ members: [
687
+ { name: "start_time", type: "core::integer::u64" },
688
+ { name: "end_time", type: "core::integer::u64" },
689
+ { name: "price", type: "core::integer::u256" },
690
+ { name: "payment_token", type: "core::starknet::contract_address::ContractAddress" },
691
+ { name: "max_quantity_per_wallet", type: "core::integer::u256" }
692
+ ]
693
+ },
694
+ {
695
+ type: "function",
696
+ name: "register_organizer",
697
+ inputs: [
698
+ { name: "organizer", type: "core::starknet::contract_address::ContractAddress" },
699
+ { name: "name", type: "core::byte_array::ByteArray" }
700
+ ],
701
+ outputs: [],
702
+ state_mutability: "external"
703
+ },
704
+ {
705
+ type: "function",
706
+ name: "revoke_organizer",
707
+ inputs: [{ name: "organizer", type: "core::starknet::contract_address::ContractAddress" }],
708
+ outputs: [],
709
+ state_mutability: "external"
710
+ },
711
+ {
712
+ type: "function",
713
+ name: "is_active_organizer",
714
+ inputs: [{ name: "organizer", type: "core::starknet::contract_address::ContractAddress" }],
715
+ outputs: [{ type: "core::bool" }],
716
+ state_mutability: "view"
717
+ },
718
+ {
719
+ type: "function",
720
+ name: "create_drop",
721
+ inputs: [
722
+ { name: "name", type: "core::byte_array::ByteArray" },
723
+ { name: "symbol", type: "core::byte_array::ByteArray" },
724
+ { name: "base_uri", type: "core::byte_array::ByteArray" },
725
+ { name: "max_supply", type: "core::integer::u256" },
726
+ { name: "initial_conditions", type: "collection_drop::types::ClaimConditions" }
727
+ ],
728
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
729
+ state_mutability: "external"
730
+ },
731
+ {
732
+ type: "function",
733
+ name: "get_drop_address",
734
+ inputs: [{ name: "drop_id", type: "core::integer::u256" }],
735
+ outputs: [{ type: "core::starknet::contract_address::ContractAddress" }],
736
+ state_mutability: "view"
737
+ },
738
+ {
739
+ type: "function",
740
+ name: "get_last_drop_id",
741
+ inputs: [],
742
+ outputs: [{ type: "core::integer::u256" }],
743
+ state_mutability: "view"
744
+ },
745
+ {
746
+ type: "function",
747
+ name: "get_organizer_drop_count",
748
+ inputs: [{ name: "organizer", type: "core::starknet::contract_address::ContractAddress" }],
749
+ outputs: [{ type: "core::integer::u32" }],
750
+ state_mutability: "view"
751
+ },
752
+ {
753
+ type: "function",
754
+ name: "set_drop_collection_class_hash",
755
+ inputs: [{ name: "new_class_hash", type: "core::starknet::class_hash::ClassHash" }],
756
+ outputs: [],
757
+ state_mutability: "external"
758
+ }
759
+ ];
502
760
 
503
761
  // src/utils/bigint.ts
504
762
  function stringifyBigInts(obj) {
@@ -1608,21 +1866,31 @@ var ApiClient = class {
1608
1866
  );
1609
1867
  return res.data;
1610
1868
  }
1869
+ // ─── Collection Drop ────────────────────────────────────────────────────────
1870
+ getDropCollections(opts = {}) {
1871
+ return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "COLLECTION_DROP");
1872
+ }
1873
+ async getDropMintStatus(collection, wallet) {
1874
+ const res = await this.get(
1875
+ `/v1/drop/mint-status/${normalizeAddress(collection)}/${normalizeAddress(wallet)}`
1876
+ );
1877
+ return res.data;
1878
+ }
1611
1879
  };
1612
- var POP_FACTORY_MAINNET = "0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111";
1613
1880
  var PopService = class {
1614
1881
  constructor(_config) {
1615
- this.factoryAddress = POP_FACTORY_MAINNET;
1882
+ this.factoryAddress = POP_FACTORY_CONTRACT_MAINNET;
1883
+ }
1884
+ _collection(address, account) {
1885
+ return new Contract(POPCollectionABI, normalizeAddress(address), account);
1616
1886
  }
1617
1887
  async claim(account, collectionAddress) {
1618
- const collection = new Contract(POPCollectionABI, normalizeAddress(collectionAddress), account);
1619
- const call = collection.populate("claim", []);
1888
+ const call = this._collection(collectionAddress, account).populate("claim", []);
1620
1889
  const res = await account.execute([call]);
1621
1890
  return { txHash: res.transaction_hash };
1622
1891
  }
1623
1892
  async adminMint(account, params) {
1624
- const collection = new Contract(POPCollectionABI, normalizeAddress(params.collection), account);
1625
- const call = collection.populate("admin_mint", [
1893
+ const call = this._collection(params.collection, account).populate("admin_mint", [
1626
1894
  params.recipient,
1627
1895
  params.customUri ?? ""
1628
1896
  ]);
@@ -1630,49 +1898,126 @@ var PopService = class {
1630
1898
  return { txHash: res.transaction_hash };
1631
1899
  }
1632
1900
  async addToAllowlist(account, params) {
1633
- const collection = new Contract(POPCollectionABI, normalizeAddress(params.collection), account);
1634
- const call = collection.populate("add_to_allowlist", [params.address]);
1901
+ const call = this._collection(params.collection, account).populate("add_to_allowlist", [params.address]);
1635
1902
  const res = await account.execute([call]);
1636
1903
  return { txHash: res.transaction_hash };
1637
1904
  }
1638
1905
  async batchAddToAllowlist(account, params) {
1639
- const collection = new Contract(POPCollectionABI, normalizeAddress(params.collection), account);
1906
+ const collection = this._collection(params.collection, account);
1640
1907
  const CHUNK = 200;
1641
1908
  const calls = [];
1642
1909
  for (let i = 0; i < params.addresses.length; i += CHUNK) {
1643
- const chunk = params.addresses.slice(i, i + CHUNK);
1644
- calls.push(collection.populate("batch_add_to_allowlist", [chunk]));
1910
+ calls.push(collection.populate("batch_add_to_allowlist", [params.addresses.slice(i, i + CHUNK)]));
1645
1911
  }
1646
1912
  const res = await account.execute(calls);
1647
1913
  return { txHash: res.transaction_hash };
1648
1914
  }
1649
1915
  async removeFromAllowlist(account, params) {
1650
- const collection = new Contract(POPCollectionABI, normalizeAddress(params.collection), account);
1651
- const call = collection.populate("remove_from_allowlist", [params.address]);
1916
+ const call = this._collection(params.collection, account).populate("remove_from_allowlist", [params.address]);
1652
1917
  const res = await account.execute([call]);
1653
1918
  return { txHash: res.transaction_hash };
1654
1919
  }
1655
1920
  async setTokenUri(account, params) {
1656
- const collection = new Contract(POPCollectionABI, normalizeAddress(params.collection), account);
1657
- const call = collection.populate("set_token_uri", [BigInt(params.tokenId), params.uri]);
1921
+ const call = this._collection(params.collection, account).populate("set_token_uri", [
1922
+ BigInt(params.tokenId),
1923
+ params.uri
1924
+ ]);
1658
1925
  const res = await account.execute([call]);
1659
1926
  return { txHash: res.transaction_hash };
1660
1927
  }
1661
1928
  async setPaused(account, params) {
1662
- const collection = new Contract(POPCollectionABI, normalizeAddress(params.collection), account);
1663
- const call = collection.populate("set_paused", [params.paused]);
1929
+ const call = this._collection(params.collection, account).populate("set_paused", [params.paused]);
1664
1930
  const res = await account.execute([call]);
1665
1931
  return { txHash: res.transaction_hash };
1666
1932
  }
1667
1933
  async createCollection(account, params) {
1668
1934
  const factory = new Contract(POPFactoryABI, this.factoryAddress, account);
1669
- const eventTypeVariant = { [params.eventType]: {} };
1670
1935
  const call = factory.populate("create_collection", [
1671
1936
  params.name,
1672
1937
  params.symbol,
1673
1938
  params.baseUri,
1674
1939
  params.claimEndTime,
1675
- eventTypeVariant
1940
+ { [params.eventType]: {} }
1941
+ ]);
1942
+ const res = await account.execute([call]);
1943
+ return { txHash: res.transaction_hash };
1944
+ }
1945
+ };
1946
+ function toContractConditions(c) {
1947
+ return {
1948
+ start_time: c.startTime,
1949
+ end_time: c.endTime,
1950
+ price: BigInt(c.price),
1951
+ payment_token: c.paymentToken,
1952
+ max_quantity_per_wallet: BigInt(c.maxQuantityPerWallet)
1953
+ };
1954
+ }
1955
+ var DropService = class {
1956
+ constructor(_config) {
1957
+ this.factoryAddress = DROP_FACTORY_CONTRACT_MAINNET;
1958
+ }
1959
+ _collection(address, account) {
1960
+ return new Contract(DropCollectionABI, normalizeAddress(address), account);
1961
+ }
1962
+ async claim(account, collectionAddress, quantity = 1) {
1963
+ const call = this._collection(collectionAddress, account).populate("claim", [BigInt(quantity)]);
1964
+ const res = await account.execute([call]);
1965
+ return { txHash: res.transaction_hash };
1966
+ }
1967
+ async adminMint(account, params) {
1968
+ const call = this._collection(params.collection, account).populate("admin_mint", [
1969
+ params.recipient,
1970
+ BigInt(params.quantity ?? 1),
1971
+ params.customUri ?? ""
1972
+ ]);
1973
+ const res = await account.execute([call]);
1974
+ return { txHash: res.transaction_hash };
1975
+ }
1976
+ async setClaimConditions(account, params) {
1977
+ const call = this._collection(params.collection, account).populate("set_claim_conditions", [
1978
+ toContractConditions(params.conditions)
1979
+ ]);
1980
+ const res = await account.execute([call]);
1981
+ return { txHash: res.transaction_hash };
1982
+ }
1983
+ async setAllowlistEnabled(account, params) {
1984
+ const call = this._collection(params.collection, account).populate("set_allowlist_enabled", [params.enabled]);
1985
+ const res = await account.execute([call]);
1986
+ return { txHash: res.transaction_hash };
1987
+ }
1988
+ async addToAllowlist(account, params) {
1989
+ const call = this._collection(params.collection, account).populate("add_to_allowlist", [params.address]);
1990
+ const res = await account.execute([call]);
1991
+ return { txHash: res.transaction_hash };
1992
+ }
1993
+ async batchAddToAllowlist(account, params) {
1994
+ const collection = this._collection(params.collection, account);
1995
+ const CHUNK = 200;
1996
+ const calls = [];
1997
+ for (let i = 0; i < params.addresses.length; i += CHUNK) {
1998
+ calls.push(collection.populate("batch_add_to_allowlist", [params.addresses.slice(i, i + CHUNK)]));
1999
+ }
2000
+ const res = await account.execute(calls);
2001
+ return { txHash: res.transaction_hash };
2002
+ }
2003
+ async setPaused(account, params) {
2004
+ const call = this._collection(params.collection, account).populate("set_paused", [params.paused]);
2005
+ const res = await account.execute([call]);
2006
+ return { txHash: res.transaction_hash };
2007
+ }
2008
+ async withdrawPayments(account, params) {
2009
+ const call = this._collection(params.collection, account).populate("withdraw_payments", []);
2010
+ const res = await account.execute([call]);
2011
+ return { txHash: res.transaction_hash };
2012
+ }
2013
+ async createDrop(account, params) {
2014
+ const factory = new Contract(DropFactoryABI, this.factoryAddress, account);
2015
+ const call = factory.populate("create_drop", [
2016
+ params.name,
2017
+ params.symbol,
2018
+ params.baseUri,
2019
+ BigInt(params.maxSupply),
2020
+ toContractConditions(params.initialConditions)
1676
2021
  ]);
1677
2022
  const res = await account.execute([call]);
1678
2023
  return { txHash: res.transaction_hash };
@@ -1685,7 +2030,8 @@ var MedialaneClient = class {
1685
2030
  this.config = resolveConfig(rawConfig);
1686
2031
  this.marketplace = new MarketplaceModule(this.config);
1687
2032
  this.services = {
1688
- pop: new PopService(this.config)
2033
+ pop: new PopService(this.config),
2034
+ drop: new DropService(this.config)
1689
2035
  };
1690
2036
  if (!this.config.backendUrl) {
1691
2037
  this.api = new Proxy({}, {
@@ -1715,6 +2061,6 @@ var MedialaneClient = class {
1715
2061
  // src/types/api.ts
1716
2062
  var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
1717
2063
 
1718
- export { ApiClient, COLLECTION_CONTRACT_MAINNET, DEFAULT_RPC_URLS, IPMarketplaceABI, MARKETPLACE_CONTRACT_MAINNET, MarketplaceModule, MedialaneApiError, MedialaneClient, MedialaneError, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PopService, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, buildCancellationTypedData, buildFulfillmentTypedData, buildOrderTypedData, formatAmount, getListableTokens, getTokenByAddress, getTokenBySymbol, normalizeAddress, parseAmount, resolveConfig, shortenAddress, stringifyBigInts, u256ToBigInt };
2064
+ export { ApiClient, COLLECTION_CONTRACT_MAINNET, DEFAULT_RPC_URLS, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, IPMarketplaceABI, MARKETPLACE_CONTRACT_MAINNET, MarketplaceModule, MedialaneApiError, MedialaneClient, MedialaneError, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PopService, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, buildCancellationTypedData, buildFulfillmentTypedData, buildOrderTypedData, formatAmount, getListableTokens, getTokenByAddress, getTokenBySymbol, normalizeAddress, parseAmount, resolveConfig, shortenAddress, stringifyBigInts, u256ToBigInt };
1719
2065
  //# sourceMappingURL=index.js.map
1720
2066
  //# sourceMappingURL=index.js.map