Skip to content

Commit

Permalink
Merge pull request #450 from HausDAO/develop
Browse files Browse the repository at this point in the history
release v0.3.2
  • Loading branch information
skuhlmann authored Nov 10, 2023
2 parents ac2698a + 702d5cd commit 4a2f11b
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 68 deletions.
4 changes: 2 additions & 2 deletions libs/abis/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@daohaus/abis",
"version": "0.3.1",
"version": "0.3.2",
"type": "commonjs"
}
}
4 changes: 2 additions & 2 deletions libs/connect-context/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/connect-context",
"version": "0.3.1"
}
"version": "0.3.2"
}
4 changes: 2 additions & 2 deletions libs/connect/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@daohaus/connect",
"version": "0.3.1",
"version": "0.3.2",
"peerDependencies": {
"react-router-dom": "^6.4.3"
}
}
}
4 changes: 2 additions & 2 deletions libs/contract-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@daohaus/contract-utils",
"version": "0.3.1",
"version": "0.3.2",
"type": "commonjs"
}
}
4 changes: 2 additions & 2 deletions libs/data-fetch-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@daohaus/data-fetch-utils",
"version": "0.3.1",
"version": "0.3.2",
"type": "commonjs"
}
}
4 changes: 2 additions & 2 deletions libs/form-builder-base/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/form-builder-base",
"version": "0.3.1"
}
"version": "0.3.2"
}
4 changes: 2 additions & 2 deletions libs/form-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/form-builder",
"version": "0.3.1"
}
"version": "0.3.2"
}
4 changes: 2 additions & 2 deletions libs/keychain-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/keychain-utils",
"version": "0.3.1"
}
"version": "0.3.2"
}
4 changes: 2 additions & 2 deletions libs/moloch-v3-data/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@daohaus/moloch-v3-data",
"version": "0.3.1",
"version": "0.3.2",
"type": "commonjs"
}
}
4 changes: 2 additions & 2 deletions libs/moloch-v3-fields/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/moloch-v3-fields",
"version": "0.3.1"
}
"version": "0.3.2"
}
44 changes: 28 additions & 16 deletions libs/moloch-v3-fields/src/fields/MarkdownField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
DialogContent,
Field,
Label,
Card,
WrappedTextArea,
} from '@daohaus/ui';

import { useFormContext } from 'react-hook-form';
import { BiPencil } from 'react-icons/bi';
import { MdFullscreen, MdFullscreenExit, MdPreview } from 'react-icons/md';
Expand Down Expand Up @@ -38,8 +40,6 @@ const MarkDownContainer = styled.div`

const DialogMarkDownContainer = styled.div`
height: 50rem;
max-width: 100rem;
min-width: 50rem;
overflow-y: scroll;
padding: 10px;
margin-bottom: 5rem;
Expand All @@ -64,8 +64,12 @@ const LabelContainer = styled(Label)`

const DialogWrappedTextArea = styled(WrappedTextArea)`
height: 50rem;
max-width: 100rem;
min-width: 70rem;
overflow-y: scroll;
padding: 10px;
margin-bottom: 5rem;
border-radius: 5px;
font-size: 1.5rem;
font-family: inherit;
`;

const DialogButtonWrapper = styled.div`
Expand All @@ -75,6 +79,12 @@ const DialogButtonWrapper = styled.div`
margin-bottom: -2rem;
`;

const ContentWrapper = styled(Card)`
border: none;
min-width: 50vw;
max-width: 90vw;
`;

