@medialane/sdk 0.181.0 → 0.183.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-EWDU2XV3.cjs → chunk-F5USCCM4.cjs} +7 -78
- package/dist/chunk-F5USCCM4.cjs.map +1 -0
- package/dist/{chunk-BTSTG6SP.js → chunk-JZXIZGHW.js} +4 -71
- package/dist/chunk-JZXIZGHW.js.map +1 -0
- package/dist/{errors-Bsah998f.d.cts → errors-C3dgi8bK.d.cts} +1 -7
- package/dist/{errors-DQyz1fFP.d.ts → errors-kFtjB-a3.d.ts} +1 -7
- 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 +131 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -23
- package/dist/index.d.ts +16 -23
- package/dist/index.js +55 -3
- 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 +126 -289
- 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 +52 -213
- 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-BTSTG6SP.js.map +0 -1
- package/dist/chunk-EWDU2XV3.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: chunkEWDU2XV3_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, chunkEWDU2XV3_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, chunkEWDU2XV3_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, chunkEWDU2XV3_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);
|
|
@@ -12048,18 +11878,32 @@ async function confirmIntentBestEffort(client, intentId, txHash) {
|
|
|
12048
11878
|
await client.api.confirmIntent(intentId, txHash).catch(() => {
|
|
12049
11879
|
});
|
|
12050
11880
|
}
|
|
12051
|
-
var SYNC_TIMEOUT_MS =
|
|
12052
|
-
|
|
11881
|
+
var SYNC_TIMEOUT_MS = 2e4;
|
|
11882
|
+
var SYNC_RETRY_MS = 2e3;
|
|
11883
|
+
function readableLater(err) {
|
|
11884
|
+
return err instanceof chunkF5USCCM4_cjs.MedialaneApiError && err.status === 404;
|
|
11885
|
+
}
|
|
11886
|
+
async function syncTransactionBestEffort(client, txHash, timeoutMs = SYNC_TIMEOUT_MS, retryMs = SYNC_RETRY_MS) {
|
|
11887
|
+
const deadline = Date.now() + timeoutMs;
|
|
11888
|
+
let stopped = false;
|
|
12053
11889
|
let timer;
|
|
12054
11890
|
const timeout = new Promise((resolve) => {
|
|
12055
11891
|
timer = setTimeout(() => resolve(), timeoutMs);
|
|
12056
11892
|
});
|
|
12057
|
-
const sync =
|
|
12058
|
-
|
|
12059
|
-
|
|
11893
|
+
const sync = (async () => {
|
|
11894
|
+
while (!stopped) {
|
|
11895
|
+
const again = await client.api.syncTransaction(txHash).then(
|
|
11896
|
+
(res) => res.data?.pending === true,
|
|
11897
|
+
readableLater
|
|
11898
|
+
);
|
|
11899
|
+
if (!again || Date.now() + retryMs >= deadline) return;
|
|
11900
|
+
await new Promise((resolve) => setTimeout(resolve, retryMs));
|
|
11901
|
+
}
|
|
11902
|
+
})();
|
|
12060
11903
|
try {
|
|
12061
11904
|
await Promise.race([sync, timeout]);
|
|
12062
11905
|
} finally {
|
|
11906
|
+
stopped = true;
|
|
12063
11907
|
if (timer) clearTimeout(timer);
|
|
12064
11908
|
}
|
|
12065
11909
|
}
|
|
@@ -12072,16 +11916,16 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
|
|
|
12072
11916
|
const receipt = await provider.getTransactionReceipt(txHash);
|
|
12073
11917
|
const status = receipt.execution_status ?? receipt.status;
|
|
12074
11918
|
if (status === "REVERTED" || status === "REJECTED") {
|
|
12075
|
-
throw new
|
|
11919
|
+
throw new chunkF5USCCM4_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
|
|
12076
11920
|
}
|
|
12077
11921
|
if (status) return receipt;
|
|
12078
11922
|
} catch (err) {
|
|
12079
11923
|
if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
|
|
12080
11924
|
}
|
|
12081
11925
|
}
|
|
12082
|
-
throw new
|
|
11926
|
+
throw new chunkF5USCCM4_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
|
|
12083
11927
|
}
|
|
12084
|
-
async function executeIntent(
|
|
11928
|
+
async function executeIntent(signer, client, intent, opts = {}) {
|
|
12085
11929
|
let calls;
|
|
12086
11930
|
if (intent.requiresSignature) {
|
|
12087
11931
|
const signature = await signer.signTypedData(intent.typedData);
|
|
@@ -12091,20 +11935,20 @@ async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
|
12091
11935
|
calls = intent.calls;
|
|
12092
11936
|
}
|
|
12093
11937
|
const { txHash } = await signer.execute(calls, { intentIds: [intent.id] });
|
|
12094
|
-
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11938
|
+
const receipt = await assertTransactionSucceeded(client.provider, txHash);
|
|
12095
11939
|
await Promise.all([
|
|
12096
11940
|
syncTransactionBestEffort(client, txHash),
|
|
12097
11941
|
opts.confirm !== false ? confirmIntentBestEffort(client, intent.id, txHash) : void 0
|
|
12098
11942
|
]);
|
|
12099
11943
|
return { txHash, receipt };
|
|
12100
11944
|
}
|
|
12101
|
-
async function executeIntents(
|
|
11945
|
+
async function executeIntents(signer, client, intents, opts = {}) {
|
|
12102
11946
|
if (intents.some((i) => i.requiresSignature)) {
|
|
12103
11947
|
throw new Error("Expected prebuilt intents (requiresSignature=false)");
|
|
12104
11948
|
}
|
|
12105
11949
|
const calls = intents.flatMap((i) => i.calls);
|
|
12106
11950
|
const { txHash } = await signer.execute(calls, { intentIds: intents.map((i) => i.id) });
|
|
12107
|
-
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11951
|
+
const receipt = await assertTransactionSucceeded(client.provider, txHash);
|
|
12108
11952
|
await Promise.all([
|
|
12109
11953
|
syncTransactionBestEffort(client, txHash),
|
|
12110
11954
|
...opts.confirm !== false ? intents.map((i) => confirmIntentBestEffort(client, i.id, txHash)) : []
|
|
@@ -12132,14 +11976,14 @@ function u2563(low, high) {
|
|
|
12132
11976
|
return (BigInt(low ?? 0) + (BigInt(high ?? 0) << 128n)).toString();
|
|
12133
11977
|
}
|
|
12134
11978
|
function deployedCollectionFromReceipt(receipt, service) {
|
|
12135
|
-
const factory =
|
|
11979
|
+
const factory = chunkF5USCCM4_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
|
|
12136
11980
|
const { event, address } = DEPLOY_EVENTS[service];
|
|
12137
11981
|
const selector = BigInt(starknet.hash.getSelectorFromName(event));
|
|
12138
11982
|
for (const e of receipt.events ?? []) {
|
|
12139
11983
|
if (factory && !sameFelt(e.from_address, factory)) continue;
|
|
12140
11984
|
if (!sameFelt(e.keys?.[0], selector)) continue;
|
|
12141
11985
|
const value = address(e);
|
|
12142
|
-
if (value) return
|
|
11986
|
+
if (value) return chunkF5USCCM4_cjs.normalizeAddress("STARKNET", value);
|
|
12143
11987
|
}
|
|
12144
11988
|
return null;
|
|
12145
11989
|
}
|
|
@@ -12260,13 +12104,13 @@ function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
|
|
|
12260
12104
|
}
|
|
12261
12105
|
function buildDeployAccountParams(ownerPubkey, salt = 0) {
|
|
12262
12106
|
return {
|
|
12263
|
-
classHash:
|
|
12264
|
-
constructorCalldata:
|
|
12107
|
+
classHash: chunkF5USCCM4_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
|
|
12108
|
+
constructorCalldata: chunkF5USCCM4_cjs.ownerConstructorCalldata(ownerPubkey),
|
|
12265
12109
|
addressSalt: starknet.num.toHex(salt),
|
|
12266
|
-
contractAddress:
|
|
12110
|
+
contractAddress: chunkF5USCCM4_cjs.computeAccountAddress(ownerPubkey, salt)
|
|
12267
12111
|
};
|
|
12268
12112
|
}
|
|
12269
|
-
var norm = (address) =>
|
|
12113
|
+
var norm = (address) => chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address);
|
|
12270
12114
|
var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
|
|
12271
12115
|
function encodeFeltArray(items) {
|
|
12272
12116
|
return [starknet.num.toHex(items.length), ...items];
|
|
@@ -12463,7 +12307,7 @@ var InvalidRecoveryKeyError = class extends Error {
|
|
|
12463
12307
|
var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
|
|
12464
12308
|
function keyPair(privateKey) {
|
|
12465
12309
|
try {
|
|
12466
|
-
return
|
|
12310
|
+
return chunkF5USCCM4_cjs.starkKeyPairFromPrivateKey(privateKey);
|
|
12467
12311
|
} catch {
|
|
12468
12312
|
throw new InvalidRecoveryKeyError();
|
|
12469
12313
|
}
|
|
@@ -12476,7 +12320,7 @@ function parseRecoveryKey(input) {
|
|
|
12476
12320
|
const trimmed = input.trim();
|
|
12477
12321
|
if (!trimmed.startsWith(PREFIX)) {
|
|
12478
12322
|
const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
|
|
12479
|
-
return { walletAddress:
|
|
12323
|
+
return { walletAddress: chunkF5USCCM4_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
|
|
12480
12324
|
}
|
|
12481
12325
|
const parts = trimmed.slice(PREFIX.length).split(":");
|
|
12482
12326
|
const [walletAddress, privateKey] = parts;
|
|
@@ -12498,7 +12342,7 @@ function describeRecoveryAction(escape) {
|
|
|
12498
12342
|
return "none";
|
|
12499
12343
|
}
|
|
12500
12344
|
function normalizeWalletAddress(address) {
|
|
12501
|
-
return
|
|
12345
|
+
return chunkF5USCCM4_cjs.normalizeAddress("STARKNET", address);
|
|
12502
12346
|
}
|
|
12503
12347
|
function isValidStarknetAddress(address) {
|
|
12504
12348
|
try {
|
|
@@ -12543,14 +12387,9 @@ async function estimateSelfFundedFee(provider, address, calls) {
|
|
|
12543
12387
|
return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
|
|
12544
12388
|
}
|
|
12545
12389
|
async function feeTokenBalance(provider, address, unit) {
|
|
12546
|
-
const token =
|
|
12390
|
+
const token = chunkF5USCCM4_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
|
|
12547
12391
|
if (!token) throw new Error(`No fee token for unit ${unit}`);
|
|
12548
|
-
|
|
12549
|
-
contractAddress: token.address,
|
|
12550
|
-
entrypoint: "balance_of",
|
|
12551
|
-
calldata: [address]
|
|
12552
|
-
});
|
|
12553
|
-
return BigInt(low) + (BigInt(high) << 128n);
|
|
12392
|
+
return erc20Balance(provider, token.address, address);
|
|
12554
12393
|
}
|
|
12555
12394
|
function selfFundedExecutor(deps) {
|
|
12556
12395
|
return {
|
|
@@ -12575,7 +12414,7 @@ function sponsoredExecutor(deps) {
|
|
|
12575
12414
|
{ proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
|
|
12576
12415
|
{
|
|
12577
12416
|
address: userAddress,
|
|
12578
|
-
signTypedData: async (data) =>
|
|
12417
|
+
signTypedData: async (data) => chunkF5USCCM4_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
|
|
12579
12418
|
},
|
|
12580
12419
|
{ intentIds }
|
|
12581
12420
|
);
|
|
@@ -12625,7 +12464,7 @@ async function deploySponsored(input) {
|
|
|
12625
12464
|
return { transactionHash };
|
|
12626
12465
|
}
|
|
12627
12466
|
async function deploySelfFunded(input) {
|
|
12628
|
-
const classHash =
|
|
12467
|
+
const classHash = chunk7EYJC5CB_cjs.getCoordinates("STARKNET").mediaWalletClassHash;
|
|
12629
12468
|
if (!classHash) throw new Error("Media Wallet class hash is not configured");
|
|
12630
12469
|
const account = new starknet.Account({
|
|
12631
12470
|
provider: input.provider,
|
|
@@ -12635,7 +12474,7 @@ async function deploySelfFunded(input) {
|
|
|
12635
12474
|
});
|
|
12636
12475
|
const { transaction_hash } = await account.deployAccount({
|
|
12637
12476
|
classHash,
|
|
12638
|
-
constructorCalldata:
|
|
12477
|
+
constructorCalldata: chunkF5USCCM4_cjs.ownerConstructorCalldata(input.ownerPubKey),
|
|
12639
12478
|
addressSalt: 0,
|
|
12640
12479
|
contractAddress: input.ownerAddress
|
|
12641
12480
|
});
|
|
@@ -12791,7 +12630,7 @@ function createMediaWallet(config) {
|
|
|
12791
12630
|
};
|
|
12792
12631
|
const walletIntents = config.walletIntents ?? (async (params) => {
|
|
12793
12632
|
if (!config.backendUrl) throw new Error("This wallet has no backend url configured");
|
|
12794
|
-
const created = await new
|
|
12633
|
+
const created = await new chunkF5USCCM4_cjs.ApiClient(config.backendUrl).createWalletManageIntent(params);
|
|
12795
12634
|
return created.data;
|
|
12796
12635
|
});
|
|
12797
12636
|
const manage = async (sealed, params) => {
|
|
@@ -12808,7 +12647,7 @@ function createMediaWallet(config) {
|
|
|
12808
12647
|
address: sealed.address,
|
|
12809
12648
|
signTypedData: async (data) => {
|
|
12810
12649
|
const privateKeyHex = await unlockOnce(sealed);
|
|
12811
|
-
return
|
|
12650
|
+
return chunkF5USCCM4_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
|
|
12812
12651
|
},
|
|
12813
12652
|
execute: async (calls, opts) => {
|
|
12814
12653
|
const { transactionHash } = await run(sealed, calls, void 0, opts?.intentIds);
|
|
@@ -12849,55 +12688,55 @@ async function claimSessionWallet(api, walletAddress, deps) {
|
|
|
12849
12688
|
|
|
12850
12689
|
Object.defineProperty(exports, "InvalidStarkPrivateKeyError", {
|
|
12851
12690
|
enumerable: true,
|
|
12852
|
-
get: function () { return
|
|
12691
|
+
get: function () { return chunkF5USCCM4_cjs.InvalidStarkPrivateKeyError; }
|
|
12853
12692
|
});
|
|
12854
12693
|
Object.defineProperty(exports, "PasskeyCancelledError", {
|
|
12855
12694
|
enumerable: true,
|
|
12856
|
-
get: function () { return
|
|
12695
|
+
get: function () { return chunkF5USCCM4_cjs.PasskeyCancelledError; }
|
|
12857
12696
|
});
|
|
12858
12697
|
Object.defineProperty(exports, "PasskeyUnsupportedError", {
|
|
12859
12698
|
enumerable: true,
|
|
12860
|
-
get: function () { return
|
|
12699
|
+
get: function () { return chunkF5USCCM4_cjs.PasskeyUnsupportedError; }
|
|
12861
12700
|
});
|
|
12862
12701
|
Object.defineProperty(exports, "UserFacingError", {
|
|
12863
12702
|
enumerable: true,
|
|
12864
|
-
get: function () { return
|
|
12703
|
+
get: function () { return chunkF5USCCM4_cjs.UserFacingError; }
|
|
12865
12704
|
});
|
|
12866
12705
|
Object.defineProperty(exports, "computeAccountAddress", {
|
|
12867
12706
|
enumerable: true,
|
|
12868
|
-
get: function () { return
|
|
12707
|
+
get: function () { return chunkF5USCCM4_cjs.computeAccountAddress; }
|
|
12869
12708
|
});
|
|
12870
12709
|
Object.defineProperty(exports, "createPasskeyOwner", {
|
|
12871
12710
|
enumerable: true,
|
|
12872
|
-
get: function () { return
|
|
12711
|
+
get: function () { return chunkF5USCCM4_cjs.createPasskeyOwner; }
|
|
12873
12712
|
});
|
|
12874
12713
|
Object.defineProperty(exports, "deriveAesKey", {
|
|
12875
12714
|
enumerable: true,
|
|
12876
|
-
get: function () { return
|
|
12715
|
+
get: function () { return chunkF5USCCM4_cjs.deriveAesKey; }
|
|
12877
12716
|
});
|
|
12878
12717
|
Object.defineProperty(exports, "generateStarkKeyPair", {
|
|
12879
12718
|
enumerable: true,
|
|
12880
|
-
get: function () { return
|
|
12719
|
+
get: function () { return chunkF5USCCM4_cjs.generateStarkKeyPair; }
|
|
12881
12720
|
});
|
|
12882
12721
|
Object.defineProperty(exports, "ownerConstructorCalldata", {
|
|
12883
12722
|
enumerable: true,
|
|
12884
|
-
get: function () { return
|
|
12723
|
+
get: function () { return chunkF5USCCM4_cjs.ownerConstructorCalldata; }
|
|
12885
12724
|
});
|
|
12886
12725
|
Object.defineProperty(exports, "sealPrivateKey", {
|
|
12887
12726
|
enumerable: true,
|
|
12888
|
-
get: function () { return
|
|
12727
|
+
get: function () { return chunkF5USCCM4_cjs.sealPrivateKey; }
|
|
12889
12728
|
});
|
|
12890
12729
|
Object.defineProperty(exports, "signWithPrivateKey", {
|
|
12891
12730
|
enumerable: true,
|
|
12892
|
-
get: function () { return
|
|
12731
|
+
get: function () { return chunkF5USCCM4_cjs.signWithPrivateKey; }
|
|
12893
12732
|
});
|
|
12894
12733
|
Object.defineProperty(exports, "starkKeyPairFromPrivateKey", {
|
|
12895
12734
|
enumerable: true,
|
|
12896
|
-
get: function () { return
|
|
12735
|
+
get: function () { return chunkF5USCCM4_cjs.starkKeyPairFromPrivateKey; }
|
|
12897
12736
|
});
|
|
12898
12737
|
Object.defineProperty(exports, "unsealPrivateKey", {
|
|
12899
12738
|
enumerable: true,
|
|
12900
|
-
get: function () { return
|
|
12739
|
+
get: function () { return chunkF5USCCM4_cjs.unsealPrivateKey; }
|
|
12901
12740
|
});
|
|
12902
12741
|
exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
|
|
12903
12742
|
exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
|
|
@@ -12965,6 +12804,7 @@ exports.coinToRaw = toRaw;
|
|
|
12965
12804
|
exports.completeDeployment = completeDeployment;
|
|
12966
12805
|
exports.computeOwnerGuid = computeOwnerGuid;
|
|
12967
12806
|
exports.confirmIntentBestEffort = confirmIntentBestEffort;
|
|
12807
|
+
exports.createChainProvider = createChainProvider;
|
|
12968
12808
|
exports.createDeploymentCoordinator = createDeploymentCoordinator;
|
|
12969
12809
|
exports.createMediaWallet = createMediaWallet;
|
|
12970
12810
|
exports.createOwnerStore = createOwnerStore;
|
|
@@ -12988,6 +12828,7 @@ exports.encodeByteArray = encodeByteArray;
|
|
|
12988
12828
|
exports.encodePairingPayload = encodePairingPayload;
|
|
12989
12829
|
exports.encodePopClaimFragment = encodePopClaimFragment;
|
|
12990
12830
|
exports.encodeRecoveryKey = encodeRecoveryKey;
|
|
12831
|
+
exports.erc20Balance = erc20Balance;
|
|
12991
12832
|
exports.estimateSelfFundedFee = estimateSelfFundedFee;
|
|
12992
12833
|
exports.executeIntent = executeIntent;
|
|
12993
12834
|
exports.executeIntents = executeIntents;
|
|
@@ -12997,14 +12838,10 @@ exports.feeAmount = feeAmount;
|
|
|
12997
12838
|
exports.feeBps = feeBps;
|
|
12998
12839
|
exports.fundWithChainTransfer = fundWithChainTransfer;
|
|
12999
12840
|
exports.fundingApiFor = fundingApiFor;
|
|
13000
|
-
exports.getCounter = getCounter;
|
|
13001
|
-
exports.getCounter1155 = getCounter1155;
|
|
13002
12841
|
exports.getCreatorCoinGuarantees = getCreatorCoinGuarantees;
|
|
13003
12842
|
exports.getEscape = getEscape;
|
|
13004
12843
|
exports.getEscapeSecurityPeriod = getEscapeSecurityPeriod;
|
|
13005
12844
|
exports.getGuardians = getGuardians;
|
|
13006
|
-
exports.getOrderDetails = getOrderDetails;
|
|
13007
|
-
exports.getOrderDetails1155 = getOrderDetails1155;
|
|
13008
12845
|
exports.getOwners = getOwners;
|
|
13009
12846
|
exports.getSiwsStorageKey = getSiwsStorageKey;
|
|
13010
12847
|
exports.getStoredSiwsToken = getStoredSiwsToken;
|