Skip to content

Commit

Permalink
fix: update netAssetTransfers
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyjackal committed Mar 22, 2024
1 parent 1e244d9 commit e54b37f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
30 changes: 25 additions & 5 deletions src/transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ describe('transformations', () => {
if (tx1) {
const netAssetTransfers = tx1.netAssetTransfers;
expect(Object.keys(netAssetTransfers).length).toBe(3);

expect(
netAssetTransfers['0xd1d507b688b518d2b7a4f65007799a5e9d80e974'].sent
.length,
Expand All @@ -388,13 +389,12 @@ describe('transformations', () => {
{
contract: '0x0000000000a39bb272e79075ade125fd351887ac',
type: 'erc20',
value: '1313400000000000000',
value: '6600000000000000',
},
]);

expect(
netAssetTransfers['0x2d89cc4e013db2908b877c51d39ff63982761c96'].sent
.length,
netAssetTransfers['0x2d89cc4e013db2908b877c51d39ff63982761c96'].sent,
).toStrictEqual([
{
contract: '0x23581767a106ae21c074b2276d25e5c3e136a68b',
Expand All @@ -409,7 +409,27 @@ describe('transformations', () => {
{
contract: '0x0000000000a39bb272e79075ade125fd351887ac',
type: 'erc20',
value: '6600000000000000',
value: '1313400000000000000',
},
]);

expect(
netAssetTransfers['0x4974a7af396d1908cac650bb923f4bd8dd4047c2']
.received,
).toStrictEqual([
{
contract: '0x23581767a106ae21c074b2276d25e5c3e136a68b',
type: 'erc721',
tokenId: '2281',
},
]);
expect(
netAssetTransfers['0x4974a7af396d1908cac650bb923f4bd8dd4047c2'].sent,
).toStrictEqual([
{
contract: '0x0000000000a39bb272e79075ade125fd351887ac',
type: 'erc20',
value: '1320000000000000000',
},
]);
}
Expand All @@ -432,7 +452,7 @@ describe('transformations', () => {
expect(Object.keys(ckTransfers).length).toBe(3);
expect(
ckTransfers['0x82f8cb7e198972e2ef89e0c0cc10ffbd878792a6'].sent,
).toStrictEqual([{ type: 'eth', value: '9750000000000000' }]);
).toStrictEqual([{ type: 'eth', value: '10000000000000000' }]);
expect(
ckTransfers['0x82f8cb7e198972e2ef89e0c0cc10ffbd878792a6'].received,
).toStrictEqual([
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/_common/netAssetTransfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ export function extractNetAssetTransfers(
}

if (value < BigInt(0)) {
netAssetTransfers[address].sent.push(assetTransferred);
netAssetTransfers[address].sent.push({ ...assetTransferred });
} else {
netAssetTransfers[address].received.push(assetTransferred);
netAssetTransfers[address].received.push({ ...assetTransferred });
}
}
}
Expand Down

0 comments on commit e54b37f

Please sign in to comment.