Skip to content

Commit

Permalink
add missing function on temp proxy, republish (#132)
Browse files Browse the repository at this point in the history
* Adds missing function in temp subname proxy, publishes on mainnet/testnet

* Add better tests, add mainnet/testnet tests too
  • Loading branch information
manolisliolios authored Jun 3, 2024
1 parent d6014f0 commit 83cc050
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-olives-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mysten/suins": patch
---

Adds new temp subname proxy to fix issue
6 changes: 0 additions & 6 deletions documentation/pages/subnames.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { Callout } from 'nextra/components'

# Subnames

<Callout type="warning" emoji="⚠️">
Subnames are currently available only on Testnet.
</Callout>

Subnames are nested names under a parent name. Unlike regular names, there is not a cost associated with creating subnames.

The maximum nesting depth is **eight** levels. The total depth, including the SLD and TLD, means the maximum total depth is 10 levels.
Expand Down
7 changes: 7 additions & 0 deletions packages/denylist/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
name = "denylist"
version = "0.0.1"
edition = "2024.beta"
#mainnet
published-at="0xc967b7862d926720761ee15fbd0254a975afa928712abcaa4f7c17bb2b38d38b"

#testnet
# published-at="a86c05fbc6371788eb31260dc5085f4bfeab8b95c95d9092c9eb86e63fae3d49"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override=true }
suins = { local = "../suins" }

[addresses]
denylist = "0xc967b7862d926720761ee15fbd0254a975afa928712abcaa4f7c17bb2b38d38b"

#testnet
# denylist = "a86c05fbc6371788eb31260dc5085f4bfeab8b95c95d9092c9eb86e63fae3d49"
4 changes: 2 additions & 2 deletions packages/subdomains/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2024.beta"
published-at="0xe177697e191327901637f8d2c5ffbbde8b1aaac27ec1024c4b62d1ebd1cd7430"

#testnet
#published-at="0xb0c14a9891efc8080e976db617a2d830183aa9034cbdf575dbb9e5856e38c283"
#published-at="0x3c272bc45f9157b7818ece4f7411bdfa8af46303b071aca4e18c03119c9ff636"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override=true }
Expand All @@ -20,4 +20,4 @@ denylist = { local = "../denylist" }
subdomains="0xe177697e191327901637f8d2c5ffbbde8b1aaac27ec1024c4b62d1ebd1cd7430"

#testnet
#subdomains = "0xb0c14a9891efc8080e976db617a2d830183aa9034cbdf575dbb9e5856e38c283"
#subdomains = "0x3c272bc45f9157b7818ece4f7411bdfa8af46303b071aca4e18c03119c9ff636"
18 changes: 16 additions & 2 deletions packages/temp_subdomain_proxy/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 2
manifest_digest = "E6E9B71784212F15CE83BAFF38D4DE27F380BFA652A300F4C82331B7506FCF8F"
manifest_digest = "5B3CC880F9BF3F296CD220EE9A75E5A07404B45E00D25457EC0EB60A1D3CFFCA"
deps_digest = "060AD7E57DFB13104F21BE5F5C3759D03F0553FC3229247D9A7A6B45F50D03A3"
dependencies = [
{ name = "Sui" },
Expand Down Expand Up @@ -59,6 +59,20 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.26.0"
compiler-version = "1.27.0"
edition = "2024.beta"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0xdacfd7c1176a68137b38a875d76a2f65d277596d2c632881931d926b16de2698"
latest-published-id = "0xdacfd7c1176a68137b38a875d76a2f65d277596d2c632881931d926b16de2698"
published-version = "1"

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0xfd5ad004acbd5e3dd4fc0de4f1f1d465f8db5bb2ec1de63694ce6dc887fe1c89"
latest-published-id = "0xfd5ad004acbd5e3dd4fc0de4f1f1d465f8db5bb2ec1de63694ce6dc887fe1c89"
published-version = "1"
12 changes: 8 additions & 4 deletions packages/temp_subdomain_proxy/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
name = "temp_subdomain_proxy"
version = "0.0.1"
edition = "2024.beta"

#mainnet
published-at="0xdacfd7c1176a68137b38a875d76a2f65d277596d2c632881931d926b16de2698"
#testnet
#published-at="0x471adb89c0b5094febfcde87f0a90ec32daea71755dd9eed9e68bc3e527562b5"
#published-at="0xfd5ad004acbd5e3dd4fc0de4f1f1d465f8db5bb2ec1de63694ce6dc887fe1c89"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet", override=true }
subdomains = { local = "../subdomains" }
utils = { local = "../utils" }

[addresses]
temp_subdomain_proxy = "0x0"
#temp_subdomain_proxy = "0x0"

# mainnet
temp_subdomain_proxy = "0xdacfd7c1176a68137b38a875d76a2f65d277596d2c632881931d926b16de2698"
#testnet
#temp_subdomain_proxy = "0x471adb89c0b5094febfcde87f0a90ec32daea71755dd9eed9e68bc3e527562b5"
#temp_subdomain_proxy = "0xfd5ad004acbd5e3dd4fc0de4f1f1d465f8db5bb2ec1de63694ce6dc887fe1c89"
18 changes: 18 additions & 0 deletions packages/temp_subdomain_proxy/sources/subdomain_proxy.move
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ module temp_subdomain_proxy::subdomain_proxy {
);
}

public fun edit_setup(
suins: &mut SuiNS,
parent: &SubDomainRegistration,
clock: &Clock,
subdomain_name: String,
allow_creation: bool,
allow_time_extension: bool
) {
subdomains::edit_setup(
suins,
parent.nft(),
clock,
subdomain_name,
allow_creation,
allow_time_extension
);
}

public fun set_target_address(
suins: &mut SuiNS,
subdomain: &SubDomainRegistration,
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
name = "utils"
version = "0.0.1"
edition = "2024.beta"
published-at="0xf7854c81cf500d60a4437f4599f7ff3b89abd13f645ae08f62345c7a25317bee"
published-at="0x7954ae683314ec7e156acbf0c0fc964ce035fd7f456fe7576848226502cfde1b"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override=true }
suins = { local = "../suins" }

[addresses]
utils = "0xf7854c81cf500d60a4437f4599f7ff3b89abd13f645ae08f62345c7a25317bee"
utils = "0x7954ae683314ec7e156acbf0c0fc964ce035fd7f456fe7576848226502cfde1b"
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"eslint:fix": "pnpm run eslint:check --fix",
"lint": "pnpm run eslint:check && pnpm run prettier:check",
"lint:fix": "pnpm run eslint:fix && pnpm run prettier:fix",
"test:e2e": "wait-on http://127.0.0.1:9123 -l --timeout 120000 && vitest run e2e",
"test:e2e": "wait-on http://127.0.0.1:9123 -l --timeout 120000 && vitest run",
"prepare:e2e": "cargo build --bin sui-test-validator --bin sui --profile dev && cross-env RUST_LOG=info,sui=error,anemo_tower=warn,consensus=off cargo run --bin sui-test-validator -- --epoch-duration-ms 300000"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const MAINNET_CONFIG: Constants = {
registrationPackageId: '0x9d451fa0139fef8f7c1f0bd5d7e45b7fa9dbb84c2e63c2819c7abd0a7f7d749d',
renewalPackageId: '0xd5e5f74126e7934e35991643b0111c3361827fc0564c83fa810668837c6f0b0f',
subNamesPackageId: '0xe177697e191327901637f8d2c5ffbbde8b1aaac27ec1024c4b62d1ebd1cd7430',
tempSubNamesProxyPackageId: '0x59effd9323a836dd7373108ce1ca93acd8570c5d28a2ce790e5bfe34b649a0d0',
tempSubNamesProxyPackageId: '0xdacfd7c1176a68137b38a875d76a2f65d277596d2c632881931d926b16de2698',
registryTableId: '0xe64cd9db9f829c6cc405d9790bd71567ae07259855f4fba6f02c84f52298c106',
};

Expand All @@ -45,6 +45,6 @@ export const TESTNET_CONFIG: Constants = {
registrationPackageId: '0x4255184a0143c0ce4394a3f16a6f5aa5d64507269e54e51ea396d569fe8f1ba5',
renewalPackageId: '0x54800ebb4606fd0c03b4554976264373b3374eeb3fd63e7ff69f31cac786ba8c',
subNamesPackageId: '0x3c272bc45f9157b7818ece4f7411bdfa8af46303b071aca4e18c03119c9ff636',
tempSubNamesProxyPackageId: '0xd258bfc8d5a58f18deaf069e758a66200eb09614566cc0ee66bbe17a261d2206',
tempSubNamesProxyPackageId: '0xfd5ad004acbd5e3dd4fc0de4f1f1d465f8db5bb2ec1de63694ce6dc887fe1c89',
registryTableId: '0xb120c0d55432630fce61f7854795a3463deb6e3b443cc4ae72e1282073ff56e4',
};
19 changes: 19 additions & 0 deletions sdk/test/live.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it } from 'vitest';

