Skip to content

Commit

Permalink
chore(secret): name and symbol fix
Browse files Browse the repository at this point in the history
  • Loading branch information
D4mph1r committed Oct 24, 2024
1 parent 35afbeb commit 0f5cad5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/handlers/secret/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { Pubkey } from "secretjs/dist/wallet_amino";
import { Lock721, Lock1155 } from "../../contractsTypes/secret/secretBridge";
import { raise } from "../ton";
import { TokenInfo } from "../types";
import { GetOwnedTokensResponse, TSecretHandler, TSecretParams } from "./types";
import {
GetOwnedTokensResponse,
TNftInfo,
TSecretHandler,
TSecretParams,
TSftInfo,
} from "./types";

export function secretHandler({
bridge,
Expand All @@ -18,6 +24,11 @@ export function secretHandler({
owner: string,
ea: { viewingKey: string; codeHash?: string },
) {
const contractInfo: TNftInfo = await provider.query.compute.queryContract({
contract_address: contract,
query: { contract_info: {} },
});

const res = (await provider.query.snip721.GetOwnedTokens({
auth: {
viewer: {
Expand Down Expand Up @@ -63,6 +74,8 @@ export function secretHandler({
native: {
contract: contract,
contractHash: ea.codeHash || "",
name: contractInfo.contract_info.name || "",
symbol: contractInfo.contract_info.symbol || "",
tokenId: token,
viewingKey: ea.viewingKey,
metadata: tokenInfo.all_nft_info.info?.token_uri || "",
Expand Down Expand Up @@ -111,6 +124,12 @@ export function secretHandler({
token_id: token.token_id,
});

const contractInfo: TSftInfo =
await provider.query.compute.queryContract({
contract_address: contract,
query: { token_id_public_info: { token_id: token.token_id } },
});

response.push({
collectionIdent: contract,
uri:
Expand All @@ -124,6 +143,8 @@ export function secretHandler({
tokenId: token.token_id,
amount: Number(token.amount),
viewingKey: ea.viewingKey,
name: contractInfo.token_id_public_info.token_id_info.name,
symbol: contractInfo.token_id_public_info.token_id_info.symbol,
metadata:
tokenInfo.token_id_private_info.token_id_info.public_metadata
.token_uri || "",
Expand Down
17 changes: 17 additions & 0 deletions src/handlers/secret/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,20 @@ export type TSecretParams = {
};

export type GetOwnedTokensResponse = Snip721GetTokensResponse | string;

export type TNftInfo = {
contract_info: { name: string; symbol: string };
};

export type TSftInfo = {
token_id_public_info: {
token_id_info: {
token_id: string;
name: string;
symbol: string;
curator: string;
};
total_supply: string;
owner: string | undefined | null;
};
};

0 comments on commit 0f5cad5

Please sign in to comment.