Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore (metadata): Remove all metadata loading methods #350

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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