Skip to content

Commit

Permalink
fix: update program id of counter program
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Dec 6, 2024
1 parent d57dd62 commit 8c2dcb0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion anchor/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolution = true
skip-lint = false

[programs.localnet]
counter = "DLw5fJNrrBCWoy75aukoDApBZm4MEvaWCvPJoqtLSg1p"
counter = "coUnmi3oBUtwtd9fjeAvSsJssXh5A5xyPbhpewyzRVF"

[registry]
url = "https://api.apr.dev"
Expand Down
2 changes: 1 addition & 1 deletion anchor/programs/counter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use anchor_lang::prelude::*;

declare_id!("DLw5fJNrrBCWoy75aukoDApBZm4MEvaWCvPJoqtLSg1p");
declare_id!("coUnmi3oBUtwtd9fjeAvSsJssXh5A5xyPbhpewyzRVF");

#[program]
pub mod counter {
Expand Down
6 changes: 3 additions & 3 deletions anchor/src/counter-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export { Counter, CounterIDL }
export const COUNTER_PROGRAM_ID = new PublicKey(CounterIDL.address)

// This is a helper function to get the Counter Anchor program.
export function getCounterProgram(provider: AnchorProvider) {
return new Program(CounterIDL as Counter, provider)
export function getCounterProgram(provider: AnchorProvider, address?: PublicKey) {
return new Program({ ...CounterIDL, address: address ? address.toBase58() : CounterIDL.address } as Counter, provider)
}

// This is a helper function to get the program ID for the Counter program depending on the cluster.
Expand All @@ -21,7 +21,7 @@ export function getCounterProgramId(cluster: Cluster) {
case 'devnet':
case 'testnet':
// This is the program ID for the Counter program on devnet and testnet.
return new PublicKey('CounNZdmsQmWh7uVngV9FXW2dZ6zAgbJyYsvBpqbykg')
return new PublicKey('coUnmi3oBUtwtd9fjeAvSsJssXh5A5xyPbhpewyzRVF')
case 'mainnet-beta':
default:
return COUNTER_PROGRAM_ID
Expand Down
2 changes: 1 addition & 1 deletion anchor/target/idl/counter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "DLw5fJNrrBCWoy75aukoDApBZm4MEvaWCvPJoqtLSg1p",
"address": "coUnmi3oBUtwtd9fjeAvSsJssXh5A5xyPbhpewyzRVF",
"metadata": {
"name": "counter",
"version": "0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion anchor/target/types/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* IDL can be found at `target/idl/counter.json`.
*/
export type Counter = {
"address": "DLw5fJNrrBCWoy75aukoDApBZm4MEvaWCvPJoqtLSg1p",
"address": "coUnmi3oBUtwtd9fjeAvSsJssXh5A5xyPbhpewyzRVF",
"metadata": {
"name": "counter",
"version": "0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/counter/counter-data-access.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useCounterProgram() {
const transactionToast = useTransactionToast()
const provider = useAnchorProvider()
const programId = useMemo(() => getCounterProgramId(cluster.network as Cluster), [cluster])
const program = getCounterProgram(provider)
const program = useMemo(() => getCounterProgram(provider, programId), [provider, programId])

const accounts = useQuery({
queryKey: ['counter', 'all', { cluster }],
Expand Down

0 comments on commit 8c2dcb0

Please sign in to comment.