diff --git a/.github/workflows/suins-build-tx.yaml b/.github/workflows/suins-build-tx.yaml index cb940da4..de828518 100644 --- a/.github/workflows/suins-build-tx.yaml +++ b/.github/workflows/suins-build-tx.yaml @@ -12,8 +12,7 @@ on: - Disable Free Claims - Profits to Treasury - Transfer Reserved Names - - DayOne Discount - - Contest Winner Coupons + - Update Display sui_tools_image: description: 'image reference of sui_tools' default: 'mysten/sui-tools:mainnet' @@ -113,25 +112,15 @@ jobs: run: | cd scripts && pnpm create-deepbook-pools - - name: DayOne Discount - if: ${{ inputs.transaction_type == 'DayOne Discount' }} + - name: Update Display + if: ${{ inputs.transaction_type == 'Update Display' }} env: NODE_ENV: production GAS_OBJECT: ${{ inputs.gas_object_id }} NETWORK: mainnet ORIGIN: gh_action run: | - cd scripts && pnpm setup-dayone-discount - - - name: Contest Winner Coupons - if: ${{ inputs.transaction_type == 'Contest Winner Coupons' }} - env: - NODE_ENV: production - GAS_OBJECT: ${{ inputs.gas_object_id }} - NETWORK: mainnet - ORIGIN: gh_action - run: | - cd scripts && pnpm ts-node transactions/create-contest-winner-coupons.ts + cd scripts && pnpm ts-node transactions/update-mainnet-display.ts - name: Show Transaction Data (To sign) run: | diff --git a/scripts/init/display_tp.ts b/scripts/init/display_tp.ts index 266466d7..5d8e05b2 100644 --- a/scripts/init/display_tp.ts +++ b/scripts/init/display_tp.ts @@ -2,26 +2,36 @@ // SPDX-License-Identifier: Apache-2.0 import { TransactionBlock } from '@mysten/sui.js/transactions'; +export const getImageUrl = (isSubdomain: boolean, network: 'mainnet' | 'testnet') => { + const name = `{${isSubdomain ? 'nft.' : ''}domain_name}`; + const expiration = `{${isSubdomain ? 'nft.' : ''}expiration_timestamp_ms}`; + + return `https://api-${network}.suins.io/nfts/${name}/${expiration}`; +}; + /** Creates the display. Should be called for both subnames and names. */ export const createDisplay = ({ txb, publisher, isSubdomain, suinsPackageIdV1, + subdomainsPackageId, + network = 'mainnet', }: { txb: TransactionBlock; publisher: string; isSubdomain: boolean; suinsPackageIdV1: string; + subdomainsPackageId: string; + network: 'mainnet' | 'testnet'; }) => { + const subnameRegistration = `${subdomainsPackageId}::subdomain_registration::SubDomainRegistration`; + const suinsRegistration = `${suinsPackageIdV1}::suins_registration::SuinsRegistration`; + const display = txb.moveCall({ target: `0x2::display::new`, arguments: [txb.object(publisher)], - typeArguments: [ - isSubdomain - ? `${suinsPackageIdV1}::subdomain_registration::SubDomainRegistration` - : `${suinsPackageIdV1}::suins_registration::SuinsRegistration`, - ], + typeArguments: [isSubdomain ? subnameRegistration : suinsRegistration], }); txb.moveCall({ @@ -32,26 +42,18 @@ export const createDisplay = ({ txb.pure([ `{${isSubdomain ? 'nft.' : ''}domain_name}`, `https://{${isSubdomain ? 'nft.' : ''}domain_name}.id`, - `https://storage.googleapis.com/suins-nft-images/{${isSubdomain ? 'nft.' : ''}image_url}.png`, + getImageUrl(isSubdomain, network), 'SuiNS - Sculpt Your Identity', 'https://suins.io', ]), ], - typeArguments: [ - isSubdomain - ? `${suinsPackageIdV1}::subdomain_registration::SubDomainRegistration` - : `${suinsPackageIdV1}::suins_registration::SuinsRegistration`, - ], + typeArguments: [isSubdomain ? subnameRegistration : suinsRegistration], }); txb.moveCall({ target: `0x2::display::update_version`, arguments: [display], - typeArguments: [ - isSubdomain - ? `${suinsPackageIdV1}::subdomain_registration::SubDomainRegistration` - : `${suinsPackageIdV1}::suins_registration::SuinsRegistration`, - ], + typeArguments: [isSubdomain ? subnameRegistration : suinsRegistration], }); const sender = txb.moveCall({ diff --git a/scripts/init/packages.ts b/scripts/init/packages.ts index 2a16058e..bc1403ac 100644 --- a/scripts/init/packages.ts +++ b/scripts/init/packages.ts @@ -96,6 +96,8 @@ export const Packages = (network: Network) => { publisher, isSubdomain: false, suinsPackageIdV1: packageId, + network: 'testnet', + subdomainsPackageId: packageId, }); // create display for subnames createDisplay({ @@ -103,6 +105,8 @@ export const Packages = (network: Network) => { publisher, isSubdomain: true, suinsPackageIdV1: packageId, + network: 'testnet', + subdomainsPackageId: packageId, }); }, }, diff --git a/scripts/transactions/update-mainnet-display.ts b/scripts/transactions/update-mainnet-display.ts new file mode 100644 index 00000000..e522aa8d --- /dev/null +++ b/scripts/transactions/update-mainnet-display.ts @@ -0,0 +1,68 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 +import { TransactionBlock } from '@mysten/sui.js/transactions'; + +import { mainPackage } from '../config/constants'; +import { getImageUrl } from '../init/display_tp'; +import { prepareMultisigTx, signAndExecute } from '../utils/utils'; + +const run = async () => { + const txb = new TransactionBlock(); + const pkg = mainPackage.mainnet; + + const subnameRegistrationType = `0x00c2f85e07181b90c140b15c5ce27d863f93c4d9159d2a4e7bdaeb40e286d6f5::subdomain_registration::SubDomainRegistration`; + const suinsRegistrationType = `${pkg.packageId}::suins_registration::SuinsRegistration`; + + + // update Display + const nameDisplay = txb.object( + `0x866fbd8e51b6637c25f0e811ece9a85eb417f3987ecdfefb80f15d1192d72b4c`, + ); + const subNameDisplay = txb.object( + `0xaf0cdabb6592026c58dae385d84791f21ce8e35a75f343f7e11acaf224f6a680`, + ); + + txb.moveCall({ + target: `0x2::display::edit`, + arguments: [ + nameDisplay, + txb.pure.string('image_url'), + txb.pure.string(getImageUrl(false, 'mainnet')), + ], + typeArguments: [suinsRegistrationType], + }); + + txb.moveCall({ + target: `0x2::display::edit`, + arguments: [ + subNameDisplay, + txb.pure.string('image_url'), + txb.pure.string(getImageUrl(true, 'mainnet')), + ], + typeArguments: [subnameRegistrationType], + }); + + txb.moveCall({ + target: `0x2::display::update_version`, + arguments: [nameDisplay], + typeArguments: [suinsRegistrationType], + }); + + txb.moveCall({ + target: `0x2::display::update_version`, + arguments: [subNameDisplay], + typeArguments: [subnameRegistrationType], + }); + + // transfer nikhil.sui to address! + txb.transferObjects( + [ + txb.object('0x2560cf8d37120ab69c29969fd69f0d9ce2eaf68f874b6a2cd5e2c9b3ae3487c7') + ], + txb.pure.address('0x2fd42dfdbd2eb7055a7bc7d4ce000ae53cc22f0c2f2006862bebc8df1f676027') + ); + + await prepareMultisigTx(txb, 'mainnet', mainPackage.mainnet.adminAddress); +}; + +run();