@medialane/sdk 0.101.1 → 0.102.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/starknet/index.cjs
CHANGED
|
@@ -11551,6 +11551,58 @@ async function requestSiwsToken({
|
|
|
11551
11551
|
return token;
|
|
11552
11552
|
}
|
|
11553
11553
|
|
|
11554
|
+
// src/starknet/services/executeIntent.ts
|
|
11555
|
+
async function confirmIntentBestEffort(client, intentId, txHash) {
|
|
11556
|
+
await client.api.confirmIntent(intentId, txHash).catch(() => {
|
|
11557
|
+
});
|
|
11558
|
+
}
|
|
11559
|
+
var RECEIPT_RETRY_DELAYS_MS = [0, 3e3, 5e3, 7e3, 1e4];
|
|
11560
|
+
async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECEIPT_RETRY_DELAYS_MS) {
|
|
11561
|
+
for (let attempt = 0; attempt < retryDelaysMs.length; attempt++) {
|
|
11562
|
+
const delay = retryDelaysMs[attempt];
|
|
11563
|
+
if (delay) await new Promise((r) => setTimeout(r, delay));
|
|
11564
|
+
try {
|
|
11565
|
+
const receipt = await provider.getTransactionReceipt(txHash);
|
|
11566
|
+
const status = receipt.execution_status ?? receipt.status;
|
|
11567
|
+
if (status === "REVERTED" || status === "REJECTED") {
|
|
11568
|
+
throw new Error("Transaction was submitted but reverted onchain. Please check your balance and try again.");
|
|
11569
|
+
}
|
|
11570
|
+
if (status) return;
|
|
11571
|
+
} catch (err) {
|
|
11572
|
+
if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
|
|
11573
|
+
}
|
|
11574
|
+
}
|
|
11575
|
+
throw new Error("Verification timed out. Check your account for the transaction status.");
|
|
11576
|
+
}
|
|
11577
|
+
async function executeIntent(provider, signer, client, intent, opts = {}) {
|
|
11578
|
+
let calls;
|
|
11579
|
+
if (intent.requiresSignature) {
|
|
11580
|
+
const signature = await signer.signTypedData(intent.typedData);
|
|
11581
|
+
const signed = await client.api.submitIntentSignature(intent.id, signature);
|
|
11582
|
+
calls = signed.data.calls;
|
|
11583
|
+
} else {
|
|
11584
|
+
calls = intent.calls;
|
|
11585
|
+
}
|
|
11586
|
+
const { txHash } = await signer.execute(calls);
|
|
11587
|
+
await assertTransactionSucceeded(provider, txHash);
|
|
11588
|
+
if (opts.confirm !== false) {
|
|
11589
|
+
await confirmIntentBestEffort(client, intent.id, txHash);
|
|
11590
|
+
}
|
|
11591
|
+
return { txHash };
|
|
11592
|
+
}
|
|
11593
|
+
async function executeIntents(provider, signer, client, intents, opts = {}) {
|
|
11594
|
+
if (intents.some((i) => i.requiresSignature)) {
|
|
11595
|
+
throw new Error("Expected prebuilt intents (requiresSignature=false)");
|
|
11596
|
+
}
|
|
11597
|
+
const calls = intents.flatMap((i) => i.calls);
|
|
11598
|
+
const { txHash } = await signer.execute(calls);
|
|
11599
|
+
await assertTransactionSucceeded(provider, txHash);
|
|
11600
|
+
if (opts.confirm !== false) {
|
|
11601
|
+
await Promise.all(intents.map((i) => confirmIntentBestEffort(client, i.id, txHash)));
|
|
11602
|
+
}
|
|
11603
|
+
return { txHash };
|
|
11604
|
+
}
|
|
11605
|
+
|
|
11554
11606
|
// src/starknet/services/sponsoredExecutor.ts
|
|
11555
11607
|
var SponsoredCallRejectedError = class extends Error {
|
|
11556
11608
|
};
|
|
@@ -11797,6 +11849,7 @@ exports.StarknetVenue = StarknetVenue;
|
|
|
11797
11849
|
exports.TicketService = TicketService;
|
|
11798
11850
|
exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
|
|
11799
11851
|
exports.adminRequestDigest = adminRequestDigest;
|
|
11852
|
+
exports.assertTransactionSucceeded = assertTransactionSucceeded;
|
|
11800
11853
|
exports.build1155CancellationTypedData = build1155CancellationTypedData;
|
|
11801
11854
|
exports.build1155OrderTypedData = build1155OrderTypedData;
|
|
11802
11855
|
exports.buildAdminSessionTypedData = buildAdminSessionTypedData;
|
|
@@ -11815,6 +11868,7 @@ exports.buybackQuoteRaw = buybackQuoteRaw;
|
|
|
11815
11868
|
exports.coinToRaw = toRaw;
|
|
11816
11869
|
exports.computeAccountAddress = computeAccountAddress;
|
|
11817
11870
|
exports.computeOwnerGuid = computeOwnerGuid;
|
|
11871
|
+
exports.confirmIntentBestEffort = confirmIntentBestEffort;
|
|
11818
11872
|
exports.createAdminSessionGrant = createAdminSessionGrant;
|
|
11819
11873
|
exports.decodeEscapeAndStatus = decodeEscapeAndStatus;
|
|
11820
11874
|
exports.decodeGuardiansInfo = decodeGuardiansInfo;
|
|
@@ -11822,6 +11876,8 @@ exports.deriveAesKey = deriveAesKey;
|
|
|
11822
11876
|
exports.deriveOwnerKeyPair = deriveOwnerKeyPair;
|
|
11823
11877
|
exports.encodeAdminHeaders = encodeAdminHeaders;
|
|
11824
11878
|
exports.encodeByteArray = encodeByteArray;
|
|
11879
|
+
exports.executeIntent = executeIntent;
|
|
11880
|
+
exports.executeIntents = executeIntents;
|
|
11825
11881
|
exports.executeSponsored = executeSponsored;
|
|
11826
11882
|
exports.fdvHuman = fdvHuman;
|
|
11827
11883
|
exports.generateStarkKeyPair = generateStarkKeyPair;
|