Skip to content

Commit

Permalink
ref: starknetid hooks mainnet migration (#410)
Browse files Browse the repository at this point in the history
update starknetid hooks to work with latest version of starknetid contracts
  • Loading branch information
fracek authored Mar 12, 2024
2 parents 988cb50 + 61eda85 commit 229a320
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-taxis-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@starknet-react/core": minor
---

update starknetid hooks to work with latest version of starknetid contracts
14 changes: 2 additions & 12 deletions packages/core/src/hooks/useStarkAddress.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { useMemo } from "react";
import {
CallData,
Provider,
ProviderInterface,
RawArgs,
starknetId,
} from "starknet";
import { CallData, Provider, ProviderInterface, starknetId } from "starknet";

import { UseQueryProps, UseQueryResult, useQuery } from "~/query";
import { useProvider } from "./useProvider";
Expand Down Expand Up @@ -91,14 +85,10 @@ function queryFn({
const namingContract = contract ?? StarknetIdNamingContract[network];
const p = new Provider(provider);
const encodedDomain = decodeDomain(name);
const calldata: RawArgs =
network === "mainnet"
? { domain: encodedDomain }
: { domain: encodedDomain, hint: [] };
const result = await p.callContract({
contractAddress: namingContract as string,
entrypoint: "domain_to_address",
calldata: CallData.compile(calldata),
calldata: CallData.compile({ domain: encodedDomain, hint: [] }),
});

// StarknetID returns 0x0 if no name is found, but that can be dangerous
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/hooks/useStarkProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ function queryFn({
{
execution: staticExecution(),
to: hardcoded(naming),
selector:
network === "mainnet"
? hardcoded(hash.getSelectorFromName("domain_to_token_id"))
: hardcoded(hash.getSelectorFromName("domain_to_id")),
selector: hardcoded(hash.getSelectorFromName("domain_to_id")),
calldata: [arrayReference(0, 0)],
},
{
Expand Down

0 comments on commit 229a320

Please sign in to comment.