-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from MystenLabs/ml/single-ptb-registry-setup
Allow registration & setup of names in a single PTB
- Loading branch information
Showing
8 changed files
with
176 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 0 | ||
manifest_digest = "EE479753CF869115F6C15EFFEE4A4F51363E4A07A23A076868DE76C8B3F887F3" | ||
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" | ||
|
||
dependencies = [ | ||
{ name = "Sui" }, | ||
{ name = "suins" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "MoveStdlib" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "testnet", subdir = "crates/sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
name = "Sui" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "testnet", subdir = "crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ name = "MoveStdlib" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "suins" | ||
source = { local = "../suins" } | ||
|
||
dependencies = [ | ||
{ name = "Sui" }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "utils" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet", override=true } | ||
suins = { local = "../suins" } | ||
|
||
[addresses] | ||
utils = "0x0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// A simple package to allows us set a target address & default name in a single PTB in frontend. | ||
/// Unblocks better UX in the registration flow | easier adoption for non-technical users. | ||
module utils::direct_setup { | ||
use std::option; | ||
use std::string::{String}; | ||
|
||
use sui::tx_context::{TxContext, sender}; | ||
use sui::clock::Clock; | ||
|
||
use suins::domain; | ||
use suins::registry::{Self, Registry}; | ||
use suins::suins::{Self, SuiNS}; | ||
use suins::suins_registration::{Self as nft, SuinsRegistration}; | ||
|
||
/// Authorization token for the controller. | ||
struct DirectSetup has drop {} | ||
|
||
/// Set the target address of a domain. | ||
public fun set_target_address( | ||
suins: &mut SuiNS, | ||
nft: &SuinsRegistration, | ||
new_target: address, | ||
clock: &Clock, | ||
) { | ||
let registry = suins::app_registry_mut<DirectSetup, Registry>(DirectSetup {}, suins); | ||
registry::assert_nft_is_authorized(registry, nft, clock); | ||
|
||
let domain = nft::domain(nft); | ||
registry::set_target_address(registry, domain, option::some(new_target)); | ||
} | ||
|
||
/// Set the reverse lookup address for the domain | ||
public fun set_reverse_lookup(suins: &mut SuiNS, domain_name: String, ctx: &TxContext) { | ||
let domain = domain::new(domain_name); | ||
let registry = suins::app_registry_mut<DirectSetup, Registry>(DirectSetup {}, suins); | ||
registry::set_reverse_lookup(registry, sender(ctx), domain); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2023, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import dotenv from "dotenv"; | ||
dotenv.config(); | ||
import { executeTx, prepareMultisigTx, prepareSigner } from "../airdrop/helper"; | ||
import { TransactionBlock } from "@mysten/sui.js"; | ||
import { Network, mainPackage } from "../config/constants"; | ||
|
||
export const authorizeDirectSetupApp = async (network: Network) => { | ||
const tx = new TransactionBlock(); | ||
|
||
const config = mainPackage[network]; | ||
|
||
// authorize the direct setup app. | ||
tx.moveCall({ | ||
target: `${config.packageId}::suins::authorize_app`, | ||
arguments: [ | ||
tx.object(config.adminCap), | ||
tx.object(config.suins), | ||
], | ||
typeArguments: [`${config.directSetupPackageId}::direct_setup::DirectSetup`], | ||
}); | ||
|
||
// for mainnet, we just prepare multisig TX | ||
if(network === 'mainnet') return prepareMultisigTx(tx, 'mainnet'); | ||
|
||
return executeTx(prepareSigner(config.provider), tx); | ||
// prepare tx data. | ||
|
||
} | ||
|
||
authorizeDirectSetupApp("mainnet"); | ||
// authorizeDirectSetupApp("testnet"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2023, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import dotenv from "dotenv"; | ||
dotenv.config(); | ||
import { execSync } from 'child_process'; | ||
|
||
const gasObject = process.env.GAS_OBJECT; | ||
|
||
// Github actions are always on mainnet. | ||
// This will publish the day_one package. | ||
const publish = async () => { | ||
|
||
if(!gasObject) throw new Error("Gas Object not supplied for a mainnet transaction"); | ||
|
||
// on GH Action, the sui binary is located on root. Referencing that as `/` doesn't work. | ||
const suiFolder = process.env.ORIGIN === 'gh_action' ? '../../sui' : 'sui'; | ||
const publishCall = `${suiFolder} client publish --gas-budget 3000000000 --gas ${gasObject} --serialize-unsigned-transaction` | ||
|
||
// to suins/..(packages)/..(base)/scripts/tx/tx-data.txt | ||
execSync(`cd $PWD/../packages/utils && ${publishCall} > $PWD/../../scripts/tx/tx-data.txt`); | ||
} | ||
|
||
publish(); |