@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.
@@ -12937,13 +12937,33 @@ function createPasskeyOwner(config) {
12937
12937
  }
12938
12938
  };
12939
12939
  }
12940
+
12941
+ // src/utils/token.ts
12942
+ function getTokenBySymbol(symbol) {
12943
+ if (typeof symbol !== "string") return void 0;
12944
+ const upper = symbol.toUpperCase();
12945
+ return SUPPORTED_TOKENS.find((t) => t.symbol === upper);
12946
+ }
12947
+
12948
+ // src/wallet/executors.ts
12940
12949
  function accountFor(provider, address, privateKeyHex) {
12941
12950
  return new starknet.Account({ provider, address, signer: privateKeyHex, cairoVersion: "1" });
12942
12951
  }
12943
12952
  async function estimateSelfFundedFee(provider, address, calls) {
12944
12953
  const account = new starknet.Account({ provider, address, signer: "0x1", cairoVersion: "1" });
12945
12954
  const estimate = await account.estimateInvokeFee(calls);
12946
- return { feeRaw: estimate.overall_fee, unit: estimate.unit };
12955
+ const balanceRaw = await feeTokenBalance(provider, address, estimate.unit).catch(() => null);
12956
+ return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
12957
+ }
12958
+ async function feeTokenBalance(provider, address, unit) {
12959
+ const token = getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
12960
+ if (!token) throw new Error(`No fee token for unit ${unit}`);
12961
+ const [low = "0x0", high = "0x0"] = await provider.callContract({
12962
+ contractAddress: token.address,
12963
+ entrypoint: "balance_of",
12964
+ calldata: [address]
12965
+ });
12966
+ return BigInt(low) + (BigInt(high) << 128n);
12947
12967
  }
12948
12968
  function selfFundedExecutor(deps) {
12949
12969
  return {