repo_description: Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿
repo_topics: blockchain crypto dapp graphql hacktoberfest lens-protocol nextjs react social-media tailwindcss turborepo typescript vitest wagmi web3
code: import type { Address } from "viem";
  import type {
    AccountFollowRuleFragment,
    AccountFollowRules,
    GroupRuleFragment,
    GroupRules
  } from "@/indexer/generated";
  import getAnyKeyValue from "./getAnyKeyValue";
  
  interface AssetDetails {
    assetAddress: Address | null;
    assetSymbol: string | null;
    amount: number | null;
  }
  
  const extractPaymentDetails = (
    rules: GroupRuleFragment[] | AccountFollowRuleFragment[]
  ): AssetDetails => {
    for (const rule of rules) {
      if (rule.type === "SIMPLE_PAYMENT") {
        return {
          amount:
            Number(getAnyKeyValue(rule.config, "amount")?.bigDecimal) || null,
          assetAddress:
            getAnyKeyValue(rule.config, "assetContract")?.address || null,
          assetSymbol: getAnyKeyValue(rule.config, "assetSymbol")?.string || null
        };
      }
    }
  
    return { amount: null, assetAddress: null, assetSymbol: null };
  };
  
  export const getSimplePaymentDetails = (
    rules: GroupRules | AccountFollowRules
  ): AssetDetails =>
    extractPaymentDetails(rules.required) || extractPaymentDetails(rules.anyOf);
  