Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quest 3 setup scripts #27

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/suins-build-tx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
description: 'select transaction type to create'
type: choice
options:
- Publish Utils
- Authorize Utils
- Publish Discounts
- Authorize Discounts
- Withdraw Auction Profits
- Transfer Reserved Names
- Main package upgrade
Expand Down Expand Up @@ -115,25 +115,25 @@ jobs:
run: |
cd scripts && pnpm withdraw:auction:profits

- name: Publish Utils
if: ${{ inputs.transaction_type == 'Publish Utils' }}
- name: Publish Discounts
if: ${{ inputs.transaction_type == 'Publish Discounts' }}
env:
NODE_ENV: production
GAS_OBJECT: ${{ inputs.gas_object_id }}
NETWORK: mainnet
ORIGIN: gh_action
run: |
cd scripts && pnpm publish-utils
cd scripts && pnpm publish-discounts

- name: Authorize Utils
if: ${{ inputs.transaction_type == 'Authorize Utils' }}
- name: Authorize Discounts
if: ${{ inputs.transaction_type == 'Authorize Discounts' }}
env:
NODE_ENV: production
GAS_OBJECT: ${{ inputs.gas_object_id }}
NETWORK: mainnet
ORIGIN: gh_action
run: |
cd scripts && pnpm authorize-utils
cd scripts && pnpm authorize-discounts

- name: Show Transaction Data (To sign)
run: |
Expand Down
3 changes: 2 additions & 1 deletion packages/day_one/Move.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[package]
name = "day_one"
version = "0.0.1"
published-at="0xbf1431324a4a6eadd70e0ac6c5a16f36492f255ed4d011978b2cf34ad738efe6"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "2d985a3" }

suins = { local = "../suins" }

[addresses]
day_one = "0x0"
day_one = "0xbf1431324a4a6eadd70e0ac6c5a16f36492f255ed4d011978b2cf34ad738efe6"
10 changes: 10 additions & 0 deletions packages/day_one/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ We will have new promotions that will depend on the `DayOne` struct,
but it will only be useful as long as users have activated it.

The DayOne can only be activated by the `bogo` module, which is the first promotion run for DayOne holders.


## Mainnet

V1: `0xbf1431324a4a6eadd70e0ac6c5a16f36492f255ed4d011978b2cf34ad738efe6`

## Testnet


V1: `0x7bd306e890d403f52d89e860a3c21a8c5717e64f954103b3023cafa31179e60c`
6 changes: 3 additions & 3 deletions packages/discounts/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 0
manifest_digest = "87F5FF1A0FA485D7D0BCCB2C91C7735B8B019AE73BA311049CEED5DDBEF1E16A"
manifest_digest = "3AED8A6ABDB452446388F627000D349F8CCC747A20B6A81510D9A94CD9782C8A"
deps_digest = "060AD7E57DFB13104F21BE5F5C3759D03F0553FC3229247D9A7A6B45F50D03A3"

dependencies = [
Expand All @@ -13,11 +13,11 @@ dependencies = [

[[move.package]]
name = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
name = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/sui-framework" }
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ name = "MoveStdlib" },
Expand Down
2 changes: 1 addition & 1 deletion packages/discounts/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "discounts"
version = "0.0.1"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet", override=true }
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override=true }
suins = { local = "../suins" }
day_one = { local = "../day_one" }

