Skip to content

Commit

Permalink
Merge pull request #400 from Once-Upon/datadanne/nouns-contract-upgrades
Browse files Browse the repository at this point in the history
Update Nouns protocol to support new AuctionHouseV2 and DAOLogicV4 ABIs
  • Loading branch information
pcowgill authored Jul 19, 2024
2 parents efd9327 + bdbe341 commit ea8150f
Show file tree
Hide file tree
Showing 11 changed files with 4,179 additions and 584 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion src/contextualizers/protocol/nouns/auctionHouse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Transaction } from '../../../types';
import { contextSummary, containsBigInt } from '../../../helpers/utils';
import { detect, generate } from './auctionHouse';
import nounsAuctionHouseBid0x4efdef57 from '../../test/transactions/nouns-auction-house-bid-0x4efdef57.json';
import nounsAuctionHouseV2Bid0x034346af from '../../test/transactions/nouns-auction-house-v2-bid-0x034346af.json';
import nounsAuctionHouseSettleAndCreate0x354aea2d from '../../test/transactions/nouns-auction-house-settle-and-create-0x354aea2d.json';
import catchall0xc35c01ac from '../../test/transactions/catchall-0xc35c01ac.json';

Expand All @@ -14,7 +15,7 @@ describe('Nouns Auction House', () => {
expect(match).toBe(true);
});

