@medialane/sdk 0.167.0 → 0.168.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-USFXQO4T.js → chunk-3QGECZBS.js} +44 -2
- package/dist/chunk-3QGECZBS.js.map +1 -0
- package/dist/{chunk-TPONHUAU.cjs → chunk-BILJIXSP.cjs} +44 -2
- package/dist/chunk-BILJIXSP.cjs.map +1 -0
- package/dist/{errors-DRiTDrwm.d.ts → errors-CWbsAodQ.d.ts} +102 -2
- package/dist/{errors-GcSzVvZL.d.cts → errors-CwqwX-vA.d.cts} +102 -2
- package/dist/evm/index.d.cts +1 -1
- package/dist/evm/index.d.ts +1 -1
- package/dist/index.cjs +77 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/solana/index.d.cts +1 -1
- package/dist/solana/index.d.ts +1 -1
- package/dist/starknet/index.cjs +98 -112
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +13 -6
- package/dist/starknet/index.d.ts +13 -6
- package/dist/starknet/index.js +32 -46
- package/dist/starknet/index.js.map +1 -1
- package/dist/stellar/index.d.cts +1 -1
- package/dist/stellar/index.d.ts +1 -1
- package/dist/{types-PPshMWr7.d.cts → types-C-y68Ut2.d.cts} +3 -1
- package/dist/{types-PPshMWr7.d.ts → types-C-y68Ut2.d.ts} +3 -1
- package/package.json +1 -1
- package/dist/chunk-TPONHUAU.cjs.map +0 -1
- package/dist/chunk-USFXQO4T.js.map +0 -1
package/dist/starknet/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBILJIXSP_cjs = require('../chunk-BILJIXSP.cjs');
|
|
4
4
|
var chunkH7I6TEOA_cjs = require('../chunk-H7I6TEOA.cjs');
|
|
5
5
|
var starknet = require('starknet');
|
|
6
6
|
var hkdf_js = require('@noble/hashes/hkdf.js');
|
|
@@ -33,7 +33,7 @@ function getChainId(config) {
|
|
|
33
33
|
return starknet.constants.StarknetChainId.SN_MAIN;
|
|
34
34
|
}
|
|
35
35
|
function resolveToken(currency) {
|
|
36
|
-
const token =
|
|
36
|
+
const token = chunkBILJIXSP_cjs.SUPPORTED_TOKENS.find(
|
|
37
37
|
(t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
|
|
38
38
|
);
|
|
39
39
|
if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
|
|
@@ -44,7 +44,7 @@ function getProvider(config) {
|
|
|
44
44
|
let p = _providerCache.get(config);
|
|
45
45
|
if (!p) {
|
|
46
46
|
const urls = [config.rpcUrl];
|
|
47
|
-
p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch:
|
|
47
|
+
p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch: chunkBILJIXSP_cjs.createFailoverFetch(urls) });
|
|
48
48
|
_providerCache.set(config, p);
|
|
49
49
|
}
|
|
50
50
|
return p;
|
|
@@ -9768,7 +9768,7 @@ function merkleTree(leafHashes) {
|
|
|
9768
9768
|
};
|
|
9769
9769
|
}
|
|
9770
9770
|
function buildPopAllowlist(addresses) {
|
|
9771
|
-
const unique = [...new Set(addresses.map((a) =>
|
|
9771
|
+
const unique = [...new Set(addresses.map((a) => chunkBILJIXSP_cjs.normalizeAddress("STARKNET", a)))];
|
|
9772
9772
|
if (unique.length === 0) throw new Error("An allowlist needs at least one address");
|
|
9773
9773
|
const leaves = unique.map((address) => ({ address, leaf: popLeafHash(address) }));
|
|
9774
9774
|
const tree = merkleTree(leaves.map((l) => l.leaf));
|
|
@@ -9794,7 +9794,7 @@ function decodePopClaimFragment(fragment) {
|
|
|
9794
9794
|
|
|
9795
9795
|
// src/starknet/pop-claim.ts
|
|
9796
9796
|
function popClaimLinks(origin, collection, list) {
|
|
9797
|
-
const base = `${origin}${
|
|
9797
|
+
const base = `${origin}${chunkBILJIXSP_cjs.collectionHref("STARKNET", collection)}`;
|
|
9798
9798
|
return Object.entries(list.proofs).map(([address, proof]) => ({
|
|
9799
9799
|
address,
|
|
9800
9800
|
url: `${base}${encodePopClaimFragment(proof)}`
|
|
@@ -9804,7 +9804,7 @@ function popClaimLinksCsv(links) {
|
|
|
9804
9804
|
return ["address,claim_link", ...links.map((l) => `${l.address},${l.url}`)].join("\n");
|
|
9805
9805
|
}
|
|
9806
9806
|
async function popClaimInfo(provider, collection) {
|
|
9807
|
-
const contractAddress =
|
|
9807
|
+
const contractAddress = chunkBILJIXSP_cjs.normalizeAddress("STARKNET", collection);
|
|
9808
9808
|
const [root, end] = await Promise.all([
|
|
9809
9809
|
provider.callContract({ contractAddress, entrypoint: "allowlist_root", calldata: [] }),
|
|
9810
9810
|
provider.callContract({ contractAddress, entrypoint: "claim_end_time", calldata: [] })
|
|
@@ -9821,7 +9821,7 @@ function popClaimState(input) {
|
|
|
9821
9821
|
if (!wallet || !verifyPopProof(info.root, wallet, proof)) return "wrong-wallet";
|
|
9822
9822
|
return "ready";
|
|
9823
9823
|
}
|
|
9824
|
-
var addr = (a) =>
|
|
9824
|
+
var addr = (a) => chunkBILJIXSP_cjs.normalizeAddress("STARKNET", a);
|
|
9825
9825
|
var byteArrayFelts = (s) => starknet.CallData.compile([starknet.byteArray.byteArrayFromString(s)]);
|
|
9826
9826
|
var popCalls = {
|
|
9827
9827
|
claim(collection, proof) {
|
|
@@ -9876,9 +9876,9 @@ var PopService = class {
|
|
|
9876
9876
|
};
|
|
9877
9877
|
async function popHasClaimed(provider, collection, address) {
|
|
9878
9878
|
const res = await provider.callContract({
|
|
9879
|
-
contractAddress:
|
|
9879
|
+
contractAddress: chunkBILJIXSP_cjs.normalizeAddress("STARKNET", collection),
|
|
9880
9880
|
entrypoint: "has_claimed",
|
|
9881
|
-
calldata: [
|
|
9881
|
+
calldata: [chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address)]
|
|
9882
9882
|
});
|
|
9883
9883
|
return BigInt(res[0] ?? "0x0") !== 0n;
|
|
9884
9884
|
}
|
|
@@ -9912,7 +9912,7 @@ var DropService = class {
|
|
|
9912
9912
|
this.config = config;
|
|
9913
9913
|
}
|
|
9914
9914
|
_collection(address, account) {
|
|
9915
|
-
return newContract(DropCollectionABI,
|
|
9915
|
+
return newContract(DropCollectionABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address), account);
|
|
9916
9916
|
}
|
|
9917
9917
|
async claim(account, collectionAddress, quantity = 1) {
|
|
9918
9918
|
const collection = this._collection(collectionAddress, account);
|
|
@@ -9997,14 +9997,14 @@ var ERC1155CollectionService = class {
|
|
|
9997
9997
|
_factory(account) {
|
|
9998
9998
|
return newContract(
|
|
9999
9999
|
IPCollection1155FactoryABI,
|
|
10000
|
-
|
|
10000
|
+
chunkBILJIXSP_cjs.normalizeAddress("STARKNET", this.factoryAddress),
|
|
10001
10001
|
account
|
|
10002
10002
|
);
|
|
10003
10003
|
}
|
|
10004
10004
|
_collection(address, account) {
|
|
10005
10005
|
return newContract(
|
|
10006
10006
|
IPCollection1155ABI,
|
|
10007
|
-
|
|
10007
|
+
chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address),
|
|
10008
10008
|
account
|
|
10009
10009
|
);
|
|
10010
10010
|
}
|
|
@@ -10232,20 +10232,20 @@ function buildLaunchOnEkuboCalls(params) {
|
|
|
10232
10232
|
}
|
|
10233
10233
|
var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
|
|
10234
10234
|
function parseCreatorCoinCreated(receipt) {
|
|
10235
|
-
const factory =
|
|
10235
|
+
const factory = chunkBILJIXSP_cjs.normalizeAddress("STARKNET", chunkH7I6TEOA_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory);
|
|
10236
10236
|
for (const ev of receipt?.events ?? []) {
|
|
10237
10237
|
let from;
|
|
10238
10238
|
try {
|
|
10239
|
-
from =
|
|
10239
|
+
from = chunkBILJIXSP_cjs.normalizeAddress("STARKNET", ev.from_address ?? "");
|
|
10240
10240
|
} catch {
|
|
10241
10241
|
continue;
|
|
10242
10242
|
}
|
|
10243
10243
|
if (from !== factory) continue;
|
|
10244
10244
|
const k0 = ev.keys?.[0];
|
|
10245
|
-
if (!k0 ||
|
|
10245
|
+
if (!k0 || chunkBILJIXSP_cjs.normalizeAddress("STARKNET", k0) !== chunkBILJIXSP_cjs.normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
|
|
10246
10246
|
const data = ev.data ?? [];
|
|
10247
10247
|
if (data.length < 1) continue;
|
|
10248
|
-
return
|
|
10248
|
+
return chunkBILJIXSP_cjs.normalizeAddress("STARKNET", data[data.length - 1]);
|
|
10249
10249
|
}
|
|
10250
10250
|
throw new Error("Coin deployed but the coin address could not be read from the receipt");
|
|
10251
10251
|
}
|
|
@@ -10281,14 +10281,14 @@ var TicketService = class {
|
|
|
10281
10281
|
_factory(account, factoryAddress) {
|
|
10282
10282
|
const address = factoryAddress ?? this.factoryAddress;
|
|
10283
10283
|
if (!address) throw new Error("IP-Tickets factory address not configured for this chain");
|
|
10284
|
-
return newContract(IPTicketCollectionFactoryABI,
|
|
10284
|
+
return newContract(IPTicketCollectionFactoryABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address), account);
|
|
10285
10285
|
}
|
|
10286
10286
|
_collection(address, account) {
|
|
10287
|
-
return newContract(IPTicketCollectionABI,
|
|
10287
|
+
return newContract(IPTicketCollectionABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address), account);
|
|
10288
10288
|
}
|
|
10289
10289
|
_collectionRead(address) {
|
|
10290
10290
|
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
10291
|
-
return newContract(IPTicketCollectionABI,
|
|
10291
|
+
return newContract(IPTicketCollectionABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address), provider);
|
|
10292
10292
|
}
|
|
10293
10293
|
async deployCollection(account, params) {
|
|
10294
10294
|
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
@@ -10354,14 +10354,14 @@ var ClubService = class {
|
|
|
10354
10354
|
_factory(account, factoryAddress) {
|
|
10355
10355
|
const address = factoryAddress ?? this.factoryAddress;
|
|
10356
10356
|
if (!address) throw new Error("IP-Club factory address not configured for this chain");
|
|
10357
|
-
return newContract(IPClubFactoryABI,
|
|
10357
|
+
return newContract(IPClubFactoryABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address), account);
|
|
10358
10358
|
}
|
|
10359
10359
|
_collection(address, account) {
|
|
10360
|
-
return newContract(IPClubCollectionABI,
|
|
10360
|
+
return newContract(IPClubCollectionABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address), account);
|
|
10361
10361
|
}
|
|
10362
10362
|
_collectionRead(address) {
|
|
10363
10363
|
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
10364
|
-
return newContract(IPClubCollectionABI,
|
|
10364
|
+
return newContract(IPClubCollectionABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address), provider);
|
|
10365
10365
|
}
|
|
10366
10366
|
async deployCollection(account, params) {
|
|
10367
10367
|
const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
|
|
@@ -10431,7 +10431,7 @@ var SponsorshipService = class {
|
|
|
10431
10431
|
if (!resolved) {
|
|
10432
10432
|
throw new Error("IP-Sponsorship address not configured for this chain");
|
|
10433
10433
|
}
|
|
10434
|
-
return newContract(IPSponsorshipABI,
|
|
10434
|
+
return newContract(IPSponsorshipABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", resolved), account);
|
|
10435
10435
|
}
|
|
10436
10436
|
_contractRead(address) {
|
|
10437
10437
|
const resolved = address ?? this.sponsorshipAddress;
|
|
@@ -10439,7 +10439,7 @@ var SponsorshipService = class {
|
|
|
10439
10439
|
throw new Error("IP-Sponsorship address not configured for this chain");
|
|
10440
10440
|
}
|
|
10441
10441
|
const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
|
|
10442
|
-
return newContract(IPSponsorshipABI,
|
|
10442
|
+
return newContract(IPSponsorshipABI, chunkBILJIXSP_cjs.normalizeAddress("STARKNET", resolved), provider);
|
|
10443
10443
|
}
|
|
10444
10444
|
async createOffer(account, params) {
|
|
10445
10445
|
const specificSponsor = params.specificSponsor ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.specificSponsor) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
|
|
@@ -10474,7 +10474,7 @@ var SponsorshipService = class {
|
|
|
10474
10474
|
const approveCall = {
|
|
10475
10475
|
contractAddress: params.paymentToken,
|
|
10476
10476
|
entrypoint: "approve",
|
|
10477
|
-
calldata: [
|
|
10477
|
+
calldata: [chunkBILJIXSP_cjs.normalizeAddress("STARKNET", sponsorshipAddress), amount.low.toString(), amount.high.toString()]
|
|
10478
10478
|
};
|
|
10479
10479
|
const bidCall = this._contract(account, sponsorshipAddress).populate("place_bid", [
|
|
10480
10480
|
starknet.cairo.uint256(params.offerId),
|
|
@@ -10601,7 +10601,7 @@ var SponsorshipService = class {
|
|
|
10601
10601
|
// src/starknet/client.ts
|
|
10602
10602
|
var MedialaneClient = class {
|
|
10603
10603
|
constructor(rawConfig = {}) {
|
|
10604
|
-
this.config =
|
|
10604
|
+
this.config = chunkBILJIXSP_cjs.resolveConfig(rawConfig);
|
|
10605
10605
|
this.services = {
|
|
10606
10606
|
pop: new PopService(this.config),
|
|
10607
10607
|
drop: new DropService(this.config),
|
|
@@ -10612,9 +10612,9 @@ var MedialaneClient = class {
|
|
|
10612
10612
|
sponsorship: new SponsorshipService(this.config)
|
|
10613
10613
|
};
|
|
10614
10614
|
if (!this.config.backendUrl) {
|
|
10615
|
-
const sentinel = new
|
|
10615
|
+
const sentinel = new chunkBILJIXSP_cjs.ApiClient("https://medialane-sdk-no-backend.invalid", this.config.apiKey);
|
|
10616
10616
|
const apiMethodNames = new Set(
|
|
10617
|
-
Object.getOwnPropertyNames(
|
|
10617
|
+
Object.getOwnPropertyNames(chunkBILJIXSP_cjs.ApiClient.prototype).filter(
|
|
10618
10618
|
(k) => k !== "constructor" && typeof sentinel[k] === "function"
|
|
10619
10619
|
)
|
|
10620
10620
|
);
|
|
@@ -10631,7 +10631,7 @@ var MedialaneClient = class {
|
|
|
10631
10631
|
}
|
|
10632
10632
|
});
|
|
10633
10633
|
} else {
|
|
10634
|
-
this.api = new
|
|
10634
|
+
this.api = new chunkBILJIXSP_cjs.ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
|
|
10635
10635
|
}
|
|
10636
10636
|
}
|
|
10637
10637
|
get chain() {
|
|
@@ -10803,7 +10803,7 @@ function buildListingOrder(i, cfg) {
|
|
|
10803
10803
|
salt: i.salt,
|
|
10804
10804
|
counter: i.counter
|
|
10805
10805
|
};
|
|
10806
|
-
const typedData =
|
|
10806
|
+
const typedData = chunkBILJIXSP_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
|
|
10807
10807
|
return { orderParams, typedData };
|
|
10808
10808
|
}
|
|
10809
10809
|
function buildOfferOrder(i, cfg) {
|
|
@@ -10824,11 +10824,11 @@ function buildOfferOrder(i, cfg) {
|
|
|
10824
10824
|
salt: i.salt,
|
|
10825
10825
|
counter: i.counter
|
|
10826
10826
|
};
|
|
10827
|
-
const typedData =
|
|
10827
|
+
const typedData = chunkBILJIXSP_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
|
|
10828
10828
|
return { orderParams, typedData };
|
|
10829
10829
|
}
|
|
10830
10830
|
function registerPayload(orderParams, signature) {
|
|
10831
|
-
return
|
|
10831
|
+
return chunkBILJIXSP_cjs.stringifyBigInts({
|
|
10832
10832
|
parameters: {
|
|
10833
10833
|
...orderParams,
|
|
10834
10834
|
offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
|
|
@@ -10859,14 +10859,14 @@ function buildFulfillCalls(a, cfg) {
|
|
|
10859
10859
|
return fee ? [approve, fulfill, fee] : [approve, fulfill];
|
|
10860
10860
|
}
|
|
10861
10861
|
function buildCancelCalls(a, cfg) {
|
|
10862
|
-
const cancelRequest =
|
|
10862
|
+
const cancelRequest = chunkBILJIXSP_cjs.stringifyBigInts({
|
|
10863
10863
|
cancelation: { order_hash: a.orderHash, offerer: a.offerer },
|
|
10864
10864
|
signature: a.signature
|
|
10865
10865
|
});
|
|
10866
10866
|
return [contractFor(cfg).populate("cancel_order", [cancelRequest])];
|
|
10867
10867
|
}
|
|
10868
10868
|
function buildCancelTypedData(orderHash, offerer, cfg) {
|
|
10869
|
-
return
|
|
10869
|
+
return chunkBILJIXSP_cjs.stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
|
|
10870
10870
|
}
|
|
10871
10871
|
function contractFor2(cfg) {
|
|
10872
10872
|
return newContract(Medialane1155ABI, cfg.marketplace1155Contract, getProvider(cfg));
|
|
@@ -10889,7 +10889,7 @@ function buildListing1155Order(i, cfg) {
|
|
|
10889
10889
|
salt: i.salt,
|
|
10890
10890
|
counter: i.counter
|
|
10891
10891
|
};
|
|
10892
|
-
const typedData =
|
|
10892
|
+
const typedData = chunkBILJIXSP_cjs.stringifyBigInts(
|
|
10893
10893
|
build1155OrderTypedData(orderParams, getChainId(cfg))
|
|
10894
10894
|
);
|
|
10895
10895
|
return { orderParams, typedData };
|
|
@@ -10912,13 +10912,13 @@ function buildOffer1155Order(i, cfg) {
|
|
|
10912
10912
|
salt: i.salt,
|
|
10913
10913
|
counter: i.counter
|
|
10914
10914
|
};
|
|
10915
|
-
const typedData =
|
|
10915
|
+
const typedData = chunkBILJIXSP_cjs.stringifyBigInts(
|
|
10916
10916
|
build1155OrderTypedData(orderParams, getChainId(cfg))
|
|
10917
10917
|
);
|
|
10918
10918
|
return { orderParams, typedData };
|
|
10919
10919
|
}
|
|
10920
10920
|
function registerPayload2(orderParams, signature) {
|
|
10921
|
-
return
|
|
10921
|
+
return chunkBILJIXSP_cjs.stringifyBigInts({
|
|
10922
10922
|
parameters: {
|
|
10923
10923
|
...orderParams,
|
|
10924
10924
|
offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
|
|
@@ -10949,14 +10949,14 @@ function buildFulfill1155Calls(a, cfg) {
|
|
|
10949
10949
|
return fee ? [approve, fulfill, fee] : [approve, fulfill];
|
|
10950
10950
|
}
|
|
10951
10951
|
function buildCancel1155Calls(a, cfg) {
|
|
10952
|
-
const cancelPayload =
|
|
10952
|
+
const cancelPayload = chunkBILJIXSP_cjs.stringifyBigInts({
|
|
10953
10953
|
cancelation: { order_hash: a.orderHash, offerer: a.offerer },
|
|
10954
10954
|
signature: a.signature
|
|
10955
10955
|
});
|
|
10956
10956
|
return [contractFor2(cfg).populate("cancel_order", [cancelPayload])];
|
|
10957
10957
|
}
|
|
10958
10958
|
function buildCancel1155TypedData(orderHash, offerer, cfg) {
|
|
10959
|
-
return
|
|
10959
|
+
return chunkBILJIXSP_cjs.stringifyBigInts(
|
|
10960
10960
|
build1155CancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg))
|
|
10961
10961
|
);
|
|
10962
10962
|
}
|
|
@@ -11300,14 +11300,14 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
|
|
|
11300
11300
|
const receipt = await provider.getTransactionReceipt(txHash);
|
|
11301
11301
|
const status = receipt.execution_status ?? receipt.status;
|
|
11302
11302
|
if (status === "REVERTED" || status === "REJECTED") {
|
|
11303
|
-
throw new
|
|
11303
|
+
throw new chunkBILJIXSP_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
|
|
11304
11304
|
}
|
|
11305
11305
|
if (status) return receipt;
|
|
11306
11306
|
} catch (err) {
|
|
11307
11307
|
if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
|
|
11308
11308
|
}
|
|
11309
11309
|
}
|
|
11310
|
-
throw new
|
|
11310
|
+
throw new chunkBILJIXSP_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
|
|
11311
11311
|
}
|
|
11312
11312
|
async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
11313
11313
|
let calls;
|
|
@@ -11318,7 +11318,7 @@ async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
|
11318
11318
|
} else {
|
|
11319
11319
|
calls = intent.calls;
|
|
11320
11320
|
}
|
|
11321
|
-
const { txHash } = await signer.execute(calls);
|
|
11321
|
+
const { txHash } = await signer.execute(calls, { intentIds: [intent.id] });
|
|
11322
11322
|
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11323
11323
|
await Promise.all([
|
|
11324
11324
|
syncTransactionBestEffort(client, txHash),
|
|
@@ -11331,7 +11331,7 @@ async function executeIntents(provider, signer, client, intents, opts = {}) {
|
|
|
11331
11331
|
throw new Error("Expected prebuilt intents (requiresSignature=false)");
|
|
11332
11332
|
}
|
|
11333
11333
|
const calls = intents.flatMap((i) => i.calls);
|
|
11334
|
-
const { txHash } = await signer.execute(calls);
|
|
11334
|
+
const { txHash } = await signer.execute(calls, { intentIds: intents.map((i) => i.id) });
|
|
11335
11335
|
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11336
11336
|
await Promise.all([
|
|
11337
11337
|
syncTransactionBestEffort(client, txHash),
|
|
@@ -11360,14 +11360,14 @@ function u2562(low, high) {
|
|
|
11360
11360
|
return (BigInt(low ?? 0) + (BigInt(high ?? 0) << 128n)).toString();
|
|
11361
11361
|
}
|
|
11362
11362
|
function deployedCollectionFromReceipt(receipt, service) {
|
|
11363
|
-
const factory =
|
|
11363
|
+
const factory = chunkBILJIXSP_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
|
|
11364
11364
|
const { event, address } = DEPLOY_EVENTS[service];
|
|
11365
11365
|
const selector = BigInt(starknet.hash.getSelectorFromName(event));
|
|
11366
11366
|
for (const e of receipt.events ?? []) {
|
|
11367
11367
|
if (factory && !sameFelt(e.from_address, factory)) continue;
|
|
11368
11368
|
if (!sameFelt(e.keys?.[0], selector)) continue;
|
|
11369
11369
|
const value = address(e);
|
|
11370
|
-
if (value) return
|
|
11370
|
+
if (value) return chunkBILJIXSP_cjs.normalizeAddress("STARKNET", value);
|
|
11371
11371
|
}
|
|
11372
11372
|
return null;
|
|
11373
11373
|
}
|
|
@@ -11393,14 +11393,14 @@ async function failureOf(res, fallback) {
|
|
|
11393
11393
|
const body = await res.json().catch(() => null);
|
|
11394
11394
|
return { reason: body?.error || fallback, code: typeof body?.code === "string" ? body.code : void 0 };
|
|
11395
11395
|
}
|
|
11396
|
-
async function executeSponsored(config, signer, calls) {
|
|
11396
|
+
async function executeSponsored(config, signer, calls, intentIds) {
|
|
11397
11397
|
const doFetch = config.fetchImpl ?? fetch;
|
|
11398
11398
|
const base = config.proxyUrl.replace(/\/$/, "");
|
|
11399
|
-
const headers = { "Content-Type": "application/json" };
|
|
11399
|
+
const headers = { "Content-Type": "application/json", ...config.headers };
|
|
11400
11400
|
const buildRes = await doFetch(`${base}/build`, {
|
|
11401
11401
|
method: "POST",
|
|
11402
11402
|
headers,
|
|
11403
|
-
body: JSON.stringify({ userAddress: signer.address, calls })
|
|
11403
|
+
body: JSON.stringify(intentIds ? { intentIds } : { userAddress: signer.address, calls })
|
|
11404
11404
|
});
|
|
11405
11405
|
if (!buildRes.ok) {
|
|
11406
11406
|
const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
|
|
@@ -11412,7 +11412,7 @@ async function executeSponsored(config, signer, calls) {
|
|
|
11412
11412
|
const executeRes = await doFetch(`${base}/execute`, {
|
|
11413
11413
|
method: "POST",
|
|
11414
11414
|
headers,
|
|
11415
|
-
body: JSON.stringify({ userAddress: signer.address, typedData, signature, calls })
|
|
11415
|
+
body: JSON.stringify(intentIds ? { intentIds, typedData, signature } : { userAddress: signer.address, typedData, signature, calls })
|
|
11416
11416
|
});
|
|
11417
11417
|
if (!executeRes.ok) {
|
|
11418
11418
|
const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
|
|
@@ -11488,13 +11488,13 @@ function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
|
|
|
11488
11488
|
}
|
|
11489
11489
|
function buildDeployAccountParams(ownerPubkey, salt = 0) {
|
|
11490
11490
|
return {
|
|
11491
|
-
classHash:
|
|
11492
|
-
constructorCalldata:
|
|
11491
|
+
classHash: chunkBILJIXSP_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
|
|
11492
|
+
constructorCalldata: chunkBILJIXSP_cjs.ownerConstructorCalldata(ownerPubkey),
|
|
11493
11493
|
addressSalt: starknet.num.toHex(salt),
|
|
11494
|
-
contractAddress:
|
|
11494
|
+
contractAddress: chunkBILJIXSP_cjs.computeAccountAddress(ownerPubkey, salt)
|
|
11495
11495
|
};
|
|
11496
11496
|
}
|
|
11497
|
-
var norm = (address) =>
|
|
11497
|
+
var norm = (address) => chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address);
|
|
11498
11498
|
var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
|
|
11499
11499
|
function encodeFeltArray(items) {
|
|
11500
11500
|
return [starknet.num.toHex(items.length), ...items];
|
|
@@ -11691,7 +11691,7 @@ var InvalidRecoveryKeyError = class extends Error {
|
|
|
11691
11691
|
var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
|
|
11692
11692
|
function keyPair(privateKey) {
|
|
11693
11693
|
try {
|
|
11694
|
-
return
|
|
11694
|
+
return chunkBILJIXSP_cjs.starkKeyPairFromPrivateKey(privateKey);
|
|
11695
11695
|
} catch {
|
|
11696
11696
|
throw new InvalidRecoveryKeyError();
|
|
11697
11697
|
}
|
|
@@ -11704,7 +11704,7 @@ function parseRecoveryKey(input) {
|
|
|
11704
11704
|
const trimmed = input.trim();
|
|
11705
11705
|
if (!trimmed.startsWith(PREFIX)) {
|
|
11706
11706
|
const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
|
|
11707
|
-
return { walletAddress:
|
|
11707
|
+
return { walletAddress: chunkBILJIXSP_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
|
|
11708
11708
|
}
|
|
11709
11709
|
const parts = trimmed.slice(PREFIX.length).split(":");
|
|
11710
11710
|
const [walletAddress, privateKey] = parts;
|
|
@@ -11726,7 +11726,7 @@ function describeRecoveryAction(escape) {
|
|
|
11726
11726
|
return "none";
|
|
11727
11727
|
}
|
|
11728
11728
|
function normalizeWalletAddress(address) {
|
|
11729
|
-
return
|
|
11729
|
+
return chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address);
|
|
11730
11730
|
}
|
|
11731
11731
|
function isValidStarknetAddress(address) {
|
|
11732
11732
|
try {
|
|
@@ -11771,7 +11771,7 @@ async function estimateSelfFundedFee(provider, address, calls) {
|
|
|
11771
11771
|
return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
|
|
11772
11772
|
}
|
|
11773
11773
|
async function feeTokenBalance(provider, address, unit) {
|
|
11774
|
-
const token =
|
|
11774
|
+
const token = chunkBILJIXSP_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
|
|
11775
11775
|
if (!token) throw new Error(`No fee token for unit ${unit}`);
|
|
11776
11776
|
const [low = "0x0", high = "0x0"] = await provider.callContract({
|
|
11777
11777
|
contractAddress: token.address,
|
|
@@ -11793,14 +11793,15 @@ function sponsoredExecutor(deps) {
|
|
|
11793
11793
|
const fallback = deps.fallback ?? selfFundedExecutor(deps);
|
|
11794
11794
|
return {
|
|
11795
11795
|
async execute(input) {
|
|
11796
|
-
const { userAddress, privateKeyHex, calls } = input;
|
|
11796
|
+
const { userAddress, privateKeyHex, calls, intentIds } = input;
|
|
11797
11797
|
const result = await executeSponsored(
|
|
11798
11798
|
{ proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
|
|
11799
11799
|
{
|
|
11800
11800
|
address: userAddress,
|
|
11801
|
-
signTypedData: async (data) =>
|
|
11801
|
+
signTypedData: async (data) => chunkBILJIXSP_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
|
|
11802
11802
|
},
|
|
11803
|
-
calls
|
|
11803
|
+
calls,
|
|
11804
|
+
intentIds
|
|
11804
11805
|
);
|
|
11805
11806
|
if (result.status === "sponsored") return { transactionHash: result.transactionHash };
|
|
11806
11807
|
const consented = await deps.consent.request({ address: userAddress, calls });
|
|
@@ -11858,7 +11859,7 @@ async function deploySelfFunded(input) {
|
|
|
11858
11859
|
});
|
|
11859
11860
|
const { transaction_hash } = await account.deployAccount({
|
|
11860
11861
|
classHash,
|
|
11861
|
-
constructorCalldata:
|
|
11862
|
+
constructorCalldata: chunkBILJIXSP_cjs.ownerConstructorCalldata(input.ownerPubKey),
|
|
11862
11863
|
addressSalt: 0,
|
|
11863
11864
|
contractAddress: input.ownerAddress
|
|
11864
11865
|
});
|
|
@@ -11926,7 +11927,7 @@ async function completeDeployment(deps, onStep, options = {}) {
|
|
|
11926
11927
|
backendUrl: deps.backendUrl,
|
|
11927
11928
|
walletAddress: address,
|
|
11928
11929
|
signer: {
|
|
11929
|
-
signMessage: async (td) =>
|
|
11930
|
+
signMessage: async (td) => chunkBILJIXSP_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(td, address))
|
|
11930
11931
|
}
|
|
11931
11932
|
});
|
|
11932
11933
|
deps.store.notifyChange();
|
|
@@ -12014,14 +12015,25 @@ function createMediaWallet(config) {
|
|
|
12014
12015
|
unlockCache.set(sealed.address, { promise, timer });
|
|
12015
12016
|
return promise;
|
|
12016
12017
|
};
|
|
12017
|
-
const run = async (sealed, calls, userAddress) => {
|
|
12018
|
+
const run = async (sealed, calls, userAddress, intentIds) => {
|
|
12018
12019
|
const privateKeyHex = await unlockOnce(sealed);
|
|
12019
12020
|
return config.executor.execute({
|
|
12020
12021
|
userAddress: userAddress ?? sealed.address,
|
|
12021
12022
|
privateKeyHex,
|
|
12022
|
-
calls
|
|
12023
|
+
calls,
|
|
12024
|
+
intentIds
|
|
12023
12025
|
});
|
|
12024
12026
|
};
|
|
12027
|
+
const walletIntents = config.walletIntents ?? (async (params) => {
|
|
12028
|
+
if (!config.backendUrl) throw new Error("This wallet has no backend url configured");
|
|
12029
|
+
const created = await new chunkBILJIXSP_cjs.ApiClient(config.backendUrl).createWalletManageIntent(params);
|
|
12030
|
+
return created.data;
|
|
12031
|
+
});
|
|
12032
|
+
const manage = async (sealed, params) => {
|
|
12033
|
+
const intent = await walletIntents(params);
|
|
12034
|
+
const { transactionHash } = await run(sealed, intent.calls, params.owner, [intent.id]);
|
|
12035
|
+
return transactionHash;
|
|
12036
|
+
};
|
|
12025
12037
|
return {
|
|
12026
12038
|
store: config.store,
|
|
12027
12039
|
passkey: config.passkey,
|
|
@@ -12031,10 +12043,10 @@ function createMediaWallet(config) {
|
|
|
12031
12043
|
address: sealed.address,
|
|
12032
12044
|
signTypedData: async (data) => {
|
|
12033
12045
|
const privateKeyHex = await unlockOnce(sealed);
|
|
12034
|
-
return
|
|
12046
|
+
return chunkBILJIXSP_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
|
|
12035
12047
|
},
|
|
12036
|
-
execute: async (calls) => {
|
|
12037
|
-
const { transactionHash } = await run(sealed, calls);
|
|
12048
|
+
execute: async (calls, opts) => {
|
|
12049
|
+
const { transactionHash } = await run(sealed, calls, void 0, opts?.intentIds);
|
|
12038
12050
|
return { txHash: transactionHash };
|
|
12039
12051
|
}
|
|
12040
12052
|
};
|
|
@@ -12049,38 +12061,12 @@ function createMediaWallet(config) {
|
|
|
12049
12061
|
const guid = BigInt(computeOwnerGuid(devicePubkey));
|
|
12050
12062
|
return owners.some((owner) => BigInt(owner.guid) === guid);
|
|
12051
12063
|
},
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
},
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
guardianSealed,
|
|
12059
|
-
[buildTriggerEscapeOwnerCall(targetAddress, newOwnerPubkey)],
|
|
12060
|
-
normalizeWalletAddress(targetAddress)
|
|
12061
|
-
);
|
|
12062
|
-
return transactionHash;
|
|
12063
|
-
},
|
|
12064
|
-
async completeEscapeOwner(guardianSealed, targetAddress) {
|
|
12065
|
-
const { transactionHash } = await run(
|
|
12066
|
-
guardianSealed,
|
|
12067
|
-
[buildCompleteEscapeOwnerCall(targetAddress)],
|
|
12068
|
-
normalizeWalletAddress(targetAddress)
|
|
12069
|
-
);
|
|
12070
|
-
return transactionHash;
|
|
12071
|
-
},
|
|
12072
|
-
async cancelEscape(sealed) {
|
|
12073
|
-
const { transactionHash } = await run(sealed, [buildCancelEscapeCall(sealed.address)]);
|
|
12074
|
-
return transactionHash;
|
|
12075
|
-
},
|
|
12076
|
-
async addDevice(sealed, devicePubkey) {
|
|
12077
|
-
const { transactionHash } = await run(sealed, [buildAddOwnerCall(sealed.address, devicePubkey)]);
|
|
12078
|
-
return transactionHash;
|
|
12079
|
-
},
|
|
12080
|
-
async removeDevice(sealed, ownerGuid) {
|
|
12081
|
-
const { transactionHash } = await run(sealed, [buildRemoveOwnerByGuidCall(sealed.address, ownerGuid)]);
|
|
12082
|
-
return transactionHash;
|
|
12083
|
-
},
|
|
12064
|
+
setFirstGuardian: (sealed, guardianPubkey) => manage(sealed, { owner: sealed.address, action: "set_first_guardian", pubkey: guardianPubkey }),
|
|
12065
|
+
triggerEscapeOwner: (guardianSealed, targetAddress, newOwnerPubkey) => manage(guardianSealed, { owner: normalizeWalletAddress(targetAddress), action: "trigger_escape", newOwnerPubkey }),
|
|
12066
|
+
completeEscapeOwner: (guardianSealed, targetAddress) => manage(guardianSealed, { owner: normalizeWalletAddress(targetAddress), action: "complete_escape" }),
|
|
12067
|
+
cancelEscape: (sealed) => manage(sealed, { owner: sealed.address, action: "cancel_escape" }),
|
|
12068
|
+
addDevice: (sealed, devicePubkey) => manage(sealed, { owner: sealed.address, action: "add_owner", pubkey: devicePubkey }),
|
|
12069
|
+
removeDevice: (sealed, ownerGuid) => manage(sealed, { owner: sealed.address, action: "remove_owner", ownerGuid }),
|
|
12084
12070
|
completeDeployment: (onStep, options) => deployments.run(onStep, options),
|
|
12085
12071
|
isDeploying: () => deployments.isDeploying()
|
|
12086
12072
|
};
|
|
@@ -12098,55 +12084,55 @@ async function claimSessionWallet(api, walletAddress, deps) {
|
|
|
12098
12084
|
|
|
12099
12085
|
Object.defineProperty(exports, "InvalidStarkPrivateKeyError", {
|
|
12100
12086
|
enumerable: true,
|
|
12101
|
-
get: function () { return
|
|
12087
|
+
get: function () { return chunkBILJIXSP_cjs.InvalidStarkPrivateKeyError; }
|
|
12102
12088
|
});
|
|
12103
12089
|
Object.defineProperty(exports, "PasskeyCancelledError", {
|
|
12104
12090
|
enumerable: true,
|
|
12105
|
-
get: function () { return
|
|
12091
|
+
get: function () { return chunkBILJIXSP_cjs.PasskeyCancelledError; }
|
|
12106
12092
|
});
|
|
12107
12093
|
Object.defineProperty(exports, "PasskeyUnsupportedError", {
|
|
12108
12094
|
enumerable: true,
|
|
12109
|
-
get: function () { return
|
|
12095
|
+
get: function () { return chunkBILJIXSP_cjs.PasskeyUnsupportedError; }
|
|
12110
12096
|
});
|
|
12111
12097
|
Object.defineProperty(exports, "UserFacingError", {
|
|
12112
12098
|
enumerable: true,
|
|
12113
|
-
get: function () { return
|
|
12099
|
+
get: function () { return chunkBILJIXSP_cjs.UserFacingError; }
|
|
12114
12100
|
});
|
|
12115
12101
|
Object.defineProperty(exports, "computeAccountAddress", {
|
|
12116
12102
|
enumerable: true,
|
|
12117
|
-
get: function () { return
|
|
12103
|
+
get: function () { return chunkBILJIXSP_cjs.computeAccountAddress; }
|
|
12118
12104
|
});
|
|
12119
12105
|
Object.defineProperty(exports, "createPasskeyOwner", {
|
|
12120
12106
|
enumerable: true,
|
|
12121
|
-
get: function () { return
|
|
12107
|
+
get: function () { return chunkBILJIXSP_cjs.createPasskeyOwner; }
|
|
12122
12108
|
});
|
|
12123
12109
|
Object.defineProperty(exports, "deriveAesKey", {
|
|
12124
12110
|
enumerable: true,
|
|
12125
|
-
get: function () { return
|
|
12111
|
+
get: function () { return chunkBILJIXSP_cjs.deriveAesKey; }
|
|
12126
12112
|
});
|
|
12127
12113
|
Object.defineProperty(exports, "generateStarkKeyPair", {
|
|
12128
12114
|
enumerable: true,
|
|
12129
|
-
get: function () { return
|
|
12115
|
+
get: function () { return chunkBILJIXSP_cjs.generateStarkKeyPair; }
|
|
12130
12116
|
});
|
|
12131
12117
|
Object.defineProperty(exports, "ownerConstructorCalldata", {
|
|
12132
12118
|
enumerable: true,
|
|
12133
|
-
get: function () { return
|
|
12119
|
+
get: function () { return chunkBILJIXSP_cjs.ownerConstructorCalldata; }
|
|
12134
12120
|
});
|
|
12135
12121
|
Object.defineProperty(exports, "sealPrivateKey", {
|
|
12136
12122
|
enumerable: true,
|
|
12137
|
-
get: function () { return
|
|
12123
|
+
get: function () { return chunkBILJIXSP_cjs.sealPrivateKey; }
|
|
12138
12124
|
});
|
|
12139
12125
|
Object.defineProperty(exports, "signWithPrivateKey", {
|
|
12140
12126
|
enumerable: true,
|
|
12141
|
-
get: function () { return
|
|
12127
|
+
get: function () { return chunkBILJIXSP_cjs.signWithPrivateKey; }
|
|
12142
12128
|
});
|
|
12143
12129
|
Object.defineProperty(exports, "starkKeyPairFromPrivateKey", {
|
|
12144
12130
|
enumerable: true,
|
|
12145
|
-
get: function () { return
|
|
12131
|
+
get: function () { return chunkBILJIXSP_cjs.starkKeyPairFromPrivateKey; }
|
|
12146
12132
|
});
|
|
12147
12133
|
Object.defineProperty(exports, "unsealPrivateKey", {
|
|
12148
12134
|
enumerable: true,
|
|
12149
|
-
get: function () { return
|
|
12135
|
+
get: function () { return chunkBILJIXSP_cjs.unsealPrivateKey; }
|
|
12150
12136
|
});
|
|
12151
12137
|
exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
|
|
12152
12138
|
exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
|