@medialane/sdk 0.166.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 +100 -113
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +20 -7
- package/dist/starknet/index.d.ts +20 -7
- package/dist/starknet/index.js +34 -47
- 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
|
}
|
|
@@ -11239,7 +11239,8 @@ async function fundWithChainTransfer(api, wallet, options) {
|
|
|
11239
11239
|
const pollMs = options.pollMs ?? 3e3;
|
|
11240
11240
|
const maxPolls = options.maxPolls ?? 20;
|
|
11241
11241
|
step("creating");
|
|
11242
|
-
const
|
|
11242
|
+
const params = options.amount !== void 0 ? { amount: options.amount } : { amountUsdc: options.amountUsdc };
|
|
11243
|
+
const { data: intent } = await api.createFunding({ method: "chain-transfer", params });
|
|
11243
11244
|
let txHash;
|
|
11244
11245
|
let transferStarted = false;
|
|
11245
11246
|
try {
|
|
@@ -11299,14 +11300,14 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
|
|
|
11299
11300
|
const receipt = await provider.getTransactionReceipt(txHash);
|
|
11300
11301
|
const status = receipt.execution_status ?? receipt.status;
|
|
11301
11302
|
if (status === "REVERTED" || status === "REJECTED") {
|
|
11302
|
-
throw new
|
|
11303
|
+
throw new chunkBILJIXSP_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
|
|
11303
11304
|
}
|
|
11304
11305
|
if (status) return receipt;
|
|
11305
11306
|
} catch (err) {
|
|
11306
11307
|
if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
|
|
11307
11308
|
}
|
|
11308
11309
|
}
|
|
11309
|
-
throw new
|
|
11310
|
+
throw new chunkBILJIXSP_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
|
|
11310
11311
|
}
|
|
11311
11312
|
async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
11312
11313
|
let calls;
|
|
@@ -11317,7 +11318,7 @@ async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
|
11317
11318
|
} else {
|
|
11318
11319
|
calls = intent.calls;
|
|
11319
11320
|
}
|
|
11320
|
-
const { txHash } = await signer.execute(calls);
|
|
11321
|
+
const { txHash } = await signer.execute(calls, { intentIds: [intent.id] });
|
|
11321
11322
|
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11322
11323
|
await Promise.all([
|
|
11323
11324
|
syncTransactionBestEffort(client, txHash),
|
|
@@ -11330,7 +11331,7 @@ async function executeIntents(provider, signer, client, intents, opts = {}) {
|
|
|
11330
11331
|
throw new Error("Expected prebuilt intents (requiresSignature=false)");
|
|
11331
11332
|
}
|
|
11332
11333
|
const calls = intents.flatMap((i) => i.calls);
|
|
11333
|
-
const { txHash } = await signer.execute(calls);
|
|
11334
|
+
const { txHash } = await signer.execute(calls, { intentIds: intents.map((i) => i.id) });
|
|
11334
11335
|
const receipt = await assertTransactionSucceeded(provider, txHash);
|
|
11335
11336
|
await Promise.all([
|
|
11336
11337
|
syncTransactionBestEffort(client, txHash),
|
|
@@ -11359,14 +11360,14 @@ function u2562(low, high) {
|
|
|
11359
11360
|
return (BigInt(low ?? 0) + (BigInt(high ?? 0) << 128n)).toString();
|
|
11360
11361
|
}
|
|
11361
11362
|
function deployedCollectionFromReceipt(receipt, service) {
|
|
11362
|
-
const factory =
|
|
11363
|
+
const factory = chunkBILJIXSP_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
|
|
11363
11364
|
const { event, address } = DEPLOY_EVENTS[service];
|
|
11364
11365
|
const selector = BigInt(starknet.hash.getSelectorFromName(event));
|
|
11365
11366
|
for (const e of receipt.events ?? []) {
|
|
11366
11367
|
if (factory && !sameFelt(e.from_address, factory)) continue;
|
|
11367
11368
|
if (!sameFelt(e.keys?.[0], selector)) continue;
|
|
11368
11369
|
const value = address(e);
|
|
11369
|
-
if (value) return
|
|
11370
|
+
if (value) return chunkBILJIXSP_cjs.normalizeAddress("STARKNET", value);
|
|
11370
11371
|
}
|
|
11371
11372
|
return null;
|
|
11372
11373
|
}
|
|
@@ -11392,14 +11393,14 @@ async function failureOf(res, fallback) {
|
|
|
11392
11393
|
const body = await res.json().catch(() => null);
|
|
11393
11394
|
return { reason: body?.error || fallback, code: typeof body?.code === "string" ? body.code : void 0 };
|
|
11394
11395
|
}
|
|
11395
|
-
async function executeSponsored(config, signer, calls) {
|
|
11396
|
+
async function executeSponsored(config, signer, calls, intentIds) {
|
|
11396
11397
|
const doFetch = config.fetchImpl ?? fetch;
|
|
11397
11398
|
const base = config.proxyUrl.replace(/\/$/, "");
|
|
11398
|
-
const headers = { "Content-Type": "application/json" };
|
|
11399
|
+
const headers = { "Content-Type": "application/json", ...config.headers };
|
|
11399
11400
|
const buildRes = await doFetch(`${base}/build`, {
|
|
11400
11401
|
method: "POST",
|
|
11401
11402
|
headers,
|
|
11402
|
-
body: JSON.stringify({ userAddress: signer.address, calls })
|
|
11403
|
+
body: JSON.stringify(intentIds ? { intentIds } : { userAddress: signer.address, calls })
|
|
11403
11404
|
});
|
|
11404
11405
|
if (!buildRes.ok) {
|
|
11405
11406
|
const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
|
|
@@ -11411,7 +11412,7 @@ async function executeSponsored(config, signer, calls) {
|
|
|
11411
11412
|
const executeRes = await doFetch(`${base}/execute`, {
|
|
11412
11413
|
method: "POST",
|
|
11413
11414
|
headers,
|
|
11414
|
-
body: JSON.stringify({ userAddress: signer.address, typedData, signature, calls })
|
|
11415
|
+
body: JSON.stringify(intentIds ? { intentIds, typedData, signature } : { userAddress: signer.address, typedData, signature, calls })
|
|
11415
11416
|
});
|
|
11416
11417
|
if (!executeRes.ok) {
|
|
11417
11418
|
const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
|
|
@@ -11487,13 +11488,13 @@ function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
|
|
|
11487
11488
|
}
|
|
11488
11489
|
function buildDeployAccountParams(ownerPubkey, salt = 0) {
|
|
11489
11490
|
return {
|
|
11490
|
-
classHash:
|
|
11491
|
-
constructorCalldata:
|
|
11491
|
+
classHash: chunkBILJIXSP_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
|
|
11492
|
+
constructorCalldata: chunkBILJIXSP_cjs.ownerConstructorCalldata(ownerPubkey),
|
|
11492
11493
|
addressSalt: starknet.num.toHex(salt),
|
|
11493
|
-
contractAddress:
|
|
11494
|
+
contractAddress: chunkBILJIXSP_cjs.computeAccountAddress(ownerPubkey, salt)
|
|
11494
11495
|
};
|
|
11495
11496
|
}
|
|
11496
|
-
var norm = (address) =>
|
|
11497
|
+
var norm = (address) => chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address);
|
|
11497
11498
|
var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
|
|
11498
11499
|
function encodeFeltArray(items) {
|
|
11499
11500
|
return [starknet.num.toHex(items.length), ...items];
|
|
@@ -11690,7 +11691,7 @@ var InvalidRecoveryKeyError = class extends Error {
|
|
|
11690
11691
|
var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
|
|
11691
11692
|
function keyPair(privateKey) {
|
|
11692
11693
|
try {
|
|
11693
|
-
return
|
|
11694
|
+
return chunkBILJIXSP_cjs.starkKeyPairFromPrivateKey(privateKey);
|
|
11694
11695
|
} catch {
|
|
11695
11696
|
throw new InvalidRecoveryKeyError();
|
|
11696
11697
|
}
|
|
@@ -11703,7 +11704,7 @@ function parseRecoveryKey(input) {
|
|
|
11703
11704
|
const trimmed = input.trim();
|
|
11704
11705
|
if (!trimmed.startsWith(PREFIX)) {
|
|
11705
11706
|
const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
|
|
11706
|
-
return { walletAddress:
|
|
11707
|
+
return { walletAddress: chunkBILJIXSP_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
|
|
11707
11708
|
}
|
|
11708
11709
|
const parts = trimmed.slice(PREFIX.length).split(":");
|
|
11709
11710
|
const [walletAddress, privateKey] = parts;
|
|
@@ -11725,7 +11726,7 @@ function describeRecoveryAction(escape) {
|
|
|
11725
11726
|
return "none";
|
|
11726
11727
|
}
|
|
11727
11728
|
function normalizeWalletAddress(address) {
|
|
11728
|
-
return
|
|
11729
|
+
return chunkBILJIXSP_cjs.normalizeAddress("STARKNET", address);
|
|
11729
11730
|
}
|
|
11730
11731
|
function isValidStarknetAddress(address) {
|
|
11731
11732
|
try {
|
|
@@ -11770,7 +11771,7 @@ async function estimateSelfFundedFee(provider, address, calls) {
|
|
|
11770
11771
|
return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
|
|
11771
11772
|
}
|
|
11772
11773
|
async function feeTokenBalance(provider, address, unit) {
|
|
11773
|
-
const token =
|
|
11774
|
+
const token = chunkBILJIXSP_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
|
|
11774
11775
|
if (!token) throw new Error(`No fee token for unit ${unit}`);
|
|
11775
11776
|
const [low = "0x0", high = "0x0"] = await provider.callContract({
|
|
11776
11777
|
contractAddress: token.address,
|
|
@@ -11792,14 +11793,15 @@ function sponsoredExecutor(deps) {
|
|
|
11792
11793
|
const fallback = deps.fallback ?? selfFundedExecutor(deps);
|
|
11793
11794
|
return {
|
|
11794
11795
|
async execute(input) {
|
|
11795
|
-
const { userAddress, privateKeyHex, calls } = input;
|
|
11796
|
+
const { userAddress, privateKeyHex, calls, intentIds } = input;
|
|
11796
11797
|
const result = await executeSponsored(
|
|
11797
11798
|
{ proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
|
|
11798
11799
|
{
|
|
11799
11800
|
address: userAddress,
|
|
11800
|
-
signTypedData: async (data) =>
|
|
11801
|
+
signTypedData: async (data) => chunkBILJIXSP_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
|
|
11801
11802
|
},
|
|
11802
|
-
calls
|
|
11803
|
+
calls,
|
|
11804
|
+
intentIds
|
|
11803
11805
|
);
|
|
11804
11806
|
if (result.status === "sponsored") return { transactionHash: result.transactionHash };
|
|
11805
11807
|
const consented = await deps.consent.request({ address: userAddress, calls });
|
|
@@ -11857,7 +11859,7 @@ async function deploySelfFunded(input) {
|
|
|
11857
11859
|
});
|
|
11858
11860
|
const { transaction_hash } = await account.deployAccount({
|
|
11859
11861
|
classHash,
|
|
11860
|
-
constructorCalldata:
|
|
11862
|
+
constructorCalldata: chunkBILJIXSP_cjs.ownerConstructorCalldata(input.ownerPubKey),
|
|
11861
11863
|
addressSalt: 0,
|
|
11862
11864
|
contractAddress: input.ownerAddress
|
|
11863
11865
|
});
|
|
@@ -11925,7 +11927,7 @@ async function completeDeployment(deps, onStep, options = {}) {
|
|
|
11925
11927
|
backendUrl: deps.backendUrl,
|
|
11926
11928
|
walletAddress: address,
|
|
11927
11929
|
signer: {
|
|
11928
|
-
signMessage: async (td) =>
|
|
11930
|
+
signMessage: async (td) => chunkBILJIXSP_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(td, address))
|
|
11929
11931
|
}
|
|
11930
11932
|
});
|
|
11931
11933
|
deps.store.notifyChange();
|
|
@@ -12013,14 +12015,25 @@ function createMediaWallet(config) {
|
|
|
12013
12015
|
unlockCache.set(sealed.address, { promise, timer });
|
|
12014
12016
|
return promise;
|
|
12015
12017
|
};
|
|
12016
|
-
const run = async (sealed, calls, userAddress) => {
|
|
12018
|
+
const run = async (sealed, calls, userAddress, intentIds) => {
|
|
12017
12019
|
const privateKeyHex = await unlockOnce(sealed);
|
|
12018
12020
|
return config.executor.execute({
|
|
12019
12021
|
userAddress: userAddress ?? sealed.address,
|
|
12020
12022
|
privateKeyHex,
|
|
12021
|
-
calls
|
|
12023
|
+
calls,
|
|
12024
|
+
intentIds
|
|
12022
12025
|
});
|
|
12023
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
|
+
};
|
|
12024
12037
|
return {
|
|
12025
12038
|
store: config.store,
|
|
12026
12039
|
passkey: config.passkey,
|
|
@@ -12030,10 +12043,10 @@ function createMediaWallet(config) {
|
|
|
12030
12043
|
address: sealed.address,
|
|
12031
12044
|
signTypedData: async (data) => {
|
|
12032
12045
|
const privateKeyHex = await unlockOnce(sealed);
|
|
12033
|
-
return
|
|
12046
|
+
return chunkBILJIXSP_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
|
|
12034
12047
|
},
|
|
12035
|
-
execute: async (calls) => {
|
|
12036
|
-
const { transactionHash } = await run(sealed, calls);
|
|
12048
|
+
execute: async (calls, opts) => {
|
|
12049
|
+
const { transactionHash } = await run(sealed, calls, void 0, opts?.intentIds);
|
|
12037
12050
|
return { txHash: transactionHash };
|
|
12038
12051
|
}
|
|
12039
12052
|
};
|
|
@@ -12048,38 +12061,12 @@ function createMediaWallet(config) {
|
|
|
12048
12061
|
const guid = BigInt(computeOwnerGuid(devicePubkey));
|
|
12049
12062
|
return owners.some((owner) => BigInt(owner.guid) === guid);
|
|
12050
12063
|
},
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
},
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
guardianSealed,
|
|
12058
|
-
[buildTriggerEscapeOwnerCall(targetAddress, newOwnerPubkey)],
|
|
12059
|
-
normalizeWalletAddress(targetAddress)
|
|
12060
|
-
);
|
|
12061
|
-
return transactionHash;
|
|
12062
|
-
},
|
|
12063
|
-
async completeEscapeOwner(guardianSealed, targetAddress) {
|
|
12064
|
-
const { transactionHash } = await run(
|
|
12065
|
-
guardianSealed,
|
|
12066
|
-
[buildCompleteEscapeOwnerCall(targetAddress)],
|
|
12067
|
-
normalizeWalletAddress(targetAddress)
|
|
12068
|
-
);
|
|
12069
|
-
return transactionHash;
|
|
12070
|
-
},
|
|
12071
|
-
async cancelEscape(sealed) {
|
|
12072
|
-
const { transactionHash } = await run(sealed, [buildCancelEscapeCall(sealed.address)]);
|
|
12073
|
-
return transactionHash;
|
|
12074
|
-
},
|
|
12075
|
-
async addDevice(sealed, devicePubkey) {
|
|
12076
|
-
const { transactionHash } = await run(sealed, [buildAddOwnerCall(sealed.address, devicePubkey)]);
|
|
12077
|
-
return transactionHash;
|
|
12078
|
-
},
|
|
12079
|
-
async removeDevice(sealed, ownerGuid) {
|
|
12080
|
-
const { transactionHash } = await run(sealed, [buildRemoveOwnerByGuidCall(sealed.address, ownerGuid)]);
|
|
12081
|
-
return transactionHash;
|
|
12082
|
-
},
|
|
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 }),
|
|
12083
12070
|
completeDeployment: (onStep, options) => deployments.run(onStep, options),
|
|
12084
12071
|
isDeploying: () => deployments.isDeploying()
|
|
12085
12072
|
};
|
|
@@ -12097,55 +12084,55 @@ async function claimSessionWallet(api, walletAddress, deps) {
|
|
|
12097
12084
|
|
|
12098
12085
|
Object.defineProperty(exports, "InvalidStarkPrivateKeyError", {
|
|
12099
12086
|
enumerable: true,
|
|
12100
|
-
get: function () { return
|
|
12087
|
+
get: function () { return chunkBILJIXSP_cjs.InvalidStarkPrivateKeyError; }
|
|
12101
12088
|
});
|
|
12102
12089
|
Object.defineProperty(exports, "PasskeyCancelledError", {
|
|
12103
12090
|
enumerable: true,
|
|
12104
|
-
get: function () { return
|
|
12091
|
+
get: function () { return chunkBILJIXSP_cjs.PasskeyCancelledError; }
|
|
12105
12092
|
});
|
|
12106
12093
|
Object.defineProperty(exports, "PasskeyUnsupportedError", {
|
|
12107
12094
|
enumerable: true,
|
|
12108
|
-
get: function () { return
|
|
12095
|
+
get: function () { return chunkBILJIXSP_cjs.PasskeyUnsupportedError; }
|
|
12109
12096
|
});
|
|
12110
12097
|
Object.defineProperty(exports, "UserFacingError", {
|
|
12111
12098
|
enumerable: true,
|
|
12112
|
-
get: function () { return
|
|
12099
|
+
get: function () { return chunkBILJIXSP_cjs.UserFacingError; }
|
|
12113
12100
|
});
|
|
12114
12101
|
Object.defineProperty(exports, "computeAccountAddress", {
|
|
12115
12102
|
enumerable: true,
|
|
12116
|
-
get: function () { return
|
|
12103
|
+
get: function () { return chunkBILJIXSP_cjs.computeAccountAddress; }
|
|
12117
12104
|
});
|
|
12118
12105
|
Object.defineProperty(exports, "createPasskeyOwner", {
|
|
12119
12106
|
enumerable: true,
|
|
12120
|
-
get: function () { return
|
|
12107
|
+
get: function () { return chunkBILJIXSP_cjs.createPasskeyOwner; }
|
|
12121
12108
|
});
|
|
12122
12109
|
Object.defineProperty(exports, "deriveAesKey", {
|
|
12123
12110
|
enumerable: true,
|
|
12124
|
-
get: function () { return
|
|
12111
|
+
get: function () { return chunkBILJIXSP_cjs.deriveAesKey; }
|
|
12125
12112
|
});
|
|
12126
12113
|
Object.defineProperty(exports, "generateStarkKeyPair", {
|
|
12127
12114
|
enumerable: true,
|
|
12128
|
-
get: function () { return
|
|
12115
|
+
get: function () { return chunkBILJIXSP_cjs.generateStarkKeyPair; }
|
|
12129
12116
|
});
|
|
12130
12117
|
Object.defineProperty(exports, "ownerConstructorCalldata", {
|
|
12131
12118
|
enumerable: true,
|
|
12132
|
-
get: function () { return
|
|
12119
|
+
get: function () { return chunkBILJIXSP_cjs.ownerConstructorCalldata; }
|
|
12133
12120
|
});
|
|
12134
12121
|
Object.defineProperty(exports, "sealPrivateKey", {
|
|
12135
12122
|
enumerable: true,
|
|
12136
|
-
get: function () { return
|
|
12123
|
+
get: function () { return chunkBILJIXSP_cjs.sealPrivateKey; }
|
|
12137
12124
|
});
|
|
12138
12125
|
Object.defineProperty(exports, "signWithPrivateKey", {
|
|
12139
12126
|
enumerable: true,
|
|
12140
|
-
get: function () { return
|
|
12127
|
+
get: function () { return chunkBILJIXSP_cjs.signWithPrivateKey; }
|
|
12141
12128
|
});
|
|
12142
12129
|
Object.defineProperty(exports, "starkKeyPairFromPrivateKey", {
|
|
12143
12130
|
enumerable: true,
|
|
12144
|
-
get: function () { return
|
|
12131
|
+
get: function () { return chunkBILJIXSP_cjs.starkKeyPairFromPrivateKey; }
|
|
12145
12132
|
});
|
|
12146
12133
|
Object.defineProperty(exports, "unsealPrivateKey", {
|
|
12147
12134
|
enumerable: true,
|
|
12148
|
-
get: function () { return
|
|
12135
|
+
get: function () { return chunkBILJIXSP_cjs.unsealPrivateKey; }
|
|
12149
12136
|
});
|
|
12150
12137
|
exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
|
|
12151
12138
|
exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
|