Expand Down
4 changes: 3 additions & 1 deletion packages/discounts/sources/discounts.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// Can be called only when promotions are active for a specific type T.
/// Activation / deactivation happens through PTBs.
module discounts::discounts {

use std::option::{Option};
use std::string::{Self, String};
use std::type_name::{Self as type};

Expand Down Expand Up @@ -57,6 +57,7 @@ module discounts::discounts {
domain_name: String,
payment: Coin<SUI>,
clock: &Clock,
_reseller: Option<String>,
ctx: &mut TxContext
): SuinsRegistration {
// For normal flow, we do not allow DayOne to be used.
Expand All @@ -75,6 +76,7 @@ module discounts::discounts {
domain_name: String,
payment: Coin<SUI>,
clock: &Clock,
_reseller: Option<String>,
ctx: &mut TxContext
): SuinsRegistration {
assert!(is_active(day_one), ENotActiveDayOne);
Expand Down
6 changes: 3 additions & 3 deletions packages/discounts/tests/discount_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#[test_only]
module discounts::discount_tests {

use std::option;
use std::string::{utf8, String};

use sui::test_scenario::{Self as ts, Scenario, ctx};
Expand Down Expand Up @@ -78,7 +78,7 @@ module discounts::discount_tests {
let discount_house = ts::take_shared<DiscountHouse>(scenario);
let clock = ts::take_shared<Clock>(scenario);

let name = discounts::register<T>(&mut discount_house, &mut suins, item, domain_name, payment, &clock, ctx(scenario));
let name = discounts::register<T>(&mut discount_house, &mut suins, item, domain_name, payment, &clock, option::none(), ctx(scenario));

transfer::public_transfer(name, user);

Expand All @@ -99,7 +99,7 @@ module discounts::discount_tests {
let discount_house = ts::take_shared<DiscountHouse>(scenario);
let clock = ts::take_shared<Clock>(scenario);

let name = discounts::register_with_day_one(&mut discount_house, &mut suins, item, domain_name, payment, &clock, ctx(scenario));
let name = discounts::register_with_day_one(&mut discount_house, &mut suins, item, domain_name, payment, &clock, option::none(), ctx(scenario));

transfer::public_transfer(name, user);

Expand Down
14 changes: 13 additions & 1 deletion scripts/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export type PackageInfo = {
suins: string;
displayObject?: string;
directSetupPackageId: string;
discountsPackage: {
packageId: string;
discountHouseId: string;
}
}

export const mainPackage: Config = {
Expand All @@ -30,6 +34,10 @@ export const mainPackage: Config = {
provider: new JsonRpcProvider(new Connection({
fullnode: 'https://suins-rpc.mainnet.sui.io'
})),
discountsPackage: {
packageId: 'TODO: FILL THIS IN',
discountHouseId: 'TODO: Fill this in',
},
directSetupPackageId: '0xdac22652eb400beb1f5e2126459cae8eedc116b73b8ad60b71e3e8d7fdb317e2'

},
Expand All @@ -43,7 +51,11 @@ export const mainPackage: Config = {
provider: new JsonRpcProvider(new Connection({
fullnode: 'https://suins-rpc.testnet.sui.io:443'
})),
directSetupPackageId: '0x9af70a4cb6d7144e68fd972eef672a74c7fe41aa5c0bb67ba40d7d1ae87bfb19'
directSetupPackageId: '0x9af70a4cb6d7144e68fd972eef672a74c7fe41aa5c0bb67ba40d7d1ae87bfb19',
discountsPackage: {
packageId: '0xa784ba6d2a3e7f0a51f332ce0cbb147e72b09b03ed56e96024178c538f9ff0ab',
discountHouseId: '0x599385bf98d823368069df46143ce9906aa4dec8beedfe8f560fcceb2b5580e5',
},
}
}

Expand Down
4 changes: 3 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"transfer::names": "ts-node reserved-names/transfer-names.ts",
"withdraw:auction:profits":"ts-node transactions/withdraw_funds_20290927.ts",
"publish-utils": "ts-node transactions/publish_utils.ts",
"authorize-utils": "ts-node transactions/authorize_utils.ts"
"authorize-utils": "ts-node transactions/authorize_utils.ts",
"publish-discounts": "ts-node transactions/publish_discounts.ts",
"authorize-discounts": "ts-node transactions/quest_3_setup.ts"
},
"keywords": [],
"author": "",
Expand Down
22 changes: 22 additions & 0 deletions scripts/transactions/publish_coupons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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;

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/coupons && ${publishCall} > $PWD/../../scripts/tx/tx-data.txt`);
}

publish();
22 changes: 22 additions & 0 deletions scripts/transactions/publish_discounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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;

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/discounts && ${publishCall} > $PWD/../../scripts/tx/tx-data.txt`);
}

publish();
109 changes: 109 additions & 0 deletions scripts/transactions/quest_3_setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// 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 { Network, PackageInfo, mainPackage } from "../config/constants";
import { MIST_PER_SUI, TransactionBlock } from "@mysten/sui.js";

const SUIFREN_BULLSHARK_TYPE: Record<Network, string> = {
mainnet: '0xee496a0cc04d06a345982ba6697c90c619020de9e274408c7819f787ff66e1a1::suifrens::SuiFren<0x8894fa02fc6f36cbc485ae9145d05f247a78e220814fb8419ab261bd81f08f32::bullshark::Bullshark>',
testnet: '0x80d7de9c4a56194087e0ba0bf59492aa8e6a5ee881606226930827085ddf2332::suifrens::SuiFren<0x297d8afb6ede450529d347cf9254caeea2b685c8baef67b084122291ebaefb38::bullshark::Bullshark>'
};

const SUIFREN_CAPY_TYPE: Record<Network, string> = {
mainnet: '0xee496a0cc04d06a345982ba6697c90c619020de9e274408c7819f787ff66e1a1::suifrens::SuiFren<0xee496a0cc04d06a345982ba6697c90c619020de9e274408c7819f787ff66e1a1::capy::Capy>',
testnet: '0x80d7de9c4a56194087e0ba0bf59492aa8e6a5ee881606226930827085ddf2332::suifrens::SuiFren<0x80d7de9c4a56194087e0ba0bf59492aa8e6a5ee881606226930827085ddf2332::capy::Capy>'
};

const DAY_ONE_TYPE: Record<Network, string> = {
mainnet: '0xbf1431324a4a6eadd70e0ac6c5a16f36492f255ed4d011978b2cf34ad738efe6::day_one::DayOne',
testnet: '0x71c2dc2ce8a3cde0f7fa6638519c64f24b1b7bc20e8272d2ca0690ffbbfabc4a::day_one::DayOne'
};

// Discount setup. (Final pricing)
export type Discount = {
threeCharacterPrice: bigint;
fourCharacterPrice: bigint;
fivePlusCharacterPrice: bigint;
}
// A char range available for free claims.
export type Range = {
from: number;
to: number;
}

// Sets up discount prices for type.
const setupDiscountForType = (txb: TransactionBlock, setup: PackageInfo, type: string, prices: Discount) => {
txb.moveCall({
target: `${setup.discountsPackage.packageId}::discounts::authorize_type`,
arguments: [
txb.object(setup.adminCap),
txb.object(setup.discountsPackage.discountHouseId),
txb.pure(prices.threeCharacterPrice, 'u64'),
txb.pure(prices.fourCharacterPrice, 'u64'),
txb.pure(prices.fivePlusCharacterPrice, 'u64'),
],
typeArguments: [type]
});
}

// Sets up free claims for type.
const setupFreeClaimsForType = (txb: TransactionBlock, setup: PackageInfo, type: string, characters: Range) => {
txb.moveCall({
target: `${setup.discountsPackage.packageId}::free_claims::authorize_type`,
arguments: [
txb.object(setup.adminCap),
txb.object(setup.discountsPackage.discountHouseId),
txb.pure([characters.from, characters.to], 'vector<u8>')
],
typeArguments: [type]
});
}

// Setup Quests 3.
const setup = async (network: Network) => {
const setup = mainPackage[network];

const txb = new TransactionBlock();

// authorize `discount` package to claim names
txb.moveCall({
target: `${setup.packageId}::suins::authorize_app`,
arguments: [
txb.object(setup.adminCap),
txb.object(setup.suins),
],
typeArguments: [`${setup.discountsPackage.packageId}::house::DiscountHouseApp`],
});

// setup `discount` both for free-claims & discounts by presenting type.
// 3 chars -> 250 | 4 chars -> 50 | 5 chars+ -> 10
const priceList: Discount = {
threeCharacterPrice: 250n * MIST_PER_SUI,
fourCharacterPrice: 50n * MIST_PER_SUI,
fivePlusCharacterPrice: 10n * MIST_PER_SUI
};

/// authorize the discounts package to allow name registrations.
setupDiscountForType(txb, setup, SUIFREN_BULLSHARK_TYPE[network], priceList);
setupDiscountForType(txb, setup, SUIFREN_CAPY_TYPE[network], priceList);
setupDiscountForType(txb, setup, DAY_ONE_TYPE[network], priceList);

// authorize the free claims to allow free claiming for 10+ names.
setupFreeClaimsForType(txb, setup, SUIFREN_BULLSHARK_TYPE[network], { from: 10, to: 63 });
setupFreeClaimsForType(txb, setup, SUIFREN_CAPY_TYPE[network], { from: 10, to: 63 });
setupFreeClaimsForType(txb, setup, DAY_ONE_TYPE[network], { from: 10, to: 63 });

// for mainnet, we prepare the multi-sig tx.
if(network === 'mainnet') return prepareMultisigTx(txb, 'mainnet');

// For testnet, we execute the TX directly.
return executeTx(prepareSigner(setup.provider), txb);
}

if(process.env.NETWORK === 'mainnet') setup('mainnet')
else setup('testnet');


2 changes: 1 addition & 1 deletion scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand Down