@medialane/sdk 0.35.1 → 0.37.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/index.cjs +284 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +188 -123
- package/dist/index.d.ts +188 -123
- package/dist/index.js +272 -132
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -2,71 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var starknet = require('starknet');
|
|
5
|
+
var sha3_js = require('@noble/hashes/sha3.js');
|
|
6
|
+
var base = require('@scure/base');
|
|
5
7
|
|
|
6
8
|
// src/config.ts
|
|
7
9
|
|
|
8
|
-
// src/
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
39
|
-
decimals: 18,
|
|
40
|
-
listable: true
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
symbol: "STRK",
|
|
44
|
-
address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
45
|
-
decimals: 18,
|
|
46
|
-
listable: true
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
symbol: "WBTC",
|
|
50
|
-
address: "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
51
|
-
decimals: 8,
|
|
52
|
-
listable: true
|
|
10
|
+
// src/chains.ts
|
|
11
|
+
var CHAINS = ["STARKNET", "ETHEREUM", "SOLANA", "BASE", "BITCOIN"];
|
|
12
|
+
var COORDINATES = {
|
|
13
|
+
STARKNET: {
|
|
14
|
+
rpcUrl: "https://rpc.starknet.lava.build",
|
|
15
|
+
marketplace721: "0x069cf5391077e3ebdd9cb6aebf90ed530d29f0d6aa34a43f5afae938c0fb565e",
|
|
16
|
+
marketplace721ClassHash: "0x04c6f952d747ad7ead1b3dad4c1d587837d38f8ec29d6c095a4afa5b5ece5957",
|
|
17
|
+
marketplace721StartBlock: 10350340,
|
|
18
|
+
marketplace1155: "0x040cd7b3e73bb3c892166e34bdc01d1797f97ecbc356c23f1cf38033cacf0077",
|
|
19
|
+
marketplace1155ClassHash: "0x02600bb720908f119afe482309d36c39d087587f0df9576454acfb6363e78cd8",
|
|
20
|
+
marketplace1155StartBlock: 10350855,
|
|
21
|
+
collection721: "0x0322cb7119955e01ac778d40976eb3ba50540bb0899f812d612f9c7e63e49fd2",
|
|
22
|
+
collection721StartBlock: 10046166,
|
|
23
|
+
ipNftClassHash: "0x27ee4ded786d51bced1e94afec3034d6ffce71c032c45ee1ff283ccfa9db12e",
|
|
24
|
+
ipCollectionClassHash: "0x287ccdff8b6655a2248cfe170d82eae3a35303cd00ef3e751b25ddca26d9095",
|
|
25
|
+
collection1155: "0x0083543c3ee15040a419fc539fa6889f5b956e7d071bcfa97842cb0ae42ad6cc",
|
|
26
|
+
collection1155FactoryClassHash: "0x331a69da8655a882ba1fbcb55188b8fa09116521db901bbbaafc9fead0689f8",
|
|
27
|
+
collection1155ClassHash: "0x4e110b59af240ae6c7742999964c4eae13fb2ed935c47fe97653ec017ebea34",
|
|
28
|
+
collection1155StartBlock: 10665319,
|
|
29
|
+
popFactory: "0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111",
|
|
30
|
+
popCollectionClassHash: "0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f",
|
|
31
|
+
dropFactory: "0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800",
|
|
32
|
+
dropCollectionClassHash: "0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282",
|
|
33
|
+
nftComments: "0x02cdac70c94447189af0389dfea63f4d5e4154ea8a563de288a5ab1c39e37843",
|
|
34
|
+
creatorCoinFactory: "0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c",
|
|
35
|
+
creatorCoinEkuboLauncher: "0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4",
|
|
36
|
+
creatorCoinClassHash: "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6",
|
|
37
|
+
creatorCoinFactoryClassHash: "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55",
|
|
38
|
+
creatorCoinStartBlock: 10474544,
|
|
39
|
+
ekuboCore: "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b"
|
|
53
40
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
var COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = "0x331a69da8655a882ba1fbcb55188b8fa09116521db901bbbaafc9fead0689f8";
|
|
62
|
-
var COLLECTION_1155_CLASS_HASH_MAINNET = "0x4e110b59af240ae6c7742999964c4eae13fb2ed935c47fe97653ec017ebea34";
|
|
63
|
-
var COLLECTION_1155_START_BLOCK_MAINNET = 10665319;
|
|
64
|
-
var CREATOR_COIN_FACTORY_CONTRACT_MAINNET = "0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c";
|
|
65
|
-
var CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = "0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4";
|
|
66
|
-
var CREATOR_COIN_CLASS_HASH_MAINNET = "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6";
|
|
67
|
-
var CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55";
|
|
68
|
-
var CREATOR_COIN_START_BLOCK_MAINNET = 10474544;
|
|
69
|
-
var EKUBO_CORE_MAINNET = "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b";
|
|
41
|
+
};
|
|
42
|
+
function getCoordinates(chain) {
|
|
43
|
+
const c = COORDINATES[chain];
|
|
44
|
+
if (!c) throw new Error(`No coordinates configured for chain "${chain}"`);
|
|
45
|
+
return c;
|
|
46
|
+
}
|
|
47
|
+
var DEFAULT_CHAIN = "STARKNET";
|
|
70
48
|
var FeeConfigSchema = zod.z.object({
|
|
71
49
|
enabled: zod.z.boolean().default(true),
|
|
72
50
|
fundAddress: zod.z.string().min(1).optional(),
|
|
@@ -98,10 +76,13 @@ function buildFeeCall(p, cfg) {
|
|
|
98
76
|
|
|
99
77
|
// src/config.ts
|
|
100
78
|
var MedialaneConfigSchema = zod.z.object({
|
|
101
|
-
|
|
79
|
+
// Chain-scoped client (spec 2026-06-13 Decision B): one client per chain,
|
|
80
|
+
// coordinates resolved from the registry. Replaces the removed `network` axis.
|
|
81
|
+
chain: zod.z.enum(CHAINS).default(DEFAULT_CHAIN),
|
|
102
82
|
rpcUrl: zod.z.string().url().optional(),
|
|
103
83
|
backendUrl: zod.z.string().url().optional(),
|
|
104
84
|
apiKey: zod.z.string().optional(),
|
|
85
|
+
// Per-contract overrides remain for tests/forks; default from the registry.
|
|
105
86
|
marketplace721Contract: zod.z.string().optional(),
|
|
106
87
|
marketplaceContract: zod.z.string().optional(),
|
|
107
88
|
marketplace1155Contract: zod.z.string().optional(),
|
|
@@ -117,19 +98,20 @@ var MedialaneConfigSchema = zod.z.object({
|
|
|
117
98
|
});
|
|
118
99
|
function resolveConfig(raw) {
|
|
119
100
|
const parsed = MedialaneConfigSchema.parse(raw);
|
|
120
|
-
const
|
|
121
|
-
const
|
|
101
|
+
const coords = getCoordinates(parsed.chain);
|
|
102
|
+
const marketplace721Contract = parsed.marketplace721Contract ?? parsed.marketplaceContract ?? coords.marketplace721;
|
|
103
|
+
const collection721Contract = parsed.collection721Contract ?? parsed.collectionContract ?? coords.collection721;
|
|
122
104
|
return {
|
|
123
|
-
|
|
124
|
-
rpcUrl: parsed.rpcUrl ??
|
|
105
|
+
chain: parsed.chain,
|
|
106
|
+
rpcUrl: parsed.rpcUrl ?? coords.rpcUrl,
|
|
125
107
|
backendUrl: parsed.backendUrl,
|
|
126
108
|
apiKey: parsed.apiKey,
|
|
127
109
|
marketplace721Contract,
|
|
128
110
|
marketplaceContract: marketplace721Contract,
|
|
129
|
-
marketplace1155Contract: parsed.marketplace1155Contract ??
|
|
111
|
+
marketplace1155Contract: parsed.marketplace1155Contract ?? coords.marketplace1155,
|
|
130
112
|
collection721Contract,
|
|
131
113
|
collectionContract: collection721Contract,
|
|
132
|
-
collection1155Contract: parsed.collection1155Contract ??
|
|
114
|
+
collection1155Contract: parsed.collection1155Contract ?? coords.collection1155,
|
|
133
115
|
retryOptions: parsed.retryOptions,
|
|
134
116
|
feeConfig: resolveFeeConfig(parsed.feeConfig)
|
|
135
117
|
};
|
|
@@ -4531,6 +4513,68 @@ var IPNftABI = [
|
|
|
4531
4513
|
// src/abis/creatorCoinFactory.ts
|
|
4532
4514
|
var CreatorCoinFactoryABI = [{ "type": "impl", "name": "FactoryImpl", "interface_name": "creator_coin::factory::interface::IFactory" }, { "type": "struct", "name": "core::integer::u256", "members": [{ "name": "low", "type": "core::integer::u128" }, { "name": "high", "type": "core::integer::u128" }] }, { "type": "struct", "name": "core::array::Span::<core::starknet::contract_address::ContractAddress>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<core::starknet::contract_address::ContractAddress>" }] }, { "type": "struct", "name": "core::array::Span::<core::integer::u256>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<core::integer::u256>" }] }, { "type": "struct", "name": "creator_coin::factory::LaunchParameters", "members": [{ "name": "creator_coin_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "transfer_restriction_delay", "type": "core::integer::u64" }, { "name": "max_percentage_buy_launch", "type": "core::integer::u16" }, { "name": "quote_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "initial_holders", "type": "core::array::Span::<core::starknet::contract_address::ContractAddress>" }, { "name": "initial_holders_amounts", "type": "core::array::Span::<core::integer::u256>" }] }, { "type": "enum", "name": "core::bool", "variants": [{ "name": "False", "type": "()" }, { "name": "True", "type": "()" }] }, { "type": "struct", "name": "ekubo::types::i129::i129", "members": [{ "name": "mag", "type": "core::integer::u128" }, { "name": "sign", "type": "core::bool" }] }, { "type": "struct", "name": "creator_coin::exchanges::ekubo::ekubo_adapter::EkuboPoolParameters", "members": [{ "name": "fee", "type": "core::integer::u128" }, { "name": "tick_spacing", "type": "core::integer::u128" }, { "name": "starting_price", "type": "ekubo::types::i129::i129" }, { "name": "bound", "type": "core::integer::u128" }] }, { "type": "struct", "name": "ekubo::types::keys::PoolKey", "members": [{ "name": "token0", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "token1", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "fee", "type": "core::integer::u128" }, { "name": "tick_spacing", "type": "core::integer::u128" }, { "name": "extension", "type": "core::starknet::contract_address::ContractAddress" }] }, { "type": "struct", "name": "ekubo::types::bounds::Bounds", "members": [{ "name": "lower", "type": "ekubo::types::i129::i129" }, { "name": "upper", "type": "ekubo::types::i129::i129" }] }, { "type": "struct", "name": "creator_coin::exchanges::ekubo::launcher::EkuboLP", "members": [{ "name": "owner", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "quote_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "pool_key", "type": "ekubo::types::keys::PoolKey" }, { "name": "bounds", "type": "ekubo::types::bounds::Bounds" }] }, { "type": "enum", "name": "creator_coin::exchanges::SupportedExchanges", "variants": [{ "name": "Jediswap", "type": "()" }, { "name": "Ekubo", "type": "()" }, { "name": "Starkdefi", "type": "()" }] }, { "type": "enum", "name": "creator_coin::token::creator_coin::LiquidityType", "variants": [{ "name": "JediERC20", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "StarkDeFiERC20", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "EkuboNFT", "type": "core::integer::u64" }] }, { "type": "enum", "name": "core::option::Option::<(core::starknet::contract_address::ContractAddress, creator_coin::token::creator_coin::LiquidityType)>", "variants": [{ "name": "Some", "type": "(core::starknet::contract_address::ContractAddress, creator_coin::token::creator_coin::LiquidityType)" }, { "name": "None", "type": "()" }] }, { "type": "interface", "name": "creator_coin::factory::interface::IFactory", "items": [{ "type": "function", "name": "create_creator_coin", "inputs": [{ "name": "owner", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "name", "type": "core::felt252" }, { "name": "symbol", "type": "core::felt252" }, { "name": "initial_supply", "type": "core::integer::u256" }, { "name": "contract_address_salt", "type": "core::felt252" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "external" }, { "type": "function", "name": "launch_on_jediswap", "inputs": [{ "name": "launch_parameters", "type": "creator_coin::factory::LaunchParameters" }, { "name": "quote_amount", "type": "core::integer::u256" }, { "name": "unlock_time", "type": "core::integer::u64" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "external" }, { "type": "function", "name": "launch_on_ekubo", "inputs": [{ "name": "launch_parameters", "type": "creator_coin::factory::LaunchParameters" }, { "name": "ekubo_parameters", "type": "creator_coin::exchanges::ekubo::ekubo_adapter::EkuboPoolParameters" }], "outputs": [{ "type": "(core::integer::u64, creator_coin::exchanges::ekubo::launcher::EkuboLP)" }], "state_mutability": "external" }, { "type": "function", "name": "launch_on_starkdefi", "inputs": [{ "name": "launch_parameters", "type": "creator_coin::factory::LaunchParameters" }, { "name": "quote_amount", "type": "core::integer::u256" }, { "name": "unlock_time", "type": "core::integer::u64" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "external" }, { "type": "function", "name": "exchange_address", "inputs": [{ "name": "exchange", "type": "creator_coin::exchanges::SupportedExchanges" }], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "view" }, { "type": "function", "name": "lock_manager_address", "inputs": [], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "view" }, { "type": "function", "name": "locked_liquidity", "inputs": [{ "name": "token", "type": "core::starknet::contract_address::ContractAddress" }], "outputs": [{ "type": "core::option::Option::<(core::starknet::contract_address::ContractAddress, creator_coin::token::creator_coin::LiquidityType)>" }], "state_mutability": "view" }, { "type": "function", "name": "is_creator_coin", "inputs": [{ "name": "address", "type": "core::starknet::contract_address::ContractAddress" }], "outputs": [{ "type": "core::bool" }], "state_mutability": "view" }, { "type": "function", "name": "ekubo_core_address", "inputs": [], "outputs": [{ "type": "core::starknet::contract_address::ContractAddress" }], "state_mutability": "view" }] }, { "type": "struct", "name": "core::array::Span::<(creator_coin::exchanges::SupportedExchanges, core::starknet::contract_address::ContractAddress)>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<(creator_coin::exchanges::SupportedExchanges, core::starknet::contract_address::ContractAddress)>" }] }, { "type": "struct", "name": "core::array::Span::<(core::starknet::contract_address::ContractAddress, core::starknet::contract_address::ContractAddress)>", "members": [{ "name": "snapshot", "type": "@core::array::Array::<(core::starknet::contract_address::ContractAddress, core::starknet::contract_address::ContractAddress)>" }] }, { "type": "constructor", "name": "constructor", "inputs": [{ "name": "creator_coin_class_hash", "type": "core::starknet::class_hash::ClassHash" }, { "name": "lock_manager_address", "type": "core::starknet::contract_address::ContractAddress" }, { "name": "exchanges", "type": "core::array::Span::<(creator_coin::exchanges::SupportedExchanges, core::starknet::contract_address::ContractAddress)>" }, { "name": "migrated_tokens", "type": "core::array::Span::<(core::starknet::contract_address::ContractAddress, core::starknet::contract_address::ContractAddress)>" }] }, { "type": "event", "name": "creator_coin::factory::factory::Factory::CreatorCoinCreated", "kind": "struct", "members": [{ "name": "owner", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }, { "name": "name", "type": "core::felt252", "kind": "data" }, { "name": "symbol", "type": "core::felt252", "kind": "data" }, { "name": "initial_supply", "type": "core::integer::u256", "kind": "data" }, { "name": "creator_coin_address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }] }, { "type": "event", "name": "creator_coin::factory::factory::Factory::CreatorCoinLaunched", "kind": "struct", "members": [{ "name": "creator_coin_address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }, { "name": "quote_token", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" }, { "name": "exchange_name", "type": "core::felt252", "kind": "data" }] }, { "type": "event", "name": "creator_coin::factory::factory::Factory::Event", "kind": "enum", "variants": [{ "name": "CreatorCoinCreated", "type": "creator_coin::factory::factory::Factory::CreatorCoinCreated", "kind": "nested" }, { "name": "CreatorCoinLaunched", "type": "creator_coin::factory::factory::Factory::CreatorCoinLaunched", "kind": "nested" }] }];
|
|
4533
4515
|
|
|
4516
|
+
// src/constants.ts
|
|
4517
|
+
var SN = getCoordinates("STARKNET");
|
|
4518
|
+
var MARKETPLACE_721_CONTRACT_MAINNET = SN.marketplace721;
|
|
4519
|
+
var MARKETPLACE_721_CLASS_HASH_MAINNET = SN.marketplace721ClassHash;
|
|
4520
|
+
var MARKETPLACE_721_START_BLOCK_MAINNET = SN.marketplace721StartBlock;
|
|
4521
|
+
var MARKETPLACE_1155_CONTRACT_MAINNET = SN.marketplace1155;
|
|
4522
|
+
var MARKETPLACE_1155_CLASS_HASH_MAINNET = SN.marketplace1155ClassHash;
|
|
4523
|
+
var MARKETPLACE_1155_START_BLOCK_MAINNET = SN.marketplace1155StartBlock;
|
|
4524
|
+
var COLLECTION_721_CONTRACT_MAINNET = SN.collection721;
|
|
4525
|
+
var IPNFT_CLASS_HASH_MAINNET = SN.ipNftClassHash;
|
|
4526
|
+
var IPCOLLECTION_CLASS_HASH_MAINNET = SN.ipCollectionClassHash;
|
|
4527
|
+
var COLLECTION_721_START_BLOCK_MAINNET = SN.collection721StartBlock;
|
|
4528
|
+
var DROP_FACTORY_CONTRACT_MAINNET = SN.dropFactory;
|
|
4529
|
+
var POP_FACTORY_CONTRACT_MAINNET = SN.popFactory;
|
|
4530
|
+
var NFTCOMMENTS_CONTRACT_MAINNET = SN.nftComments;
|
|
4531
|
+
var SUPPORTED_TOKENS = [
|
|
4532
|
+
{
|
|
4533
|
+
// Circle-native USDC on Starknet (canonical)
|
|
4534
|
+
symbol: "USDC",
|
|
4535
|
+
address: "0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb",
|
|
4536
|
+
decimals: 6,
|
|
4537
|
+
listable: true
|
|
4538
|
+
},
|
|
4539
|
+
{
|
|
4540
|
+
symbol: "USDT",
|
|
4541
|
+
address: "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",
|
|
4542
|
+
decimals: 6,
|
|
4543
|
+
listable: true
|
|
4544
|
+
},
|
|
4545
|
+
{
|
|
4546
|
+
symbol: "ETH",
|
|
4547
|
+
address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
4548
|
+
decimals: 18,
|
|
4549
|
+
listable: true
|
|
4550
|
+
},
|
|
4551
|
+
{
|
|
4552
|
+
symbol: "STRK",
|
|
4553
|
+
address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
4554
|
+
decimals: 18,
|
|
4555
|
+
listable: true
|
|
4556
|
+
},
|
|
4557
|
+
{
|
|
4558
|
+
symbol: "WBTC",
|
|
4559
|
+
address: "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
4560
|
+
decimals: 8,
|
|
4561
|
+
listable: true
|
|
4562
|
+
}
|
|
4563
|
+
];
|
|
4564
|
+
var DEFAULT_CURRENCY = "USDC";
|
|
4565
|
+
var POP_COLLECTION_CLASS_HASH_MAINNET = SN.popCollectionClassHash;
|
|
4566
|
+
var DROP_COLLECTION_CLASS_HASH_MAINNET = SN.dropCollectionClassHash;
|
|
4567
|
+
var COLLECTION_1155_CONTRACT_MAINNET = SN.collection1155;
|
|
4568
|
+
var COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = SN.collection1155FactoryClassHash;
|
|
4569
|
+
var COLLECTION_1155_CLASS_HASH_MAINNET = SN.collection1155ClassHash;
|
|
4570
|
+
var COLLECTION_1155_START_BLOCK_MAINNET = SN.collection1155StartBlock;
|
|
4571
|
+
var CREATOR_COIN_FACTORY_CONTRACT_MAINNET = SN.creatorCoinFactory;
|
|
4572
|
+
var CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = SN.creatorCoinEkuboLauncher;
|
|
4573
|
+
var CREATOR_COIN_CLASS_HASH_MAINNET = SN.creatorCoinClassHash;
|
|
4574
|
+
var CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = SN.creatorCoinFactoryClassHash;
|
|
4575
|
+
var CREATOR_COIN_START_BLOCK_MAINNET = SN.creatorCoinStartBlock;
|
|
4576
|
+
var EKUBO_CORE_MAINNET = SN.ekuboCore;
|
|
4577
|
+
|
|
4534
4578
|
// src/utils/bigint.ts
|
|
4535
4579
|
function stringifyBigInts(obj) {
|
|
4536
4580
|
if (typeof obj === "bigint") {
|
|
@@ -4671,7 +4715,10 @@ function toSignatureArray(sig) {
|
|
|
4671
4715
|
const s = sig;
|
|
4672
4716
|
return [s.r.toString(), s.s.toString()];
|
|
4673
4717
|
}
|
|
4674
|
-
function getChainId(
|
|
4718
|
+
function getChainId(config) {
|
|
4719
|
+
if (config.chain !== "STARKNET") {
|
|
4720
|
+
throw new Error(`SNIP-12 signing is Starknet-only; got chain "${config.chain}"`);
|
|
4721
|
+
}
|
|
4675
4722
|
return starknet.constants.StarknetChainId.SN_MAIN;
|
|
4676
4723
|
}
|
|
4677
4724
|
function resolveToken(currency) {
|
|
@@ -4738,7 +4785,7 @@ async function createListing(account, params, config) {
|
|
|
4738
4785
|
salt: generateSalt(),
|
|
4739
4786
|
counter
|
|
4740
4787
|
};
|
|
4741
|
-
const chainId = getChainId();
|
|
4788
|
+
const chainId = getChainId(config);
|
|
4742
4789
|
const typedData = stringifyBigInts(buildOrderTypedData(orderParams, chainId));
|
|
4743
4790
|
const signature = await account.signMessage(typedData);
|
|
4744
4791
|
const signatureArray = toSignatureArray(signature);
|
|
@@ -4820,7 +4867,7 @@ async function makeOffer(account, params, config) {
|
|
|
4820
4867
|
salt: generateSalt(),
|
|
4821
4868
|
counter
|
|
4822
4869
|
};
|
|
4823
|
-
const chainId = getChainId();
|
|
4870
|
+
const chainId = getChainId(config);
|
|
4824
4871
|
const typedData = stringifyBigInts(buildOrderTypedData(orderParams, chainId));
|
|
4825
4872
|
const signature = await account.signMessage(typedData);
|
|
4826
4873
|
const signatureArray = toSignatureArray(signature);
|
|
@@ -4887,7 +4934,7 @@ async function fulfillOrder(account, params, config) {
|
|
|
4887
4934
|
async function cancelOrder(account, params, config) {
|
|
4888
4935
|
const { orderHash } = params;
|
|
4889
4936
|
const { contract, provider } = makeContract(config);
|
|
4890
|
-
const chainId = getChainId();
|
|
4937
|
+
const chainId = getChainId(config);
|
|
4891
4938
|
const cancelParams = {
|
|
4892
4939
|
order_hash: orderHash,
|
|
4893
4940
|
offerer: account.address
|
|
@@ -5073,7 +5120,7 @@ async function createListing1155(account, params, config) {
|
|
|
5073
5120
|
const priceWei = parseAmount(pricePerUnit, token.decimals);
|
|
5074
5121
|
const now = Math.floor(Date.now() / 1e3);
|
|
5075
5122
|
const endTime = now + durationSeconds;
|
|
5076
|
-
const chainId = getChainId();
|
|
5123
|
+
const chainId = getChainId(config);
|
|
5077
5124
|
const counter = (await contract.get_counter(account.address)).toString();
|
|
5078
5125
|
const royaltyMaxBps = await resolveRoyaltyMaxBps(provider, nftContract, tokenId, params.royaltyMaxBps);
|
|
5079
5126
|
const orderParams = {
|
|
@@ -5173,7 +5220,7 @@ async function cancelOrder1155(account, params, config) {
|
|
|
5173
5220
|
const { orderHash } = params;
|
|
5174
5221
|
const contract = getContract(config);
|
|
5175
5222
|
const provider = getProvider(config);
|
|
5176
|
-
const chainId = getChainId();
|
|
5223
|
+
const chainId = getChainId(config);
|
|
5177
5224
|
const cancelParams = {
|
|
5178
5225
|
order_hash: orderHash,
|
|
5179
5226
|
offerer: account.address
|
|
@@ -5207,7 +5254,7 @@ async function makeOffer1155(account, params, config) {
|
|
|
5207
5254
|
} = params;
|
|
5208
5255
|
const contract = getContract(config);
|
|
5209
5256
|
const provider = getProvider(config);
|
|
5210
|
-
const chainId = getChainId();
|
|
5257
|
+
const chainId = getChainId(config);
|
|
5211
5258
|
const token = resolveToken(currency);
|
|
5212
5259
|
const priceWei = parseAmount(price, token.decimals);
|
|
5213
5260
|
const now = Math.floor(Date.now() / 1e3);
|
|
@@ -5389,12 +5436,46 @@ var Medialane1155Module = class {
|
|
|
5389
5436
|
return build1155CancellationTypedData(params, chainId);
|
|
5390
5437
|
}
|
|
5391
5438
|
};
|
|
5392
|
-
function normalizeAddress(address) {
|
|
5439
|
+
function normalizeAddress(chain, address) {
|
|
5440
|
+
switch (chain) {
|
|
5441
|
+
case "STARKNET":
|
|
5442
|
+
return normalizeStarknet(address);
|
|
5443
|
+
case "ETHEREUM":
|
|
5444
|
+
case "BASE":
|
|
5445
|
+
return normalizeEvm(address);
|
|
5446
|
+
case "SOLANA":
|
|
5447
|
+
return normalizeSolana(address);
|
|
5448
|
+
case "BITCOIN":
|
|
5449
|
+
throw new Error("BITCOIN address normalization not implemented");
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
function normalizeStarknet(address) {
|
|
5393
5453
|
try {
|
|
5394
5454
|
const hex = starknet.num.toHex(BigInt(address));
|
|
5395
5455
|
return "0x" + hex.slice(2).padStart(64, "0").toLowerCase();
|
|
5396
5456
|
} catch {
|
|
5397
|
-
throw new Error(`Invalid
|
|
5457
|
+
throw new Error(`Invalid STARKNET address: "${address}"`);
|
|
5458
|
+
}
|
|
5459
|
+
}
|
|
5460
|
+
function normalizeEvm(address) {
|
|
5461
|
+
const m = /^0x([0-9a-fA-F]{40})$/.exec(address);
|
|
5462
|
+
if (!m) throw new Error(`Invalid ETHEREUM/BASE address: "${address}"`);
|
|
5463
|
+
const lower = m[1].toLowerCase();
|
|
5464
|
+
const hash2 = sha3_js.keccak_256(new TextEncoder().encode(lower));
|
|
5465
|
+
let out = "0x";
|
|
5466
|
+
for (let i = 0; i < 40; i++) {
|
|
5467
|
+
const nibble = hash2[i >> 1] >> (i % 2 === 0 ? 4 : 0) & 15;
|
|
5468
|
+
out += nibble >= 8 ? lower[i].toUpperCase() : lower[i];
|
|
5469
|
+
}
|
|
5470
|
+
return out;
|
|
5471
|
+
}
|
|
5472
|
+
function normalizeSolana(address) {
|
|
5473
|
+
try {
|
|
5474
|
+
const bytes = base.base58.decode(address);
|
|
5475
|
+
if (bytes.length !== 32) throw new Error("not a 32-byte key");
|
|
5476
|
+
return address;
|
|
5477
|
+
} catch {
|
|
5478
|
+
throw new Error(`Invalid SOLANA address: "${address}"`);
|
|
5398
5479
|
}
|
|
5399
5480
|
}
|
|
5400
5481
|
function normalizeHash(hash2) {
|
|
@@ -5402,11 +5483,11 @@ function normalizeHash(hash2) {
|
|
|
5402
5483
|
const hex = starknet.num.toHex(BigInt(hash2));
|
|
5403
5484
|
return "0x" + hex.slice(2).padStart(64, "0").toLowerCase();
|
|
5404
5485
|
} catch {
|
|
5405
|
-
throw new Error(`Invalid
|
|
5486
|
+
throw new Error(`Invalid hash: "${hash2}"`);
|
|
5406
5487
|
}
|
|
5407
5488
|
}
|
|
5408
|
-
function shortenAddress(address, chars = 4) {
|
|
5409
|
-
const norm = normalizeAddress(address);
|
|
5489
|
+
function shortenAddress(chain, address, chars = 4) {
|
|
5490
|
+
const norm = normalizeAddress(chain, address);
|
|
5410
5491
|
return `${norm.slice(0, chars + 2)}...${norm.slice(-chars)}`;
|
|
5411
5492
|
}
|
|
5412
5493
|
|
|
@@ -5460,11 +5541,16 @@ var MedialaneApiError = class extends Error {
|
|
|
5460
5541
|
}
|
|
5461
5542
|
};
|
|
5462
5543
|
var ApiClient = class {
|
|
5463
|
-
constructor(baseUrl, apiKey, retryOptions) {
|
|
5544
|
+
constructor(baseUrl, apiKey, retryOptions, chain = "STARKNET") {
|
|
5464
5545
|
this.baseUrl = baseUrl;
|
|
5546
|
+
this.chain = chain;
|
|
5465
5547
|
this.baseHeaders = apiKey ? { "x-api-key": apiKey } : {};
|
|
5466
5548
|
this.retryOptions = retryOptions;
|
|
5467
5549
|
}
|
|
5550
|
+
/** Normalize an address for this client's chain (chain-scoped — Decision B). */
|
|
5551
|
+
addr(a) {
|
|
5552
|
+
return normalizeAddress(this.chain, a);
|
|
5553
|
+
}
|
|
5468
5554
|
async request(path, init) {
|
|
5469
5555
|
const url = `${this.baseUrl.replace(/\/$/, "")}${path}`;
|
|
5470
5556
|
const headers = { ...this.baseHeaders };
|
|
@@ -5526,7 +5612,7 @@ var ApiClient = class {
|
|
|
5526
5612
|
if (query.sort) params.set("sort", query.sort);
|
|
5527
5613
|
if (query.page !== void 0) params.set("page", String(query.page));
|
|
5528
5614
|
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
5529
|
-
if (query.offerer) params.set("offerer",
|
|
5615
|
+
if (query.offerer) params.set("offerer", this.addr(query.offerer));
|
|
5530
5616
|
if (query.minPrice) params.set("minPrice", query.minPrice);
|
|
5531
5617
|
if (query.maxPrice) params.set("maxPrice", query.maxPrice);
|
|
5532
5618
|
const qs = params.toString();
|
|
@@ -5536,11 +5622,11 @@ var ApiClient = class {
|
|
|
5536
5622
|
return this.get(`/v1/orders/${orderHash}`);
|
|
5537
5623
|
}
|
|
5538
5624
|
getActiveOrdersForToken(contract, tokenId) {
|
|
5539
|
-
return this.get(`/v1/orders/token/${
|
|
5625
|
+
return this.get(`/v1/orders/token/${this.addr(contract)}/${tokenId}`);
|
|
5540
5626
|
}
|
|
5541
5627
|
getOrdersByUser(address, page = 1, limit = 20) {
|
|
5542
5628
|
return this.get(
|
|
5543
|
-
`/v1/orders/user/${
|
|
5629
|
+
`/v1/orders/user/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
5544
5630
|
);
|
|
5545
5631
|
}
|
|
5546
5632
|
// ─── Tokens ────────────────────────────────────────────────────────────────
|
|
@@ -5551,7 +5637,7 @@ var ApiClient = class {
|
|
|
5551
5637
|
}
|
|
5552
5638
|
getTokensByOwner(address, page = 1, limit = 20) {
|
|
5553
5639
|
return this.get(
|
|
5554
|
-
`/v1/tokens/owned/${
|
|
5640
|
+
`/v1/tokens/owned/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
5555
5641
|
);
|
|
5556
5642
|
}
|
|
5557
5643
|
getTokenHistory(contract, tokenId, page = 1, limit = 20) {
|
|
@@ -5568,15 +5654,15 @@ var ApiClient = class {
|
|
|
5568
5654
|
return this.get(`/v1/collections?${params}`);
|
|
5569
5655
|
}
|
|
5570
5656
|
getCollectionsByOwner(owner, page = 1, limit = 50) {
|
|
5571
|
-
const params = new URLSearchParams({ owner:
|
|
5657
|
+
const params = new URLSearchParams({ owner: this.addr(owner), page: String(page), limit: String(limit) });
|
|
5572
5658
|
return this.get(`/v1/collections?${params}`);
|
|
5573
5659
|
}
|
|
5574
5660
|
getCollection(contract) {
|
|
5575
|
-
return this.get(`/v1/collections/${
|
|
5661
|
+
return this.get(`/v1/collections/${this.addr(contract)}`);
|
|
5576
5662
|
}
|
|
5577
5663
|
getCollectionTokens(contract, page = 1, limit = 20) {
|
|
5578
5664
|
return this.get(
|
|
5579
|
-
`/v1/collections/${
|
|
5665
|
+
`/v1/collections/${this.addr(contract)}/tokens?page=${page}&limit=${limit}`
|
|
5580
5666
|
);
|
|
5581
5667
|
}
|
|
5582
5668
|
// ─── Activities ────────────────────────────────────────────────────────────
|
|
@@ -5590,7 +5676,7 @@ var ApiClient = class {
|
|
|
5590
5676
|
}
|
|
5591
5677
|
getActivitiesByAddress(address, page = 1, limit = 20) {
|
|
5592
5678
|
return this.get(
|
|
5593
|
-
`/v1/activities/${
|
|
5679
|
+
`/v1/activities/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
5594
5680
|
);
|
|
5595
5681
|
}
|
|
5596
5682
|
// ─── Comments ──────────────────────────────────────────────────────────────
|
|
@@ -5600,7 +5686,7 @@ var ApiClient = class {
|
|
|
5600
5686
|
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
5601
5687
|
const qs = params.toString();
|
|
5602
5688
|
return this.get(
|
|
5603
|
-
`/v1/tokens/${
|
|
5689
|
+
`/v1/tokens/${this.addr(contract)}/${tokenId}/comments${qs ? `?${qs}` : ""}`
|
|
5604
5690
|
);
|
|
5605
5691
|
}
|
|
5606
5692
|
// ─── Search ────────────────────────────────────────────────────────────────
|
|
@@ -5738,7 +5824,7 @@ var ApiClient = class {
|
|
|
5738
5824
|
}
|
|
5739
5825
|
// ─── Collection Profiles ────────────────────────────────────────────────────
|
|
5740
5826
|
async getCollectionProfile(contractAddress) {
|
|
5741
|
-
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${
|
|
5827
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${this.addr(contractAddress)}/profile`;
|
|
5742
5828
|
const res = await fetch(url, { headers: this.baseHeaders });
|
|
5743
5829
|
return this.checkResponse(res, { allow404: true });
|
|
5744
5830
|
}
|
|
@@ -5746,7 +5832,7 @@ var ApiClient = class {
|
|
|
5746
5832
|
* Update collection profile. Requires Clerk JWT for ownership check.
|
|
5747
5833
|
*/
|
|
5748
5834
|
async updateCollectionProfile(contractAddress, data, clerkToken) {
|
|
5749
|
-
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${
|
|
5835
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${this.addr(contractAddress)}/profile`;
|
|
5750
5836
|
const res = await fetch(url, {
|
|
5751
5837
|
method: "PATCH",
|
|
5752
5838
|
headers: {
|
|
@@ -5759,7 +5845,7 @@ var ApiClient = class {
|
|
|
5759
5845
|
return this.checkResponse(res);
|
|
5760
5846
|
}
|
|
5761
5847
|
async getGatedContent(contractAddress, clerkToken) {
|
|
5762
|
-
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${
|
|
5848
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${this.addr(contractAddress)}/gated-content`;
|
|
5763
5849
|
const res = await fetch(url, {
|
|
5764
5850
|
headers: { ...this.baseHeaders, "Authorization": `Bearer ${clerkToken}` }
|
|
5765
5851
|
});
|
|
@@ -5777,7 +5863,7 @@ var ApiClient = class {
|
|
|
5777
5863
|
return this.checkResponse(res);
|
|
5778
5864
|
}
|
|
5779
5865
|
async getCreatorProfile(walletAddress) {
|
|
5780
|
-
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/${
|
|
5866
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/${this.addr(walletAddress)}/profile`;
|
|
5781
5867
|
const res = await fetch(url, { headers: this.baseHeaders });
|
|
5782
5868
|
return this.checkResponse(res, { allow404: true });
|
|
5783
5869
|
}
|
|
@@ -5791,7 +5877,7 @@ var ApiClient = class {
|
|
|
5791
5877
|
* Update creator profile. Requires Clerk JWT; wallet must match authenticated user.
|
|
5792
5878
|
*/
|
|
5793
5879
|
async updateCreatorProfile(walletAddress, data, clerkToken) {
|
|
5794
|
-
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/${
|
|
5880
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/${this.addr(walletAddress)}/profile`;
|
|
5795
5881
|
const res = await fetch(url, {
|
|
5796
5882
|
method: "PATCH",
|
|
5797
5883
|
headers: {
|
|
@@ -5891,7 +5977,7 @@ var ApiClient = class {
|
|
|
5891
5977
|
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
5892
5978
|
const qs = params.toString();
|
|
5893
5979
|
return this.get(
|
|
5894
|
-
`/v1/tokens/${
|
|
5980
|
+
`/v1/tokens/${this.addr(contract)}/${tokenId}/remixes${qs ? `?${qs}` : ""}`
|
|
5895
5981
|
);
|
|
5896
5982
|
}
|
|
5897
5983
|
/**
|
|
@@ -5986,14 +6072,14 @@ var ApiClient = class {
|
|
|
5986
6072
|
}
|
|
5987
6073
|
async getPopEligibility(collection, wallet) {
|
|
5988
6074
|
const res = await this.get(
|
|
5989
|
-
`/v1/pop/eligibility/${
|
|
6075
|
+
`/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
|
|
5990
6076
|
);
|
|
5991
6077
|
return res.data;
|
|
5992
6078
|
}
|
|
5993
6079
|
async getPopEligibilityBatch(collection, wallets) {
|
|
5994
|
-
const params = new URLSearchParams({ wallets: wallets.map(
|
|
6080
|
+
const params = new URLSearchParams({ wallets: wallets.map((w) => this.addr(w)).join(",") });
|
|
5995
6081
|
const res = await this.get(
|
|
5996
|
-
`/v1/pop/eligibility/${
|
|
6082
|
+
`/v1/pop/eligibility/${this.addr(collection)}?${params}`
|
|
5997
6083
|
);
|
|
5998
6084
|
return res.data;
|
|
5999
6085
|
}
|
|
@@ -6003,7 +6089,7 @@ var ApiClient = class {
|
|
|
6003
6089
|
}
|
|
6004
6090
|
async getDropMintStatus(collection, wallet) {
|
|
6005
6091
|
const res = await this.get(
|
|
6006
|
-
`/v1/drop/mint-status/${
|
|
6092
|
+
`/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
|
|
6007
6093
|
);
|
|
6008
6094
|
return res.data;
|
|
6009
6095
|
}
|
|
@@ -6013,7 +6099,7 @@ var PopService = class {
|
|
|
6013
6099
|
this.factoryAddress = POP_FACTORY_CONTRACT_MAINNET;
|
|
6014
6100
|
}
|
|
6015
6101
|
_collection(address, account) {
|
|
6016
|
-
return new starknet.Contract(POPCollectionABI, normalizeAddress(address), account);
|
|
6102
|
+
return new starknet.Contract(POPCollectionABI, normalizeAddress("STARKNET", address), account);
|
|
6017
6103
|
}
|
|
6018
6104
|
async claim(account, collectionAddress) {
|
|
6019
6105
|
const call = this._collection(collectionAddress, account).populate("claim", []);
|
|
@@ -6089,7 +6175,7 @@ var DropService = class {
|
|
|
6089
6175
|
this.config = config;
|
|
6090
6176
|
}
|
|
6091
6177
|
_collection(address, account) {
|
|
6092
|
-
return new starknet.Contract(DropCollectionABI, normalizeAddress(address), account);
|
|
6178
|
+
return new starknet.Contract(DropCollectionABI, normalizeAddress("STARKNET", address), account);
|
|
6093
6179
|
}
|
|
6094
6180
|
async claim(account, collectionAddress, quantity = 1) {
|
|
6095
6181
|
const collection = this._collection(collectionAddress, account);
|
|
@@ -6172,14 +6258,14 @@ var ERC1155CollectionService = class {
|
|
|
6172
6258
|
_factory(account) {
|
|
6173
6259
|
return new starknet.Contract(
|
|
6174
6260
|
IPCollection1155FactoryABI,
|
|
6175
|
-
normalizeAddress(this.factoryAddress),
|
|
6261
|
+
normalizeAddress("STARKNET", this.factoryAddress),
|
|
6176
6262
|
account
|
|
6177
6263
|
);
|
|
6178
6264
|
}
|
|
6179
6265
|
_collection(address, account) {
|
|
6180
6266
|
return new starknet.Contract(
|
|
6181
6267
|
IPCollection1155ABI,
|
|
6182
|
-
normalizeAddress(address),
|
|
6268
|
+
normalizeAddress("STARKNET", address),
|
|
6183
6269
|
account
|
|
6184
6270
|
);
|
|
6185
6271
|
}
|
|
@@ -6301,7 +6387,7 @@ async function getCreatorCoinPrice(coinAddress, provider) {
|
|
|
6301
6387
|
if (BigInt(r[0]) !== 0n || BigInt(r[1]) !== 0n) return null;
|
|
6302
6388
|
const fee = r[2];
|
|
6303
6389
|
const tickSpacing = r[3];
|
|
6304
|
-
const quoteToken = normalizeAddress("0x" + BigInt(r[7]).toString(16));
|
|
6390
|
+
const quoteToken = normalizeAddress("STARKNET", "0x" + BigInt(r[7]).toString(16));
|
|
6305
6391
|
const token = getTokenByAddress(quoteToken);
|
|
6306
6392
|
const quoteDecimals = token?.decimals ?? 18;
|
|
6307
6393
|
const ci = BigInt(coinAddress);
|
|
@@ -6369,20 +6455,20 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
6369
6455
|
}
|
|
6370
6456
|
var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
|
|
6371
6457
|
function parseCreatorCoinCreated(receipt) {
|
|
6372
|
-
const factory = normalizeAddress(CREATOR_COIN_FACTORY_CONTRACT_MAINNET);
|
|
6458
|
+
const factory = normalizeAddress("STARKNET", CREATOR_COIN_FACTORY_CONTRACT_MAINNET);
|
|
6373
6459
|
for (const ev of receipt?.events ?? []) {
|
|
6374
6460
|
let from;
|
|
6375
6461
|
try {
|
|
6376
|
-
from = normalizeAddress(ev.from_address ?? "");
|
|
6462
|
+
from = normalizeAddress("STARKNET", ev.from_address ?? "");
|
|
6377
6463
|
} catch {
|
|
6378
6464
|
continue;
|
|
6379
6465
|
}
|
|
6380
6466
|
if (from !== factory) continue;
|
|
6381
6467
|
const k0 = ev.keys?.[0];
|
|
6382
|
-
if (!k0 || normalizeAddress(k0) !== normalizeAddress(CREATOR_COIN_CREATED_SELECTOR)) continue;
|
|
6468
|
+
if (!k0 || normalizeAddress("STARKNET", k0) !== normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
|
|
6383
6469
|
const data = ev.data ?? [];
|
|
6384
6470
|
if (data.length < 1) continue;
|
|
6385
|
-
return normalizeAddress(data[data.length - 1]);
|
|
6471
|
+
return normalizeAddress("STARKNET", data[data.length - 1]);
|
|
6386
6472
|
}
|
|
6387
6473
|
throw new Error("Coin deployed but the coin address could not be read from the receipt");
|
|
6388
6474
|
}
|
|
@@ -6452,11 +6538,11 @@ var MedialaneClient = class {
|
|
|
6452
6538
|
}
|
|
6453
6539
|
});
|
|
6454
6540
|
} else {
|
|
6455
|
-
this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions);
|
|
6541
|
+
this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
|
|
6456
6542
|
}
|
|
6457
6543
|
}
|
|
6458
|
-
get
|
|
6459
|
-
return this.config.
|
|
6544
|
+
get chain() {
|
|
6545
|
+
return this.config.chain;
|
|
6460
6546
|
}
|
|
6461
6547
|
get rpcUrl() {
|
|
6462
6548
|
return this.config.rpcUrl;
|
|
@@ -6469,6 +6555,46 @@ var MedialaneClient = class {
|
|
|
6469
6555
|
// src/types/api.ts
|
|
6470
6556
|
var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
|
|
6471
6557
|
|
|
6558
|
+
// src/services/coinLaunchMath.ts
|
|
6559
|
+
var COIN_DECIMALS2 = 18;
|
|
6560
|
+
var LAUNCH_PRICE_QUOTE_PER_COIN = 0.01;
|
|
6561
|
+
var MIN_SUPPLY = 1000n;
|
|
6562
|
+
var MAX_SUPPLY = 1000000000000n;
|
|
6563
|
+
var MAX_FELT_BYTES = 31;
|
|
6564
|
+
function byteLen(s) {
|
|
6565
|
+
return new TextEncoder().encode(s).length;
|
|
6566
|
+
}
|
|
6567
|
+
function validateName(s) {
|
|
6568
|
+
if (!s.trim()) return "Name is required";
|
|
6569
|
+
if (byteLen(s) > MAX_FELT_BYTES) return `Name must be at most ${MAX_FELT_BYTES} bytes`;
|
|
6570
|
+
return null;
|
|
6571
|
+
}
|
|
6572
|
+
function validateSymbol(s) {
|
|
6573
|
+
if (!s.trim()) return "Symbol is required";
|
|
6574
|
+
if (byteLen(s) > MAX_FELT_BYTES) return `Symbol must be at most ${MAX_FELT_BYTES} bytes`;
|
|
6575
|
+
return null;
|
|
6576
|
+
}
|
|
6577
|
+
function validateSupply(human) {
|
|
6578
|
+
if (!/^\d+$/.test(human.trim())) return "Supply must be a whole number";
|
|
6579
|
+
const v = BigInt(human.trim());
|
|
6580
|
+
if (v < MIN_SUPPLY) return `Supply must be at least ${MIN_SUPPLY.toString()}`;
|
|
6581
|
+
if (v > MAX_SUPPLY) return `Supply must be at most ${MAX_SUPPLY.toString()}`;
|
|
6582
|
+
return null;
|
|
6583
|
+
}
|
|
6584
|
+
function toRaw(human, decimals = COIN_DECIMALS2) {
|
|
6585
|
+
return human * 10n ** BigInt(decimals);
|
|
6586
|
+
}
|
|
6587
|
+
function teamCoinsRaw(supplyRaw, pct) {
|
|
6588
|
+
const bps = BigInt(Math.round(pct * 100));
|
|
6589
|
+
return supplyRaw * bps / 10000n;
|
|
6590
|
+
}
|
|
6591
|
+
function buybackQuoteRaw(teamCoinsRawValue, quoteDecimals) {
|
|
6592
|
+
return teamCoinsRawValue * 10n ** BigInt(quoteDecimals) / (100n * 10n ** BigInt(COIN_DECIMALS2));
|
|
6593
|
+
}
|
|
6594
|
+
function fdvHuman(supplyHuman) {
|
|
6595
|
+
return supplyHuman * LAUNCH_PRICE_QUOTE_PER_COIN;
|
|
6596
|
+
}
|
|
6597
|
+
|
|
6472
6598
|
// src/services/registry.ts
|
|
6473
6599
|
var SERVICES = {
|
|
6474
6600
|
"mip-erc721": {
|
|
@@ -6478,8 +6604,10 @@ var SERVICES = {
|
|
|
6478
6604
|
standard: "ERC721",
|
|
6479
6605
|
provenance: "MEDIALANE",
|
|
6480
6606
|
onchain: {
|
|
6481
|
-
|
|
6482
|
-
|
|
6607
|
+
STARKNET: {
|
|
6608
|
+
factoryAddress: COLLECTION_721_CONTRACT_MAINNET,
|
|
6609
|
+
startBlock: COLLECTION_721_START_BLOCK_MAINNET
|
|
6610
|
+
}
|
|
6483
6611
|
},
|
|
6484
6612
|
uiVariant: "standard",
|
|
6485
6613
|
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
@@ -6501,7 +6629,7 @@ var SERVICES = {
|
|
|
6501
6629
|
uiVariant: "standard",
|
|
6502
6630
|
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
6503
6631
|
// No factory — single shared contract. Events declared when the genesis
|
|
6504
|
-
// contract address is wired into onchain.factoryAddress here.
|
|
6632
|
+
// contract address is wired into onchain.STARKNET.factoryAddress here.
|
|
6505
6633
|
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
6506
6634
|
},
|
|
6507
6635
|
"mip-erc1155": {
|
|
@@ -6511,9 +6639,11 @@ var SERVICES = {
|
|
|
6511
6639
|
standard: "ERC1155",
|
|
6512
6640
|
provenance: "MEDIALANE",
|
|
6513
6641
|
onchain: {
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6642
|
+
STARKNET: {
|
|
6643
|
+
factoryAddress: COLLECTION_1155_CONTRACT_MAINNET,
|
|
6644
|
+
classHash: COLLECTION_1155_CLASS_HASH_MAINNET,
|
|
6645
|
+
startBlock: COLLECTION_1155_START_BLOCK_MAINNET
|
|
6646
|
+
}
|
|
6517
6647
|
},
|
|
6518
6648
|
uiVariant: "edition",
|
|
6519
6649
|
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
@@ -6529,8 +6659,10 @@ var SERVICES = {
|
|
|
6529
6659
|
standard: "ERC721",
|
|
6530
6660
|
provenance: "MEDIALANE",
|
|
6531
6661
|
onchain: {
|
|
6532
|
-
|
|
6533
|
-
|
|
6662
|
+
STARKNET: {
|
|
6663
|
+
factoryAddress: POP_FACTORY_CONTRACT_MAINNET,
|
|
6664
|
+
classHash: POP_COLLECTION_CLASS_HASH_MAINNET
|
|
6665
|
+
}
|
|
6534
6666
|
},
|
|
6535
6667
|
uiVariant: "pop",
|
|
6536
6668
|
capabilities: ["claim", "transfer"],
|
|
@@ -6547,8 +6679,10 @@ var SERVICES = {
|
|
|
6547
6679
|
standard: "ERC721",
|
|
6548
6680
|
provenance: "MEDIALANE",
|
|
6549
6681
|
onchain: {
|
|
6550
|
-
|
|
6551
|
-
|
|
6682
|
+
STARKNET: {
|
|
6683
|
+
factoryAddress: DROP_FACTORY_CONTRACT_MAINNET,
|
|
6684
|
+
classHash: DROP_COLLECTION_CLASS_HASH_MAINNET
|
|
6685
|
+
}
|
|
6552
6686
|
},
|
|
6553
6687
|
uiVariant: "drop",
|
|
6554
6688
|
capabilities: ["claim", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
@@ -6565,9 +6699,11 @@ var SERVICES = {
|
|
|
6565
6699
|
standard: "ERC20",
|
|
6566
6700
|
provenance: "MEDIALANE",
|
|
6567
6701
|
onchain: {
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6702
|
+
STARKNET: {
|
|
6703
|
+
factoryAddress: CREATOR_COIN_FACTORY_CONTRACT_MAINNET,
|
|
6704
|
+
classHash: CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET,
|
|
6705
|
+
startBlock: CREATOR_COIN_START_BLOCK_MAINNET
|
|
6706
|
+
}
|
|
6571
6707
|
},
|
|
6572
6708
|
uiVariant: "coin",
|
|
6573
6709
|
// `swap` is a UI affordance (05 §III): the marketplace renders an embedded
|
|
@@ -6587,9 +6723,11 @@ var SERVICES = {
|
|
|
6587
6723
|
standard: "ERC721",
|
|
6588
6724
|
provenance: "MEDIALANE",
|
|
6589
6725
|
onchain: {
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6726
|
+
STARKNET: {
|
|
6727
|
+
factoryAddress: MARKETPLACE_721_CONTRACT_MAINNET,
|
|
6728
|
+
classHash: MARKETPLACE_721_CLASS_HASH_MAINNET,
|
|
6729
|
+
startBlock: MARKETPLACE_721_START_BLOCK_MAINNET
|
|
6730
|
+
}
|
|
6593
6731
|
},
|
|
6594
6732
|
uiVariant: "standard",
|
|
6595
6733
|
capabilities: ["list", "buy", "make_offer", "cancel"],
|
|
@@ -6606,9 +6744,11 @@ var SERVICES = {
|
|
|
6606
6744
|
standard: "ERC1155",
|
|
6607
6745
|
provenance: "MEDIALANE",
|
|
6608
6746
|
onchain: {
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6747
|
+
STARKNET: {
|
|
6748
|
+
factoryAddress: MARKETPLACE_1155_CONTRACT_MAINNET,
|
|
6749
|
+
classHash: MARKETPLACE_1155_CLASS_HASH_MAINNET,
|
|
6750
|
+
startBlock: MARKETPLACE_1155_START_BLOCK_MAINNET
|
|
6751
|
+
}
|
|
6612
6752
|
},
|
|
6613
6753
|
uiVariant: "edition",
|
|
6614
6754
|
capabilities: ["list", "buy", "make_offer", "cancel"],
|
|
@@ -6662,6 +6802,9 @@ function getServicesByCapability(cap) {
|
|
|
6662
6802
|
}
|
|
6663
6803
|
|
|
6664
6804
|
exports.ApiClient = ApiClient;
|
|
6805
|
+
exports.CHAINS = CHAINS;
|
|
6806
|
+
exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
|
|
6807
|
+
exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
|
|
6665
6808
|
exports.COLLECTION_1155_CLASS_HASH_MAINNET = COLLECTION_1155_CLASS_HASH_MAINNET;
|
|
6666
6809
|
exports.COLLECTION_1155_CONTRACT_MAINNET = COLLECTION_1155_CONTRACT_MAINNET;
|
|
6667
6810
|
exports.COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET;
|
|
@@ -6676,7 +6819,7 @@ exports.CREATOR_COIN_START_BLOCK_MAINNET = CREATOR_COIN_START_BLOCK_MAINNET;
|
|
|
6676
6819
|
exports.CollectionRegistryABI = CollectionRegistryABI;
|
|
6677
6820
|
exports.CreatorCoinFactoryABI = CreatorCoinFactoryABI;
|
|
6678
6821
|
exports.CreatorCoinService = CreatorCoinService;
|
|
6679
|
-
exports.
|
|
6822
|
+
exports.DEFAULT_CHAIN = DEFAULT_CHAIN;
|
|
6680
6823
|
exports.DROP_COLLECTION_CLASS_HASH_MAINNET = DROP_COLLECTION_CLASS_HASH_MAINNET;
|
|
6681
6824
|
exports.DROP_FACTORY_CONTRACT_MAINNET = DROP_FACTORY_CONTRACT_MAINNET;
|
|
6682
6825
|
exports.DropCollectionABI = DropCollectionABI;
|
|
@@ -6692,6 +6835,7 @@ exports.IPCollectionABI = IPCollectionABI;
|
|
|
6692
6835
|
exports.IPMarketplaceABI = IPMarketplaceABI;
|
|
6693
6836
|
exports.IPNFT_CLASS_HASH_MAINNET = IPNFT_CLASS_HASH_MAINNET;
|
|
6694
6837
|
exports.IPNftABI = IPNftABI;
|
|
6838
|
+
exports.LAUNCH_PRICE_QUOTE_PER_COIN = LAUNCH_PRICE_QUOTE_PER_COIN;
|
|
6695
6839
|
exports.MARKETPLACE_1155_CLASS_HASH_MAINNET = MARKETPLACE_1155_CLASS_HASH_MAINNET;
|
|
6696
6840
|
exports.MARKETPLACE_1155_CONTRACT_MAINNET = MARKETPLACE_1155_CONTRACT_MAINNET;
|
|
6697
6841
|
exports.MARKETPLACE_1155_START_BLOCK_MAINNET = MARKETPLACE_1155_START_BLOCK_MAINNET;
|
|
@@ -6712,7 +6856,6 @@ exports.POP_COLLECTION_CLASS_HASH_MAINNET = POP_COLLECTION_CLASS_HASH_MAINNET;
|
|
|
6712
6856
|
exports.POP_FACTORY_CONTRACT_MAINNET = POP_FACTORY_CONTRACT_MAINNET;
|
|
6713
6857
|
exports.PUBLIC_RPC_FALLBACKS = PUBLIC_RPC_FALLBACKS;
|
|
6714
6858
|
exports.PopService = PopService;
|
|
6715
|
-
exports.SUPPORTED_NETWORKS = SUPPORTED_NETWORKS;
|
|
6716
6859
|
exports.SUPPORTED_TOKENS = SUPPORTED_TOKENS;
|
|
6717
6860
|
exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
|
|
6718
6861
|
exports.build1155CancellationTypedData = build1155CancellationTypedData;
|
|
@@ -6722,9 +6865,13 @@ exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
|
|
|
6722
6865
|
exports.buildFeeCall = buildFeeCall;
|
|
6723
6866
|
exports.buildLaunchOnEkuboCalls = buildLaunchOnEkuboCalls;
|
|
6724
6867
|
exports.buildOrderTypedData = buildOrderTypedData;
|
|
6868
|
+
exports.buybackQuoteRaw = buybackQuoteRaw;
|
|
6869
|
+
exports.coinToRaw = toRaw;
|
|
6725
6870
|
exports.createFailoverFetch = createFailoverFetch;
|
|
6726
6871
|
exports.encodeByteArray = encodeByteArray;
|
|
6872
|
+
exports.fdvHuman = fdvHuman;
|
|
6727
6873
|
exports.formatAmount = formatAmount;
|
|
6874
|
+
exports.getCoordinates = getCoordinates;
|
|
6728
6875
|
exports.getCreatorCoinPrice = getCreatorCoinPrice;
|
|
6729
6876
|
exports.getListableTokens = getListableTokens;
|
|
6730
6877
|
exports.getService = getService;
|
|
@@ -6742,6 +6889,10 @@ exports.resolveConfig = resolveConfig;
|
|
|
6742
6889
|
exports.resolveFeeConfig = resolveFeeConfig;
|
|
6743
6890
|
exports.shortenAddress = shortenAddress;
|
|
6744
6891
|
exports.stringifyBigInts = stringifyBigInts;
|
|
6892
|
+
exports.teamCoinsRaw = teamCoinsRaw;
|
|
6745
6893
|
exports.u256ToBigInt = u256ToBigInt;
|
|
6894
|
+
exports.validateCoinName = validateName;
|
|
6895
|
+
exports.validateCoinSupply = validateSupply;
|
|
6896
|
+
exports.validateCoinSymbol = validateSymbol;
|
|
6746
6897
|
//# sourceMappingURL=index.cjs.map
|
|
6747
6898
|
//# sourceMappingURL=index.cjs.map
|