From 120b3585e3dbb58767d7c306cfa12562f8e8a33b Mon Sep 17 00:00:00 2001 From: Manolis Liolios Date: Sat, 20 Apr 2024 11:11:41 +0300 Subject: [PATCH] More improvements --- scripts/init/packages.ts | 23 ++++++++--- scripts/init/setup.ts | 13 +++++++ .../renewals/authorize_renewals.ts | 39 +++++++------------ 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/scripts/init/packages.ts b/scripts/init/packages.ts index b5370d41..d7526bf3 100644 --- a/scripts/init/packages.ts +++ b/scripts/init/packages.ts @@ -148,15 +148,26 @@ export const Packages = (network: Network) => { authorizationType: `${packageId}::renew::Renew`, } }, - setupFunction: (txb: TransactionBlock, packageId: string, suinsPackageIdV1: string, adminCap: string, suins: string) => { + setupFunction: ({ + txb, + packageId, + adminCap, + suinsPackageIdV1, + suins, + priceList + } : { + txb: TransactionBlock, + packageId: string, + suinsPackageIdV1: string, + adminCap: string, + suins: string; + priceList: { [key: string]: number }; + } + ) => { const configuration = newPriceConfig({ txb, suinsPackageIdV1, - priceList: { - three: 2 * Number(MIST_PER_SUI), - four: 1 * Number(MIST_PER_SUI), - fivePlus: 0.2 * Number(MIST_PER_SUI) - } + priceList }); setupApp({ txb, diff --git a/scripts/init/setup.ts b/scripts/init/setup.ts index e335a1c5..95b16651 100644 --- a/scripts/init/setup.ts +++ b/scripts/init/setup.ts @@ -4,6 +4,7 @@ import { authorizeApp } from "./authorization"; import packageInfo from "../published.json"; import { signAndExecute } from "../utils/utils"; import { PackageInfo } from "./types"; +import { MIST_PER_SUI } from "@mysten/sui.js/utils"; export const setup = async (packageInfo: PackageInfo, network: Network) => { const packages = Packages(network); @@ -25,6 +26,18 @@ export const setup = async (packageInfo: PackageInfo, network: Network) => { packages.Subdomains.setupFunction(txb, packageInfo.Subdomains.packageId, packageInfo.SuiNS.adminCap, packageInfo.SuiNS.suins); packages.DenyList.setupFunction(txb, packageInfo.DenyList.packageId, packageInfo.SuiNS.adminCap, packageInfo.SuiNS.suins); packages.SuiNS.setupFunction(txb, packageInfo.SuiNS.packageId, packageInfo.SuiNS.adminCap, packageInfo.SuiNS.suins, packageInfo.SuiNS.publisher); + packages.Renewal.setupFunction({ + txb, + adminCap: packageInfo.SuiNS.adminCap, + suins: packageInfo.SuiNS.suins, + packageId: packageInfo.Renewal.packageId, + suinsPackageIdV1: packageInfo.SuiNS.packageId, + priceList: { + three: 2 * Number(MIST_PER_SUI), + four: 1 * Number(MIST_PER_SUI), + fivePlus: 0.2 * Number(MIST_PER_SUI) + } + }); try{ await signAndExecute(txb, network); diff --git a/scripts/transactions/renewals/authorize_renewals.ts b/scripts/transactions/renewals/authorize_renewals.ts index f4100a40..c7b25789 100644 --- a/scripts/transactions/renewals/authorize_renewals.ts +++ b/scripts/transactions/renewals/authorize_renewals.ts @@ -7,37 +7,24 @@ import { MIST_PER_SUI } from "@mysten/sui.js/utils"; import { Network, mainPackage } from "../../config/constants"; import { TransactionBlock } from "@mysten/sui.js/transactions"; import { prepareMultisigTx, signAndExecute } from "../../utils/utils"; -import { authorizeApp, newPriceConfig, setupApp } from "../../init/authorization"; +import { Packages } from "../../init/packages"; export const authorize = async (network: Network) => { const txb = new TransactionBlock(); const config = mainPackage[network]; - authorizeApp({ - txb, - adminCap: config.adminCap, - suins: config.suins, - type: `${config.renewalsPackageId}::renew::Renew`, - suinsPackageIdV1: config.packageId - }); - - const configuration = newPriceConfig({ - txb, - suinsPackageIdV1: config.packageId, - priceList: { - three: 50 * Number(MIST_PER_SUI), - four: 10 * Number(MIST_PER_SUI), - fivePlus: 2 * Number(MIST_PER_SUI) - } - }); - - setupApp({ - txb, - adminCap: config.adminCap, - suins: config.suins, - target: `${config.renewalsPackageId}::renew::setup`, - args: [configuration] - }); + Packages('mainnet').Renewal.setupFunction({ + txb, + adminCap: config.adminCap, + suins: config.suins, + packageId: config.renewalsPackageId, + suinsPackageIdV1: config.packageId, + priceList: { + three: 50 * Number(MIST_PER_SUI), + four: 10 * Number(MIST_PER_SUI), + fivePlus: 2 * Number(MIST_PER_SUI) + } + }); // for mainnet, we just prepare multisig TX if(network === 'mainnet') return prepareMultisigTx(txb, 'mainnet');