Skip to content

Commit

Permalink
Merge branch 'master' into alias-space-name
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaituVR authored Jan 24, 2025
2 parents d19b797 + 491fbdb commit 64d4d00
Showing 1 changed file with 45 additions and 18 deletions.
63 changes: 45 additions & 18 deletions apps/ui/src/networks/evm/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { vote as highlightVote } from '@/helpers/highlight';
import { getSwapLink } from '@/helpers/link';
import { executionCall, MANA_URL } from '@/helpers/mana';
import { getProvider } from '@/helpers/provider';
import { convertToMetaTransactions } from '@/helpers/transactions';
import { createErc1155Metadata, verifyNetwork } from '@/helpers/utils';
import { EVM_CONNECTORS } from '@/networks/common/constants';
Expand Down Expand Up @@ -80,12 +81,26 @@ export function createActions(
return code !== '0x';
};

/**
* Get signer from Web3 provider with ENS resolver on mainnet
* @param web3 Web3 provider
* @returns signer with ENS resolver on mainnet
*/
const getSigner = (web3: Web3Provider) => {
const signer = web3.getSigner();
signer.provider.getResolver = (value: string) => {
return getProvider(1).getResolver(value);
};

return signer;
};

return {
async predictSpaceAddress(web3: Web3Provider, { salt }) {
await verifyNetwork(web3, chainId);

return client.predictSpaceAddress({
signer: web3.getSigner(),
signer: getSigner(web3),
saltNonce: salt
});
},
Expand Down Expand Up @@ -113,7 +128,7 @@ export function createActions(
);
},
async createSpace(
web3: any,
web3: Web3Provider,
salt: string,
params: {
controller: string;
Expand Down Expand Up @@ -152,7 +167,7 @@ export function createActions(
);

const response = await client.deploySpace({
signer: web3.getSigner(),
signer: getSigner(web3),
saltNonce: salt,
params: {
...params,
Expand Down Expand Up @@ -268,16 +283,18 @@ export function createActions(
metadataUri: `ipfs://${pinned.cid}`
};

const signer = getSigner(web3);

if (relayerType === 'evm') {
return ethSigClient.propose({
signer: web3.getSigner(),
signer,
data
});
}

return client.propose(
{
signer: web3.getSigner(),
signer,
envelope: {
data
}
Expand Down Expand Up @@ -354,16 +371,18 @@ export function createActions(
metadataUri: `ipfs://${pinned.cid}`
};

const signer = getSigner(web3);

if (relayerType === 'evm') {
return ethSigClient.updateProposal({
signer: web3.getSigner(),
signer,
data
});
}

return client.updateProposal(
{
signer: web3.getSigner(),
signer,
envelope: {
data
}
Expand All @@ -377,12 +396,14 @@ export function createActions(
cancelProposal: async (web3: Web3Provider, proposal: Proposal) => {
await verifyNetwork(web3, chainId);

const address = await web3.getSigner().getAddress();
const signer = getSigner(web3);

const address = await signer.getAddress();
const isContract = await getIsContract(address);

return client.cancel(
{
signer: web3.getSigner(),
signer,
space: proposal.space.id,
proposal: proposal.proposal_id as number
},
Expand Down Expand Up @@ -440,20 +461,22 @@ export function createActions(
chainId
};

const signer = getSigner(web3);

if (!isContract && proposal.execution_strategy_type === 'Axiom') {
return highlightVote({ signer: web3.getSigner(), data });
return highlightVote({ signer, data });
}

if (relayerType === 'evm') {
return ethSigClient.vote({
signer: web3.getSigner(),
signer,
data
});
}

return client.vote(
{
signer: web3.getSigner(),
signer,
envelope: {
data
}
Expand Down Expand Up @@ -505,7 +528,7 @@ export function createActions(
await verifyNetwork(web3, chainId);

return client.vetoExecution({
signer: web3.getSigner(),
signer: getSigner(web3),
executionStrategy: proposal.execution_strategy,
executionHash: proposal.execution_hash
});
Expand All @@ -517,12 +540,14 @@ export function createActions(
) => {
await verifyNetwork(web3, chainId);

const address = await web3.getSigner().getAddress();
const signer = web3.getSigner();

const address = await signer.getAddress();
const isContract = await getIsContract(address);

return client.transferOwnership(
{
signer: web3.getSigner(),
signer,
space: space.id,
owner
},
Expand Down Expand Up @@ -570,18 +595,20 @@ export function createActions(
throw new Error('Unsupported delegation type');
}

const signer = getSigner(web3);

const votesContract = new Contract(
contractParams.address,
contractParams.abi,
web3.getSigner()
signer
);

return votesContract[contractParams.functionName](
...contractParams.functionParams
);
},
updateSettings: async (
web3: any,
web3: Web3Provider,
space: Space,
metadata: SpaceMetadata,
authenticatorsToAdd: StrategyConfig[],
Expand Down Expand Up @@ -613,7 +640,7 @@ export function createActions(
);

return client.updateSettings({
signer: web3.getSigner(),
signer: getSigner(web3),
space: space.id,
settings: {
metadataUri: `ipfs://${pinned.cid}`,
Expand Down

0 comments on commit 64d4d00

Please sign in to comment.