Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider issue #12

Open
Harold-coder opened this issue Jun 23, 2022 · 1 comment
Open

Provider issue #12

Harold-coder opened this issue Jun 23, 2022 · 1 comment

Comments

@Harold-coder
Copy link

Harold-coder commented Jun 23, 2022

When I try to run the code after episode 9, I get this error:

project_serum_anchor__WEBPACK_IMPORTED_MODULE_3_.Provider is not a constructor
at ReactiveEffect.eval [as fn] (useWorkspace.js?a7cf:15:1)

Here is my useWorkspace.js

import { computed } from 'vue'
import { useAnchorWallet } from 'solana-wallets-vue'
import { Connection, PublicKey } from '@solana/web3.js'
import { Provider, Program } from '@project-serum/anchor'
import idl from '../../../target/idl/solana_twitter.json'

const programID = new PublicKey(idl.metadata.address)
let workspace = null

export const useWorkspace = () => workspace

export const initWorkspace = () => {
    const wallet = useAnchorWallet()
    const connection = new Connection('http://127.0.0.1:8899')
    const provider = computed(() => new Provider(connection, wallet.value))
    const program = computed(() => new Program(idl, programID, provider.value))

    workspace = {
        wallet,
        connection,
        provider,
        program,
    }
}
@enyelsequeira
Copy link

if you are having this issue, update @project-serum/achor. this is always changing so this might be the cause of your issue the version I am using is "@project-serum/anchor": "^0.21.0", and this works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants