@medialane/sdk 0.6.0 → 0.6.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/README.md +4 -0
- package/dist/index.cjs +359 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +409 -3
- package/dist/index.d.ts +409 -3
- package/dist/index.js +355 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,6 +1866,16 @@ 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
1880
|
var POP_FACTORY_MAINNET = "0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111";
|
|
1613
1881
|
var PopService = class {
|
|
@@ -1678,6 +1946,90 @@ var PopService = class {
|
|
|
1678
1946
|
return { txHash: res.transaction_hash };
|
|
1679
1947
|
}
|
|
1680
1948
|
};
|
|
1949
|
+
var DROP_FACTORY_MAINNET = "0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800";
|
|
1950
|
+
function toContractConditions(c) {
|
|
1951
|
+
return {
|
|
1952
|
+
start_time: c.startTime,
|
|
1953
|
+
end_time: c.endTime,
|
|
1954
|
+
price: BigInt(c.price),
|
|
1955
|
+
payment_token: c.paymentToken,
|
|
1956
|
+
max_quantity_per_wallet: BigInt(c.maxQuantityPerWallet)
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
var DropService = class {
|
|
1960
|
+
constructor(_config) {
|
|
1961
|
+
this.factoryAddress = DROP_FACTORY_MAINNET;
|
|
1962
|
+
}
|
|
1963
|
+
async claim(account, collectionAddress, quantity = 1) {
|
|
1964
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(collectionAddress), account);
|
|
1965
|
+
const call = collection.populate("claim", [BigInt(quantity)]);
|
|
1966
|
+
const res = await account.execute([call]);
|
|
1967
|
+
return { txHash: res.transaction_hash };
|
|
1968
|
+
}
|
|
1969
|
+
async adminMint(account, params) {
|
|
1970
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(params.collection), account);
|
|
1971
|
+
const call = collection.populate("admin_mint", [
|
|
1972
|
+
params.recipient,
|
|
1973
|
+
BigInt(params.quantity ?? 1),
|
|
1974
|
+
params.customUri ?? ""
|
|
1975
|
+
]);
|
|
1976
|
+
const res = await account.execute([call]);
|
|
1977
|
+
return { txHash: res.transaction_hash };
|
|
1978
|
+
}
|
|
1979
|
+
async setClaimConditions(account, params) {
|
|
1980
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(params.collection), account);
|
|
1981
|
+
const call = collection.populate("set_claim_conditions", [toContractConditions(params.conditions)]);
|
|
1982
|
+
const res = await account.execute([call]);
|
|
1983
|
+
return { txHash: res.transaction_hash };
|
|
1984
|
+
}
|
|
1985
|
+
async setAllowlistEnabled(account, params) {
|
|
1986
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(params.collection), account);
|
|
1987
|
+
const call = collection.populate("set_allowlist_enabled", [params.enabled]);
|
|
1988
|
+
const res = await account.execute([call]);
|
|
1989
|
+
return { txHash: res.transaction_hash };
|
|
1990
|
+
}
|
|
1991
|
+
async addToAllowlist(account, params) {
|
|
1992
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(params.collection), account);
|
|
1993
|
+
const call = collection.populate("add_to_allowlist", [params.address]);
|
|
1994
|
+
const res = await account.execute([call]);
|
|
1995
|
+
return { txHash: res.transaction_hash };
|
|
1996
|
+
}
|
|
1997
|
+
async batchAddToAllowlist(account, params) {
|
|
1998
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(params.collection), account);
|
|
1999
|
+
const CHUNK = 200;
|
|
2000
|
+
const calls = [];
|
|
2001
|
+
for (let i = 0; i < params.addresses.length; i += CHUNK) {
|
|
2002
|
+
const chunk = params.addresses.slice(i, i + CHUNK);
|
|
2003
|
+
calls.push(collection.populate("batch_add_to_allowlist", [chunk]));
|
|
2004
|
+
}
|
|
2005
|
+
const res = await account.execute(calls);
|
|
2006
|
+
return { txHash: res.transaction_hash };
|
|
2007
|
+
}
|
|
2008
|
+
async setPaused(account, params) {
|
|
2009
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(params.collection), account);
|
|
2010
|
+
const call = collection.populate("set_paused", [params.paused]);
|
|
2011
|
+
const res = await account.execute([call]);
|
|
2012
|
+
return { txHash: res.transaction_hash };
|
|
2013
|
+
}
|
|
2014
|
+
async withdrawPayments(account, params) {
|
|
2015
|
+
const collection = new Contract(DropCollectionABI, normalizeAddress(params.collection), account);
|
|
2016
|
+
const call = collection.populate("withdraw_payments", []);
|
|
2017
|
+
const res = await account.execute([call]);
|
|
2018
|
+
return { txHash: res.transaction_hash };
|
|
2019
|
+
}
|
|
2020
|
+
async createDrop(account, params) {
|
|
2021
|
+
const factory = new Contract(DropFactoryABI, this.factoryAddress, account);
|
|
2022
|
+
const call = factory.populate("create_drop", [
|
|
2023
|
+
params.name,
|
|
2024
|
+
params.symbol,
|
|
2025
|
+
params.baseUri,
|
|
2026
|
+
BigInt(params.maxSupply),
|
|
2027
|
+
toContractConditions(params.initialConditions)
|
|
2028
|
+
]);
|
|
2029
|
+
const res = await account.execute([call]);
|
|
2030
|
+
return { txHash: res.transaction_hash };
|
|
2031
|
+
}
|
|
2032
|
+
};
|
|
1681
2033
|
|
|
1682
2034
|
// src/client.ts
|
|
1683
2035
|
var MedialaneClient = class {
|
|
@@ -1685,7 +2037,8 @@ var MedialaneClient = class {
|
|
|
1685
2037
|
this.config = resolveConfig(rawConfig);
|
|
1686
2038
|
this.marketplace = new MarketplaceModule(this.config);
|
|
1687
2039
|
this.services = {
|
|
1688
|
-
pop: new PopService(this.config)
|
|
2040
|
+
pop: new PopService(this.config),
|
|
2041
|
+
drop: new DropService(this.config)
|
|
1689
2042
|
};
|
|
1690
2043
|
if (!this.config.backendUrl) {
|
|
1691
2044
|
this.api = new Proxy({}, {
|
|
@@ -1715,6 +2068,6 @@ var MedialaneClient = class {
|
|
|
1715
2068
|
// src/types/api.ts
|
|
1716
2069
|
var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
|
|
1717
2070
|
|
|
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 };
|
|
2071
|
+
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
2072
|
//# sourceMappingURL=index.js.map
|
|
1720
2073
|
//# sourceMappingURL=index.js.map
|