Skip to content

Commit

Permalink
Introduce new display (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
manolisliolios authored Jul 25, 2024
1 parent 9600a51 commit 308cf9b
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 31 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/suins-build-tx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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: |
Expand Down
34 changes: 18 additions & 16 deletions scripts/init/display_tp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand Down
4 changes: 4 additions & 0 deletions scripts/init/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ export const Packages = (network: Network) => {
publisher,
isSubdomain: false,
suinsPackageIdV1: packageId,
network: 'testnet',
subdomainsPackageId: packageId,
});
// create display for subnames
createDisplay({
txb,
publisher,
isSubdomain: true,
suinsPackageIdV1: packageId,
network: 'testnet',
subdomainsPackageId: packageId,
});
},
},
Expand Down
68 changes: 68 additions & 0 deletions scripts/transactions/update-mainnet-display.ts
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 308cf9b

Please sign in to comment.