diff --git a/.github/workflows/suins-build-tx.yaml b/.github/workflows/suins-build-tx.yaml index 0ceba547..b2507c17 100644 --- a/.github/workflows/suins-build-tx.yaml +++ b/.github/workflows/suins-build-tx.yaml @@ -9,8 +9,8 @@ on: type: choice options: - Main package upgrade - - Publish DayOne Package - - DayOne display transfer policy and setup script + - Enable BOGO App + - Disable BOGO App sui_tools_image: description: 'image reference of sui_tools' default: 'mysten/sui-tools:2d985a342263ae224966e871b24beeafe11d782a' @@ -111,7 +111,27 @@ jobs: NETWORK: mainnet ORIGIN: gh_action run: | - cd scripts && pnpm migrations::day_one::setup + cd scripts && pnpm migrations::day_one::setup + + - name: Enable DayOne BOGO Deal + if: ${{ inputs.transaction_type == 'Enable BOGO App' }} + env: + NODE_ENV: production + GAS_OBJECT: ${{ inputs.gas_object_id }} + NETWORK: mainnet + ORIGIN: gh_action + run: | + cd scripts && pnpm migrations::day_one::authorize + + - name: Disable DayOne BOGO Deal + if: ${{ inputs.transaction_type == 'Disable BOGO App' }} + env: + NODE_ENV: production + GAS_OBJECT: ${{ inputs.gas_object_id }} + NETWORK: mainnet + ORIGIN: gh_action + run: | + cd scripts && pnpm migrations::day_one::deauthorize - name: Show Transaction Data (To sign) run: | diff --git a/packages/suins/README.md b/packages/suins/README.md index 35580b43..05064ae8 100644 --- a/packages/suins/README.md +++ b/packages/suins/README.md @@ -7,8 +7,12 @@ This directory contains the main suins package. ## Mainnet Addresses + +- V2: `0xb7004c7914308557f7afbaf0dca8dd258e18e306cb7a45b28019f3d0a693f162` + V2 rev: 2d985a3 -V2: `0xb7004c7914308557f7afbaf0dca8dd258e18e306cb7a45b28019f3d0a693f162` +Introduced `uid` & `uid_mut` for `SuinsRegistration` object. + V1 rev: (was testnet) V1: `0xd22b24490e0bae52676651b4f56660a5ff8022a2576e0089f79b3c88d44e08f0` @@ -17,6 +21,11 @@ V1: `0xd22b24490e0bae52676651b4f56660a5ff8022a2576e0089f79b3c88d44e08f0` +- V3: `0x7e1ed011b9e68f5144d9b12f756a3fb34a5a5d71f294629722214ffa92767487` +rev: `d9bcbb2` + +Introduces `uid` & `uid_mut` for `SuinsRegistration` object. + rev: `a2af559` - V2: `0x0cf216d6964d17c08e35bd85d3c57bee7413209c63f659567b7b44ce125bc44f` diff --git a/scripts/airdrop/authorize-app.ts b/scripts/airdrop/authorize-app.ts new file mode 100644 index 00000000..231118f6 --- /dev/null +++ b/scripts/airdrop/authorize-app.ts @@ -0,0 +1,33 @@ +import { TransactionBlock } from "@mysten/sui.js"; +import { executeTx, prepareSigner } from "./helper"; +import { addressConfig, mainnetConfig } from "../config/day_one"; +import { Network, mainPackage } from "../config/constants"; + +export const authorizeBogoApp = async (network: Network): Promise => { + + const suinsPackageConfig = mainPackage[network]; + const airdropConfig = network === 'mainnet' ? mainnetConfig : addressConfig; + const tx = new TransactionBlock(); + + tx.moveCall({ + target: `${suinsPackageConfig.packageId}::suins::authorize_app`, + arguments: [ + tx.object(suinsPackageConfig.adminCap), + tx.object(suinsPackageConfig.suins), + ], + typeArguments: [`${airdropConfig.packageId}::bogo::BogoApp`], + }); + + // return if we're on multisig execution. + if(airdropConfig.isMainnet) return tx; + + const signer = prepareSigner(mainPackage[network].provider); + await executeTx(signer, tx); +} + + +/* + uncomment any of these when running locally. + */ + +// authorizeBogoApp('mainnet'); diff --git a/scripts/airdrop/deauthorize-app.ts b/scripts/airdrop/deauthorize-app.ts new file mode 100644 index 00000000..198f5940 --- /dev/null +++ b/scripts/airdrop/deauthorize-app.ts @@ -0,0 +1,33 @@ +import { TransactionBlock } from "@mysten/sui.js"; +import { executeTx, prepareSigner } from "./helper"; +import { addressConfig, mainnetConfig } from "../config/day_one"; +import { Network, mainPackage } from "../config/constants"; + +export const deauthorizeBogoApp = async (network: Network): Promise => { + + const suinsPackageConfig = mainPackage[network]; + const airdropConfig = network === 'mainnet' ? mainnetConfig : addressConfig; + const tx = new TransactionBlock(); + + tx.moveCall({ + target: `${suinsPackageConfig.packageId}::suins::deauthorize_app`, + arguments: [ + tx.object(suinsPackageConfig.adminCap), + tx.object(suinsPackageConfig.suins), + ], + typeArguments: [`${airdropConfig.packageId}::bogo::BogoApp`], + }); + + // return if we're on multisig execution. + if(airdropConfig.isMainnet) return tx; + + const signer = prepareSigner(mainPackage[network].provider); + await executeTx(signer, tx); +} + + +/* + uncomment any of these when running locally. + */ + +// deauthorizeBogoApp('mainnet'); diff --git a/scripts/airdrop/helper.ts b/scripts/airdrop/helper.ts index 7022f56e..afc540bb 100644 --- a/scripts/airdrop/helper.ts +++ b/scripts/airdrop/helper.ts @@ -1,4 +1,4 @@ -import { Connection, Ed25519Keypair, JsonRpcProvider, ObjectId, RawSigner, SuiAddress, SuiTransactionBlockResponse, TransactionArgument, TransactionBlock, bcs, getExecutionStatus, getExecutionStatusGasSummary, getExecutionStatusType, isValidSuiAddress, normalizeSuiAddress, testnetConnection, toB64 } +import { Connection, Ed25519Keypair, ExportedKeypair, JsonRpcProvider, ObjectId, RawSigner, SuiAddress, SuiTransactionBlockResponse, TransactionArgument, TransactionBlock, bcs, fromExportedKeypair, getExecutionStatus, getExecutionStatusGasSummary, getExecutionStatusType, isValidSuiAddress, normalizeSuiAddress, testnetConnection, toB64 } from "@mysten/sui.js"; import * as blake2 from 'blake2'; @@ -6,6 +6,7 @@ import fs from "fs"; import { AirdropConfig, addressConfig, mainnetConfig } from "../config/day_one"; import { Network, mainPackage } from "../config/constants"; import { execSync } from 'child_process'; +import { fromHEX } from "@mysten/bcs"; export const MAX_MINTS_PER_TRANSACTION = 2_000; export const TOTAL_RANDOM_ADDRESSES = 48 * MAX_MINTS_PER_TRANSACTION; // attempt with 95K. @@ -17,13 +18,17 @@ export const executeTx = async (signer: RawSigner, tx: TransactionBlock, options chunkNum: number, failedChunks: number[] }) => { + + const requestOptions = options?.isAirdropExecution ? { + showEffects: true + } : { + showObjectChanges: true, + showEffects: true + } return signer .signAndExecuteTransactionBlock({ transactionBlock: tx, - options: { - showObjectChanges: true, - showEffects: true, - }, + options: requestOptions, }) .then(function (res) { if (!(options?.isAirdropExecution)) { @@ -124,6 +129,18 @@ export const prepareSigner = (provider: JsonRpcProvider): RawSigner => { return new RawSigner(keypair, provider); } +export const prepareSignerFromPrivateKey = (network: Network) => { + const privateKey = process.env.PRIVATE_KEY || ''; + if (!privateKey) throw new Error(`ERROR: Private key not exported or exported wrong! Please run 'export PRIVATE_KEY=""'`); + const keyPair: ExportedKeypair = { + schema: 'ED25519', + privateKey: toB64(fromHEX(privateKey)), + }; + + const config = mainPackage[network]; + return new RawSigner(fromExportedKeypair(keyPair), config.provider); +} + // converts an array of addresses to a buffer using the `buffer` module. export const addressesToBuffer = (tx: TransactionBlock, batch: string[], config: AirdropConfig): TransactionArgument => { diff --git a/scripts/config/constants.ts b/scripts/config/constants.ts index d1545256..ca9d1994 100644 --- a/scripts/config/constants.ts +++ b/scripts/config/constants.ts @@ -1,4 +1,4 @@ -import { Connection, JsonRpcProvider, ObjectId, SuiAddress } from "@mysten/sui.js" +import { Connection, JsonRpcProvider, ObjectId, SuiAddress, testnetConnection } from "@mysten/sui.js" export type Network = 'mainnet' | 'testnet' @@ -10,6 +10,8 @@ export type PackageInfo = { publisherId:ObjectId; adminAddress: SuiAddress; provider: JsonRpcProvider; + adminCap: ObjectId; + suins: ObjectId; } export const mainPackage: Config = { @@ -18,15 +20,19 @@ export const mainPackage: Config = { upgradeCap: '0x9cda28244a0d0de294d2b271e772a9c33eb47d316c59913d7369b545b4af098c', publisherId: '0x7339f23f06df3601167d67a31752781d307136fd18304c48c928778e752caae1', adminAddress: '0xa81a2328b7bbf70ab196d6aca400b5b0721dec7615bf272d95e0b0df04517e72', + adminCap: '0x3f8d702d90c572b60ac692fb5074f7a7ac350b80d9c59eab4f6b7692786cae0a', + suins: '0x6e0ddefc0ad98889c04bab9639e512c21766c5e6366f89e696956d9be6952871', provider: new JsonRpcProvider(new Connection({ fullnode: 'https://suins-rpc.mainnet.sui.io' })) }, testnet: { - packageId: '0x48380438a54490534efcd9bea3c48038faf7f386f5a80b647314972a177a242a', - publisherId: '0xf9953e8250dc19d5455e037bbe40a21ecb605871442af23f7b0399076d90bc53', - adminAddress: '0xfe09cf0b3d77678b99250572624bf74fe3b12af915c5db95f0ed5d755612eb68', + packageId: '0x701b8ca1c40f11288a1ed2de0a9a2713e972524fbab748a7e6c137225361653f', + publisherId: '0xd12afb9b5e4a8dc875d22fc927e78952dc9bd84730b33c02e9fd30949c100e38', + adminAddress: '0x7bdfc33239bd05af27d6989cee5455da4bc69ed4cfab5d178434a96ff412514a', + adminCap: '0xadc8b4c3fa0cc022e995968e06fca1d4a47f782f7bb0e88c52730eca77cdae03', + suins: '0xedc672fadedee348108618da7555f771d4fec8d3331779a8411ff8184aded726', provider: new JsonRpcProvider(new Connection({ fullnode: 'https://suins-rpc.testnet.sui.io:443' })) diff --git a/scripts/package.json b/scripts/package.json index f4766aca..f915a439 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -6,13 +6,15 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "transactions::main_package::upgrade": "ts-node transactions/main_package_upgrade.ts", - "transactions::day_one::publish": "ts-node transactions/publish_day_one.ts", - "migrations::day_one::setup": "ts-node transactions/setup_display_tp_and_mints.ts" + "migrations::day_one::authorize": "ts-node transactions/authorize_bogo_app.ts", + "migrations::day_one::deauthorize": "ts-node transactions/deauthorize_bogo_app.ts" + }, "keywords": [], "author": "", "license": "ISC", "dependencies": { + "@mysten/bcs": "^0.7.3", "@mysten/kiosk": "^0.3.3", "@mysten/sui.js": "^0.37.1", "@types/blake2": "^4.0.1", diff --git a/scripts/pnpm-lock.yaml b/scripts/pnpm-lock.yaml index 22b0c59e..8440a7a6 100644 --- a/scripts/pnpm-lock.yaml +++ b/scripts/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@mysten/bcs': + specifier: ^0.7.3 + version: 0.7.3 '@mysten/kiosk': specifier: ^0.3.3 version: 0.3.3 diff --git a/scripts/transactions/authorize_bogo_app.ts b/scripts/transactions/authorize_bogo_app.ts new file mode 100644 index 00000000..40b8147c --- /dev/null +++ b/scripts/transactions/authorize_bogo_app.ts @@ -0,0 +1,19 @@ +// Copyright (c) 2023, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +import dotenv from "dotenv"; +dotenv.config(); +import { prepareMultisigTx } from "../airdrop/helper"; +import { authorizeBogoApp } from "../airdrop/authorize-app"; + +const authorizeApp = async () => { + // read addresses from file + // convert to batches. + const tx = await authorizeBogoApp('mainnet'); + + if(!tx) throw new Error("TX not defined"); + + prepareMultisigTx(tx, 'mainnet'); +} + +authorizeApp(); diff --git a/scripts/transactions/deauthorize_bogo_app.ts b/scripts/transactions/deauthorize_bogo_app.ts new file mode 100644 index 00000000..43c3d6ee --- /dev/null +++ b/scripts/transactions/deauthorize_bogo_app.ts @@ -0,0 +1,19 @@ +// Copyright (c) 2023, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +import dotenv from "dotenv"; +dotenv.config(); +import { prepareMultisigTx } from "../airdrop/helper"; +import { deauthorizeBogoApp } from "../airdrop/deauthorize-app"; + +const deauthorizeApp = async () => { + // read addresses from file + // convert to batches. + const tx = await deauthorizeBogoApp('mainnet'); + + if(!tx) throw new Error("TX not defined"); + + prepareMultisigTx(tx, 'mainnet'); +} + +deauthorizeApp();