Skip to content

Commit

Permalink
renewals
Browse files Browse the repository at this point in the history
  • Loading branch information
manolisliolios committed Mar 27, 2024
1 parent 2854e08 commit 3e9a8a0
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 5 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/suins-build-tx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ on:
options:
- Disable Discounts
- Disable Free Claims
- Publish Discounts
- Authorize Discounts
- Withdraw Auction Profits
- Transfer Reserved Names
- Main package upgrade
- Create Deepbook Pools
- Publish Renewals
- Authorize Renewals
sui_tools_image:
description: 'image reference of sui_tools'
default: 'mysten/sui-tools:mainnet'
Expand Down Expand Up @@ -168,6 +169,26 @@ jobs:
run: |
cd scripts && pnpm create-deepbook-pools
- name: Publish Renewals
if: ${{ inputs.transaction_type == 'Publish Renewals' }}
env:
NODE_ENV: production
GAS_OBJECT: ${{ inputs.gas_object_id }}
NETWORK: mainnet
ORIGIN: gh_action
run: |
cd scripts && pnpm publish-renewals
- name: Authorize Renewals
if: ${{ inputs.transaction_type == 'Authorize Renewals' }}
env:
NODE_ENV: production
GAS_OBJECT: ${{ inputs.gas_object_id }}
NETWORK: mainnet
ORIGIN: gh_action
run: |
cd scripts && pnpm authorize-renewals
- name: Show Transaction Data (To sign)
run: |
cat scripts/tx/tx-data.txt
Expand Down
7 changes: 5 additions & 2 deletions scripts/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export type PackageInfo = {
discountsPackage: {
packageId: string;
discountHouseId: string;
}
},
renewalsPackageId: string;
}

export const mainPackage: Config = {
Expand All @@ -38,7 +39,8 @@ export const mainPackage: Config = {
packageId: '0x6a6ea140e095ddd82f7c745905054b3203129dd04a09d0375416c31161932d2d',
discountHouseId: '0x7fdd883c0b7427f18cdb498c4c87a4a79d6bec4783cb3f21aa3816bbc64ce8ef',
},
directSetupPackageId: '0xdac22652eb400beb1f5e2126459cae8eedc116b73b8ad60b71e3e8d7fdb317e2'
directSetupPackageId: '0xdac22652eb400beb1f5e2126459cae8eedc116b73b8ad60b71e3e8d7fdb317e2',
renewalsPackageId: '',

},
testnet: {
Expand All @@ -56,6 +58,7 @@ export const mainPackage: Config = {
packageId: '0x319364827e018833f545d8291f0482c5859ead75663543dda153b50df83244eb',
discountHouseId: '0x5cee9eadc06ae2a330ba8caee517fc1502dffae6474454c45f79f0b00d148ec4',
},
renewalsPackageId: '',
}
}

Expand Down
4 changes: 3 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"authorize-discounts": "ts-node transactions/quest_3_setup.ts",
"disable-free-claims": "ts-node transactions/quest3/disable_free_claims.ts",
"disable-discounts": "ts-node transactions/quest3/disable_discounts.ts",
"create-deepbook-pools": "ts-node transactions/deepbook/create_pools.ts"
"create-deepbook-pools": "ts-node transactions/deepbook/create_pools.ts",
"publish-renewals": "ts-node transactions/renewals/publish_renewals.ts",
"authorize-renewals": "ts-node transactions/renewals/authorize_renewals.ts"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion scripts/reserved-names/owned-objects.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions scripts/transactions/renewals/authorize_renewals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2023, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import dotenv from "dotenv";
dotenv.config();
import { executeTx, prepareMultisigTx, prepareSigner } from "../../airdrop/helper";
import { MIST_PER_SUI, TransactionBlock } from "@mysten/sui.js";
import { Network, mainPackage } from "../../config/constants";

export const authorize = async (network: Network) => {
const txb = new TransactionBlock();

const config = mainPackage[network];
txb.moveCall({
target: `${config.packageId}::suins::authorize_app`,
arguments: [
txb.object(config.adminCap),
txb.object(config.suins),
],
typeArguments: [`${config.renewalsPackageId}::renew::Renew`],
});

const configuration = txb.moveCall({
target: `${config.packageId}::config::new`,
arguments: [
txb.pure([...Array(33).keys()]),
txb.pure(50n * MIST_PER_SUI),
txb.pure(10n * MIST_PER_SUI),
txb.pure(2n * MIST_PER_SUI),
],
});

txb.moveCall({
target: `${config.renewalsPackageId}::renew::setup`,
arguments: [
txb.object(config.adminCap),
txb.object(config.suins),
configuration,
],
typeArguments: [],
});

// for mainnet, we just prepare multisig TX
if(network === 'mainnet') return prepareMultisigTx(txb, 'mainnet');

return executeTx(prepareSigner(config.provider), txb);
}

authorize("mainnet");
23 changes: 23 additions & 0 deletions scripts/transactions/renewals/publish_renewals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2023, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import dotenv from "dotenv";
dotenv.config();
import { execSync } from 'child_process';

const gasObject = process.env.GAS_OBJECT;

// Github actions are always on mainnet.
const publish = async () => {

if(!gasObject) throw new Error("Gas Object not supplied for a mainnet transaction");

// on GH Action, the sui binary is located on root. Referencing that as `/` doesn't work.
const suiFolder = process.env.ORIGIN === 'gh_action' ? '../../sui' : 'sui';
const publishCall = `${suiFolder} client publish --gas-budget 3000000000 --gas ${gasObject} --serialize-unsigned-transaction`

// to suins/..(packages)/..(base)/scripts/tx/tx-data.txt
execSync(`cd $PWD/../packages/renewal && ${publishCall} > $PWD/../../scripts/tx/tx-data.txt`);
}

publish();

0 comments on commit 3e9a8a0

Please sign in to comment.