@rabbitholegg/questdk
Advanced tools
Comparing version 2.0.0-alpha.42 to 2.0.0-alpha.43
@@ -6,2 +6,3 @@ "use strict"; | ||
const viem_1 = require("viem"); | ||
const nft_js_1 = require("../tokens/nft.js"); | ||
function boost(rpcUrl) { | ||
@@ -18,2 +19,4 @@ const client = (0, viem_1.createClient)({ | ||
fetchERC1155MetadataByUUID: (uuid) => (0, erc1155_js_1.fetchERC1155MetadataByUUID)(client, uuid), | ||
fetchTokenMetadata: (contractAddress, tokenId) => (0, nft_js_1.fetchTokenMetadata)(client, contractAddress, tokenId), | ||
fetchTokenMetadataByUUID: (uuid) => (0, nft_js_1.fetchTokenMetadataByUUID)(client, uuid), | ||
}; | ||
@@ -20,0 +23,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fetchQuestActionParams = void 0; | ||
exports.fetchQuestByUUID = exports.fetchQuestActionParams = void 0; | ||
const axios_1 = require("axios"); | ||
async function fetchQuestActionParams(uuid) { | ||
const quest = await fetchQuestByUUID(uuid); | ||
if (!quest.actionParams) | ||
throw new Error('Quest does not have action parameters'); | ||
return quest.actionParams; | ||
} | ||
exports.fetchQuestActionParams = fetchQuestActionParams; | ||
async function fetchQuestByUUID(uuid) { | ||
const endpoint = `https://api.rabbithole.gg/v1.2/quest/public/${uuid}`; | ||
console.log('Fetching quest data from:', endpoint); | ||
try { | ||
const response = await axios_1.default.get(endpoint); | ||
const actionParams = response.data.actionParams; | ||
return actionParams; | ||
const response = await axios_1.default.get(endpoint, { | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
return response.data; | ||
} | ||
@@ -17,4 +29,4 @@ catch (error) { | ||
} | ||
exports.fetchQuestActionParams = fetchQuestActionParams; | ||
exports.fetchQuestByUUID = fetchQuestByUUID; | ||
exports.default = fetchQuestActionParams; | ||
//# sourceMappingURL=fetchQuestData.js.map |
@@ -31,2 +31,5 @@ "use strict"; | ||
const tokenId = actionParams.data.tokenId; | ||
if (!contractAddress || !tokenId) { | ||
throw new Error('Quest action is missing contract address or token ID'); | ||
} | ||
return fetchERC1155Metadata(client, contractAddress, tokenId); | ||
@@ -33,0 +36,0 @@ } |
@@ -31,2 +31,5 @@ "use strict"; | ||
const tokenId = actionParams.data.tokenId; | ||
if (!contractAddress || !tokenId) { | ||
throw new Error('Invalid mint action params'); | ||
} | ||
return fetchERC721Metadata(client, contractAddress, tokenId); | ||
@@ -33,0 +36,0 @@ } |
import { fetchERC721Media, fetchERC721Metadata, fetchERC721MetadataByUUID, } from '../tokens/erc721.js'; | ||
import { fetchERC1155Media, fetchERC1155Metadata, fetchERC1155MetadataByUUID, } from '../tokens/erc1155.js'; | ||
import { createClient, http } from 'viem'; | ||
import { fetchTokenMetadata, fetchTokenMetadataByUUID } from '../tokens/nft.js'; | ||
/** | ||
@@ -20,2 +21,4 @@ * Initializes an Ethereum client with the specified RPC URL and provides methods for ERC721 and ERC1155 token interactions. | ||
fetchERC1155MetadataByUUID: (uuid) => fetchERC1155MetadataByUUID(client, uuid), | ||
fetchTokenMetadata: (contractAddress, tokenId) => fetchTokenMetadata(client, contractAddress, tokenId), | ||
fetchTokenMetadataByUUID: (uuid) => fetchTokenMetadataByUUID(client, uuid), | ||
}; | ||
@@ -22,0 +25,0 @@ } |
import axios from 'axios'; | ||
import {} from '@rabbitholegg/questdk-plugin-utils'; | ||
/** | ||
@@ -8,7 +9,18 @@ * Fetches quest data from RabbitHole API and extracts action parameters. | ||
export async function fetchQuestActionParams(uuid) { | ||
const quest = await fetchQuestByUUID(uuid); | ||
if (!quest.actionParams) | ||
throw new Error('Quest does not have action parameters'); | ||
return quest.actionParams; | ||
} | ||
export async function fetchQuestByUUID(uuid) { | ||
const endpoint = `https://api.rabbithole.gg/v1.2/quest/public/${uuid}`; | ||
console.log('Fetching quest data from:', endpoint); | ||
try { | ||
const response = await axios.get(endpoint); | ||
const actionParams = response.data.actionParams; | ||
return actionParams; | ||
const response = await axios.get(endpoint, { | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
return response.data; | ||
} | ||
@@ -15,0 +27,0 @@ catch (error) { |
@@ -49,4 +49,7 @@ import fetchQuestActionParams from '../quests/fetchQuestData.js'; | ||
const tokenId = actionParams.data.tokenId; | ||
if (!contractAddress || !tokenId) { | ||
throw new Error('Quest action is missing contract address or token ID'); | ||
} | ||
return fetchERC1155Metadata(client, contractAddress, tokenId); | ||
} | ||
//# sourceMappingURL=erc1155.js.map |
@@ -50,4 +50,7 @@ import fetchQuestActionParams from '../quests/fetchQuestData.js'; | ||
const tokenId = actionParams.data.tokenId; | ||
if (!contractAddress || !tokenId) { | ||
throw new Error('Invalid mint action params'); | ||
} | ||
return fetchERC721Metadata(client, contractAddress, tokenId); | ||
} | ||
//# sourceMappingURL=erc721.js.map |
@@ -13,4 +13,6 @@ /** | ||
fetchERC1155MetadataByUUID: (uuid: string) => Promise<any>; | ||
fetchTokenMetadata: (contractAddress: string, tokenId: number) => Promise<any>; | ||
fetchTokenMetadataByUUID: (uuid: string) => Promise<any>; | ||
}; | ||
export default boost; | ||
//# sourceMappingURL=boost.d.ts.map |
@@ -0,1 +1,2 @@ | ||
import { type QuestActionParamsByType, type QuestDetails } from '@rabbitholegg/questdk-plugin-utils'; | ||
/** | ||
@@ -6,4 +7,5 @@ * Fetches quest data from RabbitHole API and extracts action parameters. | ||
*/ | ||
export declare function fetchQuestActionParams(uuid: string): Promise<any>; | ||
export declare function fetchQuestActionParams(uuid: string): Promise<QuestActionParamsByType>; | ||
export declare function fetchQuestByUUID(uuid: string): Promise<QuestDetails>; | ||
export default fetchQuestActionParams; | ||
//# sourceMappingURL=fetchQuestData.d.ts.map |
{ | ||
"name": "@rabbitholegg/questdk", | ||
"description": "", | ||
"version": "2.0.0-alpha.42", | ||
"version": "2.0.0-alpha.43", | ||
"files": [ | ||
@@ -6,0 +6,0 @@ "dist", |
@@ -12,2 +12,3 @@ import { | ||
import { type PublicClient, createClient, http } from 'viem' | ||
import { fetchTokenMetadata, fetchTokenMetadataByUUID } from '../tokens/nft.js' | ||
/** | ||
@@ -36,2 +37,6 @@ * Initializes an Ethereum client with the specified RPC URL and provides methods for ERC721 and ERC1155 token interactions. | ||
fetchERC1155MetadataByUUID(client, uuid), | ||
fetchTokenMetadata: (contractAddress: string, tokenId: number) => | ||
fetchTokenMetadata(client, contractAddress, tokenId), | ||
fetchTokenMetadataByUUID: (uuid: string) => | ||
fetchTokenMetadataByUUID(client, uuid), | ||
} | ||
@@ -38,0 +43,0 @@ } |
import axios from 'axios' | ||
import { | ||
type QuestActionParamsByType, | ||
type QuestDetails, | ||
} from '@rabbitholegg/questdk-plugin-utils' | ||
/** | ||
@@ -8,9 +11,22 @@ * Fetches quest data from RabbitHole API and extracts action parameters. | ||
*/ | ||
export async function fetchQuestActionParams(uuid: string): Promise<any> { | ||
export async function fetchQuestActionParams( | ||
uuid: string, | ||
): Promise<QuestActionParamsByType> { | ||
const quest = await fetchQuestByUUID(uuid) | ||
if (!quest.actionParams) | ||
throw new Error('Quest does not have action parameters') | ||
return quest.actionParams | ||
} | ||
export async function fetchQuestByUUID(uuid: string): Promise<QuestDetails> { | ||
const endpoint = `https://api.rabbithole.gg/v1.2/quest/public/${uuid}` | ||
console.log('Fetching quest data from:', endpoint) | ||
try { | ||
const response = await axios.get(endpoint) | ||
const actionParams = response.data.actionParams | ||
return actionParams | ||
const response = await axios.get(endpoint, { | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
return response.data | ||
} catch (error) { | ||
@@ -17,0 +33,0 @@ console.error('Error fetching quest data:', error) |
@@ -64,3 +64,6 @@ import fetchQuestActionParams from '../quests/fetchQuestData.js' | ||
const tokenId = actionParams.data.tokenId | ||
if (!contractAddress || !tokenId) { | ||
throw new Error('Quest action is missing contract address or token ID') | ||
} | ||
return fetchERC1155Metadata(client, contractAddress, tokenId) | ||
} |
@@ -65,3 +65,6 @@ import fetchQuestActionParams from '../quests/fetchQuestData.js' | ||
const tokenId = actionParams.data.tokenId | ||
if (!contractAddress || !tokenId) { | ||
throw new Error('Invalid mint action params') | ||
} | ||
return fetchERC721Metadata(client, contractAddress, tokenId) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145406
120
2431