Skip to content

Commit abfbe29

Browse files
committed
fix herotags
1 parent 4e7032f commit abfbe29

File tree

5 files changed

+30
-52
lines changed

5 files changed

+30
-52
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### [0.14.4](https://github.com/xdevguild/buildo.dev/releases/tag/v0.14.4) (2024-10-13)
2+
- fix Herotags (DNS) - works only on the mainnet
3+
14
### [0.14.3](https://github.com/xdevguild/buildo.dev/releases/tag/v0.14.3) (2024-07-06)
25
- improve transaction status UI
36
- update dependencies

app/(operations)/general-operations/herotag/components/herotag.tsx

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import keccak from 'keccak';
3+
import { keccak256 } from 'js-sha3';
44
import {
55
SmartContract,
66
Address,
@@ -20,26 +20,19 @@ import { OperationInfoBox } from '@/app/(operations)/components/operations-ui/op
2020
import { useTransaction } from '@useelven/core';
2121

2222
const dnsScAddressForHerotag = (herotag: string) => {
23-
const hashedHerotag = keccak('keccak256').update(herotag).digest();
24-
25-
const initialAddress = Buffer.from(Array(32).fill(1));
26-
const initialAddressSlice = Uint8Array.prototype.slice.call(
27-
initialAddress,
28-
0,
29-
30
30-
);
31-
const scId = Uint8Array.prototype.slice.call(hashedHerotag, 31);
32-
33-
const deployer_pubkey = Buffer.concat([
34-
initialAddressSlice,
35-
Buffer.from([0, Buffer.from(scId).readUIntBE(0, 1)]),
36-
]);
37-
23+
const hashedHerotagBuffer = keccak256.arrayBuffer(herotag);
24+
const hashedHerotag = new Uint8Array(hashedHerotagBuffer);
25+
const initialAddress = new Uint8Array(32).fill(1);
26+
const initialAddressSlice = initialAddress.slice(0, 30);
27+
const scIdByte = hashedHerotag[31];
28+
const deployer_pubkey = new Uint8Array(32);
29+
deployer_pubkey.set(initialAddressSlice, 0);
30+
deployer_pubkey[30] = 0;
31+
deployer_pubkey[31] = scIdByte;
3832
const scAddress = SmartContract.computeAddress(
3933
new Address(deployer_pubkey),
4034
0
4135
);
42-
4336
return scAddress;
4437
};
4538

@@ -72,13 +65,15 @@ export const Herotag = () => {
7265
});
7366

7467
const onSubmit = async ({ herotag }: z.infer<typeof formSchema>) => {
75-
const dnsScAddress = dnsScAddressForHerotag(`${herotag.trim()}`);
68+
// TODO: the suffix will probably change in the future dns sc releases
69+
const fullHerotag = `${herotag.trim()}.elrond`;
70+
const dnsScAddress = dnsScAddressForHerotag(fullHerotag);
7671

77-
const args: TypedValue[] = [BytesValue.fromUTF8(`${herotag.trim()}`)];
72+
const args: TypedValue[] = [BytesValue.fromUTF8(fullHerotag)];
7873

7974
// TODO: use modern tools for contract calls
8075
const data = new ContractCallPayloadBuilder()
81-
.setFunction(new ContractFunction('SetUserName'))
76+
.setFunction(new ContractFunction('register'))
8277
.setArgs(args)
8378
.build();
8479

lib/operations-menu-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export const operationsMenuConfig: Record<
2727
path: '/general-operations/account-storage',
2828
},
2929
{
30-
title: 'Set a herotag',
30+
title: 'Set a herotag (DNS) [Mainnet only]',
3131
description:
32-
'Create a herotag and assign it to your address (transaction fees applied)',
32+
'Create a herotag (DNS name for your address) and assign it to your address (transaction fees applied). Works only on the Mainnet.',
3333
path: '/general-operations/herotag',
3434
},
3535
{

package-lock.json

Lines changed: 8 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "buildo.dev",
3-
"version": "0.14.3",
3+
"version": "0.14.4",
44
"author": "Julian Ćwirko <julian.io>",
55
"license": "MIT",
66
"homepage": "https://www.buildo.dev",
@@ -39,7 +39,7 @@
3939
"buffer": "6.0.3",
4040
"class-variance-authority": "0.7.0",
4141
"clsx": "2.1.1",
42-
"keccak": "3.0.4",
42+
"js-sha3": "^0.9.3",
4343
"lucide-react": "0.400.0",
4444
"next": "14.2.4",
4545
"next-themes": "0.3.0",
@@ -53,7 +53,6 @@
5353
"zod": "3.23.8"
5454
},
5555
"devDependencies": {
56-
"@types/keccak": "3.0.4",
5756
"@types/node": "20.14.10",
5857
"@types/qrcode": "1.5.5",
5958
"@types/react": "18.3.3",

0 commit comments

Comments
 (0)