diff --git a/src/common/utils.ts b/src/common/utils.ts index 8816af3..df093ed 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -152,7 +152,7 @@ export function parseRefund(value: any): Refund { export function parseDataNft(value: NftType): DataNft { let attributes; try { - attributes = DataNft.decodeAttributes(value.attributes); + attributes = DataNft.decodeAttributes(value.attributes); // normal attributes } catch (error: any) { try { attributes = { @@ -160,8 +160,8 @@ export function parseDataNft(value: NftType): DataNft { dataStream: value.metadata?.itheum_data_stream_url ?? '', dataMarshal: value.metadata?.itheum_data_marshal_url ?? '', creator: value.metadata?.itheum_creator ?? '', - creationTime: undefined, - description: '', + creationTime: new Date(value.timestamp * 1000), + description: value.metadata?.description ?? '', isDataNFTPH: true, title: value.name }; diff --git a/src/datanft.ts b/src/datanft.ts index bb0f356..d960943 100644 --- a/src/datanft.ts +++ b/src/datanft.ts @@ -49,6 +49,7 @@ export class DataNft implements DataNftType { readonly owner: string = ''; // works if tokenIdentifier is an NFT readonly overrideDataMarshal: string = ''; readonly overrideDataMarshalChainId: string = ''; + readonly isDataNFTPH: boolean = false; static networkConfiguration: Config; static apiConfiguration: string; diff --git a/tests/bond.test.ts b/tests/bond.test.ts index f12c7d2..4f347cb 100644 --- a/tests/bond.test.ts +++ b/tests/bond.test.ts @@ -41,39 +41,39 @@ describe('Bond test', () => { const bond: Bond[] = await bondContract.viewBonds([1]); expect(bond).toMatchObject; - // const sameBond: Bond[] = await bondContract.viewBonds( - // [tokenIdentifier], - // [76] - // ); - // expect(sameBond).toMatchObject; - // const sameBond2: Bond[] = await bondContract.viewBonds([ - // createTokenIdentifier(tokenIdentifier, 76) - // ]); - // expect(sameBond2).toMatchObject; - // expect(sameBond).toStrictEqual(sameBond2); + const sameBond: Bond[] = await bondContract.viewBonds( + [tokenIdentifier], + [172] + ); + expect(sameBond).toMatchObject; + const sameBond2: Bond[] = await bondContract.viewBonds([ + createTokenIdentifier(tokenIdentifier, 172) + ]); + expect(sameBond2).toMatchObject; + expect(sameBond).toStrictEqual(sameBond2); - // const singleBond: Bond = await bondContract.viewBond(1); - // expect(singleBond).toMatchObject; - // expect(singleBond).toStrictEqual(sameBond2[0]); + const singleBond: Bond = await bondContract.viewBond(1); + expect(singleBond).toMatchObject; + expect(singleBond).toStrictEqual(sameBond2[0]); - // const pagedBonds: Bond[] = await bondContract.viewPagedBonds(0, 2); - // expect(pagedBonds).toMatchObject; - // expect(pagedBonds.length).toBe(3); - // expect(pagedBonds[0]).toStrictEqual(singleBond); + const pagedBonds: Bond[] = await bondContract.viewPagedBonds(0, 2); + expect(pagedBonds).toMatchObject; + expect(pagedBonds.length).toBe(3); + expect(pagedBonds[0]).toStrictEqual(singleBond); - // const compensation: Compensation = await bondContract.viewCompensation(1); - // expect(compensation).toMatchObject; + const compensation: Compensation = await bondContract.viewCompensation(1); + expect(compensation).toMatchObject; - // const compensations: Compensation[] = await bondContract.viewCompensations([ - // { tokenIdentifier: tokenIdentifier, nonce: 76 } - // ]); - // expect(compensations).toMatchObject; - // expect(compensations[0]).toStrictEqual(compensation); + const compensations: Compensation[] = await bondContract.viewCompensations([ + { tokenIdentifier: tokenIdentifier, nonce: 172 } + ]); + expect(compensations).toMatchObject; + expect(compensations[0]).toStrictEqual(compensation); - // const pagedCompensations: Compensation[] = - // await bondContract.viewPagedCompensations(0, 2); - // expect(pagedCompensations).toMatchObject; - // expect(pagedCompensations.length).toBe(3); - // expect(pagedCompensations[0]).toStrictEqual(compensation); + const pagedCompensations: Compensation[] = + await bondContract.viewPagedCompensations(0, 2); + expect(pagedCompensations).toMatchObject; + expect(pagedCompensations.length).toBe(3); + expect(pagedCompensations[0]).toStrictEqual(compensation); }, 20000); });