@medialane/sdk 0.180.0 → 0.182.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 +2 -4
- package/dist/{chunk-WYKCGQPN.js → chunk-3ME5YKTW.js} +2 -3
- package/dist/chunk-3ME5YKTW.js.map +1 -0
- package/dist/{chunk-VJVBWHAD.cjs → chunk-7EYJC5CB.cjs} +2 -3
- package/dist/chunk-7EYJC5CB.cjs.map +1 -0
- package/dist/{chunk-PNUHSQPU.cjs → chunk-F5USCCM4.cjs} +37 -126
- package/dist/chunk-F5USCCM4.cjs.map +1 -0
- package/dist/{chunk-H263CTVH.js → chunk-JZXIZGHW.js} +34 -119
- package/dist/chunk-JZXIZGHW.js.map +1 -0
- package/dist/{errors-DThsFcc1.d.cts → errors-C3dgi8bK.d.cts} +35 -26
- package/dist/{errors-CTVls5-y.d.ts → errors-kFtjB-a3.d.ts} +35 -26
- package/dist/evm/index.cjs +3 -3
- package/dist/evm/index.d.cts +1 -1
- package/dist/evm/index.d.ts +1 -1
- package/dist/evm/index.js +1 -1
- package/dist/index.cjs +83 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -27
- package/dist/index.d.ts +7 -27
- package/dist/index.js +9 -14
- package/dist/index.js.map +1 -1
- package/dist/solana/index.cjs +2 -2
- package/dist/solana/index.d.cts +1 -1
- package/dist/solana/index.d.ts +1 -1
- package/dist/solana/index.js +1 -1
- package/dist/starknet/index.cjs +137 -290
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +15 -120
- package/dist/starknet/index.d.ts +15 -120
- package/dist/starknet/index.js +62 -214
- package/dist/starknet/index.js.map +1 -1
- package/dist/stellar/index.cjs +2 -2
- package/dist/stellar/index.d.cts +1 -1
- package/dist/stellar/index.d.ts +1 -1
- package/dist/stellar/index.js +1 -1
- package/dist/{types-BTNjkUst.d.cts → types-DC4jNPAF.d.cts} +0 -4
- package/dist/{types-BTNjkUst.d.ts → types-DC4jNPAF.d.ts} +0 -4
- package/package.json +1 -1
- package/dist/chunk-H263CTVH.js.map +0 -1
- package/dist/chunk-PNUHSQPU.cjs.map +0 -1
- package/dist/chunk-VJVBWHAD.cjs.map +0 -1
- package/dist/chunk-WYKCGQPN.js.map +0 -1
package/dist/starknet/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkF5USCCM4_cjs = require('../chunk-F5USCCM4.cjs');
|
|
4
|
+
var chunk7EYJC5CB_cjs = require('../chunk-7EYJC5CB.cjs');
|
|
5
5
|
var starknet = require('starknet');
|
|
6
6
|
var hkdf_js = require('@noble/hashes/hkdf.js');
|
|
7
7
|
var sha2_js = require('@noble/hashes/sha2.js');
|
|
@@ -33,22 +33,12 @@ function getChainId(config) {
|
|
|
33
33
|
return starknet.constants.StarknetChainId.SN_MAIN;
|
|
34
34
|
}
|
|
35
35
|
function resolveToken(currency) {
|
|
36
|
-
const token =
|
|
36
|
+
const token = chunkF5USCCM4_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");
|
|
40
40
|
return token;
|
|
41
41
|
}
|
|
42
|
-
var _providerCache = /* @__PURE__ */ new WeakMap();
|
|
43
|
-
function getProvider(config) {
|
|
44
|
-
let p = _providerCache.get(config);
|
|
45
|
-
if (!p) {
|
|
46
|
-
const urls = [config.rpcUrl];
|
|
47
|
-
p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch: chunkPNUHSQPU_cjs.createFailoverFetch(urls) });
|
|
48
|
-
_providerCache.set(config, p);
|
|
49
|
-
}
|
|
50
|
-
return p;
|
|
51
|
-
}
|
|
52
42
|
|
|
53
43
|
// src/starknet/abis/ipMarketplace.ts
|
|
54
44
|
var IPMarketplaceABI = [
|
|
@@ -10415,7 +10405,7 @@ function merkleTree(leafHashes) {
|
|
|
10415
10405
|
};
|
|
10416
10406
|
}
|
|
10417
10407
|
function buildPopAllowlist(addresses) {
|
|
10418
|
-
const unique = [...new Set(addresses.map((a) =>
|
|
10408
|
+
const unique = [...new Set(addresses.map((a) => chunkF5USCCM4_cjs.normalizeAddress("STARKNET", a)))];
|
|
10419
10409
|
if (unique.length === 0) throw new Error("An allowlist needs at least one address");
|
|
10420
10410
|
const leaves = unique.map((address) => ({ address, leaf: popLeafHash(address) }));
|
|
10421
10411
|
const tree = merkleTree(leaves.map((l) => l.leaf));
|
|
@@ -10441,7 +10431,7 @@ function decodePopClaimFragment(fragment) {
|
|
|
10441
10431
|
|
|
10442
10432
|
// src/starknet/pop-claim.ts
|
|
10443
10433
|
function popClaimLinks(origin, collection, list) {
|
|
10444
|
-
const base = `${origin}${
|
|
10434
|
+
const base = `${origin}${chunkF5USCCM4_cjs.collectionHref("STARKNET", collection)}`;
|
|
10445
10435
|
return Object.entries(list.proofs).map(([address, proof]) => ({
|
|
10446
10436
|
address,
|
|
10447
10437
|
url: `${base}${encodePopClaimFragment(proof)}`
|
|
@@ -10451,7 +10441,7 @@ function popClaimLinksCsv(links) {
|
|
|
10451
10441
|
return ["address,claim_link", ...links.map((l) => `${l.address},${l.url}`)].join("\n");
|
|
10452
10442
|
}
|
|
10453
10443
|
async function popClaimInfo(provider, collection) {
|
|
10454
|
-
const contractAddress =
|
|
10444
|
+
const contractAddress = chunkF5USCCM4_cjs.normalizeAddress("STARKNET", collection);
|
|
10455
10445
|
const [root, end] = await Promise.all([
|
|
10456
10446
|
provider.callContract({ contractAddress, entrypoint: "allowlist_root", calldata: [] }),
|
|
10457
10447
|
provider.callContract({ contractAddress, entrypoint: "claim_end_time", calldata: [] })
|
|
@@ -10468,7 +10458,7 @@ function popClaimState(input) {
|
|
|
10468
10458
|
if (!wallet || !verifyPopProof(info.root, wallet, proof)) return "wrong-wallet";
|
|
10469
10459
|
return "ready";
|
|
10470
10460
|
}
|
|
10471
|
-
var addr = (a) =>
|
|
10461
|
+
var addr = (a) => chunkF5USCCM4_cjs.normalizeAddress("STARKNET", a);
|
|
10472
10462
|
var byteArrayFelts = (s) => starknet.CallData.compile([starknet.byteArray.byteArrayFromString(s)]);
|
|
10473
10463
|
var popCalls = {
|
|
10474
10464
|
claim(collection, proof) {
|
|
@@ -10491,7 +10481,7 @@ var popCalls = {
|
|
|
10491
10481
|
// src/starknet/services/pop.ts
|
|
10492
10482
|
var PopService = class {
|
|
10493
10483
|
constructor(config) {
|
|
10494
|
-
this.factoryAddress =
|
|
10484
|
+
this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).popFactory;
|
|
10495
10485
|
}
|
|
10496
10486
|
async createCollection(account, params) {
|
|
10497
10487
|
const factory = newContract(POPFactoryABI, this.factoryAddress, account);
|
|
@@ -10523,9 +10513,9 @@ var PopService = class {
|
|
|
10523
10513
|
};
|
|
10524
10514
|
async function popHasClaimed(provider, collection, address) {
|
|
10525
10515
|
const res = await provider.callContract({
|
|
10526
|
-
contractAddress:
|
|
10516
|
+
contractAddress: chunkF5USCCM4_cjs.normalizeAddress("STARKNET", collection),
|
|
10527
10517
|
entrypoint: "has_claimed",
|
|
10528
|
-
calldata: [
|
|
10518
|
+
calldata: [chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address)]
|
|
10529
10519
|
});
|
|
10530
10520
|
return BigInt(res[0] ?? "0x0") !== 0n;
|
|
10531
10521
|
}
|
|
@@ -10547,7 +10537,7 @@ function buildFeeCall(p, cfg) {
|
|
|
10547
10537
|
};
|
|
10548
10538
|
}
|
|
10549
10539
|
var DROP_MAX_CLAIM_QUANTITY = 50n;
|
|
10550
|
-
var addr2 = (a) =>
|
|
10540
|
+
var addr2 = (a) => chunkF5USCCM4_cjs.normalizeAddress("STARKNET", a);
|
|
10551
10541
|
var factoryData = new starknet.CallData(DropFactoryABI);
|
|
10552
10542
|
var collectionData = new starknet.CallData(DropCollectionABI);
|
|
10553
10543
|
function toContractTerms(t) {
|
|
@@ -10617,7 +10607,7 @@ function dropMintCost(price, quantity, feeBps2) {
|
|
|
10617
10607
|
}
|
|
10618
10608
|
|
|
10619
10609
|
// src/starknet/drop-state.ts
|
|
10620
|
-
var hex = (v) =>
|
|
10610
|
+
var hex = (v) => chunkF5USCCM4_cjs.normalizeAddress("STARKNET", v ?? "0x0");
|
|
10621
10611
|
var u256 = (low, high) => BigInt(low ?? "0x0") + (BigInt(high ?? "0x0") << 128n);
|
|
10622
10612
|
async function readDrop(provider, collection) {
|
|
10623
10613
|
const contractAddress = hex(collection);
|
|
@@ -10672,7 +10662,7 @@ function dropMintState(input) {
|
|
|
10672
10662
|
return { state: "ready", maxQuantity: max };
|
|
10673
10663
|
}
|
|
10674
10664
|
function dropClaimLinks(origin, collection, list) {
|
|
10675
|
-
const base = `${origin}${
|
|
10665
|
+
const base = `${origin}${chunkF5USCCM4_cjs.dropHref(collection)}`;
|
|
10676
10666
|
return Object.entries(list.proofs).map(([address, proof]) => ({
|
|
10677
10667
|
address,
|
|
10678
10668
|
url: `${base}${encodePopClaimFragment(proof)}`
|
|
@@ -10681,10 +10671,9 @@ function dropClaimLinks(origin, collection, list) {
|
|
|
10681
10671
|
|
|
10682
10672
|
// src/starknet/services/drop.ts
|
|
10683
10673
|
var DropService = class {
|
|
10684
|
-
constructor(config
|
|
10685
|
-
this.factoryAddress =
|
|
10674
|
+
constructor(config) {
|
|
10675
|
+
this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).dropFactory;
|
|
10686
10676
|
this.config = config;
|
|
10687
|
-
this.reader = reader ?? new starknet.RpcProvider({ nodeUrl: config.rpcUrl });
|
|
10688
10677
|
}
|
|
10689
10678
|
async createDrop(account, params) {
|
|
10690
10679
|
const res = await account.execute([dropCalls.create(this.factoryAddress, params)]);
|
|
@@ -10692,7 +10681,7 @@ var DropService = class {
|
|
|
10692
10681
|
}
|
|
10693
10682
|
/** Mints `quantity` to the account, paying the drop's price and the platform fee. */
|
|
10694
10683
|
async claim(account, params) {
|
|
10695
|
-
const drop = await readDrop(
|
|
10684
|
+
const drop = await readDrop(account.provider, params.collection);
|
|
10696
10685
|
const calls = dropCalls.claim(params.collection, {
|
|
10697
10686
|
quantity: params.quantity,
|
|
10698
10687
|
proof: params.proof,
|
|
@@ -10719,19 +10708,19 @@ var DropService = class {
|
|
|
10719
10708
|
// src/starknet/services/erc1155collection.ts
|
|
10720
10709
|
var ERC1155CollectionService = class {
|
|
10721
10710
|
constructor(config) {
|
|
10722
|
-
this.factoryAddress = config.collection1155Contract ??
|
|
10711
|
+
this.factoryAddress = config.collection1155Contract ?? chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).collection1155;
|
|
10723
10712
|
}
|
|
10724
10713
|
_factory(account) {
|
|
10725
10714
|
return newContract(
|
|
10726
10715
|
IPCollection1155FactoryABI,
|
|
10727
|
-
|
|
10716
|
+
chunkF5USCCM4_cjs.normalizeAddress("STARKNET", this.factoryAddress),
|
|
10728
10717
|
account
|
|
10729
10718
|
);
|
|
10730
10719
|
}
|
|
10731
10720
|
_collection(address, account) {
|
|
10732
10721
|
return newContract(
|
|
10733
10722
|
IPCollection1155ABI,
|
|
10734
|
-
|
|
10723
|
+
chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address),
|
|
10735
10724
|
account
|
|
10736
10725
|
);
|
|
10737
10726
|
}
|
|
@@ -10914,7 +10903,7 @@ function factoryContract() {
|
|
|
10914
10903
|
if (!_factoryContract) {
|
|
10915
10904
|
_factoryContract = newContract(
|
|
10916
10905
|
CreatorCoinFactoryABI,
|
|
10917
|
-
|
|
10906
|
+
chunk7EYJC5CB_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory
|
|
10918
10907
|
);
|
|
10919
10908
|
}
|
|
10920
10909
|
return _factoryContract;
|
|
@@ -10951,7 +10940,7 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
10951
10940
|
calls.push({
|
|
10952
10941
|
contractAddress: params.quoteToken,
|
|
10953
10942
|
entrypoint: "transfer",
|
|
10954
|
-
calldata: [
|
|
10943
|
+
calldata: [chunk7EYJC5CB_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory, amt.low, amt.high]
|
|
10955
10944
|
});
|
|
10956
10945
|
}
|
|
10957
10946
|
calls.push(factoryContract().populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
|
|
@@ -10959,27 +10948,26 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
10959
10948
|
}
|
|
10960
10949
|
var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
|
|
10961
10950
|
function parseCreatorCoinCreated(receipt) {
|
|
10962
|
-
const factory =
|
|
10951
|
+
const factory = chunkF5USCCM4_cjs.normalizeAddress("STARKNET", chunk7EYJC5CB_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory);
|
|
10963
10952
|
for (const ev of receipt?.events ?? []) {
|
|
10964
10953
|
let from;
|
|
10965
10954
|
try {
|
|
10966
|
-
from =
|
|
10955
|
+
from = chunkF5USCCM4_cjs.normalizeAddress("STARKNET", ev.from_address ?? "");
|
|
10967
10956
|
} catch {
|
|
10968
10957
|
continue;
|
|
10969
10958
|
}
|
|
10970
10959
|
if (from !== factory) continue;
|
|
10971
10960
|
const k0 = ev.keys?.[0];
|
|
10972
|
-
if (!k0 ||
|
|
10961
|
+
if (!k0 || chunkF5USCCM4_cjs.normalizeAddress("STARKNET", k0) !== chunkF5USCCM4_cjs.normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
|
|
10973
10962
|
const data = ev.data ?? [];
|
|
10974
10963
|
if (data.length < 1) continue;
|
|
10975
|
-
return
|
|
10964
|
+
return chunkF5USCCM4_cjs.normalizeAddress("STARKNET", data[data.length - 1]);
|
|
10976
10965
|
}
|
|
10977
10966
|
throw new Error("Coin deployed but the coin address could not be read from the receipt");
|
|
10978
10967
|
}
|
|
10979
10968
|
var CreatorCoinService = class {
|
|
10980
10969
|
constructor(config) {
|
|
10981
|
-
this.factoryAddress =
|
|
10982
|
-
this.config = config;
|
|
10970
|
+
this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).creatorCoinFactory;
|
|
10983
10971
|
}
|
|
10984
10972
|
_factory(account) {
|
|
10985
10973
|
return newContract(CreatorCoinFactoryABI, this.factoryAddress, account);
|
|
@@ -10996,26 +10984,18 @@ var CreatorCoinService = class {
|
|
|
10996
10984
|
const r = await this._factory(account).is_creator_coin(address);
|
|
10997
10985
|
return BigInt(r) === 1n;
|
|
10998
10986
|
}
|
|
10999
|
-
async getGuarantees(coinAddress) {
|
|
11000
|
-
return getCreatorCoinGuarantees(coinAddress, new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl }));
|
|
11001
|
-
}
|
|
11002
10987
|
};
|
|
11003
10988
|
var TicketService = class {
|
|
11004
10989
|
constructor(config) {
|
|
11005
|
-
this.
|
|
11006
|
-
this.factoryAddress = chunkVJVBWHAD_cjs.getStarknetCoordinates(config.chain).ipTicketsFactory;
|
|
10990
|
+
this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).ipTicketsFactory;
|
|
11007
10991
|
}
|
|
11008
10992
|
_factory(account, factoryAddress) {
|
|
11009
10993
|
const address = factoryAddress ?? this.factoryAddress;
|
|
11010
10994
|
if (!address) throw new Error("IP-Tickets factory address not configured for this chain");
|
|
11011
|
-
return newContract(IPTicketCollectionFactoryABI,
|
|
10995
|
+
return newContract(IPTicketCollectionFactoryABI, chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address), account);
|
|
11012
10996
|
}
|
|
11013
10997
|
_collection(address, account) {
|
|
11014
|
-
return newContract(IPTicketCollectionABI,
|
|
11015
|
-
}
|
|
11016
|
-
_collectionRead(address) {
|
|
11017
|
-
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
11018
|
-
return newContract(IPTicketCollectionABI, chunkPNUHSQPU_cjs.normalizeAddress("STARKNET", address), provider);
|
|
10998
|
+
return newContract(IPTicketCollectionABI, chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address), account);
|
|
11019
10999
|
}
|
|
11020
11000
|
async deployCollection(account, params) {
|
|
11021
11001
|
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
@@ -11048,47 +11028,18 @@ var TicketService = class {
|
|
|
11048
11028
|
const res = await account.execute([call]);
|
|
11049
11029
|
return { txHash: res.transaction_hash };
|
|
11050
11030
|
}
|
|
11051
|
-
async isValid(params) {
|
|
11052
|
-
const result = await this._collectionRead(params.collection).call("is_valid", [
|
|
11053
|
-
starknet.cairo.uint256(params.tokenId),
|
|
11054
|
-
params.holder
|
|
11055
|
-
]);
|
|
11056
|
-
return Boolean(result);
|
|
11057
|
-
}
|
|
11058
|
-
async getTicketCount(params) {
|
|
11059
|
-
const result = await this._collectionRead(params.collection).call("ticket_count", []);
|
|
11060
|
-
return BigInt(result);
|
|
11061
|
-
}
|
|
11062
|
-
async getTicket(params) {
|
|
11063
|
-
const t = await this._collectionRead(params.collection).call("get_ticket", [
|
|
11064
|
-
starknet.cairo.uint256(params.tokenId)
|
|
11065
|
-
]);
|
|
11066
|
-
return {
|
|
11067
|
-
maxSupply: BigInt(t.max_supply),
|
|
11068
|
-
minted: BigInt(t.minted),
|
|
11069
|
-
startTime: t.start_time?.variant === "Some" ? Number(t.start_time.values[0] ?? t.start_time.value) : null,
|
|
11070
|
-
endTime: t.end_time?.variant === "Some" ? Number(t.end_time.values[0] ?? t.end_time.value) : null,
|
|
11071
|
-
royaltyBps: Number(t.royalty_bps),
|
|
11072
|
-
metadataUri: t.metadata_uri
|
|
11073
|
-
};
|
|
11074
|
-
}
|
|
11075
11031
|
};
|
|
11076
11032
|
var ClubService = class {
|
|
11077
11033
|
constructor(config) {
|
|
11078
|
-
this.
|
|
11079
|
-
this.factoryAddress = chunkVJVBWHAD_cjs.getStarknetCoordinates(config.chain).ipClubFactory;
|
|
11034
|
+
this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).ipClubFactory;
|
|
11080
11035
|
}
|
|
11081
11036
|
_factory(account, factoryAddress) {
|
|
11082
11037
|
const address = factoryAddress ?? this.factoryAddress;
|
|
11083
11038
|
if (!address) throw new Error("IP-Club factory address not configured for this chain");
|
|
11084
|
-
return newContract(IPClubFactoryABI,
|
|
11039
|
+
return newContract(IPClubFactoryABI, chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address), account);
|
|
11085
11040
|
}
|
|
11086
11041
|
_collection(address, account) {
|
|
11087
|
-
return newContract(IPClubCollectionABI,
|
|
11088
|
-
}
|
|
11089
|
-
_collectionRead(address) {
|
|
11090
|
-
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
11091
|
-
return newContract(IPClubCollectionABI, chunkPNUHSQPU_cjs.normalizeAddress("STARKNET", address), provider);
|
|
11042
|
+
return newContract(IPClubCollectionABI, chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address), account);
|
|
11092
11043
|
}
|
|
11093
11044
|
async deployCollection(account, params) {
|
|
11094
11045
|
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
@@ -11121,52 +11072,17 @@ var ClubService = class {
|
|
|
11121
11072
|
const res = await account.execute([call]);
|
|
11122
11073
|
return { txHash: res.transaction_hash };
|
|
11123
11074
|
}
|
|
11124
|
-
async isMember(params) {
|
|
11125
|
-
const result = await this._collectionRead(params.collection).call("is_member", [
|
|
11126
|
-
params.holder
|
|
11127
|
-
]);
|
|
11128
|
-
return Boolean(result);
|
|
11129
|
-
}
|
|
11130
|
-
async isMemberOf(params) {
|
|
11131
|
-
const result = await this._collectionRead(params.collection).call("is_member_of", [
|
|
11132
|
-
starknet.cairo.uint256(params.tokenId),
|
|
11133
|
-
params.holder
|
|
11134
|
-
]);
|
|
11135
|
-
return Boolean(result);
|
|
11136
|
-
}
|
|
11137
|
-
async getMembership(params) {
|
|
11138
|
-
const m = await this._collectionRead(params.collection).call("get_membership", [
|
|
11139
|
-
starknet.cairo.uint256(params.tokenId)
|
|
11140
|
-
]);
|
|
11141
|
-
return {
|
|
11142
|
-
maxSupply: BigInt(m.max_supply),
|
|
11143
|
-
minted: BigInt(m.minted),
|
|
11144
|
-
startTime: m.start_time?.variant === "Some" ? Number(m.start_time.values[0] ?? m.start_time.value) : null,
|
|
11145
|
-
endTime: m.end_time?.variant === "Some" ? Number(m.end_time.values[0] ?? m.end_time.value) : null,
|
|
11146
|
-
royaltyBps: Number(m.royalty_bps),
|
|
11147
|
-
metadataUri: m.metadata_uri
|
|
11148
|
-
};
|
|
11149
|
-
}
|
|
11150
11075
|
};
|
|
11151
11076
|
var SponsorshipService = class {
|
|
11152
11077
|
constructor(config) {
|
|
11153
|
-
this.
|
|
11154
|
-
this.sponsorshipAddress = chunkVJVBWHAD_cjs.getStarknetCoordinates(config.chain).ipSponsorship;
|
|
11078
|
+
this.sponsorshipAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).ipSponsorship;
|
|
11155
11079
|
}
|
|
11156
11080
|
_contract(account, address) {
|
|
11157
11081
|
const resolved = address ?? this.sponsorshipAddress;
|
|
11158
11082
|
if (!resolved) {
|
|
11159
11083
|
throw new Error("IP-Sponsorship address not configured for this chain");
|
|
11160
11084
|
}
|
|
11161
|
-
return newContract(IPSponsorshipABI,
|
|
11162
|
-
}
|
|
11163
|
-
_contractRead(address) {
|
|
11164
|
-
const resolved = address ?? this.sponsorshipAddress;
|
|
11165
|
-
if (!resolved) {
|
|
11166
|
-
throw new Error("IP-Sponsorship address not configured for this chain");
|
|
11167
|
-
}
|
|
11168
|
-
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
11169
|
-
return newContract(IPSponsorshipABI, chunkPNUHSQPU_cjs.normalizeAddress("STARKNET", resolved), provider);
|
|
11085
|
+
return newContract(IPSponsorshipABI, chunkF5USCCM4_cjs.normalizeAddress("STARKNET", resolved), account);
|
|
11170
11086
|
}
|
|
11171
11087
|
async createOffer(account, params) {
|
|
11172
11088
|
const specificSponsor = params.specificSponsor ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.specificSponsor) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
|
|
@@ -11201,7 +11117,7 @@ var SponsorshipService = class {
|
|
|
11201
11117
|
const approveCall = {
|
|
11202
11118
|
contractAddress: params.paymentToken,
|
|
11203
11119
|
entrypoint: "approve",
|
|
11204
|
-
calldata: [
|
|
11120
|
+
calldata: [chunkF5USCCM4_cjs.normalizeAddress("STARKNET", sponsorshipAddress), amount.low.toString(), amount.high.toString()]
|
|
11205
11121
|
};
|
|
11206
11122
|
const bidCall = this._contract(account, sponsorshipAddress).populate("place_bid", [
|
|
11207
11123
|
starknet.cairo.uint256(params.offerId),
|
|
@@ -11261,74 +11177,19 @@ var SponsorshipService = class {
|
|
|
11261
11177
|
const res = await account.execute([call]);
|
|
11262
11178
|
return { txHash: res.transaction_hash };
|
|
11263
11179
|
}
|
|
11264
|
-
async getOffer(params) {
|
|
11265
|
-
const o = await this._contractRead(params.sponsorshipAddress).call("get_offer", [
|
|
11266
|
-
starknet.cairo.uint256(params.offerId)
|
|
11267
|
-
]);
|
|
11268
|
-
return {
|
|
11269
|
-
author: o.author,
|
|
11270
|
-
nftContract: o.nft_contract,
|
|
11271
|
-
tokenId: BigInt(o.token_id),
|
|
11272
|
-
minAmount: BigInt(o.min_amount),
|
|
11273
|
-
duration: Number(o.duration),
|
|
11274
|
-
paymentToken: o.payment_token,
|
|
11275
|
-
licenseTermsUri: o.license_terms_uri,
|
|
11276
|
-
transferable: Boolean(o.transferable),
|
|
11277
|
-
specificSponsor: o.specific_sponsor?.variant === "Some" ? o.specific_sponsor.values?.[0] ?? o.specific_sponsor.value : null,
|
|
11278
|
-
open: Boolean(o.open),
|
|
11279
|
-
royaltyBps: BigInt(o.royalty_bps)
|
|
11280
|
-
};
|
|
11281
|
-
}
|
|
11282
|
-
async getBid(params) {
|
|
11283
|
-
const result = await this._contractRead(params.sponsorshipAddress).call("get_bid", [
|
|
11284
|
-
starknet.cairo.uint256(params.offerId),
|
|
11285
|
-
params.sponsor
|
|
11286
|
-
]);
|
|
11287
|
-
return BigInt(result);
|
|
11288
|
-
}
|
|
11289
|
-
async getProposal(params) {
|
|
11290
|
-
const p = await this._contractRead(params.sponsorshipAddress).call("get_proposal", [
|
|
11291
|
-
starknet.cairo.uint256(params.proposalId)
|
|
11292
|
-
]);
|
|
11293
|
-
return {
|
|
11294
|
-
proposer: p.proposer,
|
|
11295
|
-
nftContract: p.nft_contract,
|
|
11296
|
-
tokenId: BigInt(p.token_id),
|
|
11297
|
-
amount: BigInt(p.amount),
|
|
11298
|
-
duration: Number(p.duration),
|
|
11299
|
-
validUntil: Number(p.valid_until),
|
|
11300
|
-
paymentToken: p.payment_token,
|
|
11301
|
-
licenseTermsUri: p.license_terms_uri,
|
|
11302
|
-
transferable: Boolean(p.transferable),
|
|
11303
|
-
open: Boolean(p.open),
|
|
11304
|
-
royaltyBps: BigInt(p.royalty_bps)
|
|
11305
|
-
};
|
|
11306
|
-
}
|
|
11307
|
-
async getLastOfferId(params) {
|
|
11308
|
-
const result = await this._contractRead(params?.sponsorshipAddress).call("get_last_offer_id", []);
|
|
11309
|
-
return BigInt(result);
|
|
11310
|
-
}
|
|
11311
|
-
async getLastProposalId(params) {
|
|
11312
|
-
const result = await this._contractRead(params?.sponsorshipAddress).call("get_last_proposal_id", []);
|
|
11313
|
-
return BigInt(result);
|
|
11314
|
-
}
|
|
11315
|
-
async getLastLicenseId(params) {
|
|
11316
|
-
const result = await this._contractRead(params?.sponsorshipAddress).call("get_last_license_id", []);
|
|
11317
|
-
return BigInt(result);
|
|
11318
|
-
}
|
|
11319
|
-
async royaltyInfo(params) {
|
|
11320
|
-
const [recipient, amount] = await this._contractRead(params.sponsorshipAddress).call("royalty_info", [
|
|
11321
|
-
starknet.cairo.uint256(params.licenseId),
|
|
11322
|
-
starknet.cairo.uint256(params.salePrice)
|
|
11323
|
-
]);
|
|
11324
|
-
return { recipient, amount: BigInt(amount) };
|
|
11325
|
-
}
|
|
11326
11180
|
};
|
|
11181
|
+
function createChainProvider(backendUrl, apiKey) {
|
|
11182
|
+
return new starknet.RpcProvider({
|
|
11183
|
+
nodeUrl: `${backendUrl.replace(/\/$/, "")}/v1/rpc`,
|
|
11184
|
+
headers: apiKey ? { "x-api-key": apiKey } : {},
|
|
11185
|
+
blockIdentifier: "latest"
|
|
11186
|
+
});
|
|
11187
|
+
}
|
|
11327
11188
|
|
|
11328
11189
|
// src/starknet/client.ts
|
|
11329
11190
|
var MedialaneClient = class {
|
|
11330
11191
|
constructor(rawConfig = {}) {
|
|
11331
|
-
this.config =
|
|
11192
|
+
this.config = chunkF5USCCM4_cjs.resolveConfig(rawConfig);
|
|
11332
11193
|
this.services = {
|
|
11333
11194
|
pop: new PopService(this.config),
|
|
11334
11195
|
drop: new DropService(this.config),
|
|
@@ -11339,9 +11200,9 @@ var MedialaneClient = class {
|
|
|
11339
11200
|
sponsorship: new SponsorshipService(this.config)
|
|
11340
11201
|
};
|
|
11341
11202
|
if (!this.config.backendUrl) {
|
|
11342
|
-
const sentinel = new
|
|
11203
|
+
const sentinel = new chunkF5USCCM4_cjs.ApiClient("https://medialane-sdk-no-backend.invalid", this.config.apiKey);
|
|
11343
11204
|
const apiMethodNames = new Set(
|
|
11344
|
-
Object.getOwnPropertyNames(
|
|
11205
|
+
Object.getOwnPropertyNames(chunkF5USCCM4_cjs.ApiClient.prototype).filter(
|
|
11345
11206
|
(k) => k !== "constructor" && typeof sentinel[k] === "function"
|
|
11346
11207
|
)
|
|
11347
11208
|
);
|
|
@@ -11358,60 +11219,28 @@ var MedialaneClient = class {
|
|
|
11358
11219
|
}
|
|
11359
11220
|
});
|
|
11360
11221
|
} else {
|
|
11361
|
-
this.api = new
|
|
11222
|
+
this.api = new chunkF5USCCM4_cjs.ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
|
|
11362
11223
|
}
|
|
11363
11224
|
}
|
|
11364
11225
|
get chain() {
|
|
11365
11226
|
return this.config.chain;
|
|
11366
11227
|
}
|
|
11367
|
-
get
|
|
11368
|
-
|
|
11228
|
+
get provider() {
|
|
11229
|
+
if (!this.config.backendUrl) {
|
|
11230
|
+
throw new Error("backendUrl not configured. Pass backendUrl to MedialaneClient to use .provider");
|
|
11231
|
+
}
|
|
11232
|
+
return this._provider ?? (this._provider = createChainProvider(this.config.backendUrl, this.config.apiKey));
|
|
11369
11233
|
}
|
|
11370
11234
|
get marketplaceContract() {
|
|
11371
11235
|
return this.config.marketplaceContract;
|
|
11372
11236
|
}
|
|
11373
11237
|
};
|
|
11374
11238
|
|
|
11375
|
-
// src/starknet/
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
const
|
|
11379
|
-
|
|
11380
|
-
const contract = newContract(
|
|
11381
|
-
IPMarketplaceABI,
|
|
11382
|
-
config.marketplaceContract,
|
|
11383
|
-
getProvider(config)
|
|
11384
|
-
);
|
|
11385
|
-
const entry = { contract };
|
|
11386
|
-
_contractCache.set(config, entry);
|
|
11387
|
-
return entry;
|
|
11388
|
-
}
|
|
11389
|
-
async function getOrderDetails(orderHash, config) {
|
|
11390
|
-
const { contract } = makeContract(config);
|
|
11391
|
-
return contract.get_order_details(orderHash);
|
|
11392
|
-
}
|
|
11393
|
-
async function getCounter(address, config) {
|
|
11394
|
-
const { contract } = makeContract(config);
|
|
11395
|
-
return BigInt((await contract.get_counter(address)).toString());
|
|
11396
|
-
}
|
|
11397
|
-
|
|
11398
|
-
// src/starknet/marketplace1155/orders.ts
|
|
11399
|
-
var _contractCache2 = /* @__PURE__ */ new WeakMap();
|
|
11400
|
-
function getContract(config) {
|
|
11401
|
-
let c = _contractCache2.get(config);
|
|
11402
|
-
if (!c) {
|
|
11403
|
-
c = newContract(Medialane1155ABI, config.marketplace1155Contract, getProvider(config));
|
|
11404
|
-
_contractCache2.set(config, c);
|
|
11405
|
-
}
|
|
11406
|
-
return c;
|
|
11407
|
-
}
|
|
11408
|
-
async function getOrderDetails1155(orderHash, config) {
|
|
11409
|
-
const contract = getContract(config);
|
|
11410
|
-
return contract.get_order_details(orderHash);
|
|
11411
|
-
}
|
|
11412
|
-
async function getCounter1155(address, config) {
|
|
11413
|
-
const contract = getContract(config);
|
|
11414
|
-
return BigInt((await contract.get_counter(address)).toString());
|
|
11239
|
+
// src/starknet/erc20.ts
|
|
11240
|
+
async function erc20Balance(provider, token, holder) {
|
|
11241
|
+
const read = (entrypoint) => provider.callContract({ contractAddress: token, entrypoint, calldata: [holder] }, "latest");
|
|
11242
|
+
const [low = "0x0", high = "0x0"] = await read("balanceOf").catch(() => read("balance_of"));
|
|
11243
|
+
return BigInt(low) + (BigInt(high) << 128n);
|
|
11415
11244
|
}
|
|
11416
11245
|
var STARKNET_DOMAIN = [
|
|
11417
11246
|
{ name: "name", type: "shortstring" },
|
|
@@ -11510,7 +11339,7 @@ function build1155CancellationTypedData(message, chainId) {
|
|
|
11510
11339
|
|
|
11511
11340
|
// src/starknet/marketplace/build.ts
|
|
11512
11341
|
function contractFor(cfg) {
|
|
11513
|
-
return newContract(IPMarketplaceABI, cfg.marketplaceContract
|
|
11342
|
+
return newContract(IPMarketplaceABI, cfg.marketplaceContract);
|
|
11514
11343
|
}
|
|
11515
11344
|
function buildListingOrder(i, cfg) {
|
|
11516
11345
|
const orderParams = {
|
|
@@ -11530,7 +11359,7 @@ function buildListingOrder(i, cfg) {
|
|
|
11530
11359
|
salt: i.salt,
|
|
11531
11360
|
counter: i.counter
|
|
11532
11361
|
};
|
|
11533
|
-
const typedData =
|
|
11362
|
+
const typedData = chunkF5USCCM4_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
|
|
11534
11363
|
return { orderParams, typedData };
|
|
11535
11364
|
}
|
|
11536
11365
|
function buildOfferOrder(i, cfg) {
|
|
@@ -11551,11 +11380,11 @@ function buildOfferOrder(i, cfg) {
|
|
|
11551
11380
|
salt: i.salt,
|
|
11552
11381
|
counter: i.counter
|
|
11553
11382
|
};
|
|
11554
|
-
const typedData =
|
|
11383
|
+
const typedData = chunkF5USCCM4_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
|
|
11555
11384
|
return { orderParams, typedData };
|
|
11556
11385
|
}
|
|
11557
11386
|
function registerPayload(orderParams, signature) {
|
|
11558
|
-
return
|
|
11387
|
+
return chunkF5USCCM4_cjs.stringifyBigInts({
|
|
11559
11388
|
parameters: {
|
|
11560
11389
|
...orderParams,
|
|
11561
11390
|
offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
|
|
@@ -11586,17 +11415,17 @@ function buildFulfillCalls(a, cfg) {
|
|
|
11586
11415
|
return fee ? [approve, fulfill, fee] : [approve, fulfill];
|
|
11587
11416
|
}
|
|
11588
11417
|
function buildCancelCalls(a, cfg) {
|
|
11589
|
-
const cancelRequest =
|
|
11418
|
+
const cancelRequest = chunkF5USCCM4_cjs.stringifyBigInts({
|
|
11590
11419
|
cancelation: { order_hash: a.orderHash, offerer: a.offerer },
|
|
11591
11420
|
signature: a.signature
|
|
11592
11421
|
});
|
|
11593
11422
|
return [contractFor(cfg).populate("cancel_order", [cancelRequest])];
|
|
11594
11423
|
}
|
|
11595
11424
|
function buildCancelTypedData(orderHash, offerer, cfg) {
|
|
11596
|
-
return
|
|
11425
|
+
return chunkF5USCCM4_cjs.stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
|
|
11597
11426
|
}
|
|
11598
11427
|
function contractFor2(cfg) {
|
|
11599
|
-
return newContract(Medialane1155ABI, cfg.marketplace1155Contract
|
|
11428
|
+
return newContract(Medialane1155ABI, cfg.marketplace1155Contract);
|
|
11600
11429
|
}
|
|
11601
11430
|
function buildListing1155Order(i, cfg) {
|
|
11602
11431
|
const orderParams = {
|
|
@@ -11616,7 +11445,7 @@ function buildListing1155Order(i, cfg) {
|
|
|
11616
11445
|
salt: i.salt,
|
|
11617
11446
|
counter: i.counter
|
|
11618
11447
|
};
|
|
11619
|
-
const typedData =
|
|
11448
|
+
const typedData = chunkF5USCCM4_cjs.stringifyBigInts(
|
|
11620
11449
|
build1155OrderTypedData(orderParams, getChainId(cfg))
|
|
11621
11450
|
);
|
|
11622
11451
|
return { orderParams, typedData };
|
|
@@ -11639,13 +11468,13 @@ function buildOffer1155Order(i, cfg) {
|
|
|
11639
11468
|
salt: i.salt,
|
|
11640
11469
|
counter: i.counter
|
|
11641
11470
|
};
|
|
11642
|
-
const typedData =
|
|
11471
|
+
const typedData = chunkF5USCCM4_cjs.stringifyBigInts(
|
|
11643
11472
|
build1155OrderTypedData(orderParams, getChainId(cfg))
|
|
11644
11473
|
);
|
|
11645
11474
|
return { orderParams, typedData };
|
|
11646
11475
|
}
|
|
11647
11476
|
function registerPayload2(orderParams, signature) {
|
|
11648
|
-
return
|
|
11477
|
+
return chunkF5USCCM4_cjs.stringifyBigInts({
|
|
11649
11478
|
parameters: {
|
|
11650
11479
|
...orderParams,
|
|
11651
11480
|
offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
|
|
@@ -11676,14 +11505,14 @@ function buildFulfill1155Calls(a, cfg) {
|
|
|
11676
11505
|
return fee ? [approve, fulfill, fee] : [approve, fulfill];
|
|
11677
11506
|
}
|
|
11678
11507
|
function buildCancel1155Calls(a, cfg) {
|
|
11679
|
-
const cancelPayload =
|
|
11508
|
+
const cancelPayload = chunkF5USCCM4_cjs.stringifyBigInts({
|
|
11680
11509
|
cancelation: { order_hash: a.orderHash, offerer: a.offerer },
|
|
11681
11510
|
signature: a.signature
|
|
11682
11511
|
});
|
|
11683
11512
|
return [contractFor2(cfg).populate("cancel_order", [cancelPayload])];
|
|
11684
11513
|
}
|
|
11685
11514
|
function buildCancel1155TypedData(orderHash, offerer, cfg) {
|
|
11686
|
-
return
|
|
11515
|
+
return chunkF5USCCM4_cjs.stringifyBigInts(
|
|
11687
11516
|
build1155CancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg))
|
|
11688
11517
|
);
|
|
11689
11518
|
}
|
|
@@ -11701,7 +11530,8 @@ var StarknetVenue = class {
|
|
|
11701
11530
|
]);
|
|
11702
11531
|
}
|
|
11703
11532
|
getOrderDetails(orderRef) {
|
|
11704
|
-
|
|
11533
|
+
const marketplace = newContract(IPMarketplaceABI, this.deps.config.marketplaceContract, this.deps.provider);
|
|
11534
|
+
return marketplace.get_order_details(orderRef);
|
|
11705
11535
|
}
|
|
11706
11536
|
async getCounter(address) {
|
|
11707
11537
|
return this.readCounter(this.deps.config.marketplaceContract, address);
|
|
@@ -11956,6 +11786,29 @@ async function signInWithWallet(args) {
|
|
|
11956
11786
|
}
|
|
11957
11787
|
}
|
|
11958
11788
|
|
|
11789
|
+
// src/starknet/api-key-confirmation.ts
|
|
11790
|
+
function apiKeyConfirmationTypedData(input) {
|
|
11791
|
+
return {
|
|
11792
|
+
domain: { name: "Medialane", version: "1", chainId: "SN_MAIN", revision: "1" },
|
|
11793
|
+
primaryType: "ApiKeyConfirmation",
|
|
11794
|
+
types: {
|
|
11795
|
+
StarknetDomain: [
|
|
11796
|
+
{ name: "name", type: "shortstring" },
|
|
11797
|
+
{ name: "version", type: "shortstring" },
|
|
11798
|
+
{ name: "chainId", type: "shortstring" },
|
|
11799
|
+
{ name: "revision", type: "shortstring" }
|
|
11800
|
+
],
|
|
11801
|
+
ApiKeyConfirmation: [
|
|
11802
|
+
{ name: "action", type: "shortstring" },
|
|
11803
|
+
{ name: "key", type: "string" },
|
|
11804
|
+
{ name: "account", type: "string" },
|
|
11805
|
+
{ name: "expiresAt", type: "timestamp" }
|
|
11806
|
+
]
|
|
11807
|
+
},
|
|
11808
|
+
message: { action: input.action, key: input.key, account: input.account, expiresAt: input.expiresAt }
|
|
11809
|
+
};
|
|
11810
|
+
}
|
|
11811
|
+
|
|
11959
11812
|
// src/starknet/funding/chain-transfer.ts
|
|
11960
11813
|
var FundingTransferNotSentError = class extends Error {
|
|
11961
11814
|
constructor(message = "The transfer was not sent.") {
|
|
@@ -11963,13 +11816,13 @@ var FundingTransferNotSentError = class extends Error {
|
|
|
11963
11816
|
this.name = "FundingTransferNotSentError";
|
|
11964
11817
|
}
|
|
11965
11818
|
};
|
|
11966
|
-
function fundingApiFor(client
|
|
11819
|
+
function fundingApiFor(client) {
|
|
11967
11820
|
return {
|
|
11968
|
-
createFunding: (input) => client.createFunding(input
|
|
11969
|
-
getFundingChallenge: (id, payer) => client.getFundingChallenge(id, payer
|
|
11970
|
-
authorizeFunding: (id, input) => client.authorizeFunding(id, input
|
|
11971
|
-
submitFunding: (id, txHash) => client.submitFunding(id, txHash
|
|
11972
|
-
cancelFunding: (id) => client.cancelFunding(id
|
|
11821
|
+
createFunding: (input) => client.createFunding(input),
|
|
11822
|
+
getFundingChallenge: (id, payer) => client.getFundingChallenge(id, payer),
|
|
11823
|
+
authorizeFunding: (id, input) => client.authorizeFunding(id, input),
|
|
11824
|
+
submitFunding: (id, txHash) => client.submitFunding(id, txHash),
|
|
11825
|
+
cancelFunding: (id) => client.cancelFunding(id)
|
|
11973
11826
|
};
|
|
11974
11827
|
}
|
|
11975
11828
|
function buildFundingTransferCall(instructions) {
|
|
@@ -12049,16 +11902,16 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
|
|
|
12049
11902
|
const receipt = await provider.getTransactionReceipt(txHash);
|
|
12050
11903
|
const status = receipt.execution_status ?? receipt.status;
|
|
12051
11904
|
if (status === "REVERTED" || status === "REJECTED") {
|
|
12052
|
-
throw new
|
|
11905
|
+
throw new chunkF5USCCM4_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
|
|
12053
11906
|
}
|
|
12054
11907
|
if (status) return receipt;
|
|
12055
11908
|
} catch (err) {
|
|
12056
11909
|
if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
|
|
12057
11910
|
}
|
|
12058
11911
|
}
|
|
12059
|
-
throw new
|
|
11912
|
+
throw new chunkF5USCCM4_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
|
|
12060
11913
|
}
|
|
12061
|
-
async function executeIntent(
|
|
11914
|
+
async function executeIntent(signer, client, intent, opts = {}) {
|
|
12062
11915
|
let calls;
|
|
12063
11916
|
if (intent.requiresSignature) {
|
|
12064
11917
|
const signature = await signer.signTypedData(intent.typedData);
|
|
@@ -12068,20 +11921,20 @@ async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
|
12068
11921
|
calls = intent.calls;
|
|
12069
11922
|
}
|
|
12070
11923
|
const { txHash } = await signer.execute(calls, { intentIds: [intent.id] });
|
|
12071
|
-
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11924
|
+
const receipt = await assertTransactionSucceeded(client.provider, txHash);
|
|
12072
11925
|
await Promise.all([
|
|
12073
11926
|
syncTransactionBestEffort(client, txHash),
|
|
12074
11927
|
opts.confirm !== false ? confirmIntentBestEffort(client, intent.id, txHash) : void 0
|
|
12075
11928
|
]);
|
|
12076
11929
|
return { txHash, receipt };
|
|
12077
11930
|
}
|
|
12078
|
-
async function executeIntents(
|
|
11931
|
+
async function executeIntents(signer, client, intents, opts = {}) {
|
|
12079
11932
|
if (intents.some((i) => i.requiresSignature)) {
|
|
12080
11933
|
throw new Error("Expected prebuilt intents (requiresSignature=false)");
|
|
12081
11934
|
}
|
|
12082
11935
|
const calls = intents.flatMap((i) => i.calls);
|
|
12083
11936
|
const { txHash } = await signer.execute(calls, { intentIds: intents.map((i) => i.id) });
|
|
12084
|
-
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11937
|
+
const receipt = await assertTransactionSucceeded(client.provider, txHash);
|
|
12085
11938
|
await Promise.all([
|
|
12086
11939
|
syncTransactionBestEffort(client, txHash),
|
|
12087
11940
|
...opts.confirm !== false ? intents.map((i) => confirmIntentBestEffort(client, i.id, txHash)) : []
|
|
@@ -12109,14 +11962,14 @@ function u2563(low, high) {
|
|
|
12109
11962
|
return (BigInt(low ?? 0) + (BigInt(high ?? 0) << 128n)).toString();
|
|
12110
11963
|
}
|
|
12111
11964
|
function deployedCollectionFromReceipt(receipt, service) {
|
|
12112
|
-
const factory =
|
|
11965
|
+
const factory = chunkF5USCCM4_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
|
|
12113
11966
|
const { event, address } = DEPLOY_EVENTS[service];
|
|
12114
11967
|
const selector = BigInt(starknet.hash.getSelectorFromName(event));
|
|
12115
11968
|
for (const e of receipt.events ?? []) {
|
|
12116
11969
|
if (factory && !sameFelt(e.from_address, factory)) continue;
|
|
12117
11970
|
if (!sameFelt(e.keys?.[0], selector)) continue;
|
|
12118
11971
|
const value = address(e);
|
|
12119
|
-
if (value) return
|
|
11972
|
+
if (value) return chunkF5USCCM4_cjs.normalizeAddress("STARKNET", value);
|
|
12120
11973
|
}
|
|
12121
11974
|
return null;
|
|
12122
11975
|
}
|
|
@@ -12237,13 +12090,13 @@ function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
|
|
|
12237
12090
|
}
|
|
12238
12091
|
function buildDeployAccountParams(ownerPubkey, salt = 0) {
|
|
12239
12092
|
return {
|
|
12240
|
-
classHash:
|
|
12241
|
-
constructorCalldata:
|
|
12093
|
+
classHash: chunkF5USCCM4_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
|
|
12094
|
+
constructorCalldata: chunkF5USCCM4_cjs.ownerConstructorCalldata(ownerPubkey),
|
|
12242
12095
|
addressSalt: starknet.num.toHex(salt),
|
|
12243
|
-
contractAddress:
|
|
12096
|
+
contractAddress: chunkF5USCCM4_cjs.computeAccountAddress(ownerPubkey, salt)
|
|
12244
12097
|
};
|
|
12245
12098
|
}
|
|
12246
|
-
var norm = (address) =>
|
|
12099
|
+
var norm = (address) => chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address);
|
|
12247
12100
|
var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
|
|
12248
12101
|
function encodeFeltArray(items) {
|
|
12249
12102
|
return [starknet.num.toHex(items.length), ...items];
|
|
@@ -12440,7 +12293,7 @@ var InvalidRecoveryKeyError = class extends Error {
|
|
|
12440
12293
|
var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
|
|
12441
12294
|
function keyPair(privateKey) {
|
|
12442
12295
|
try {
|
|
12443
|
-
return
|
|
12296
|
+
return chunkF5USCCM4_cjs.starkKeyPairFromPrivateKey(privateKey);
|
|
12444
12297
|
} catch {
|
|
12445
12298
|
throw new InvalidRecoveryKeyError();
|
|
12446
12299
|
}
|
|
@@ -12453,7 +12306,7 @@ function parseRecoveryKey(input) {
|
|
|
12453
12306
|
const trimmed = input.trim();
|
|
12454
12307
|
if (!trimmed.startsWith(PREFIX)) {
|
|
12455
12308
|
const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
|
|
12456
|
-
return { walletAddress:
|
|
12309
|
+
return { walletAddress: chunkF5USCCM4_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
|
|
12457
12310
|
}
|
|
12458
12311
|
const parts = trimmed.slice(PREFIX.length).split(":");
|
|
12459
12312
|
const [walletAddress, privateKey] = parts;
|
|
@@ -12475,7 +12328,7 @@ function describeRecoveryAction(escape) {
|
|
|
12475
12328
|
return "none";
|
|
12476
12329
|
}
|
|
12477
12330
|
function normalizeWalletAddress(address) {
|
|
12478
|
-
return
|
|
12331
|
+
return chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address);
|
|
12479
12332
|
}
|
|
12480
12333
|
function isValidStarknetAddress(address) {
|
|
12481
12334
|
try {
|
|
@@ -12520,14 +12373,9 @@ async function estimateSelfFundedFee(provider, address, calls) {
|
|
|
12520
12373
|
return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
|
|
12521
12374
|
}
|
|
12522
12375
|
async function feeTokenBalance(provider, address, unit) {
|
|
12523
|
-
const token =
|
|
12376
|
+
const token = chunkF5USCCM4_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
|
|
12524
12377
|
if (!token) throw new Error(`No fee token for unit ${unit}`);
|
|
12525
|
-
|
|
12526
|
-
contractAddress: token.address,
|
|
12527
|
-
entrypoint: "balance_of",
|
|
12528
|
-
calldata: [address]
|
|
12529
|
-
});
|
|
12530
|
-
return BigInt(low) + (BigInt(high) << 128n);
|
|
12378
|
+
return erc20Balance(provider, token.address, address);
|
|
12531
12379
|
}
|
|
12532
12380
|
function selfFundedExecutor(deps) {
|
|
12533
12381
|
return {
|
|
@@ -12552,7 +12400,7 @@ function sponsoredExecutor(deps) {
|
|
|
12552
12400
|
{ proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
|
|
12553
12401
|
{
|
|
12554
12402
|
address: userAddress,
|
|
12555
|
-
signTypedData: async (data) =>
|
|
12403
|
+
signTypedData: async (data) => chunkF5USCCM4_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
|
|
12556
12404
|
},
|
|
12557
12405
|
{ intentIds }
|
|
12558
12406
|
);
|
|
@@ -12602,7 +12450,7 @@ async function deploySponsored(input) {
|
|
|
12602
12450
|
return { transactionHash };
|
|
12603
12451
|
}
|
|
12604
12452
|
async function deploySelfFunded(input) {
|
|
12605
|
-
const classHash =
|
|
12453
|
+
const classHash = chunk7EYJC5CB_cjs.getCoordinates("STARKNET").mediaWalletClassHash;
|
|
12606
12454
|
if (!classHash) throw new Error("Media Wallet class hash is not configured");
|
|
12607
12455
|
const account = new starknet.Account({
|
|
12608
12456
|
provider: input.provider,
|
|
@@ -12612,7 +12460,7 @@ async function deploySelfFunded(input) {
|
|
|
12612
12460
|
});
|
|
12613
12461
|
const { transaction_hash } = await account.deployAccount({
|
|
12614
12462
|
classHash,
|
|
12615
|
-
constructorCalldata:
|
|
12463
|
+
constructorCalldata: chunkF5USCCM4_cjs.ownerConstructorCalldata(input.ownerPubKey),
|
|
12616
12464
|
addressSalt: 0,
|
|
12617
12465
|
contractAddress: input.ownerAddress
|
|
12618
12466
|
});
|
|
@@ -12768,7 +12616,7 @@ function createMediaWallet(config) {
|
|
|
12768
12616
|
};
|
|
12769
12617
|
const walletIntents = config.walletIntents ?? (async (params) => {
|
|
12770
12618
|
if (!config.backendUrl) throw new Error("This wallet has no backend url configured");
|
|
12771
|
-
const created = await new
|
|
12619
|
+
const created = await new chunkF5USCCM4_cjs.ApiClient(config.backendUrl).createWalletManageIntent(params);
|
|
12772
12620
|
return created.data;
|
|
12773
12621
|
});
|
|
12774
12622
|
const manage = async (sealed, params) => {
|
|
@@ -12785,7 +12633,7 @@ function createMediaWallet(config) {
|
|
|
12785
12633
|
address: sealed.address,
|
|
12786
12634
|
signTypedData: async (data) => {
|
|
12787
12635
|
const privateKeyHex = await unlockOnce(sealed);
|
|
12788
|
-
return
|
|
12636
|
+
return chunkF5USCCM4_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
|
|
12789
12637
|
},
|
|
12790
12638
|
execute: async (calls, opts) => {
|
|
12791
12639
|
const { transactionHash } = await run(sealed, calls, void 0, opts?.intentIds);
|
|
@@ -12826,55 +12674,55 @@ async function claimSessionWallet(api, walletAddress, deps) {
|
|
|
12826
12674
|
|
|
12827
12675
|
Object.defineProperty(exports, "InvalidStarkPrivateKeyError", {
|
|
12828
12676
|
enumerable: true,
|
|
12829
|
-
get: function () { return
|
|
12677
|
+
get: function () { return chunkF5USCCM4_cjs.InvalidStarkPrivateKeyError; }
|
|
12830
12678
|
});
|
|
12831
12679
|
Object.defineProperty(exports, "PasskeyCancelledError", {
|
|
12832
12680
|
enumerable: true,
|
|
12833
|
-
get: function () { return
|
|
12681
|
+
get: function () { return chunkF5USCCM4_cjs.PasskeyCancelledError; }
|
|
12834
12682
|
});
|
|
12835
12683
|
Object.defineProperty(exports, "PasskeyUnsupportedError", {
|
|
12836
12684
|
enumerable: true,
|
|
12837
|
-
get: function () { return
|
|
12685
|
+
get: function () { return chunkF5USCCM4_cjs.PasskeyUnsupportedError; }
|
|
12838
12686
|
});
|
|
12839
12687
|
Object.defineProperty(exports, "UserFacingError", {
|
|
12840
12688
|
enumerable: true,
|
|
12841
|
-
get: function () { return
|
|
12689
|
+
get: function () { return chunkF5USCCM4_cjs.UserFacingError; }
|
|
12842
12690
|
});
|
|
12843
12691
|
Object.defineProperty(exports, "computeAccountAddress", {
|
|
12844
12692
|
enumerable: true,
|
|
12845
|
-
get: function () { return
|
|
12693
|
+
get: function () { return chunkF5USCCM4_cjs.computeAccountAddress; }
|
|
12846
12694
|
});
|
|
12847
12695
|
Object.defineProperty(exports, "createPasskeyOwner", {
|
|
12848
12696
|
enumerable: true,
|
|
12849
|
-
get: function () { return
|
|
12697
|
+
get: function () { return chunkF5USCCM4_cjs.createPasskeyOwner; }
|
|
12850
12698
|
});
|
|
12851
12699
|
Object.defineProperty(exports, "deriveAesKey", {
|
|
12852
12700
|
enumerable: true,
|
|
12853
|
-
get: function () { return
|
|
12701
|
+
get: function () { return chunkF5USCCM4_cjs.deriveAesKey; }
|
|
12854
12702
|
});
|
|
12855
12703
|
Object.defineProperty(exports, "generateStarkKeyPair", {
|
|
12856
12704
|
enumerable: true,
|
|
12857
|
-
get: function () { return
|
|
12705
|
+
get: function () { return chunkF5USCCM4_cjs.generateStarkKeyPair; }
|
|
12858
12706
|
});
|
|
12859
12707
|
Object.defineProperty(exports, "ownerConstructorCalldata", {
|
|
12860
12708
|
enumerable: true,
|
|
12861
|
-
get: function () { return
|
|
12709
|
+
get: function () { return chunkF5USCCM4_cjs.ownerConstructorCalldata; }
|
|
12862
12710
|
});
|
|
12863
12711
|
Object.defineProperty(exports, "sealPrivateKey", {
|
|
12864
12712
|
enumerable: true,
|
|
12865
|
-
get: function () { return
|
|
12713
|
+
get: function () { return chunkF5USCCM4_cjs.sealPrivateKey; }
|
|
12866
12714
|
});
|
|
12867
12715
|
Object.defineProperty(exports, "signWithPrivateKey", {
|
|
12868
12716
|
enumerable: true,
|
|
12869
|
-
get: function () { return
|
|
12717
|
+
get: function () { return chunkF5USCCM4_cjs.signWithPrivateKey; }
|
|
12870
12718
|
});
|
|
12871
12719
|
Object.defineProperty(exports, "starkKeyPairFromPrivateKey", {
|
|
12872
12720
|
enumerable: true,
|
|
12873
|
-
get: function () { return
|
|
12721
|
+
get: function () { return chunkF5USCCM4_cjs.starkKeyPairFromPrivateKey; }
|
|
12874
12722
|
});
|
|
12875
12723
|
Object.defineProperty(exports, "unsealPrivateKey", {
|
|
12876
12724
|
enumerable: true,
|
|
12877
|
-
get: function () { return
|
|
12725
|
+
get: function () { return chunkF5USCCM4_cjs.unsealPrivateKey; }
|
|
12878
12726
|
});
|
|
12879
12727
|
exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
|
|
12880
12728
|
exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
|
|
@@ -12916,6 +12764,7 @@ exports.TicketService = TicketService;
|
|
|
12916
12764
|
exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
|
|
12917
12765
|
exports.accountFor = accountFor;
|
|
12918
12766
|
exports.allowsFallbackFunding = allowsFallbackFunding;
|
|
12767
|
+
exports.apiKeyConfirmationTypedData = apiKeyConfirmationTypedData;
|
|
12919
12768
|
exports.assertTransactionSucceeded = assertTransactionSucceeded;
|
|
12920
12769
|
exports.build1155CancellationTypedData = build1155CancellationTypedData;
|
|
12921
12770
|
exports.build1155OrderTypedData = build1155OrderTypedData;
|
|
@@ -12941,6 +12790,7 @@ exports.coinToRaw = toRaw;
|
|
|
12941
12790
|
exports.completeDeployment = completeDeployment;
|
|
12942
12791
|
exports.computeOwnerGuid = computeOwnerGuid;
|
|
12943
12792
|
exports.confirmIntentBestEffort = confirmIntentBestEffort;
|
|
12793
|
+
exports.createChainProvider = createChainProvider;
|
|
12944
12794
|
exports.createDeploymentCoordinator = createDeploymentCoordinator;
|
|
12945
12795
|
exports.createMediaWallet = createMediaWallet;
|
|
12946
12796
|
exports.createOwnerStore = createOwnerStore;
|
|
@@ -12964,6 +12814,7 @@ exports.encodeByteArray = encodeByteArray;
|
|
|
12964
12814
|
exports.encodePairingPayload = encodePairingPayload;
|
|
12965
12815
|
exports.encodePopClaimFragment = encodePopClaimFragment;
|
|
12966
12816
|
exports.encodeRecoveryKey = encodeRecoveryKey;
|
|
12817
|
+
exports.erc20Balance = erc20Balance;
|
|
12967
12818
|
exports.estimateSelfFundedFee = estimateSelfFundedFee;
|
|
12968
12819
|
exports.executeIntent = executeIntent;
|
|
12969
12820
|
exports.executeIntents = executeIntents;
|
|
@@ -12973,14 +12824,10 @@ exports.feeAmount = feeAmount;
|
|
|
12973
12824
|
exports.feeBps = feeBps;
|
|
12974
12825
|
exports.fundWithChainTransfer = fundWithChainTransfer;
|
|
12975
12826
|
exports.fundingApiFor = fundingApiFor;
|
|
12976
|
-
exports.getCounter = getCounter;
|
|
12977
|
-
exports.getCounter1155 = getCounter1155;
|
|
12978
12827
|
exports.getCreatorCoinGuarantees = getCreatorCoinGuarantees;
|
|
12979
12828
|
exports.getEscape = getEscape;
|
|
12980
12829
|
exports.getEscapeSecurityPeriod = getEscapeSecurityPeriod;
|
|
12981
12830
|
exports.getGuardians = getGuardians;
|
|
12982
|
-
exports.getOrderDetails = getOrderDetails;
|
|
12983
|
-
exports.getOrderDetails1155 = getOrderDetails1155;
|
|
12984
12831
|
exports.getOwners = getOwners;
|
|
12985
12832
|
exports.getSiwsStorageKey = getSiwsStorageKey;
|
|
12986
12833
|
exports.getStoredSiwsToken = getStoredSiwsToken;
|