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