mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Remove deprecated org parts
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -1,225 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { navigate } from "svelte-routing";
|
||||
import Modal from "@app/Modal.svelte";
|
||||
import Error from "@app/Error.svelte";
|
||||
import type { Err } from "@app/error";
|
||||
import { Org } from "@app/base/orgs/Org";
|
||||
import type { Config } from "@app/config";
|
||||
import Loading from "@app/Loading.svelte";
|
||||
import Options from "@app/Options.svelte";
|
||||
import Address from "@app/Address.svelte";
|
||||
import Button from "@app/Button.svelte";
|
||||
|
||||
export let config: Config;
|
||||
export let owner: string;
|
||||
|
||||
enum State {
|
||||
Idle,
|
||||
Signing,
|
||||
Pending,
|
||||
Success,
|
||||
}
|
||||
|
||||
enum Governance {
|
||||
Existing = "existing",
|
||||
Quorum = "quorum",
|
||||
}
|
||||
|
||||
const orgTypes = [
|
||||
{
|
||||
label: "Multi-signature",
|
||||
description: [
|
||||
"Creates an org with a multi-signature contract as its owner, and the specified account as the first member.",
|
||||
"A [Gnosis Safe](https://gnosis-safe.io) will be deployed for your org.",
|
||||
"Transactions such as anchoring have to be approved by a quorum of signers.",
|
||||
],
|
||||
value: Governance.Quorum,
|
||||
},
|
||||
{
|
||||
label: "Existing owner",
|
||||
description: [
|
||||
`Creates an org with the specified account as the sole owner.`,
|
||||
`Org transactions such as anchoring are signed and executed from that account.`,
|
||||
`This option allows for using an existing contract or EOA as the owner of the org.`,
|
||||
],
|
||||
value: Governance.Existing,
|
||||
},
|
||||
];
|
||||
|
||||
let state = State.Idle;
|
||||
let error: Err | null = null;
|
||||
let org: Org | null = null;
|
||||
let governance = Governance.Quorum;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
const createOrg = async () => {
|
||||
state = State.Signing;
|
||||
|
||||
try {
|
||||
const tx =
|
||||
governance === Governance.Quorum
|
||||
? await Org.createMultiSig([owner], 1, config)
|
||||
: await Org.create(owner, config);
|
||||
|
||||
state = State.Pending;
|
||||
|
||||
const receipt = await tx.wait();
|
||||
org = Org.fromReceipt(receipt);
|
||||
state = State.Success;
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
|
||||
state = State.Idle;
|
||||
error = e;
|
||||
}
|
||||
};
|
||||
|
||||
const onGovernanceChanged = (event: { detail: string }) => {
|
||||
switch (event.detail) {
|
||||
case "existing":
|
||||
governance = Governance.Existing;
|
||||
break;
|
||||
case "quorum":
|
||||
governance = Governance.Quorum;
|
||||
break;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.fields {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 7fr;
|
||||
grid-gap: 0.5rem 2rem;
|
||||
}
|
||||
.fields > span {
|
||||
justify-self: start;
|
||||
align-self: center;
|
||||
height: 2rem;
|
||||
line-height: 2rem;
|
||||
}
|
||||
.configuration {
|
||||
max-width: 35rem;
|
||||
text-align: left;
|
||||
}
|
||||
.governance {
|
||||
background-color: var(--color-secondary-background);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 1rem 1rem 0rem 1rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
label[for="address"] {
|
||||
margin-left: 1.5rem;
|
||||
font-size: var(--font-size-tiny);
|
||||
color: var(--color-secondary);
|
||||
}
|
||||
input[name="address"] {
|
||||
margin: 0.5rem 0 0 0;
|
||||
width: 100%;
|
||||
}
|
||||
.notice {
|
||||
font-size: var(--font-size-small);
|
||||
border-radius: var(--border-radius);
|
||||
color: var(--color-yellow);
|
||||
background-color: var(--color-yellow-background);
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if error}
|
||||
<Error {error} floating on:close />
|
||||
{:else if org}
|
||||
<!-- Org created -->
|
||||
<Modal floating on:close>
|
||||
<span slot="title">🎉</span>
|
||||
|
||||
<span slot="subtitle">
|
||||
<span class="txt-bold">Your org was successfully created.</span>
|
||||
</span>
|
||||
|
||||
<span slot="body">
|
||||
<div class="fields">
|
||||
<span class="label">Address</span>
|
||||
<span><Address address={org.address} {config} /></span>
|
||||
|
||||
<span class="label">Owner</span>
|
||||
<span><Address resolve address={org.owner} {config} /></span>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
<span slot="actions">
|
||||
<Button
|
||||
variant="foreground"
|
||||
on:click={() => navigate(`/${org?.address}`)}>
|
||||
Done
|
||||
</Button>
|
||||
</span>
|
||||
</Modal>
|
||||
{:else}
|
||||
<!-- Org creation flow -->
|
||||
<Modal floating on:close center>
|
||||
<span slot="title">
|
||||
<div>🎪</div>
|
||||
<span>Create an Org</span>
|
||||
</span>
|
||||
|
||||
<span slot="subtitle">
|
||||
{#if state === State.Idle}
|
||||
<div class="highlight">Select how you'd like to create your org</div>
|
||||
{:else if state === State.Signing}
|
||||
<div class="highlight">
|
||||
Please confirm the transaction in your wallet.
|
||||
</div>
|
||||
{:else if state === State.Pending}
|
||||
<div class="highlight">Waiting for transaction to be processed...</div>
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
<span slot="body">
|
||||
{#if state === State.Idle}
|
||||
<div class="configuration">
|
||||
<div class="notice">
|
||||
<span class="txt-bold">Notice:</span>
|
||||
Orgs V1 are being deprecated. It is recommended not to create new orgs
|
||||
at this point.
|
||||
</div>
|
||||
|
||||
<div class="governance">
|
||||
<Options
|
||||
name="governance"
|
||||
disabled={state !== State.Idle}
|
||||
selected={governance}
|
||||
options={orgTypes}
|
||||
on:changed={onGovernanceChanged} />
|
||||
</div>
|
||||
|
||||
<label class="input" for="address">Ethereum account address</label>
|
||||
<input
|
||||
name="address"
|
||||
class="small"
|
||||
type="text"
|
||||
maxlength="42"
|
||||
bind:value={owner} />
|
||||
</div>
|
||||
{:else}
|
||||
<Loading center small />
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
<span slot="actions">
|
||||
{#if state === State.Idle}
|
||||
<Button
|
||||
on:click={createOrg}
|
||||
variant="primary"
|
||||
waiting={[State.Signing, State.Pending].includes(state)}
|
||||
disabled={state !== State.Idle}>
|
||||
Create
|
||||
</Button>
|
||||
|
||||
<Button on:click={() => dispatch("close")} variant="text">Close</Button>
|
||||
{/if}
|
||||
</span>
|
||||
</Modal>
|
||||
{/if}
|
||||
@@ -1,122 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { SvelteComponent } from "svelte";
|
||||
import { session } from "@app/session";
|
||||
import Create from "@app/base/orgs/Create.svelte";
|
||||
import { Org } from "@app/base/orgs/Org";
|
||||
import type { Config } from "@app/config";
|
||||
import Loading from "@app/Loading.svelte";
|
||||
import Message from "@app/Message.svelte";
|
||||
import Cards from "@app/Cards.svelte";
|
||||
import { setOpenGraphMetaTag } from "@app/utils";
|
||||
import Button from "@app/Button.svelte";
|
||||
|
||||
export let config: Config;
|
||||
|
||||
setOpenGraphMetaTag([
|
||||
{ prop: "og:title", content: "Radicle Orgs" },
|
||||
{ prop: "og:description", content: "Orgs of the Radicle Network" },
|
||||
{ prop: "og:url", content: window.location.href },
|
||||
]);
|
||||
|
||||
const onCreate = () => (modal = Create);
|
||||
let modal: typeof SvelteComponent | null = null;
|
||||
|
||||
$: account = $session && $session.address;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
main {
|
||||
width: 100%;
|
||||
padding: 3rem;
|
||||
display: block;
|
||||
align-items: space-between;
|
||||
justify-content: space-between;
|
||||
}
|
||||
main header {
|
||||
color: var(--color-secondary);
|
||||
font-size: var(--font-size-medium);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 1rem 0;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.my-orgs {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
.orgs-empty {
|
||||
padding: 2rem 0 1rem 0;
|
||||
}
|
||||
|
||||
.loading {
|
||||
padding: 2rem 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>Radicle: Orgs</title>
|
||||
</svelte:head>
|
||||
|
||||
<main>
|
||||
{#if account}
|
||||
<div class="my-orgs">
|
||||
<header>
|
||||
<span>
|
||||
My <span class="txt-bold">Orgs</span>
|
||||
</span>
|
||||
<Button variant="secondary" on:click={onCreate} disabled={!account}>
|
||||
Create
|
||||
</Button>
|
||||
</header>
|
||||
|
||||
{#await Org.getOrgsByMember(account, config)}
|
||||
<div class="loading">
|
||||
<Loading center />
|
||||
</div>
|
||||
{:then orgs}
|
||||
<Cards {config} {orgs}>
|
||||
<div class="orgs-empty txt-missing">
|
||||
Orgs you are a member of show up here.
|
||||
</div>
|
||||
</Cards>
|
||||
{:catch}
|
||||
<div>
|
||||
<Message error>
|
||||
<span class="txt-bold">Error:</span>
|
||||
failed to load orgs.
|
||||
</Message>
|
||||
</div>
|
||||
{/await}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<header>
|
||||
<span>
|
||||
<span class="txt-bold">Orgs</span>
|
||||
of the Radicle network
|
||||
</span>
|
||||
</header>
|
||||
|
||||
{#await Org.getAll(config)}
|
||||
<div class="loading">
|
||||
<Loading center />
|
||||
</div>
|
||||
{:then orgs}
|
||||
<Cards {config} {orgs}>
|
||||
<div class="orgs-empty">There are no orgs.</div>
|
||||
</Cards>
|
||||
{:catch}
|
||||
<div>
|
||||
<Message error>
|
||||
<span class="txt-bold">Error:</span>
|
||||
failed to load orgs.
|
||||
</Message>
|
||||
</div>
|
||||
{/await}
|
||||
</main>
|
||||
|
||||
<svelte:component
|
||||
this={modal}
|
||||
owner={account}
|
||||
{config}
|
||||
on:close={() => (modal = null)} />
|
||||
@@ -1,37 +1,12 @@
|
||||
import * as ethers from "ethers";
|
||||
import type { TransactionResponse } from "@ethersproject/providers";
|
||||
import type { ContractReceipt } from "@ethersproject/contracts";
|
||||
import { OperationType } from "@gnosis.pm/safe-core-sdk-types";
|
||||
|
||||
import { assert } from "@app/error";
|
||||
import * as utils from "@app/utils";
|
||||
import * as cache from "@app/cache";
|
||||
import type { SafeMultisigTransactionListResponse } from "@gnosis.pm/safe-service-client";
|
||||
import type SafeServiceClient from "@gnosis.pm/safe-service-client";
|
||||
import type { Safe } from "@app/utils";
|
||||
import type { Config } from "@app/config";
|
||||
import type { PendingAnchor, Anchor } from "@app/project";
|
||||
|
||||
const GetProjects = `
|
||||
query GetProjects($org: ID!) {
|
||||
projects(where: { org: $org }) {
|
||||
anchor {
|
||||
objectId
|
||||
multihash
|
||||
timestamp
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const GetOrgs = `
|
||||
query GetOrgs {
|
||||
orgs {
|
||||
id
|
||||
owner
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const GetSafesByOwners = `
|
||||
query GetSafesByOwners($owners: [String!]!) {
|
||||
@@ -198,119 +173,6 @@ export class Org {
|
||||
return members.includes(address.toLowerCase());
|
||||
}
|
||||
|
||||
async getProjects(config: Config): Promise<Anchor[]> {
|
||||
const result = await utils.querySubgraph(
|
||||
config.orgs.subgraph,
|
||||
GetProjects,
|
||||
{ org: this.address },
|
||||
);
|
||||
const projects: Anchor[] = [];
|
||||
|
||||
for (const p of result.projects) {
|
||||
try {
|
||||
const proj: Anchor = {
|
||||
confirmed: true,
|
||||
id: utils.formatRadicleId(ethers.utils.arrayify(p.anchor.objectId)),
|
||||
anchor: {
|
||||
stateHash: utils.formatProjectHash(
|
||||
ethers.utils.arrayify(p.anchor.multihash),
|
||||
),
|
||||
},
|
||||
};
|
||||
projects.push(proj);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
return projects;
|
||||
}
|
||||
|
||||
async getPendingProjects(config: Config): Promise<PendingAnchor[]> {
|
||||
if (!config.safe.client) return [];
|
||||
|
||||
try {
|
||||
const orgAddr = ethers.utils.getAddress(this.address);
|
||||
const response = await getPendingProjects(
|
||||
ethers.utils.getAddress(this.owner),
|
||||
config.safe.client,
|
||||
);
|
||||
const projects: PendingAnchor[] = [];
|
||||
|
||||
for (const tx of response.results || []) {
|
||||
if (tx.data && tx.to === orgAddr) {
|
||||
const anchor = parseAnchorTx(tx.data, config);
|
||||
const confirmations = tx.confirmations?.map(t => t.owner) || [];
|
||||
|
||||
if (anchor) {
|
||||
projects.push({
|
||||
id: anchor.id,
|
||||
anchor: { stateHash: anchor.stateHash },
|
||||
confirmations,
|
||||
safeTxHash: tx.safeTxHash,
|
||||
confirmed: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return projects;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
static async getAnchor(
|
||||
orgAddr: string,
|
||||
urn: string,
|
||||
config: Config,
|
||||
): Promise<string | null> {
|
||||
const org = new ethers.Contract(orgAddr, config.abi.org, config.provider);
|
||||
const unpadded = utils.decodeRadicleId(urn);
|
||||
const id = ethers.utils.zeroPad(unpadded, 32);
|
||||
|
||||
try {
|
||||
const [, hash] = await org.anchors(id);
|
||||
const anchor = utils.formatProjectHash(ethers.utils.arrayify(hash));
|
||||
|
||||
return anchor;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static async getMulti(ids: string[], config: Config): Promise<Array<Org>> {
|
||||
const results = await Promise.all(ids.map(addr => Org.get(addr, config)));
|
||||
const orgs = results.filter((org): org is Org => org !== null);
|
||||
|
||||
return orgs;
|
||||
}
|
||||
|
||||
static async getAll(config: Config): Promise<Array<Org>> {
|
||||
const result = await utils.querySubgraph(config.orgs.subgraph, GetOrgs, {});
|
||||
const orgs: Org[] = [];
|
||||
|
||||
for (const o of result.orgs) {
|
||||
try {
|
||||
orgs.push(new Org(o.id, o.owner));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
return orgs;
|
||||
}
|
||||
|
||||
static fromReceipt(receipt: ContractReceipt): Org | null {
|
||||
const event = receipt.events?.find(e => e.event === "OrgCreated");
|
||||
|
||||
if (event && event.args) {
|
||||
const address = event.args[0];
|
||||
const owner = event.args[1];
|
||||
|
||||
return new Org(address, owner);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static async get(addressOrName: string, config: Config): Promise<Org | null> {
|
||||
const org = await getOrgContract(addressOrName, config);
|
||||
|
||||
@@ -354,62 +216,6 @@ export class Org {
|
||||
|
||||
return orgs.map(o => new Org(o.id, o.owner));
|
||||
}
|
||||
|
||||
static async createMultiSig(
|
||||
owners: [string],
|
||||
threshold: number,
|
||||
config: Config,
|
||||
): Promise<TransactionResponse> {
|
||||
assert(config.signer);
|
||||
|
||||
const orgFactory = new ethers.Contract(
|
||||
config.orgFactory.address,
|
||||
config.abi.orgFactory,
|
||||
config.signer,
|
||||
);
|
||||
|
||||
return orgFactory["createOrg(address[],uint256)"](owners, threshold, {
|
||||
gasLimit: config.gasLimits.createOrg,
|
||||
});
|
||||
}
|
||||
|
||||
static async create(
|
||||
owner: string,
|
||||
config: Config,
|
||||
): Promise<TransactionResponse> {
|
||||
assert(config.signer);
|
||||
|
||||
const orgFactory = new ethers.Contract(
|
||||
config.orgFactory.address,
|
||||
config.abi.orgFactory,
|
||||
config.signer,
|
||||
);
|
||||
|
||||
return orgFactory["createOrg(address)"](owner, {
|
||||
gasLimit: config.gasLimits.createOrg,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function parseAnchorTx(
|
||||
data: string,
|
||||
config: Config,
|
||||
): { id: string; stateHash: string } | null {
|
||||
const iface = new ethers.utils.Interface(config.abi.org);
|
||||
const parsedTx = iface.parseTransaction({ data });
|
||||
|
||||
if (parsedTx.name === "anchor") {
|
||||
const encodedProjectUrn = parsedTx.args[0];
|
||||
const encodedCommitHash = parsedTx.args[2];
|
||||
const id = utils.formatRadicleId(
|
||||
ethers.utils.arrayify(`${encodedProjectUrn}`),
|
||||
);
|
||||
const byteArray = ethers.utils.arrayify(encodedCommitHash);
|
||||
const stateHash = utils.formatProjectHash(byteArray);
|
||||
|
||||
return { id, stateHash };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const getOrgContract = cache.cached(
|
||||
@@ -425,20 +231,3 @@ export const resolveOrgOwner = cache.cached(
|
||||
},
|
||||
org => org.address,
|
||||
);
|
||||
|
||||
export const getPendingProjects = cache.cached(
|
||||
async (
|
||||
owner: string,
|
||||
client: SafeServiceClient,
|
||||
): Promise<SafeMultisigTransactionListResponse> => {
|
||||
try {
|
||||
return await client.getPendingTransactions(
|
||||
ethers.utils.getAddress(owner),
|
||||
);
|
||||
} catch (e) {
|
||||
return { count: 0, results: [] };
|
||||
}
|
||||
},
|
||||
owner => owner,
|
||||
{ max: 1000, ttl: 5 * 60 * 1000 }, // Cache results for 5 minutes.
|
||||
);
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Route } from "svelte-routing";
|
||||
import Redirect from "@app/Redirect.svelte";
|
||||
import NotFound from "@app/NotFound.svelte";
|
||||
</script>
|
||||
|
||||
<Route path="/orgs">
|
||||
<NotFound
|
||||
title="404"
|
||||
subtitle="Radicle Orgs are in the process of being re-designed." />
|
||||
</Route>
|
||||
|
||||
<Route path="/orgs/:addressOrName" let:params>
|
||||
<Redirect to="/{params.addressOrName}" />
|
||||
</Route>
|
||||
@@ -1,183 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { onMount, createEventDispatcher } from "svelte";
|
||||
import Modal from "@app/Modal.svelte";
|
||||
import type { Config } from "@app/config";
|
||||
import { formatAddress, isAddress } from "@app/utils";
|
||||
import Loading from "@app/Loading.svelte";
|
||||
import { assert } from "@app/error";
|
||||
import * as utils from "@app/utils";
|
||||
import Address from "@app/Address.svelte";
|
||||
import Button from "@app/Button.svelte";
|
||||
|
||||
import type { Org } from "./Org";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let org: Org;
|
||||
export let config: Config;
|
||||
|
||||
enum State {
|
||||
Idle,
|
||||
|
||||
// Single sig states.
|
||||
Signing,
|
||||
Pending,
|
||||
Success,
|
||||
|
||||
// Multi sig states.
|
||||
Proposing,
|
||||
Proposed,
|
||||
|
||||
Failed,
|
||||
}
|
||||
|
||||
let newOwner: string | null = null;
|
||||
let state = State.Idle;
|
||||
let error: string | null = null;
|
||||
let input: HTMLInputElement | null = null;
|
||||
|
||||
onMount(() => {
|
||||
input && input.focus();
|
||||
});
|
||||
|
||||
const resetForm = () => {
|
||||
state = State.Idle;
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
assert(newOwner);
|
||||
|
||||
if (!isAddress(newOwner)) {
|
||||
state = State.Failed;
|
||||
error = `"${newOwner}" is not a valid Ethereum address.`;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (org && (await utils.isSafe(org.owner, config))) {
|
||||
state = State.Proposing;
|
||||
await org.setOwnerMultisig(newOwner, config);
|
||||
state = State.Proposed;
|
||||
} else {
|
||||
state = State.Signing;
|
||||
const tx = await org.setOwner(newOwner, config);
|
||||
state = State.Pending;
|
||||
await tx.wait();
|
||||
state = State.Success;
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
state = State.Failed;
|
||||
error = e.message;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if state === State.Success && newOwner}
|
||||
<Modal floating small>
|
||||
<div slot="title">✅</div>
|
||||
|
||||
<div slot="subtitle">
|
||||
The ownership of <span class="txt-bold">
|
||||
{formatAddress(org.address)}
|
||||
</span>
|
||||
was successfully transfered to
|
||||
<span class="txt-bold">{newOwner}</span>
|
||||
.
|
||||
</div>
|
||||
|
||||
<div slot="actions">
|
||||
<Button variant="secondary" on:click={() => dispatch("close")}>
|
||||
Done
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
{:else if state === State.Proposed && org}
|
||||
<Modal floating>
|
||||
<div slot="title">🪴</div>
|
||||
|
||||
<div slot="subtitle">
|
||||
<p>
|
||||
The transaction to set the owner of <span class="txt-bold">
|
||||
{formatAddress(org.address)}
|
||||
</span>
|
||||
to
|
||||
<span class="txt-bold">{newOwner}</span>
|
||||
was proposed to:
|
||||
</p>
|
||||
<p><Address address={org.owner} {config} compact /></p>
|
||||
</div>
|
||||
|
||||
<div slot="actions">
|
||||
<Button variant="secondary" on:click={() => dispatch("close")}>
|
||||
Done
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
{:else}
|
||||
<Modal floating error={state === State.Failed} small={state === State.Failed}>
|
||||
<div slot="title">
|
||||
🔑
|
||||
<div>Transfer ownership</div>
|
||||
</div>
|
||||
|
||||
<div slot="subtitle">
|
||||
{#if state === State.Signing}
|
||||
Please confirm the transaction in your wallet.
|
||||
{:else if state === State.Pending}
|
||||
Waiting for transaction to be processed...
|
||||
{:else if state === State.Proposing && org}
|
||||
Proposal is being submitted to the safe
|
||||
<span class="txt-bold">{formatAddress(org.owner)}</span>
|
||||
, please sign the transaction in your wallet.
|
||||
{:else if state === State.Idle}
|
||||
Transfer the ownership of Org <span class="txt-bold">
|
||||
{formatAddress(org.address)}
|
||||
</span>
|
||||
to a new address.
|
||||
{:else if state === State.Failed}
|
||||
<div class="error">
|
||||
{error}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div slot="body">
|
||||
{#if state === State.Idle}
|
||||
<input
|
||||
type="text"
|
||||
size="40"
|
||||
disabled={state !== State.Idle}
|
||||
bind:this={input}
|
||||
bind:value={newOwner} />
|
||||
{:else if state === State.Pending || state === State.Proposing || state === State.Signing}
|
||||
<Loading small center />
|
||||
{:else if state === State.Failed}
|
||||
<!-- ... -->
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div slot="actions">
|
||||
{#if state === State.Signing}
|
||||
<Button variant="text" on:click={() => dispatch("close")}>
|
||||
Cancel
|
||||
</Button>
|
||||
{:else if state === State.Pending}
|
||||
<Button variant="text" on:click={() => dispatch("close")}>Close</Button>
|
||||
{:else if state === State.Failed}
|
||||
<Button variant="negative" on:click={resetForm}>Back</Button>
|
||||
{:else}
|
||||
<Button
|
||||
variant="primary"
|
||||
on:click={onSubmit}
|
||||
disabled={!newOwner || state !== State.Idle}>
|
||||
Submit
|
||||
</Button>
|
||||
|
||||
<Button variant="text" on:click={() => dispatch("close")}>
|
||||
Cancel
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
@@ -1,104 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { navigate } from "svelte-routing";
|
||||
import { onMount } from "svelte";
|
||||
import type { Config } from "@app/config";
|
||||
import * as proj from "@app/project";
|
||||
import Widget from "@app/base/projects/Widget.svelte";
|
||||
import type { Profile } from "@app/profile";
|
||||
import type { ProjectInfo, Anchor, PendingAnchor } from "@app/project";
|
||||
import type { Seed } from "@app/base/seeds/Seed";
|
||||
import AnchorActions from "@app/base/profiles/AnchorActions.svelte";
|
||||
import List from "@app/List.svelte";
|
||||
|
||||
export let seed: Seed;
|
||||
export let profile: Profile | null = null;
|
||||
export let account: string | null = null;
|
||||
export let projects: proj.ProjectInfo[];
|
||||
export let config: Config;
|
||||
|
||||
let anchors: Record<string, Anchor> = {};
|
||||
let pendingAnchors: Record<string, PendingAnchor> = {};
|
||||
// A pointer to the current page of projects added to the listing
|
||||
let page = 0;
|
||||
|
||||
const loadAnchors = async () => {
|
||||
if (profile) {
|
||||
const [pending, confirmed] = await Promise.all([
|
||||
profile.pendingAnchors(config),
|
||||
profile.confirmedAnchors(config),
|
||||
]);
|
||||
|
||||
anchors = confirmed;
|
||||
pendingAnchors = pending;
|
||||
}
|
||||
};
|
||||
|
||||
const fetchMoreProjects = async (): Promise<proj.ProjectInfo[]> => {
|
||||
const projects = await proj.Project.getProjects(seed.api, {
|
||||
perPage: 10,
|
||||
page: (page += 1),
|
||||
});
|
||||
if (projects.length > 0) {
|
||||
return projects;
|
||||
}
|
||||
|
||||
// We return an empty array, for when no more projects are found, since List is looking for an iterable.
|
||||
return [];
|
||||
};
|
||||
|
||||
const onClick = (project: ProjectInfo) => {
|
||||
navigate(
|
||||
proj.path({
|
||||
urn: project.urn,
|
||||
seed: seed?.host,
|
||||
profile: profile?.name ?? profile?.address,
|
||||
revision: project.head,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
onMount(loadAnchors);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.projects {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.projects .project {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="projects">
|
||||
<List items={projects} query={fetchMoreProjects}>
|
||||
<svelte:fragment slot="list" let:items>
|
||||
{#each items as project}
|
||||
{@const anchor = anchors[project.urn]}
|
||||
{@const pendingAnchor = pendingAnchors[project.urn]}
|
||||
{#if project.head}
|
||||
<div class="project">
|
||||
<Widget {project} {seed} {anchor} on:click={() => onClick(project)}>
|
||||
<span class="actions" slot="actions">
|
||||
{#if profile?.org?.safe && account && anchor}
|
||||
{#if pendingAnchor}
|
||||
<!-- Pending anchor -->
|
||||
<AnchorActions
|
||||
{account}
|
||||
{config}
|
||||
anchor={pendingAnchor}
|
||||
safe={profile.org.safe}
|
||||
on:success={() => loadAnchors()} />
|
||||
{/if}
|
||||
{/if}
|
||||
</span>
|
||||
</Widget>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</List>
|
||||
</div>
|
||||
Reference in New Issue
Block a user