Skip to content

Commit 2790399

Browse files
upgrade to scaffold 0.3.15
2 parents 37296d5 + 127d742 commit 2790399

File tree

12 files changed

+987
-235
lines changed

12 files changed

+987
-235
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ss-2",
3-
"version": "0.3.13",
3+
"version": "0.3.15",
44
"author": "Q3 Labs",
55
"license": "MIT",
66
"private": true,

packages/nextjs/app/debug/_components/contract/TxReceipt.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const TxReceipt = (
2727
aria-hidden="true"
2828
/>
2929
) : (
30-
//@ts-ignore coponent works but some typing issue came up, ts-expect-error does not work
30+
//@ts-ignore component works but some typing issue came up, ts-expect-error does not work
3131
<CopyToClipboard
3232
text={
3333
decodeContractResponse({

packages/nextjs/components/scaffold-stark/Address.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export const Address = ({
5252

5353
const checkSumAddress = useMemo(() => {
5454
if (!address) return undefined;
55+
56+
if (address.toLowerCase() === "0x") {
57+
return "0x0";
58+
}
59+
5560
return getChecksumAddress(address);
5661
}, [address]);
5762

@@ -60,6 +65,19 @@ export const Address = ({
6065
checkSumAddress || address || "",
6166
);
6267

68+
const isValidHexAddress = (value: string): boolean => {
69+
if (value.toLowerCase() === "0x") {
70+
value = "0x0";
71+
}
72+
73+
if (value.toLowerCase() === "0x0x0") {
74+
return false;
75+
}
76+
77+
const hexAddressRegex = /^0x[0-9a-fA-F]+$/;
78+
return hexAddressRegex.test(value);
79+
};
80+
6381
const [displayAddress, setDisplayAddress] = useState(
6482
checkSumAddress?.slice(0, 6) + "..." + checkSumAddress?.slice(-4),
6583
);
@@ -96,8 +114,8 @@ export const Address = ({
96114
);
97115
}
98116

99-
if (!validateChecksumAddress(checkSumAddress)) {
100-
return <span className="text-error">Wrong address</span>;
117+
if (!checkSumAddress) {
118+
return <span className="text-error">Invalid address format</span>;
101119
}
102120

103121
return (

packages/nextjs/components/scaffold-stark/CustomConnectButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export const CustomConnectButton = () => {
4545
}, [account]);
4646

4747
if (status === "disconnected") return <ConnectModal />;
48-
// Skip wrong network check if using a fork
49-
if (!scaffoldConfig.isFork && accountChainId !== targetNetwork.id) {
48+
49+
if (accountChainId !== targetNetwork.id) {
5050
return <WrongNetworkDropdown />;
5151
}
5252

packages/nextjs/components/scaffold-stark/Input/AddressInput.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,24 @@ export const AddressInput = ({
2121

2222
const handleChange = useCallback(
2323
(newValue: Address) => {
24-
//setEnteredEnsName(undefined);
24+
const sanitizedValue = newValue.toLowerCase();
25+
26+
if (sanitizedValue === "0x") {
27+
onChange("0x0" as Address);
28+
return;
29+
}
30+
31+
const isValid =
32+
/^(0x)([a-fA-F0-9]{40})$/.test(sanitizedValue) &&
33+
!/0x.*0x/.test(sanitizedValue);
34+
if (!isValid) {
35+
return;
36+
}
37+
38+
if (sanitizedValue.length !== 42) {
39+
return;
40+
}
41+
2542
onChange(newValue);
2643
},
2744
[onChange],

packages/nextjs/next.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/** @type {import('next').NextConfig} */
2+
import webpack from "webpack";
3+
24
const nextConfig = {
35
reactStrictMode: true,
46
images: {
@@ -62,6 +64,11 @@ const nextConfig = {
6264
});
6365
}
6466
config.externals.push("pino-pretty", "lokijs", "encoding");
67+
config.plugins.push(
68+
new webpack.NormalModuleReplacementPlugin(/^node:(.*)$/, (resource) => {
69+
resource.request = resource.request.replace(/^node:/, "");
70+
}),
71+
);
6572
return config;
6673
},
6774
};

packages/nextjs/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
"typescript": "^5",
8282
"url": "^0.11.4",
8383
"vercel": "^33.7.1",
84-
"vitest": "^2.1.1"
84+
"vitest": "^2.1.1",
85+
"webpack": "^5.97.1",
86+
"webpack-cli": "^6.0.1"
8587
}
8688
}

packages/nextjs/scaffold.config.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ export type ScaffoldConfig = {
88
rpcProviderUrl: string;
99
walletAutoConnect: boolean;
1010
autoConnectTTL: number;
11-
/**
12-
* Flag to indicate if the network is a fork of another network
13-
* This is used to handle network validation differently for forked networks
14-
* since they share the same chain ID as their parent network
15-
*/
16-
isFork?: boolean;
1711
};
1812

1913
const scaffoldConfig = {
@@ -31,12 +25,6 @@ const scaffoldConfig = {
3125
*/
3226
autoConnectTTL: 60000,
3327
walletAutoConnect: true,
34-
/**
35-
* Set to true when using a fork of a network
36-
* This will prevent showing the wrong network dropdown when the chainId matches
37-
* but the RPC URL is different (e.g., when using a local fork of mainnet)
38-
*/
39-
isFork: false,
4028
} as const satisfies ScaffoldConfig;
4129

4230
export default scaffoldConfig;

packages/nextjs/services/web3/provider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {
77
import * as chains from "@starknet-react/chains";
88

99
const containsDevnet = (networks: readonly chains.Chain[]) => {
10-
return networks.filter((it) => it.id == chains.devnet.id).length > 0;
10+
return (
11+
networks.filter((it) => it.network == chains.devnet.network).length > 0
12+
);
1113
};
1214

1315
const provider =

packages/nextjs/supportedChains.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as chains from "@starknet-react/chains";
22

3+
// devnet with mainnet network ID
34
const mainnetFork = {
45
id: BigInt("0x534e5f4d41494e"),
56
network: "devnet",

0 commit comments

Comments
 (0)