Skip to content

Commit 130b367

Browse files
committed
move a few config from name and ownership guard to inside the contract and update tests
1 parent b39b3d7 commit 130b367

File tree

16 files changed

+236
-251
lines changed

16 files changed

+236
-251
lines changed

contracts/Factory.cash

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ pragma cashscript 0.11.3;
22

33
/**
44
* @param nameContractBytecode - Partial bytecode of the name contract
5-
* @param minWaitTime - Minimum wait time to consider an auction ended
65
* @param creatorIncentivePKH - PKH of the creator incentive
7-
* @param tld - TLD of the name
86
*/
97
contract Factory(
108
bytes nameContractBytecode,
11-
int minWaitTime,
129
bytes20 creatorIncentivePKH,
13-
bytes tld
1410
) {
1511
/**
1612
* This function finalizes a name registration auction by:
@@ -89,9 +85,12 @@ contract Factory(
8985
// Strict value check
9086
require(tx.outputs[2].value == tx.inputs[2].value, "Output 2: name minting NFT satoshi value must match input 2");
9187

92-
// Enforcing the relative timelock, the auctionNFT must be atleast `minWaitTime` old
88+
// Enforcing the relative timelock, the auctionNFT must be atleast 4194306 old
9389
// to be considered ended.
94-
require(tx.inputs[3].sequenceNumber == minWaitTime, "Input 3: auction NFT sequence number must equal minimum wait time");
90+
// 4194306 is sequence number in time, 2*512 seconds
91+
92+
// TODO: Make this 3 hours
93+
require(tx.inputs[3].sequenceNumber == 4194306, "Input 3: auction NFT sequence number must equal 4194306");
9594

9695
// Extract the PKH and name from the auctionNFT
9796
bytes20 bidderPKH, bytes name = tx.inputs[3].nftCommitment.split(20);
@@ -100,6 +99,7 @@ contract Factory(
10099
int nameLength = name.length;
101100
// category + name + bytecode.
102101
// Note: `inactivityExpiryTime` in the name is already added to the nameContractBytecode in the constructor.
102+
bytes constant tld = bytes('.bch');
103103
bytes nameBytecode = 0x20 + registryInputCategory + bytes(nameLength + tld.length) + name + tld + nameContractBytecode;
104104
bytes32 scriptHash = hash256(nameBytecode);
105105
bytes35 nameLockingBytecode = new LockingBytecodeP2SH32(scriptHash);

contracts/Name.cash

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
pragma cashscript 0.11.3;
22

33
/**
4-
* @param inactivityExpiryTime The time period after which the name is considered inactive.
54
* @param name The name of the name.
65
* @param tld The TLD of the name.
76
* @param nameCategory The category of the name.
87
*/
98
contract Name(
10-
int inactivityExpiryTime,
119
bytes name,
1210
bytes tld,
1311
bytes nameCategory
@@ -194,7 +192,10 @@ contract Name(
194192
// If an external party is attempting to burn the authNFTs
195193
if (tx.inputs[2].tokenCategory == 0x) {
196194
// If pure BCH input, then allow anyone to burn given the time limit has passed.
197-
require(tx.inputs[1].sequenceNumber == inactivityExpiryTime, "Input 1: internal auth NFT sequence number must equal inactivity expiry time");
195+
// 4194305 is sequence number in time, 1*512 seconds
196+
197+
// TODO: Make this 2 years
198+
require(tx.inputs[1].sequenceNumber == 4194305, "Input 1: internal auth NFT sequence number must equal inactivity expiry time");
198199
} else {
199200
// If name ownership NFT input, then allow the owner to burn anytime.
200201
require(tx.inputs[2].tokenCategory == nameCategory, "Input 2: name ownership NFT token category must match name category");

contracts/OwnershipGuard.cash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ pragma cashscript 0.11.3;
22

33
/**
44
* @param nameContractBytecode The the partial bytecode of the name contract that has an Owner.
5-
* @param tld - TLD of the name
65
*/
7-
contract OwnershipGuard(bytes nameContractBytecode, bytes tld) {
6+
contract OwnershipGuard(bytes nameContractBytecode) {
87
/**
98
* If the name being auctioned already has an `externalAuthNFT` with the same category, then the auction is invalid.
109
* Because it means that an owner still exists. If it is known that the name has been abandoned for > `inactivityExpiryTime`
@@ -61,6 +60,7 @@ contract OwnershipGuard(bytes nameContractBytecode, bytes tld) {
6160
int nameLength = name.length;
6261
// category + name + bytecode.
6362
// Note: `inactivityExpiryTime` in the name is already added to the nameContractBytecode in the constructor.
63+
bytes constant tld = bytes('.bch');
6464
bytes nameBytecode = 0x20 + registryInputCategory + bytes(nameLength + tld.length) + name + tld + nameContractBytecode;
6565
bytes32 scriptHash = hash256(nameBytecode);
6666
bytes35 nameLockingBytecode = new LockingBytecodeP2SH32(scriptHash);

lib/compiled/Accumulator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,5 @@ export default {
120120
'name': 'cashc',
121121
'version': '0.11.3',
122122
},
123-
'updatedAt': '2025-08-06T02:52:32.928Z',
123+
'updatedAt': '2025-08-06T03:04:37.389Z',
124124
};

lib/compiled/Auction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,5 @@ export default {
145145
'name': 'cashc',
146146
'version': '0.11.3',
147147
},
148-
'updatedAt': '2025-08-06T02:52:30.672Z',
148+
'updatedAt': '2025-08-06T03:04:34.839Z',
149149
};

lib/compiled/Bid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,5 @@ export default {
110110
'name': 'cashc',
111111
'version': '0.11.3',
112112
},
113-
'updatedAt': '2025-08-06T02:52:31.315Z',
113+
'updatedAt': '2025-08-06T03:04:35.488Z',
114114
};

lib/compiled/ConflictResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ export default {
9090
'name': 'cashc',
9191
'version': '0.11.3',
9292
},
93-
'updatedAt': '2025-08-06T02:52:32.628Z',
93+
'updatedAt': '2025-08-06T03:04:37.071Z',
9494
};

lib/compiled/Factory.ts

Lines changed: 65 additions & 73 deletions
Large diffs are not rendered by default.

lib/compiled/Name.ts

Lines changed: 119 additions & 123 deletions
Large diffs are not rendered by default.

lib/compiled/NameEnforcer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ export default {
9090
'name': 'cashc',
9191
'version': '0.11.3',
9292
},
93-
'updatedAt': '2025-08-06T02:52:31.954Z',
93+
'updatedAt': '2025-08-06T03:04:36.277Z',
9494
};

0 commit comments

Comments
 (0)