Skip to content

Commit 23b9334

Browse files
authored
Add implementation for setOwner (#31)
* Implement setOwner Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Remove extensive variable checks Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> --------- Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz>
1 parent 6a05727 commit 23b9334

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

sui/ts/src/ntt.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ export class SuiNtt<N extends Network, C extends SuiChains>
280280
}
281281

282282
async getPauser(): Promise<AccountAddress<C> | null> {
283-
// TODO
284-
return null;
283+
// In Sui NTT, the owner and pauser are the same (AdminCap holder)
284+
return this.getOwner();
285285
}
286286

287287
async getThreshold(): Promise<number> {
@@ -396,14 +396,37 @@ export class SuiNtt<N extends Network, C extends SuiChains>
396396
newOwner: AccountAddress<C>,
397397
payer?: AccountAddress<C>
398398
): AsyncGenerator<UnsignedTransaction<N, C>> {
399-
throw new Error("Not implemented");
399+
const txb = new Transaction();
400+
401+
// Get Admin and Upgrade cap IDs
402+
const adminCapId = await this.getAdminCapId();
403+
const upgradeCapId = await this.getUpgradeCapId();
404+
405+
// Transfer AdminCap and UpgradeCap to new owner
406+
txb.transferObjects(
407+
[txb.object(adminCapId), txb.object(upgradeCapId)],
408+
newOwner.toString()
409+
);
410+
411+
const unsignedTx = new SuiUnsignedTransaction(
412+
txb,
413+
this.network,
414+
this.chain,
415+
"Transfer Ownership"
416+
);
417+
418+
yield unsignedTx;
400419
}
401420

402421
async *setPauser(
403422
newPauser: AccountAddress<C>,
404423
payer?: AccountAddress<C>
405424
): AsyncGenerator<UnsignedTransaction<N, C>> {
406-
throw new Error("Not implemented");
425+
// In Sui NTT, owner and pauser are the same (AdminCap holder)
426+
// Use setOwner instead to change the pauser
427+
throw new Error(
428+
"setPauser not supported: owner and pauser are the same in Sui NTT. Use setOwner instead."
429+
);
407430
}
408431

409432
// Peer Management
@@ -1247,8 +1270,6 @@ export class SuiNtt<N extends Network, C extends SuiChains>
12471270
}
12481271

12491272
// The timestamp should be in the fields of the enum variant
1250-
// TODO Not sure if this is the correct way to get the timestamp
1251-
// I wasn't able to get the exact field name while debugging live
12521273
const releaseTimestamp = parseInt(releaseStatus.fields?.["pos0"]);
12531274

12541275
// Get the full inbox item to access the transfer data

0 commit comments

Comments
 (0)