Skip to content

Commit 13f2d12

Browse files
committed
Fix validation issues and proper display logic for send assets / airdrop actions
1 parent bbbb82a commit 13f2d12

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

src/components/ProposalBuilder/ProposalActionCard.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ export function ProposalActionCard({
127127
? getAddress(action.transactions[0].parameters[0].value)
128128
: zeroAddress;
129129
const transferAmount = BigInt(action.transactions[0].parameters[1].value || '0');
130+
130131
if (!destinationAddress || !transferAmount) {
131132
return null;
132133
}
133134

135+
// TODO: This does not work for native asset
134136
const actionAsset = assetsFungible.find(
135-
asset => getAddress(asset.tokenAddress) === destinationAddress,
137+
asset => getAddress(asset.tokenAddress) === getAddress(action.transactions[0].targetAddress),
136138
);
137139

138140
if (!actionAsset) {
@@ -158,8 +160,11 @@ export function ProposalActionCard({
158160
);
159161
const recipientsCount = action.transactions[1].parameters[1].value?.split(',').length || 0;
160162

163+
// First transaction in the airdrop proposal will be approval transaction, which is called on the token
164+
// Thus we can find the asset by looking at the target address of the first transaction
165+
161166
const actionAsset = assetsFungible.find(
162-
asset => getAddress(asset.tokenAddress) === action.transactions[0].targetAddress,
167+
asset => getAddress(asset.tokenAddress) === getAddress(action.transactions[0].targetAddress),
163168
);
164169

165170
if (!actionAsset) {

src/components/ProposalBuilder/StepButtons.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export default function StepButtons(props: StepButtonsProps) {
5757
type="submit"
5858
isDisabled={
5959
!canUserCreateProposal ||
60+
!!proposalMetadataError ||
6061
!!transactionsError ||
62+
!proposalMetadata.title ||
6163
!!nonceError ||
6264
pendingTransaction
6365
}

src/hooks/DAO/useSendAssetsActionModal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,13 @@ export default function useSendAssetsActionModal() {
2828
return;
2929
}
3030
const isNative = isNativeAsset(sendAssetsData.asset);
31-
const transactionData = prepareSendAssetsActionData({
32-
transferAmount: sendAssetsData.transferAmount,
33-
asset: sendAssetsData.asset,
34-
destinationAddress: sendAssetsData.destinationAddress,
35-
});
31+
const transactionData = prepareSendAssetsActionData(sendAssetsData);
3632
addAction({
3733
actionType: ProposalActionType.TRANSFER,
3834
content: <></>,
3935
transactions: [
4036
{
41-
targetAddress: transactionData.calldata,
37+
targetAddress: transactionData.target,
4238
ethValue: {
4339
bigintValue: transactionData.value,
4440
value: transactionData.value.toString(),

src/hooks/utils/useCreateRoles.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,11 +1704,7 @@ export default function useCreateRoles() {
17041704

17051705
// Add "send assets" actions to the proposal data
17061706
values.actions.forEach(action => {
1707-
const actionData = prepareSendAssetsActionData({
1708-
transferAmount: action.transferAmount,
1709-
asset: action.asset,
1710-
destinationAddress: action.destinationAddress,
1711-
});
1707+
const actionData = prepareSendAssetsActionData(action);
17121708
proposalData.targets.push(actionData.target);
17131709
proposalData.values.push(actionData.value);
17141710
proposalData.calldatas.push(actionData.calldata);

src/hooks/utils/useGetSafeName.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const getSafeName = async (
1919

2020
const mainnetPublicClient = createPublicClient({
2121
chain: mainnet.chain,
22-
transport: http(mainnet.rpcEndpoint),
22+
transport: http(mainnet.rpcEndpoint, { batch: true }),
2323
});
2424
const ensName = await mainnetPublicClient.getEnsName({ address });
2525
if (ensName) {

src/hooks/utils/useResolveENSName.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const useResolveENSName = () => {
4545

4646
const mainnetPublicClient = createPublicClient({
4747
chain: mainnet.chain,
48-
transport: http(mainnet.rpcEndpoint),
48+
transport: http(mainnet.rpcEndpoint, { batch: true }),
4949
});
5050
const resolvedAddress = await mainnetPublicClient.getEnsAddress({ name: normalizedName });
5151
if (resolvedAddress) {

src/pages/dao/proposals/actions/new/SafeProposalWithActionsCreatePage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as amplitude from '@amplitude/analytics-browser';
22
import { Center } from '@chakra-ui/react';
3-
import { useEffect } from 'react';
3+
import { useEffect, useMemo } from 'react';
44
import { ProposalBuilder } from '../../../../../components/ProposalBuilder';
55
import { DEFAULT_PROPOSAL } from '../../../../../components/ProposalBuilder/constants';
66
import { BarLoader } from '../../../../../components/ui/loaders/BarLoader';
@@ -23,6 +23,7 @@ export function SafeProposalWithActionsCreatePage() {
2323

2424
const { prepareProposal } = usePrepareProposal();
2525
const { getTransactions } = useProposalActionsStore();
26+
const transactions = useMemo(() => getTransactions(), [getTransactions]);
2627

2728
const HEADER_HEIGHT = useHeaderHeight();
2829

@@ -38,7 +39,7 @@ export function SafeProposalWithActionsCreatePage() {
3839
<ProposalBuilder
3940
initialValues={{
4041
...DEFAULT_PROPOSAL,
41-
transactions: getTransactions(),
42+
transactions,
4243
nonce: safe.nextNonce,
4344
}}
4445
mode={ProposalBuilderMode.PROPOSAL_WITH_ACTIONS}

src/providers/NetworkConfig/web3-modal.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const transportsReducer = (
2424
accumulator: Record<string, HttpTransport>,
2525
network: NetworkConfig,
2626
) => {
27-
accumulator[network.chain.id] = http(network.rpcEndpoint);
27+
accumulator[network.chain.id] = http(network.rpcEndpoint, { batch: true });
2828
return accumulator;
2929
};
3030

src/utils/dao/prepareSendAssetsActionData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const prepareSendAssetsActionData = ({
3232
}
3333

3434
const actionData = {
35-
target: target,
35+
target,
3636
value: isNative ? transferAmount : 0n,
3737
calldata,
3838
};

0 commit comments

Comments
 (0)