Skip to content

Commit 9d5826b

Browse files
committed
Deployed contracts, small UI improvements
1 parent c05c8f7 commit 9d5826b

File tree

9 files changed

+1952
-204
lines changed

9 files changed

+1952
-204
lines changed

packages/foundry/broadcast/Deploy.s.sol/84532/run-1728867702.json

Lines changed: 210 additions & 0 deletions
Large diffs are not rendered by default.

packages/foundry/broadcast/Deploy.s.sol/84532/run-latest.json

Lines changed: 210 additions & 0 deletions
Large diffs are not rendered by default.

packages/foundry/contracts/BasedProfile.sol

Lines changed: 10 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ struct Profile {
1111
string username;
1212
string bio;
1313
string imageURL;
14-
}
15-
16-
struct Socials {
17-
string instagram;
18-
string twitter;
19-
string telegram;
20-
string discord;
2114
string email;
2215
}
2316

@@ -29,7 +22,6 @@ contract BasedProfile {
2922
//////////////////////////////////////////////////////////////*/
3023

3124
mapping(address => Profile) public profiles;
32-
mapping(address => Socials) public socials;
3325
mapping(string => address) public nameToAddress;
3426

3527
/*//////////////////////////////////////////////////////////////
@@ -39,44 +31,25 @@ contract BasedProfile {
3931
function setProfile(
4032
string memory _username,
4133
string memory _bio,
42-
string memory _imageURL
34+
string memory _imageURL,
35+
string memory _email
4336
) public {
4437
if (
4538
keccak256(bytes(_username))
4639
!= keccak256(bytes(profiles[msg.sender].username))
4740
) {
4841
setUsername(_username);
4942
}
50-
profiles[msg.sender].bio = _bio;
51-
profiles[msg.sender].imageURL = _imageURL;
52-
}
53-
54-
function setSocials(
55-
string memory _instagram,
56-
string memory _twitter,
57-
string memory _telegram,
58-
string memory _discord,
59-
string memory _email
60-
) public {
61-
if (bytes(_instagram).length != 0) {
62-
require(
63-
_isValidInstagramUsername(_instagram), "Instagram username is invalid"
64-
);
65-
}
66-
if (bytes(_twitter).length != 0) {
67-
require(_isValidTwitterUsername(_twitter), "Twitter username is invalid");
68-
}
69-
if (bytes(_telegram).length != 0) {
70-
require(
71-
_isValidTelegramUsername(_telegram), "Telegram username is invalid"
72-
);
73-
}
74-
if (bytes(_discord).length != 0) { }
75-
if (bytes(_email).length != 0) {
43+
if (
44+
bytes(_email).length != 0
45+
&& keccak256(bytes(_email))
46+
!= keccak256(bytes(profiles[msg.sender].email))
47+
) {
7648
require(_isValidEmail(_email));
49+
profiles[msg.sender].email = _email;
7750
}
78-
socials[msg.sender] =
79-
Socials(_instagram, _twitter, _telegram, _discord, _email);
51+
profiles[msg.sender].bio = _bio;
52+
profiles[msg.sender].imageURL = _imageURL;
8053
}
8154

8255
// We keep this a separate function in case someone just wants to change username
@@ -152,137 +125,6 @@ contract BasedProfile {
152125
return string(verifiedString);
153126
}
154127

155-
function _isValidInstagramUsername(
156-
string memory username
157-
) internal pure returns (bool) {
158-
bytes memory usernameBytes = bytes(username);
159-
if (usernameBytes.length < 2 || usernameBytes.length > 30) {
160-
return false;
161-
}
162-
163-
bool lastCharacterWasPeriod = false;
164-
165-
for (uint256 i = 0; i < usernameBytes.length; i++) {
166-
bytes1 character = usernameBytes[i];
167-
168-
// Check for valid characters
169-
if (
170-
!(character >= 0x30 && character <= 0x39) // 0-9
171-
&& !(character >= 0x41 && character <= 0x5A) // A-Z
172-
&& !(character >= 0x61 && character <= 0x7A) // a-z
173-
&& !(character == 0x2E) // .
174-
&& !(character == 0x5F) // _
175-
) {
176-
return false;
177-
}
178-
179-
// Check for consecutive periods
180-
if (character == 0x2E) {
181-
// .
182-
if (lastCharacterWasPeriod) {
183-
return false;
184-
}
185-
lastCharacterWasPeriod = true;
186-
} else {
187-
lastCharacterWasPeriod = false;
188-
}
189-
}
190-
return true;
191-
}
192-
193-
function _isValidTwitterUsername(
194-
string memory username
195-
) internal pure returns (bool) {
196-
bytes memory usernameBytes = bytes(username);
197-
if (usernameBytes.length < 4 || usernameBytes.length > 15) {
198-
return false;
199-
}
200-
for (uint256 i = 0; i < usernameBytes.length; i++) {
201-
bytes1 character = usernameBytes[i];
202-
if (
203-
!(character >= 0x30 && character <= 0x39) // 0-9
204-
&& !(character >= 0x41 && character <= 0x5A) // A-Z
205-
&& !(character >= 0x61 && character <= 0x7A) // a-z
206-
&& !(character == 0x5F) // _
207-
) {
208-
return false;
209-
}
210-
}
211-
return true;
212-
}
213-
214-
function _isValidTelegramUsername(
215-
string memory username
216-
) internal pure returns (bool) {
217-
bytes memory usernameBytes = bytes(username);
218-
if (usernameBytes.length < 5 || usernameBytes.length > 32) {
219-
return false;
220-
}
221-
222-
for (uint256 i = 0; i < usernameBytes.length; i++) {
223-
bytes1 character = usernameBytes[i];
224-
225-
// Convert uppercase letters to lowercase
226-
if (character >= 0x41 && character <= 0x5A) {
227-
// A-Z
228-
character = bytes1(uint8(character) + 32);
229-
}
230-
231-
// Check for valid characters
232-
if (
233-
!(character >= 0x30 && character <= 0x39) // 0-9
234-
&& !(character >= 0x61 && character <= 0x7A) // a-z
235-
&& !(character == 0x5F) // _
236-
) {
237-
return false;
238-
}
239-
}
240-
return true;
241-
}
242-
243-
function _isValidDiscordUsername(
244-
string memory username
245-
) internal pure returns (bool) {
246-
bytes memory usernameBytes = bytes(username);
247-
if (usernameBytes.length < 2 || usernameBytes.length > 32) {
248-
return false;
249-
}
250-
251-
bool lastCharacterWasPeriod = false;
252-
253-
for (uint256 i = 0; i < usernameBytes.length; i++) {
254-
bytes1 character = usernameBytes[i];
255-
256-
// Convert uppercase letters to lowercase
257-
if (character >= 0x41 && character <= 0x5A) {
258-
// A-Z
259-
character = bytes1(uint8(character) + 32);
260-
}
261-
262-
// Check for valid characters
263-
if (
264-
!(character >= 0x30 && character <= 0x39) // 0-9
265-
&& !(character >= 0x61 && character <= 0x7A) // a-z
266-
&& !(character == 0x5F) // _
267-
&& !(character == 0x2E) // .
268-
) {
269-
return false;
270-
}
271-
272-
// Check for consecutive periods
273-
if (character == 0x2E) {
274-
// .
275-
if (lastCharacterWasPeriod) {
276-
return false;
277-
}
278-
lastCharacterWasPeriod = true;
279-
} else {
280-
lastCharacterWasPeriod = false;
281-
}
282-
}
283-
return true;
284-
}
285-
286128
function _isValidEmail(
287129
string memory email
288130
) internal pure returns (bool) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"networkName": "Base Sepolia"
3+
}

packages/nextjs/app/create/Create.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const Create = ({ onClose }: { onClose: any }) => {
4141
{/* <div className="flex flex-col md:flex-row items-start flex-grow"> */}
4242
<div className="w-full px-10 bg-base-100 rounded-lg py-4 ">
4343
<div className="flex flex-row justify-between items-center mb-4">
44-
<h3 className="text-2xl font-bold ">Create a new post</h3>
44+
<h3 className="text-2xl font-bold ">Enter article details</h3>
4545
</div>
4646

4747
{/* Metadata and Attributes Forms */}

packages/nextjs/app/create/_components/MintingButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const MintingButtons: React.FC<MintingFormProps> = ({ yourJSON, resetForm
7171
<div className="flex flex-col justify-center items-center mt-6 gap-3">
7272
<div className="flex items-center">
7373
<button className="cool-button" disabled={loading} onClick={handleCreatePost}>
74-
Create Post
74+
Publish article
7575
</button>
7676
</div>
7777
</div>

0 commit comments

Comments
 (0)