To set this up for development with Switchboard, the first step is to get this to work.
- Install Anchor if you don't currently have it installed.
- navigate to the
switchboard_v2
directory withinswitchboard-core
and runanchor test
. This will build switchboardv2 and run the addin-tests.ts script, which will set up a realm, governance, queue, oracles, permissions, and proposal. - you will need to make sure the pubkeys of the governance program and switchboard program throughout the codebase are pointed to your local pubkeys of those programs:
- you can determine the pubkeys of the localnet switchboardv2 and governance programs by navigating to
switchboard-core/switchboard_v2/target/deploy
and runningsolana-keygen pubkey switchboard_v2-keypair.json
andsolana-keygen pubkey spl_governance-keypair.json
respectively - You'll need to set the
declare_id!(...)
in Switchboardv2'slib.rs
to point at your localnet switchboard program's pubkey, and you'll need to set Switchboardv2'slib.rs
GOVERNANCE_PID
variable to the spl_governance pubkey. - you'll also need to ensure that
sbv2.ts
variable GOVERNANCE_PID points at the correct pubkey for your localnet governance program - when you want to run the UI, start a local validator by running
solana-test-validator
. This will created a directory calledtest-ledger
in the location you run the command. - run the addin test suite,
anchor test
- start the governance-ui by running
yarn dev
- most of the work is in
hooks/useRealm.ts
andhooks/useVotingPlugins.ts
in the governance-ui. The UI work is incomponents/TokenBalance
Whenever you change dependencies (adding, removing, or updating, either in package.json or yarn.lock), there are various files that must be kept up-to-date.
yarn.lock
:
- Run yarn again after your changes to ensure yarn.lock has been properly updated.
- Run
yarn deduplicate
to remove duplicate dependencies from the lockfile.
The allow-scripts
configuration in package.json
:
- Run
yarn allow-scripts auto
to update theallow-scripts
configuration automatically. This config determines whether the package's install/postinstall scripts are allowed to run. - Alternatively update the
allow-scripts
section manually. - Review each new package to determine whether the install script needs to run or not, testing if necessary.
- Use
npx can-i-ignore-scripts
to help assessing whether scripts are needed
Bootstrap a developer-friendly NextJS app configured with:
- Typescript
- Linting with ESLint
- Formatting with Prettier
- Linting, typechecking and formatting on by default using
husky
for commit hooks - Testing with Jest and
react-testing-library
Deploy the example using Vercel:
Execute create-next-app
with npm or Yarn to bootstrap the example:
npx create-next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app
# or
yarn create next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app
Deploy it to the cloud with Vercel (Documentation).