@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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { hash, cairo, num, Contract, uint256, RpcProvider, TypedDataRevision, shortString, constants } from 'starknet';
|
|
2
|
+
import { hash, cairo, num, Contract, uint256, RpcProvider, ec, encode, TypedDataRevision, shortString, constants } from 'starknet';
|
|
3
3
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
|
|
@@ -1107,44 +1107,6 @@ var DropFactoryABI = [
|
|
|
1107
1107
|
}
|
|
1108
1108
|
];
|
|
1109
1109
|
|
|
1110
|
-
// src/abis/collectionRegistry.ts
|
|
1111
|
-
var CollectionRegistryABI = [
|
|
1112
|
-
{
|
|
1113
|
-
type: "struct",
|
|
1114
|
-
name: "core::byte_array::ByteArray",
|
|
1115
|
-
members: [
|
|
1116
|
-
{ name: "data", type: "core::array::Array::<core::felt252>" },
|
|
1117
|
-
{ name: "pending_word", type: "core::felt252" },
|
|
1118
|
-
{ name: "pending_word_len", type: "core::integer::u32" }
|
|
1119
|
-
]
|
|
1120
|
-
},
|
|
1121
|
-
{
|
|
1122
|
-
type: "struct",
|
|
1123
|
-
name: "ip_collection_erc_721::types::Collection",
|
|
1124
|
-
members: [
|
|
1125
|
-
{ name: "name", type: "core::byte_array::ByteArray" },
|
|
1126
|
-
{ name: "symbol", type: "core::byte_array::ByteArray" },
|
|
1127
|
-
{ name: "base_uri", type: "core::byte_array::ByteArray" },
|
|
1128
|
-
{ name: "owner", type: "core::starknet::contract_address::ContractAddress" },
|
|
1129
|
-
{ name: "ip_nft", type: "core::starknet::contract_address::ContractAddress" }
|
|
1130
|
-
]
|
|
1131
|
-
},
|
|
1132
|
-
{
|
|
1133
|
-
type: "function",
|
|
1134
|
-
name: "list_user_collections",
|
|
1135
|
-
inputs: [{ name: "user", type: "core::starknet::contract_address::ContractAddress" }],
|
|
1136
|
-
outputs: [{ type: "core::array::Span::<core::integer::u256>" }],
|
|
1137
|
-
state_mutability: "view"
|
|
1138
|
-
},
|
|
1139
|
-
{
|
|
1140
|
-
type: "function",
|
|
1141
|
-
name: "get_collection",
|
|
1142
|
-
inputs: [{ name: "collection_id", type: "core::integer::u256" }],
|
|
1143
|
-
outputs: [{ type: "ip_collection_erc_721::types::Collection" }],
|
|
1144
|
-
state_mutability: "view"
|
|
1145
|
-
}
|
|
1146
|
-
];
|
|
1147
|
-
|
|
1148
1110
|
// src/abis/medialane1155.ts
|
|
1149
1111
|
var Medialane1155ABI = [
|
|
1150
1112
|
{
|
|
@@ -4670,20 +4632,6 @@ var IPNftABI = [
|
|
|
4670
4632
|
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" }] }];
|
|
4671
4633
|
|
|
4672
4634
|
// src/constants.ts
|
|
4673
|
-
var SN = getCoordinates("STARKNET");
|
|
4674
|
-
var MARKETPLACE_721_CONTRACT_MAINNET = SN.marketplace721;
|
|
4675
|
-
var MARKETPLACE_721_CLASS_HASH_MAINNET = SN.marketplace721ClassHash;
|
|
4676
|
-
var MARKETPLACE_721_START_BLOCK_MAINNET = SN.marketplace721StartBlock;
|
|
4677
|
-
var MARKETPLACE_1155_CONTRACT_MAINNET = SN.marketplace1155;
|
|
4678
|
-
var MARKETPLACE_1155_CLASS_HASH_MAINNET = SN.marketplace1155ClassHash;
|
|
4679
|
-
var MARKETPLACE_1155_START_BLOCK_MAINNET = SN.marketplace1155StartBlock;
|
|
4680
|
-
var COLLECTION_721_CONTRACT_MAINNET = SN.collection721;
|
|
4681
|
-
var IPNFT_CLASS_HASH_MAINNET = SN.ipNftClassHash;
|
|
4682
|
-
var IPCOLLECTION_CLASS_HASH_MAINNET = SN.ipCollectionClassHash;
|
|
4683
|
-
var COLLECTION_721_START_BLOCK_MAINNET = SN.collection721StartBlock;
|
|
4684
|
-
var DROP_FACTORY_CONTRACT_MAINNET = SN.dropFactory;
|
|
4685
|
-
var POP_FACTORY_CONTRACT_MAINNET = SN.popFactory;
|
|
4686
|
-
var NFTCOMMENTS_CONTRACT_MAINNET = SN.nftComments;
|
|
4687
4635
|
var SUPPORTED_TOKENS = [
|
|
4688
4636
|
{
|
|
4689
4637
|
// Circle-native USDC on Starknet (canonical)
|
|
@@ -4718,18 +4666,6 @@ var SUPPORTED_TOKENS = [
|
|
|
4718
4666
|
}
|
|
4719
4667
|
];
|
|
4720
4668
|
var DEFAULT_CURRENCY = "USDC";
|
|
4721
|
-
var POP_COLLECTION_CLASS_HASH_MAINNET = SN.popCollectionClassHash;
|
|
4722
|
-
var DROP_COLLECTION_CLASS_HASH_MAINNET = SN.dropCollectionClassHash;
|
|
4723
|
-
var COLLECTION_1155_CONTRACT_MAINNET = SN.collection1155;
|
|
4724
|
-
var COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = SN.collection1155FactoryClassHash;
|
|
4725
|
-
var COLLECTION_1155_CLASS_HASH_MAINNET = SN.collection1155ClassHash;
|
|
4726
|
-
var COLLECTION_1155_START_BLOCK_MAINNET = SN.collection1155StartBlock;
|
|
4727
|
-
var CREATOR_COIN_FACTORY_CONTRACT_MAINNET = SN.creatorCoinFactory;
|
|
4728
|
-
var CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = SN.creatorCoinEkuboLauncher;
|
|
4729
|
-
var CREATOR_COIN_CLASS_HASH_MAINNET = SN.creatorCoinClassHash;
|
|
4730
|
-
var CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET = SN.creatorCoinFactoryClassHash;
|
|
4731
|
-
var CREATOR_COIN_START_BLOCK_MAINNET = SN.creatorCoinStartBlock;
|
|
4732
|
-
var EKUBO_CORE_MAINNET = SN.ekuboCore;
|
|
4733
4669
|
|
|
4734
4670
|
// src/utils/bigint.ts
|
|
4735
4671
|
function stringifyBigInts(obj) {
|
|
@@ -5623,10 +5559,10 @@ function normalizeEvm(address) {
|
|
|
5623
5559
|
const m = /^0x([0-9a-fA-F]{40})$/.exec(address);
|
|
5624
5560
|
if (!m) throw new Error(`Invalid ETHEREUM/BASE address: "${address}"`);
|
|
5625
5561
|
const lower = m[1].toLowerCase();
|
|
5626
|
-
const
|
|
5562
|
+
const hash4 = keccak_256(new TextEncoder().encode(lower));
|
|
5627
5563
|
let out = "0x";
|
|
5628
5564
|
for (let i = 0; i < 40; i++) {
|
|
5629
|
-
const nibble =
|
|
5565
|
+
const nibble = hash4[i >> 1] >> (i % 2 === 0 ? 4 : 0) & 15;
|
|
5630
5566
|
out += nibble >= 8 ? lower[i].toUpperCase() : lower[i];
|
|
5631
5567
|
}
|
|
5632
5568
|
return out;
|
|
@@ -5640,12 +5576,12 @@ function normalizeSolana(address) {
|
|
|
5640
5576
|
throw new Error(`Invalid SOLANA address: "${address}"`);
|
|
5641
5577
|
}
|
|
5642
5578
|
}
|
|
5643
|
-
function normalizeHash(
|
|
5579
|
+
function normalizeHash(hash4) {
|
|
5644
5580
|
try {
|
|
5645
|
-
const hex = num.toHex(BigInt(
|
|
5581
|
+
const hex = num.toHex(BigInt(hash4));
|
|
5646
5582
|
return "0x" + hex.slice(2).padStart(64, "0").toLowerCase();
|
|
5647
5583
|
} catch {
|
|
5648
|
-
throw new Error(`Invalid hash: "${
|
|
5584
|
+
throw new Error(`Invalid hash: "${hash4}"`);
|
|
5649
5585
|
}
|
|
5650
5586
|
}
|
|
5651
5587
|
function shortenAddress(chain, address, chars = 4) {
|
|
@@ -6271,8 +6207,8 @@ var ApiClient = class {
|
|
|
6271
6207
|
}
|
|
6272
6208
|
};
|
|
6273
6209
|
var PopService = class {
|
|
6274
|
-
constructor(
|
|
6275
|
-
this.factoryAddress =
|
|
6210
|
+
constructor(config) {
|
|
6211
|
+
this.factoryAddress = getCoordinates(config.chain).popFactory;
|
|
6276
6212
|
}
|
|
6277
6213
|
_collection(address, account) {
|
|
6278
6214
|
return new Contract(POPCollectionABI, normalizeAddress("STARKNET", address), account);
|
|
@@ -6347,7 +6283,7 @@ function toContractConditions(c) {
|
|
|
6347
6283
|
}
|
|
6348
6284
|
var DropService = class {
|
|
6349
6285
|
constructor(config) {
|
|
6350
|
-
this.factoryAddress =
|
|
6286
|
+
this.factoryAddress = getCoordinates(config.chain).dropFactory;
|
|
6351
6287
|
this.config = config;
|
|
6352
6288
|
}
|
|
6353
6289
|
_collection(address, account) {
|
|
@@ -6429,7 +6365,7 @@ var DropService = class {
|
|
|
6429
6365
|
};
|
|
6430
6366
|
var ERC1155CollectionService = class {
|
|
6431
6367
|
constructor(config) {
|
|
6432
|
-
this.factoryAddress = config.collection1155Contract ??
|
|
6368
|
+
this.factoryAddress = config.collection1155Contract ?? getCoordinates(config.chain).collection1155;
|
|
6433
6369
|
}
|
|
6434
6370
|
_factory(account) {
|
|
6435
6371
|
return new Contract(
|
|
@@ -6571,7 +6507,7 @@ async function getCreatorCoinPrice(coinAddress, provider) {
|
|
|
6571
6507
|
const [t0, t1] = ci < qi ? [coinAddress, quoteToken] : [quoteToken, coinAddress];
|
|
6572
6508
|
const quoteIsToken0 = qi === BigInt(t0);
|
|
6573
6509
|
const pp = await provider.callContract({
|
|
6574
|
-
contractAddress:
|
|
6510
|
+
contractAddress: getCoordinates("STARKNET").ekuboCore,
|
|
6575
6511
|
entrypoint: "get_pool_price",
|
|
6576
6512
|
calldata: [t0, t1, fee, tickSpacing, "0x0"]
|
|
6577
6513
|
});
|
|
@@ -6586,7 +6522,7 @@ function factoryContract() {
|
|
|
6586
6522
|
if (!_factoryContract) {
|
|
6587
6523
|
_factoryContract = new Contract(
|
|
6588
6524
|
CreatorCoinFactoryABI,
|
|
6589
|
-
|
|
6525
|
+
getCoordinates("STARKNET").creatorCoinFactory
|
|
6590
6526
|
);
|
|
6591
6527
|
}
|
|
6592
6528
|
return _factoryContract;
|
|
@@ -6623,7 +6559,7 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
6623
6559
|
calls.push({
|
|
6624
6560
|
contractAddress: params.quoteToken,
|
|
6625
6561
|
entrypoint: "transfer",
|
|
6626
|
-
calldata: [
|
|
6562
|
+
calldata: [getCoordinates("STARKNET").creatorCoinFactory, amt.low, amt.high]
|
|
6627
6563
|
});
|
|
6628
6564
|
}
|
|
6629
6565
|
calls.push(factoryContract().populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
|
|
@@ -6631,7 +6567,7 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
6631
6567
|
}
|
|
6632
6568
|
var CREATOR_COIN_CREATED_SELECTOR = hash.getSelectorFromName("CreatorCoinCreated");
|
|
6633
6569
|
function parseCreatorCoinCreated(receipt) {
|
|
6634
|
-
const factory = normalizeAddress("STARKNET",
|
|
6570
|
+
const factory = normalizeAddress("STARKNET", getCoordinates("STARKNET").creatorCoinFactory);
|
|
6635
6571
|
for (const ev of receipt?.events ?? []) {
|
|
6636
6572
|
let from;
|
|
6637
6573
|
try {
|
|
@@ -6650,7 +6586,7 @@ function parseCreatorCoinCreated(receipt) {
|
|
|
6650
6586
|
}
|
|
6651
6587
|
var CreatorCoinService = class {
|
|
6652
6588
|
constructor(config) {
|
|
6653
|
-
this.factoryAddress =
|
|
6589
|
+
this.factoryAddress = getCoordinates(config.chain).creatorCoinFactory;
|
|
6654
6590
|
this.config = config;
|
|
6655
6591
|
}
|
|
6656
6592
|
_factory(account) {
|
|
@@ -6728,6 +6664,135 @@ var MedialaneClient = class {
|
|
|
6728
6664
|
}
|
|
6729
6665
|
};
|
|
6730
6666
|
|
|
6667
|
+
// src/admin-auth/types.ts
|
|
6668
|
+
var ADMIN_SCOPE = "admin-api";
|
|
6669
|
+
function adminRequestDigest(req) {
|
|
6670
|
+
return hash.computePoseidonHashOnElements([
|
|
6671
|
+
hash.starknetKeccak(req.method.toUpperCase()),
|
|
6672
|
+
hash.starknetKeccak(req.path),
|
|
6673
|
+
hash.starknetKeccak(req.body ?? ""),
|
|
6674
|
+
num.toBigInt(req.nonce),
|
|
6675
|
+
BigInt(req.ts)
|
|
6676
|
+
]);
|
|
6677
|
+
}
|
|
6678
|
+
function signAdminRequest(sessionPrivateKey, req) {
|
|
6679
|
+
const digest = adminRequestDigest(req);
|
|
6680
|
+
return ec.starkCurve.sign(digest, sessionPrivateKey).toCompactHex();
|
|
6681
|
+
}
|
|
6682
|
+
function verifyAdminRequestSig(sessionPublicKey, req, sig) {
|
|
6683
|
+
try {
|
|
6684
|
+
return ec.starkCurve.verify(sig, adminRequestDigest(req), sessionPublicKey);
|
|
6685
|
+
} catch {
|
|
6686
|
+
return false;
|
|
6687
|
+
}
|
|
6688
|
+
}
|
|
6689
|
+
function buildAdminSessionTypedData(p) {
|
|
6690
|
+
return {
|
|
6691
|
+
types: {
|
|
6692
|
+
StarknetDomain: [
|
|
6693
|
+
{ name: "name", type: "shortstring" },
|
|
6694
|
+
{ name: "version", type: "shortstring" },
|
|
6695
|
+
{ name: "chainId", type: "shortstring" },
|
|
6696
|
+
{ name: "revision", type: "shortstring" }
|
|
6697
|
+
],
|
|
6698
|
+
AdminSession: [
|
|
6699
|
+
{ name: "sessionKeyHash", type: "felt" },
|
|
6700
|
+
{ name: "scope", type: "shortstring" },
|
|
6701
|
+
{ name: "issuedAt", type: "felt" },
|
|
6702
|
+
{ name: "expiresAt", type: "felt" }
|
|
6703
|
+
]
|
|
6704
|
+
},
|
|
6705
|
+
primaryType: "AdminSession",
|
|
6706
|
+
domain: { name: "Medialane Admin", version: "1", chainId: p.chainId ?? "SN_MAIN", revision: "1" },
|
|
6707
|
+
message: {
|
|
6708
|
+
sessionKeyHash: p.sessionKeyHash,
|
|
6709
|
+
scope: p.scope,
|
|
6710
|
+
issuedAt: String(p.issuedAt),
|
|
6711
|
+
expiresAt: String(p.expiresAt)
|
|
6712
|
+
}
|
|
6713
|
+
};
|
|
6714
|
+
}
|
|
6715
|
+
function sessionKeyHashOf(sessionPublicKey) {
|
|
6716
|
+
return num.toHex(hash.starknetKeccak(sessionPublicKey));
|
|
6717
|
+
}
|
|
6718
|
+
async function createAdminSessionGrant(signTypedData, opts) {
|
|
6719
|
+
const priv = ec.starkCurve.utils.randomPrivateKey();
|
|
6720
|
+
const sessionPrivateKey = "0x" + encode.buf2hex(priv);
|
|
6721
|
+
const sessionPublicKey = "0x" + encode.buf2hex(ec.starkCurve.getPublicKey(sessionPrivateKey, false));
|
|
6722
|
+
const sessionKeyHash = sessionKeyHashOf(sessionPublicKey);
|
|
6723
|
+
const nowSec = Math.floor((opts.now?.() ?? Date.now()) / 1e3);
|
|
6724
|
+
const issuedAt = nowSec;
|
|
6725
|
+
const expiresAt = nowSec + (opts.ttlSeconds ?? 7200);
|
|
6726
|
+
const data = buildAdminSessionTypedData({ sessionKeyHash, scope: ADMIN_SCOPE, issuedAt, expiresAt, chainId: opts.chainId });
|
|
6727
|
+
const walletSig = await signTypedData(data);
|
|
6728
|
+
const grant = {
|
|
6729
|
+
wallet: opts.wallet,
|
|
6730
|
+
chain: opts.chain ?? "STARKNET",
|
|
6731
|
+
sessionPublicKey,
|
|
6732
|
+
sessionKeyHash,
|
|
6733
|
+
scope: ADMIN_SCOPE,
|
|
6734
|
+
issuedAt,
|
|
6735
|
+
expiresAt,
|
|
6736
|
+
walletSig
|
|
6737
|
+
};
|
|
6738
|
+
return { grant, sessionPrivateKey };
|
|
6739
|
+
}
|
|
6740
|
+
|
|
6741
|
+
// src/admin-auth/headers.ts
|
|
6742
|
+
var ADMIN_HEADERS = {
|
|
6743
|
+
grant: "x-ml-admin-grant",
|
|
6744
|
+
sig: "x-ml-admin-sig",
|
|
6745
|
+
nonce: "x-ml-admin-nonce",
|
|
6746
|
+
ts: "x-ml-admin-ts"
|
|
6747
|
+
};
|
|
6748
|
+
function b64urlEncode(s) {
|
|
6749
|
+
const bytes = new TextEncoder().encode(s);
|
|
6750
|
+
let bin = "";
|
|
6751
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
6752
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
6753
|
+
}
|
|
6754
|
+
function b64urlDecode(s) {
|
|
6755
|
+
const pad = s.length % 4 ? "=".repeat(4 - s.length % 4) : "";
|
|
6756
|
+
const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + pad);
|
|
6757
|
+
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
6758
|
+
return new TextDecoder().decode(bytes);
|
|
6759
|
+
}
|
|
6760
|
+
function randomNonce() {
|
|
6761
|
+
const b = new Uint8Array(16);
|
|
6762
|
+
crypto.getRandomValues(b);
|
|
6763
|
+
let hex = "";
|
|
6764
|
+
for (const x of b) hex += x.toString(16).padStart(2, "0");
|
|
6765
|
+
return "0x" + hex;
|
|
6766
|
+
}
|
|
6767
|
+
function encodeAdminHeaders(session, reqInit) {
|
|
6768
|
+
const nonce = randomNonce();
|
|
6769
|
+
const ts = Math.floor((reqInit.now?.() ?? Date.now()) / 1e3);
|
|
6770
|
+
const req = { method: reqInit.method, path: reqInit.path, body: reqInit.body ?? "", nonce, ts };
|
|
6771
|
+
const sig = signAdminRequest(session.sessionPrivateKey, req);
|
|
6772
|
+
return {
|
|
6773
|
+
[ADMIN_HEADERS.grant]: b64urlEncode(JSON.stringify(session.grant)),
|
|
6774
|
+
[ADMIN_HEADERS.sig]: sig,
|
|
6775
|
+
[ADMIN_HEADERS.nonce]: nonce,
|
|
6776
|
+
[ADMIN_HEADERS.ts]: String(ts)
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6779
|
+
function parseAdminHeaders(get) {
|
|
6780
|
+
const rawGrant = get(ADMIN_HEADERS.grant);
|
|
6781
|
+
const sig = get(ADMIN_HEADERS.sig);
|
|
6782
|
+
const nonce = get(ADMIN_HEADERS.nonce);
|
|
6783
|
+
const tsRaw = get(ADMIN_HEADERS.ts);
|
|
6784
|
+
if (!rawGrant || !sig || !nonce || !tsRaw) return null;
|
|
6785
|
+
try {
|
|
6786
|
+
const grant = JSON.parse(b64urlDecode(rawGrant));
|
|
6787
|
+
if (!grant.wallet || !grant.sessionPublicKey || !grant.sessionKeyHash || !Array.isArray(grant.walletSig) || typeof grant.expiresAt !== "number") return null;
|
|
6788
|
+
const ts = Number(tsRaw);
|
|
6789
|
+
if (!Number.isFinite(ts)) return null;
|
|
6790
|
+
return { grant, sig, nonce, ts };
|
|
6791
|
+
} catch {
|
|
6792
|
+
return null;
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6795
|
+
|
|
6731
6796
|
// src/types/api.ts
|
|
6732
6797
|
var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
|
|
6733
6798
|
|
|
@@ -6772,6 +6837,7 @@ function fdvHuman(supplyHuman) {
|
|
|
6772
6837
|
}
|
|
6773
6838
|
|
|
6774
6839
|
// src/services/registry.ts
|
|
6840
|
+
var SN = getCoordinates("STARKNET");
|
|
6775
6841
|
var SERVICES = {
|
|
6776
6842
|
"mip-erc721": {
|
|
6777
6843
|
id: "mip-erc721",
|
|
@@ -6781,8 +6847,8 @@ var SERVICES = {
|
|
|
6781
6847
|
provenance: "MEDIALANE",
|
|
6782
6848
|
onchain: {
|
|
6783
6849
|
STARKNET: {
|
|
6784
|
-
factoryAddress:
|
|
6785
|
-
startBlock:
|
|
6850
|
+
factoryAddress: SN.collection721,
|
|
6851
|
+
startBlock: SN.collection721StartBlock
|
|
6786
6852
|
}
|
|
6787
6853
|
},
|
|
6788
6854
|
uiVariant: "standard",
|
|
@@ -6816,9 +6882,9 @@ var SERVICES = {
|
|
|
6816
6882
|
provenance: "MEDIALANE",
|
|
6817
6883
|
onchain: {
|
|
6818
6884
|
STARKNET: {
|
|
6819
|
-
factoryAddress:
|
|
6820
|
-
classHash:
|
|
6821
|
-
startBlock:
|
|
6885
|
+
factoryAddress: SN.collection1155,
|
|
6886
|
+
classHash: SN.collection1155ClassHash,
|
|
6887
|
+
startBlock: SN.collection1155StartBlock
|
|
6822
6888
|
}
|
|
6823
6889
|
},
|
|
6824
6890
|
uiVariant: "edition",
|
|
@@ -6836,8 +6902,8 @@ var SERVICES = {
|
|
|
6836
6902
|
provenance: "MEDIALANE",
|
|
6837
6903
|
onchain: {
|
|
6838
6904
|
STARKNET: {
|
|
6839
|
-
factoryAddress:
|
|
6840
|
-
classHash:
|
|
6905
|
+
factoryAddress: SN.popFactory,
|
|
6906
|
+
classHash: SN.popCollectionClassHash
|
|
6841
6907
|
}
|
|
6842
6908
|
},
|
|
6843
6909
|
uiVariant: "pop",
|
|
@@ -6856,8 +6922,8 @@ var SERVICES = {
|
|
|
6856
6922
|
provenance: "MEDIALANE",
|
|
6857
6923
|
onchain: {
|
|
6858
6924
|
STARKNET: {
|
|
6859
|
-
factoryAddress:
|
|
6860
|
-
classHash:
|
|
6925
|
+
factoryAddress: SN.dropFactory,
|
|
6926
|
+
classHash: SN.dropCollectionClassHash
|
|
6861
6927
|
}
|
|
6862
6928
|
},
|
|
6863
6929
|
uiVariant: "drop",
|
|
@@ -6876,9 +6942,9 @@ var SERVICES = {
|
|
|
6876
6942
|
provenance: "MEDIALANE",
|
|
6877
6943
|
onchain: {
|
|
6878
6944
|
STARKNET: {
|
|
6879
|
-
factoryAddress:
|
|
6880
|
-
classHash:
|
|
6881
|
-
startBlock:
|
|
6945
|
+
factoryAddress: SN.creatorCoinFactory,
|
|
6946
|
+
classHash: SN.creatorCoinFactoryClassHash,
|
|
6947
|
+
startBlock: SN.creatorCoinStartBlock
|
|
6882
6948
|
}
|
|
6883
6949
|
},
|
|
6884
6950
|
uiVariant: "coin",
|
|
@@ -6900,9 +6966,9 @@ var SERVICES = {
|
|
|
6900
6966
|
provenance: "MEDIALANE",
|
|
6901
6967
|
onchain: {
|
|
6902
6968
|
STARKNET: {
|
|
6903
|
-
factoryAddress:
|
|
6904
|
-
classHash:
|
|
6905
|
-
startBlock:
|
|
6969
|
+
factoryAddress: SN.marketplace721,
|
|
6970
|
+
classHash: SN.marketplace721ClassHash,
|
|
6971
|
+
startBlock: SN.marketplace721StartBlock
|
|
6906
6972
|
}
|
|
6907
6973
|
},
|
|
6908
6974
|
uiVariant: "standard",
|
|
@@ -6921,9 +6987,9 @@ var SERVICES = {
|
|
|
6921
6987
|
provenance: "MEDIALANE",
|
|
6922
6988
|
onchain: {
|
|
6923
6989
|
STARKNET: {
|
|
6924
|
-
factoryAddress:
|
|
6925
|
-
classHash:
|
|
6926
|
-
startBlock:
|
|
6990
|
+
factoryAddress: SN.marketplace1155,
|
|
6991
|
+
classHash: SN.marketplace1155ClassHash,
|
|
6992
|
+
startBlock: SN.marketplace1155StartBlock
|
|
6927
6993
|
}
|
|
6928
6994
|
},
|
|
6929
6995
|
uiVariant: "edition",
|
|
@@ -6977,6 +7043,6 @@ function getServicesByCapability(cap) {
|
|
|
6977
7043
|
);
|
|
6978
7044
|
}
|
|
6979
7045
|
|
|
6980
|
-
export { ApiClient, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY,
|
|
7046
|
+
export { ADMIN_HEADERS, ADMIN_SCOPE, ApiClient, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, CreatorCoinFactoryABI, CreatorCoinService, DEFAULT_CHAIN, DEFAULT_CURRENCY, DropCollectionABI, DropFactoryABI, DropService, ERC1155CollectionService, FeeConfigSchema, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNftABI, LAUNCH_PRICE_QUOTE_PER_COIN, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, PUBLIC_RPC_FALLBACKS, PopService, SUPPORTED_TOKENS, VALIDATED_EKUBO_PARAMS, adminRequestDigest, build1155CancellationTypedData, build1155OrderTypedData, buildAdminSessionTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createAdminSessionGrant, createFailoverFetch, encodeAdminHeaders, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAdminHeaders, parseAmount, parseCreatorCoinCreated, randomNonce, resolveConfig, resolveFeeConfig, sessionKeyHashOf, shortenAddress, signAdminRequest, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol, verifyAdminRequestSig };
|
|
6981
7047
|
//# sourceMappingURL=index.js.map
|
|
6982
7048
|
//# sourceMappingURL=index.js.map
|