oyster icon indicating copy to clipboard operation
oyster copied to clipboard

[governance-sdk] TypeError: (0 , superstruct_1.instance) is not a function

Open jessupjn opened this issue 2 years ago • 5 comments

Our sdk relies on getGovernance from @solana/spl-governance. When the sdk is imported into our react project I am seeing an error thrown in console:

[bpfUpgradeableLoader.ts:12] Uncaught TypeError: (0 , superstruct_3.instance) is not a function
    at Object.../switchboardv2-api/node_modules/@solana/spl-governance/lib/tools/sdk/bpfUpgradeableLoader.js (bpfUpgradeableLoader.ts:12:1)
    at Object.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Object.../switchboardv2-api/node_modules/@solana/spl-governance/lib/governance/version.js (version.ts:10:1)
    at Object.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Object.../switchboardv2-api/node_modules/@solana/spl-governance/lib/governance/index.js (index.ts:11:1)
    at Object.options.factory (react refresh:6:1)

which corresponds to the PublicKeyFromString export from bpfUpgradeableLoader.ts:

export const PublicKeyFromString = coerce(
  instance(PublicKey),
  string(),
  value => new PublicKey(value),
);

Wanted to call this out and see if there was something that I may have missed

jessupjn avatar Apr 11 '22 15:04 jessupjn

Seems to be an issue in webpack - and is reproducible using the wallet-adapter starter repos:

  1. I forked the repo under jessupjn/wallet-adapter
  2. Added @solana/spl-governance dep to package/starter/create-react-app-starter and printed from it.
  3. UI breaks with the same error shown above.

(Note that this is not reproducible when the same modifications are made to packages/starter/material-ui-starter)

jessupjn avatar Apr 12 '22 13:04 jessupjn

See the workaround https://discord.com/channels/910194960941338677/910566058740568094/959827068252741702

It depends on https://github.com/facebook/create-react-app/pull/12021

SebastianBor avatar Apr 12 '22 14:04 SebastianBor

Hey @SebastianBor. I am not in the discord directed by that link. Could you copy and paste the workaround for this issue?

0xodia avatar Apr 19 '22 18:04 0xodia

@SebastianBor Unable to load discord convo. Could you please write workaround here?

badass-commits avatar Apr 22 '22 21:04 badass-commits

image

SebastianBor avatar Apr 23 '22 20:04 SebastianBor