synapsecns / sanguine

Synapse Monorepo
MIT License
37 stars 30 forks source link

Screener can be awaited at the end of the Seen #2965

Open trajan0x opened 3 months ago

trajan0x commented 3 months ago

Minor performance optimization

image

I'd call at top of image then use await pattern

greptile-apps[bot] commented 3 months ago

To optimize performance by awaiting the screener at the end of the screenAddress function, follow these steps:

  1. Open /packages/synapse-interface/utils/screenAddress.ts.
  2. Locate the screenAddress function.
  3. Move the await fetch(url, { method: 'GET' }) call to the top of the function.
  4. Use the await pattern to handle the response and risk detection.
export const screenAddress = async (
  address: Address | string
): Promise<boolean> => {
  const url = `https://screener.omnirpc.io/fe/address/${address}`

  const response = await fetch(url, { method: 'GET' })
  const { risk } = await response.json()

  if (isBlacklisted(address) || risk) {
    const event = createRiskDetectedEvent(address)
    GlobalEventEmitter.dispatchEvent(event)
    return true
  }

  return false
}

References

/agents/contracts/test/attestationharness/generate.go /contrib/screener-api/docs /.github/workflows/scan.yml /agents/contracts/test/snapshotharness/generate.go /packages/solidity-devops/src/SynapseScript.sol /core/go.mod /contrib/screener-api/config/doc.go /packages/solidity-devops/src/SynapseScript06.sol /contrib/screener-api/docs/swagger.yaml /charts/screener/Chart.yaml /contrib/screener-api/README.md /contrib/screener-api/docs/swagger.json /services/rfq/README.md /contrib/screener-api /.github/stale.yml /.yarn/releases/yarn-1.22.19.cjs /.github/PULL_REQUEST_TEMPLATE.md /services/scribe/go.mod /packages/synapse-interface/utils/screenAddress.ts /packages/synapse-interface/patch.ts /contrib/screener-api/go.mod /.github/actions/add-label/action.yml /contrib/screener-api/screener /services/scribe/metadata/metadata.go /packages/synapse-interface/components/ui/SearchResults.tsx

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/synapsecns/sanguine/master) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)