Skip to content

Commit

Permalink
Centralize github api client for loading funding.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Brown committed Dec 10, 2024
1 parent c49391b commit 4017139
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@
import { createEventDispatcher } from 'svelte';
import type { StepComponentEvents } from '$lib/components/stepper/types';
import Button from '$lib/components/button/button.svelte';
// import unreachable from '$lib/utils/unreachable';
// import { getChangedTemplate } from '../add-ethereum-address/drips-json-template';
import { Octokit } from '@octokit/rest';
import GitHub from '$lib/utils/github/GitHub';
import type { Writable } from 'svelte/store';
import type { State } from '../../claim-project-flow';
import { loadingFundingInfo } from '../enter-git-url/enter-git-url';
const octokit = new Octokit();
const github = new GitHub(octokit);
const dispatch = createEventDispatcher<StepComponentEvents>();
export let context: Writable<State>;
Expand All @@ -29,7 +22,7 @@
dispatch('await', {
message: 'Gathering project information…',
promise: async () => {
return loadingFundingInfo(context, github);
return loadingFundingInfo(context);
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@
import walletStore from '$lib/stores/wallet/wallet.store';
import ArrowLeft from '$lib/components/icons/ArrowLeft.svelte';
import modal from '$lib/stores/modal';
import { Octokit } from '@octokit/rest';
import GitHub from '$lib/utils/github/GitHub';
import { loadingFundingInfo } from './enter-git-url';
const octokit = new Octokit();
const github = new GitHub(octokit);
export let context: Writable<State>;
export let projectUrl: string | undefined = undefined;
Expand Down Expand Up @@ -219,7 +214,8 @@
$context.projectColor = seededRandomElement(possibleColors, project.account.accountId);
validationState = { type: 'valid' };
loadingFundingInfo(context, github);
// TODO: do before heading to next step?
loadingFundingInfo(context);
} catch (error: unknown) {
// eslint-disable-next-line no-console
console.error(error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import type { State } from '../../claim-project-flow';
import unreachable from '$lib/utils/unreachable';
import { getChangedTemplate } from '../add-ethereum-address/drips-json-template';
import type GitHub from '$lib/utils/github/GitHub';
import GitHub from '$lib/utils/github/GitHub';
import { get, type Writable } from 'svelte/store';
import walletStore from '$lib/stores/wallet/wallet.store';
import { Octokit } from '@octokit/rest';

export async function loadingFundingInfo(context: Writable<State>, github: GitHub): Promise<void> {
const octokit = new Octokit();
const github = new GitHub(octokit);

export async function loadingFundingInfo(context: Writable<State>): Promise<void> {
const $walletStore = get(walletStore);
const address = $walletStore.address ?? '';
const network = $walletStore.network.name
Expand Down

0 comments on commit 4017139

Please sign in to comment.