Skip to content

Commit

Permalink
Hook up progress for first challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Jan 7, 2025
1 parent c914ef9 commit d00d2ab
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/config/fcl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fcl from '@onflow/fcl';
import config from '@generated/docusaurus.config';
import flowJSON from '../../flow.json';

const flowNetwork = config.customFields?.flowNetwork;
const flowNetwork = (config.customFields?.flowNetwork as string) || 'testnet';

console.log('Dapp running on network:', flowNetwork);

Expand All @@ -25,4 +25,11 @@ export function configureFCL(): void {
});
}

export function getContractAddress(contractName: string): string | null {
return fcl.sansPrefix(
flowJSON.deployments[flowNetwork][contractName] ||
flowJSON.contracts[contractName]?.aliases[flowNetwork],
);
}

configureFCL();
5 changes: 4 additions & 1 deletion src/hooks/use-progress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SocialType } from '../types/gold-star';
import { ChallengeContract } from '../utils/constants';
import { useCurrentUser } from './use-current-user';
import { useProfile } from './use-profile';

Expand Down Expand Up @@ -33,7 +34,9 @@ export function useProgress() {
const challengeItems = [
{
label: 'Complete first challenge',
completed: false,
completed:
profile &&
profile.submissions?.[ChallengeContract.NOOP_CHALLENGE]?.completed,
},
] as ProgressItem[];

Expand Down
4 changes: 4 additions & 0 deletions src/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ export const HIGHLIGHT_LANGUAGES = [
export const DISCORD_URL = 'https://discord.gg/flow';
export const DISCORD_ANNOUNCEMENTS_CHANNEL_ID = '621529603718119424';
export const DISCORD_DEV_UPDATES_CHANNEL_ID = '811693600403357706';

export enum ChallengeContract {
NOOP_CHALLENGE = 'NoopChallenge',
}
11 changes: 11 additions & 0 deletions src/utils/flow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as fcl from '@onflow/fcl';

export function typeIdentifier(
address: string,
contractName: string,
type?: string,
): string {
return `A.${fcl.sansPrefix(address)}.${contractName}${
type ? `.${type}` : ''
}`;
}

0 comments on commit d00d2ab

Please sign in to comment.