Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 committed Nov 12, 2024
1 parent edd5c3c commit fcdb0a6
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'yarn'

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-dep-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'yarn'

- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions components/governance/Vote/VoteResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const VoteResults = ({ proposal, communityMint }: VoteResultsProps) => {
const { t } = useTranslation(['governance'])

const yesVoteCount = fmtTokenAmount(
proposal.getYesVoteCount() as BN,
proposal.getYesVoteCount() as unknown as BN,
communityMint.decimals,
)
const noVoteCount = fmtTokenAmount(
proposal.getNoVoteCount() as BN,
proposal.getNoVoteCount() as unknown as BN,
communityMint.decimals,
)
const totalVoteCount = yesVoteCount + noVoteCount
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"postinstall": "tar -xzC public -f vendor/charting_library.tgz;tar -xzC public -f vendor/datafeeds.tgz"
},
"engines": {
"node": ">=20.x"
"node": ">=20"
},
"dependencies": {
"@blockworks-foundation/mango-feeds": "0.1.7",
Expand All @@ -29,6 +29,8 @@
"@headlessui/react": "1.6.6",
"@heroicons/react": "2.0.18",
"@iarna/toml": "2.2.5",
"@metamask/base-controller": "7.0.2",
"@metamask/phishing-controller": "12.3.0",
"@metaplex-foundation/js": "0.19.4",
"@project-serum/anchor": "0.25.0",
"@pythnetwork/client": "2.21.1",
Expand Down
34 changes: 31 additions & 3 deletions utils/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ import {
JsonMetadata,
} from '@metaplex-foundation/js'
import { safeRace } from '@solana/promises'
import {
PhishingController,
PhishingControllerActions,
} from '@metamask/phishing-controller'
import { ControllerMessenger } from '@metamask/base-controller'

function getRestrictedMessenger() {
const controllerMessenger = new ControllerMessenger<
PhishingControllerActions,
never
>()
const messenger = controllerMessenger.getRestricted({
name: 'PhishingController',
allowedActions: [],
allowedEvents: [],
})
return messenger
}

const phishingControllerMessenger = getRestrictedMessenger()
const phishingController = new PhishingController({
messenger: phishingControllerMessenger,
})

export class TokenAccount {
publicKey!: PublicKey
Expand Down Expand Up @@ -119,9 +142,14 @@ function loadNft(

export async function getNFTsByOwner(owner: PublicKey, connection: Connection) {
const metaplex = new Metaplex(connection)

const rawNfts = await metaplex.nfts().findAllByOwner({
owner,
await phishingController.maybeUpdateState()
const rawNfts = (
await metaplex.nfts().findAllByOwner({
owner,
})
).filter((x) => {
const isUrlSafe = !phishingController.test(x.uri).result
return isUrlSafe
})

const nfts = await Promise.all(
Expand Down
Loading

0 comments on commit fcdb0a6

Please sign in to comment.