Skip to content

Commit

Permalink
More improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
manolisliolios committed Apr 20, 2024
1 parent d70c615 commit 120b358
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 32 deletions.
23 changes: 17 additions & 6 deletions scripts/init/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions scripts/init/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
39 changes: 13 additions & 26 deletions scripts/transactions/renewals/authorize_renewals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 120b358

Please sign in to comment.