@@ -2,6 +2,7 @@ import { ConseilQueryBuilder, ConseilOperator, KeyStore, MultiAssetTokenHelper,
22import { BigNumber } from 'bignumber.js' ;
33import { JSONPath } from 'jsonpath-plus' ;
44import { proxyFetch , ImageProxyServer , ImageProxyDataType } from 'nft-image-proxy' ;
5+ import * as png from 'pngjs' ;
56
67import { NFT_ACTION_TYPES , NFT_ERRORS , NFT_PROVIDERS } from './constants' ;
78import { TransferNFTError } from './exceptions' ;
@@ -580,9 +581,38 @@ export async function getObjktNFTDetails(tezosUrl: string, objectId: number | st
580581 } ;
581582}
582583
584+ export async function get8bidouDetails ( tezosUrl : string , objectId : number | string , metadataMap : number ) {
585+ const packedNftId = TezosMessageUtils . encodeBigMapKey ( Buffer . from ( TezosMessageUtils . writePackedData ( objectId , 'int' ) , 'hex' ) ) ;
586+ const nftInfo = await TezosNodeReader . getValueForBigMapKey ( tezosUrl , metadataMap , packedNftId ) ;
587+
588+ const creatorBytes = JSONPath ( { path : '$.args[2].bytes' , json : nftInfo } ) [ 0 ] ; // $.args[1].string
589+ const descriptionBytes = JSONPath ( { path : '$.args[4].bytes' , json : nftInfo } ) [ 0 ] ;
590+ const nameBytes = JSONPath ( { path : '$.args[3].bytes' , json : nftInfo } ) [ 0 ] ;
591+ const imageDataBytes = JSONPath ( { path : '$.args[5].string' , json : nftInfo } ) [ 0 ] ;
592+
593+ const nftCreators = Buffer . from ( creatorBytes , 'hex' ) . toString ( ) ;
594+ const nftDescription = Buffer . from ( descriptionBytes , 'hex' ) . toString ( ) ;
595+ const nftName = Buffer . from ( nameBytes , 'hex' ) . toString ( ) ;
596+
597+ const image = new png . PNG ( { width : 8 , height : 8 , bitDepth : 8 , colorType : 2 , inputColorType : 2 , inputHasAlpha : false } ) ;
598+ image . data = Buffer . from ( imageDataBytes , 'hex' ) ;
599+ const buffer = png . PNG . sync . write ( image , { width : 8 , height : 8 , bitDepth : 8 , colorType : 2 , inputColorType : 2 , inputHasAlpha : false } ) ;
600+ const artifactUrl = `data:image/png;base64,${ buffer . toString ( 'base64' ) } ` ;
601+
602+ return {
603+ name : nftName ,
604+ description : nftDescription ,
605+ creators : nftCreators ,
606+ artifactUrl,
607+ artifactType : 'image/png' ,
608+ artifactModerationMessage : undefined ,
609+ thumbnailUri : artifactUrl ,
610+ } ;
611+ }
612+
583613export async function getDogamiDetails ( tezosUrl : string , objectId : number | string , metadataMap : number ) {
584614 const packedNftId = TezosMessageUtils . encodeBigMapKey ( Buffer . from ( TezosMessageUtils . writePackedData ( objectId , 'int' ) , 'hex' ) ) ;
585- const nftInfo = await TezosNodeReader . getValueForBigMapKey ( tezosUrl , metadataMap , packedNftId ) ; // TODO: store in token definition
615+ const nftInfo = await TezosNodeReader . getValueForBigMapKey ( tezosUrl , metadataMap , packedNftId ) ;
586616
587617 const artifactUrlBytes = JSONPath ( { path : '$.args[1][0].args[1].bytes' , json : nftInfo } ) [ 0 ] ;
588618 const creatorBytes = JSONPath ( { path : '$.args[1][2].args[1].bytes' , json : nftInfo } ) [ 0 ] ;
@@ -855,6 +885,9 @@ export async function getCollection(tokenAddress: string, tokenMapId: number, qu
855885 if ( metadataMapId === 115420 ) {
856886 // HACK: dogami
857887 objectDetails = await getDogamiDetails ( node . tezosUrl , objectId , metadataMapId ) ;
888+ } else if ( metadataMapId === 113218 ) {
889+ // HACK 8bidou
890+ objectDetails = await get8bidouDetails ( node . tezosUrl , objectId , metadataMapId ) ;
858891 } else {
859892 objectDetails = await getObjktNFTDetails ( node . tezosUrl , objectId , metadataMapId , urlPath ) ;
860893 }
0 commit comments