@medialane/sdk 0.170.0 → 0.172.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/README.md +1 -1
- package/dist/{chunk-DOIIAXHD.cjs → chunk-BC2L2H6A.cjs} +4 -19
- package/dist/{chunk-DOIIAXHD.cjs.map → chunk-BC2L2H6A.cjs.map} +1 -1
- package/dist/{chunk-HUTEU22Y.js → chunk-DDZJFN65.js} +4 -19
- package/dist/{chunk-HUTEU22Y.js.map → chunk-DDZJFN65.js.map} +1 -1
- package/dist/{errors-PGCoVYdU.d.ts → errors-5C3YHsDE.d.ts} +6 -32
- package/dist/{errors-CZlv-DJJ.d.cts → errors-DvSfHOZu.d.cts} +6 -32
- package/dist/index.cjs +75 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +88 -81
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +14 -8
- package/dist/starknet/index.d.ts +14 -8
- package/dist/starknet/index.js +19 -12
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/starknet/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBC2L2H6A_cjs = require('../chunk-BC2L2H6A.cjs');
|
|
4
4
|
var chunkVJVBWHAD_cjs = require('../chunk-VJVBWHAD.cjs');
|
|
5
5
|
var starknet = require('starknet');
|
|
6
6
|
var hkdf_js = require('@noble/hashes/hkdf.js');
|
|
@@ -33,7 +33,7 @@ function getChainId(config) {
|
|
|
33
33
|
return starknet.constants.StarknetChainId.SN_MAIN;
|
|
34
34
|
}
|
|
35
35
|
function resolveToken(currency) {
|
|
36
|
-
const token =
|
|
36
|
+
const token = chunkBC2L2H6A_cjs.SUPPORTED_TOKENS.find(
|
|
37
37
|
(t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
|
|
38
38
|
);
|
|
39
39
|
if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
|
|
@@ -44,7 +44,7 @@ function getProvider(config) {
|
|
|
44
44
|
let p = _providerCache.get(config);
|
|
45
45
|
if (!p) {
|
|
46
46
|
const urls = [config.rpcUrl];
|
|
47
|
-
p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch:
|
|
47
|
+
p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch: chunkBC2L2H6A_cjs.createFailoverFetch(urls) });
|
|
48
48
|
_providerCache.set(config, p);
|
|
49
49
|
}
|
|
50
50
|
return p;
|
|
@@ -10415,7 +10415,7 @@ function merkleTree(leafHashes) {
|
|
|
10415
10415
|
};
|
|
10416
10416
|
}
|
|
10417
10417
|
function buildPopAllowlist(addresses) {
|
|
10418
|
-
const unique = [...new Set(addresses.map((a) =>
|
|
10418
|
+
const unique = [...new Set(addresses.map((a) => chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", a)))];
|
|
10419
10419
|
if (unique.length === 0) throw new Error("An allowlist needs at least one address");
|
|
10420
10420
|
const leaves = unique.map((address) => ({ address, leaf: popLeafHash(address) }));
|
|
10421
10421
|
const tree = merkleTree(leaves.map((l) => l.leaf));
|
|
@@ -10441,7 +10441,7 @@ function decodePopClaimFragment(fragment) {
|
|
|
10441
10441
|
|
|
10442
10442
|
// src/starknet/pop-claim.ts
|
|
10443
10443
|
function popClaimLinks(origin, collection, list) {
|
|
10444
|
-
const base = `${origin}${
|
|
10444
|
+
const base = `${origin}${chunkBC2L2H6A_cjs.collectionHref("STARKNET", collection)}`;
|
|
10445
10445
|
return Object.entries(list.proofs).map(([address, proof]) => ({
|
|
10446
10446
|
address,
|
|
10447
10447
|
url: `${base}${encodePopClaimFragment(proof)}`
|
|
@@ -10451,7 +10451,7 @@ function popClaimLinksCsv(links) {
|
|
|
10451
10451
|
return ["address,claim_link", ...links.map((l) => `${l.address},${l.url}`)].join("\n");
|
|
10452
10452
|
}
|
|
10453
10453
|
async function popClaimInfo(provider, collection) {
|
|
10454
|
-
const contractAddress =
|
|
10454
|
+
const contractAddress = chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", collection);
|
|
10455
10455
|
const [root, end] = await Promise.all([
|
|
10456
10456
|
provider.callContract({ contractAddress, entrypoint: "allowlist_root", calldata: [] }),
|
|
10457
10457
|
provider.callContract({ contractAddress, entrypoint: "claim_end_time", calldata: [] })
|
|
@@ -10468,7 +10468,7 @@ function popClaimState(input) {
|
|
|
10468
10468
|
if (!wallet || !verifyPopProof(info.root, wallet, proof)) return "wrong-wallet";
|
|
10469
10469
|
return "ready";
|
|
10470
10470
|
}
|
|
10471
|
-
var addr = (a) =>
|
|
10471
|
+
var addr = (a) => chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", a);
|
|
10472
10472
|
var byteArrayFelts = (s) => starknet.CallData.compile([starknet.byteArray.byteArrayFromString(s)]);
|
|
10473
10473
|
var popCalls = {
|
|
10474
10474
|
claim(collection, proof) {
|
|
@@ -10523,9 +10523,9 @@ var PopService = class {
|
|
|
10523
10523
|
};
|
|
10524
10524
|
async function popHasClaimed(provider, collection, address) {
|
|
10525
10525
|
const res = await provider.callContract({
|
|
10526
|
-
contractAddress:
|
|
10526
|
+
contractAddress: chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", collection),
|
|
10527
10527
|
entrypoint: "has_claimed",
|
|
10528
|
-
calldata: [
|
|
10528
|
+
calldata: [chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address)]
|
|
10529
10529
|
});
|
|
10530
10530
|
return BigInt(res[0] ?? "0x0") !== 0n;
|
|
10531
10531
|
}
|
|
@@ -10546,7 +10546,8 @@ function buildFeeCall(p, cfg) {
|
|
|
10546
10546
|
calldata: [cfg.fundAddress, u.low.toString(), u.high.toString()]
|
|
10547
10547
|
};
|
|
10548
10548
|
}
|
|
10549
|
-
var
|
|
10549
|
+
var DROP_MAX_CLAIM_QUANTITY = 50n;
|
|
10550
|
+
var addr2 = (a) => chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", a);
|
|
10550
10551
|
var factoryData = new starknet.CallData(DropFactoryABI);
|
|
10551
10552
|
var collectionData = new starknet.CallData(DropCollectionABI);
|
|
10552
10553
|
function toContractTerms(t) {
|
|
@@ -10577,6 +10578,7 @@ var dropCalls = {
|
|
|
10577
10578
|
/** Approve (paid drops) and claim. The platform fee call is added by the caller. */
|
|
10578
10579
|
claim(collection, p) {
|
|
10579
10580
|
const quantity = BigInt(p.quantity);
|
|
10581
|
+
if (quantity < 1n || quantity > DROP_MAX_CLAIM_QUANTITY) throw new RangeError(`quantity must be 1 to ${DROP_MAX_CLAIM_QUANTITY}`);
|
|
10580
10582
|
const total = BigInt(p.price) * quantity;
|
|
10581
10583
|
const calls = [];
|
|
10582
10584
|
if (total > 0n) {
|
|
@@ -10595,10 +10597,12 @@ var dropCalls = {
|
|
|
10595
10597
|
},
|
|
10596
10598
|
/** Organizer only: free mint within the supply cap. */
|
|
10597
10599
|
issue(collection, recipient, quantity) {
|
|
10600
|
+
const q = BigInt(quantity);
|
|
10601
|
+
if (q < 1n) throw new RangeError("quantity must be at least 1");
|
|
10598
10602
|
return {
|
|
10599
10603
|
contractAddress: addr2(collection),
|
|
10600
10604
|
entrypoint: "issue",
|
|
10601
|
-
calldata: collectionData.compile("issue", { recipient: addr2(recipient), quantity: starknet.cairo.uint256(
|
|
10605
|
+
calldata: collectionData.compile("issue", { recipient: addr2(recipient), quantity: starknet.cairo.uint256(q) })
|
|
10602
10606
|
};
|
|
10603
10607
|
},
|
|
10604
10608
|
/** Organizer only. 0 opens the drop to everyone. */
|
|
@@ -10606,14 +10610,14 @@ var dropCalls = {
|
|
|
10606
10610
|
return { contractAddress: addr2(collection), entrypoint: "set_allowlist_root", calldata: collectionData.compile("set_allowlist_root", { root }) };
|
|
10607
10611
|
}
|
|
10608
10612
|
};
|
|
10609
|
-
function dropMintCost(price, quantity,
|
|
10613
|
+
function dropMintCost(price, quantity, feeBps2) {
|
|
10610
10614
|
const subtotal = BigInt(price) * BigInt(quantity);
|
|
10611
|
-
const fee = feeAmount(subtotal,
|
|
10615
|
+
const fee = feeAmount(subtotal, feeBps2);
|
|
10612
10616
|
return { subtotal, fee, total: subtotal + fee };
|
|
10613
10617
|
}
|
|
10614
10618
|
|
|
10615
10619
|
// src/starknet/drop-state.ts
|
|
10616
|
-
var hex = (v) =>
|
|
10620
|
+
var hex = (v) => chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", v ?? "0x0");
|
|
10617
10621
|
var u256 = (low, high) => BigInt(low ?? "0x0") + (BigInt(high ?? "0x0") << 128n);
|
|
10618
10622
|
async function readDrop(provider, collection) {
|
|
10619
10623
|
const contractAddress = hex(collection);
|
|
@@ -10641,7 +10645,6 @@ async function dropClaimedBy(provider, collection, wallet) {
|
|
|
10641
10645
|
const res = await provider.callContract({ contractAddress: hex(collection), entrypoint: "claimed_by", calldata: [hex(wallet)] });
|
|
10642
10646
|
return u256(res[0], res[1]);
|
|
10643
10647
|
}
|
|
10644
|
-
var DROP_MAX_CLAIM_QUANTITY = 50n;
|
|
10645
10648
|
function dropMintState(input) {
|
|
10646
10649
|
const none = (state) => ({ state, maxQuantity: 0n });
|
|
10647
10650
|
const { drop, wallet, claimed, proof, balance, now } = input;
|
|
@@ -10663,13 +10666,13 @@ function dropMintState(input) {
|
|
|
10663
10666
|
if (walletLeft !== null && walletLeft < max) max = walletLeft;
|
|
10664
10667
|
if (drop.price > 0n) {
|
|
10665
10668
|
if (balance === null) return none("loading");
|
|
10666
|
-
while (max > 0n && dropMintCost(drop.price, max, input.
|
|
10669
|
+
while (max > 0n && dropMintCost(drop.price, max, input.feeBps).total > balance) max--;
|
|
10667
10670
|
if (max === 0n) return none("insufficient-balance");
|
|
10668
10671
|
}
|
|
10669
10672
|
return { state: "ready", maxQuantity: max };
|
|
10670
10673
|
}
|
|
10671
10674
|
function dropClaimLinks(origin, collection, list) {
|
|
10672
|
-
const base = `${origin}${
|
|
10675
|
+
const base = `${origin}${chunkBC2L2H6A_cjs.dropHref(collection)}`;
|
|
10673
10676
|
return Object.entries(list.proofs).map(([address, proof]) => ({
|
|
10674
10677
|
address,
|
|
10675
10678
|
url: `${base}${encodePopClaimFragment(proof)}`
|
|
@@ -10721,14 +10724,14 @@ var ERC1155CollectionService = class {
|
|
|
10721
10724
|
_factory(account) {
|
|
10722
10725
|
return newContract(
|
|
10723
10726
|
IPCollection1155FactoryABI,
|
|
10724
|
-
|
|
10727
|
+
chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", this.factoryAddress),
|
|
10725
10728
|
account
|
|
10726
10729
|
);
|
|
10727
10730
|
}
|
|
10728
10731
|
_collection(address, account) {
|
|
10729
10732
|
return newContract(
|
|
10730
10733
|
IPCollection1155ABI,
|
|
10731
|
-
|
|
10734
|
+
chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address),
|
|
10732
10735
|
account
|
|
10733
10736
|
);
|
|
10734
10737
|
}
|
|
@@ -10956,20 +10959,20 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
10956
10959
|
}
|
|
10957
10960
|
var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
|
|
10958
10961
|
function parseCreatorCoinCreated(receipt) {
|
|
10959
|
-
const factory =
|
|
10962
|
+
const factory = chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", chunkVJVBWHAD_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory);
|
|
10960
10963
|
for (const ev of receipt?.events ?? []) {
|
|
10961
10964
|
let from;
|
|
10962
10965
|
try {
|
|
10963
|
-
from =
|
|
10966
|
+
from = chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", ev.from_address ?? "");
|
|
10964
10967
|
} catch {
|
|
10965
10968
|
continue;
|
|
10966
10969
|
}
|
|
10967
10970
|
if (from !== factory) continue;
|
|
10968
10971
|
const k0 = ev.keys?.[0];
|
|
10969
|
-
if (!k0 ||
|
|
10972
|
+
if (!k0 || chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", k0) !== chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
|
|
10970
10973
|
const data = ev.data ?? [];
|
|
10971
10974
|
if (data.length < 1) continue;
|
|
10972
|
-
return
|
|
10975
|
+
return chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", data[data.length - 1]);
|
|
10973
10976
|
}
|
|
10974
10977
|
throw new Error("Coin deployed but the coin address could not be read from the receipt");
|
|
10975
10978
|
}
|
|
@@ -11005,14 +11008,14 @@ var TicketService = class {
|
|
|
11005
11008
|
_factory(account, factoryAddress) {
|
|
11006
11009
|
const address = factoryAddress ?? this.factoryAddress;
|
|
11007
11010
|
if (!address) throw new Error("IP-Tickets factory address not configured for this chain");
|
|
11008
|
-
return newContract(IPTicketCollectionFactoryABI,
|
|
11011
|
+
return newContract(IPTicketCollectionFactoryABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address), account);
|
|
11009
11012
|
}
|
|
11010
11013
|
_collection(address, account) {
|
|
11011
|
-
return newContract(IPTicketCollectionABI,
|
|
11014
|
+
return newContract(IPTicketCollectionABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address), account);
|
|
11012
11015
|
}
|
|
11013
11016
|
_collectionRead(address) {
|
|
11014
11017
|
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
11015
|
-
return newContract(IPTicketCollectionABI,
|
|
11018
|
+
return newContract(IPTicketCollectionABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address), provider);
|
|
11016
11019
|
}
|
|
11017
11020
|
async deployCollection(account, params) {
|
|
11018
11021
|
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
@@ -11078,14 +11081,14 @@ var ClubService = class {
|
|
|
11078
11081
|
_factory(account, factoryAddress) {
|
|
11079
11082
|
const address = factoryAddress ?? this.factoryAddress;
|
|
11080
11083
|
if (!address) throw new Error("IP-Club factory address not configured for this chain");
|
|
11081
|
-
return newContract(IPClubFactoryABI,
|
|
11084
|
+
return newContract(IPClubFactoryABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address), account);
|
|
11082
11085
|
}
|
|
11083
11086
|
_collection(address, account) {
|
|
11084
|
-
return newContract(IPClubCollectionABI,
|
|
11087
|
+
return newContract(IPClubCollectionABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address), account);
|
|
11085
11088
|
}
|
|
11086
11089
|
_collectionRead(address) {
|
|
11087
11090
|
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
11088
|
-
return newContract(IPClubCollectionABI,
|
|
11091
|
+
return newContract(IPClubCollectionABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address), provider);
|
|
11089
11092
|
}
|
|
11090
11093
|
async deployCollection(account, params) {
|
|
11091
11094
|
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
@@ -11155,7 +11158,7 @@ var SponsorshipService = class {
|
|
|
11155
11158
|
if (!resolved) {
|
|
11156
11159
|
throw new Error("IP-Sponsorship address not configured for this chain");
|
|
11157
11160
|
}
|
|
11158
|
-
return newContract(IPSponsorshipABI,
|
|
11161
|
+
return newContract(IPSponsorshipABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", resolved), account);
|
|
11159
11162
|
}
|
|
11160
11163
|
_contractRead(address) {
|
|
11161
11164
|
const resolved = address ?? this.sponsorshipAddress;
|
|
@@ -11163,7 +11166,7 @@ var SponsorshipService = class {
|
|
|
11163
11166
|
throw new Error("IP-Sponsorship address not configured for this chain");
|
|
11164
11167
|
}
|
|
11165
11168
|
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
11166
|
-
return newContract(IPSponsorshipABI,
|
|
11169
|
+
return newContract(IPSponsorshipABI, chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", resolved), provider);
|
|
11167
11170
|
}
|
|
11168
11171
|
async createOffer(account, params) {
|
|
11169
11172
|
const specificSponsor = params.specificSponsor ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.specificSponsor) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
|
|
@@ -11198,7 +11201,7 @@ var SponsorshipService = class {
|
|
|
11198
11201
|
const approveCall = {
|
|
11199
11202
|
contractAddress: params.paymentToken,
|
|
11200
11203
|
entrypoint: "approve",
|
|
11201
|
-
calldata: [
|
|
11204
|
+
calldata: [chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", sponsorshipAddress), amount.low.toString(), amount.high.toString()]
|
|
11202
11205
|
};
|
|
11203
11206
|
const bidCall = this._contract(account, sponsorshipAddress).populate("place_bid", [
|
|
11204
11207
|
starknet.cairo.uint256(params.offerId),
|
|
@@ -11325,7 +11328,7 @@ var SponsorshipService = class {
|
|
|
11325
11328
|
// src/starknet/client.ts
|
|
11326
11329
|
var MedialaneClient = class {
|
|
11327
11330
|
constructor(rawConfig = {}) {
|
|
11328
|
-
this.config =
|
|
11331
|
+
this.config = chunkBC2L2H6A_cjs.resolveConfig(rawConfig);
|
|
11329
11332
|
this.services = {
|
|
11330
11333
|
pop: new PopService(this.config),
|
|
11331
11334
|
drop: new DropService(this.config),
|
|
@@ -11336,9 +11339,9 @@ var MedialaneClient = class {
|
|
|
11336
11339
|
sponsorship: new SponsorshipService(this.config)
|
|
11337
11340
|
};
|
|
11338
11341
|
if (!this.config.backendUrl) {
|
|
11339
|
-
const sentinel = new
|
|
11342
|
+
const sentinel = new chunkBC2L2H6A_cjs.ApiClient("https://medialane-sdk-no-backend.invalid", this.config.apiKey);
|
|
11340
11343
|
const apiMethodNames = new Set(
|
|
11341
|
-
Object.getOwnPropertyNames(
|
|
11344
|
+
Object.getOwnPropertyNames(chunkBC2L2H6A_cjs.ApiClient.prototype).filter(
|
|
11342
11345
|
(k) => k !== "constructor" && typeof sentinel[k] === "function"
|
|
11343
11346
|
)
|
|
11344
11347
|
);
|
|
@@ -11355,7 +11358,7 @@ var MedialaneClient = class {
|
|
|
11355
11358
|
}
|
|
11356
11359
|
});
|
|
11357
11360
|
} else {
|
|
11358
|
-
this.api = new
|
|
11361
|
+
this.api = new chunkBC2L2H6A_cjs.ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
|
|
11359
11362
|
}
|
|
11360
11363
|
}
|
|
11361
11364
|
get chain() {
|
|
@@ -11527,7 +11530,7 @@ function buildListingOrder(i, cfg) {
|
|
|
11527
11530
|
salt: i.salt,
|
|
11528
11531
|
counter: i.counter
|
|
11529
11532
|
};
|
|
11530
|
-
const typedData =
|
|
11533
|
+
const typedData = chunkBC2L2H6A_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
|
|
11531
11534
|
return { orderParams, typedData };
|
|
11532
11535
|
}
|
|
11533
11536
|
function buildOfferOrder(i, cfg) {
|
|
@@ -11548,11 +11551,11 @@ function buildOfferOrder(i, cfg) {
|
|
|
11548
11551
|
salt: i.salt,
|
|
11549
11552
|
counter: i.counter
|
|
11550
11553
|
};
|
|
11551
|
-
const typedData =
|
|
11554
|
+
const typedData = chunkBC2L2H6A_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
|
|
11552
11555
|
return { orderParams, typedData };
|
|
11553
11556
|
}
|
|
11554
11557
|
function registerPayload(orderParams, signature) {
|
|
11555
|
-
return
|
|
11558
|
+
return chunkBC2L2H6A_cjs.stringifyBigInts({
|
|
11556
11559
|
parameters: {
|
|
11557
11560
|
...orderParams,
|
|
11558
11561
|
offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
|
|
@@ -11583,14 +11586,14 @@ function buildFulfillCalls(a, cfg) {
|
|
|
11583
11586
|
return fee ? [approve, fulfill, fee] : [approve, fulfill];
|
|
11584
11587
|
}
|
|
11585
11588
|
function buildCancelCalls(a, cfg) {
|
|
11586
|
-
const cancelRequest =
|
|
11589
|
+
const cancelRequest = chunkBC2L2H6A_cjs.stringifyBigInts({
|
|
11587
11590
|
cancelation: { order_hash: a.orderHash, offerer: a.offerer },
|
|
11588
11591
|
signature: a.signature
|
|
11589
11592
|
});
|
|
11590
11593
|
return [contractFor(cfg).populate("cancel_order", [cancelRequest])];
|
|
11591
11594
|
}
|
|
11592
11595
|
function buildCancelTypedData(orderHash, offerer, cfg) {
|
|
11593
|
-
return
|
|
11596
|
+
return chunkBC2L2H6A_cjs.stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
|
|
11594
11597
|
}
|
|
11595
11598
|
function contractFor2(cfg) {
|
|
11596
11599
|
return newContract(Medialane1155ABI, cfg.marketplace1155Contract, getProvider(cfg));
|
|
@@ -11613,7 +11616,7 @@ function buildListing1155Order(i, cfg) {
|
|
|
11613
11616
|
salt: i.salt,
|
|
11614
11617
|
counter: i.counter
|
|
11615
11618
|
};
|
|
11616
|
-
const typedData =
|
|
11619
|
+
const typedData = chunkBC2L2H6A_cjs.stringifyBigInts(
|
|
11617
11620
|
build1155OrderTypedData(orderParams, getChainId(cfg))
|
|
11618
11621
|
);
|
|
11619
11622
|
return { orderParams, typedData };
|
|
@@ -11636,13 +11639,13 @@ function buildOffer1155Order(i, cfg) {
|
|
|
11636
11639
|
salt: i.salt,
|
|
11637
11640
|
counter: i.counter
|
|
11638
11641
|
};
|
|
11639
|
-
const typedData =
|
|
11642
|
+
const typedData = chunkBC2L2H6A_cjs.stringifyBigInts(
|
|
11640
11643
|
build1155OrderTypedData(orderParams, getChainId(cfg))
|
|
11641
11644
|
);
|
|
11642
11645
|
return { orderParams, typedData };
|
|
11643
11646
|
}
|
|
11644
11647
|
function registerPayload2(orderParams, signature) {
|
|
11645
|
-
return
|
|
11648
|
+
return chunkBC2L2H6A_cjs.stringifyBigInts({
|
|
11646
11649
|
parameters: {
|
|
11647
11650
|
...orderParams,
|
|
11648
11651
|
offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
|
|
@@ -11673,14 +11676,14 @@ function buildFulfill1155Calls(a, cfg) {
|
|
|
11673
11676
|
return fee ? [approve, fulfill, fee] : [approve, fulfill];
|
|
11674
11677
|
}
|
|
11675
11678
|
function buildCancel1155Calls(a, cfg) {
|
|
11676
|
-
const cancelPayload =
|
|
11679
|
+
const cancelPayload = chunkBC2L2H6A_cjs.stringifyBigInts({
|
|
11677
11680
|
cancelation: { order_hash: a.orderHash, offerer: a.offerer },
|
|
11678
11681
|
signature: a.signature
|
|
11679
11682
|
});
|
|
11680
11683
|
return [contractFor2(cfg).populate("cancel_order", [cancelPayload])];
|
|
11681
11684
|
}
|
|
11682
11685
|
function buildCancel1155TypedData(orderHash, offerer, cfg) {
|
|
11683
|
-
return
|
|
11686
|
+
return chunkBC2L2H6A_cjs.stringifyBigInts(
|
|
11684
11687
|
build1155CancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg))
|
|
11685
11688
|
);
|
|
11686
11689
|
}
|
|
@@ -12024,14 +12027,14 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
|
|
|
12024
12027
|
const receipt = await provider.getTransactionReceipt(txHash);
|
|
12025
12028
|
const status = receipt.execution_status ?? receipt.status;
|
|
12026
12029
|
if (status === "REVERTED" || status === "REJECTED") {
|
|
12027
|
-
throw new
|
|
12030
|
+
throw new chunkBC2L2H6A_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
|
|
12028
12031
|
}
|
|
12029
12032
|
if (status) return receipt;
|
|
12030
12033
|
} catch (err) {
|
|
12031
12034
|
if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
|
|
12032
12035
|
}
|
|
12033
12036
|
}
|
|
12034
|
-
throw new
|
|
12037
|
+
throw new chunkBC2L2H6A_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
|
|
12035
12038
|
}
|
|
12036
12039
|
async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
12037
12040
|
let calls;
|
|
@@ -12084,14 +12087,14 @@ function u2563(low, high) {
|
|
|
12084
12087
|
return (BigInt(low ?? 0) + (BigInt(high ?? 0) << 128n)).toString();
|
|
12085
12088
|
}
|
|
12086
12089
|
function deployedCollectionFromReceipt(receipt, service) {
|
|
12087
|
-
const factory =
|
|
12090
|
+
const factory = chunkBC2L2H6A_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
|
|
12088
12091
|
const { event, address } = DEPLOY_EVENTS[service];
|
|
12089
12092
|
const selector = BigInt(starknet.hash.getSelectorFromName(event));
|
|
12090
12093
|
for (const e of receipt.events ?? []) {
|
|
12091
12094
|
if (factory && !sameFelt(e.from_address, factory)) continue;
|
|
12092
12095
|
if (!sameFelt(e.keys?.[0], selector)) continue;
|
|
12093
12096
|
const value = address(e);
|
|
12094
|
-
if (value) return
|
|
12097
|
+
if (value) return chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", value);
|
|
12095
12098
|
}
|
|
12096
12099
|
return null;
|
|
12097
12100
|
}
|
|
@@ -12117,14 +12120,14 @@ async function failureOf(res, fallback) {
|
|
|
12117
12120
|
const body = await res.json().catch(() => null);
|
|
12118
12121
|
return { reason: body?.error || fallback, code: typeof body?.code === "string" ? body.code : void 0 };
|
|
12119
12122
|
}
|
|
12120
|
-
async function executeSponsored(config, signer,
|
|
12123
|
+
async function executeSponsored(config, signer, request) {
|
|
12121
12124
|
const doFetch = config.fetchImpl ?? fetch;
|
|
12122
12125
|
const base = config.proxyUrl.replace(/\/$/, "");
|
|
12123
12126
|
const headers = { "Content-Type": "application/json", ...config.headers };
|
|
12124
12127
|
const buildRes = await doFetch(`${base}/build`, {
|
|
12125
12128
|
method: "POST",
|
|
12126
12129
|
headers,
|
|
12127
|
-
body: JSON.stringify(
|
|
12130
|
+
body: JSON.stringify(request)
|
|
12128
12131
|
});
|
|
12129
12132
|
if (!buildRes.ok) {
|
|
12130
12133
|
const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
|
|
@@ -12136,7 +12139,7 @@ async function executeSponsored(config, signer, calls, intentIds) {
|
|
|
12136
12139
|
const executeRes = await doFetch(`${base}/execute`, {
|
|
12137
12140
|
method: "POST",
|
|
12138
12141
|
headers,
|
|
12139
|
-
body: JSON.stringify(
|
|
12142
|
+
body: JSON.stringify({ ...request, typedData, signature })
|
|
12140
12143
|
});
|
|
12141
12144
|
if (!executeRes.ok) {
|
|
12142
12145
|
const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
|
|
@@ -12212,13 +12215,13 @@ function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
|
|
|
12212
12215
|
}
|
|
12213
12216
|
function buildDeployAccountParams(ownerPubkey, salt = 0) {
|
|
12214
12217
|
return {
|
|
12215
|
-
classHash:
|
|
12216
|
-
constructorCalldata:
|
|
12218
|
+
classHash: chunkBC2L2H6A_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
|
|
12219
|
+
constructorCalldata: chunkBC2L2H6A_cjs.ownerConstructorCalldata(ownerPubkey),
|
|
12217
12220
|
addressSalt: starknet.num.toHex(salt),
|
|
12218
|
-
contractAddress:
|
|
12221
|
+
contractAddress: chunkBC2L2H6A_cjs.computeAccountAddress(ownerPubkey, salt)
|
|
12219
12222
|
};
|
|
12220
12223
|
}
|
|
12221
|
-
var norm = (address) =>
|
|
12224
|
+
var norm = (address) => chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address);
|
|
12222
12225
|
var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
|
|
12223
12226
|
function encodeFeltArray(items) {
|
|
12224
12227
|
return [starknet.num.toHex(items.length), ...items];
|
|
@@ -12415,7 +12418,7 @@ var InvalidRecoveryKeyError = class extends Error {
|
|
|
12415
12418
|
var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
|
|
12416
12419
|
function keyPair(privateKey) {
|
|
12417
12420
|
try {
|
|
12418
|
-
return
|
|
12421
|
+
return chunkBC2L2H6A_cjs.starkKeyPairFromPrivateKey(privateKey);
|
|
12419
12422
|
} catch {
|
|
12420
12423
|
throw new InvalidRecoveryKeyError();
|
|
12421
12424
|
}
|
|
@@ -12428,7 +12431,7 @@ function parseRecoveryKey(input) {
|
|
|
12428
12431
|
const trimmed = input.trim();
|
|
12429
12432
|
if (!trimmed.startsWith(PREFIX)) {
|
|
12430
12433
|
const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
|
|
12431
|
-
return { walletAddress:
|
|
12434
|
+
return { walletAddress: chunkBC2L2H6A_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
|
|
12432
12435
|
}
|
|
12433
12436
|
const parts = trimmed.slice(PREFIX.length).split(":");
|
|
12434
12437
|
const [walletAddress, privateKey] = parts;
|
|
@@ -12450,7 +12453,7 @@ function describeRecoveryAction(escape) {
|
|
|
12450
12453
|
return "none";
|
|
12451
12454
|
}
|
|
12452
12455
|
function normalizeWalletAddress(address) {
|
|
12453
|
-
return
|
|
12456
|
+
return chunkBC2L2H6A_cjs.normalizeAddress("STARKNET", address);
|
|
12454
12457
|
}
|
|
12455
12458
|
function isValidStarknetAddress(address) {
|
|
12456
12459
|
try {
|
|
@@ -12495,7 +12498,7 @@ async function estimateSelfFundedFee(provider, address, calls) {
|
|
|
12495
12498
|
return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
|
|
12496
12499
|
}
|
|
12497
12500
|
async function feeTokenBalance(provider, address, unit) {
|
|
12498
|
-
const token =
|
|
12501
|
+
const token = chunkBC2L2H6A_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
|
|
12499
12502
|
if (!token) throw new Error(`No fee token for unit ${unit}`);
|
|
12500
12503
|
const [low = "0x0", high = "0x0"] = await provider.callContract({
|
|
12501
12504
|
contractAddress: token.address,
|
|
@@ -12518,14 +12521,18 @@ function sponsoredExecutor(deps) {
|
|
|
12518
12521
|
return {
|
|
12519
12522
|
async execute(input) {
|
|
12520
12523
|
const { userAddress, privateKeyHex, calls, intentIds } = input;
|
|
12524
|
+
if (!intentIds?.length) {
|
|
12525
|
+
const consented2 = await deps.consent.request({ address: userAddress, calls });
|
|
12526
|
+
if (!consented2) throw new SponsoredCallRejectedError("This action can't be sponsored");
|
|
12527
|
+
return fallback.execute(input);
|
|
12528
|
+
}
|
|
12521
12529
|
const result = await executeSponsored(
|
|
12522
12530
|
{ proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
|
|
12523
12531
|
{
|
|
12524
12532
|
address: userAddress,
|
|
12525
|
-
signTypedData: async (data) =>
|
|
12533
|
+
signTypedData: async (data) => chunkBC2L2H6A_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
|
|
12526
12534
|
},
|
|
12527
|
-
|
|
12528
|
-
intentIds
|
|
12535
|
+
{ intentIds }
|
|
12529
12536
|
);
|
|
12530
12537
|
if (result.status === "sponsored") return { transactionHash: result.transactionHash };
|
|
12531
12538
|
const consented = await deps.consent.request({ address: userAddress, calls });
|
|
@@ -12583,7 +12590,7 @@ async function deploySelfFunded(input) {
|
|
|
12583
12590
|
});
|
|
12584
12591
|
const { transaction_hash } = await account.deployAccount({
|
|
12585
12592
|
classHash,
|
|
12586
|
-
constructorCalldata:
|
|
12593
|
+
constructorCalldata: chunkBC2L2H6A_cjs.ownerConstructorCalldata(input.ownerPubKey),
|
|
12587
12594
|
addressSalt: 0,
|
|
12588
12595
|
contractAddress: input.ownerAddress
|
|
12589
12596
|
});
|
|
@@ -12651,7 +12658,7 @@ async function completeDeployment(deps, onStep, options = {}) {
|
|
|
12651
12658
|
backendUrl: deps.backendUrl,
|
|
12652
12659
|
walletAddress: address,
|
|
12653
12660
|
signer: {
|
|
12654
|
-
signMessage: async (td) =>
|
|
12661
|
+
signMessage: async (td) => chunkBC2L2H6A_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(td, address))
|
|
12655
12662
|
}
|
|
12656
12663
|
});
|
|
12657
12664
|
deps.store.notifyChange();
|
|
@@ -12750,7 +12757,7 @@ function createMediaWallet(config) {
|
|
|
12750
12757
|
};
|
|
12751
12758
|
const walletIntents = config.walletIntents ?? (async (params) => {
|
|
12752
12759
|
if (!config.backendUrl) throw new Error("This wallet has no backend url configured");
|
|
12753
|
-
const created = await new
|
|
12760
|
+
const created = await new chunkBC2L2H6A_cjs.ApiClient(config.backendUrl).createWalletManageIntent(params);
|
|
12754
12761
|
return created.data;
|
|
12755
12762
|
});
|
|
12756
12763
|
const manage = async (sealed, params) => {
|
|
@@ -12767,7 +12774,7 @@ function createMediaWallet(config) {
|
|
|
12767
12774
|
address: sealed.address,
|
|
12768
12775
|
signTypedData: async (data) => {
|
|
12769
12776
|
const privateKeyHex = await unlockOnce(sealed);
|
|
12770
|
-
return
|
|
12777
|
+
return chunkBC2L2H6A_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
|
|
12771
12778
|
},
|
|
12772
12779
|
execute: async (calls, opts) => {
|
|
12773
12780
|
const { transactionHash } = await run(sealed, calls, void 0, opts?.intentIds);
|
|
@@ -12808,55 +12815,55 @@ async function claimSessionWallet(api, walletAddress, deps) {
|
|
|
12808
12815
|
|
|
12809
12816
|
Object.defineProperty(exports, "InvalidStarkPrivateKeyError", {
|
|
12810
12817
|
enumerable: true,
|
|
12811
|
-
get: function () { return
|
|
12818
|
+
get: function () { return chunkBC2L2H6A_cjs.InvalidStarkPrivateKeyError; }
|
|
12812
12819
|
});
|
|
12813
12820
|
Object.defineProperty(exports, "PasskeyCancelledError", {
|
|
12814
12821
|
enumerable: true,
|
|
12815
|
-
get: function () { return
|
|
12822
|
+
get: function () { return chunkBC2L2H6A_cjs.PasskeyCancelledError; }
|
|
12816
12823
|
});
|
|
12817
12824
|
Object.defineProperty(exports, "PasskeyUnsupportedError", {
|
|
12818
12825
|
enumerable: true,
|
|
12819
|
-
get: function () { return
|
|
12826
|
+
get: function () { return chunkBC2L2H6A_cjs.PasskeyUnsupportedError; }
|
|
12820
12827
|
});
|
|
12821
12828
|
Object.defineProperty(exports, "UserFacingError", {
|
|
12822
12829
|
enumerable: true,
|
|
12823
|
-
get: function () { return
|
|
12830
|
+
get: function () { return chunkBC2L2H6A_cjs.UserFacingError; }
|
|
12824
12831
|
});
|
|
12825
12832
|
Object.defineProperty(exports, "computeAccountAddress", {
|
|
12826
12833
|
enumerable: true,
|
|
12827
|
-
get: function () { return
|
|
12834
|
+
get: function () { return chunkBC2L2H6A_cjs.computeAccountAddress; }
|
|
12828
12835
|
});
|
|
12829
12836
|
Object.defineProperty(exports, "createPasskeyOwner", {
|
|
12830
12837
|
enumerable: true,
|
|
12831
|
-
get: function () { return
|
|
12838
|
+
get: function () { return chunkBC2L2H6A_cjs.createPasskeyOwner; }
|
|
12832
12839
|
});
|
|
12833
12840
|
Object.defineProperty(exports, "deriveAesKey", {
|
|
12834
12841
|
enumerable: true,
|
|
12835
|
-
get: function () { return
|
|
12842
|
+
get: function () { return chunkBC2L2H6A_cjs.deriveAesKey; }
|
|
12836
12843
|
});
|
|
12837
12844
|
Object.defineProperty(exports, "generateStarkKeyPair", {
|
|
12838
12845
|
enumerable: true,
|
|
12839
|
-
get: function () { return
|
|
12846
|
+
get: function () { return chunkBC2L2H6A_cjs.generateStarkKeyPair; }
|
|
12840
12847
|
});
|
|
12841
12848
|
Object.defineProperty(exports, "ownerConstructorCalldata", {
|
|
12842
12849
|
enumerable: true,
|
|
12843
|
-
get: function () { return
|
|
12850
|
+
get: function () { return chunkBC2L2H6A_cjs.ownerConstructorCalldata; }
|
|
12844
12851
|
});
|
|
12845
12852
|
Object.defineProperty(exports, "sealPrivateKey", {
|
|
12846
12853
|
enumerable: true,
|
|
12847
|
-
get: function () { return
|
|
12854
|
+
get: function () { return chunkBC2L2H6A_cjs.sealPrivateKey; }
|
|
12848
12855
|
});
|
|
12849
12856
|
Object.defineProperty(exports, "signWithPrivateKey", {
|
|
12850
12857
|
enumerable: true,
|
|
12851
|
-
get: function () { return
|
|
12858
|
+
get: function () { return chunkBC2L2H6A_cjs.signWithPrivateKey; }
|
|
12852
12859
|
});
|
|
12853
12860
|
Object.defineProperty(exports, "starkKeyPairFromPrivateKey", {
|
|
12854
12861
|
enumerable: true,
|
|
12855
|
-
get: function () { return
|
|
12862
|
+
get: function () { return chunkBC2L2H6A_cjs.starkKeyPairFromPrivateKey; }
|
|
12856
12863
|
});
|
|
12857
12864
|
Object.defineProperty(exports, "unsealPrivateKey", {
|
|
12858
12865
|
enumerable: true,
|
|
12859
|
-
get: function () { return
|
|
12866
|
+
get: function () { return chunkBC2L2H6A_cjs.unsealPrivateKey; }
|
|
12860
12867
|
});
|
|
12861
12868
|
exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
|
|
12862
12869
|
exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
|