@medialane/sdk 0.182.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/dist/index.cjs +55 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +53 -1
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +19 -5
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +1 -1
- package/dist/starknet/index.d.ts +1 -1
- package/dist/starknet/index.js +20 -6
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -8325,7 +8325,7 @@ interface ReceiptProvider {
|
|
|
8325
8325
|
getTransactionReceipt(txHash: string): Promise<unknown>;
|
|
8326
8326
|
}
|
|
8327
8327
|
declare function confirmIntentBestEffort(client: MedialaneClient, intentId: string, txHash: string): Promise<void>;
|
|
8328
|
-
declare function syncTransactionBestEffort(client: MedialaneClient, txHash: string, timeoutMs?: number): Promise<void>;
|
|
8328
|
+
declare function syncTransactionBestEffort(client: MedialaneClient, txHash: string, timeoutMs?: number, retryMs?: number): Promise<void>;
|
|
8329
8329
|
declare function assertTransactionSucceeded(provider: ReceiptProvider, txHash: string, retryDelaysMs?: readonly number[]): Promise<ReceiptLike>;
|
|
8330
8330
|
interface ExecuteIntentOpts {
|
|
8331
8331
|
confirm?: boolean;
|
package/dist/starknet/index.d.ts
CHANGED
|
@@ -8325,7 +8325,7 @@ interface ReceiptProvider {
|
|
|
8325
8325
|
getTransactionReceipt(txHash: string): Promise<unknown>;
|
|
8326
8326
|
}
|
|
8327
8327
|
declare function confirmIntentBestEffort(client: MedialaneClient, intentId: string, txHash: string): Promise<void>;
|
|
8328
|
-
declare function syncTransactionBestEffort(client: MedialaneClient, txHash: string, timeoutMs?: number): Promise<void>;
|
|
8328
|
+
declare function syncTransactionBestEffort(client: MedialaneClient, txHash: string, timeoutMs?: number, retryMs?: number): Promise<void>;
|
|
8329
8329
|
declare function assertTransactionSucceeded(provider: ReceiptProvider, txHash: string, retryDelaysMs?: readonly number[]): Promise<ReceiptLike>;
|
|
8330
8330
|
interface ExecuteIntentOpts {
|
|
8331
8331
|
confirm?: boolean;
|
package/dist/starknet/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeAddress, collectionHref, dropHref, resolveConfig, ApiClient, UserFacingError, getService, STARKNET_MEDIAWALLET_CLASS_HASH, computeAccountAddress, ownerConstructorCalldata, getTokenBySymbol, signWithPrivateKey, stringifyBigInts, SUPPORTED_TOKENS, starkKeyPairFromPrivateKey } from '../chunk-JZXIZGHW.js';
|
|
1
|
+
import { normalizeAddress, collectionHref, dropHref, resolveConfig, ApiClient, UserFacingError, getService, STARKNET_MEDIAWALLET_CLASS_HASH, computeAccountAddress, ownerConstructorCalldata, getTokenBySymbol, signWithPrivateKey, stringifyBigInts, SUPPORTED_TOKENS, MedialaneApiError, starkKeyPairFromPrivateKey } from '../chunk-JZXIZGHW.js';
|
|
2
2
|
export { InvalidStarkPrivateKeyError, PasskeyCancelledError, PasskeyUnsupportedError, UserFacingError, computeAccountAddress, createPasskeyOwner, deriveAesKey, generateStarkKeyPair, ownerConstructorCalldata, sealPrivateKey, signWithPrivateKey, starkKeyPairFromPrivateKey, unsealPrivateKey } from '../chunk-JZXIZGHW.js';
|
|
3
3
|
import { getStarknetCoordinates, getCoordinates } from '../chunk-3ME5YKTW.js';
|
|
4
4
|
import { CallData, hash, cairo, uint256, CairoOption, CairoOptionVariant, RpcProvider, num, ec, validateAndParseAddress, Account, typedData, stark, byteArray, Contract, TypedDataRevision, constants, shortString } from 'starknet';
|
|
@@ -11877,18 +11877,32 @@ async function confirmIntentBestEffort(client, intentId, txHash) {
|
|
|
11877
11877
|
await client.api.confirmIntent(intentId, txHash).catch(() => {
|
|
11878
11878
|
});
|
|
11879
11879
|
}
|
|
11880
|
-
var SYNC_TIMEOUT_MS =
|
|
11881
|
-
|
|
11880
|
+
var SYNC_TIMEOUT_MS = 2e4;
|
|
11881
|
+
var SYNC_RETRY_MS = 2e3;
|
|
11882
|
+
function readableLater(err) {
|
|
11883
|
+
return err instanceof MedialaneApiError && err.status === 404;
|
|
11884
|
+
}
|
|
11885
|
+
async function syncTransactionBestEffort(client, txHash, timeoutMs = SYNC_TIMEOUT_MS, retryMs = SYNC_RETRY_MS) {
|
|
11886
|
+
const deadline = Date.now() + timeoutMs;
|
|
11887
|
+
let stopped = false;
|
|
11882
11888
|
let timer;
|
|
11883
11889
|
const timeout = new Promise((resolve) => {
|
|
11884
11890
|
timer = setTimeout(() => resolve(), timeoutMs);
|
|
11885
11891
|
});
|
|
11886
|
-
const sync =
|
|
11887
|
-
|
|
11888
|
-
|
|
11892
|
+
const sync = (async () => {
|
|
11893
|
+
while (!stopped) {
|
|
11894
|
+
const again = await client.api.syncTransaction(txHash).then(
|
|
11895
|
+
(res) => res.data?.pending === true,
|
|
11896
|
+
readableLater
|
|
11897
|
+
);
|
|
11898
|
+
if (!again || Date.now() + retryMs >= deadline) return;
|
|
11899
|
+
await new Promise((resolve) => setTimeout(resolve, retryMs));
|
|
11900
|
+
}
|
|
11901
|
+
})();
|
|
11889
11902
|
try {
|
|
11890
11903
|
await Promise.race([sync, timeout]);
|
|
11891
11904
|
} finally {
|
|
11905
|
+
stopped = true;
|
|
11892
11906
|
if (timer) clearTimeout(timer);
|
|
11893
11907
|
}
|
|
11894
11908
|
}
|