Skip to content

Commit

Permalink
Merge pull request #63 from pbkompasz/62-fix-highlight
Browse files Browse the repository at this point in the history
Fix Highlight Base Ingestor
  • Loading branch information
chrismaddern authored Dec 4, 2024
2 parents 24f9305 + a580156 commit 6f5382b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 37 deletions.
12 changes: 10 additions & 2 deletions src/dry-run/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ const resources = mintIngestorResources();
if (simulationResult.success) {
console.log('✅ Simulation Success');
} else {
console.log('❌ Simulation Failed');
console.log(JSON.stringify(simulationResult, null, 2));
const totalCalls = simulationResult.rawSimulationResult.calls.length;
const failedCalls = simulationResult.rawSimulationResult.calls.filter(
(call: { error: any }) => call.error,
).length;
if (totalCalls - failedCalls > 0) {
console.log(`✅ Although one or more (${failedCalls}) Error Occurred [execution reverted] Contract Execution Completed`);
} else {
console.log('❌ Simulation Failed');
}
console.log(JSON.stringify(simulationResult, null, 2));
}
} catch (error) {
console.error(error);
Expand Down
52 changes: 25 additions & 27 deletions src/ingestors/highlight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,32 @@ const CONTRACT_ADDRESS = '0x8087039152c472Fa74F47398628fF002994056EA';

export class HighlightIngestor implements MintIngestor {
async supportsUrl(resources: MintIngestorResources, url: string): Promise<boolean> {
return false;
// const id = url.split('/').pop();
// if (!id) {
// return false;
// }

// const collection = await getHighlightCollectionById(resources, id);

// if (!collection || collection.chainId !== 8453) {
// return false;
// }

// const urlPattern = /^https:\/\/highlight\.xyz\/mint\/[a-f0-9]{24}$/;
// return (
// new URL(url).hostname === 'www.highlight.xyz' || new URL(url).hostname === 'highlight.xyz' || urlPattern.test(url)
// );
const id = url.split('/').pop();
if (!id) {
return false;
}

const collection = await getHighlightCollectionById(resources, id);

if (!collection || collection.chainId !== 8453) {
return false;
}

const urlPattern = /^https:\/\/highlight\.xyz\/mint\/[a-f0-9]{24}$/;
return (
new URL(url).hostname === 'www.highlight.xyz' || new URL(url).hostname === 'highlight.xyz' || urlPattern.test(url)
);
}

async supportsContract(resources: MintIngestorResources, contractOptions: MintContractOptions): Promise<boolean> {
return false;
// if (contractOptions.chainId !== 8453) {
// return false;
// }
// const collection = await getHighlightCollectionByAddress(resources, contractOptions);
// if (!collection) {
// return false;
// }
// return true;
if (contractOptions.chainId !== 8453) {
return false;
}
const collection = await getHighlightCollectionByAddress(resources, contractOptions);
if (!collection) {
return false;
}
return true;
}

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

const collectionId = collection.highlightCollection?.id || collection.id;
const collectionId = collection.id || collection.highlightCollection?.id;

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

mintBuilder.setMintOutputContract({ chainId: 8453, address: collection.highlightCollection.address });
mintBuilder.setMintOutputContract({ chainId: 8453, address: collection.primaryContract });

const vectorId = await getHighlightVectorId(resources, collectionId);

Expand Down
4 changes: 2 additions & 2 deletions src/ingestors/highlight/offchain-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const getHighlightVectorId = async (resources: MintIngestorResources, id:
const data = {
operationName: 'GetCollectionSaleDetails',
variables: {
collectionId: id,
collectionId: `base:${id}`,
},
query: `
query GetCollectionSaleDetails($collectionId: String!) {
Expand Down Expand Up @@ -123,7 +123,7 @@ export const getHighlightCollectionOwnerDetails = async (resources: MintIngestor
operationName: 'GetCollectionCreatorDetails',
variables: {
withEns: true,
collectionId: id,
collectionId: `base:${id}`,
},
query: `query GetCollectionCreatorDetails($collectionId: String!, $withEns: Boolean) {
getPublicCollectionDetails(collectionId: $collectionId) {
Expand Down
15 changes: 14 additions & 1 deletion src/ingestors/highlight/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@ export type CollectionByAddress2 = {
};
};

export type CollectionByAddress = CollectionByAddress1 & CollectionByAddress2;
export type CollectionByAddress3 = {
collection: {
// Collection address
id: string;
name: string;
creator: string;
image: string;
animationUrl: string;
address: string;
};
primaryContract: string;
};

export type CollectionByAddress = CollectionByAddress1 & CollectionByAddress2 & CollectionByAddress3;
10 changes: 5 additions & 5 deletions test/ingestors/highlight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { basicIngestorTests } from '../shared/basic-ingestor-tests';

const resources = mintIngestorResources();

describe.skip('highlight', function () {
describe('highlight', function () {
basicIngestorTests(
new HighlightIngestor(),
resources,
Expand Down Expand Up @@ -64,8 +64,8 @@ describe.skip('highlight', function () {
expect(template.description).to.contain('3,333 Based Fren$ muy basados');
const mintInstructions = template.mintInstructions as EVMMintInstructions;

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

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

expect(mintInstructions.contractAddress).to.equal('0x8087039152c472Fa74F47398628fF002994056EA');
expect(mintInstructions.contractMethod).to.equal('vectorMint721');
expect(mintInstructions.contractParams).to.equal('[977, 1, address]');
expect(mintInstructions.contractParams).to.equal('[977, quantity, address]');
expect(mintInstructions.priceWei).to.equal('800000000000000');

expect(template.featuredImageUrl).to.equal(
Expand Down

0 comments on commit 6f5382b

Please sign in to comment.