Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect contextualization #370

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/contextualizers/heuristics/erc1155Mint/erc1155Mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export function generate(transaction: Transaction): Transaction {
if (amount > 1) {
transaction.context.variables = {
...transaction.context.variables,
multipleERC11155s: {
type: AssetType.ERC1155,
token: assetTransfer.contract,
},
amount: {
type: 'number',
value: amount,
Expand All @@ -163,8 +167,8 @@ export function generate(transaction: Transaction): Transaction {
title: 'NFT Mint',
default:
sender === recipient
? '[[recipient]][[minted]][[amount]][[token]]'
: '[[sender]][[minted]][[amount]][[token]]to[[recipient]]',
? '[[recipient]][[minted]][[amount]][[multipleERC11155s]]'
: '[[sender]][[minted]][[amount]][[multipleERC11155s]]to[[recipient]]',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ponyjackal We should merge amount and multipleERC11155s into one variable of type ERC1155, which contains the amount and the token contract

},
};
if (hasPrice) {
Expand Down
19 changes: 19 additions & 0 deletions src/contextualizers/protocol/zoraCreator/zoraCreator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { detect, generate } from './zoraCreator';
import { containsBigInt, contextSummary } from '../../../helpers/utils';
import mintWithRewards0x6ccb3140 from '../../test/transactions/mintWithRewards-0x6ccb3140.json';
import zoraMintWithRewards0x837a9a69 from '../../test/transactions/zoraMintWithRewards-0x837a9a69.json';
import zoraMint0x9f62a82c from '../../test/transactions/zoraMint-0x9f62a82c.json';
import catchall0xc35c01ac from '../../test/transactions/catchall-0xc35c01ac.json';

describe('Zora Mint', () => {
Expand All @@ -16,6 +17,11 @@ describe('Zora Mint', () => {
zoraMintWithRewards0x837a9a69 as unknown as Transaction,
);
expect(zoraMintWithRewards2).toBe(true);

const zoraMintWithRewards3 = detect(
zoraMint0x9f62a82c as unknown as Transaction,
);
expect(zoraMintWithRewards3).toBe(true);
});

it('Should generate context for mintWithRewards transaction', () => {
Expand Down Expand Up @@ -44,6 +50,19 @@ describe('Zora Mint', () => {
'0xf70da97812cb96acdf810712aa562db8dfa3dbef MINTED 1 0xf41a3e3033d4e878943194b729aec993a4ea2045 #29 to 0xd97622b57112f82a0db8b1aee08e37aa6b4b2a03 for 0.000777 ETH with 0.000111 ETH in rewards for 0xecfc2ee50409e459c554a2b0376f882ce916d853',
);
expect(containsBigInt(zoraMintWithRewards2.context)).toBe(false);

const zoraMintWithRewards3 = generate(
zoraMint0x9f62a82c as unknown as Transaction,
);
expect(zoraMintWithRewards3.context?.summaries?.category).toBe(
'PROTOCOL_1',
);
expect(zoraMintWithRewards3.context?.summaries?.en.title).toBe('Zora');
const desc3 = contextSummary(zoraMintWithRewards3.context);
expect(desc3).toBe(
'0x74b78e98093f5b522a7ebdac3b994641ca7c2b20 MINTED 28 x 0x878dd96c70b1bef2d1a4c307266579cb958cbf04 for 0.021756 ETH with 0.000111 ETH in rewards for 0x7bf90111ad7c22bec9e9dff8a01a44713cc1b1b6',
);
expect(containsBigInt(zoraMintWithRewards3.context)).toBe(false);
});

it('Should not detect as zora creator', () => {
Expand Down
Loading
Loading