Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-custom-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
n0izn0iz authored Feb 19, 2025
2 parents 52fb1b5 + a047053 commit 88e41fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/hooks/useNSNameInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {
getNetwork,
} from "@/networks";
import { getCosmosNameServiceQueryClient } from "@/utils/contracts";
import { derivePkgAddr, extractGnoString } from "@/utils/gno";
import {
derivePkgAddr,
extractGnoAddress,
extractGnoString,
} from "@/utils/gno";
import { ProfileData } from "@/utils/upp";

export const GNO_CONTRACT_FIELD = {
Expand Down Expand Up @@ -159,7 +163,7 @@ const gnoGetAddressByUsername = async (
network.nameServiceContractAddress,
`GetUserByName(${JSON.stringify(name)}).Address`,
);
const address = extractGnoString(res);
const address = extractGnoAddress(res);
return address;
} catch (err) {
if (
Expand Down
10 changes: 10 additions & 0 deletions packages/utils/gno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ export const adenaAddPkg = async (
export const extractGnoNumber = (str: string) => {
return parseFloat(str.slice("(".length).split(" ")[0]);
};
export const extractGnoAddress = (str: string) => {
console.log("extracting address", str);
const jsonStr = str.slice("(".length, -" std.Address)".length);
if (!jsonStr) {
return "";
}
// FIXME: sanitize
// eslint-disable-next-line no-restricted-syntax
return JSON.parse(jsonStr) as string;
};
export const extractGnoString = (str: string) => {
console.log("extracting string from", str);
const jsonStr = str.slice("(".length, -" string)".length);
Expand Down

0 comments on commit 88e41fd

Please sign in to comment.