Skip to content

Commit

Permalink
fix: reorder storage operations in dnsAlloc function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Dec 26, 2024
1 parent 96b5733 commit 863ef47
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions smart-contract/assembly/contracts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ export function dnsAlloc(binaryArgs: StaticArray<u8>): StaticArray<u8> {
assert(!Storage.has(domainToTargetKey(domain)), 'Domain already registered');

const counter = bytesToU256(Storage.get(COUNTER_KEY));
// @ts-ignore (fix for IDE)
Storage.set(COUNTER_KEY, u256ToBytes(counter + u256.One));

// Mint the token
_update(owner, counter, '');
Expand All @@ -199,6 +197,8 @@ export function dnsAlloc(binaryArgs: StaticArray<u8>): StaticArray<u8> {
Storage.set(targetToDomainKey(target, domain), []);
Storage.set(tokenIdToDomainKey(counter), stringToBytes(domain));
Storage.set(domainToTokenIdKey(domain), u256ToBytes(counter));
// @ts-ignore (fix for IDE)
Storage.set(COUNTER_KEY, u256ToBytes(counter + u256.One));

const storageCosts = initialBalance - balance();
const totalCost = calculateCreationCost(domain.length) + storageCosts;
Expand Down

0 comments on commit 863ef47

Please sign in to comment.