@chipi-stack/backend 14.7.0 → 14.9.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/wallets.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { shortString, hash, RpcProvider, ec, Account, num, CairoCustomEnum, CairoOption, CairoOptionVariant, CallData } from 'starknet';
2
- import { WALLET_RPC_ENDPOINTS, SHHH_VERIFIER_CLASS_HASHES, WALLET_CLASS_HASHES, API_ENDPOINTS, ChipiTransactionError, ChipiApiError } from '@chipi-stack/shared';
2
+ import { WALLET_RPC_ENDPOINTS, SHHH_VERIFIER_CLASS_HASHES, WALLET_CLASS_HASHES, API_ENDPOINTS, ChipiTransactionError, ChipiApiError, getWalletTypeFromClassHash } from '@chipi-stack/shared';
3
3
  import CryptoES from 'crypto-es';
4
4
  import { randomBytes } from 'crypto';
5
5
 
@@ -510,7 +510,15 @@ var executePaymasterTransaction = async ({
510
510
  usePasskey ? "encryptKey is required when using passkey. The passkey authentication should have provided the encryptKey." : "encryptKey is required for transaction execution"
511
511
  );
512
512
  }
513
- const walletType = wallet.walletType ?? "READY";
513
+ let walletType = wallet.walletType ?? "READY";
514
+ if (!wallet.walletType) {
515
+ try {
516
+ const resolveProvider = new RpcProvider({ nodeUrl: WALLET_RPC_ENDPOINTS.CHIPI });
517
+ const onChainClassHash = await resolveProvider.getClassHashAt(wallet.publicKey, "latest");
518
+ walletType = getWalletTypeFromClassHash(onChainClassHash) ?? "READY";
519
+ } catch {
520
+ }
521
+ }
514
522
  if (walletType === "SHHH") {
515
523
  const { executeShhhSponsoredRaw: executeShhhSponsoredRaw2 } = await Promise.resolve().then(() => (init_execute_paymaster_raw(), execute_paymaster_raw_exports));
516
524
  const shhhSignerKind = (wallet.signerKind ?? "STARK") || "STARK";