Skip to content

Commit af37e74

Browse files
authored
feat: Update DFK Decoders (#53)
1 parent 9439d39 commit af37e74

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

services/decoder/protocols/defi-kingdoms/defi-kingdoms.decoders.ts

+42-6
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,55 @@ GoldRushDecoder.on(
3939
};
4040
};
4141

42+
const date = timestampParser(tx.block_signed_at, "YYYY-MM-DD");
43+
44+
const { data: PetNFT } =
45+
await covalent_client.NftService.getNftMetadataForGivenTokenIdForContract(
46+
chain_name,
47+
// * INFO: Hero NFT Contract Address
48+
"0x1990F87d6BC9D9385917E3EDa0A7674411C3Cd7F",
49+
decoded.petId.toString(),
50+
{
51+
withUncached: true,
52+
}
53+
);
54+
55+
const nfts: EventNFTs = [
56+
{
57+
heading: `Pet ID: ${decoded.petId.toString()}`,
58+
collection_address: PetNFT?.items?.[0]?.contract_address,
59+
collection_name:
60+
PetNFT?.items?.[0]?.nft_data?.external_data?.name || null,
61+
token_identifier: decoded.petId.toString(),
62+
images: {
63+
default:
64+
PetNFT?.items?.[0]?.nft_data?.external_data?.image ||
65+
null,
66+
256:
67+
PetNFT?.items?.[0]?.nft_data?.external_data
68+
?.image_256 || null,
69+
512:
70+
PetNFT?.items?.[0]?.nft_data?.external_data
71+
?.image_512 || null,
72+
1024:
73+
PetNFT?.items?.[0]?.nft_data?.external_data
74+
?.image_1024 || null,
75+
},
76+
},
77+
];
78+
4279
const details: EventDetails = [
4380
{
4481
heading: "Fed By",
4582
value: decoded.fedBy,
4683
type: "address",
4784
},
48-
{
49-
heading: "Pet ID",
50-
value: decoded.petId.toString(),
51-
type: "text",
52-
},
5385
{
5486
heading: "Food Type",
55-
value: decoded.foodType.toString(),
87+
value:
88+
Number(decoded.foodType) === 1
89+
? "Premium Pet Treat"
90+
: "Regular Pet Treat",
5691
type: "text",
5792
},
5893
{
@@ -75,6 +110,7 @@ GoldRushDecoder.on(
75110
},
76111
...(options.raw_logs ? { raw_log: log_event } : {}),
77112
details,
113+
nfts,
78114
};
79115
}
80116
);

services/decoder/protocols/defi-kingdoms/defi-kingdoms.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ describe("defi-kingdoms", () => {
1717
if (!event) {
1818
throw Error("Event not found");
1919
}
20-
expect(event?.details?.length).toEqual(4);
20+
if (event.nfts) {
21+
expect(event.nfts?.length).toBeGreaterThan(0);
22+
}
23+
expect(event?.details?.length).toEqual(3);
2124
});
2225

2326
test("defi-kingdoms-mainnet:Auction Created", async () => {

0 commit comments

Comments
 (0)