Skip to content

Commit 6f5382b

Browse files
authored
Merge pull request #63 from pbkompasz/62-fix-highlight
Fix Highlight Base Ingestor
2 parents 24f9305 + a580156 commit 6f5382b

File tree

5 files changed

+56
-37
lines changed

5 files changed

+56
-37
lines changed

src/dry-run/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,16 @@ const resources = mintIngestorResources();
5959
if (simulationResult.success) {
6060
console.log('✅ Simulation Success');
6161
} else {
62-
console.log('❌ Simulation Failed');
63-
console.log(JSON.stringify(simulationResult, null, 2));
62+
const totalCalls = simulationResult.rawSimulationResult.calls.length;
63+
const failedCalls = simulationResult.rawSimulationResult.calls.filter(
64+
(call: { error: any }) => call.error,
65+
).length;
66+
if (totalCalls - failedCalls > 0) {
67+
console.log(`✅ Although one or more (${failedCalls}) Error Occurred [execution reverted] Contract Execution Completed`);
68+
} else {
69+
console.log('❌ Simulation Failed');
70+
}
71+
console.log(JSON.stringify(simulationResult, null, 2));
6472
}
6573
} catch (error) {
6674
console.error(error);

src/ingestors/highlight/index.ts

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,32 @@ const CONTRACT_ADDRESS = '0x8087039152c472Fa74F47398628fF002994056EA';
1515

1616
export class HighlightIngestor implements MintIngestor {
1717
async supportsUrl(resources: MintIngestorResources, url: string): Promise<boolean> {
18-
return false;
19-
// const id = url.split('/').pop();
20-
// if (!id) {
21-
// return false;
22-
// }
23-
24-
// const collection = await getHighlightCollectionById(resources, id);
25-
26-
// if (!collection || collection.chainId !== 8453) {
27-
// return false;
28-
// }
29-
30-
// const urlPattern = /^https:\/\/highlight\.xyz\/mint\/[a-f0-9]{24}$/;
31-
// return (
32-
// new URL(url).hostname === 'www.highlight.xyz' || new URL(url).hostname === 'highlight.xyz' || urlPattern.test(url)
33-
// );
18+
const id = url.split('/').pop();
19+
if (!id) {
20+
return false;
21+
}
22+
23+
const collection = await getHighlightCollectionById(resources, id);
24+
25+
if (!collection || collection.chainId !== 8453) {
26+
return false;
27+
}
28+
29+
const urlPattern = /^https:\/\/highlight\.xyz\/mint\/[a-f0-9]{24}$/;
30+
return (
31+
new URL(url).hostname === 'www.highlight.xyz' || new URL(url).hostname === 'highlight.xyz' || urlPattern.test(url)
32+
);
3433
}
3534

3635
async supportsContract(resources: MintIngestorResources, contractOptions: MintContractOptions): Promise<boolean> {
37-
return false;
38-
// if (contractOptions.chainId !== 8453) {
39-
// return false;
40-
// }
41-
// const collection = await getHighlightCollectionByAddress(resources, contractOptions);
42-
// if (!collection) {
43-
// return false;
44-
// }
45-
// return true;
36+
if (contractOptions.chainId !== 8453) {
37+
return false;
38+
}
39+
const collection = await getHighlightCollectionByAddress(resources, contractOptions);
40+
if (!collection) {
41+
return false;
42+
}
43+
return true;
4644
}
4745

4846
async createMintForContract(
@@ -82,7 +80,7 @@ export class HighlightIngestor implements MintIngestor {
8280
throw new MintIngestorError(MintIngestionErrorName.MissingRequiredData, 'Error finding creator');
8381
}
8482

85-
const collectionId = collection.highlightCollection?.id || collection.id;
83+
const collectionId = collection.id || collection.highlightCollection?.id;
8684

8785
if (!collectionId) {
8886
throw new MintIngestorError(MintIngestionErrorName.MissingRequiredData, 'Collection id not available');
@@ -95,7 +93,7 @@ export class HighlightIngestor implements MintIngestor {
9593
imageUrl: creator?.creatorAccountSettings?.displayAvatar,
9694
});
9795

98-
mintBuilder.setMintOutputContract({ chainId: 8453, address: collection.highlightCollection.address });
96+
mintBuilder.setMintOutputContract({ chainId: 8453, address: collection.primaryContract });
9997

10098
const vectorId = await getHighlightVectorId(resources, collectionId);
10199

src/ingestors/highlight/offchain-metadata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const getHighlightVectorId = async (resources: MintIngestorResources, id:
7979
const data = {
8080
operationName: 'GetCollectionSaleDetails',
8181
variables: {
82-
collectionId: id,
82+
collectionId: `base:${id}`,
8383
},
8484
query: `
8585
query GetCollectionSaleDetails($collectionId: String!) {
@@ -123,7 +123,7 @@ export const getHighlightCollectionOwnerDetails = async (resources: MintIngestor
123123
operationName: 'GetCollectionCreatorDetails',
124124
variables: {
125125
withEns: true,
126-
collectionId: id,
126+
collectionId: `base:${id}`,
127127
},
128128
query: `query GetCollectionCreatorDetails($collectionId: String!, $withEns: Boolean) {
129129
getPublicCollectionDetails(collectionId: $collectionId) {

src/ingestors/highlight/types.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ export type CollectionByAddress2 = {
4040
};
4141
};
4242

43-
export type CollectionByAddress = CollectionByAddress1 & CollectionByAddress2;
43+
export type CollectionByAddress3 = {
44+
collection: {
45+
// Collection address
46+
id: string;
47+
name: string;
48+
creator: string;
49+
image: string;
50+
animationUrl: string;
51+
address: string;
52+
};
53+
primaryContract: string;
54+
};
55+
56+
export type CollectionByAddress = CollectionByAddress1 & CollectionByAddress2 & CollectionByAddress3;

test/ingestors/highlight.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { basicIngestorTests } from '../shared/basic-ingestor-tests';
77

88
const resources = mintIngestorResources();
99

10-
describe.skip('highlight', function () {
10+
describe('highlight', function () {
1111
basicIngestorTests(
1212
new HighlightIngestor(),
1313
resources,
@@ -64,8 +64,8 @@ describe.skip('highlight', function () {
6464
expect(template.description).to.contain('3,333 Based Fren$ muy basados');
6565
const mintInstructions = template.mintInstructions as EVMMintInstructions;
6666

67-
expect(mintInstructions.contractAddress).to.equal('0x8087039152c472Fa74F47398628fF002994056EA');
68-
expect(template.mintOutputContract?.address).to.equal('0x0E5DDe3De7cf2761d8a81Ee68F48410425e2dBbA');
67+
expect(mintInstructions.contractAddress.toLowerCase()).to.equal('0x8087039152c472Fa74F47398628fF002994056EA'.toLowerCase());
68+
expect(template.mintOutputContract?.address.toLowerCase()).to.equal('0x0E5DDe3De7cf2761d8a81Ee68F48410425e2dBbA'.toLowerCase());
6969
expect(mintInstructions.contractMethod).to.equal('vectorMint721');
7070
expect(mintInstructions.contractParams).to.equal('[1176, quantity, address]');
7171
expect(mintInstructions.priceWei).to.equal('800000000000000');
@@ -87,7 +87,7 @@ describe.skip('highlight', function () {
8787
expect(template.availableForPurchaseEnd?.getTime()).to.equal(+new Date(1893456000000));
8888
});
8989

90-
it.skip('createMintTemplateForUrl: Returns a mint template for a supported URL with free price', async function () {
90+
it('createMintTemplateForUrl: Returns a mint template for a supported URL with free price', async function () {
9191
const ingestor = new HighlightIngestor();
9292
const url = 'https://highlight.xyz/mint/66744e64e610ed36adeb1a64';
9393
const resources = mintIngestorResources();
@@ -103,7 +103,7 @@ describe.skip('highlight', function () {
103103

104104
expect(mintInstructions.contractAddress).to.equal('0x8087039152c472Fa74F47398628fF002994056EA');
105105
expect(mintInstructions.contractMethod).to.equal('vectorMint721');
106-
expect(mintInstructions.contractParams).to.equal('[977, 1, address]');
106+
expect(mintInstructions.contractParams).to.equal('[977, quantity, address]');
107107
expect(mintInstructions.priceWei).to.equal('800000000000000');
108108

109109
expect(template.featuredImageUrl).to.equal(

0 commit comments

Comments
 (0)