Skip to content

Commit

Permalink
fix: assetTransfersOldNFTs
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyjackal committed Feb 27, 2024
1 parent cc46e37 commit 90c2a91
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/blocks/ethereum/18815007_decoded.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/transformers/ethereum/assetTransfersOldNFTs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,32 @@ describe('transactionAssetTransfersOldNFTs', () => {
}
}
});

it('should return asset transfers for Cryptokitties transactions', () => {
// Sorted combo transfers
const cryptoKittiesBlock = loadBlockFixture('ethereum', '18815007_decoded');
const cryptoKittiesAssetResult =
transactionAssetTransfers(cryptoKittiesBlock);
const cryptoKittiesResult = transform(cryptoKittiesAssetResult);
const cryptoKittiesTx = cryptoKittiesResult.transactions.find(
(tx) =>
tx.hash ===
'0x76a07f3f822f6235372804b2ffab705a79b89dbe6a15ad086b6879aa97d60321',
);
expect(cryptoKittiesTx).toBeDefined();
if (cryptoKittiesTx) {
const cryptoKittiesTransfers = cryptoKittiesTx.assetTransfers;
expect(cryptoKittiesTransfers.length).toBe(1);
if ('tokenId' in cryptoKittiesTransfers[0]) {
expect(cryptoKittiesTransfers[0].tokenId).toBe('2020925');
expect(cryptoKittiesTransfers[0].from).toBe(
'0xd695429819d9dd942b2485c3dedd141a774fc774',
);
expect(cryptoKittiesTransfers[0].to).toBe(
'0x82f8cb7e198972e2ef89e0c0cc10ffbd878792a6',
);
}
expect(cryptoKittiesTransfers[0].type).toBe('erc721');
}
});
});
4 changes: 2 additions & 2 deletions src/transformers/ethereum/assetTransfersOldNFTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ function updateTokenTransfers(tx: RawTransaction) {
if (logDescriptor) {
oldNFTsTransfers.push({
asset: log.address,
from: decodeEVMAddress(logDescriptor.args['from']),
to: decodeEVMAddress(logDescriptor.args['to']),
from: logDescriptor.args['from'].toLowerCase(),
to: logDescriptor.args['to'].toLowerCase(),
tokenId: BigInt(logDescriptor.args['value']).toString(),
type: AssetType.ERC721,
});
Expand Down

0 comments on commit 90c2a91

Please sign in to comment.