import { e2eLiveNetworkDryRunFlow } from './pre-built';

describe('it should work on live networks', () => {
it('should work on mainnet', async () => {
const res = await e2eLiveNetworkDryRunFlow('mainnet');

expect(res.effects.status.status).toEqual('success');
});

it('should work on testnet', async () => {
const res = await e2eLiveNetworkDryRunFlow('testnet');
expect(res.effects.status.status).toEqual('success');
});
});
119 changes: 119 additions & 0 deletions sdk/test/pre-built.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { getFullnodeUrl, SuiClient } from '@mysten/sui.js/client';
import { TransactionBlock } from '@mysten/sui.js/transactions';
import { normalizeSuiAddress } from '@mysten/sui.js/utils';

import { ALLOWED_METADATA, SuinsClient, SuinsTransaction } from '../src';

export const e2eLiveNetworkDryRunFlow = async (network: 'mainnet' | 'testnet') => {
const client = new SuiClient({ url: getFullnodeUrl(network) });

const sender = normalizeSuiAddress('0x2');
const suinsClient = new SuinsClient({
client,
network,
});

const tx = new TransactionBlock();
const suinsTx = new SuinsTransaction(suinsClient, tx);

const uniqueName =
(Date.now().toString(36) + Math.random().toString(36).substring(2)).repeat(2) + '.sui';

const priceList = await suinsClient.getPriceList();
// const _renewalPriceList = await suinsClient.getRenewalPriceList();
const years = 1;

// register test.sui for a year.
const nft = suinsTx.register({
name: uniqueName,
years,
price: suinsClient.calculatePrice({ name: uniqueName, years, priceList }),
});
// Sets the target address of the NFT.
suinsTx.setTargetAddress({
nft,
address: sender,
isSubname: false,
});

suinsTx.setDefault(uniqueName);

// Sets the avatar of the NFT.
suinsTx.setUserData({
nft,
key: ALLOWED_METADATA.avatar,
value: '0x0',
});

suinsTx.setUserData({
nft,
key: ALLOWED_METADATA.contentHash,
value: '0x1',
});

const subNft = suinsTx.createSubName({
parentNft: nft,
name: 'node.' + uniqueName,
expirationTimestampMs: Date.now() + 1000 * 60 * 60 * 24 * 30,
allowChildCreation: true,
allowTimeExtension: true,
});

// create/remove some leaf names as an NFT
suinsTx.createLeafSubName({
parentNft: nft,
name: 'leaf.' + uniqueName,
targetAddress: sender,
});
suinsTx.removeLeafSubName({ parentNft: nft, name: 'leaf.' + uniqueName });

// do it for sub nft too
suinsTx.createLeafSubName({
parentNft: subNft,
name: 'leaf.node.' + uniqueName,
targetAddress: sender,
});
suinsTx.removeLeafSubName({ parentNft: subNft, name: 'leaf.node.' + uniqueName });

// extend expiration a bit further for the subNft
suinsTx.extendExpiration({
nft: subNft,
expirationTimestampMs: Date.now() + 1000 * 60 * 60 * 24 * 30 * 2,
});

suinsTx.editSetup({
parentNft: nft,
name: 'node.' + uniqueName,
allowChildCreation: true,
allowTimeExtension: false,
});

// let's go 2 levels deep and edit setups!
const moreNestedNft = suinsTx.createSubName({
parentNft: subNft,
name: 'more.node.' + uniqueName,
allowChildCreation: true,
allowTimeExtension: true,
expirationTimestampMs: Date.now() + 1000 * 60 * 60 * 24 * 30,
});

suinsTx.editSetup({
parentNft: subNft,
name: 'more.node.' + uniqueName,
allowChildCreation: false,
allowTimeExtension: false,
});

// do it for sub nft too
tx.transferObjects([moreNestedNft, subNft, nft], tx.pure.address(sender));

tx.setSender(sender);

return client.dryRunTransactionBlock({
transactionBlock: await tx.build({
client,
}),
});
};

0 comments on commit 83cc050

Please sign in to comment.