@medialane/sdk 0.64.1 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evm/index.cjs +4 -3
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.d.cts +1 -1
- package/dist/evm/index.d.ts +1 -1
- package/dist/evm/index.js +4 -3
- package/dist/evm/index.js.map +1 -1
- package/dist/{index-DMNv-Oj0.d.ts → index-C2EaTkzk.d.cts} +60 -67
- package/dist/{index-_q2B0g3M.d.cts → index-DjJ4k6p_.d.ts} +60 -67
- package/dist/index.cjs +145 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -7
- package/dist/index.d.ts +16 -7
- package/dist/index.js +146 -142
- package/dist/index.js.map +1 -1
- package/dist/solana/index.cjs +4 -3
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +1 -1
- package/dist/solana/index.d.ts +1 -1
- package/dist/solana/index.js +4 -3
- package/dist/solana/index.js.map +1 -1
- package/dist/starknet/index.cjs +256 -261
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +2 -2
- package/dist/starknet/index.d.ts +2 -2
- package/dist/starknet/index.js +257 -262
- package/dist/starknet/index.js.map +1 -1
- package/dist/stellar/index.cjs +4 -3
- package/dist/stellar/index.cjs.map +1 -1
- package/dist/stellar/index.d.cts +1 -1
- package/dist/stellar/index.d.ts +1 -1
- package/dist/stellar/index.js +4 -3
- package/dist/stellar/index.js.map +1 -1
- package/dist/{types-Bx3ax9lW.d.cts → types-CIR6H6ul.d.cts} +1 -0
- package/dist/{types-Bx3ax9lW.d.ts → types-CIR6H6ul.d.ts} +1 -0
- package/package.json +3 -2
package/dist/starknet/index.cjs
CHANGED
|
@@ -37,9 +37,10 @@ var COORDINATES = {
|
|
|
37
37
|
creatorCoinFactoryClassHash: "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55",
|
|
38
38
|
creatorCoinStartBlock: 10474544,
|
|
39
39
|
ekuboCore: "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b",
|
|
40
|
-
ipTicketsFactory: "
|
|
41
|
-
ipTicketCollectionClassHash: "
|
|
42
|
-
|
|
40
|
+
ipTicketsFactory: "0x059802639b41e9c6449c3d557703e610ef639a91866dc1dd44216f9f37111ac5",
|
|
41
|
+
ipTicketCollectionClassHash: "0x047bd108881457c4f4db6c64671c1dd402f4d8c79fd9182f03a2dd841335a34b",
|
|
42
|
+
ipTicketsFactoryClassHash: "0x04a739ac3a673ebd0db96bb24475600797c3ed34827e79517f9b2b1640276e6a",
|
|
43
|
+
ipTicketsStartBlock: 11836622,
|
|
43
44
|
ipClubRegistry: "0x00e189c619b6bb07d78973a149641c59c37eb0716f8584d7520bce12d303eede",
|
|
44
45
|
ipClubNftClassHash: "0x02bc9b20cca21b04245e9215bf7121f4d7295b195890e449b472b573017fb889",
|
|
45
46
|
ipClubStartBlock: 11404776,
|
|
@@ -855,6 +856,172 @@ var ApiClient = class {
|
|
|
855
856
|
}
|
|
856
857
|
};
|
|
857
858
|
|
|
859
|
+
// src/constants.ts
|
|
860
|
+
var SN = getCoordinates("STARKNET");
|
|
861
|
+
SN.marketplace721;
|
|
862
|
+
SN.marketplace721ClassHash;
|
|
863
|
+
SN.marketplace721StartBlock;
|
|
864
|
+
SN.marketplace1155;
|
|
865
|
+
SN.marketplace1155ClassHash;
|
|
866
|
+
SN.marketplace1155StartBlock;
|
|
867
|
+
SN.collection721;
|
|
868
|
+
SN.collection721StartBlock;
|
|
869
|
+
SN.ipNftClassHash;
|
|
870
|
+
SN.ipCollectionClassHash;
|
|
871
|
+
SN.collection1155;
|
|
872
|
+
SN.collection1155FactoryClassHash;
|
|
873
|
+
SN.collection1155ClassHash;
|
|
874
|
+
SN.collection1155StartBlock;
|
|
875
|
+
SN.popFactory;
|
|
876
|
+
SN.popCollectionClassHash;
|
|
877
|
+
SN.dropFactory;
|
|
878
|
+
SN.dropCollectionClassHash;
|
|
879
|
+
SN.nftComments;
|
|
880
|
+
SN.ipTicketsFactory;
|
|
881
|
+
SN.ipTicketCollectionClassHash;
|
|
882
|
+
SN.ipClubRegistry;
|
|
883
|
+
SN.ipClubNftClassHash;
|
|
884
|
+
SN.ipClubFactory;
|
|
885
|
+
SN.ipClubCollectionClassHash;
|
|
886
|
+
SN.ipSponsorship;
|
|
887
|
+
SN.ipSponsorshipLicense;
|
|
888
|
+
SN.creatorCoinFactory;
|
|
889
|
+
SN.creatorCoinEkuboLauncher;
|
|
890
|
+
SN.creatorCoinClassHash;
|
|
891
|
+
SN.creatorCoinFactoryClassHash;
|
|
892
|
+
SN.creatorCoinStartBlock;
|
|
893
|
+
SN.ekuboCore;
|
|
894
|
+
var SUPPORTED_TOKENS = [
|
|
895
|
+
{
|
|
896
|
+
// Circle-native USDC on Starknet (canonical)
|
|
897
|
+
symbol: "USDC",
|
|
898
|
+
address: "0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb",
|
|
899
|
+
decimals: 6,
|
|
900
|
+
listable: true
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
symbol: "USDT",
|
|
904
|
+
address: "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",
|
|
905
|
+
decimals: 6,
|
|
906
|
+
listable: true
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
symbol: "ETH",
|
|
910
|
+
address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
911
|
+
decimals: 18,
|
|
912
|
+
listable: true
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
symbol: "STRK",
|
|
916
|
+
address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
917
|
+
decimals: 18,
|
|
918
|
+
listable: true
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
symbol: "WBTC",
|
|
922
|
+
address: "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
923
|
+
decimals: 8,
|
|
924
|
+
listable: true
|
|
925
|
+
}
|
|
926
|
+
];
|
|
927
|
+
|
|
928
|
+
// src/starknet/marketplace/errors.ts
|
|
929
|
+
var MedialaneError = class extends Error {
|
|
930
|
+
constructor(message, code = "UNKNOWN", cause) {
|
|
931
|
+
super(message);
|
|
932
|
+
this.code = code;
|
|
933
|
+
this.cause = cause;
|
|
934
|
+
this.name = "MedialaneError";
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
// src/utils/rpc.ts
|
|
939
|
+
var PUBLIC_RPC_FALLBACKS = [
|
|
940
|
+
"https://rpc.starknet.lava.build"
|
|
941
|
+
];
|
|
942
|
+
var TRANSIENT_BODY_RE = /"code"\s*:\s*-32001|"code"\s*:\s*-32603|unable to complete|rate.?limit|too many|throttl|exceed.*quota|temporarily unavailable|service unavailable|overload|gateway.*time|upstream.*time|backend.*error/i;
|
|
943
|
+
function isTransientRpcError(input) {
|
|
944
|
+
const { status, body } = input;
|
|
945
|
+
if (typeof status === "number" && (status === 429 || status >= 500)) return true;
|
|
946
|
+
if (body == null) return false;
|
|
947
|
+
if (typeof body === "object") {
|
|
948
|
+
const err = body.error;
|
|
949
|
+
if (!err || typeof err !== "object") return false;
|
|
950
|
+
const code = err.code;
|
|
951
|
+
if (typeof code === "number") {
|
|
952
|
+
if (code === 429) return true;
|
|
953
|
+
if (code >= -32099 && code <= -32e3) return true;
|
|
954
|
+
if (code === -32603) return true;
|
|
955
|
+
}
|
|
956
|
+
const message = err.message;
|
|
957
|
+
return typeof message === "string" ? TRANSIENT_BODY_RE.test(message) : false;
|
|
958
|
+
}
|
|
959
|
+
return TRANSIENT_BODY_RE.test(String(body));
|
|
960
|
+
}
|
|
961
|
+
function createFailoverFetch(urls, options = {}) {
|
|
962
|
+
const endpoints = urls.filter((u) => Boolean(u));
|
|
963
|
+
if (endpoints.length === 0) {
|
|
964
|
+
throw new Error("createFailoverFetch: at least one RPC URL is required");
|
|
965
|
+
}
|
|
966
|
+
const doFetch = options.baseFetch ?? fetch;
|
|
967
|
+
const failover = async (_input, init) => {
|
|
968
|
+
let lastError;
|
|
969
|
+
for (let i = 0; i < endpoints.length; i++) {
|
|
970
|
+
const url = endpoints[i];
|
|
971
|
+
const isLast = i === endpoints.length - 1;
|
|
972
|
+
try {
|
|
973
|
+
const res = await doFetch(url, init);
|
|
974
|
+
const text = await res.text();
|
|
975
|
+
const rebuilt = () => new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
976
|
+
if (isLast || !isTransientRpcError({ status: res.status, body: text })) {
|
|
977
|
+
return rebuilt();
|
|
978
|
+
}
|
|
979
|
+
options.onFailover?.({ url, status: res.status });
|
|
980
|
+
} catch (err) {
|
|
981
|
+
lastError = err;
|
|
982
|
+
if (isLast) throw err;
|
|
983
|
+
options.onFailover?.({ url, error: err });
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
throw lastError ?? new Error("createFailoverFetch: all endpoints failed");
|
|
987
|
+
};
|
|
988
|
+
return failover;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// src/starknet/marketplace/utils.ts
|
|
992
|
+
var START_TIME_BUFFER_SECS = 30;
|
|
993
|
+
function newContract(abi, address, providerOrAccount) {
|
|
994
|
+
const C = starknet.Contract;
|
|
995
|
+
return C.length === 1 ? new starknet.Contract({ abi, address, providerOrAccount }) : new starknet.Contract(
|
|
996
|
+
abi,
|
|
997
|
+
address,
|
|
998
|
+
providerOrAccount
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
function getChainId(config) {
|
|
1002
|
+
if (config.chain !== "STARKNET") {
|
|
1003
|
+
throw new Error(`SNIP-12 signing is Starknet-only; got chain "${config.chain}"`);
|
|
1004
|
+
}
|
|
1005
|
+
return starknet.constants.StarknetChainId.SN_MAIN;
|
|
1006
|
+
}
|
|
1007
|
+
function resolveToken(currency) {
|
|
1008
|
+
const token = SUPPORTED_TOKENS.find(
|
|
1009
|
+
(t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
|
|
1010
|
+
);
|
|
1011
|
+
if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
|
|
1012
|
+
return token;
|
|
1013
|
+
}
|
|
1014
|
+
var _providerCache = /* @__PURE__ */ new WeakMap();
|
|
1015
|
+
function getProvider(config) {
|
|
1016
|
+
let p = _providerCache.get(config);
|
|
1017
|
+
if (!p) {
|
|
1018
|
+
const urls = Array.from(/* @__PURE__ */ new Set([config.rpcUrl, ...PUBLIC_RPC_FALLBACKS]));
|
|
1019
|
+
p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch: createFailoverFetch(urls) });
|
|
1020
|
+
_providerCache.set(config, p);
|
|
1021
|
+
}
|
|
1022
|
+
return p;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
858
1025
|
// src/starknet/abis/ipMarketplace.ts
|
|
859
1026
|
var IPMarketplaceABI = [
|
|
860
1027
|
{
|
|
@@ -5353,12 +5520,8 @@ var IPTicketCollectionABI = [
|
|
|
5353
5520
|
},
|
|
5354
5521
|
{
|
|
5355
5522
|
"type": "struct",
|
|
5356
|
-
"name": "ip_ticket::types::
|
|
5523
|
+
"name": "ip_ticket::types::Ticket",
|
|
5357
5524
|
"members": [
|
|
5358
|
-
{
|
|
5359
|
-
"name": "creator",
|
|
5360
|
-
"type": "core::starknet::contract_address::ContractAddress"
|
|
5361
|
-
},
|
|
5362
5525
|
{
|
|
5363
5526
|
"name": "max_supply",
|
|
5364
5527
|
"type": "core::integer::u256"
|
|
@@ -5382,10 +5545,6 @@ var IPTicketCollectionABI = [
|
|
|
5382
5545
|
{
|
|
5383
5546
|
"name": "metadata_uri",
|
|
5384
5547
|
"type": "core::byte_array::ByteArray"
|
|
5385
|
-
},
|
|
5386
|
-
{
|
|
5387
|
-
"name": "active",
|
|
5388
|
-
"type": "core::bool"
|
|
5389
5548
|
}
|
|
5390
5549
|
]
|
|
5391
5550
|
},
|
|
@@ -5395,7 +5554,7 @@ var IPTicketCollectionABI = [
|
|
|
5395
5554
|
"items": [
|
|
5396
5555
|
{
|
|
5397
5556
|
"type": "function",
|
|
5398
|
-
"name": "
|
|
5557
|
+
"name": "create_ticket",
|
|
5399
5558
|
"inputs": [
|
|
5400
5559
|
{
|
|
5401
5560
|
"name": "max_supply",
|
|
@@ -5447,52 +5606,69 @@ var IPTicketCollectionABI = [
|
|
|
5447
5606
|
},
|
|
5448
5607
|
{
|
|
5449
5608
|
"type": "function",
|
|
5450
|
-
"name": "
|
|
5609
|
+
"name": "is_valid",
|
|
5451
5610
|
"inputs": [
|
|
5452
5611
|
{
|
|
5453
5612
|
"name": "token_id",
|
|
5454
5613
|
"type": "core::integer::u256"
|
|
5455
5614
|
},
|
|
5456
5615
|
{
|
|
5457
|
-
"name": "
|
|
5616
|
+
"name": "holder",
|
|
5617
|
+
"type": "core::starknet::contract_address::ContractAddress"
|
|
5618
|
+
}
|
|
5619
|
+
],
|
|
5620
|
+
"outputs": [
|
|
5621
|
+
{
|
|
5458
5622
|
"type": "core::bool"
|
|
5459
5623
|
}
|
|
5460
5624
|
],
|
|
5461
|
-
"
|
|
5462
|
-
"state_mutability": "external"
|
|
5625
|
+
"state_mutability": "view"
|
|
5463
5626
|
},
|
|
5464
5627
|
{
|
|
5465
5628
|
"type": "function",
|
|
5466
|
-
"name": "
|
|
5629
|
+
"name": "get_ticket",
|
|
5467
5630
|
"inputs": [
|
|
5468
5631
|
{
|
|
5469
5632
|
"name": "token_id",
|
|
5470
5633
|
"type": "core::integer::u256"
|
|
5471
|
-
}
|
|
5634
|
+
}
|
|
5635
|
+
],
|
|
5636
|
+
"outputs": [
|
|
5472
5637
|
{
|
|
5473
|
-
"
|
|
5474
|
-
"type": "core::starknet::contract_address::ContractAddress"
|
|
5638
|
+
"type": "ip_ticket::types::Ticket"
|
|
5475
5639
|
}
|
|
5476
5640
|
],
|
|
5641
|
+
"state_mutability": "view"
|
|
5642
|
+
},
|
|
5643
|
+
{
|
|
5644
|
+
"type": "function",
|
|
5645
|
+
"name": "name",
|
|
5646
|
+
"inputs": [],
|
|
5477
5647
|
"outputs": [
|
|
5478
5648
|
{
|
|
5479
|
-
"type": "core::
|
|
5649
|
+
"type": "core::byte_array::ByteArray"
|
|
5480
5650
|
}
|
|
5481
5651
|
],
|
|
5482
5652
|
"state_mutability": "view"
|
|
5483
5653
|
},
|
|
5484
5654
|
{
|
|
5485
5655
|
"type": "function",
|
|
5486
|
-
"name": "
|
|
5487
|
-
"inputs": [
|
|
5656
|
+
"name": "symbol",
|
|
5657
|
+
"inputs": [],
|
|
5658
|
+
"outputs": [
|
|
5488
5659
|
{
|
|
5489
|
-
"
|
|
5490
|
-
"type": "core::integer::u256"
|
|
5660
|
+
"type": "core::byte_array::ByteArray"
|
|
5491
5661
|
}
|
|
5492
5662
|
],
|
|
5663
|
+
"state_mutability": "view"
|
|
5664
|
+
},
|
|
5665
|
+
{
|
|
5666
|
+
"type": "function",
|
|
5667
|
+
"name": "base_uri",
|
|
5668
|
+
"inputs": [],
|
|
5493
5669
|
"outputs": [
|
|
5494
5670
|
{
|
|
5495
|
-
"type": "
|
|
5671
|
+
"type": "core::byte_array::ByteArray"
|
|
5496
5672
|
}
|
|
5497
5673
|
],
|
|
5498
5674
|
"state_mutability": "view"
|
|
@@ -5965,6 +6141,10 @@ var IPTicketCollectionABI = [
|
|
|
5965
6141
|
"name": "symbol",
|
|
5966
6142
|
"type": "core::byte_array::ByteArray"
|
|
5967
6143
|
},
|
|
6144
|
+
{
|
|
6145
|
+
"name": "base_uri",
|
|
6146
|
+
"type": "core::byte_array::ByteArray"
|
|
6147
|
+
},
|
|
5968
6148
|
{
|
|
5969
6149
|
"name": "owner",
|
|
5970
6150
|
"type": "core::starknet::contract_address::ContractAddress"
|
|
@@ -6160,7 +6340,7 @@ var IPTicketCollectionABI = [
|
|
|
6160
6340
|
},
|
|
6161
6341
|
{
|
|
6162
6342
|
"type": "event",
|
|
6163
|
-
"name": "ip_ticket::IPTicketCollection::IPTicketCollection::
|
|
6343
|
+
"name": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketCreated",
|
|
6164
6344
|
"kind": "struct",
|
|
6165
6345
|
"members": [
|
|
6166
6346
|
{
|
|
@@ -6195,23 +6375,6 @@ var IPTicketCollectionABI = [
|
|
|
6195
6375
|
}
|
|
6196
6376
|
]
|
|
6197
6377
|
},
|
|
6198
|
-
{
|
|
6199
|
-
"type": "event",
|
|
6200
|
-
"name": "ip_ticket::IPTicketCollection::IPTicketCollection::EventPaused",
|
|
6201
|
-
"kind": "struct",
|
|
6202
|
-
"members": [
|
|
6203
|
-
{
|
|
6204
|
-
"name": "token_id",
|
|
6205
|
-
"type": "core::integer::u256",
|
|
6206
|
-
"kind": "key"
|
|
6207
|
-
},
|
|
6208
|
-
{
|
|
6209
|
-
"name": "active",
|
|
6210
|
-
"type": "core::bool",
|
|
6211
|
-
"kind": "data"
|
|
6212
|
-
}
|
|
6213
|
-
]
|
|
6214
|
-
},
|
|
6215
6378
|
{
|
|
6216
6379
|
"type": "event",
|
|
6217
6380
|
"name": "ip_ticket::IPTicketCollection::IPTicketCollection::Event",
|
|
@@ -6233,13 +6396,8 @@ var IPTicketCollectionABI = [
|
|
|
6233
6396
|
"kind": "flat"
|
|
6234
6397
|
},
|
|
6235
6398
|
{
|
|
6236
|
-
"name": "
|
|
6237
|
-
"type": "ip_ticket::IPTicketCollection::IPTicketCollection::
|
|
6238
|
-
"kind": "nested"
|
|
6239
|
-
},
|
|
6240
|
-
{
|
|
6241
|
-
"name": "EventPaused",
|
|
6242
|
-
"type": "ip_ticket::IPTicketCollection::IPTicketCollection::EventPaused",
|
|
6399
|
+
"name": "TicketCreated",
|
|
6400
|
+
"type": "ip_ticket::IPTicketCollection::IPTicketCollection::TicketCreated",
|
|
6243
6401
|
"kind": "nested"
|
|
6244
6402
|
}
|
|
6245
6403
|
]
|
|
@@ -6308,6 +6466,10 @@ var IPTicketCollectionFactoryABI = [
|
|
|
6308
6466
|
{
|
|
6309
6467
|
"name": "symbol",
|
|
6310
6468
|
"type": "core::byte_array::ByteArray"
|
|
6469
|
+
},
|
|
6470
|
+
{
|
|
6471
|
+
"name": "base_uri",
|
|
6472
|
+
"type": "core::byte_array::ByteArray"
|
|
6311
6473
|
}
|
|
6312
6474
|
],
|
|
6313
6475
|
"outputs": [
|
|
@@ -10890,7 +11052,7 @@ var PopService = class {
|
|
|
10890
11052
|
this.factoryAddress = getStarknetCoordinates(config.chain).popFactory;
|
|
10891
11053
|
}
|
|
10892
11054
|
_collection(address, account) {
|
|
10893
|
-
return
|
|
11055
|
+
return newContract(POPCollectionABI, normalizeAddress("STARKNET", address), account);
|
|
10894
11056
|
}
|
|
10895
11057
|
async claim(account, collectionAddress) {
|
|
10896
11058
|
const call = this._collection(collectionAddress, account).populate("claim", []);
|
|
@@ -10939,7 +11101,7 @@ var PopService = class {
|
|
|
10939
11101
|
return { txHash: res.transaction_hash };
|
|
10940
11102
|
}
|
|
10941
11103
|
async createCollection(account, params) {
|
|
10942
|
-
const factory =
|
|
11104
|
+
const factory = newContract(POPFactoryABI, this.factoryAddress, account);
|
|
10943
11105
|
const call = factory.populate("create_collection", [
|
|
10944
11106
|
params.name,
|
|
10945
11107
|
params.symbol,
|
|
@@ -10981,7 +11143,7 @@ var DropService = class {
|
|
|
10981
11143
|
this.config = config;
|
|
10982
11144
|
}
|
|
10983
11145
|
_collection(address, account) {
|
|
10984
|
-
return
|
|
11146
|
+
return newContract(DropCollectionABI, normalizeAddress("STARKNET", address), account);
|
|
10985
11147
|
}
|
|
10986
11148
|
async claim(account, collectionAddress, quantity = 1) {
|
|
10987
11149
|
const collection = this._collection(collectionAddress, account);
|
|
@@ -11045,7 +11207,7 @@ var DropService = class {
|
|
|
11045
11207
|
return { txHash: res.transaction_hash };
|
|
11046
11208
|
}
|
|
11047
11209
|
async createDrop(account, params) {
|
|
11048
|
-
const factory =
|
|
11210
|
+
const factory = newContract(DropFactoryABI, this.factoryAddress, account);
|
|
11049
11211
|
const call = factory.populate("create_drop", [
|
|
11050
11212
|
params.name,
|
|
11051
11213
|
params.symbol,
|
|
@@ -11057,19 +11219,21 @@ var DropService = class {
|
|
|
11057
11219
|
return { txHash: res.transaction_hash };
|
|
11058
11220
|
}
|
|
11059
11221
|
};
|
|
11222
|
+
|
|
11223
|
+
// src/starknet/services/erc1155collection.ts
|
|
11060
11224
|
var ERC1155CollectionService = class {
|
|
11061
11225
|
constructor(config) {
|
|
11062
11226
|
this.factoryAddress = config.collection1155Contract ?? getStarknetCoordinates(config.chain).collection1155;
|
|
11063
11227
|
}
|
|
11064
11228
|
_factory(account) {
|
|
11065
|
-
return
|
|
11229
|
+
return newContract(
|
|
11066
11230
|
IPCollection1155FactoryABI,
|
|
11067
11231
|
normalizeAddress("STARKNET", this.factoryAddress),
|
|
11068
11232
|
account
|
|
11069
11233
|
);
|
|
11070
11234
|
}
|
|
11071
11235
|
_collection(address, account) {
|
|
11072
|
-
return
|
|
11236
|
+
return newContract(
|
|
11073
11237
|
IPCollection1155ABI,
|
|
11074
11238
|
normalizeAddress("STARKNET", address),
|
|
11075
11239
|
account
|
|
@@ -11178,75 +11342,6 @@ var ERC1155CollectionService = class {
|
|
|
11178
11342
|
}
|
|
11179
11343
|
};
|
|
11180
11344
|
|
|
11181
|
-
// src/constants.ts
|
|
11182
|
-
var SN = getCoordinates("STARKNET");
|
|
11183
|
-
SN.marketplace721;
|
|
11184
|
-
SN.marketplace721ClassHash;
|
|
11185
|
-
SN.marketplace721StartBlock;
|
|
11186
|
-
SN.marketplace1155;
|
|
11187
|
-
SN.marketplace1155ClassHash;
|
|
11188
|
-
SN.marketplace1155StartBlock;
|
|
11189
|
-
SN.collection721;
|
|
11190
|
-
SN.collection721StartBlock;
|
|
11191
|
-
SN.ipNftClassHash;
|
|
11192
|
-
SN.ipCollectionClassHash;
|
|
11193
|
-
SN.collection1155;
|
|
11194
|
-
SN.collection1155FactoryClassHash;
|
|
11195
|
-
SN.collection1155ClassHash;
|
|
11196
|
-
SN.collection1155StartBlock;
|
|
11197
|
-
SN.popFactory;
|
|
11198
|
-
SN.popCollectionClassHash;
|
|
11199
|
-
SN.dropFactory;
|
|
11200
|
-
SN.dropCollectionClassHash;
|
|
11201
|
-
SN.nftComments;
|
|
11202
|
-
SN.ipTicketsFactory;
|
|
11203
|
-
SN.ipTicketCollectionClassHash;
|
|
11204
|
-
SN.ipClubRegistry;
|
|
11205
|
-
SN.ipClubNftClassHash;
|
|
11206
|
-
SN.ipClubFactory;
|
|
11207
|
-
SN.ipClubCollectionClassHash;
|
|
11208
|
-
SN.ipSponsorship;
|
|
11209
|
-
SN.ipSponsorshipLicense;
|
|
11210
|
-
SN.creatorCoinFactory;
|
|
11211
|
-
SN.creatorCoinEkuboLauncher;
|
|
11212
|
-
SN.creatorCoinClassHash;
|
|
11213
|
-
SN.creatorCoinFactoryClassHash;
|
|
11214
|
-
SN.creatorCoinStartBlock;
|
|
11215
|
-
SN.ekuboCore;
|
|
11216
|
-
var SUPPORTED_TOKENS = [
|
|
11217
|
-
{
|
|
11218
|
-
// Circle-native USDC on Starknet (canonical)
|
|
11219
|
-
symbol: "USDC",
|
|
11220
|
-
address: "0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb",
|
|
11221
|
-
decimals: 6,
|
|
11222
|
-
listable: true
|
|
11223
|
-
},
|
|
11224
|
-
{
|
|
11225
|
-
symbol: "USDT",
|
|
11226
|
-
address: "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",
|
|
11227
|
-
decimals: 6,
|
|
11228
|
-
listable: true
|
|
11229
|
-
},
|
|
11230
|
-
{
|
|
11231
|
-
symbol: "ETH",
|
|
11232
|
-
address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
11233
|
-
decimals: 18,
|
|
11234
|
-
listable: true
|
|
11235
|
-
},
|
|
11236
|
-
{
|
|
11237
|
-
symbol: "STRK",
|
|
11238
|
-
address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
11239
|
-
decimals: 18,
|
|
11240
|
-
listable: true
|
|
11241
|
-
},
|
|
11242
|
-
{
|
|
11243
|
-
symbol: "WBTC",
|
|
11244
|
-
address: "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
11245
|
-
decimals: 8,
|
|
11246
|
-
listable: true
|
|
11247
|
-
}
|
|
11248
|
-
];
|
|
11249
|
-
|
|
11250
11345
|
// src/utils/token.ts
|
|
11251
11346
|
function getTokenByAddress(address) {
|
|
11252
11347
|
const lower = address.toLowerCase();
|
|
@@ -11291,7 +11386,7 @@ async function getCreatorCoinPrice(coinAddress, provider) {
|
|
|
11291
11386
|
var _factoryContract = null;
|
|
11292
11387
|
function factoryContract() {
|
|
11293
11388
|
if (!_factoryContract) {
|
|
11294
|
-
_factoryContract =
|
|
11389
|
+
_factoryContract = newContract(
|
|
11295
11390
|
CreatorCoinFactoryABI,
|
|
11296
11391
|
getStarknetCoordinates("STARKNET").creatorCoinFactory
|
|
11297
11392
|
);
|
|
@@ -11361,7 +11456,7 @@ var CreatorCoinService = class {
|
|
|
11361
11456
|
this.config = config;
|
|
11362
11457
|
}
|
|
11363
11458
|
_factory(account) {
|
|
11364
|
-
return
|
|
11459
|
+
return newContract(CreatorCoinFactoryABI, this.factoryAddress, account);
|
|
11365
11460
|
}
|
|
11366
11461
|
/** Deploy a fixed-supply CreatorCoin (full supply minted to the Factory). */
|
|
11367
11462
|
async createCreatorCoin(account, params) {
|
|
@@ -11396,26 +11491,34 @@ var TicketService = class {
|
|
|
11396
11491
|
_factory(account, factoryAddress) {
|
|
11397
11492
|
const address = factoryAddress ?? this.factoryAddress;
|
|
11398
11493
|
if (!address) throw new Error("IP-Tickets factory address not configured for this chain");
|
|
11399
|
-
return
|
|
11494
|
+
return newContract(IPTicketCollectionFactoryABI, normalizeAddress("STARKNET", address), account);
|
|
11400
11495
|
}
|
|
11401
11496
|
_collection(address, account) {
|
|
11402
|
-
return
|
|
11497
|
+
return newContract(IPTicketCollectionABI, normalizeAddress("STARKNET", address), account);
|
|
11403
11498
|
}
|
|
11404
11499
|
_collectionRead(address) {
|
|
11405
11500
|
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
11406
|
-
return
|
|
11501
|
+
return newContract(IPTicketCollectionABI, normalizeAddress("STARKNET", address), provider);
|
|
11407
11502
|
}
|
|
11408
|
-
/**
|
|
11503
|
+
/**
|
|
11504
|
+
* Deploys a new IPTicketCollection via the factory. Caller becomes owner.
|
|
11505
|
+
* `baseUri` is the collection-level metadata URI, embedded on-chain in the
|
|
11506
|
+
* deploy transaction.
|
|
11507
|
+
*/
|
|
11409
11508
|
async deployCollection(account, params) {
|
|
11410
|
-
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
11509
|
+
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
11510
|
+
params.name,
|
|
11511
|
+
params.symbol,
|
|
11512
|
+
params.baseUri
|
|
11513
|
+
]);
|
|
11411
11514
|
const res = await account.execute([call]);
|
|
11412
11515
|
return { txHash: res.transaction_hash };
|
|
11413
11516
|
}
|
|
11414
|
-
/** Owner-only. Creates a new
|
|
11415
|
-
async
|
|
11517
|
+
/** Owner-only. Creates a new ticket inside the caller's deployed collection. */
|
|
11518
|
+
async createTicket(account, params) {
|
|
11416
11519
|
const startTime = params.startTime != null ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.startTime) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
|
|
11417
11520
|
const endTime = params.endTime != null ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.endTime) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
|
|
11418
|
-
const call = this._collection(params.collection, account).populate("
|
|
11521
|
+
const call = this._collection(params.collection, account).populate("create_ticket", [
|
|
11419
11522
|
starknet.cairo.uint256(params.maxSupply),
|
|
11420
11523
|
startTime,
|
|
11421
11524
|
endTime,
|
|
@@ -11435,16 +11538,7 @@ var TicketService = class {
|
|
|
11435
11538
|
const res = await account.execute([call]);
|
|
11436
11539
|
return { txHash: res.transaction_hash };
|
|
11437
11540
|
}
|
|
11438
|
-
/**
|
|
11439
|
-
async pauseEvent(account, params) {
|
|
11440
|
-
const call = this._collection(params.collection, account).populate("pause_event", [
|
|
11441
|
-
starknet.cairo.uint256(params.tokenId),
|
|
11442
|
-
params.active
|
|
11443
|
-
]);
|
|
11444
|
-
const res = await account.execute([call]);
|
|
11445
|
-
return { txHash: res.transaction_hash };
|
|
11446
|
-
}
|
|
11447
|
-
/** Read — true if holder has balance > 0 and current time is within the event window. */
|
|
11541
|
+
/** Read — true if holder has balance > 0 and current time is within the ticket window. */
|
|
11448
11542
|
async isValid(params) {
|
|
11449
11543
|
const result = await this._collectionRead(params.collection).call("is_valid", [
|
|
11450
11544
|
starknet.cairo.uint256(params.tokenId),
|
|
@@ -11452,20 +11546,18 @@ var TicketService = class {
|
|
|
11452
11546
|
]);
|
|
11453
11547
|
return Boolean(result);
|
|
11454
11548
|
}
|
|
11455
|
-
/** Read — returns the
|
|
11456
|
-
async
|
|
11457
|
-
const
|
|
11549
|
+
/** Read — returns the Ticket record for a token ID. */
|
|
11550
|
+
async getTicket(params) {
|
|
11551
|
+
const t = await this._collectionRead(params.collection).call("get_ticket", [
|
|
11458
11552
|
starknet.cairo.uint256(params.tokenId)
|
|
11459
11553
|
]);
|
|
11460
11554
|
return {
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
metadataUri: ev.metadata_uri,
|
|
11468
|
-
active: Boolean(ev.active)
|
|
11555
|
+
maxSupply: BigInt(t.max_supply),
|
|
11556
|
+
minted: BigInt(t.minted),
|
|
11557
|
+
startTime: t.start_time?.variant === "Some" ? Number(t.start_time.values[0] ?? t.start_time.value) : null,
|
|
11558
|
+
endTime: t.end_time?.variant === "Some" ? Number(t.end_time.values[0] ?? t.end_time.value) : null,
|
|
11559
|
+
royaltyBps: Number(t.royalty_bps),
|
|
11560
|
+
metadataUri: t.metadata_uri
|
|
11469
11561
|
};
|
|
11470
11562
|
}
|
|
11471
11563
|
};
|
|
@@ -11478,15 +11570,15 @@ var ClubService = class {
|
|
|
11478
11570
|
_registry(account, registryAddress) {
|
|
11479
11571
|
const address = registryAddress ?? this.registryAddress;
|
|
11480
11572
|
if (!address) throw new Error("IP-Club registry address not configured for this chain");
|
|
11481
|
-
return
|
|
11573
|
+
return newContract(IPClubABI, normalizeAddress("STARKNET", address), account);
|
|
11482
11574
|
}
|
|
11483
11575
|
_factory(account, factoryAddress) {
|
|
11484
11576
|
const address = factoryAddress ?? this.factoryAddress;
|
|
11485
11577
|
if (!address) throw new Error("IP-Club factory address not configured for this chain");
|
|
11486
|
-
return
|
|
11578
|
+
return newContract(IPClubFactoryABI, normalizeAddress("STARKNET", address), account);
|
|
11487
11579
|
}
|
|
11488
11580
|
_collection(account, collectionAddress) {
|
|
11489
|
-
return
|
|
11581
|
+
return newContract(IPClubCollectionABI, normalizeAddress("STARKNET", collectionAddress), account);
|
|
11490
11582
|
}
|
|
11491
11583
|
/** Deploy a new per-creator membership ERC-721 collection via the factory. */
|
|
11492
11584
|
async deployClub(account, params) {
|
|
@@ -11598,7 +11690,7 @@ var SponsorshipService = class {
|
|
|
11598
11690
|
if (!resolved) {
|
|
11599
11691
|
throw new Error("IP-Sponsorship address not configured for this chain");
|
|
11600
11692
|
}
|
|
11601
|
-
return
|
|
11693
|
+
return newContract(IPSponsorshipABI, normalizeAddress("STARKNET", resolved), account);
|
|
11602
11694
|
}
|
|
11603
11695
|
/** The offer author must currently own (nftContract, tokenId) — enforced on-chain at create and accept. */
|
|
11604
11696
|
async createOffer(account, params) {
|
|
@@ -11667,7 +11759,7 @@ var SponsorshipService = class {
|
|
|
11667
11759
|
starknet.cairo.uint256(params.offerId),
|
|
11668
11760
|
params.sponsor
|
|
11669
11761
|
]);
|
|
11670
|
-
const receipt =
|
|
11762
|
+
const receipt = newContract(IPGenesisABI, normalizeAddress("STARKNET", receiptAddress), account);
|
|
11671
11763
|
const mintCall = receipt.populate("mint_item", [params.sponsor, params.licenseTermsUri]);
|
|
11672
11764
|
const res = await account.execute([acceptCall, mintCall]);
|
|
11673
11765
|
return { txHash: res.transaction_hash };
|
|
@@ -11687,7 +11779,7 @@ var SponsorshipService = class {
|
|
|
11687
11779
|
];
|
|
11688
11780
|
const receiptAddress = params.licenseReceiptAddress ?? this.licenseReceiptAddress;
|
|
11689
11781
|
if (receiptAddress && params.receiptTokenId != null) {
|
|
11690
|
-
const receipt =
|
|
11782
|
+
const receipt = newContract(IPGenesisABI, normalizeAddress("STARKNET", receiptAddress), account);
|
|
11691
11783
|
calls.push(receipt.populate("transfer_from", [account.address, params.to, starknet.cairo.uint256(params.receiptTokenId)]));
|
|
11692
11784
|
}
|
|
11693
11785
|
const res = await account.execute(calls);
|
|
@@ -11742,103 +11834,6 @@ var MedialaneClient = class {
|
|
|
11742
11834
|
}
|
|
11743
11835
|
};
|
|
11744
11836
|
|
|
11745
|
-
// src/starknet/marketplace/errors.ts
|
|
11746
|
-
var MedialaneError = class extends Error {
|
|
11747
|
-
constructor(message, code = "UNKNOWN", cause) {
|
|
11748
|
-
super(message);
|
|
11749
|
-
this.code = code;
|
|
11750
|
-
this.cause = cause;
|
|
11751
|
-
this.name = "MedialaneError";
|
|
11752
|
-
}
|
|
11753
|
-
};
|
|
11754
|
-
|
|
11755
|
-
// src/utils/rpc.ts
|
|
11756
|
-
var PUBLIC_RPC_FALLBACKS = [
|
|
11757
|
-
"https://rpc.starknet.lava.build"
|
|
11758
|
-
];
|
|
11759
|
-
var TRANSIENT_BODY_RE = /"code"\s*:\s*-32001|"code"\s*:\s*-32603|unable to complete|rate.?limit|too many|throttl|exceed.*quota|temporarily unavailable|service unavailable|overload|gateway.*time|upstream.*time|backend.*error/i;
|
|
11760
|
-
function isTransientRpcError(input) {
|
|
11761
|
-
const { status, body } = input;
|
|
11762
|
-
if (typeof status === "number" && (status === 429 || status >= 500)) return true;
|
|
11763
|
-
if (body == null) return false;
|
|
11764
|
-
if (typeof body === "object") {
|
|
11765
|
-
const err = body.error;
|
|
11766
|
-
if (!err || typeof err !== "object") return false;
|
|
11767
|
-
const code = err.code;
|
|
11768
|
-
if (typeof code === "number") {
|
|
11769
|
-
if (code === 429) return true;
|
|
11770
|
-
if (code >= -32099 && code <= -32e3) return true;
|
|
11771
|
-
if (code === -32603) return true;
|
|
11772
|
-
}
|
|
11773
|
-
const message = err.message;
|
|
11774
|
-
return typeof message === "string" ? TRANSIENT_BODY_RE.test(message) : false;
|
|
11775
|
-
}
|
|
11776
|
-
return TRANSIENT_BODY_RE.test(String(body));
|
|
11777
|
-
}
|
|
11778
|
-
function createFailoverFetch(urls, options = {}) {
|
|
11779
|
-
const endpoints = urls.filter((u) => Boolean(u));
|
|
11780
|
-
if (endpoints.length === 0) {
|
|
11781
|
-
throw new Error("createFailoverFetch: at least one RPC URL is required");
|
|
11782
|
-
}
|
|
11783
|
-
const doFetch = options.baseFetch ?? fetch;
|
|
11784
|
-
const failover = async (_input, init) => {
|
|
11785
|
-
let lastError;
|
|
11786
|
-
for (let i = 0; i < endpoints.length; i++) {
|
|
11787
|
-
const url = endpoints[i];
|
|
11788
|
-
const isLast = i === endpoints.length - 1;
|
|
11789
|
-
try {
|
|
11790
|
-
const res = await doFetch(url, init);
|
|
11791
|
-
const text = await res.text();
|
|
11792
|
-
const rebuilt = () => new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
11793
|
-
if (isLast || !isTransientRpcError({ status: res.status, body: text })) {
|
|
11794
|
-
return rebuilt();
|
|
11795
|
-
}
|
|
11796
|
-
options.onFailover?.({ url, status: res.status });
|
|
11797
|
-
} catch (err) {
|
|
11798
|
-
lastError = err;
|
|
11799
|
-
if (isLast) throw err;
|
|
11800
|
-
options.onFailover?.({ url, error: err });
|
|
11801
|
-
}
|
|
11802
|
-
}
|
|
11803
|
-
throw lastError ?? new Error("createFailoverFetch: all endpoints failed");
|
|
11804
|
-
};
|
|
11805
|
-
return failover;
|
|
11806
|
-
}
|
|
11807
|
-
|
|
11808
|
-
// src/starknet/marketplace/utils.ts
|
|
11809
|
-
var START_TIME_BUFFER_SECS = 30;
|
|
11810
|
-
function newContract(abi, address, providerOrAccount) {
|
|
11811
|
-
const C = starknet.Contract;
|
|
11812
|
-
return C.length === 1 ? new starknet.Contract({ abi, address, providerOrAccount }) : new starknet.Contract(
|
|
11813
|
-
abi,
|
|
11814
|
-
address,
|
|
11815
|
-
providerOrAccount
|
|
11816
|
-
);
|
|
11817
|
-
}
|
|
11818
|
-
function getChainId(config) {
|
|
11819
|
-
if (config.chain !== "STARKNET") {
|
|
11820
|
-
throw new Error(`SNIP-12 signing is Starknet-only; got chain "${config.chain}"`);
|
|
11821
|
-
}
|
|
11822
|
-
return starknet.constants.StarknetChainId.SN_MAIN;
|
|
11823
|
-
}
|
|
11824
|
-
function resolveToken(currency) {
|
|
11825
|
-
const token = SUPPORTED_TOKENS.find(
|
|
11826
|
-
(t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
|
|
11827
|
-
);
|
|
11828
|
-
if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
|
|
11829
|
-
return token;
|
|
11830
|
-
}
|
|
11831
|
-
var _providerCache = /* @__PURE__ */ new WeakMap();
|
|
11832
|
-
function getProvider(config) {
|
|
11833
|
-
let p = _providerCache.get(config);
|
|
11834
|
-
if (!p) {
|
|
11835
|
-
const urls = Array.from(/* @__PURE__ */ new Set([config.rpcUrl, ...PUBLIC_RPC_FALLBACKS]));
|
|
11836
|
-
p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch: createFailoverFetch(urls) });
|
|
11837
|
-
_providerCache.set(config, p);
|
|
11838
|
-
}
|
|
11839
|
-
return p;
|
|
11840
|
-
}
|
|
11841
|
-
|
|
11842
11837
|
// src/starknet/marketplace/orders.ts
|
|
11843
11838
|
var _contractCache = /* @__PURE__ */ new WeakMap();
|
|
11844
11839
|
function makeContract(config) {
|