From ab59f11727093ff195b51c8208991a54abc951a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Wed, 19 Oct 2022 14:58:29 +0200 Subject: [PATCH] Clean up config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move constants that are tightly coupled to the implementation of features and unlikely to change or be user configurable out of `config.json`. Decouple configuration from wallet state. Signed-off-by: Rลซdolfs Oลกiล†ลก --- CONTRIBUTING.md | 3 - src/Address.svelte | 14 +-- src/App.svelte | 36 +++--- src/Authorship.svelte | 8 +- src/Comment.svelte | 8 +- src/Connect.svelte | 14 +-- src/Form.svelte | 8 +- src/Header.svelte | 24 ++-- src/Profile.svelte | 23 ++-- src/Review.svelte | 10 +- src/Search.svelte | 19 +-- src/SeedAddress.spec.ts | 69 +++++------ src/SeedDropdown.svelte | 4 +- src/SiweConnect.svelte | 6 +- src/base/faucet/Index.svelte | 18 +-- src/base/faucet/Routes.svelte | 8 +- src/base/faucet/Withdraw.svelte | 6 +- src/base/faucet/lib.ts | 33 +++--- src/base/home/Index.svelte | 4 +- src/base/orgs/Org.ts | 15 ++- src/base/projects/Issue.svelte | 12 +- src/base/projects/Issue/IssueTeaser.svelte | 8 +- src/base/projects/Issues.svelte | 6 +- src/base/projects/Patch.svelte | 8 +- src/base/projects/Patch/PatchTeaser.svelte | 8 +- src/base/projects/Patch/PatchTimeline.svelte | 14 +-- src/base/projects/Patches.svelte | 6 +- src/base/projects/Project.svelte | 14 +-- src/base/projects/ProjectRoute.svelte | 6 +- src/base/projects/Routes.svelte | 12 +- src/base/projects/View.svelte | 28 ++--- src/base/registrations/Index.svelte | 12 +- src/base/registrations/New.svelte | 10 +- src/base/registrations/Routes.svelte | 12 +- src/base/registrations/Submit.svelte | 12 +- src/base/registrations/Update.svelte | 6 +- src/base/registrations/View.svelte | 19 +-- src/base/registrations/registrar.ts | 102 ++++++++-------- src/base/registrations/resolver.ts | 13 ++- src/base/seeds/Routes.svelte | 8 +- src/base/seeds/Seed.ts | 61 +++++----- src/base/seeds/View.svelte | 12 +- src/base/users/User.ts | 13 ++- src/base/vesting/Index.svelte | 16 +-- src/base/vesting/vesting.ts | 25 ++-- src/components/Modal/ConnectWallet.svelte | 8 +- src/components/Modal/SearchResults.svelte | 9 +- src/config.json | 106 +---------------- src/ens/SetName.svelte | 20 ++-- src/ethereum/contractAbis.json | 48 ++++++++ src/ethereum/networks/goerli.json | 16 +++ src/ethereum/networks/homestead.json | 15 +++ src/profile.ts | 26 ++--- src/project.ts | 8 +- src/session.ts | 78 ++++++------- src/siwe.ts | 16 +-- src/utils.test.ts | 7 +- src/utils.ts | 77 +++++++------ src/{config.ts => wallet.ts} | 115 ++++++++++--------- 59 files changed, 652 insertions(+), 670 deletions(-) create mode 100644 src/ethereum/contractAbis.json create mode 100644 src/ethereum/networks/goerli.json create mode 100644 src/ethereum/networks/homestead.json rename src/{config.ts => wallet.ts} (76%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0191fc282..be518ec39 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,9 +6,6 @@ simple guidelines. * Make sure you run `npx eslint .` to check for code formatting problems. You can use the `--fix` flag to automatically fix any issues the linter catches. * Before adding any code dependencies, check with the maintainers if this is okay. -* When using configuration parameters, eg. API URLs, API tokens or contract addresses, - add them to `config.json` and pass the `Config` object to functions that require - access to this configuraiton. * Write properly formatted comments: they should be english sentences, eg: // Return the current UNIX time. diff --git a/src/Address.svelte b/src/Address.svelte index 90517c476..9f4754fa7 100644 --- a/src/Address.svelte +++ b/src/Address.svelte @@ -12,10 +12,10 @@ import { Profile, ProfileType } from "@app/profile"; import Avatar from "@app/Avatar.svelte"; import Badge from "@app/Badge.svelte"; - import type { Config } from "@app/config"; + import type { Wallet } from "@app/wallet"; export let address: string; - export let config: Config; + export let wallet: Wallet; export let resolve = false; export let noBadge = false; export let noAvatar = false; @@ -32,12 +32,12 @@ onMount(async () => { if (!profile) { - identifyAddress(address, config).then( + identifyAddress(address, wallet).then( (t: AddressType) => (addressType = t), ); if (resolve) { - Profile.get(address, ProfileType.Minimal, config).then( + Profile.get(address, ProfileType.Minimal, wallet).then( p => (profile = p), ); } @@ -49,7 +49,7 @@ $: addressLabel = resolve && profile?.name ? compact - ? parseEnsLabel(profile.name, config) + ? parseEnsLabel(profile.name, wallet) : profile.name : checksumAddress; $: checksumAddress = compact @@ -100,7 +100,7 @@ org {/if} {:else if addressType === AddressType.Contract} - + {addressLabel} {#if !noBadge} @@ -110,7 +110,7 @@ {addressLabel} {:else} - + {addressLabel} {/if} diff --git a/src/App.svelte b/src/App.svelte index ac5107881..cb95f620d 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,6 +1,6 @@