@medialane/sdk 0.143.0 → 0.144.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.
@@ -8065,6 +8065,8 @@ declare function isDeployed(provider: ReceiptProviderLike, address: string): Pro
8065
8065
  interface SelfFundFeeEstimate {
8066
8066
  feeRaw: bigint;
8067
8067
  unit: string;
8068
+ /** The wallet's balance of the fee token; `null` when it could not be read. */
8069
+ balanceRaw: bigint | null;
8068
8070
  }
8069
8071
  type SelfFundConsentHandler = (feeEstimate: Promise<SelfFundFeeEstimate | null>) => Promise<boolean>;
8070
8072
  interface SelfFundConsent {
@@ -8065,6 +8065,8 @@ declare function isDeployed(provider: ReceiptProviderLike, address: string): Pro
8065
8065
  interface SelfFundFeeEstimate {
8066
8066
  feeRaw: bigint;
8067
8067
  unit: string;
8068
+ /** The wallet's balance of the fee token; `null` when it could not be read. */
8069
+ balanceRaw: bigint | null;
8068
8070
  }
8069
8071
  type SelfFundConsentHandler = (feeEstimate: Promise<SelfFundFeeEstimate | null>) => Promise<boolean>;
8070
8072
  interface SelfFundConsent {
@@ -12935,13 +12935,33 @@ function createPasskeyOwner(config) {
12935
12935
  }
12936
12936
  };
12937
12937
  }
12938
+
12939
+ // src/utils/token.ts
12940
+ function getTokenBySymbol(symbol) {
12941
+ if (typeof symbol !== "string") return void 0;
12942
+ const upper = symbol.toUpperCase();
12943
+ return SUPPORTED_TOKENS.find((t) => t.symbol === upper);
12944
+ }
12945
+
12946
+ // src/wallet/executors.ts
12938
12947
  function accountFor(provider, address, privateKeyHex) {
12939
12948
  return new Account({ provider, address, signer: privateKeyHex, cairoVersion: "1" });
12940
12949
  }
12941
12950
  async function estimateSelfFundedFee(provider, address, calls) {
12942
12951
  const account = new Account({ provider, address, signer: "0x1", cairoVersion: "1" });
12943
12952
  const estimate = await account.estimateInvokeFee(calls);
12944
- return { feeRaw: estimate.overall_fee, unit: estimate.unit };
12953
+ const balanceRaw = await feeTokenBalance(provider, address, estimate.unit).catch(() => null);
12954
+ return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
12955
+ }
12956
+ async function feeTokenBalance(provider, address, unit) {
12957
+ const token = getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
12958
+ if (!token) throw new Error(`No fee token for unit ${unit}`);
12959
+ const [low = "0x0", high = "0x0"] = await provider.callContract({
12960
+ contractAddress: token.address,
12961
+ entrypoint: "balance_of",
12962
+ calldata: [address]
12963
+ });
12964
+ return BigInt(low) + (BigInt(high) << 128n);
12945
12965
  }
12946
12966
  function selfFundedExecutor(deps) {
12947
12967
  return {