smlxl / evm.codes

Source for evm.codes an Ethereum Virtual Machine Opcodes Interactive Reference
https://evm.codes/
MIT License
727 stars 135 forks source link

feat: add transactions types #285

Open developerfred opened 10 months ago

developerfred commented 10 months ago

ref #270

Captura de Tela 2024-01-04 aฬ€s 20 35 42

new transaction type page

how to test

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Comments Updated (UTC)
evm-codes โœ… Ready (Inspect) Visit Preview ๐Ÿ’ฌ Add feedback Jan 30, 2024 2:09pm
dorlevi commented 10 months ago

@developerfred : it seems like the build is failing on this branch, are you addressing it?

2xic commented 9 months ago

@developerfred do you need any help addressing the feedback / getting the build to complete ?

developerfred commented 9 months ago

@developerfred do you need any help addressing the feedback / getting the build to complete ?

If you could help that would be great too, I can't see the Vercel logs I'm doing typecheck locally

vercel[bot] commented 9 months ago

@developerfred is attempting to deploy a commit to the smlXL Team on Vercel.

A member of the Team first needs to authorize it.

2xic commented 9 months ago

@developerfred do you need any help addressing the feedback / getting the build to complete ?

If you could help that would be great too, I can't see the Vercel logs I'm doing typecheck locally

Sure, attached the command for running the typechecker and how to fix them ๐Ÿ˜„

Let us know if you still have any issues ๐Ÿ™Œ

Finding the build error

If you run yarn run typecheck you should see the following two build errors (if you don't make sure you ran yarn install first)

brage@brages-MBP developerfred-evm.codes % yarn run typecheck

> evm.codes@0.1.0 typecheck
> tsc --pretty

components/KBar/Results.tsx:8:11 - error TS2339: Property 'results' does not exist on type 'ActionGroup[]'.

8   const { results } = useMatches()
            ~~~~~~~

pages/_app.tsx:38:27 - error TS2322: Type '({ id: string; name: string; shortcut: string[]; keywords: string; section: string; subtitle: string; icon: Element; children: { id: string; name: string; shortcut: string[]; keywords: string; section: string; perform: () => void; subtitle: string; icon: Element; }[]; perform?: undefined; } | { ...; } | { ...; })[]' is not assignable to type 'Action[]'.
  Type '{ id: string; name: string; shortcut: string[]; keywords: string; section: string; subtitle: string; icon: Element; children: { id: string; name: string; shortcut: string[]; keywords: string; section: string; perform: () => void; subtitle: string; icon: Element; }[]; perform?: undefined; } | { ...; } | { ...; }' is not assignable to type 'Action'.
    Type '{ id: string; name: string; shortcut: string[]; keywords: string; section: string; subtitle: string; icon: JSX.Element; children: { id: string; name: string; shortcut: string[]; keywords: string; section: string; perform: () => void; subtitle: string; icon: JSX.Element; }[]; perform?: undefined; }' is not assignable to type 'Action'.
      Types of property 'children' are incompatible.
        Type '{ id: string; name: string; shortcut: string[]; keywords: string; section: string; perform: () => void; subtitle: string; icon: Element; }[]' is not assignable to type 'string[]'.
          Type '{ id: string; name: string; shortcut: string[]; keywords: string; section: string; perform: () => void; subtitle: string; icon: JSX.Element; }' is not assignable to type 'string'.

38             <KBarProvider actions={actions}>
                             ~~~~~~~

  node_modules/kbar/lib/types.d.ts:27:5
    27     actions: Action[];
           ~~~~~~~
    The expected type comes from property 'actions' which is declared here on type 'IntrinsicAttributes & KBarProviderProps & { children?: ReactNode; }'

Found 2 errors in 2 files.

Errors  Files
     1  components/KBar/Results.tsx:8
     1  pages/_app.tsx:38

Fixing components/KBar/Results.tsx:8

So first step would be to fix the error in Results.tsx .

Since useMatches() returns an array we want to switch from

https://github.com/smlxl/evm.codes/blob/eb75abc3fe940276e80f0ae64db9a6dbfad13bbc/components/KBar/Results.tsx#L8

to

const results = useMatches() 

Fixing pages/_app.tsx:38

Then fix the issue in pages/_app.tsx where you added a new entry for the theme

(only showing the relevant code entry, but click the link for full context) https://github.com/smlxl/evm.codes/blob/eb75abc3fe940276e80f0ae64db9a6dbfad13bbc/lib/useActions.tsx#L13-L53

The Action type wants just the action id in the children field so you should be able to switch this to

    {
      id: 'theme',
      name: 'Theme',
      shortcut: ['t'],
      keywords: 'change theme',
      section: 'Settings',
      subtitle: 'Change application theme',
      icon: <Icon name="palette-line" />,
      children: [
        'theme-light',
        'theme-dark',
        'theme-system'
      ],
    },
    {
      id: 'theme-light',
      name: 'Light Mode',
      shortcut: ['l'],
      keywords: 'light theme',
      section: 'Settings',
      perform: () => setTheme('light'),
      subtitle: 'Switch to Light Mode',
      icon: <Icon name="sun-line" />,
    },
    {
      id: 'theme-dark',
      name: 'Dark Mode',
      shortcut: ['d'],
      keywords: 'dark theme',
      section: 'Settings',
      perform: () => setTheme('dark'),
      subtitle: 'Switch to Dark Mode',
      icon: <Icon name="moon-line" />,
    },
    {
      id: 'theme-system',
      name: 'System Default',
      shortcut: ['s'],
      keywords: 'system theme',
      section: 'Settings',
      perform: () => setTheme('system'),
      subtitle: 'Use system theme settings',
      icon: <Icon name="settings-2-line" />,
    },
2xic commented 9 months ago

@developerfred do you need any more help here - I'm happy to help so we can get this in a reviewable state ๐Ÿ˜„

charisra commented 9 months ago

@developerfred all you need to for the to fix the build error is replace this:

children: [
  'theme-light',
  'theme-dark',
  'theme-system'
],

with this: children: ['theme-light', 'theme-dark', 'theme-system']

in: ./lib/useActions.tsx

Want to give this a try and see if it builds? I can help more if you face more problems. Would really help if you got your local ESLint properly setup, if you havenโ€™t already.

developerfred commented 9 months ago

Thanks @2xic @dorlevi and @charisra build working now

version working https://evm-codes-fmjmeuoa2-developerfred.vercel.app/transactions

charisra commented 9 months ago

Thanks @2xic @dorlevi and @charisra build working now

version working evm-codes-fmjmeuoa2-developerfred.vercel.app/transactions

It's lot letting me preview so can't tell if it's ok @developerfred . I still see errors building in the latest builds. Can you do a check that your latest commits build successfully?

Also, if you're using VSCode, please ensure you have Prettier installed and enabled. It should auto-fix several code formatting errors.

developerfred commented 9 months ago

@charisra My commits were compiled, I also used prettier, what are the next steps?

charisra commented 9 months ago

@charisra My commits were compiled, I also used prettier, what are the next steps?

Great. I'll review once more, also check the Preview, approve and then you can merge.

charisra commented 9 months ago

So that's what I'm expected to see?

Screenshot 2024-01-31 at 17 58 01

Just the types, there's not any more info on those, it mentions There is no reference doc for this yet. Why not contribute That's the expected behavior?

developerfred commented 9 months ago

There is no reference doc for this yet. Why not contribute That's the expected behavior?

I believe this is a call action to attract contributors

charisra commented 9 months ago

@developerfred I approved the PR. Is there anything pending before you merge?