export const MarkdownField = (props: Buildable<Field>) => {
const { watch } = useFormContext();
const value = watch(props.id);
Expand Down Expand Up @@ -132,18 +142,20 @@ export const MarkdownField = (props: Buildable<Field>) => {
<MdPreview />
</Button>
</DialogButtonWrapper>
{edit ? (
<DialogWrappedTextArea {...props} />
) : (
<>
<LabelContainer>
<Label>Preview</Label>
</LabelContainer>
<DialogMarkDownContainer>
<ReactMarkdown>{value}</ReactMarkdown>
</DialogMarkDownContainer>
</>
)}
<ContentWrapper>
{edit ? (
<DialogWrappedTextArea {...props} />
) : (
<>
<LabelContainer>
<Label>Preview</Label>
</LabelContainer>
<DialogMarkDownContainer>
<ReactMarkdown>{value}</ReactMarkdown>
</DialogMarkDownContainer>
</>
)}
</ContentWrapper>
</DialogContent>
</Dialog>
</TabsContainer>
Expand Down
4 changes: 2 additions & 2 deletions libs/moloch-v3-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@daohaus/moloch-v3-hooks",
"version": "0.3.1",
"version": "0.3.2",
"peerDependencies": {
"react-query": "^3.39.3"
}
}
}
4 changes: 2 additions & 2 deletions libs/moloch-v3-legos/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@daohaus/moloch-v3-legos",
"version": "0.3.1",
"version": "0.3.2",
"type": "commonjs"
}
}
4 changes: 2 additions & 2 deletions libs/moloch-v3-macro-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@daohaus/moloch-v3-macro-ui",
"version": "0.3.1",
"version": "0.3.2",
"peerDependencies": {
"react-router-dom": "^6.4.3"
}
}
}
20 changes: 14 additions & 6 deletions libs/moloch-v3-macro-ui/src/utils/proposalDetailsHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,25 @@ const getValueFromMintOrTransferAction = (
): string => {
if (
actionData.params[0].name !== 'to' &&
!['amount', '_value'].includes(actionData.params[1].name)
!['amount', '_value', 'wad'].includes(actionData.params[1].name)
) {
return 'decoding error';
}

const value = Array.isArray(actionData.params[1].value)
? (actionData.params[1].value[0] as bigint)
: (actionData.params[1].value as bigint);
const value = actionData.params[1].type.endsWith('[]')
? actionData.params[1].value
.toString()
.split(',')
.map((v) => BigInt(v))
: [BigInt(actionData.params[1].value.toString())];

return formatValueTo({
value: toWholeUnits(value.toString(), decimals),
value: toWholeUnits(
value
.reduce((val: bigint, accValue: bigint) => accValue + val, BigInt(0))
.toString(),
decimals
),
decimals: 2,
format: 'numberShort',
});
Expand All @@ -78,7 +86,7 @@ const getRecipientAddressFromMintOrTransferAction = (
): string => {
if (
actionData.params[0].name !== 'to' &&
!['amount', '_value'].includes(actionData.params[1].name)
!['amount', '_value', 'wad'].includes(actionData.params[1].name)
) {
return 'decoding error';
}
Expand Down
4 changes: 2 additions & 2 deletions libs/profile-data/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@daohaus/profile-data",
"version": "0.3.1",
"version": "0.3.2",
"type": "commonjs"
}
}
4 changes: 2 additions & 2 deletions libs/tx-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/tx-builder",
"version": "0.3.1"
}
"version": "0.3.2"
}
2 changes: 1 addition & 1 deletion libs/tx-builder/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LOCAL_ABI } from '@daohaus/abis';
export const EXPIRY = '.proposalExpiry';
export const FORM = '.formValues';
export const CURRENT_DAO = '.daoId';
export const gasBufferMultiplier = 5;
export const gasBufferMultiplier = 1.2; // buffers baalgas estimate
export const BaalContractBase = {
type: 'local',
contractName: 'Baal',
Expand Down
6 changes: 5 additions & 1 deletion libs/tx-builder/src/utils/deepDecoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ const decodeMethod = (options: {
const inputsWithValues = (inputs as any[]).map((input, index) => ({
name: input.name,
type: input.type,
value: result.args?.[index]?.toString() || '0x',
value: Array.isArray(result.args?.[index])
? (result.args?.[index] as Array<any>).length

Check warning on line 161 in libs/tx-builder/src/utils/deepDecoding.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
? (result.args?.[index] as Array<any>).toString()

Check warning on line 162 in libs/tx-builder/src/utils/deepDecoding.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
: '[]'
: result.args?.[index]?.toString() || '0x',
}));

return {
Expand Down
21 changes: 16 additions & 5 deletions libs/tx-builder/src/utils/multicall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
MulticallArg,
StringSearch,
TXLego,
ACTION_GAS_LIMIT_ADDITION,
} from '@daohaus/utils';
import {
CONTRACT_KEYCHAINS,
Expand All @@ -39,14 +40,14 @@ import { createViemClient } from '@daohaus/utils';

export const estimateFunctionalGas = async ({
chainId,
constractAddress,
contractAddress,
from,
value,
data,
rpcs = HAUS_RPC,
}: {
chainId: ValidNetwork;
constractAddress: string;
contractAddress: string;
from: string;
value: bigint;
data: string;
Expand All @@ -59,11 +60,13 @@ export const estimateFunctionalGas = async ({

const functionGasFees = await client.estimateGas({
account: from as EthAddress,
to: constractAddress as EthAddress,
to: contractAddress as EthAddress,
value,
data: data as `0x${string}`,
});

console.log('functionGasFees', functionGasFees);

return Number(functionGasFees);
};

Expand Down Expand Up @@ -284,10 +287,12 @@ export const handleMulticallArg = async ({

export const gasEstimateFromActions = async ({
actions,
actionsCount,
chainId,
daoId,
}: {
actions: MetaTransaction[];
actionsCount: number;
chainId: ValidNetwork;
daoId: string;
safeId: string; // not used at the moment
Expand All @@ -297,7 +302,7 @@ export const gasEstimateFromActions = async ({
async (action) =>
await estimateFunctionalGas({
chainId: chainId,
constractAddress: action.to,
contractAddress: action.to,
from: daoId, // from value needs to be the safe module (baal) to estimate without revert
value: BigInt(Number(action.value)),
data: action.data,
Expand All @@ -310,9 +315,13 @@ export const gasEstimateFromActions = async ({
(a, b) => (a || 0) + (b || 0),
0
);

// extra gas overhead when calling the dao from the baal safe
const baalOnlyGas = actionsCount * ACTION_GAS_LIMIT_ADDITION;
console.log('baalOnlyGas addtition', baalOnlyGas);
console.log('totalGasEstimate', totalGasEstimate);

return totalGasEstimate;
return (totalGasEstimate || 0) + baalOnlyGas;
};

export const handleEncodeMulticallArg = async ({
Expand Down Expand Up @@ -386,12 +395,14 @@ export const handleGasEstimate = async ({
} as MetaTransaction;
const gasEstimate = await gasEstimateFromActions({
actions: encodeExecFromModule({ safeId, metaTx }),
actionsCount: actions.length,
chainId,
daoId,
safeId,
});

if (gasEstimate) {
// adds buffer to baalgas estimate
const buffer = arg.bufferPercentage || gasBufferMultiplier;
return Math.round(Number(gasEstimate) * Number(buffer));
} else {
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/ui",
"version": "0.3.1"
}
"version": "0.3.2"
}
4 changes: 2 additions & 2 deletions libs/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@daohaus/utils",
"version": "0.3.1"
}
"version": "0.3.2"
}
7 changes: 5 additions & 2 deletions libs/utils/src/constants/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ export const PROPOSAL_FILTERS: Record<string, string> = {
failed: 'Defeated',
expired: 'Expired',
};

export const GAS_BUFFER_MULTIPLIER = 5;
// Processing gas estimate buffer
export const GAS_BUFFER_MULTIPLIER = 2;
// Adding to the gas limit to account for cost of processProposal
export const PROCESS_PROPOSAL_GAS_LIMIT_ADDITION = 150000;
// Adding to the gas limit to account for cost of each action
export const ACTION_GAS_LIMIT_ADDITION = 150000;

export const L2_ADDITIONAL_GAS = 5000000;
Loading

0 comments on commit 4a2f11b

Please sign in to comment.