it('Should generate context', () => {
it('Should generate context for V1', () => {
const transaction = generate(
nounsAuctionHouseBid0x4efdef57 as unknown as Transaction,
);
Expand All @@ -24,6 +25,17 @@ describe('Nouns Auction House', () => {
);
expect(containsBigInt(transaction.context)).toBe(false);
});

it('Should generate context for V2', () => {
const transaction = generate(
nounsAuctionHouseV2Bid0x034346af as unknown as Transaction,
);
expect(transaction?.context?.summaries?.en.title).toBe('Nouns');
expect(contextSummary(transaction.context)).toBe(
'0xbdfeb5439f5daecb78a17ff846645a8bdbbf5725 BID 2 ETH on 0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03 #1163',
);
expect(containsBigInt(transaction.context)).toBe(false);
});
});

describe('settleCurrentAndCreateNewAuction', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/contextualizers/protocol/nouns/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NounsAuctionHouse from './abis/NounsAuctionHouse';
import NounsDAOLogicV3 from './abis/NounsDAOLogicV3';
import NounsAuctionHouseV2 from './abis/NounsAuctionHouseV2';
import NounsDAOLogicV4 from './abis/NounsDAOLogicV4';

export const NounsContracts = {
AuctionHouse: '0x830bd73e4184cef73443c15111a1df14e495c706',
Expand All @@ -8,6 +8,6 @@ export const NounsContracts = {
};

export const ABIs = {
NounsAuctionHouse,
NounsDAOLogicV3,
NounsAuctionHouse: NounsAuctionHouseV2,
NounsDAOLogic: NounsDAOLogicV4,
};
71 changes: 67 additions & 4 deletions src/contextualizers/protocol/nouns/daoLogic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import { detect, generate } from './daoLogic';
import catchall0xc35c01ac from '../../test/transactions/catchall-0xc35c01ac.json';

import nounsPropose0x43866eb1 from '../../test/transactions/nouns-propose-0x43866eb1.json';
import nounsProposeV40x037d933b from '../../test/transactions/nouns-propose-v4-0x037d933b.json';
import nounsProposeBySigs0xbc09b566 from '../../test/transactions/nouns-propose-by-sigs-0xbc09b566.json';
import nounsProposeBySigsV40xc67c3da3 from '../../test/transactions/nouns-propose-by-sigs-v4-0xc67c3da3.json';
import nounsCastVote0xeaf10956 from '../../test/transactions/nouns-cast-vote-0xeaf10956.json';
import nounsCastRefundableVote0x989966a2 from '../../test/transactions/nouns-cast-refundable-vote-0x989966a2.json';
import nounsCastRefundableVoteV40x31564e6a from '../../test/transactions/nouns-cast-refundable-vote-v4-0x31564e6a.json';
import nounsCastRefundableVwr0x4577a55a from '../../test/transactions/nouns-cast-refundable-vwr-0x4577a55a.json';
import nounsCastRefundableVwrV40x441947e7 from '../../test/transactions/nouns-cast-refundable-vwr-v4-0x441947e7.json';
import nounsQueue0x5949facf from '../../test/transactions/nouns-queue-0x5949facf.json';
import nounsExecute0x540c83cb from '../../test/transactions/nouns-execute-0x540c83cb.json';
import nounsCancel0xaae56ed7 from '../../test/transactions/nouns-cancel-0xaae56ed7.json';
Expand All @@ -19,7 +23,7 @@ describe('Nouns Governor', () => {
expect(match).toBe(true);
});

it('Should generate context', () => {
it('Should generate context for V3', () => {
const transaction = generate(
nounsPropose0x43866eb1 as unknown as Transaction,
);
Expand All @@ -31,6 +35,19 @@ describe('Nouns Governor', () => {

expect(transaction?.context?.variables?.description).toBeDefined();
});

it('Should generate context for V4', () => {
const transaction = generate(
nounsProposeV40x037d933b as unknown as Transaction,
);
expect(transaction?.context?.summaries?.en.title).toBe('Nouns');
expect(contextSummary(transaction.context)).toBe(
'0x4bf88042de0220647acb314af3c5f310aec3bcc0 CREATED_PROPOSAL 571',
);
expect(containsBigInt(transaction.context)).toBe(false);

expect(transaction?.context?.variables?.description).toBeDefined();
});
});

describe('proposeBySigs', () => {
Expand All @@ -41,7 +58,7 @@ describe('Nouns Governor', () => {
expect(match).toBe(true);
});

it('Should generate context', () => {
it('Should generate context for V3', () => {
const transaction = generate(
nounsProposeBySigs0xbc09b566 as unknown as Transaction,
);
Expand All @@ -53,6 +70,19 @@ describe('Nouns Governor', () => {

expect(transaction?.context?.variables?.description).toBeDefined();
});

it('Should generate context for V4', () => {
const transaction = generate(
nounsProposeBySigsV40xc67c3da3 as unknown as Transaction,
);
expect(transaction?.context?.summaries?.en.title).toBe('Nouns');
expect(contextSummary(transaction.context)).toBe(
'0x8e37d5fd47016fe5c671c7c1b980afbe6773595c CREATED_PROPOSAL 575',
);
expect(containsBigInt(transaction.context)).toBe(false);

expect(transaction?.context?.variables?.description).toBeDefined();
});
});

describe('castVote', () => {
Expand Down Expand Up @@ -81,7 +111,7 @@ describe('Nouns Governor', () => {
expect(match).toBe(true);
});

it('Should generate context', () => {
it('Should generate context for V3', () => {
const transaction = generate(
nounsCastRefundableVote0x989966a2 as unknown as Transaction,
);
Expand All @@ -91,6 +121,17 @@ describe('Nouns Governor', () => {
);
expect(containsBigInt(transaction.context)).toBe(false);
});

it('Should generate context for V4', () => {
const transaction = generate(
nounsCastRefundableVoteV40x31564e6a as unknown as Transaction,
);
expect(transaction?.context?.summaries?.en.title).toBe('Nouns');
expect(contextSummary(transaction.context)).toBe(
'0x10dec36b4ac9d3b60490dfe2799881287d4a74cc ABSTAINED from voting on proposal 573',
);
expect(containsBigInt(transaction.context)).toBe(false);
});
});

describe('castRefundableVoteWithReason', () => {
Expand All @@ -101,7 +142,7 @@ describe('Nouns Governor', () => {
expect(match).toBe(true);
});

it('Should generate context', () => {
it('Should generate context for V3', () => {
const transaction = generate(
nounsCastRefundableVwr0x4577a55a as unknown as Transaction,
);
Expand All @@ -116,6 +157,28 @@ describe('Nouns Governor', () => {
'0xceed9585854f12f81a0103861b83b995a64ad915 VOTED_AGAINST proposal 471 I have concerns around creating this long of a stream and would rather see more specific focus for the use of funds. (eg directed to a pool of web3 related charitable efforts for example.) \n\nThis will likely pass but if it doesn’t I would vote for a 1 year stream with focused distribution. ',
);
});

it('Should generate context for V4', () => {
const transaction = generate(
nounsCastRefundableVwrV40x441947e7 as unknown as Transaction,
);
expect(transaction?.context?.summaries?.en.title).toBe('Nouns');
expect(contextSummary(transaction.context)).toBe(
'0xa86882277e69fbf0a51805cdc8b0a3a113079e63 VOTED_AGAINST proposal 571',
);
expect(containsBigInt(transaction.context)).toBe(false);

expect(transaction?.context?.variables?.reason).toBeDefined();
expect(contextSummary(transaction.context, 'long')).toBe(
`0xa86882277e69fbf0a51805cdc8b0a3a113079e63 VOTED_AGAINST proposal 571
+1
> I generally disagree with having a pool of Nouns available for swapping. For this specific proposal, I\'m voting no because traits should demand a premium when they come to auction if they\'re desired. It feels like part of the game.`,
);
});
});

describe('queue', () => {
Expand Down
16 changes: 8 additions & 8 deletions src/contextualizers/protocol/nouns/daoLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const detect = (transaction: Transaction): boolean => {
try {
const decoded = decodeTransactionInput(
transaction.input as Hex,
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
);
if (!decoded) return false;

Expand Down Expand Up @@ -74,7 +74,7 @@ export const detect = (transaction: Transaction): boolean => {
export const generate = (transaction: Transaction): Transaction => {
const decoded = decodeTransactionInput(
transaction.input as Hex,
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
);
if (!decoded) return transaction;

Expand All @@ -87,7 +87,7 @@ export const generate = (transaction: Transaction): Transaction => {
const registerLog = transaction.logs?.find((log) => {
try {
const decoded = decodeLog(
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
log.data as Hex,
[log.topic0, log.topic1, log.topic2, log.topic3] as EventLogTopics,
);
Expand All @@ -101,7 +101,7 @@ export const generate = (transaction: Transaction): Transaction => {
if (registerLog) {
try {
const decoded = decodeLog(
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
registerLog.data as Hex,
[
registerLog.topic0,
Expand Down Expand Up @@ -158,7 +158,7 @@ export const generate = (transaction: Transaction): Transaction => {
const registerLog = transaction.logs?.find((log) => {
try {
const decoded = decodeLog(
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
log.data as Hex,
[log.topic0, log.topic1, log.topic2, log.topic3] as EventLogTopics,
);
Expand All @@ -172,7 +172,7 @@ export const generate = (transaction: Transaction): Transaction => {
if (registerLog) {
try {
const decoded = decodeLog(
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
registerLog.data as Hex,
[
registerLog.topic0,
Expand Down Expand Up @@ -293,7 +293,7 @@ export const generate = (transaction: Transaction): Transaction => {
const registerLog = transaction.logs?.find((log) => {
try {
const decoded = decodeLog(
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
log.data as Hex,
[log.topic0, log.topic1, log.topic2, log.topic3] as EventLogTopics,
);
Expand All @@ -307,7 +307,7 @@ export const generate = (transaction: Transaction): Transaction => {
if (registerLog) {
try {
const decoded = decodeLog(
ABIs.NounsDAOLogicV3,
ABIs.NounsDAOLogic,
registerLog.data as Hex,
[
registerLog.topic0,
Expand Down
Loading

0 comments on commit ea8150f

Please sign in to comment.