Skip to content

Commit

Permalink
Merge pull request #122 from Itheum/d-david
Browse files Browse the repository at this point in the history
fix: data nft ph parse new values
  • Loading branch information
damienen authored Mar 28, 2024
2 parents 20f7d04 + af3a24b commit 4b55d98
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ 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 = {
dataPreview: value.metadata?.itheum_data_preview_url ?? '',
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
};
Expand Down
1 change: 1 addition & 0 deletions src/datanft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
58 changes: 29 additions & 29 deletions tests/bond.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,39 @@ describe('Bond test', () => {

const bond: Bond[] = await bondContract.viewBonds([1]);
expect(bond).toMatchObject<Bond>;
// const sameBond: Bond[] = await bondContract.viewBonds(
// [tokenIdentifier],
// [76]
// );
// expect(sameBond).toMatchObject<Bond[]>;
// const sameBond2: Bond[] = await bondContract.viewBonds([
// createTokenIdentifier(tokenIdentifier, 76)
// ]);
// expect(sameBond2).toMatchObject<Bond[]>;
// expect(sameBond).toStrictEqual(sameBond2);
const sameBond: Bond[] = await bondContract.viewBonds(
[tokenIdentifier],
[172]
);
expect(sameBond).toMatchObject<Bond[]>;
const sameBond2: Bond[] = await bondContract.viewBonds([
createTokenIdentifier(tokenIdentifier, 172)
]);
expect(sameBond2).toMatchObject<Bond[]>;
expect(sameBond).toStrictEqual(sameBond2);

// const singleBond: Bond = await bondContract.viewBond(1);
// expect(singleBond).toMatchObject<Bond>;
// expect(singleBond).toStrictEqual(sameBond2[0]);
const singleBond: Bond = await bondContract.viewBond(1);
expect(singleBond).toMatchObject<Bond>;
expect(singleBond).toStrictEqual(sameBond2[0]);

// const pagedBonds: Bond[] = await bondContract.viewPagedBonds(0, 2);
// expect(pagedBonds).toMatchObject<Bond[]>;
// expect(pagedBonds.length).toBe(3);
// expect(pagedBonds[0]).toStrictEqual(singleBond);
const pagedBonds: Bond[] = await bondContract.viewPagedBonds(0, 2);
expect(pagedBonds).toMatchObject<Bond[]>;
expect(pagedBonds.length).toBe(3);
expect(pagedBonds[0]).toStrictEqual(singleBond);

// const compensation: Compensation = await bondContract.viewCompensation(1);
// expect(compensation).toMatchObject<Compensation>;
const compensation: Compensation = await bondContract.viewCompensation(1);
expect(compensation).toMatchObject<Compensation>;

// const compensations: Compensation[] = await bondContract.viewCompensations([
// { tokenIdentifier: tokenIdentifier, nonce: 76 }
// ]);
// expect(compensations).toMatchObject<Compensation[]>;
// expect(compensations[0]).toStrictEqual(compensation);
const compensations: Compensation[] = await bondContract.viewCompensations([
{ tokenIdentifier: tokenIdentifier, nonce: 172 }
]);
expect(compensations).toMatchObject<Compensation[]>;
expect(compensations[0]).toStrictEqual(compensation);

// const pagedCompensations: Compensation[] =
// await bondContract.viewPagedCompensations(0, 2);
// expect(pagedCompensations).toMatchObject<Compensation[]>;
// expect(pagedCompensations.length).toBe(3);
// expect(pagedCompensations[0]).toStrictEqual(compensation);
const pagedCompensations: Compensation[] =
await bondContract.viewPagedCompensations(0, 2);
expect(pagedCompensations).toMatchObject<Compensation[]>;
expect(pagedCompensations.length).toBe(3);
expect(pagedCompensations[0]).toStrictEqual(compensation);
}, 20000);
});

0 comments on commit 4b55d98

Please sign in to comment.