Skip to content

Commit

Permalink
fix: punycode registrations and availability queries
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Sep 19, 2023
1 parent bc8a728 commit 042095d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/src/routes/trpc/query-helper-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
namesByAddressBnsxSchema,
} from '@bns-x/core';
import { router, procedure } from './base';
import { toPunycode } from '@bns-x/punycode';

export const queryHelperRouter = router({
getAddressNames: procedure
Expand Down Expand Up @@ -83,7 +84,8 @@ The logic for determining name order in the \`names\` property is:
.input(z.string())
.output(z.boolean())
.query(async ({ input, ctx }) => {
return ctx.fetcher.getNameExists(input);
const puny = toPunycode(input);
return ctx.fetcher.getNameExists(puny);
}),
});

Expand Down
4 changes: 3 additions & 1 deletion web/common/hooks/use-name-register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
PostConditionMode,
} from 'micro-stacks/transactions';
import { toast } from 'sonner';
import { toPunycode } from '@bns-x/punycode';

export function useNameRegister(name: string, namespace: string, price: bigint) {
const { openContractCall, isRequestPending } = useAccountOpenContractCall();
Expand All @@ -33,9 +34,10 @@ export function useNameRegister(name: string, namespace: string, price: bigint)
FungibleConditionCode.Equal,
price
);
const namePuny = toPunycode(name);
await openContractCall({
...nameRegistrar.nameRegister({
name: asciiToBytes(name),
name: asciiToBytes(namePuny),
namespace: asciiToBytes(namespace),
amount: Number(price),
hashedFqn: hashFqn(name, namespace, hexToBytes('00')), // TODO: get `randomSalt()` function to work for both pre-order and register
Expand Down

0 comments on commit 042095d

Please sign in to comment.