@medialane/sdk 0.38.0 → 0.40.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 +337 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +278 -23
- package/dist/index.d.ts +278 -23
- package/dist/index.js +328 -35
- 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
|
|
|
@@ -16,10 +16,10 @@ var COORDINATES = {
|
|
|
16
16
|
marketplace1155: "0x040cd7b3e73bb3c892166e34bdc01d1797f97ecbc356c23f1cf38033cacf0077",
|
|
17
17
|
marketplace1155ClassHash: "0x02600bb720908f119afe482309d36c39d087587f0df9576454acfb6363e78cd8",
|
|
18
18
|
marketplace1155StartBlock: 10350855,
|
|
19
|
-
collection721: "
|
|
20
|
-
collection721StartBlock:
|
|
21
|
-
ipNftClassHash: "
|
|
22
|
-
ipCollectionClassHash: "
|
|
19
|
+
collection721: "0x0558c9b6ea4d403df6d765fb77be55702c572f0a811f037c6c4209fe1e5aeef2",
|
|
20
|
+
collection721StartBlock: 11002817,
|
|
21
|
+
ipNftClassHash: "0x040551f0d009a6d665ddff980a375dfccc71a8928c8bfcc9ab56244bc4464fab",
|
|
22
|
+
ipCollectionClassHash: "0x063d4ac4ae317fd155216bf1b8a4d3a63172ff72965b9ac48dd5add0c2d32b70",
|
|
23
23
|
collection1155: "0x0083543c3ee15040a419fc539fa6889f5b956e7d071bcfa97842cb0ae42ad6cc",
|
|
24
24
|
collection1155FactoryClassHash: "0x331a69da8655a882ba1fbcb55188b8fa09116521db901bbbaafc9fead0689f8",
|
|
25
25
|
collection1155ClassHash: "0x4e110b59af240ae6c7742999964c4eae13fb2ed935c47fe97653ec017ebea34",
|
|
@@ -2996,7 +2996,7 @@ var IPCollectionABI = [
|
|
|
2996
2996
|
"type": "core::integer::u256"
|
|
2997
2997
|
},
|
|
2998
2998
|
{
|
|
2999
|
-
"name": "
|
|
2999
|
+
"name": "protocol_routed_transfers",
|
|
3000
3000
|
"type": "core::integer::u256"
|
|
3001
3001
|
},
|
|
3002
3002
|
{
|
|
@@ -3086,6 +3086,10 @@ var IPCollectionABI = [
|
|
|
3086
3086
|
{
|
|
3087
3087
|
"name": "token_uri",
|
|
3088
3088
|
"type": "core::byte_array::ByteArray"
|
|
3089
|
+
},
|
|
3090
|
+
{
|
|
3091
|
+
"name": "royalty_bps",
|
|
3092
|
+
"type": "core::integer::u128"
|
|
3089
3093
|
}
|
|
3090
3094
|
],
|
|
3091
3095
|
"outputs": [
|
|
@@ -3110,6 +3114,10 @@ var IPCollectionABI = [
|
|
|
3110
3114
|
{
|
|
3111
3115
|
"name": "token_uris",
|
|
3112
3116
|
"type": "core::array::Array::<core::byte_array::ByteArray>"
|
|
3117
|
+
},
|
|
3118
|
+
{
|
|
3119
|
+
"name": "royalty_bps",
|
|
3120
|
+
"type": "core::array::Array::<core::integer::u128>"
|
|
3113
3121
|
}
|
|
3114
3122
|
],
|
|
3115
3123
|
"outputs": [
|
|
@@ -3140,8 +3148,12 @@ var IPCollectionABI = [
|
|
|
3140
3148
|
"name": "archive",
|
|
3141
3149
|
"inputs": [
|
|
3142
3150
|
{
|
|
3143
|
-
"name": "
|
|
3144
|
-
"type": "core::
|
|
3151
|
+
"name": "collection_id",
|
|
3152
|
+
"type": "core::integer::u256"
|
|
3153
|
+
},
|
|
3154
|
+
{
|
|
3155
|
+
"name": "token_id",
|
|
3156
|
+
"type": "core::integer::u256"
|
|
3145
3157
|
}
|
|
3146
3158
|
],
|
|
3147
3159
|
"outputs": [],
|
|
@@ -3152,8 +3164,12 @@ var IPCollectionABI = [
|
|
|
3152
3164
|
"name": "batch_archive",
|
|
3153
3165
|
"inputs": [
|
|
3154
3166
|
{
|
|
3155
|
-
"name": "
|
|
3156
|
-
"type": "core::array::Array::<core::
|
|
3167
|
+
"name": "collection_ids",
|
|
3168
|
+
"type": "core::array::Array::<core::integer::u256>"
|
|
3169
|
+
},
|
|
3170
|
+
{
|
|
3171
|
+
"name": "token_ids",
|
|
3172
|
+
"type": "core::array::Array::<core::integer::u256>"
|
|
3157
3173
|
}
|
|
3158
3174
|
],
|
|
3159
3175
|
"outputs": [],
|
|
@@ -3164,16 +3180,16 @@ var IPCollectionABI = [
|
|
|
3164
3180
|
"name": "transfer_token",
|
|
3165
3181
|
"inputs": [
|
|
3166
3182
|
{
|
|
3167
|
-
"name": "
|
|
3183
|
+
"name": "to",
|
|
3168
3184
|
"type": "core::starknet::contract_address::ContractAddress"
|
|
3169
3185
|
},
|
|
3170
3186
|
{
|
|
3171
|
-
"name": "
|
|
3172
|
-
"type": "core::
|
|
3187
|
+
"name": "collection_id",
|
|
3188
|
+
"type": "core::integer::u256"
|
|
3173
3189
|
},
|
|
3174
3190
|
{
|
|
3175
|
-
"name": "
|
|
3176
|
-
"type": "core::
|
|
3191
|
+
"name": "token_id",
|
|
3192
|
+
"type": "core::integer::u256"
|
|
3177
3193
|
}
|
|
3178
3194
|
],
|
|
3179
3195
|
"outputs": [],
|
|
@@ -3192,8 +3208,12 @@ var IPCollectionABI = [
|
|
|
3192
3208
|
"type": "core::starknet::contract_address::ContractAddress"
|
|
3193
3209
|
},
|
|
3194
3210
|
{
|
|
3195
|
-
"name": "
|
|
3196
|
-
"type": "core::array::Array::<core::
|
|
3211
|
+
"name": "collection_ids",
|
|
3212
|
+
"type": "core::array::Array::<core::integer::u256>"
|
|
3213
|
+
},
|
|
3214
|
+
{
|
|
3215
|
+
"name": "token_ids",
|
|
3216
|
+
"type": "core::array::Array::<core::integer::u256>"
|
|
3197
3217
|
}
|
|
3198
3218
|
],
|
|
3199
3219
|
"outputs": [],
|
|
@@ -3262,6 +3282,17 @@ var IPCollectionABI = [
|
|
|
3262
3282
|
],
|
|
3263
3283
|
"state_mutability": "view"
|
|
3264
3284
|
},
|
|
3285
|
+
{
|
|
3286
|
+
"type": "function",
|
|
3287
|
+
"name": "version",
|
|
3288
|
+
"inputs": [],
|
|
3289
|
+
"outputs": [
|
|
3290
|
+
{
|
|
3291
|
+
"type": "core::byte_array::ByteArray"
|
|
3292
|
+
}
|
|
3293
|
+
],
|
|
3294
|
+
"state_mutability": "view"
|
|
3295
|
+
},
|
|
3265
3296
|
{
|
|
3266
3297
|
"type": "function",
|
|
3267
3298
|
"name": "is_valid_collection",
|
|
@@ -3319,8 +3350,12 @@ var IPCollectionABI = [
|
|
|
3319
3350
|
"name": "get_token",
|
|
3320
3351
|
"inputs": [
|
|
3321
3352
|
{
|
|
3322
|
-
"name": "
|
|
3323
|
-
"type": "core::
|
|
3353
|
+
"name": "collection_id",
|
|
3354
|
+
"type": "core::integer::u256"
|
|
3355
|
+
},
|
|
3356
|
+
{
|
|
3357
|
+
"name": "token_id",
|
|
3358
|
+
"type": "core::integer::u256"
|
|
3324
3359
|
}
|
|
3325
3360
|
],
|
|
3326
3361
|
"outputs": [
|
|
@@ -3335,8 +3370,12 @@ var IPCollectionABI = [
|
|
|
3335
3370
|
"name": "is_valid_token",
|
|
3336
3371
|
"inputs": [
|
|
3337
3372
|
{
|
|
3338
|
-
"name": "
|
|
3339
|
-
"type": "core::
|
|
3373
|
+
"name": "collection_id",
|
|
3374
|
+
"type": "core::integer::u256"
|
|
3375
|
+
},
|
|
3376
|
+
{
|
|
3377
|
+
"name": "token_id",
|
|
3378
|
+
"type": "core::integer::u256"
|
|
3340
3379
|
}
|
|
3341
3380
|
],
|
|
3342
3381
|
"outputs": [
|
|
@@ -3351,8 +3390,12 @@ var IPCollectionABI = [
|
|
|
3351
3390
|
"name": "is_transferable_token",
|
|
3352
3391
|
"inputs": [
|
|
3353
3392
|
{
|
|
3354
|
-
"name": "
|
|
3355
|
-
"type": "core::
|
|
3393
|
+
"name": "collection_id",
|
|
3394
|
+
"type": "core::integer::u256"
|
|
3395
|
+
},
|
|
3396
|
+
{
|
|
3397
|
+
"name": "token_id",
|
|
3398
|
+
"type": "core::integer::u256"
|
|
3356
3399
|
}
|
|
3357
3400
|
],
|
|
3358
3401
|
"outputs": [
|
|
@@ -3457,6 +3500,11 @@ var IPCollectionABI = [
|
|
|
3457
3500
|
"name": "metadata_uri",
|
|
3458
3501
|
"type": "core::byte_array::ByteArray",
|
|
3459
3502
|
"kind": "data"
|
|
3503
|
+
},
|
|
3504
|
+
{
|
|
3505
|
+
"name": "royalty_bps",
|
|
3506
|
+
"type": "core::integer::u128",
|
|
3507
|
+
"kind": "data"
|
|
3460
3508
|
}
|
|
3461
3509
|
]
|
|
3462
3510
|
},
|
|
@@ -3480,6 +3528,11 @@ var IPCollectionABI = [
|
|
|
3480
3528
|
"type": "core::array::Array::<core::starknet::contract_address::ContractAddress>",
|
|
3481
3529
|
"kind": "data"
|
|
3482
3530
|
},
|
|
3531
|
+
{
|
|
3532
|
+
"name": "metadata_uris",
|
|
3533
|
+
"type": "core::array::Array::<core::byte_array::ByteArray>",
|
|
3534
|
+
"kind": "data"
|
|
3535
|
+
},
|
|
3483
3536
|
{
|
|
3484
3537
|
"name": "operator",
|
|
3485
3538
|
"type": "core::starknet::contract_address::ContractAddress",
|
|
@@ -3525,8 +3578,13 @@ var IPCollectionABI = [
|
|
|
3525
3578
|
"kind": "struct",
|
|
3526
3579
|
"members": [
|
|
3527
3580
|
{
|
|
3528
|
-
"name": "
|
|
3529
|
-
"type": "core::array::
|
|
3581
|
+
"name": "collection_ids",
|
|
3582
|
+
"type": "core::array::Span::<core::integer::u256>",
|
|
3583
|
+
"kind": "data"
|
|
3584
|
+
},
|
|
3585
|
+
{
|
|
3586
|
+
"name": "token_ids",
|
|
3587
|
+
"type": "core::array::Span::<core::integer::u256>",
|
|
3530
3588
|
"kind": "data"
|
|
3531
3589
|
},
|
|
3532
3590
|
{
|
|
@@ -3594,8 +3652,13 @@ var IPCollectionABI = [
|
|
|
3594
3652
|
"kind": "data"
|
|
3595
3653
|
},
|
|
3596
3654
|
{
|
|
3597
|
-
"name": "
|
|
3598
|
-
"type": "core::array::
|
|
3655
|
+
"name": "collection_ids",
|
|
3656
|
+
"type": "core::array::Span::<core::integer::u256>",
|
|
3657
|
+
"kind": "data"
|
|
3658
|
+
},
|
|
3659
|
+
{
|
|
3660
|
+
"name": "token_ids",
|
|
3661
|
+
"type": "core::array::Span::<core::integer::u256>",
|
|
3599
3662
|
"kind": "data"
|
|
3600
3663
|
},
|
|
3601
3664
|
{
|
|
@@ -3821,6 +3884,10 @@ var IPNftABI = [
|
|
|
3821
3884
|
{
|
|
3822
3885
|
"name": "creator",
|
|
3823
3886
|
"type": "core::starknet::contract_address::ContractAddress"
|
|
3887
|
+
},
|
|
3888
|
+
{
|
|
3889
|
+
"name": "royalty_bps",
|
|
3890
|
+
"type": "core::integer::u128"
|
|
3824
3891
|
}
|
|
3825
3892
|
],
|
|
3826
3893
|
"outputs": [],
|
|
@@ -3876,6 +3943,17 @@ var IPNftABI = [
|
|
|
3876
3943
|
],
|
|
3877
3944
|
"state_mutability": "view"
|
|
3878
3945
|
},
|
|
3946
|
+
{
|
|
3947
|
+
"type": "function",
|
|
3948
|
+
"name": "version",
|
|
3949
|
+
"inputs": [],
|
|
3950
|
+
"outputs": [
|
|
3951
|
+
{
|
|
3952
|
+
"type": "core::byte_array::ByteArray"
|
|
3953
|
+
}
|
|
3954
|
+
],
|
|
3955
|
+
"state_mutability": "view"
|
|
3956
|
+
},
|
|
3879
3957
|
{
|
|
3880
3958
|
"type": "function",
|
|
3881
3959
|
"name": "base_uri",
|
|
@@ -4358,6 +4436,75 @@ var IPNftABI = [
|
|
|
4358
4436
|
}
|
|
4359
4437
|
]
|
|
4360
4438
|
},
|
|
4439
|
+
{
|
|
4440
|
+
"type": "impl",
|
|
4441
|
+
"name": "ERC2981Impl",
|
|
4442
|
+
"interface_name": "openzeppelin_token::common::erc2981::interface::IERC2981"
|
|
4443
|
+
},
|
|
4444
|
+
{
|
|
4445
|
+
"type": "interface",
|
|
4446
|
+
"name": "openzeppelin_token::common::erc2981::interface::IERC2981",
|
|
4447
|
+
"items": [
|
|
4448
|
+
{
|
|
4449
|
+
"type": "function",
|
|
4450
|
+
"name": "royalty_info",
|
|
4451
|
+
"inputs": [
|
|
4452
|
+
{
|
|
4453
|
+
"name": "token_id",
|
|
4454
|
+
"type": "core::integer::u256"
|
|
4455
|
+
},
|
|
4456
|
+
{
|
|
4457
|
+
"name": "sale_price",
|
|
4458
|
+
"type": "core::integer::u256"
|
|
4459
|
+
}
|
|
4460
|
+
],
|
|
4461
|
+
"outputs": [
|
|
4462
|
+
{
|
|
4463
|
+
"type": "(core::starknet::contract_address::ContractAddress, core::integer::u256)"
|
|
4464
|
+
}
|
|
4465
|
+
],
|
|
4466
|
+
"state_mutability": "view"
|
|
4467
|
+
}
|
|
4468
|
+
]
|
|
4469
|
+
},
|
|
4470
|
+
{
|
|
4471
|
+
"type": "impl",
|
|
4472
|
+
"name": "ERC2981InfoImpl",
|
|
4473
|
+
"interface_name": "openzeppelin_token::common::erc2981::interface::IERC2981Info"
|
|
4474
|
+
},
|
|
4475
|
+
{
|
|
4476
|
+
"type": "interface",
|
|
4477
|
+
"name": "openzeppelin_token::common::erc2981::interface::IERC2981Info",
|
|
4478
|
+
"items": [
|
|
4479
|
+
{
|
|
4480
|
+
"type": "function",
|
|
4481
|
+
"name": "default_royalty",
|
|
4482
|
+
"inputs": [],
|
|
4483
|
+
"outputs": [
|
|
4484
|
+
{
|
|
4485
|
+
"type": "(core::starknet::contract_address::ContractAddress, core::integer::u128, core::integer::u128)"
|
|
4486
|
+
}
|
|
4487
|
+
],
|
|
4488
|
+
"state_mutability": "view"
|
|
4489
|
+
},
|
|
4490
|
+
{
|
|
4491
|
+
"type": "function",
|
|
4492
|
+
"name": "token_royalty",
|
|
4493
|
+
"inputs": [
|
|
4494
|
+
{
|
|
4495
|
+
"name": "token_id",
|
|
4496
|
+
"type": "core::integer::u256"
|
|
4497
|
+
}
|
|
4498
|
+
],
|
|
4499
|
+
"outputs": [
|
|
4500
|
+
{
|
|
4501
|
+
"type": "(core::starknet::contract_address::ContractAddress, core::integer::u128, core::integer::u128)"
|
|
4502
|
+
}
|
|
4503
|
+
],
|
|
4504
|
+
"state_mutability": "view"
|
|
4505
|
+
}
|
|
4506
|
+
]
|
|
4507
|
+
},
|
|
4361
4508
|
{
|
|
4362
4509
|
"type": "constructor",
|
|
4363
4510
|
"name": "constructor",
|
|
@@ -4484,6 +4631,12 @@ var IPNftABI = [
|
|
|
4484
4631
|
"kind": "enum",
|
|
4485
4632
|
"variants": []
|
|
4486
4633
|
},
|
|
4634
|
+
{
|
|
4635
|
+
"type": "event",
|
|
4636
|
+
"name": "openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Event",
|
|
4637
|
+
"kind": "enum",
|
|
4638
|
+
"variants": []
|
|
4639
|
+
},
|
|
4487
4640
|
{
|
|
4488
4641
|
"type": "event",
|
|
4489
4642
|
"name": "ip_collection_erc_721::IPNft::IPNft::Event",
|
|
@@ -4503,6 +4656,11 @@ var IPNftABI = [
|
|
|
4503
4656
|
"name": "ERC721EnumerableEvent",
|
|
4504
4657
|
"type": "openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event",
|
|
4505
4658
|
"kind": "flat"
|
|
4659
|
+
},
|
|
4660
|
+
{
|
|
4661
|
+
"name": "ERC2981Event",
|
|
4662
|
+
"type": "openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Event",
|
|
4663
|
+
"kind": "flat"
|
|
4506
4664
|
}
|
|
4507
4665
|
]
|
|
4508
4666
|
}
|
|
@@ -4956,11 +5114,17 @@ async function cancelOrder(account, params, config) {
|
|
|
4956
5114
|
}
|
|
4957
5115
|
}
|
|
4958
5116
|
async function mint(account, params, config) {
|
|
4959
|
-
const { collectionId, recipient, tokenUri, collectionContract } = params;
|
|
5117
|
+
const { collectionId, recipient, tokenUri, royaltyBps, collectionContract } = params;
|
|
4960
5118
|
const provider = getProvider(config);
|
|
4961
5119
|
const contractAddress = collectionContract ?? config.collectionContract;
|
|
4962
5120
|
const id = cairo.uint256(collectionId);
|
|
4963
|
-
const calldata = [
|
|
5121
|
+
const calldata = [
|
|
5122
|
+
id.low.toString(),
|
|
5123
|
+
id.high.toString(),
|
|
5124
|
+
recipient,
|
|
5125
|
+
...encodeByteArray(tokenUri),
|
|
5126
|
+
royaltyBps.toString()
|
|
5127
|
+
];
|
|
4964
5128
|
try {
|
|
4965
5129
|
const tx = await account.execute([{ contractAddress, entrypoint: "mint", calldata }]);
|
|
4966
5130
|
await provider.waitForTransaction(tx.transaction_hash);
|
|
@@ -5459,10 +5623,10 @@ function normalizeEvm(address) {
|
|
|
5459
5623
|
const m = /^0x([0-9a-fA-F]{40})$/.exec(address);
|
|
5460
5624
|
if (!m) throw new Error(`Invalid ETHEREUM/BASE address: "${address}"`);
|
|
5461
5625
|
const lower = m[1].toLowerCase();
|
|
5462
|
-
const
|
|
5626
|
+
const hash4 = keccak_256(new TextEncoder().encode(lower));
|
|
5463
5627
|
let out = "0x";
|
|
5464
5628
|
for (let i = 0; i < 40; i++) {
|
|
5465
|
-
const nibble =
|
|
5629
|
+
const nibble = hash4[i >> 1] >> (i % 2 === 0 ? 4 : 0) & 15;
|
|
5466
5630
|
out += nibble >= 8 ? lower[i].toUpperCase() : lower[i];
|
|
5467
5631
|
}
|
|
5468
5632
|
return out;
|
|
@@ -5476,12 +5640,12 @@ function normalizeSolana(address) {
|
|
|
5476
5640
|
throw new Error(`Invalid SOLANA address: "${address}"`);
|
|
5477
5641
|
}
|
|
5478
5642
|
}
|
|
5479
|
-
function normalizeHash(
|
|
5643
|
+
function normalizeHash(hash4) {
|
|
5480
5644
|
try {
|
|
5481
|
-
const hex = num.toHex(BigInt(
|
|
5645
|
+
const hex = num.toHex(BigInt(hash4));
|
|
5482
5646
|
return "0x" + hex.slice(2).padStart(64, "0").toLowerCase();
|
|
5483
5647
|
} catch {
|
|
5484
|
-
throw new Error(`Invalid hash: "${
|
|
5648
|
+
throw new Error(`Invalid hash: "${hash4}"`);
|
|
5485
5649
|
}
|
|
5486
5650
|
}
|
|
5487
5651
|
function shortenAddress(chain, address, chars = 4) {
|
|
@@ -6564,6 +6728,135 @@ var MedialaneClient = class {
|
|
|
6564
6728
|
}
|
|
6565
6729
|
};
|
|
6566
6730
|
|
|
6731
|
+
// src/admin-auth/types.ts
|
|
6732
|
+
var ADMIN_SCOPE = "admin-api";
|
|
6733
|
+
function adminRequestDigest(req) {
|
|
6734
|
+
return hash.computePoseidonHashOnElements([
|
|
6735
|
+
hash.starknetKeccak(req.method.toUpperCase()),
|
|
6736
|
+
hash.starknetKeccak(req.path),
|
|
6737
|
+
hash.starknetKeccak(req.body ?? ""),
|
|
6738
|
+
num.toBigInt(req.nonce),
|
|
6739
|
+
BigInt(req.ts)
|
|
6740
|
+
]);
|
|
6741
|
+
}
|
|
6742
|
+
function signAdminRequest(sessionPrivateKey, req) {
|
|
6743
|
+
const digest = adminRequestDigest(req);
|
|
6744
|
+
return ec.starkCurve.sign(digest, sessionPrivateKey).toCompactHex();
|
|
6745
|
+
}
|
|
6746
|
+
function verifyAdminRequestSig(sessionPublicKey, req, sig) {
|
|
6747
|
+
try {
|
|
6748
|
+
return ec.starkCurve.verify(sig, adminRequestDigest(req), sessionPublicKey);
|
|
6749
|
+
} catch {
|
|
6750
|
+
return false;
|
|
6751
|
+
}
|
|
6752
|
+
}
|
|
6753
|
+
function buildAdminSessionTypedData(p) {
|
|
6754
|
+
return {
|
|
6755
|
+
types: {
|
|
6756
|
+
StarknetDomain: [
|
|
6757
|
+
{ name: "name", type: "shortstring" },
|
|
6758
|
+
{ name: "version", type: "shortstring" },
|
|
6759
|
+
{ name: "chainId", type: "shortstring" },
|
|
6760
|
+
{ name: "revision", type: "shortstring" }
|
|
6761
|
+
],
|
|
6762
|
+
AdminSession: [
|
|
6763
|
+
{ name: "sessionKeyHash", type: "felt" },
|
|
6764
|
+
{ name: "scope", type: "shortstring" },
|
|
6765
|
+
{ name: "issuedAt", type: "felt" },
|
|
6766
|
+
{ name: "expiresAt", type: "felt" }
|
|
6767
|
+
]
|
|
6768
|
+
},
|
|
6769
|
+
primaryType: "AdminSession",
|
|
6770
|
+
domain: { name: "Medialane Admin", version: "1", chainId: p.chainId ?? "SN_MAIN", revision: "1" },
|
|
6771
|
+
message: {
|
|
6772
|
+
sessionKeyHash: p.sessionKeyHash,
|
|
6773
|
+
scope: p.scope,
|
|
6774
|
+
issuedAt: String(p.issuedAt),
|
|
6775
|
+
expiresAt: String(p.expiresAt)
|
|
6776
|
+
}
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6779
|
+
function sessionKeyHashOf(sessionPublicKey) {
|
|
6780
|
+
return num.toHex(hash.starknetKeccak(sessionPublicKey));
|
|
6781
|
+
}
|
|
6782
|
+
async function createAdminSessionGrant(signTypedData, opts) {
|
|
6783
|
+
const priv = ec.starkCurve.utils.randomPrivateKey();
|
|
6784
|
+
const sessionPrivateKey = "0x" + encode.buf2hex(priv);
|
|
6785
|
+
const sessionPublicKey = "0x" + encode.buf2hex(ec.starkCurve.getPublicKey(sessionPrivateKey, false));
|
|
6786
|
+
const sessionKeyHash = sessionKeyHashOf(sessionPublicKey);
|
|
6787
|
+
const nowSec = Math.floor((opts.now?.() ?? Date.now()) / 1e3);
|
|
6788
|
+
const issuedAt = nowSec;
|
|
6789
|
+
const expiresAt = nowSec + (opts.ttlSeconds ?? 7200);
|
|
6790
|
+
const data = buildAdminSessionTypedData({ sessionKeyHash, scope: ADMIN_SCOPE, issuedAt, expiresAt, chainId: opts.chainId });
|
|
6791
|
+
const walletSig = await signTypedData(data);
|
|
6792
|
+
const grant = {
|
|
6793
|
+
wallet: opts.wallet,
|
|
6794
|
+
chain: opts.chain ?? "STARKNET",
|
|
6795
|
+
sessionPublicKey,
|
|
6796
|
+
sessionKeyHash,
|
|
6797
|
+
scope: ADMIN_SCOPE,
|
|
6798
|
+
issuedAt,
|
|
6799
|
+
expiresAt,
|
|
6800
|
+
walletSig
|
|
6801
|
+
};
|
|
6802
|
+
return { grant, sessionPrivateKey };
|
|
6803
|
+
}
|
|
6804
|
+
|
|
6805
|
+
// src/admin-auth/headers.ts
|
|
6806
|
+
var ADMIN_HEADERS = {
|
|
6807
|
+
grant: "x-ml-admin-grant",
|
|
6808
|
+
sig: "x-ml-admin-sig",
|
|
6809
|
+
nonce: "x-ml-admin-nonce",
|
|
6810
|
+
ts: "x-ml-admin-ts"
|
|
6811
|
+
};
|
|
6812
|
+
function b64urlEncode(s) {
|
|
6813
|
+
const bytes = new TextEncoder().encode(s);
|
|
6814
|
+
let bin = "";
|
|
6815
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
6816
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
6817
|
+
}
|
|
6818
|
+
function b64urlDecode(s) {
|
|
6819
|
+
const pad = s.length % 4 ? "=".repeat(4 - s.length % 4) : "";
|
|
6820
|
+
const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + pad);
|
|
6821
|
+
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
6822
|
+
return new TextDecoder().decode(bytes);
|
|
6823
|
+
}
|
|
6824
|
+
function randomNonce() {
|
|
6825
|
+
const b = new Uint8Array(16);
|
|
6826
|
+
crypto.getRandomValues(b);
|
|
6827
|
+
let hex = "";
|
|
6828
|
+
for (const x of b) hex += x.toString(16).padStart(2, "0");
|
|
6829
|
+
return "0x" + hex;
|
|
6830
|
+
}
|
|
6831
|
+
function encodeAdminHeaders(session, reqInit) {
|
|
6832
|
+
const nonce = randomNonce();
|
|
6833
|
+
const ts = Math.floor((reqInit.now?.() ?? Date.now()) / 1e3);
|
|
6834
|
+
const req = { method: reqInit.method, path: reqInit.path, body: reqInit.body ?? "", nonce, ts };
|
|
6835
|
+
const sig = signAdminRequest(session.sessionPrivateKey, req);
|
|
6836
|
+
return {
|
|
6837
|
+
[ADMIN_HEADERS.grant]: b64urlEncode(JSON.stringify(session.grant)),
|
|
6838
|
+
[ADMIN_HEADERS.sig]: sig,
|
|
6839
|
+
[ADMIN_HEADERS.nonce]: nonce,
|
|
6840
|
+
[ADMIN_HEADERS.ts]: String(ts)
|
|
6841
|
+
};
|
|
6842
|
+
}
|
|
6843
|
+
function parseAdminHeaders(get) {
|
|
6844
|
+
const rawGrant = get(ADMIN_HEADERS.grant);
|
|
6845
|
+
const sig = get(ADMIN_HEADERS.sig);
|
|
6846
|
+
const nonce = get(ADMIN_HEADERS.nonce);
|
|
6847
|
+
const tsRaw = get(ADMIN_HEADERS.ts);
|
|
6848
|
+
if (!rawGrant || !sig || !nonce || !tsRaw) return null;
|
|
6849
|
+
try {
|
|
6850
|
+
const grant = JSON.parse(b64urlDecode(rawGrant));
|
|
6851
|
+
if (!grant.wallet || !grant.sessionPublicKey || !grant.sessionKeyHash || !Array.isArray(grant.walletSig) || typeof grant.expiresAt !== "number") return null;
|
|
6852
|
+
const ts = Number(tsRaw);
|
|
6853
|
+
if (!Number.isFinite(ts)) return null;
|
|
6854
|
+
return { grant, sig, nonce, ts };
|
|
6855
|
+
} catch {
|
|
6856
|
+
return null;
|
|
6857
|
+
}
|
|
6858
|
+
}
|
|
6859
|
+
|
|
6567
6860
|
// src/types/api.ts
|
|
6568
6861
|
var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
|
|
6569
6862
|
|
|
@@ -6813,6 +7106,6 @@ function getServicesByCapability(cap) {
|
|
|
6813
7106
|
);
|
|
6814
7107
|
}
|
|
6815
7108
|
|
|
6816
|
-
export { ApiClient, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, CollectionRegistryABI, CreatorCoinFactoryABI, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, FeeConfigSchema, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PUBLIC_RPC_FALLBACKS, PopService, SUPPORTED_TOKENS, VALIDATED_EKUBO_PARAMS, build1155CancellationTypedData, build1155OrderTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createFailoverFetch, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, parseCreatorCoinCreated, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol };
|
|
7109
|
+
export { ADMIN_HEADERS, ADMIN_SCOPE, ApiClient, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, CollectionRegistryABI, CreatorCoinFactoryABI, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, FeeConfigSchema, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, 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 };
|
|
6817
7110
|
//# sourceMappingURL=index.js.map
|
|
6818
7111
|
//# sourceMappingURL=index.js.map
|