Skip to content

Commit

Permalink
Foresight unified pid (solana-labs#743)
Browse files Browse the repository at this point in the history
* upgrade foresight-sdk to use latest pid

* use latest foresight sdk

* use latest foresight sdk

* fix foresigh sdk calls (no longer require program id)

* fix types
  • Loading branch information
kevinheavey authored Jun 11, 2022
1 parent 40eaed4 commit a2e46d5
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 43 deletions.
4 changes: 2 additions & 2 deletions components/instructions/programs/foresight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function fetchMarketListId(
}

export const FORESIGHT_INSTRUCTIONS = {
[consts.DEVNET_PID]: {
[consts.PROGRAM_ID]: {
65: {
name: 'Foresight: Init Category',
accounts: findAccounts('initCategory'),
Expand Down Expand Up @@ -215,7 +215,7 @@ export const FORESIGHT_INSTRUCTIONS = {
const marketListId = Buffer.from(marketAccount.marketListId)
const [metadataPubkey] = utils.publicKey.findProgramAddressSync(
[Buffer.from('market_metadata'), marketId, marketListId],
new PublicKey(consts.DEVNET_PID)
consts.PROGRAM_ID_PUBKEY
)
const metadataAccount = await generatedAccounts.MarketMetadata.fetch(
connection,
Expand Down
2 changes: 1 addition & 1 deletion components/instructions/programs/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const PROGRAM_NAMES = {
SysvarC1ock11111111111111111111111111111111: 'Sysvar: Clock',
'4Q6WW2ouZ6V3iaNm56MTd5n2tnTm4C5fiH8miFHnAFHo':
'Mango Voter Stake Registry Program',
[foresightConsts.DEVNET_PID]: 'Foresight Devnet',
[foresightConsts.PROGRAM_ID]: 'Foresight Dex',
...GOVERNANCE_PROGRAM_NAMES,
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@dialectlabs/react-ui": "0.8.2",
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@foresight-tmp/foresight-sdk": "^0.1.41",
"@foresight-tmp/foresight-sdk": "^0.1.44",
"@friktion-labs/friktion-sdk": "^1.1.25",
"@headlessui/react": "^1.5.0",
"@heroicons/react": "^1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import React from 'react'
import { ForesightMakeAddMarketListToCategoryParams } from '@utils/uiTypes/proposalCreationTypes'
import { Governance } from '@solana/spl-governance'
import { ProgramAccount } from '@solana/spl-governance'
import {
governance as foresightGov,
consts,
} from '@foresight-tmp/foresight-sdk'
import { governance as foresightGov } from '@foresight-tmp/foresight-sdk'
import {
commonAssets,
ForesightCategoryIdInput,
ForesightMarketListIdInput,
} from '@utils/Foresight'
import { PublicKey } from '@solana/web3.js'

function MakeAddMarketListToCategoryParams({
index,
Expand All @@ -35,7 +31,6 @@ function MakeAddMarketListToCategoryParams({
const { ix } = await foresightGov.genAddMarketListToCategoryIx(
Buffer.from(form.categoryId.padEnd(20)),
Buffer.from(form.marketListId.padEnd(20)),
new PublicKey(consts.DEVNET_PID),
wallet!.publicKey!
)
return ix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import React from 'react'
import { ForesightHasCategoryId } from '@utils/uiTypes/proposalCreationTypes'
import { Governance } from '@solana/spl-governance'
import { ProgramAccount } from '@solana/spl-governance'
import {
governance as foresightGov,
consts as foresightConsts,
} from '@foresight-tmp/foresight-sdk'
import { governance as foresightGov } from '@foresight-tmp/foresight-sdk'
import { commonAssets, ForesightCategoryIdInput } from '@utils/Foresight'
import { PublicKey } from '@solana/web3.js'

const MakeInitCategoryParams = ({
index,
Expand All @@ -30,7 +26,6 @@ const MakeInitCategoryParams = ({
async function ixCreator(form: ForesightHasCategoryId) {
const { ix } = await foresightGov.genInitCategoryIx(
Buffer.from(form.categoryId.padEnd(20)),
new PublicKey(foresightConsts.DEVNET_PID),
wallet!.publicKey!
)
return ix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import React from 'react'
import { ForesightHasMarketListId } from '@utils/uiTypes/proposalCreationTypes'
import { Governance } from '@solana/spl-governance'
import { ProgramAccount } from '@solana/spl-governance'
import {
governance as foresightGov,
consts,
} from '@foresight-tmp/foresight-sdk'
import { governance as foresightGov } from '@foresight-tmp/foresight-sdk'
import { commonAssets, ForesightMarketListIdInput } from '@utils/Foresight'
import { PublicKey } from '@solana/web3.js'

const MakeInitMarketListParams = ({
index,
Expand All @@ -30,7 +26,6 @@ const MakeInitMarketListParams = ({
async function ixCreator(form: ForesightHasMarketListId) {
const { ix } = await foresightGov.genInitMarketListIx(
Buffer.from(form.marketListId.padEnd(20)),
new PublicKey(consts.DEVNET_PID),
wallet!.publicKey!,
form.governedAccount.extensions.transferAddress!
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ import React from 'react'
import { ForesightHasMarketId } from '@utils/uiTypes/proposalCreationTypes'
import { Governance } from '@solana/spl-governance'
import { ProgramAccount } from '@solana/spl-governance'
import {
governance as foresightGov,
utils,
consts,
} from '@foresight-tmp/foresight-sdk'
import { governance as foresightGov, utils } from '@foresight-tmp/foresight-sdk'
import {
commonAssets,
ForesightMarketIdInput,
ForesightMarketListIdInput,
} from '@utils/Foresight'
import { PublicKey } from '@solana/web3.js'

const MakeInitMarketParams = ({
index,
Expand All @@ -36,7 +31,6 @@ const MakeInitMarketParams = ({
const { ix } = await foresightGov.genInitMarketIx(
Buffer.from(form.marketListId.padEnd(20)),
utils.intToArray(form.marketId, 1),
new PublicKey(consts.DEVNET_PID),
wallet!.publicKey!
)
return ix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import React from 'react'
import { ForesightMakeResolveMarketParams } from '@utils/uiTypes/proposalCreationTypes'
import { Governance } from '@solana/spl-governance'
import { ProgramAccount } from '@solana/spl-governance'
import {
governance as foresightGov,
utils,
consts,
} from '@foresight-tmp/foresight-sdk'
import { governance as foresightGov, utils } from '@foresight-tmp/foresight-sdk'
import {
commonAssets,
ForesightMarketIdInput,
ForesightMarketListIdInput,
ForesightWinnerInput,
} from '@utils/Foresight'
import { PublicKey } from '@solana/web3.js'

const MakeResolveMarketParams = ({
index,
Expand All @@ -37,7 +32,6 @@ const MakeResolveMarketParams = ({
form.winner,
utils.intToArray(form.marketId, 1),
Buffer.from(form.marketListId.padEnd(20)),
new PublicKey(consts.DEVNET_PID),
form.governedAccount.extensions.transferAddress!
)
return ix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
governance as foresightGov,
consts as foresightConsts,
utils,
consts,
} from '@foresight-tmp/foresight-sdk'
import {
commonAssets,
Expand All @@ -16,7 +15,6 @@ import {
ForesightMarketListIdInput,
ForesightMarketMetadataFieldSelect,
} from '@utils/Foresight'
import { PublicKey } from '@solana/web3.js'

export default function MakeSetMarketMetadataParams({
index,
Expand Down Expand Up @@ -49,7 +47,6 @@ export default function MakeSetMarketMetadataParams({
Buffer.from(form.marketListId.padEnd(20)),
form.content,
new field(),
new PublicKey(consts.DEVNET_PID),
wallet!.publicKey!
)
return ix
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,10 @@
lodash.isundefined "^3.0.1"
lodash.uniq "^4.5.0"

"@foresight-tmp/foresight-sdk@^0.1.41":
version "0.1.41"
resolved "https://registry.yarnpkg.com/@foresight-tmp/foresight-sdk/-/foresight-sdk-0.1.41.tgz#ff652a13a683923bdce435f0b6df776ecb844758"
integrity sha512-P9wvA37sBIErQo8XjXUK5KZqElS9gkS4Emw2fQvaRfjbcOaTvIpM1hTeFUi3oDj3Rh+GJ07cnF2RSXfxURcAug==
"@foresight-tmp/foresight-sdk@^0.1.44":
version "0.1.44"
resolved "https://registry.yarnpkg.com/@foresight-tmp/foresight-sdk/-/foresight-sdk-0.1.44.tgz#b7fee32272a9f16fd12e93da1bcbba532bb90183"
integrity sha512-MMBGcfKIwcRrllih2IaOEdnSZuE0fYrNQcSJBAuwxG6ORknKShYHPqp2cRq5NEnNZS90I0AMzhpdDXv+N/302g==
dependencies:
"@project-serum/anchor" "^0.23.0"
"@project-serum/serum" "0.13.64"
Expand Down

0 comments on commit a2e46d5

Please sign in to comment.