Skip to content

Commit

Permalink
chore (metadata): Remove all metadata loading methods
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Aug 5, 2024
1 parent 1fbf1f9 commit 96a45e4
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 68 deletions.
7 changes: 1 addition & 6 deletions src/modules/credit-score/load.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BigNumber } from "@ethersproject/bignumber";

import type { MasaInterface } from "../../interface";
import { CreditScoreDetails, ICreditScore } from "../../interface";
import { CreditScoreDetails } from "../../interface";
import { isBigNumber, patchMetadataUrl } from "../../utils";

export const loadCreditScoreDetails = async (
Expand All @@ -22,14 +22,9 @@ export const loadCreditScoreDetails = async (
console.info(`Credit Score Metadata URL: '${tokenUri}'`);
}

const metadata = <ICreditScore | undefined>(
await masa.client.metadata.get(tokenUri)
);

return {
tokenId,
tokenUri,
metadata,
};
}),
)
Expand Down
7 changes: 1 addition & 6 deletions src/modules/green/load.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumber } from "ethers";

import type { GreenDetails, IGreen, MasaInterface } from "../../interface";
import type { GreenDetails, MasaInterface } from "../../interface";
import { isBigNumber, patchMetadataUrl } from "../../utils";

export const loadGreenDetails = async (
Expand All @@ -21,14 +21,9 @@ export const loadGreenDetails = async (
console.info(`Green Metadata URL: '${tokenUri}'`);
}

const metadata = <IGreen | undefined>(
await masa.client.metadata.get(tokenUri)
);

return {
tokenId,
tokenUri,
metadata,
};
}),
)
Expand Down
11 changes: 1 addition & 10 deletions src/modules/identity/load.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { BigNumber } from "@ethersproject/bignumber";

import { Messages } from "../../collections";
import type {
IdentityDetails,
IIdentity,
MasaInterface,
} from "../../interface";
import type { IdentityDetails, MasaInterface } from "../../interface";
import { isBigNumber, patchMetadataUrl } from "../../utils";
import { resolveReverseIdentity } from "./resolve";

Expand Down Expand Up @@ -62,14 +58,9 @@ export const loadIdentityDetails = async (
console.info(`Identity Metadata URL: '${tokenUri}'`);
}

const metadata: IIdentity | undefined = <IIdentity | undefined>(
await masa.client.metadata.get(tokenUri)
);

return {
tokenId: identityId,
tokenUri,
metadata,
};
};

Expand Down
46 changes: 0 additions & 46 deletions src/utils/clients/masa-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import type {
BaseResult,
ChallengeResult,
ChallengeResultWithCookie,
ICreditScore,
IGreen,
IIdentity,
ISession,
LogoutResult,
MasaInterface,
Expand Down Expand Up @@ -188,49 +185,6 @@ export class MasaClient extends MasaBase {
},
};

metadata = {
/**
* Retrieve metadata
* @param uri
* @param additionalHeaders
*/
get: async (
uri: string,
additionalHeaders?: Record<string, string>,
): Promise<IIdentity | ICreditScore | IGreen | undefined> => {
const headers = {
cookie: this.cookie ? [this.cookie] : undefined,
...additionalHeaders,
};

const metadataResponse = await this._middlewareClient
.get(uri, {
headers,
})
.catch((error: Error | AxiosError) => {
console.error("Failed to load Metadata!", error.message, uri);
});

const { data: metadataResponseData, status } = metadataResponse || {};

if (this.masa.config.verbose) {
console.dir(
{
metadataResponse: {
status,
metadataResponseData,
},
},
{
depth: null,
},
);
}

return metadataResponseData;
},
};

soulName = {
/**
* Store metadata
Expand Down

0 comments on commit 96a45e4

Please sign in to comment.