@medialane/sdk 0.39.0 → 0.41.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 +174 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +131 -105
- package/dist/index.d.ts +131 -105
- package/dist/index.js +164 -98
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1109,44 +1109,6 @@ var DropFactoryABI = [
|
|
|
1109
1109
|
}
|
|
1110
1110
|
];
|
|
1111
1111
|
|
|
1112
|
-
// src/abis/collectionRegistry.ts
|
|
1113
|
-
var CollectionRegistryABI = [
|
|
1114
|
-
{
|
|
1115
|
-
type: "struct",
|
|
1116
|
-
name: "core::byte_array::ByteArray",
|
|
1117
|
-
members: [
|
|
1118
|
-
{ name: "data", type: "core::array::Array::<core::felt252>" },
|
|
1119
|
-
{ name: "pending_word", type: "core::felt252" },
|
|
1120
|
-
{ name: "pending_word_len", type: "core::integer::u32" }
|
|
1121
|
-
]
|
|
1122
|
-
},
|
|
1123
|
-
{
|
|
1124
|
-
type: "struct",
|
|
1125
|
-
name: "ip_collection_erc_721::types::Collection",
|
|
1126
|
-
members: [
|
|
1127
|
-
{ name: "name", type: "core::byte_array::ByteArray" },
|
|
1128
|
-
{ name: "symbol", type: "core::byte_array::ByteArray" },
|
|
1129
|
-
{ name: "base_uri", type: "core::byte_array::ByteArray" },
|
|
1130
|
-
{ name: "owner", type: "core::starknet::contract_address::ContractAddress" },
|
|
1131
|
-
{ name: "ip_nft", type: "core::starknet::contract_address::ContractAddress" }
|
|
1132
|
-
]
|
|
1133
|
-
},
|
|
1134
|
-
{
|
|
1135
|
-
type: "function",
|
|
1136
|
-
name: "list_user_collections",
|
|
1137
|
-
inputs: [{ name: "user", type: "core::starknet::contract_address::ContractAddress" }],
|
|
1138
|
-
outputs: [{ type: "core::array::Span::<core::integer::u256>" }],
|
|
1139
|
-
state_mutability: "view"
|
|
1140
|
-
},
|
|
1141
|
-
{
|
|
1142
|
-
type: "function",
|
|
1143
|
-
name: "get_collection",
|
|
1144
|
-
inputs: [{ name: "collection_id", type: "core::integer::u256" }],
|
|
1145
|
-
outputs: [{ type: "ip_collection_erc_721::types::Collection" }],
|
|
1146
|
-
state_mutability: "view"
|
|
1147
|
-
}
|
|
1148
|
-
];
|
|
1149
|
-
|
|
1150
1112
|
// src/abis/medialane1155.ts
|
|
1151
1113
|
var Medialane1155ABI = [
|
|
1152
1114
|
{
|
|
@@ -4672,20 +4634,6 @@ var IPNftABI = [
|
|
|
4672
4634
|
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" }] }];
|
|
4673
4635
|
|
|
4674
4636
|
// src/constants.ts
|
|
4675
|
-
var SN = getCoordinates("STARKNET");
|
|
4676
|
-
var MARKETPLACE_721_CONTRACT_MAINNET = SN.marketplace721;
|
|
4677
|
-
var MARKETPLACE_721_CLASS_HASH_MAINNET = SN.marketplace721ClassHash;
|
|
4678
|
-
var MARKETPLACE_721_START_BLOCK_MAINNET = SN.marketplace721StartBlock;
|
|
4679
|
-
var MARKETPLACE_1155_CONTRACT_MAINNET = SN.marketplace1155;
|
|
4680
|
-
var MARKETPLACE_1155_CLASS_HASH_MAINNET = SN.marketplace1155ClassHash;
|
|
4681
|
-
var MARKETPLACE_1155_START_BLOCK_MAINNET = SN.marketplace1155StartBlock;
|
|
4682
|
-
var COLLECTION_721_CONTRACT_MAINNET = SN.collection721;
|
|
4683
|
-
var IPNFT_CLASS_HASH_MAINNET = SN.ipNftClassHash;
|
|
4684
|
-
var IPCOLLECTION_CLASS_HASH_MAINNET = SN.ipCollectionClassHash;
|
|
4685
|
-
var COLLECTION_721_START_BLOCK_MAINNET = SN.collection721StartBlock;
|
|
4686
|
-
var DROP_FACTORY_CONTRACT_MAINNET = SN.dropFactory;
|
|
4687
|
-
var POP_FACTORY_CONTRACT_MAINNET = SN.popFactory;
|
|
4688
|
-
var NFTCOMMENTS_CONTRACT_MAINNET = SN.nftComments;
|
|
4689
4637
|
var SUPPORTED_TOKENS = [
|
|
4690
4638
|
{
|
|
4691
4639
|
// Circle-native USDC on Starknet (canonical)
|
|
@@ -4720,18 +4668,6 @@ var SUPPORTED_TOKENS = [
|
|
|
4720
4668
|
}
|
|
4721
4669
|
];
|
|
4722
4670
|
var DEFAULT_CURRENCY = "USDC";
|
|
4723
|
-
var POP_COLLECTION_CLASS_HASH_MAINNET = SN.popCollectionClassHash;
|
|
4724
|
-
var DROP_COLLECTION_CLASS_HASH_MAINNET = SN.dropCollectionClassHash;
|
|
4725
|
-
var COLLECTION_1155_CONTRACT_MAINNET = SN.collection1155;
|
|
4726
|
-
var COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = SN.collection1155FactoryClassHash;
|
|
4727
|
-
var COLLECTION_1155_CLASS_HASH_MAINNET = SN.collection1155ClassHash;
|
|
4728
|
-
var COLLECTION_1155_START_BLOCK_MAINNET = SN.collection1155StartBlock;
|
|
4729
|
-
var CREATOR_COIN_FACTORY_CONTRACT_MAINNET = SN.creatorCoinFactory;
|
|
4730
|
-
var CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = SN.creatorCoinEkuboLauncher;
|
|
4731
|
-
var CREATOR_COIN_CLASS_HASH_MAINNET = SN.creatorCoinClassHash;
|
|
4732
|
-
var CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = SN.creatorCoinFactoryClassHash;
|
|
4733
|
-
var CREATOR_COIN_START_BLOCK_MAINNET = SN.creatorCoinStartBlock;
|
|
4734
|
-
var EKUBO_CORE_MAINNET = SN.ekuboCore;
|
|
4735
4671
|
|
|
4736
4672
|
// src/utils/bigint.ts
|
|
4737
4673
|
function stringifyBigInts(obj) {
|
|
@@ -5625,10 +5561,10 @@ function normalizeEvm(address) {
|
|
|
5625
5561
|
const m = /^0x([0-9a-fA-F]{40})$/.exec(address);
|
|
5626
5562
|
if (!m) throw new Error(`Invalid ETHEREUM/BASE address: "${address}"`);
|
|
5627
5563
|
const lower = m[1].toLowerCase();
|
|
5628
|
-
const
|
|
5564
|
+
const hash4 = sha3_js.keccak_256(new TextEncoder().encode(lower));
|
|
5629
5565
|
let out = "0x";
|
|
5630
5566
|
for (let i = 0; i < 40; i++) {
|
|
5631
|
-
const nibble =
|
|
5567
|
+
const nibble = hash4[i >> 1] >> (i % 2 === 0 ? 4 : 0) & 15;
|
|
5632
5568
|
out += nibble >= 8 ? lower[i].toUpperCase() : lower[i];
|
|
5633
5569
|
}
|
|
5634
5570
|
return out;
|
|
@@ -5642,12 +5578,12 @@ function normalizeSolana(address) {
|
|
|
5642
5578
|
throw new Error(`Invalid SOLANA address: "${address}"`);
|
|
5643
5579
|
}
|
|
5644
5580
|
}
|
|
5645
|
-
function normalizeHash(
|
|
5581
|
+
function normalizeHash(hash4) {
|
|
5646
5582
|
try {
|
|
5647
|
-
const hex = starknet.num.toHex(BigInt(
|
|
5583
|
+
const hex = starknet.num.toHex(BigInt(hash4));
|
|
5648
5584
|
return "0x" + hex.slice(2).padStart(64, "0").toLowerCase();
|
|
5649
5585
|
} catch {
|
|
5650
|
-
throw new Error(`Invalid hash: "${
|
|
5586
|
+
throw new Error(`Invalid hash: "${hash4}"`);
|
|
5651
5587
|
}
|
|
5652
5588
|
}
|
|
5653
5589
|
function shortenAddress(chain, address, chars = 4) {
|
|
@@ -6273,8 +6209,8 @@ var ApiClient = class {
|
|
|
6273
6209
|
}
|
|
6274
6210
|
};
|
|
6275
6211
|
var PopService = class {
|
|
6276
|
-
constructor(
|
|
6277
|
-
this.factoryAddress =
|
|
6212
|
+
constructor(config) {
|
|
6213
|
+
this.factoryAddress = getCoordinates(config.chain).popFactory;
|
|
6278
6214
|
}
|
|
6279
6215
|
_collection(address, account) {
|
|
6280
6216
|
return new starknet.Contract(POPCollectionABI, normalizeAddress("STARKNET", address), account);
|
|
@@ -6349,7 +6285,7 @@ function toContractConditions(c) {
|
|
|
6349
6285
|
}
|
|
6350
6286
|
var DropService = class {
|
|
6351
6287
|
constructor(config) {
|
|
6352
|
-
this.factoryAddress =
|
|
6288
|
+
this.factoryAddress = getCoordinates(config.chain).dropFactory;
|
|
6353
6289
|
this.config = config;
|
|
6354
6290
|
}
|
|
6355
6291
|
_collection(address, account) {
|
|
@@ -6431,7 +6367,7 @@ var DropService = class {
|
|
|
6431
6367
|
};
|
|
6432
6368
|
var ERC1155CollectionService = class {
|
|
6433
6369
|
constructor(config) {
|
|
6434
|
-
this.factoryAddress = config.collection1155Contract ??
|
|
6370
|
+
this.factoryAddress = config.collection1155Contract ?? getCoordinates(config.chain).collection1155;
|
|
6435
6371
|
}
|
|
6436
6372
|
_factory(account) {
|
|
6437
6373
|
return new starknet.Contract(
|
|
@@ -6573,7 +6509,7 @@ async function getCreatorCoinPrice(coinAddress, provider) {
|
|
|
6573
6509
|
const [t0, t1] = ci < qi ? [coinAddress, quoteToken] : [quoteToken, coinAddress];
|
|
6574
6510
|
const quoteIsToken0 = qi === BigInt(t0);
|
|
6575
6511
|
const pp = await provider.callContract({
|
|
6576
|
-
contractAddress:
|
|
6512
|
+
contractAddress: getCoordinates("STARKNET").ekuboCore,
|
|
6577
6513
|
entrypoint: "get_pool_price",
|
|
6578
6514
|
calldata: [t0, t1, fee, tickSpacing, "0x0"]
|
|
6579
6515
|
});
|
|
@@ -6588,7 +6524,7 @@ function factoryContract() {
|
|
|
6588
6524
|
if (!_factoryContract) {
|
|
6589
6525
|
_factoryContract = new starknet.Contract(
|
|
6590
6526
|
CreatorCoinFactoryABI,
|
|
6591
|
-
|
|
6527
|
+
getCoordinates("STARKNET").creatorCoinFactory
|
|
6592
6528
|
);
|
|
6593
6529
|
}
|
|
6594
6530
|
return _factoryContract;
|
|
@@ -6625,7 +6561,7 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
6625
6561
|
calls.push({
|
|
6626
6562
|
contractAddress: params.quoteToken,
|
|
6627
6563
|
entrypoint: "transfer",
|
|
6628
|
-
calldata: [
|
|
6564
|
+
calldata: [getCoordinates("STARKNET").creatorCoinFactory, amt.low, amt.high]
|
|
6629
6565
|
});
|
|
6630
6566
|
}
|
|
6631
6567
|
calls.push(factoryContract().populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
|
|
@@ -6633,7 +6569,7 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
6633
6569
|
}
|
|
6634
6570
|
var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
|
|
6635
6571
|
function parseCreatorCoinCreated(receipt) {
|
|
6636
|
-
const factory = normalizeAddress("STARKNET",
|
|
6572
|
+
const factory = normalizeAddress("STARKNET", getCoordinates("STARKNET").creatorCoinFactory);
|
|
6637
6573
|
for (const ev of receipt?.events ?? []) {
|
|
6638
6574
|
let from;
|
|
6639
6575
|
try {
|
|
@@ -6652,7 +6588,7 @@ function parseCreatorCoinCreated(receipt) {
|
|
|
6652
6588
|
}
|
|
6653
6589
|
var CreatorCoinService = class {
|
|
6654
6590
|
constructor(config) {
|
|
6655
|
-
this.factoryAddress =
|
|
6591
|
+
this.factoryAddress = getCoordinates(config.chain).creatorCoinFactory;
|
|
6656
6592
|
this.config = config;
|
|
6657
6593
|
}
|
|
6658
6594
|
_factory(account) {
|
|
@@ -6730,6 +6666,135 @@ var MedialaneClient = class {
|
|
|
6730
6666
|
}
|
|
6731
6667
|
};
|
|
6732
6668
|
|
|
6669
|
+
// src/admin-auth/types.ts
|
|
6670
|
+
var ADMIN_SCOPE = "admin-api";
|
|
6671
|
+
function adminRequestDigest(req) {
|
|
6672
|
+
return starknet.hash.computePoseidonHashOnElements([
|
|
6673
|
+
starknet.hash.starknetKeccak(req.method.toUpperCase()),
|
|
6674
|
+
starknet.hash.starknetKeccak(req.path),
|
|
6675
|
+
starknet.hash.starknetKeccak(req.body ?? ""),
|
|
6676
|
+
starknet.num.toBigInt(req.nonce),
|
|
6677
|
+
BigInt(req.ts)
|
|
6678
|
+
]);
|
|
6679
|
+
}
|
|
6680
|
+
function signAdminRequest(sessionPrivateKey, req) {
|
|
6681
|
+
const digest = adminRequestDigest(req);
|
|
6682
|
+
return starknet.ec.starkCurve.sign(digest, sessionPrivateKey).toCompactHex();
|
|
6683
|
+
}
|
|
6684
|
+
function verifyAdminRequestSig(sessionPublicKey, req, sig) {
|
|
6685
|
+
try {
|
|
6686
|
+
return starknet.ec.starkCurve.verify(sig, adminRequestDigest(req), sessionPublicKey);
|
|
6687
|
+
} catch {
|
|
6688
|
+
return false;
|
|
6689
|
+
}
|
|
6690
|
+
}
|
|
6691
|
+
function buildAdminSessionTypedData(p) {
|
|
6692
|
+
return {
|
|
6693
|
+
types: {
|
|
6694
|
+
StarknetDomain: [
|
|
6695
|
+
{ name: "name", type: "shortstring" },
|
|
6696
|
+
{ name: "version", type: "shortstring" },
|
|
6697
|
+
{ name: "chainId", type: "shortstring" },
|
|
6698
|
+
{ name: "revision", type: "shortstring" }
|
|
6699
|
+
],
|
|
6700
|
+
AdminSession: [
|
|
6701
|
+
{ name: "sessionKeyHash", type: "felt" },
|
|
6702
|
+
{ name: "scope", type: "shortstring" },
|
|
6703
|
+
{ name: "issuedAt", type: "felt" },
|
|
6704
|
+
{ name: "expiresAt", type: "felt" }
|
|
6705
|
+
]
|
|
6706
|
+
},
|
|
6707
|
+
primaryType: "AdminSession",
|
|
6708
|
+
domain: { name: "Medialane Admin", version: "1", chainId: p.chainId ?? "SN_MAIN", revision: "1" },
|
|
6709
|
+
message: {
|
|
6710
|
+
sessionKeyHash: p.sessionKeyHash,
|
|
6711
|
+
scope: p.scope,
|
|
6712
|
+
issuedAt: String(p.issuedAt),
|
|
6713
|
+
expiresAt: String(p.expiresAt)
|
|
6714
|
+
}
|
|
6715
|
+
};
|
|
6716
|
+
}
|
|
6717
|
+
function sessionKeyHashOf(sessionPublicKey) {
|
|
6718
|
+
return starknet.num.toHex(starknet.hash.starknetKeccak(sessionPublicKey));
|
|
6719
|
+
}
|
|
6720
|
+
async function createAdminSessionGrant(signTypedData, opts) {
|
|
6721
|
+
const priv = starknet.ec.starkCurve.utils.randomPrivateKey();
|
|
6722
|
+
const sessionPrivateKey = "0x" + starknet.encode.buf2hex(priv);
|
|
6723
|
+
const sessionPublicKey = "0x" + starknet.encode.buf2hex(starknet.ec.starkCurve.getPublicKey(sessionPrivateKey, false));
|
|
6724
|
+
const sessionKeyHash = sessionKeyHashOf(sessionPublicKey);
|
|
6725
|
+
const nowSec = Math.floor((opts.now?.() ?? Date.now()) / 1e3);
|
|
6726
|
+
const issuedAt = nowSec;
|
|
6727
|
+
const expiresAt = nowSec + (opts.ttlSeconds ?? 7200);
|
|
6728
|
+
const data = buildAdminSessionTypedData({ sessionKeyHash, scope: ADMIN_SCOPE, issuedAt, expiresAt, chainId: opts.chainId });
|
|
6729
|
+
const walletSig = await signTypedData(data);
|
|
6730
|
+
const grant = {
|
|
6731
|
+
wallet: opts.wallet,
|
|
6732
|
+
chain: opts.chain ?? "STARKNET",
|
|
6733
|
+
sessionPublicKey,
|
|
6734
|
+
sessionKeyHash,
|
|
6735
|
+
scope: ADMIN_SCOPE,
|
|
6736
|
+
issuedAt,
|
|
6737
|
+
expiresAt,
|
|
6738
|
+
walletSig
|
|
6739
|
+
};
|
|
6740
|
+
return { grant, sessionPrivateKey };
|
|
6741
|
+
}
|
|
6742
|
+
|
|
6743
|
+
// src/admin-auth/headers.ts
|
|
6744
|
+
var ADMIN_HEADERS = {
|
|
6745
|
+
grant: "x-ml-admin-grant",
|
|
6746
|
+
sig: "x-ml-admin-sig",
|
|
6747
|
+
nonce: "x-ml-admin-nonce",
|
|
6748
|
+
ts: "x-ml-admin-ts"
|
|
6749
|
+
};
|
|
6750
|
+
function b64urlEncode(s) {
|
|
6751
|
+
const bytes = new TextEncoder().encode(s);
|
|
6752
|
+
let bin = "";
|
|
6753
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
6754
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
6755
|
+
}
|
|
6756
|
+
function b64urlDecode(s) {
|
|
6757
|
+
const pad = s.length % 4 ? "=".repeat(4 - s.length % 4) : "";
|
|
6758
|
+
const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + pad);
|
|
6759
|
+
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
6760
|
+
return new TextDecoder().decode(bytes);
|
|
6761
|
+
}
|
|
6762
|
+
function randomNonce() {
|
|
6763
|
+
const b = new Uint8Array(16);
|
|
6764
|
+
crypto.getRandomValues(b);
|
|
6765
|
+
let hex = "";
|
|
6766
|
+
for (const x of b) hex += x.toString(16).padStart(2, "0");
|
|
6767
|
+
return "0x" + hex;
|
|
6768
|
+
}
|
|
6769
|
+
function encodeAdminHeaders(session, reqInit) {
|
|
6770
|
+
const nonce = randomNonce();
|
|
6771
|
+
const ts = Math.floor((reqInit.now?.() ?? Date.now()) / 1e3);
|
|
6772
|
+
const req = { method: reqInit.method, path: reqInit.path, body: reqInit.body ?? "", nonce, ts };
|
|
6773
|
+
const sig = signAdminRequest(session.sessionPrivateKey, req);
|
|
6774
|
+
return {
|
|
6775
|
+
[ADMIN_HEADERS.grant]: b64urlEncode(JSON.stringify(session.grant)),
|
|
6776
|
+
[ADMIN_HEADERS.sig]: sig,
|
|
6777
|
+
[ADMIN_HEADERS.nonce]: nonce,
|
|
6778
|
+
[ADMIN_HEADERS.ts]: String(ts)
|
|
6779
|
+
};
|
|
6780
|
+
}
|
|
6781
|
+
function parseAdminHeaders(get) {
|
|
6782
|
+
const rawGrant = get(ADMIN_HEADERS.grant);
|
|
6783
|
+
const sig = get(ADMIN_HEADERS.sig);
|
|
6784
|
+
const nonce = get(ADMIN_HEADERS.nonce);
|
|
6785
|
+
const tsRaw = get(ADMIN_HEADERS.ts);
|
|
6786
|
+
if (!rawGrant || !sig || !nonce || !tsRaw) return null;
|
|
6787
|
+
try {
|
|
6788
|
+
const grant = JSON.parse(b64urlDecode(rawGrant));
|
|
6789
|
+
if (!grant.wallet || !grant.sessionPublicKey || !grant.sessionKeyHash || !Array.isArray(grant.walletSig) || typeof grant.expiresAt !== "number") return null;
|
|
6790
|
+
const ts = Number(tsRaw);
|
|
6791
|
+
if (!Number.isFinite(ts)) return null;
|
|
6792
|
+
return { grant, sig, nonce, ts };
|
|
6793
|
+
} catch {
|
|
6794
|
+
return null;
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
|
|
6733
6798
|
// src/types/api.ts
|
|
6734
6799
|
var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
|
|
6735
6800
|
|
|
@@ -6774,6 +6839,7 @@ function fdvHuman(supplyHuman) {
|
|
|
6774
6839
|
}
|
|
6775
6840
|
|
|
6776
6841
|
// src/services/registry.ts
|
|
6842
|
+
var SN = getCoordinates("STARKNET");
|
|
6777
6843
|
var SERVICES = {
|
|
6778
6844
|
"mip-erc721": {
|
|
6779
6845
|
id: "mip-erc721",
|
|
@@ -6783,8 +6849,8 @@ var SERVICES = {
|
|
|
6783
6849
|
provenance: "MEDIALANE",
|
|
6784
6850
|
onchain: {
|
|
6785
6851
|
STARKNET: {
|
|
6786
|
-
factoryAddress:
|
|
6787
|
-
startBlock:
|
|
6852
|
+
factoryAddress: SN.collection721,
|
|
6853
|
+
startBlock: SN.collection721StartBlock
|
|
6788
6854
|
}
|
|
6789
6855
|
},
|
|
6790
6856
|
uiVariant: "standard",
|
|
@@ -6818,9 +6884,9 @@ var SERVICES = {
|
|
|
6818
6884
|
provenance: "MEDIALANE",
|
|
6819
6885
|
onchain: {
|
|
6820
6886
|
STARKNET: {
|
|
6821
|
-
factoryAddress:
|
|
6822
|
-
classHash:
|
|
6823
|
-
startBlock:
|
|
6887
|
+
factoryAddress: SN.collection1155,
|
|
6888
|
+
classHash: SN.collection1155ClassHash,
|
|
6889
|
+
startBlock: SN.collection1155StartBlock
|
|
6824
6890
|
}
|
|
6825
6891
|
},
|
|
6826
6892
|
uiVariant: "edition",
|
|
@@ -6838,8 +6904,8 @@ var SERVICES = {
|
|
|
6838
6904
|
provenance: "MEDIALANE",
|
|
6839
6905
|
onchain: {
|
|
6840
6906
|
STARKNET: {
|
|
6841
|
-
factoryAddress:
|
|
6842
|
-
classHash:
|
|
6907
|
+
factoryAddress: SN.popFactory,
|
|
6908
|
+
classHash: SN.popCollectionClassHash
|
|
6843
6909
|
}
|
|
6844
6910
|
},
|
|
6845
6911
|
uiVariant: "pop",
|
|
@@ -6858,8 +6924,8 @@ var SERVICES = {
|
|
|
6858
6924
|
provenance: "MEDIALANE",
|
|
6859
6925
|
onchain: {
|
|
6860
6926
|
STARKNET: {
|
|
6861
|
-
factoryAddress:
|
|
6862
|
-
classHash:
|
|
6927
|
+
factoryAddress: SN.dropFactory,
|
|
6928
|
+
classHash: SN.dropCollectionClassHash
|
|
6863
6929
|
}
|
|
6864
6930
|
},
|
|
6865
6931
|
uiVariant: "drop",
|
|
@@ -6878,9 +6944,9 @@ var SERVICES = {
|
|
|
6878
6944
|
provenance: "MEDIALANE",
|
|
6879
6945
|
onchain: {
|
|
6880
6946
|
STARKNET: {
|
|
6881
|
-
factoryAddress:
|
|
6882
|
-
classHash:
|
|
6883
|
-
startBlock:
|
|
6947
|
+
factoryAddress: SN.creatorCoinFactory,
|
|
6948
|
+
classHash: SN.creatorCoinFactoryClassHash,
|
|
6949
|
+
startBlock: SN.creatorCoinStartBlock
|
|
6884
6950
|
}
|
|
6885
6951
|
},
|
|
6886
6952
|
uiVariant: "coin",
|
|
@@ -6902,9 +6968,9 @@ var SERVICES = {
|
|
|
6902
6968
|
provenance: "MEDIALANE",
|
|
6903
6969
|
onchain: {
|
|
6904
6970
|
STARKNET: {
|
|
6905
|
-
factoryAddress:
|
|
6906
|
-
classHash:
|
|
6907
|
-
startBlock:
|
|
6971
|
+
factoryAddress: SN.marketplace721,
|
|
6972
|
+
classHash: SN.marketplace721ClassHash,
|
|
6973
|
+
startBlock: SN.marketplace721StartBlock
|
|
6908
6974
|
}
|
|
6909
6975
|
},
|
|
6910
6976
|
uiVariant: "standard",
|
|
@@ -6923,9 +6989,9 @@ var SERVICES = {
|
|
|
6923
6989
|
provenance: "MEDIALANE",
|
|
6924
6990
|
onchain: {
|
|
6925
6991
|
STARKNET: {
|
|
6926
|
-
factoryAddress:
|
|
6927
|
-
classHash:
|
|
6928
|
-
startBlock:
|
|
6992
|
+
factoryAddress: SN.marketplace1155,
|
|
6993
|
+
classHash: SN.marketplace1155ClassHash,
|
|
6994
|
+
startBlock: SN.marketplace1155StartBlock
|
|
6929
6995
|
}
|
|
6930
6996
|
},
|
|
6931
6997
|
uiVariant: "edition",
|
|
@@ -6979,65 +7045,44 @@ function getServicesByCapability(cap) {
|
|
|
6979
7045
|
);
|
|
6980
7046
|
}
|
|
6981
7047
|
|
|
7048
|
+
exports.ADMIN_HEADERS = ADMIN_HEADERS;
|
|
7049
|
+
exports.ADMIN_SCOPE = ADMIN_SCOPE;
|
|
6982
7050
|
exports.ApiClient = ApiClient;
|
|
6983
7051
|
exports.CHAINS = CHAINS;
|
|
6984
7052
|
exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
|
|
6985
7053
|
exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
|
|
6986
|
-
exports.COLLECTION_1155_CLASS_HASH_MAINNET = COLLECTION_1155_CLASS_HASH_MAINNET;
|
|
6987
|
-
exports.COLLECTION_1155_CONTRACT_MAINNET = COLLECTION_1155_CONTRACT_MAINNET;
|
|
6988
|
-
exports.COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET;
|
|
6989
|
-
exports.COLLECTION_1155_START_BLOCK_MAINNET = COLLECTION_1155_START_BLOCK_MAINNET;
|
|
6990
|
-
exports.COLLECTION_721_CONTRACT_MAINNET = COLLECTION_721_CONTRACT_MAINNET;
|
|
6991
|
-
exports.COLLECTION_721_START_BLOCK_MAINNET = COLLECTION_721_START_BLOCK_MAINNET;
|
|
6992
|
-
exports.CREATOR_COIN_CLASS_HASH_MAINNET = CREATOR_COIN_CLASS_HASH_MAINNET;
|
|
6993
|
-
exports.CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = CREATOR_COIN_EKUBO_LAUNCHER_MAINNET;
|
|
6994
|
-
exports.CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET;
|
|
6995
|
-
exports.CREATOR_COIN_FACTORY_CONTRACT_MAINNET = CREATOR_COIN_FACTORY_CONTRACT_MAINNET;
|
|
6996
|
-
exports.CREATOR_COIN_START_BLOCK_MAINNET = CREATOR_COIN_START_BLOCK_MAINNET;
|
|
6997
|
-
exports.CollectionRegistryABI = CollectionRegistryABI;
|
|
6998
7054
|
exports.CreatorCoinFactoryABI = CreatorCoinFactoryABI;
|
|
6999
7055
|
exports.CreatorCoinService = CreatorCoinService;
|
|
7000
7056
|
exports.DEFAULT_CHAIN = DEFAULT_CHAIN;
|
|
7001
|
-
exports.
|
|
7002
|
-
exports.DROP_FACTORY_CONTRACT_MAINNET = DROP_FACTORY_CONTRACT_MAINNET;
|
|
7057
|
+
exports.DEFAULT_CURRENCY = DEFAULT_CURRENCY;
|
|
7003
7058
|
exports.DropCollectionABI = DropCollectionABI;
|
|
7004
7059
|
exports.DropFactoryABI = DropFactoryABI;
|
|
7005
7060
|
exports.DropService = DropService;
|
|
7006
|
-
exports.EKUBO_CORE_MAINNET = EKUBO_CORE_MAINNET;
|
|
7007
7061
|
exports.ERC1155CollectionService = ERC1155CollectionService;
|
|
7008
7062
|
exports.FeeConfigSchema = FeeConfigSchema;
|
|
7009
|
-
exports.IPCOLLECTION_CLASS_HASH_MAINNET = IPCOLLECTION_CLASS_HASH_MAINNET;
|
|
7010
7063
|
exports.IPCollection1155ABI = IPCollection1155ABI;
|
|
7011
7064
|
exports.IPCollection1155FactoryABI = IPCollection1155FactoryABI;
|
|
7012
7065
|
exports.IPCollectionABI = IPCollectionABI;
|
|
7013
7066
|
exports.IPMarketplaceABI = IPMarketplaceABI;
|
|
7014
|
-
exports.IPNFT_CLASS_HASH_MAINNET = IPNFT_CLASS_HASH_MAINNET;
|
|
7015
7067
|
exports.IPNftABI = IPNftABI;
|
|
7016
7068
|
exports.LAUNCH_PRICE_QUOTE_PER_COIN = LAUNCH_PRICE_QUOTE_PER_COIN;
|
|
7017
|
-
exports.MARKETPLACE_1155_CLASS_HASH_MAINNET = MARKETPLACE_1155_CLASS_HASH_MAINNET;
|
|
7018
|
-
exports.MARKETPLACE_1155_CONTRACT_MAINNET = MARKETPLACE_1155_CONTRACT_MAINNET;
|
|
7019
|
-
exports.MARKETPLACE_1155_START_BLOCK_MAINNET = MARKETPLACE_1155_START_BLOCK_MAINNET;
|
|
7020
|
-
exports.MARKETPLACE_721_CLASS_HASH_MAINNET = MARKETPLACE_721_CLASS_HASH_MAINNET;
|
|
7021
|
-
exports.MARKETPLACE_721_CONTRACT_MAINNET = MARKETPLACE_721_CONTRACT_MAINNET;
|
|
7022
|
-
exports.MARKETPLACE_721_START_BLOCK_MAINNET = MARKETPLACE_721_START_BLOCK_MAINNET;
|
|
7023
7069
|
exports.MarketplaceModule = MarketplaceModule;
|
|
7024
7070
|
exports.Medialane1155ABI = Medialane1155ABI;
|
|
7025
7071
|
exports.Medialane1155Module = Medialane1155Module;
|
|
7026
7072
|
exports.MedialaneApiError = MedialaneApiError;
|
|
7027
7073
|
exports.MedialaneClient = MedialaneClient;
|
|
7028
7074
|
exports.MedialaneError = MedialaneError;
|
|
7029
|
-
exports.NFTCOMMENTS_CONTRACT_MAINNET = NFTCOMMENTS_CONTRACT_MAINNET;
|
|
7030
7075
|
exports.OPEN_LICENSES = OPEN_LICENSES;
|
|
7031
7076
|
exports.POPCollectionABI = POPCollectionABI;
|
|
7032
7077
|
exports.POPFactoryABI = POPFactoryABI;
|
|
7033
|
-
exports.POP_COLLECTION_CLASS_HASH_MAINNET = POP_COLLECTION_CLASS_HASH_MAINNET;
|
|
7034
|
-
exports.POP_FACTORY_CONTRACT_MAINNET = POP_FACTORY_CONTRACT_MAINNET;
|
|
7035
7078
|
exports.PUBLIC_RPC_FALLBACKS = PUBLIC_RPC_FALLBACKS;
|
|
7036
7079
|
exports.PopService = PopService;
|
|
7037
7080
|
exports.SUPPORTED_TOKENS = SUPPORTED_TOKENS;
|
|
7038
7081
|
exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
|
|
7082
|
+
exports.adminRequestDigest = adminRequestDigest;
|
|
7039
7083
|
exports.build1155CancellationTypedData = build1155CancellationTypedData;
|
|
7040
7084
|
exports.build1155OrderTypedData = build1155OrderTypedData;
|
|
7085
|
+
exports.buildAdminSessionTypedData = buildAdminSessionTypedData;
|
|
7041
7086
|
exports.buildCancellationTypedData = buildCancellationTypedData;
|
|
7042
7087
|
exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
|
|
7043
7088
|
exports.buildFeeCall = buildFeeCall;
|
|
@@ -7045,7 +7090,9 @@ exports.buildLaunchOnEkuboCalls = buildLaunchOnEkuboCalls;
|
|
|
7045
7090
|
exports.buildOrderTypedData = buildOrderTypedData;
|
|
7046
7091
|
exports.buybackQuoteRaw = buybackQuoteRaw;
|
|
7047
7092
|
exports.coinToRaw = toRaw;
|
|
7093
|
+
exports.createAdminSessionGrant = createAdminSessionGrant;
|
|
7048
7094
|
exports.createFailoverFetch = createFailoverFetch;
|
|
7095
|
+
exports.encodeAdminHeaders = encodeAdminHeaders;
|
|
7049
7096
|
exports.encodeByteArray = encodeByteArray;
|
|
7050
7097
|
exports.fdvHuman = fdvHuman;
|
|
7051
7098
|
exports.formatAmount = formatAmount;
|
|
@@ -7061,16 +7108,21 @@ exports.isTransientRpcError = isTransientRpcError;
|
|
|
7061
7108
|
exports.listServices = listServices;
|
|
7062
7109
|
exports.normalizeAddress = normalizeAddress;
|
|
7063
7110
|
exports.normalizeHash = normalizeHash;
|
|
7111
|
+
exports.parseAdminHeaders = parseAdminHeaders;
|
|
7064
7112
|
exports.parseAmount = parseAmount;
|
|
7065
7113
|
exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
|
|
7114
|
+
exports.randomNonce = randomNonce;
|
|
7066
7115
|
exports.resolveConfig = resolveConfig;
|
|
7067
7116
|
exports.resolveFeeConfig = resolveFeeConfig;
|
|
7117
|
+
exports.sessionKeyHashOf = sessionKeyHashOf;
|
|
7068
7118
|
exports.shortenAddress = shortenAddress;
|
|
7119
|
+
exports.signAdminRequest = signAdminRequest;
|
|
7069
7120
|
exports.stringifyBigInts = stringifyBigInts;
|
|
7070
7121
|
exports.teamCoinsRaw = teamCoinsRaw;
|
|
7071
7122
|
exports.u256ToBigInt = u256ToBigInt;
|
|
7072
7123
|
exports.validateCoinName = validateName;
|
|
7073
7124
|
exports.validateCoinSupply = validateSupply;
|
|
7074
7125
|
exports.validateCoinSymbol = validateSymbol;
|
|
7126
|
+
exports.verifyAdminRequestSig = verifyAdminRequestSig;
|
|
7075
7127
|
//# sourceMappingURL=index.cjs.map
|
|
7076
7128
|
//# sourceMappingURL=index.cjs.map
|