Skip to content

Commit

Permalink
refactor: remove unused actions (#1047)
Browse files Browse the repository at this point in the history
Removing actions that are no longer used (were replaced by updateSettings):
 - setMetadata
 - setVotingDelay
 - setMinVotingDuration
 - setMaxVotingDuration

This will reduce number of changes needed as we change behaviour of
calling actions as Safe.
  • Loading branch information
Sekhmet authored Dec 11, 2024
1 parent a64bab8 commit e4a618e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 214 deletions.
72 changes: 0 additions & 72 deletions apps/ui/src/composables/useActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,6 @@ export function useActions() {
return receipt;
}

async function updateMetadata(space: Space, metadata: SpaceMetadata) {
if (!web3.value.account) return await forceLogin();

const network = getReadWriteNetwork(space.network);
if (!network.managerConnectors.includes(web3.value.type as Connector)) {
throw new Error(`${web3.value.type} is not supported for this action`);
}

await wrapPromise(
space.network,
network.actions.setMetadata(auth.web3, space, metadata)
);
}

async function vote(
proposal: Proposal,
choice: Choice,
Expand Down Expand Up @@ -429,60 +415,6 @@ export function useActions() {
);
}

async function setVotingDelay(space: Space, votingDelay: number) {
if (!web3.value.account) return await forceLogin();

const network = getReadWriteNetwork(space.network);
if (!network.managerConnectors.includes(web3.value.type as Connector)) {
throw new Error(`${web3.value.type} is not supported for this action`);
}

await wrapPromise(
space.network,
network.actions.setVotingDelay(
auth.web3,
space,
getCurrentFromDuration(space.network, votingDelay)
)
);
}

async function setMinVotingDuration(space: Space, minVotingDuration: number) {
if (!web3.value.account) return await forceLogin();

const network = getReadWriteNetwork(space.network);
if (!network.managerConnectors.includes(web3.value.type as Connector)) {
throw new Error(`${web3.value.type} is not supported for this action`);
}

await wrapPromise(
space.network,
network.actions.setMinVotingDuration(
auth.web3,
space,
getCurrentFromDuration(space.network, minVotingDuration)
)
);
}

async function setMaxVotingDuration(space: Space, maxVotingDuration: number) {
if (!web3.value.account) return await forceLogin();

const network = getReadWriteNetwork(space.network);
if (!network.managerConnectors.includes(web3.value.type as Connector)) {
throw new Error(`${web3.value.type} is not supported for this action`);
}

await wrapPromise(
space.network,
network.actions.setMaxVotingDuration(
auth.web3,
space,
getCurrentFromDuration(space.network, maxVotingDuration)
)
);
}

async function transferOwnership(space: Space, owner: string) {
if (!web3.value.account) {
await forceLogin();
Expand Down Expand Up @@ -699,7 +631,6 @@ export function useActions() {
predictSpaceAddress: wrapWithErrors(predictSpaceAddress),
deployDependency: wrapWithErrors(deployDependency),
createSpace: wrapWithErrors(createSpace),
updateMetadata: wrapWithErrors(updateMetadata),
vote: wrapWithErrors(vote),
propose: wrapWithErrors(propose),
updateProposal: wrapWithErrors(updateProposal),
Expand All @@ -708,9 +639,6 @@ export function useActions() {
executeTransactions: wrapWithErrors(executeTransactions),
executeQueuedProposal: wrapWithErrors(executeQueuedProposal),
vetoProposal: wrapWithErrors(vetoProposal),
setVotingDelay: wrapWithErrors(setVotingDelay),
setMinVotingDuration: wrapWithErrors(setMinVotingDuration),
setMaxVotingDuration: wrapWithErrors(setMaxVotingDuration),
transferOwnership: wrapWithErrors(transferOwnership),
updateSettings: wrapWithErrors(updateSettings),
updateSettingsRaw: wrapWithErrors(updateSettingsRaw),
Expand Down
78 changes: 0 additions & 78 deletions apps/ui/src/networks/evm/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,6 @@ export function createActions(

return { txId: response.txId };
},
setMetadata: async (
web3: Web3Provider,
space: Space,
metadata: SpaceMetadata
) => {
await verifyNetwork(web3, chainId);

const pinned = await helpers.pin(
createErc1155Metadata(metadata, {
execution_strategies: space.executors,
execution_strategies_types: space.executors_types,
execution_destinations: space.executors_destinations
})
);

return client.setMetadataUri({
signer: web3.getSigner(),
space: space.id,
metadataUri: `ipfs://${pinned.cid}`
});
},
propose: async (
web3: Web3Provider,
connectorType: Connector,
Expand Down Expand Up @@ -523,63 +502,6 @@ export function createActions(
executionHash: proposal.execution_hash
});
},
setVotingDelay: async (
web3: Web3Provider,
space: Space,
votingDelay: number
) => {
await verifyNetwork(web3, chainId);

const address = await web3.getSigner().getAddress();
const isContract = await getIsContract(address);

return client.setVotingDelay(
{
signer: web3.getSigner(),
space: space.id,
votingDelay
},
{ noWait: isContract }
);
},
setMinVotingDuration: async (
web3: Web3Provider,
space: Space,
minVotingDuration: number
) => {
await verifyNetwork(web3, chainId);

const address = await web3.getSigner().getAddress();
const isContract = await getIsContract(address);

return client.setMinVotingDuration(
{
signer: web3.getSigner(),
space: space.id,
minVotingDuration
},
{ noWait: isContract }
);
},
setMaxVotingDuration: async (
web3: Web3Provider,
space: Space,
maxVotingDuration: number
) => {
await verifyNetwork(web3, chainId);

const address = await web3.getSigner().getAddress();
const isContract = await getIsContract(address);

return client.setMaxVotingDuration(
{
signer: web3.getSigner(),
space: space.id,
maxVotingDuration
},
{ noWait: isContract }
);
},
transferOwnership: async (
web3: Web3Provider,
space: Space,
Expand Down
52 changes: 0 additions & 52 deletions apps/ui/src/networks/starknet/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,6 @@ export function createActions(
}
});
},
setMetadata: async (web3: any, space: Space, metadata: SpaceMetadata) => {
await verifyStarknetNetwork(web3, chainId);

const pinned = await helpers.pin(
createErc1155Metadata(metadata, {
execution_strategies: space.executors,
execution_strategies_types: space.executors_types,
execution_destinations: space.executors_destinations
})
);

return client.setMetadataUri({
signer: web3.provider.account,
space: space.id,
metadataUri: `ipfs://${pinned.cid}`
});
},
propose: async (
web3: any,
connectorType: Connector,
Expand Down Expand Up @@ -570,41 +553,6 @@ export function createActions(
});
},
vetoProposal: () => null,
setVotingDelay: async (web3: any, space: Space, votingDelay: number) => {
await verifyStarknetNetwork(web3, chainId);

return client.setVotingDelay({
signer: web3.provider.account,
space: space.id,
votingDelay
});
},
setMinVotingDuration: async (
web3: any,
space: Space,
minVotingDuration: number
) => {
await verifyStarknetNetwork(web3, chainId);

return client.setMinVotingDuration({
signer: web3.provider.account,
space: space.id,
minVotingDuration
});
},
setMaxVotingDuration: async (
web3: any,
space: Space,
maxVotingDuration: number
) => {
await verifyStarknetNetwork(web3, chainId);

return client.setMaxVotingDuration({
signer: web3.provider.account,
space: space.id,
maxVotingDuration
});
},
transferOwnership: async (web3: any, space: Space, owner: string) => {
await verifyStarknetNetwork(web3, chainId);

Expand Down
12 changes: 0 additions & 12 deletions apps/ui/src/networks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,10 @@ export type NetworkActions = ReadOnlyNetworkActions & {
metadata: SpaceMetadata;
}
);
setMetadata(web3: Web3Provider, space: Space, metadata: SpaceMetadata);
finalizeProposal(web3: Web3Provider, proposal: Proposal);
executeTransactions(web3: Web3Provider, proposal: Proposal);
executeQueuedProposal(web3: Web3Provider, proposal: Proposal);
vetoProposal(web3: Web3Provider, proposal: Proposal);
setVotingDelay(web3: Web3Provider, space: Space, votingDelay: number);
setMinVotingDuration(
web3: Web3Provider,
space: Space,
minVotingDuration: number
);
setMaxVotingDuration(
web3: Web3Provider,
space: Space,
maxVotingDuration: number
);
updateSettings(
web3: Web3Provider,
space: Space,
Expand Down

0 comments on commit e4a618e

Please sign in to comment.