@medialane/sdk 0.60.0 → 0.62.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.
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { hash, num, cairo, Contract, uint256, RpcProvider, CairoOption, CairoOptionVariant, ec, encode, TypedDataRevision, constants, shortString } from 'starknet';
2
+ import { hash, num, cairo, Contract, uint256, RpcProvider, CairoOption, CairoOptionVariant, ec, encode, TypedDataRevision, shortString, constants } from 'starknet';
3
3
  import { keccak_256 } from '@noble/hashes/sha3.js';
4
4
  import { base32, base58 } from '@scure/base';
5
5
 
@@ -4649,26 +4649,8 @@ var CreatorCoinFactoryABI = [{ "type": "impl", "name": "FactoryImpl", "interface
4649
4649
  var IPTicketCollectionABI = [
4650
4650
  {
4651
4651
  "type": "impl",
4652
- "name": "ERC721MetadataImpl",
4653
- "interface_name": "openzeppelin_token::erc721::interface::IERC721Metadata"
4654
- },
4655
- {
4656
- "type": "struct",
4657
- "name": "core::byte_array::ByteArray",
4658
- "members": [
4659
- {
4660
- "name": "data",
4661
- "type": "core::array::Array::<core::bytes_31::bytes31>"
4662
- },
4663
- {
4664
- "name": "pending_word",
4665
- "type": "core::felt252"
4666
- },
4667
- {
4668
- "name": "pending_word_len",
4669
- "type": "core::internal::bounded_int::BoundedInt::<0, 30>"
4670
- }
4671
- ]
4652
+ "name": "ERC1155MetadataURIImpl",
4653
+ "interface_name": "openzeppelin_token::erc1155::interface::IERC1155MetadataURI"
4672
4654
  },
4673
4655
  {
4674
4656
  "type": "struct",
@@ -4685,64 +4667,33 @@ var IPTicketCollectionABI = [
4685
4667
  ]
4686
4668
  },
4687
4669
  {
4688
- "type": "interface",
4689
- "name": "openzeppelin_token::erc721::interface::IERC721Metadata",
4690
- "items": [
4670
+ "type": "struct",
4671
+ "name": "core::byte_array::ByteArray",
4672
+ "members": [
4691
4673
  {
4692
- "type": "function",
4693
- "name": "name",
4694
- "inputs": [],
4695
- "outputs": [
4696
- {
4697
- "type": "core::byte_array::ByteArray"
4698
- }
4699
- ],
4700
- "state_mutability": "view"
4674
+ "name": "data",
4675
+ "type": "core::array::Array::<core::bytes_31::bytes31>"
4701
4676
  },
4702
4677
  {
4703
- "type": "function",
4704
- "name": "symbol",
4705
- "inputs": [],
4706
- "outputs": [
4707
- {
4708
- "type": "core::byte_array::ByteArray"
4709
- }
4710
- ],
4711
- "state_mutability": "view"
4678
+ "name": "pending_word",
4679
+ "type": "core::felt252"
4712
4680
  },
4713
4681
  {
4714
- "type": "function",
4715
- "name": "token_uri",
4716
- "inputs": [
4717
- {
4718
- "name": "token_id",
4719
- "type": "core::integer::u256"
4720
- }
4721
- ],
4722
- "outputs": [
4723
- {
4724
- "type": "core::byte_array::ByteArray"
4725
- }
4726
- ],
4727
- "state_mutability": "view"
4682
+ "name": "pending_word_len",
4683
+ "type": "core::internal::bounded_int::BoundedInt::<0, 30>"
4728
4684
  }
4729
4685
  ]
4730
4686
  },
4731
- {
4732
- "type": "impl",
4733
- "name": "ERC721MetadataCamelOnlyImpl",
4734
- "interface_name": "openzeppelin_token::erc721::interface::IERC721MetadataCamelOnly"
4735
- },
4736
4687
  {
4737
4688
  "type": "interface",
4738
- "name": "openzeppelin_token::erc721::interface::IERC721MetadataCamelOnly",
4689
+ "name": "openzeppelin_token::erc1155::interface::IERC1155MetadataURI",
4739
4690
  "items": [
4740
4691
  {
4741
4692
  "type": "function",
4742
- "name": "tokenURI",
4693
+ "name": "uri",
4743
4694
  "inputs": [
4744
4695
  {
4745
- "name": "tokenId",
4696
+ "name": "token_id",
4746
4697
  "type": "core::integer::u256"
4747
4698
  }
4748
4699
  ],
@@ -4757,16 +4708,16 @@ var IPTicketCollectionABI = [
4757
4708
  },
4758
4709
  {
4759
4710
  "type": "impl",
4760
- "name": "IPTicketImpl",
4711
+ "name": "IPTicketCollectionImpl",
4761
4712
  "interface_name": "ip_ticket::interface::IIPTicketCollection"
4762
4713
  },
4763
4714
  {
4764
4715
  "type": "enum",
4765
- "name": "core::option::Option::<core::starknet::contract_address::ContractAddress>",
4716
+ "name": "core::option::Option::<core::integer::u64>",
4766
4717
  "variants": [
4767
4718
  {
4768
4719
  "name": "Some",
4769
- "type": "core::starknet::contract_address::ContractAddress"
4720
+ "type": "core::integer::u64"
4770
4721
  },
4771
4722
  {
4772
4723
  "name": "None",
@@ -4790,16 +4741,12 @@ var IPTicketCollectionABI = [
4790
4741
  },
4791
4742
  {
4792
4743
  "type": "struct",
4793
- "name": "ip_ticket::types::TicketCollection",
4744
+ "name": "ip_ticket::types::EventRecord",
4794
4745
  "members": [
4795
4746
  {
4796
4747
  "name": "creator",
4797
4748
  "type": "core::starknet::contract_address::ContractAddress"
4798
4749
  },
4799
- {
4800
- "name": "price",
4801
- "type": "core::integer::u256"
4802
- },
4803
4750
  {
4804
4751
  "name": "max_supply",
4805
4752
  "type": "core::integer::u256"
@@ -4809,16 +4756,16 @@ var IPTicketCollectionABI = [
4809
4756
  "type": "core::integer::u256"
4810
4757
  },
4811
4758
  {
4812
- "name": "expiration",
4813
- "type": "core::integer::u64"
4759
+ "name": "start_time",
4760
+ "type": "core::option::Option::<core::integer::u64>"
4814
4761
  },
4815
4762
  {
4816
- "name": "royalty_bps",
4817
- "type": "core::integer::u256"
4763
+ "name": "end_time",
4764
+ "type": "core::option::Option::<core::integer::u64>"
4818
4765
  },
4819
4766
  {
4820
- "name": "payment_token",
4821
- "type": "core::option::Option::<core::starknet::contract_address::ContractAddress>"
4767
+ "name": "royalty_bps",
4768
+ "type": "core::integer::u16"
4822
4769
  },
4823
4770
  {
4824
4771
  "name": "metadata_uri",
@@ -4830,71 +4777,29 @@ var IPTicketCollectionABI = [
4830
4777
  }
4831
4778
  ]
4832
4779
  },
4833
- {
4834
- "type": "struct",
4835
- "name": "ip_ticket::types::TicketData",
4836
- "members": [
4837
- {
4838
- "name": "token_id",
4839
- "type": "core::integer::u256"
4840
- },
4841
- {
4842
- "name": "owner",
4843
- "type": "core::starknet::contract_address::ContractAddress"
4844
- },
4845
- {
4846
- "name": "collection_id",
4847
- "type": "core::integer::u256"
4848
- },
4849
- {
4850
- "name": "creator",
4851
- "type": "core::starknet::contract_address::ContractAddress"
4852
- },
4853
- {
4854
- "name": "metadata_uri",
4855
- "type": "core::byte_array::ByteArray"
4856
- },
4857
- {
4858
- "name": "expiration",
4859
- "type": "core::integer::u64"
4860
- },
4861
- {
4862
- "name": "redeemed",
4863
- "type": "core::bool"
4864
- },
4865
- {
4866
- "name": "valid",
4867
- "type": "core::bool"
4868
- }
4869
- ]
4870
- },
4871
4780
  {
4872
4781
  "type": "interface",
4873
4782
  "name": "ip_ticket::interface::IIPTicketCollection",
4874
4783
  "items": [
4875
4784
  {
4876
4785
  "type": "function",
4877
- "name": "create_ticket_collection",
4786
+ "name": "create_event",
4878
4787
  "inputs": [
4879
- {
4880
- "name": "price",
4881
- "type": "core::integer::u256"
4882
- },
4883
4788
  {
4884
4789
  "name": "max_supply",
4885
4790
  "type": "core::integer::u256"
4886
4791
  },
4887
4792
  {
4888
- "name": "expiration",
4889
- "type": "core::integer::u64"
4793
+ "name": "start_time",
4794
+ "type": "core::option::Option::<core::integer::u64>"
4890
4795
  },
4891
4796
  {
4892
- "name": "royalty_bps",
4893
- "type": "core::integer::u256"
4797
+ "name": "end_time",
4798
+ "type": "core::option::Option::<core::integer::u64>"
4894
4799
  },
4895
4800
  {
4896
- "name": "payment_token",
4897
- "type": "core::option::Option::<core::starknet::contract_address::ContractAddress>"
4801
+ "name": "royalty_bps",
4802
+ "type": "core::integer::u16"
4898
4803
  },
4899
4804
  {
4900
4805
  "name": "metadata_uri",
@@ -4910,43 +4815,35 @@ var IPTicketCollectionABI = [
4910
4815
  },
4911
4816
  {
4912
4817
  "type": "function",
4913
- "name": "set_collection_active",
4818
+ "name": "mint",
4914
4819
  "inputs": [
4915
4820
  {
4916
- "name": "collection_id",
4917
- "type": "core::integer::u256"
4821
+ "name": "to",
4822
+ "type": "core::starknet::contract_address::ContractAddress"
4918
4823
  },
4919
4824
  {
4920
- "name": "active",
4921
- "type": "core::bool"
4922
- }
4923
- ],
4924
- "outputs": [],
4925
- "state_mutability": "external"
4926
- },
4927
- {
4928
- "type": "function",
4929
- "name": "mint_ticket",
4930
- "inputs": [
4931
- {
4932
- "name": "collection_id",
4825
+ "name": "token_id",
4933
4826
  "type": "core::integer::u256"
4934
- }
4935
- ],
4936
- "outputs": [
4827
+ },
4937
4828
  {
4829
+ "name": "amount",
4938
4830
  "type": "core::integer::u256"
4939
4831
  }
4940
4832
  ],
4833
+ "outputs": [],
4941
4834
  "state_mutability": "external"
4942
4835
  },
4943
4836
  {
4944
4837
  "type": "function",
4945
- "name": "redeem_ticket",
4838
+ "name": "pause_event",
4946
4839
  "inputs": [
4947
4840
  {
4948
4841
  "name": "token_id",
4949
4842
  "type": "core::integer::u256"
4843
+ },
4844
+ {
4845
+ "name": "active",
4846
+ "type": "core::bool"
4950
4847
  }
4951
4848
  ],
4952
4849
  "outputs": [],
@@ -4954,15 +4851,15 @@ var IPTicketCollectionABI = [
4954
4851
  },
4955
4852
  {
4956
4853
  "type": "function",
4957
- "name": "has_valid_ticket",
4854
+ "name": "is_valid",
4958
4855
  "inputs": [
4959
4856
  {
4960
- "name": "user",
4961
- "type": "core::starknet::contract_address::ContractAddress"
4857
+ "name": "token_id",
4858
+ "type": "core::integer::u256"
4962
4859
  },
4963
4860
  {
4964
- "name": "collection_id",
4965
- "type": "core::integer::u256"
4861
+ "name": "holder",
4862
+ "type": "core::starknet::contract_address::ContractAddress"
4966
4863
  }
4967
4864
  ],
4968
4865
  "outputs": [
@@ -4974,23 +4871,7 @@ var IPTicketCollectionABI = [
4974
4871
  },
4975
4872
  {
4976
4873
  "type": "function",
4977
- "name": "get_ticket_collection",
4978
- "inputs": [
4979
- {
4980
- "name": "collection_id",
4981
- "type": "core::integer::u256"
4982
- }
4983
- ],
4984
- "outputs": [
4985
- {
4986
- "type": "ip_ticket::types::TicketCollection"
4987
- }
4988
- ],
4989
- "state_mutability": "view"
4990
- },
4991
- {
4992
- "type": "function",
4993
- "name": "get_ticket_data",
4874
+ "name": "get_event",
4994
4875
  "inputs": [
4995
4876
  {
4996
4877
  "name": "token_id",
@@ -4999,72 +4880,34 @@ var IPTicketCollectionABI = [
4999
4880
  ],
5000
4881
  "outputs": [
5001
4882
  {
5002
- "type": "ip_ticket::types::TicketData"
4883
+ "type": "ip_ticket::types::EventRecord"
5003
4884
  }
5004
4885
  ],
5005
4886
  "state_mutability": "view"
5006
4887
  },
5007
4888
  {
5008
4889
  "type": "function",
5009
- "name": "get_ticket_collection_id",
4890
+ "name": "royalty_info",
5010
4891
  "inputs": [
5011
4892
  {
5012
4893
  "name": "token_id",
5013
4894
  "type": "core::integer::u256"
5014
- }
5015
- ],
5016
- "outputs": [
5017
- {
5018
- "type": "core::integer::u256"
5019
- }
5020
- ],
5021
- "state_mutability": "view"
5022
- },
5023
- {
5024
- "type": "function",
5025
- "name": "get_active_ticket_balance",
5026
- "inputs": [
5027
- {
5028
- "name": "user",
5029
- "type": "core::starknet::contract_address::ContractAddress"
5030
4895
  },
5031
4896
  {
5032
- "name": "collection_id",
5033
- "type": "core::integer::u256"
5034
- }
5035
- ],
5036
- "outputs": [
5037
- {
5038
- "type": "core::integer::u256"
5039
- }
5040
- ],
5041
- "state_mutability": "view"
5042
- },
5043
- {
5044
- "type": "function",
5045
- "name": "get_last_collection_id",
5046
- "inputs": [],
5047
- "outputs": [
5048
- {
4897
+ "name": "sale_price",
5049
4898
  "type": "core::integer::u256"
5050
4899
  }
5051
4900
  ],
5052
- "state_mutability": "view"
5053
- },
5054
- {
5055
- "type": "function",
5056
- "name": "total_supply",
5057
- "inputs": [],
5058
4901
  "outputs": [
5059
4902
  {
5060
- "type": "core::integer::u256"
4903
+ "type": "(core::starknet::contract_address::ContractAddress, core::integer::u256)"
5061
4904
  }
5062
4905
  ],
5063
4906
  "state_mutability": "view"
5064
4907
  },
5065
4908
  {
5066
4909
  "type": "function",
5067
- "name": "royalty_info",
4910
+ "name": "royaltyInfo",
5068
4911
  "inputs": [
5069
4912
  {
5070
4913
  "name": "token_id",
@@ -5084,20 +4927,11 @@ var IPTicketCollectionABI = [
5084
4927
  },
5085
4928
  {
5086
4929
  "type": "function",
5087
- "name": "royaltyInfo",
5088
- "inputs": [
5089
- {
5090
- "name": "token_id",
5091
- "type": "core::integer::u256"
5092
- },
5093
- {
5094
- "name": "sale_price",
5095
- "type": "core::integer::u256"
5096
- }
5097
- ],
4930
+ "name": "version",
4931
+ "inputs": [],
5098
4932
  "outputs": [
5099
4933
  {
5100
- "type": "(core::starknet::contract_address::ContractAddress, core::integer::u256)"
4934
+ "type": "core::byte_array::ByteArray"
5101
4935
  }
5102
4936
  ],
5103
4937
  "state_mutability": "view"
@@ -5106,8 +4940,28 @@ var IPTicketCollectionABI = [
5106
4940
  },
5107
4941
  {
5108
4942
  "type": "impl",
5109
- "name": "ERC721Impl",
5110
- "interface_name": "openzeppelin_token::erc721::interface::IERC721"
4943
+ "name": "ERC1155Impl",
4944
+ "interface_name": "openzeppelin_token::erc1155::interface::IERC1155"
4945
+ },
4946
+ {
4947
+ "type": "struct",
4948
+ "name": "core::array::Span::<core::starknet::contract_address::ContractAddress>",
4949
+ "members": [
4950
+ {
4951
+ "name": "snapshot",
4952
+ "type": "@core::array::Array::<core::starknet::contract_address::ContractAddress>"
4953
+ }
4954
+ ]
4955
+ },
4956
+ {
4957
+ "type": "struct",
4958
+ "name": "core::array::Span::<core::integer::u256>",
4959
+ "members": [
4960
+ {
4961
+ "name": "snapshot",
4962
+ "type": "@core::array::Array::<core::integer::u256>"
4963
+ }
4964
+ ]
5111
4965
  },
5112
4966
  {
5113
4967
  "type": "struct",
@@ -5121,7 +4975,7 @@ var IPTicketCollectionABI = [
5121
4975
  },
5122
4976
  {
5123
4977
  "type": "interface",
5124
- "name": "openzeppelin_token::erc721::interface::IERC721",
4978
+ "name": "openzeppelin_token::erc1155::interface::IERC1155",
5125
4979
  "items": [
5126
4980
  {
5127
4981
  "type": "function",
@@ -5130,6 +4984,10 @@ var IPTicketCollectionABI = [
5130
4984
  {
5131
4985
  "name": "account",
5132
4986
  "type": "core::starknet::contract_address::ContractAddress"
4987
+ },
4988
+ {
4989
+ "name": "token_id",
4990
+ "type": "core::integer::u256"
5133
4991
  }
5134
4992
  ],
5135
4993
  "outputs": [
@@ -5141,16 +4999,20 @@ var IPTicketCollectionABI = [
5141
4999
  },
5142
5000
  {
5143
5001
  "type": "function",
5144
- "name": "owner_of",
5002
+ "name": "balance_of_batch",
5145
5003
  "inputs": [
5146
5004
  {
5147
- "name": "token_id",
5148
- "type": "core::integer::u256"
5005
+ "name": "accounts",
5006
+ "type": "core::array::Span::<core::starknet::contract_address::ContractAddress>"
5007
+ },
5008
+ {
5009
+ "name": "token_ids",
5010
+ "type": "core::array::Span::<core::integer::u256>"
5149
5011
  }
5150
5012
  ],
5151
5013
  "outputs": [
5152
5014
  {
5153
- "type": "core::starknet::contract_address::ContractAddress"
5015
+ "type": "core::array::Span::<core::integer::u256>"
5154
5016
  }
5155
5017
  ],
5156
5018
  "state_mutability": "view"
@@ -5171,6 +5033,10 @@ var IPTicketCollectionABI = [
5171
5033
  "name": "token_id",
5172
5034
  "type": "core::integer::u256"
5173
5035
  },
5036
+ {
5037
+ "name": "value",
5038
+ "type": "core::integer::u256"
5039
+ },
5174
5040
  {
5175
5041
  "name": "data",
5176
5042
  "type": "core::array::Span::<core::felt252>"
@@ -5181,7 +5047,7 @@ var IPTicketCollectionABI = [
5181
5047
  },
5182
5048
  {
5183
5049
  "type": "function",
5184
- "name": "transfer_from",
5050
+ "name": "safe_batch_transfer_from",
5185
5051
  "inputs": [
5186
5052
  {
5187
5053
  "name": "from",
@@ -5192,24 +5058,16 @@ var IPTicketCollectionABI = [
5192
5058
  "type": "core::starknet::contract_address::ContractAddress"
5193
5059
  },
5194
5060
  {
5195
- "name": "token_id",
5196
- "type": "core::integer::u256"
5197
- }
5198
- ],
5199
- "outputs": [],
5200
- "state_mutability": "external"
5201
- },
5202
- {
5203
- "type": "function",
5204
- "name": "approve",
5205
- "inputs": [
5061
+ "name": "token_ids",
5062
+ "type": "core::array::Span::<core::integer::u256>"
5063
+ },
5206
5064
  {
5207
- "name": "to",
5208
- "type": "core::starknet::contract_address::ContractAddress"
5065
+ "name": "values",
5066
+ "type": "core::array::Span::<core::integer::u256>"
5209
5067
  },
5210
5068
  {
5211
- "name": "token_id",
5212
- "type": "core::integer::u256"
5069
+ "name": "data",
5070
+ "type": "core::array::Span::<core::felt252>"
5213
5071
  }
5214
5072
  ],
5215
5073
  "outputs": [],
@@ -5217,66 +5075,50 @@ var IPTicketCollectionABI = [
5217
5075
  },
5218
5076
  {
5219
5077
  "type": "function",
5220
- "name": "set_approval_for_all",
5078
+ "name": "is_approved_for_all",
5221
5079
  "inputs": [
5222
5080
  {
5223
- "name": "operator",
5081
+ "name": "owner",
5224
5082
  "type": "core::starknet::contract_address::ContractAddress"
5225
5083
  },
5226
5084
  {
5227
- "name": "approved",
5228
- "type": "core::bool"
5229
- }
5230
- ],
5231
- "outputs": [],
5232
- "state_mutability": "external"
5233
- },
5234
- {
5235
- "type": "function",
5236
- "name": "get_approved",
5237
- "inputs": [
5238
- {
5239
- "name": "token_id",
5240
- "type": "core::integer::u256"
5085
+ "name": "operator",
5086
+ "type": "core::starknet::contract_address::ContractAddress"
5241
5087
  }
5242
5088
  ],
5243
5089
  "outputs": [
5244
5090
  {
5245
- "type": "core::starknet::contract_address::ContractAddress"
5091
+ "type": "core::bool"
5246
5092
  }
5247
5093
  ],
5248
5094
  "state_mutability": "view"
5249
5095
  },
5250
5096
  {
5251
5097
  "type": "function",
5252
- "name": "is_approved_for_all",
5098
+ "name": "set_approval_for_all",
5253
5099
  "inputs": [
5254
- {
5255
- "name": "owner",
5256
- "type": "core::starknet::contract_address::ContractAddress"
5257
- },
5258
5100
  {
5259
5101
  "name": "operator",
5260
5102
  "type": "core::starknet::contract_address::ContractAddress"
5261
- }
5262
- ],
5263
- "outputs": [
5103
+ },
5264
5104
  {
5105
+ "name": "approved",
5265
5106
  "type": "core::bool"
5266
5107
  }
5267
5108
  ],
5268
- "state_mutability": "view"
5109
+ "outputs": [],
5110
+ "state_mutability": "external"
5269
5111
  }
5270
5112
  ]
5271
5113
  },
5272
5114
  {
5273
5115
  "type": "impl",
5274
- "name": "ERC721CamelOnly",
5275
- "interface_name": "openzeppelin_token::erc721::interface::IERC721CamelOnly"
5116
+ "name": "ERC1155CamelImpl",
5117
+ "interface_name": "openzeppelin_token::erc1155::interface::IERC1155Camel"
5276
5118
  },
5277
5119
  {
5278
5120
  "type": "interface",
5279
- "name": "openzeppelin_token::erc721::interface::IERC721CamelOnly",
5121
+ "name": "openzeppelin_token::erc1155::interface::IERC1155Camel",
5280
5122
  "items": [
5281
5123
  {
5282
5124
  "type": "function",
@@ -5285,6 +5127,10 @@ var IPTicketCollectionABI = [
5285
5127
  {
5286
5128
  "name": "account",
5287
5129
  "type": "core::starknet::contract_address::ContractAddress"
5130
+ },
5131
+ {
5132
+ "name": "tokenId",
5133
+ "type": "core::integer::u256"
5288
5134
  }
5289
5135
  ],
5290
5136
  "outputs": [
@@ -5296,16 +5142,20 @@ var IPTicketCollectionABI = [
5296
5142
  },
5297
5143
  {
5298
5144
  "type": "function",
5299
- "name": "ownerOf",
5145
+ "name": "balanceOfBatch",
5300
5146
  "inputs": [
5301
5147
  {
5302
- "name": "tokenId",
5303
- "type": "core::integer::u256"
5148
+ "name": "accounts",
5149
+ "type": "core::array::Span::<core::starknet::contract_address::ContractAddress>"
5150
+ },
5151
+ {
5152
+ "name": "tokenIds",
5153
+ "type": "core::array::Span::<core::integer::u256>"
5304
5154
  }
5305
5155
  ],
5306
5156
  "outputs": [
5307
5157
  {
5308
- "type": "core::starknet::contract_address::ContractAddress"
5158
+ "type": "core::array::Span::<core::integer::u256>"
5309
5159
  }
5310
5160
  ],
5311
5161
  "state_mutability": "view"
@@ -5326,6 +5176,10 @@ var IPTicketCollectionABI = [
5326
5176
  "name": "tokenId",
5327
5177
  "type": "core::integer::u256"
5328
5178
  },
5179
+ {
5180
+ "name": "value",
5181
+ "type": "core::integer::u256"
5182
+ },
5329
5183
  {
5330
5184
  "name": "data",
5331
5185
  "type": "core::array::Span::<core::felt252>"
@@ -5336,7 +5190,7 @@ var IPTicketCollectionABI = [
5336
5190
  },
5337
5191
  {
5338
5192
  "type": "function",
5339
- "name": "transferFrom",
5193
+ "name": "safeBatchTransferFrom",
5340
5194
  "inputs": [
5341
5195
  {
5342
5196
  "name": "from",
@@ -5347,24 +5201,16 @@ var IPTicketCollectionABI = [
5347
5201
  "type": "core::starknet::contract_address::ContractAddress"
5348
5202
  },
5349
5203
  {
5350
- "name": "tokenId",
5351
- "type": "core::integer::u256"
5352
- }
5353
- ],
5354
- "outputs": [],
5355
- "state_mutability": "external"
5356
- },
5357
- {
5358
- "type": "function",
5359
- "name": "setApprovalForAll",
5360
- "inputs": [
5204
+ "name": "tokenIds",
5205
+ "type": "core::array::Span::<core::integer::u256>"
5206
+ },
5361
5207
  {
5362
- "name": "operator",
5363
- "type": "core::starknet::contract_address::ContractAddress"
5208
+ "name": "values",
5209
+ "type": "core::array::Span::<core::integer::u256>"
5364
5210
  },
5365
5211
  {
5366
- "name": "approved",
5367
- "type": "core::bool"
5212
+ "name": "data",
5213
+ "type": "core::array::Span::<core::felt252>"
5368
5214
  }
5369
5215
  ],
5370
5216
  "outputs": [],
@@ -5372,39 +5218,39 @@ var IPTicketCollectionABI = [
5372
5218
  },
5373
5219
  {
5374
5220
  "type": "function",
5375
- "name": "getApproved",
5221
+ "name": "isApprovedForAll",
5376
5222
  "inputs": [
5377
5223
  {
5378
- "name": "tokenId",
5379
- "type": "core::integer::u256"
5224
+ "name": "owner",
5225
+ "type": "core::starknet::contract_address::ContractAddress"
5226
+ },
5227
+ {
5228
+ "name": "operator",
5229
+ "type": "core::starknet::contract_address::ContractAddress"
5380
5230
  }
5381
5231
  ],
5382
5232
  "outputs": [
5383
5233
  {
5384
- "type": "core::starknet::contract_address::ContractAddress"
5234
+ "type": "core::bool"
5385
5235
  }
5386
5236
  ],
5387
5237
  "state_mutability": "view"
5388
5238
  },
5389
5239
  {
5390
5240
  "type": "function",
5391
- "name": "isApprovedForAll",
5241
+ "name": "setApprovalForAll",
5392
5242
  "inputs": [
5393
- {
5394
- "name": "owner",
5395
- "type": "core::starknet::contract_address::ContractAddress"
5396
- },
5397
5243
  {
5398
5244
  "name": "operator",
5399
5245
  "type": "core::starknet::contract_address::ContractAddress"
5400
- }
5401
- ],
5402
- "outputs": [
5246
+ },
5403
5247
  {
5248
+ "name": "approved",
5404
5249
  "type": "core::bool"
5405
5250
  }
5406
5251
  ],
5407
- "state_mutability": "view"
5252
+ "outputs": [],
5253
+ "state_mutability": "external"
5408
5254
  }
5409
5255
  ]
5410
5256
  },
@@ -5515,9 +5361,14 @@ var IPTicketCollectionABI = [
5515
5361
  },
5516
5362
  {
5517
5363
  "type": "event",
5518
- "name": "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
5364
+ "name": "openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle",
5519
5365
  "kind": "struct",
5520
5366
  "members": [
5367
+ {
5368
+ "name": "operator",
5369
+ "type": "core::starknet::contract_address::ContractAddress",
5370
+ "kind": "key"
5371
+ },
5521
5372
  {
5522
5373
  "name": "from",
5523
5374
  "type": "core::starknet::contract_address::ContractAddress",
@@ -5529,37 +5380,52 @@ var IPTicketCollectionABI = [
5529
5380
  "kind": "key"
5530
5381
  },
5531
5382
  {
5532
- "name": "token_id",
5383
+ "name": "id",
5533
5384
  "type": "core::integer::u256",
5534
- "kind": "key"
5385
+ "kind": "data"
5386
+ },
5387
+ {
5388
+ "name": "value",
5389
+ "type": "core::integer::u256",
5390
+ "kind": "data"
5535
5391
  }
5536
5392
  ]
5537
5393
  },
5538
5394
  {
5539
5395
  "type": "event",
5540
- "name": "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
5396
+ "name": "openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch",
5541
5397
  "kind": "struct",
5542
5398
  "members": [
5543
5399
  {
5544
- "name": "owner",
5400
+ "name": "operator",
5545
5401
  "type": "core::starknet::contract_address::ContractAddress",
5546
5402
  "kind": "key"
5547
5403
  },
5548
5404
  {
5549
- "name": "approved",
5405
+ "name": "from",
5550
5406
  "type": "core::starknet::contract_address::ContractAddress",
5551
5407
  "kind": "key"
5552
5408
  },
5553
5409
  {
5554
- "name": "token_id",
5555
- "type": "core::integer::u256",
5410
+ "name": "to",
5411
+ "type": "core::starknet::contract_address::ContractAddress",
5556
5412
  "kind": "key"
5413
+ },
5414
+ {
5415
+ "name": "ids",
5416
+ "type": "core::array::Span::<core::integer::u256>",
5417
+ "kind": "data"
5418
+ },
5419
+ {
5420
+ "name": "values",
5421
+ "type": "core::array::Span::<core::integer::u256>",
5422
+ "kind": "data"
5557
5423
  }
5558
5424
  ]
5559
5425
  },
5560
5426
  {
5561
5427
  "type": "event",
5562
- "name": "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
5428
+ "name": "openzeppelin_token::erc1155::erc1155::ERC1155Component::ApprovalForAll",
5563
5429
  "kind": "struct",
5564
5430
  "members": [
5565
5431
  {
@@ -5568,35 +5434,57 @@ var IPTicketCollectionABI = [
5568
5434
  "kind": "key"
5569
5435
  },
5570
5436
  {
5571
- "name": "operator",
5572
- "type": "core::starknet::contract_address::ContractAddress",
5573
- "kind": "key"
5437
+ "name": "operator",
5438
+ "type": "core::starknet::contract_address::ContractAddress",
5439
+ "kind": "key"
5440
+ },
5441
+ {
5442
+ "name": "approved",
5443
+ "type": "core::bool",
5444
+ "kind": "data"
5445
+ }
5446
+ ]
5447
+ },
5448
+ {
5449
+ "type": "event",
5450
+ "name": "openzeppelin_token::erc1155::erc1155::ERC1155Component::URI",
5451
+ "kind": "struct",
5452
+ "members": [
5453
+ {
5454
+ "name": "value",
5455
+ "type": "core::byte_array::ByteArray",
5456
+ "kind": "data"
5574
5457
  },
5575
5458
  {
5576
- "name": "approved",
5577
- "type": "core::bool",
5578
- "kind": "data"
5459
+ "name": "id",
5460
+ "type": "core::integer::u256",
5461
+ "kind": "key"
5579
5462
  }
5580
5463
  ]
5581
5464
  },
5582
5465
  {
5583
5466
  "type": "event",
5584
- "name": "openzeppelin_token::erc721::erc721::ERC721Component::Event",
5467
+ "name": "openzeppelin_token::erc1155::erc1155::ERC1155Component::Event",
5585
5468
  "kind": "enum",
5586
5469
  "variants": [
5587
5470
  {
5588
- "name": "Transfer",
5589
- "type": "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
5471
+ "name": "TransferSingle",
5472
+ "type": "openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle",
5590
5473
  "kind": "nested"
5591
5474
  },
5592
5475
  {
5593
- "name": "Approval",
5594
- "type": "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
5476
+ "name": "TransferBatch",
5477
+ "type": "openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch",
5595
5478
  "kind": "nested"
5596
5479
  },
5597
5480
  {
5598
5481
  "name": "ApprovalForAll",
5599
- "type": "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
5482
+ "type": "openzeppelin_token::erc1155::erc1155::ERC1155Component::ApprovalForAll",
5483
+ "kind": "nested"
5484
+ },
5485
+ {
5486
+ "name": "URI",
5487
+ "type": "openzeppelin_token::erc1155::erc1155::ERC1155Component::URI",
5600
5488
  "kind": "nested"
5601
5489
  }
5602
5490
  ]
@@ -5660,42 +5548,27 @@ var IPTicketCollectionABI = [
5660
5548
  },
5661
5549
  {
5662
5550
  "type": "event",
5663
- "name": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketCollectionCreated",
5551
+ "name": "ip_ticket::IPTicketCollection::IPTicketCollection::EventCreated",
5664
5552
  "kind": "struct",
5665
5553
  "members": [
5666
5554
  {
5667
- "name": "collection_id",
5555
+ "name": "token_id",
5668
5556
  "type": "core::integer::u256",
5669
5557
  "kind": "key"
5670
5558
  },
5671
- {
5672
- "name": "creator",
5673
- "type": "core::starknet::contract_address::ContractAddress",
5674
- "kind": "key"
5675
- },
5676
- {
5677
- "name": "price",
5678
- "type": "core::integer::u256",
5679
- "kind": "data"
5680
- },
5681
5559
  {
5682
5560
  "name": "max_supply",
5683
5561
  "type": "core::integer::u256",
5684
5562
  "kind": "data"
5685
5563
  },
5686
5564
  {
5687
- "name": "expiration",
5688
- "type": "core::integer::u64",
5689
- "kind": "data"
5690
- },
5691
- {
5692
- "name": "royalty_bps",
5693
- "type": "core::integer::u256",
5565
+ "name": "start_time",
5566
+ "type": "core::option::Option::<core::integer::u64>",
5694
5567
  "kind": "data"
5695
5568
  },
5696
5569
  {
5697
- "name": "payment_token",
5698
- "type": "core::option::Option::<core::starknet::contract_address::ContractAddress>",
5570
+ "name": "end_time",
5571
+ "type": "core::option::Option::<core::integer::u64>",
5699
5572
  "kind": "data"
5700
5573
  },
5701
5574
  {
@@ -5712,11 +5585,11 @@ var IPTicketCollectionABI = [
5712
5585
  },
5713
5586
  {
5714
5587
  "type": "event",
5715
- "name": "ip_ticket::IPTicketCollection::IPTicketCollection::CollectionStatusUpdated",
5588
+ "name": "ip_ticket::IPTicketCollection::IPTicketCollection::EventPaused",
5716
5589
  "kind": "struct",
5717
5590
  "members": [
5718
5591
  {
5719
- "name": "collection_id",
5592
+ "name": "token_id",
5720
5593
  "type": "core::integer::u256",
5721
5594
  "kind": "key"
5722
5595
  },
@@ -5724,65 +5597,6 @@ var IPTicketCollectionABI = [
5724
5597
  "name": "active",
5725
5598
  "type": "core::bool",
5726
5599
  "kind": "data"
5727
- },
5728
- {
5729
- "name": "updated_at",
5730
- "type": "core::integer::u64",
5731
- "kind": "data"
5732
- }
5733
- ]
5734
- },
5735
- {
5736
- "type": "event",
5737
- "name": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketMinted",
5738
- "kind": "struct",
5739
- "members": [
5740
- {
5741
- "name": "token_id",
5742
- "type": "core::integer::u256",
5743
- "kind": "key"
5744
- },
5745
- {
5746
- "name": "collection_id",
5747
- "type": "core::integer::u256",
5748
- "kind": "key"
5749
- },
5750
- {
5751
- "name": "owner",
5752
- "type": "core::starknet::contract_address::ContractAddress",
5753
- "kind": "key"
5754
- },
5755
- {
5756
- "name": "minted_at",
5757
- "type": "core::integer::u64",
5758
- "kind": "data"
5759
- }
5760
- ]
5761
- },
5762
- {
5763
- "type": "event",
5764
- "name": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketRedeemed",
5765
- "kind": "struct",
5766
- "members": [
5767
- {
5768
- "name": "token_id",
5769
- "type": "core::integer::u256",
5770
- "kind": "key"
5771
- },
5772
- {
5773
- "name": "collection_id",
5774
- "type": "core::integer::u256",
5775
- "kind": "key"
5776
- },
5777
- {
5778
- "name": "owner",
5779
- "type": "core::starknet::contract_address::ContractAddress",
5780
- "kind": "key"
5781
- },
5782
- {
5783
- "name": "redeemed_at",
5784
- "type": "core::integer::u64",
5785
- "kind": "data"
5786
5600
  }
5787
5601
  ]
5788
5602
  },
@@ -5792,8 +5606,8 @@ var IPTicketCollectionABI = [
5792
5606
  "kind": "enum",
5793
5607
  "variants": [
5794
5608
  {
5795
- "name": "ERC721Event",
5796
- "type": "openzeppelin_token::erc721::erc721::ERC721Component::Event",
5609
+ "name": "ERC1155Event",
5610
+ "type": "openzeppelin_token::erc1155::erc1155::ERC1155Component::Event",
5797
5611
  "kind": "flat"
5798
5612
  },
5799
5613
  {
@@ -5807,23 +5621,13 @@ var IPTicketCollectionABI = [
5807
5621
  "kind": "flat"
5808
5622
  },
5809
5623
  {
5810
- "name": "TicketCollectionCreated",
5811
- "type": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketCollectionCreated",
5812
- "kind": "nested"
5813
- },
5814
- {
5815
- "name": "CollectionStatusUpdated",
5816
- "type": "ip_ticket::IPTicketCollection::IPTicketCollection::CollectionStatusUpdated",
5817
- "kind": "nested"
5818
- },
5819
- {
5820
- "name": "TicketMinted",
5821
- "type": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketMinted",
5624
+ "name": "EventCreated",
5625
+ "type": "ip_ticket::IPTicketCollection::IPTicketCollection::EventCreated",
5822
5626
  "kind": "nested"
5823
5627
  },
5824
5628
  {
5825
- "name": "TicketRedeemed",
5826
- "type": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketRedeemed",
5629
+ "name": "EventPaused",
5630
+ "type": "ip_ticket::IPTicketCollection::IPTicketCollection::EventPaused",
5827
5631
  "kind": "nested"
5828
5632
  }
5829
5633
  ]
@@ -5883,7 +5687,7 @@ var IPTicketCollectionFactoryABI = [
5883
5687
  },
5884
5688
  {
5885
5689
  "type": "function",
5886
- "name": "deploy_ticket_collection",
5690
+ "name": "deploy_collection",
5887
5691
  "inputs": [
5888
5692
  {
5889
5693
  "name": "name",
@@ -5903,6 +5707,47 @@ var IPTicketCollectionFactoryABI = [
5903
5707
  }
5904
5708
  ]
5905
5709
  },
5710
+ {
5711
+ "type": "impl",
5712
+ "name": "SRC5Impl",
5713
+ "interface_name": "openzeppelin_introspection::interface::ISRC5"
5714
+ },
5715
+ {
5716
+ "type": "enum",
5717
+ "name": "core::bool",
5718
+ "variants": [
5719
+ {
5720
+ "name": "False",
5721
+ "type": "()"
5722
+ },
5723
+ {
5724
+ "name": "True",
5725
+ "type": "()"
5726
+ }
5727
+ ]
5728
+ },
5729
+ {
5730
+ "type": "interface",
5731
+ "name": "openzeppelin_introspection::interface::ISRC5",
5732
+ "items": [
5733
+ {
5734
+ "type": "function",
5735
+ "name": "supports_interface",
5736
+ "inputs": [
5737
+ {
5738
+ "name": "interface_id",
5739
+ "type": "core::felt252"
5740
+ }
5741
+ ],
5742
+ "outputs": [
5743
+ {
5744
+ "type": "core::bool"
5745
+ }
5746
+ ],
5747
+ "state_mutability": "view"
5748
+ }
5749
+ ]
5750
+ },
5906
5751
  {
5907
5752
  "type": "constructor",
5908
5753
  "name": "constructor",
@@ -5913,6 +5758,12 @@ var IPTicketCollectionFactoryABI = [
5913
5758
  }
5914
5759
  ]
5915
5760
  },
5761
+ {
5762
+ "type": "event",
5763
+ "name": "openzeppelin_introspection::src5::SRC5Component::Event",
5764
+ "kind": "enum",
5765
+ "variants": []
5766
+ },
5916
5767
  {
5917
5768
  "type": "event",
5918
5769
  "name": "ip_ticket::IPTicketCollectionFactory::IPTicketCollectionFactory::CollectionDeployed",
@@ -5945,6 +5796,11 @@ var IPTicketCollectionFactoryABI = [
5945
5796
  "name": "ip_ticket::IPTicketCollectionFactory::IPTicketCollectionFactory::Event",
5946
5797
  "kind": "enum",
5947
5798
  "variants": [
5799
+ {
5800
+ "name": "SRC5Event",
5801
+ "type": "openzeppelin_introspection::src5::SRC5Component::Event",
5802
+ "kind": "flat"
5803
+ },
5948
5804
  {
5949
5805
  "name": "CollectionDeployed",
5950
5806
  "type": "ip_ticket::IPTicketCollectionFactory::IPTicketCollectionFactory::CollectionDeployed",
@@ -10486,12 +10342,39 @@ var SUPPORTED_TOKENS = [
10486
10342
  ];
10487
10343
  var DEFAULT_CURRENCY = "USDC";
10488
10344
 
10345
+ // src/utils/bigint.ts
10346
+ function stringifyBigInts(obj) {
10347
+ if (typeof obj === "bigint") {
10348
+ return obj.toString();
10349
+ }
10350
+ if (Array.isArray(obj)) {
10351
+ return obj.map(stringifyBigInts);
10352
+ }
10353
+ if (obj !== null && typeof obj === "object") {
10354
+ return Object.fromEntries(
10355
+ Object.entries(obj).map(([key, value]) => [
10356
+ key,
10357
+ stringifyBigInts(value)
10358
+ ])
10359
+ );
10360
+ }
10361
+ return obj;
10362
+ }
10363
+
10489
10364
  // src/utils/token.ts
10490
10365
  function parseAmount(human, decimals) {
10491
10366
  const [whole, frac = ""] = human.split(".");
10492
10367
  const fracPadded = frac.padEnd(decimals, "0").slice(0, decimals);
10493
10368
  return (BigInt(whole) * BigInt(10) ** BigInt(decimals) + BigInt(fracPadded)).toString();
10494
10369
  }
10370
+ function formatAmount(raw, decimals) {
10371
+ const value = BigInt(raw);
10372
+ const factor = BigInt(Math.pow(10, decimals));
10373
+ const whole = value / factor;
10374
+ const remainder = value % factor;
10375
+ const fractional = remainder.toString().padStart(decimals, "0");
10376
+ return `${whole}.${fractional}`;
10377
+ }
10495
10378
  function getTokenByAddress(address) {
10496
10379
  const lower = address.toLowerCase();
10497
10380
  return SUPPORTED_TOKENS.find((t) => t.address.toLowerCase() === lower);
@@ -10520,25 +10403,6 @@ function buildFeeCall(p, cfg) {
10520
10403
  };
10521
10404
  }
10522
10405
 
10523
- // src/utils/bigint.ts
10524
- function stringifyBigInts(obj) {
10525
- if (typeof obj === "bigint") {
10526
- return obj.toString();
10527
- }
10528
- if (Array.isArray(obj)) {
10529
- return obj.map(stringifyBigInts);
10530
- }
10531
- if (obj !== null && typeof obj === "object") {
10532
- return Object.fromEntries(
10533
- Object.entries(obj).map(([key, value]) => [
10534
- key,
10535
- stringifyBigInts(value)
10536
- ])
10537
- );
10538
- }
10539
- return obj;
10540
- }
10541
-
10542
10406
  // src/utils/rpc.ts
10543
10407
  var PUBLIC_RPC_FALLBACKS = [
10544
10408
  "https://rpc.starknet.lava.build"
@@ -10630,105 +10494,17 @@ function resolveToken(currency) {
10630
10494
  (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
10631
10495
  );
10632
10496
  if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
10633
- return token;
10634
- }
10635
- var _providerCache = /* @__PURE__ */ new WeakMap();
10636
- function getProvider(config) {
10637
- let p = _providerCache.get(config);
10638
- if (!p) {
10639
- const urls = Array.from(/* @__PURE__ */ new Set([config.rpcUrl, ...PUBLIC_RPC_FALLBACKS]));
10640
- p = new RpcProvider({ nodeUrl: urls[0], baseFetch: createFailoverFetch(urls) });
10641
- _providerCache.set(config, p);
10642
- }
10643
- return p;
10644
- }
10645
-
10646
- // src/starknet/marketplace/build.ts
10647
- function contractFor(cfg) {
10648
- return new Contract(IPMarketplaceABI, cfg.marketplaceContract, getProvider(cfg));
10649
- }
10650
- function buildListingOrder(i, cfg) {
10651
- const orderParams = {
10652
- offerer: i.offerer,
10653
- marketplace: cfg.marketplaceContract,
10654
- offer: { item_type: "ERC721", token: i.nftContract, identifier_or_criteria: i.tokenId, amount: "1" },
10655
- consideration: {
10656
- item_type: "ERC20",
10657
- token: i.paymentTokenAddress,
10658
- identifier_or_criteria: "0",
10659
- amount: i.priceWei,
10660
- recipient: i.offerer
10661
- },
10662
- royalty_max_bps: i.royaltyMaxBps,
10663
- start_time: String(i.startTime),
10664
- end_time: String(i.endTime),
10665
- salt: i.salt,
10666
- counter: i.counter
10667
- };
10668
- const typedData = stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10669
- return { orderParams, typedData };
10670
- }
10671
- function buildOfferOrder(i, cfg) {
10672
- const orderParams = {
10673
- offerer: i.offerer,
10674
- marketplace: cfg.marketplaceContract,
10675
- offer: { item_type: "ERC20", token: i.paymentTokenAddress, identifier_or_criteria: "0", amount: i.priceWei },
10676
- consideration: {
10677
- item_type: "ERC721",
10678
- token: i.nftContract,
10679
- identifier_or_criteria: i.tokenId,
10680
- amount: "1",
10681
- recipient: i.offerer
10682
- },
10683
- royalty_max_bps: i.royaltyMaxBps,
10684
- start_time: String(i.startTime),
10685
- end_time: String(i.endTime),
10686
- salt: i.salt,
10687
- counter: i.counter
10688
- };
10689
- const typedData = stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10690
- return { orderParams, typedData };
10691
- }
10692
- function registerPayload(orderParams, signature) {
10693
- return stringifyBigInts({
10694
- parameters: {
10695
- ...orderParams,
10696
- offer: { ...orderParams.offer, item_type: shortString.encodeShortString(orderParams.offer.item_type) },
10697
- consideration: {
10698
- ...orderParams.consideration,
10699
- item_type: shortString.encodeShortString(orderParams.consideration.item_type)
10700
- }
10701
- },
10702
- signature
10703
- });
10704
- }
10705
- function buildRegisterCalls(a, cfg) {
10706
- const registerCall = contractFor(cfg).populate("register_order", [registerPayload(a.orderParams, a.signature)]);
10707
- return a.approvalNeeded ? [a.approve, registerCall] : [registerCall];
10708
- }
10709
- function buildFulfillCalls(a, cfg) {
10710
- const u = cairo.uint256(a.totalPrice);
10711
- const approve = {
10712
- contractAddress: a.paymentToken,
10713
- entrypoint: "approve",
10714
- calldata: [cfg.marketplaceContract, u.low.toString(), u.high.toString()]
10715
- };
10716
- const fulfill = contractFor(cfg).populate("fulfill_order", [a.orderHash]);
10717
- const fee = buildFeeCall(
10718
- { surface: "marketplace", token: a.paymentToken, grossAmount: BigInt(a.totalPrice) },
10719
- cfg.feeConfig
10720
- );
10721
- return fee ? [approve, fulfill, fee] : [approve, fulfill];
10722
- }
10723
- function buildCancelCalls(a, cfg) {
10724
- const cancelRequest = stringifyBigInts({
10725
- cancelation: { order_hash: a.orderHash, offerer: a.offerer },
10726
- signature: a.signature
10727
- });
10728
- return [contractFor(cfg).populate("cancel_order", [cancelRequest])];
10497
+ return token;
10729
10498
  }
10730
- function buildCancelTypedData(orderHash, offerer, cfg) {
10731
- return stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
10499
+ var _providerCache = /* @__PURE__ */ new WeakMap();
10500
+ function getProvider(config) {
10501
+ let p = _providerCache.get(config);
10502
+ if (!p) {
10503
+ const urls = Array.from(/* @__PURE__ */ new Set([config.rpcUrl, ...PUBLIC_RPC_FALLBACKS]));
10504
+ p = new RpcProvider({ nodeUrl: urls[0], baseFetch: createFailoverFetch(urls) });
10505
+ _providerCache.set(config, p);
10506
+ }
10507
+ return p;
10732
10508
  }
10733
10509
 
10734
10510
  // src/starknet/marketplace/orders.ts
@@ -10755,22 +10531,46 @@ async function createListing(account, params, config) {
10755
10531
  const endTime = now + durationSeconds;
10756
10532
  const counter = (await contract.get_counter(account.address)).toString();
10757
10533
  const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
10758
- const { orderParams, typedData } = buildListingOrder(
10759
- {
10760
- offerer: account.address,
10761
- nftContract,
10762
- tokenId,
10763
- priceWei,
10764
- paymentTokenAddress: token.address,
10765
- royaltyMaxBps,
10766
- startTime,
10767
- endTime,
10768
- salt: generateSalt(),
10769
- counter
10534
+ const orderParams = {
10535
+ offerer: account.address,
10536
+ marketplace: config.marketplaceContract,
10537
+ offer: {
10538
+ item_type: "ERC721",
10539
+ token: nftContract,
10540
+ identifier_or_criteria: tokenId,
10541
+ amount: "1"
10770
10542
  },
10771
- config
10772
- );
10773
- const signatureArray = toSignatureArray(await account.signMessage(typedData));
10543
+ consideration: {
10544
+ item_type: "ERC20",
10545
+ token: token.address,
10546
+ identifier_or_criteria: "0",
10547
+ amount: priceWei,
10548
+ recipient: account.address
10549
+ },
10550
+ royalty_max_bps: royaltyMaxBps,
10551
+ start_time: startTime.toString(),
10552
+ end_time: endTime.toString(),
10553
+ salt: generateSalt(),
10554
+ counter
10555
+ };
10556
+ const chainId = getChainId(config);
10557
+ const typedData = stringifyBigInts(buildOrderTypedData(orderParams, chainId));
10558
+ const signature = await account.signMessage(typedData);
10559
+ const signatureArray = toSignatureArray(signature);
10560
+ const registerPayload = stringifyBigInts({
10561
+ parameters: {
10562
+ ...orderParams,
10563
+ offer: {
10564
+ ...orderParams.offer,
10565
+ item_type: shortString.encodeShortString(orderParams.offer.item_type)
10566
+ },
10567
+ consideration: {
10568
+ ...orderParams.consideration,
10569
+ item_type: shortString.encodeShortString(orderParams.consideration.item_type)
10570
+ }
10571
+ },
10572
+ signature: signatureArray
10573
+ });
10774
10574
  const tokenIdUint256 = cairo.uint256(tokenId);
10775
10575
  let isAlreadyApproved = false;
10776
10576
  try {
@@ -10782,19 +10582,19 @@ async function createListing(account, params, config) {
10782
10582
  isAlreadyApproved = BigInt(result[0]).toString() === BigInt(config.marketplaceContract).toString();
10783
10583
  } catch {
10784
10584
  }
10785
- const approve = {
10786
- contractAddress: nftContract,
10787
- entrypoint: "approve",
10788
- calldata: [
10789
- config.marketplaceContract,
10790
- tokenIdUint256.low.toString(),
10791
- tokenIdUint256.high.toString()
10792
- ]
10793
- };
10794
- const calls = buildRegisterCalls(
10795
- { orderParams, signature: signatureArray, approvalNeeded: !isAlreadyApproved, approve },
10796
- config
10797
- );
10585
+ const registerCall = contract.populate("register_order", [registerPayload]);
10586
+ const calls = isAlreadyApproved ? [registerCall] : [
10587
+ {
10588
+ contractAddress: nftContract,
10589
+ entrypoint: "approve",
10590
+ calldata: [
10591
+ config.marketplaceContract,
10592
+ tokenIdUint256.low.toString(),
10593
+ tokenIdUint256.high.toString()
10594
+ ]
10595
+ },
10596
+ registerCall
10597
+ ];
10798
10598
  try {
10799
10599
  const tx = await account.execute(calls);
10800
10600
  await provider.waitForTransaction(tx.transaction_hash);
@@ -10813,22 +10613,46 @@ async function makeOffer(account, params, config) {
10813
10613
  const endTime = now + durationSeconds;
10814
10614
  const counter = (await contract.get_counter(account.address)).toString();
10815
10615
  const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
10816
- const { orderParams, typedData } = buildOfferOrder(
10817
- {
10818
- offerer: account.address,
10819
- nftContract,
10820
- tokenId,
10821
- priceWei,
10822
- paymentTokenAddress: token.address,
10823
- royaltyMaxBps,
10824
- startTime,
10825
- endTime,
10826
- salt: generateSalt(),
10827
- counter
10616
+ const orderParams = {
10617
+ offerer: account.address,
10618
+ marketplace: config.marketplaceContract,
10619
+ offer: {
10620
+ item_type: "ERC20",
10621
+ token: token.address,
10622
+ identifier_or_criteria: "0",
10623
+ amount: priceWei
10828
10624
  },
10829
- config
10830
- );
10831
- const signatureArray = toSignatureArray(await account.signMessage(typedData));
10625
+ consideration: {
10626
+ item_type: "ERC721",
10627
+ token: nftContract,
10628
+ identifier_or_criteria: tokenId,
10629
+ amount: "1",
10630
+ recipient: account.address
10631
+ },
10632
+ royalty_max_bps: royaltyMaxBps,
10633
+ start_time: startTime.toString(),
10634
+ end_time: endTime.toString(),
10635
+ salt: generateSalt(),
10636
+ counter
10637
+ };
10638
+ const chainId = getChainId(config);
10639
+ const typedData = stringifyBigInts(buildOrderTypedData(orderParams, chainId));
10640
+ const signature = await account.signMessage(typedData);
10641
+ const signatureArray = toSignatureArray(signature);
10642
+ const registerPayload = stringifyBigInts({
10643
+ parameters: {
10644
+ ...orderParams,
10645
+ offer: {
10646
+ ...orderParams.offer,
10647
+ item_type: shortString.encodeShortString(orderParams.offer.item_type)
10648
+ },
10649
+ consideration: {
10650
+ ...orderParams.consideration,
10651
+ item_type: shortString.encodeShortString(orderParams.consideration.item_type)
10652
+ }
10653
+ },
10654
+ signature: signatureArray
10655
+ });
10832
10656
  const amountUint256 = cairo.uint256(priceWei);
10833
10657
  const approveCall = {
10834
10658
  contractAddress: token.address,
@@ -10839,12 +10663,9 @@ async function makeOffer(account, params, config) {
10839
10663
  amountUint256.high.toString()
10840
10664
  ]
10841
10665
  };
10842
- const calls = buildRegisterCalls(
10843
- { orderParams, signature: signatureArray, approvalNeeded: true, approve: approveCall },
10844
- config
10845
- );
10666
+ const registerCall = contract.populate("register_order", [registerPayload]);
10846
10667
  try {
10847
- const tx = await account.execute(calls);
10668
+ const tx = await account.execute([approveCall, registerCall]);
10848
10669
  await provider.waitForTransaction(tx.transaction_hash);
10849
10670
  return { txHash: tx.transaction_hash };
10850
10671
  } catch (err) {
@@ -10853,8 +10674,23 @@ async function makeOffer(account, params, config) {
10853
10674
  }
10854
10675
  async function fulfillOrder(account, params, config) {
10855
10676
  const { orderHash, paymentToken, totalPrice } = params;
10856
- const { provider } = makeContract(config);
10857
- const calls = buildFulfillCalls({ orderHash, paymentToken, totalPrice }, config);
10677
+ const { contract, provider } = makeContract(config);
10678
+ const totalPriceU256 = cairo.uint256(totalPrice);
10679
+ const approveCall = {
10680
+ contractAddress: paymentToken,
10681
+ entrypoint: "approve",
10682
+ calldata: [
10683
+ config.marketplaceContract,
10684
+ totalPriceU256.low.toString(),
10685
+ totalPriceU256.high.toString()
10686
+ ]
10687
+ };
10688
+ const fulfillCall = contract.populate("fulfill_order", [orderHash]);
10689
+ const feeCall = buildFeeCall(
10690
+ { surface: "marketplace", token: paymentToken, grossAmount: BigInt(totalPrice) },
10691
+ config.feeConfig
10692
+ );
10693
+ const calls = feeCall ? [approveCall, fulfillCall, feeCall] : [approveCall, fulfillCall];
10858
10694
  try {
10859
10695
  const tx = await account.execute(calls);
10860
10696
  await provider.waitForTransaction(tx.transaction_hash);
@@ -10865,12 +10701,24 @@ async function fulfillOrder(account, params, config) {
10865
10701
  }
10866
10702
  async function cancelOrder(account, params, config) {
10867
10703
  const { orderHash } = params;
10868
- const { provider } = makeContract(config);
10869
- const typedData = buildCancelTypedData(orderHash, account.address, config);
10870
- const signatureArray = toSignatureArray(await account.signMessage(typedData));
10871
- const calls = buildCancelCalls({ orderHash, offerer: account.address, signature: signatureArray }, config);
10704
+ const { contract, provider } = makeContract(config);
10705
+ const chainId = getChainId(config);
10706
+ const cancelParams = {
10707
+ order_hash: orderHash,
10708
+ offerer: account.address
10709
+ };
10710
+ const typedData = stringifyBigInts(
10711
+ buildCancellationTypedData(cancelParams, chainId)
10712
+ );
10713
+ const signature = await account.signMessage(typedData);
10714
+ const signatureArray = toSignatureArray(signature);
10715
+ const cancelRequest = stringifyBigInts({
10716
+ cancelation: cancelParams,
10717
+ signature: signatureArray
10718
+ });
10719
+ const call = contract.populate("cancel_order", [cancelRequest]);
10872
10720
  try {
10873
- const tx = await account.execute(calls);
10721
+ const tx = await account.execute(call);
10874
10722
  await provider.waitForTransaction(tx.transaction_hash);
10875
10723
  return { txHash: tx.transaction_hash };
10876
10724
  } catch (err) {
@@ -11017,100 +10865,6 @@ var MarketplaceModule = class {
11017
10865
  return buildCancellationTypedData(params, chainId);
11018
10866
  }
11019
10867
  };
11020
- function contractFor2(cfg) {
11021
- return new Contract(Medialane1155ABI, cfg.marketplace1155Contract, getProvider(cfg));
11022
- }
11023
- function buildListing1155Order(i, cfg) {
11024
- const orderParams = {
11025
- offerer: i.offerer,
11026
- marketplace: cfg.marketplace1155Contract,
11027
- offer: { item_type: "ERC1155", token: i.nftContract, identifier_or_criteria: i.tokenId, amount: i.quantity },
11028
- consideration: {
11029
- item_type: "ERC20",
11030
- token: i.paymentTokenAddress,
11031
- identifier_or_criteria: "0",
11032
- amount: i.priceWeiPerUnit,
11033
- recipient: i.offerer
11034
- },
11035
- royalty_max_bps: i.royaltyMaxBps,
11036
- start_time: String(i.startTime),
11037
- end_time: String(i.endTime),
11038
- salt: i.salt,
11039
- counter: i.counter
11040
- };
11041
- const typedData = stringifyBigInts(
11042
- build1155OrderTypedData(orderParams, getChainId(cfg))
11043
- );
11044
- return { orderParams, typedData };
11045
- }
11046
- function buildOffer1155Order(i, cfg) {
11047
- const orderParams = {
11048
- offerer: i.offerer,
11049
- marketplace: cfg.marketplace1155Contract,
11050
- offer: { item_type: "ERC20", token: i.paymentTokenAddress, identifier_or_criteria: "0", amount: i.priceWeiPerUnit },
11051
- consideration: {
11052
- item_type: "ERC1155",
11053
- token: i.nftContract,
11054
- identifier_or_criteria: i.tokenId,
11055
- amount: i.quantity,
11056
- recipient: i.offerer
11057
- },
11058
- royalty_max_bps: i.royaltyMaxBps,
11059
- start_time: String(i.startTime),
11060
- end_time: String(i.endTime),
11061
- salt: i.salt,
11062
- counter: i.counter
11063
- };
11064
- const typedData = stringifyBigInts(
11065
- build1155OrderTypedData(orderParams, getChainId(cfg))
11066
- );
11067
- return { orderParams, typedData };
11068
- }
11069
- function registerPayload2(orderParams, signature) {
11070
- return stringifyBigInts({
11071
- parameters: {
11072
- ...orderParams,
11073
- offer: { ...orderParams.offer, item_type: shortString.encodeShortString(orderParams.offer.item_type) },
11074
- consideration: {
11075
- ...orderParams.consideration,
11076
- item_type: shortString.encodeShortString(orderParams.consideration.item_type)
11077
- }
11078
- },
11079
- signature
11080
- });
11081
- }
11082
- function buildRegister1155Calls(a, cfg) {
11083
- const registerCall = contractFor2(cfg).populate("register_order", [registerPayload2(a.orderParams, a.signature)]);
11084
- return a.approvalNeeded ? [a.approve, registerCall] : [registerCall];
11085
- }
11086
- function buildFulfill1155Calls(a, cfg) {
11087
- const u = cairo.uint256(a.totalPrice);
11088
- const approve = {
11089
- contractAddress: a.paymentToken,
11090
- entrypoint: "approve",
11091
- calldata: [cfg.marketplace1155Contract, u.low.toString(), u.high.toString()]
11092
- };
11093
- const fulfill = contractFor2(cfg).populate("fulfill_order", [a.orderHash, a.quantity]);
11094
- const fee = buildFeeCall(
11095
- { surface: "marketplace", token: a.paymentToken, grossAmount: BigInt(a.totalPrice) },
11096
- cfg.feeConfig
11097
- );
11098
- return fee ? [approve, fulfill, fee] : [approve, fulfill];
11099
- }
11100
- function buildCancel1155Calls(a, cfg) {
11101
- const cancelPayload = stringifyBigInts({
11102
- cancelation: { order_hash: a.orderHash, offerer: a.offerer },
11103
- signature: a.signature
11104
- });
11105
- return [contractFor2(cfg).populate("cancel_order", [cancelPayload])];
11106
- }
11107
- function buildCancel1155TypedData(orderHash, offerer, cfg) {
11108
- return stringifyBigInts(
11109
- build1155CancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg))
11110
- );
11111
- }
11112
-
11113
- // src/starknet/marketplace1155/orders.ts
11114
10868
  var _contractCache2 = /* @__PURE__ */ new WeakMap();
11115
10869
  function getContract(config) {
11116
10870
  let c = _contractCache2.get(config);
@@ -11139,27 +10893,53 @@ async function createListing1155(account, params, config) {
11139
10893
  const token = resolveToken(currency);
11140
10894
  const priceWei = parseAmount(pricePerUnit, token.decimals);
11141
10895
  const now = Math.floor(Date.now() / 1e3);
11142
- const startTime = now + START_TIME_BUFFER_SECS;
11143
10896
  const endTime = now + durationSeconds;
10897
+ const chainId = getChainId(config);
11144
10898
  const counter = (await contract.get_counter(account.address)).toString();
11145
10899
  const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
11146
- const { orderParams, typedData } = buildListing1155Order(
11147
- {
11148
- offerer: account.address,
11149
- nftContract,
11150
- tokenId,
11151
- quantity: amount,
11152
- priceWeiPerUnit: priceWei,
11153
- paymentTokenAddress: token.address,
11154
- royaltyMaxBps,
11155
- startTime,
11156
- endTime,
11157
- salt: generateSalt(),
11158
- counter
10900
+ const orderParams = {
10901
+ offerer: account.address,
10902
+ marketplace: config.marketplace1155Contract,
10903
+ offer: {
10904
+ item_type: "ERC1155",
10905
+ token: nftContract,
10906
+ identifier_or_criteria: tokenId,
10907
+ amount
10908
+ // ERC-1155 leg amount = unit quantity
11159
10909
  },
11160
- config
10910
+ consideration: {
10911
+ item_type: "ERC20",
10912
+ token: token.address,
10913
+ identifier_or_criteria: "0",
10914
+ amount: priceWei,
10915
+ // payment leg amount = price PER UNIT
10916
+ recipient: account.address
10917
+ },
10918
+ royalty_max_bps: royaltyMaxBps,
10919
+ start_time: (now + START_TIME_BUFFER_SECS).toString(),
10920
+ end_time: endTime.toString(),
10921
+ salt: generateSalt(),
10922
+ counter
10923
+ };
10924
+ const typedData = stringifyBigInts(
10925
+ build1155OrderTypedData(orderParams, chainId)
11161
10926
  );
11162
- const signatureArray = toSignatureArray(await account.signMessage(typedData));
10927
+ const signature = await account.signMessage(typedData);
10928
+ const signatureArray = toSignatureArray(signature);
10929
+ const orderPayload = stringifyBigInts({
10930
+ parameters: {
10931
+ ...orderParams,
10932
+ offer: {
10933
+ ...orderParams.offer,
10934
+ item_type: shortString.encodeShortString(orderParams.offer.item_type)
10935
+ },
10936
+ consideration: {
10937
+ ...orderParams.consideration,
10938
+ item_type: shortString.encodeShortString(orderParams.consideration.item_type)
10939
+ }
10940
+ },
10941
+ signature: signatureArray
10942
+ });
11163
10943
  let isApproved = false;
11164
10944
  try {
11165
10945
  const result = await provider.callContract({
@@ -11170,15 +10950,15 @@ async function createListing1155(account, params, config) {
11170
10950
  isApproved = BigInt(result[0]) === 1n;
11171
10951
  } catch {
11172
10952
  }
11173
- const approve = {
11174
- contractAddress: nftContract,
11175
- entrypoint: "set_approval_for_all",
11176
- calldata: [config.marketplace1155Contract, "1"]
11177
- };
11178
- const calls = buildRegister1155Calls(
11179
- { orderParams, signature: signatureArray, approvalNeeded: !isApproved, approve },
11180
- config
11181
- );
10953
+ const registerCall = contract.populate("register_order", [orderPayload]);
10954
+ const calls = isApproved ? [registerCall] : [
10955
+ {
10956
+ contractAddress: nftContract,
10957
+ entrypoint: "set_approval_for_all",
10958
+ calldata: [config.marketplace1155Contract, "1"]
10959
+ },
10960
+ registerCall
10961
+ ];
11182
10962
  try {
11183
10963
  const tx = await account.execute(calls);
11184
10964
  await provider.waitForTransaction(tx.transaction_hash);
@@ -11189,10 +10969,21 @@ async function createListing1155(account, params, config) {
11189
10969
  }
11190
10970
  async function fulfillOrder1155(account, params, config) {
11191
10971
  const { orderHash, paymentToken, totalPrice, quantity = "1" } = params;
10972
+ const contract = getContract(config);
11192
10973
  const provider = getProvider(config);
11193
- const calls = buildFulfill1155Calls({ orderHash, paymentToken, totalPrice, quantity }, config);
10974
+ const totalPriceU256 = cairo.uint256(totalPrice);
10975
+ const approveCall = {
10976
+ contractAddress: paymentToken,
10977
+ entrypoint: "approve",
10978
+ calldata: [
10979
+ config.marketplace1155Contract,
10980
+ totalPriceU256.low.toString(),
10981
+ totalPriceU256.high.toString()
10982
+ ]
10983
+ };
10984
+ const fulfillCall = contract.populate("fulfill_order", [orderHash, quantity]);
11194
10985
  try {
11195
- const tx = await account.execute(calls);
10986
+ const tx = await account.execute([approveCall, fulfillCall]);
11196
10987
  await provider.waitForTransaction(tx.transaction_hash);
11197
10988
  return { txHash: tx.transaction_hash };
11198
10989
  } catch (err) {
@@ -11201,12 +10992,25 @@ async function fulfillOrder1155(account, params, config) {
11201
10992
  }
11202
10993
  async function cancelOrder1155(account, params, config) {
11203
10994
  const { orderHash } = params;
10995
+ const contract = getContract(config);
11204
10996
  const provider = getProvider(config);
11205
- const typedData = buildCancel1155TypedData(orderHash, account.address, config);
11206
- const signatureArray = toSignatureArray(await account.signMessage(typedData));
11207
- const calls = buildCancel1155Calls({ orderHash, offerer: account.address, signature: signatureArray }, config);
10997
+ const chainId = getChainId(config);
10998
+ const cancelParams = {
10999
+ order_hash: orderHash,
11000
+ offerer: account.address
11001
+ };
11002
+ const typedData = stringifyBigInts(
11003
+ build1155CancellationTypedData(cancelParams, chainId)
11004
+ );
11005
+ const signature = await account.signMessage(typedData);
11006
+ const signatureArray = toSignatureArray(signature);
11007
+ const cancelPayload = stringifyBigInts({
11008
+ cancelation: cancelParams,
11009
+ signature: signatureArray
11010
+ });
11011
+ const cancelCall = contract.populate("cancel_order", [cancelPayload]);
11208
11012
  try {
11209
- const tx = await account.execute(calls);
11013
+ const tx = await account.execute(cancelCall);
11210
11014
  await provider.waitForTransaction(tx.transaction_hash);
11211
11015
  return { txHash: tx.transaction_hash };
11212
11016
  } catch (err) {
@@ -11224,30 +11028,56 @@ async function makeOffer1155(account, params, config) {
11224
11028
  } = params;
11225
11029
  const contract = getContract(config);
11226
11030
  const provider = getProvider(config);
11031
+ const chainId = getChainId(config);
11227
11032
  const token = resolveToken(currency);
11228
11033
  const priceWei = parseAmount(price, token.decimals);
11229
11034
  const now = Math.floor(Date.now() / 1e3);
11230
- const startTime = now + START_TIME_BUFFER_SECS;
11231
11035
  const endTime = now + durationSeconds;
11232
11036
  const counter = (await contract.get_counter(account.address)).toString();
11233
11037
  const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
11234
- const { orderParams, typedData } = buildOffer1155Order(
11235
- {
11236
- offerer: account.address,
11237
- nftContract,
11238
- tokenId,
11239
- quantity: amount,
11240
- priceWeiPerUnit: priceWei,
11241
- paymentTokenAddress: token.address,
11242
- royaltyMaxBps,
11243
- startTime,
11244
- endTime,
11245
- salt: generateSalt(),
11246
- counter
11038
+ const orderParams = {
11039
+ offerer: account.address,
11040
+ marketplace: config.marketplace1155Contract,
11041
+ offer: {
11042
+ item_type: "ERC20",
11043
+ token: token.address,
11044
+ identifier_or_criteria: "0",
11045
+ amount: priceWei
11046
+ // price PER UNIT
11247
11047
  },
11248
- config
11048
+ consideration: {
11049
+ item_type: "ERC1155",
11050
+ token: nftContract,
11051
+ identifier_or_criteria: tokenId,
11052
+ amount,
11053
+ // unit quantity
11054
+ recipient: account.address
11055
+ },
11056
+ royalty_max_bps: royaltyMaxBps,
11057
+ start_time: (now + START_TIME_BUFFER_SECS).toString(),
11058
+ end_time: endTime.toString(),
11059
+ salt: generateSalt(),
11060
+ counter
11061
+ };
11062
+ const typedData = stringifyBigInts(
11063
+ build1155OrderTypedData(orderParams, chainId)
11249
11064
  );
11250
- const signatureArray = toSignatureArray(await account.signMessage(typedData));
11065
+ const signature = await account.signMessage(typedData);
11066
+ const signatureArray = toSignatureArray(signature);
11067
+ const registerPayload = stringifyBigInts({
11068
+ parameters: {
11069
+ ...orderParams,
11070
+ offer: {
11071
+ ...orderParams.offer,
11072
+ item_type: shortString.encodeShortString(orderParams.offer.item_type)
11073
+ },
11074
+ consideration: {
11075
+ ...orderParams.consideration,
11076
+ item_type: shortString.encodeShortString(orderParams.consideration.item_type)
11077
+ }
11078
+ },
11079
+ signature: signatureArray
11080
+ });
11251
11081
  const totalWei = BigInt(priceWei) * BigInt(amount);
11252
11082
  const amountU256 = cairo.uint256(totalWei.toString());
11253
11083
  const approveCall = {
@@ -11259,12 +11089,9 @@ async function makeOffer1155(account, params, config) {
11259
11089
  amountU256.high.toString()
11260
11090
  ]
11261
11091
  };
11262
- const calls = buildRegister1155Calls(
11263
- { orderParams, signature: signatureArray, approvalNeeded: true, approve: approveCall },
11264
- config
11265
- );
11092
+ const registerCall = contract.populate("register_order", [registerPayload]);
11266
11093
  try {
11267
- const tx = await account.execute(calls);
11094
+ const tx = await account.execute([approveCall, registerCall]);
11268
11095
  await provider.waitForTransaction(tx.transaction_hash);
11269
11096
  return { txHash: tx.transaction_hash };
11270
11097
  } catch (err) {
@@ -12524,66 +12351,84 @@ var CreatorCoinService = class {
12524
12351
  };
12525
12352
  var TicketService = class {
12526
12353
  constructor(config) {
12354
+ this.config = config;
12527
12355
  this.factoryAddress = getStarknetCoordinates(config.chain).ipTicketsFactory;
12528
12356
  }
12357
+ _factory(account, factoryAddress) {
12358
+ const address = factoryAddress ?? this.factoryAddress;
12359
+ if (!address) throw new Error("IP-Tickets factory address not configured for this chain");
12360
+ return new Contract(IPTicketCollectionFactoryABI, normalizeAddress("STARKNET", address), account);
12361
+ }
12529
12362
  _collection(address, account) {
12530
12363
  return new Contract(IPTicketCollectionABI, normalizeAddress("STARKNET", address), account);
12531
12364
  }
12532
- /** Deploys a new IPTicketCollection via the factory. Caller becomes its owner. */
12533
- async deployTicketCollection(account, params) {
12534
- const factoryAddress = params.factoryAddress ?? this.factoryAddress;
12535
- if (!factoryAddress) {
12536
- throw new Error("IP-Tickets factory address not configured for this chain");
12537
- }
12538
- const factory = new Contract(IPTicketCollectionFactoryABI, factoryAddress, account);
12539
- const call = factory.populate("deploy_ticket_collection", [params.name, params.symbol]);
12365
+ _collectionRead(address) {
12366
+ const provider = new RpcProvider({ nodeUrl: this.config.rpcUrl });
12367
+ return new Contract(IPTicketCollectionABI, normalizeAddress("STARKNET", address), provider);
12368
+ }
12369
+ /** Deploys a new IPTicketCollection via the factory. Caller becomes owner. */
12370
+ async deployCollection(account, params) {
12371
+ const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [params.name, params.symbol]);
12540
12372
  const res = await account.execute([call]);
12541
12373
  return { txHash: res.transaction_hash };
12542
12374
  }
12543
- /** Owner-only. Creates a new ticket collection (event/tier) inside the caller's deployed IPTicketCollection. */
12544
- async createTicketCollection(account, params) {
12545
- const paymentToken = params.paymentToken ? new CairoOption(CairoOptionVariant.Some, params.paymentToken) : new CairoOption(CairoOptionVariant.None);
12546
- const call = this._collection(params.collection, account).populate("create_ticket_collection", [
12547
- cairo.uint256(params.price),
12375
+ /** Owner-only. Creates a new event inside the caller's deployed collection. */
12376
+ async createEvent(account, params) {
12377
+ const startTime = params.startTime != null ? new CairoOption(CairoOptionVariant.Some, params.startTime) : new CairoOption(CairoOptionVariant.None);
12378
+ const endTime = params.endTime != null ? new CairoOption(CairoOptionVariant.Some, params.endTime) : new CairoOption(CairoOptionVariant.None);
12379
+ const call = this._collection(params.collection, account).populate("create_event", [
12548
12380
  cairo.uint256(params.maxSupply),
12549
- params.expiration,
12381
+ startTime,
12382
+ endTime,
12550
12383
  params.royaltyBps,
12551
- paymentToken,
12552
12384
  params.metadataUri
12553
12385
  ]);
12554
12386
  const res = await account.execute([call]);
12555
12387
  return { txHash: res.transaction_hash };
12556
12388
  }
12557
- /** Owner-only. Gates minting only existing tickets keep access/transfer/redeem. */
12558
- async setCollectionActive(account, params) {
12559
- const call = this._collection(params.collection, account).populate("set_collection_active", [
12560
- cairo.uint256(params.collectionId),
12561
- params.active
12389
+ /** Owner-only. Mints `amount` of `tokenId` to `to`. */
12390
+ async mint(account, params) {
12391
+ const call = this._collection(params.collection, account).populate("mint", [
12392
+ params.to,
12393
+ cairo.uint256(params.tokenId),
12394
+ cairo.uint256(params.amount)
12562
12395
  ]);
12563
12396
  const res = await account.execute([call]);
12564
12397
  return { txHash: res.transaction_hash };
12565
12398
  }
12566
- /** Mints a ticket. Prepends an ERC-20 approve when the collection is paid. */
12567
- async mintTicket(account, params) {
12568
- const calls = [];
12569
- if (params.paymentToken && params.price && BigInt(params.price) > 0n) {
12570
- const amount = cairo.uint256(params.price);
12571
- calls.push({
12572
- contractAddress: params.paymentToken,
12573
- entrypoint: "approve",
12574
- calldata: [normalizeAddress("STARKNET", params.collection), amount.low.toString(), amount.high.toString()]
12575
- });
12576
- }
12577
- calls.push(this._collection(params.collection, account).populate("mint_ticket", [cairo.uint256(params.collectionId)]));
12578
- const res = await account.execute(calls);
12579
- return { txHash: res.transaction_hash };
12580
- }
12581
- /** Only the current token owner may redeem. */
12582
- async redeemTicket(account, params) {
12583
- const call = this._collection(params.collection, account).populate("redeem_ticket", [cairo.uint256(params.tokenId)]);
12399
+ /** Owner-only. Pauses or resumes minting for one event. */
12400
+ async pauseEvent(account, params) {
12401
+ const call = this._collection(params.collection, account).populate("pause_event", [
12402
+ cairo.uint256(params.tokenId),
12403
+ params.active
12404
+ ]);
12584
12405
  const res = await account.execute([call]);
12585
12406
  return { txHash: res.transaction_hash };
12586
12407
  }
12408
+ /** Read — true if holder has balance > 0 and current time is within the event window. */
12409
+ async isValid(params) {
12410
+ const result = await this._collectionRead(params.collection).call("is_valid", [
12411
+ cairo.uint256(params.tokenId),
12412
+ params.holder
12413
+ ]);
12414
+ return Boolean(result);
12415
+ }
12416
+ /** Read — returns the EventRecord for a token ID. */
12417
+ async getEvent(params) {
12418
+ const ev = await this._collectionRead(params.collection).call("get_event", [
12419
+ cairo.uint256(params.tokenId)
12420
+ ]);
12421
+ return {
12422
+ creator: ev.creator,
12423
+ maxSupply: BigInt(ev.max_supply),
12424
+ minted: BigInt(ev.minted),
12425
+ startTime: ev.start_time?.variant === "Some" ? Number(ev.start_time.values[0] ?? ev.start_time.value) : null,
12426
+ endTime: ev.end_time?.variant === "Some" ? Number(ev.end_time.values[0] ?? ev.end_time.value) : null,
12427
+ royaltyBps: Number(ev.royalty_bps),
12428
+ metadataUri: ev.metadata_uri,
12429
+ active: Boolean(ev.active)
12430
+ };
12431
+ }
12587
12432
  };
12588
12433
  var ClubService = class {
12589
12434
  constructor(config) {
@@ -12864,147 +12709,94 @@ var StarknetVenue = class {
12864
12709
  constructor(deps) {
12865
12710
  this.deps = deps;
12866
12711
  this.chain = "STARKNET";
12712
+ this.m721 = new MarketplaceModule(deps.config);
12713
+ this.m1155 = new Medialane1155Module(deps.config);
12867
12714
  }
12868
- async incrementCounter(signer) {
12869
- return signer.execute([
12870
- { contractAddress: this.deps.config.marketplaceContract, entrypoint: "increment_counter", calldata: [] }
12871
- ]);
12715
+ incrementCounter(signer) {
12716
+ return this.m721.incrementCounter(signer);
12872
12717
  }
12873
12718
  getOrderDetails(orderRef) {
12874
- return getOrderDetails(orderRef, this.deps.config);
12719
+ return this.m721.getOrderDetails(orderRef);
12875
12720
  }
12876
- async getCounter(address) {
12877
- return this.readCounter(this.deps.config.marketplaceContract, address);
12721
+ getCounter(address) {
12722
+ return this.m721.getCounter(address);
12878
12723
  }
12879
12724
  async fulfillOrder(signer, orderRef, opts) {
12880
12725
  const o = await this.deps.resolveOrder(orderRef);
12881
12726
  const quantity = opts?.quantity ?? "1";
12882
12727
  const totalPrice = (BigInt(o.unitPrice) * BigInt(quantity)).toString();
12883
- const calls = o.standard === "ERC1155" ? buildFulfill1155Calls({ orderHash: orderRef, paymentToken: o.paymentToken, totalPrice, quantity }, this.deps.config) : buildFulfillCalls({ orderHash: orderRef, paymentToken: o.paymentToken, totalPrice }, this.deps.config);
12884
- return signer.execute(calls);
12728
+ if (o.standard === "ERC1155") {
12729
+ return this.m1155.fulfillOrder(signer, {
12730
+ orderHash: orderRef,
12731
+ paymentToken: o.paymentToken,
12732
+ totalPrice,
12733
+ quantity
12734
+ });
12735
+ }
12736
+ return this.m721.fulfillOrder(signer, {
12737
+ orderHash: orderRef,
12738
+ paymentToken: o.paymentToken,
12739
+ totalPrice
12740
+ });
12885
12741
  }
12886
12742
  async cancelOrder(signer, orderRef) {
12887
12743
  const o = await this.deps.resolveOrder(orderRef);
12888
- const typedData = o.standard === "ERC1155" ? buildCancel1155TypedData(orderRef, signer.address, this.deps.config) : buildCancelTypedData(orderRef, signer.address, this.deps.config);
12889
- const signature = await signer.signTypedData(typedData);
12890
- const calls = o.standard === "ERC1155" ? buildCancel1155Calls({ orderHash: orderRef, offerer: signer.address, signature }, this.deps.config) : buildCancelCalls({ orderHash: orderRef, offerer: signer.address, signature }, this.deps.config);
12891
- return signer.execute(calls);
12744
+ if (o.standard === "ERC1155") {
12745
+ return this.m1155.cancelOrder(signer, { orderHash: orderRef });
12746
+ }
12747
+ return this.m721.cancelOrder(signer, { orderHash: orderRef });
12892
12748
  }
12893
12749
  async registerOrder(signer, p) {
12894
12750
  const standard = await this.deps.resolveStandard(p.asset.contract);
12895
- const paymentTokenAddress = resolveToken(p.paymentToken).address;
12751
+ const token = resolveToken(p.paymentToken);
12752
+ const humanPrice = formatAmount(p.amount, token.decimals);
12753
+ const durationSeconds = this.durationSeconds(p.endTime);
12896
12754
  const royaltyMaxBps = String(p.royaltyMaxBps);
12897
- const startTime = Math.floor(Date.now() / 1e3) + START_TIME_BUFFER_SECS;
12898
- const endTime = p.endTime && p.endTime > 0 ? p.endTime : startTime + NO_EXPIRY_SECONDS;
12899
12755
  const quantity = p.quantity ?? "1";
12900
- const marketplace = standard === "ERC1155" ? this.deps.config.marketplace1155Contract : this.deps.config.marketplaceContract;
12901
- const counter = String(await this.readCounter(marketplace, signer.address));
12902
- let typedData;
12903
- let buildCalls;
12756
+ let txHash;
12904
12757
  if (standard === "ERC1155") {
12905
- const built = (p.side === "listing" ? buildListing1155Order : buildOffer1155Order)(
12906
- {
12907
- offerer: signer.address,
12758
+ if (p.side === "listing") {
12759
+ const res = await this.m1155.createListing(signer, {
12908
12760
  nftContract: p.asset.contract,
12909
12761
  tokenId: p.asset.tokenId,
12910
- quantity,
12911
- priceWeiPerUnit: p.amount,
12912
- paymentTokenAddress,
12913
- royaltyMaxBps,
12914
- startTime,
12915
- endTime,
12916
- salt: p.salt,
12917
- counter
12918
- },
12919
- this.deps.config
12920
- );
12921
- typedData = built.typedData;
12922
- const approval = p.side === "listing" ? await this.approval1155ForListing(signer.address, p.asset.contract) : this.approvalForErc20(paymentTokenAddress, (BigInt(p.amount) * BigInt(quantity)).toString(), marketplace);
12923
- buildCalls = (sig) => buildRegister1155Calls({ orderParams: built.orderParams, signature: sig, ...approval }, this.deps.config);
12924
- } else {
12925
- const built = (p.side === "listing" ? buildListingOrder : buildOfferOrder)(
12926
- {
12927
- offerer: signer.address,
12762
+ amount: quantity,
12763
+ pricePerUnit: humanPrice,
12764
+ currency: p.paymentToken,
12765
+ durationSeconds,
12766
+ royaltyMaxBps
12767
+ });
12768
+ txHash = res.txHash;
12769
+ } else {
12770
+ const totalHuman = formatAmount((BigInt(p.amount) * BigInt(quantity)).toString(), token.decimals);
12771
+ const res = await this.m1155.makeOffer(signer, {
12928
12772
  nftContract: p.asset.contract,
12929
12773
  tokenId: p.asset.tokenId,
12930
- priceWei: p.amount,
12931
- paymentTokenAddress,
12932
- royaltyMaxBps,
12933
- startTime,
12934
- endTime,
12935
- salt: p.salt,
12936
- counter
12937
- },
12938
- this.deps.config
12939
- );
12940
- typedData = built.typedData;
12941
- const approval = p.side === "listing" ? await this.approval721ForListing(signer.address, p.asset.contract, p.asset.tokenId) : this.approvalForErc20(paymentTokenAddress, p.amount, marketplace);
12942
- buildCalls = (sig) => buildRegisterCalls({ orderParams: built.orderParams, signature: sig, ...approval }, this.deps.config);
12774
+ amount: quantity,
12775
+ price: totalHuman,
12776
+ currency: p.paymentToken,
12777
+ durationSeconds,
12778
+ royaltyMaxBps
12779
+ });
12780
+ txHash = res.txHash;
12781
+ }
12782
+ } else {
12783
+ const params = {
12784
+ nftContract: p.asset.contract,
12785
+ tokenId: p.asset.tokenId,
12786
+ price: humanPrice,
12787
+ currency: p.paymentToken,
12788
+ durationSeconds,
12789
+ royaltyMaxBps
12790
+ };
12791
+ const res = p.side === "listing" ? await this.m721.createListing(signer, params) : await this.m721.makeOffer(signer, params);
12792
+ txHash = res.txHash;
12943
12793
  }
12944
- const signature = await signer.signTypedData(typedData);
12945
- const { txHash } = await signer.execute(buildCalls(signature));
12946
12794
  const orderRef = await this.orderRefFromReceipt(txHash);
12947
12795
  return { txHash, orderRef };
12948
12796
  }
12949
- // ─── reads (all on deps.provider) ─────────────────────────────────────────
12950
- async readCounter(marketplace, address) {
12951
- const res = await this.deps.provider.callContract({
12952
- contractAddress: marketplace,
12953
- entrypoint: "get_counter",
12954
- calldata: [address]
12955
- });
12956
- return BigInt(res[0] ?? "0");
12957
- }
12958
- /** 721 listing approval: `get_approved(tokenId) == marketplace` ⇒ no approve. */
12959
- async approval721ForListing(_owner, nftContract, tokenId) {
12960
- const id = cairo.uint256(tokenId);
12961
- const approve = {
12962
- contractAddress: nftContract,
12963
- entrypoint: "approve",
12964
- calldata: [this.deps.config.marketplaceContract, id.low.toString(), id.high.toString()]
12965
- };
12966
- let approved = false;
12967
- try {
12968
- const res = await this.deps.provider.callContract({
12969
- contractAddress: nftContract,
12970
- entrypoint: "get_approved",
12971
- calldata: [id.low.toString(), id.high.toString()]
12972
- });
12973
- approved = BigInt(res[0]).toString() === BigInt(this.deps.config.marketplaceContract).toString();
12974
- } catch {
12975
- }
12976
- return { approvalNeeded: !approved, approve };
12977
- }
12978
- /** 1155 listing approval: `is_approved_for_all(owner, marketplace)`. */
12979
- async approval1155ForListing(owner, nftContract) {
12980
- const approve = {
12981
- contractAddress: nftContract,
12982
- entrypoint: "set_approval_for_all",
12983
- calldata: [this.deps.config.marketplace1155Contract, "1"]
12984
- };
12985
- let approved = false;
12986
- try {
12987
- const res = await this.deps.provider.callContract({
12988
- contractAddress: nftContract,
12989
- entrypoint: "is_approved_for_all",
12990
- calldata: [owner, this.deps.config.marketplace1155Contract]
12991
- });
12992
- approved = BigInt(res[0]) === 1n;
12993
- } catch {
12994
- }
12995
- return { approvalNeeded: !approved, approve };
12996
- }
12997
- /** Offers always approve the ERC-20 spend (no read). */
12998
- approvalForErc20(token, amountWei, marketplace) {
12999
- const u = cairo.uint256(amountWei);
13000
- return {
13001
- approvalNeeded: true,
13002
- approve: {
13003
- contractAddress: token,
13004
- entrypoint: "approve",
13005
- calldata: [marketplace, u.low.toString(), u.high.toString()]
13006
- }
13007
- };
12797
+ durationSeconds(endTime) {
12798
+ if (!endTime) return NO_EXPIRY_SECONDS;
12799
+ return Math.max(1, endTime - Math.floor(Date.now() / 1e3));
13008
12800
  }
13009
12801
  /** The canonical Starknet order id = the contract-emitted `OrderCreated`
13010
12802
  * hash (`keys[1]`), which is exactly what the indexer stores. */