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

update scripts libraries #66

Merged
merged 16 commits into from
Mar 28, 2024
7 changes: 7 additions & 0 deletions packages/registration/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[move]
version = 0
manifest_digest = "75434D5374AE0B76DFC7B2C8B1D93D92E43B7C10C03782CF67925E35F379A78A"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"

dependencies = [
{ name = "Sui" },
Expand All @@ -27,3 +29,8 @@ source = { local = "../suins" }
dependencies = [
{ name = "Sui" },
]

[move.toolchain-version]
compiler-version = "1.19.0"
edition = "legacy"
flavor = "sui"
2 changes: 1 addition & 1 deletion packages/registration/sources/register.move
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ module registration::register {
let registry = suins::app_registry_mut<Register, Registry>(Register {}, suins);
registry::add_record(registry, domain, no_years, clock, ctx)
}
}
}
2 changes: 1 addition & 1 deletion packages/registration/tests/register_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,4 @@ module registration::register_tests {

test_scenario::end(scenario_val);
}
}
}
29 changes: 17 additions & 12 deletions scripts/airdrop/airdrop-mint.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// TESTNET VERSION HERE. WILL CLEAN UP.
import { SuiObjectData, SuiObjectRef, SuiTransactionBlockResponse, TransactionBlock, getExecutionStatusType } from "@mysten/sui.js";
import { TransactionBlock } from "@mysten/sui.js/transactions";
import { SuiClient, SuiObjectData, SuiObjectRef, SuiTransactionBlockResponse } from "@mysten/sui.js/client";

import { MAX_MINTS_PER_TRANSACTION, addressesToBuffer, csvToBatches, executeTx, readAddressesFromFile }
from './helper';
import { prepareSigner } from "./helper";
import { addressConfig } from "../config/day_one";
import { mainPackage } from "../config/constants";
import { Network, PackageInfo, mainPackage } from "../config/constants";

const SUI_COIN_TYPE = '0x2::coin::Coin<0x2::sui::SUI>';

const network = 'testnet' // change to mainnet when running it.

const signer = prepareSigner(mainPackage[network].provider);
const signer = prepareSigner();

const config = addressConfig;
const usedCoinObjects = new Set();
Expand All @@ -23,11 +24,11 @@ const millisToMinutesAndSeconds = (millis: number) => {
}

/* get X amount of chunks of Coins based on amount per tx. */
const prepareCoinObjects = async (chunks: number) => {
const prepareCoinObjects = async (chunks: number, client: SuiClient) => {
const tx = new TransactionBlock();

// get the base gas coin from the provider
const { data } = await signer.provider.getObject({
const { data } = await client.getObject({
id: config.baseCoinObjectId
});

Expand All @@ -49,7 +50,7 @@ const prepareCoinObjects = async (chunks: number) => {
}

tx.transferObjects(coinsSplitted, tx.pure(config.massMintingAddress, 'address'));
const res = await executeTx(signer, tx);
const res = await executeTx(signer, tx, mainPackage[network].client);

//@ts-ignore
return res?.objectChanges?.filter(x => x.type === 'created' && x.objectType === SUI_COIN_TYPE).map((x: SuiObjectData) => (
Expand All @@ -64,7 +65,8 @@ const prepareCoinObjects = async (chunks: number) => {
/**
* Mints a batch of bullsharks.
* */
const mintDayOne = async ({
const mintDayOne = async (client: SuiClient,
{
id,
batch,
coinObject,
Expand Down Expand Up @@ -97,7 +99,7 @@ const mintDayOne = async ({
tx.setGasBudget(2_900_000_000);


let res = await executeTx(signer, tx, {
let res = await executeTx(signer, tx, client, {
isAirdropExecution: true,
chunkNum: id,
failedChunks
Expand All @@ -106,7 +108,7 @@ const mintDayOne = async ({
return getExecutionStatusType(res as SuiTransactionBlockResponse) === 'success';
}

const executeMintsForBatches = async (batches: string[][], initialBatch = 0) => {
const executeMintsForBatches = async (batches: string[][], initialBatch = 0, network: Network) => {

const MAX_BATCH_SIZE = 50; // The current airdrop is doable in 48 hashes. 50 batches will be running concurrently.
let start = Date.now(); // time we started the mint process.
Expand All @@ -115,11 +117,13 @@ const executeMintsForBatches = async (batches: string[][], initialBatch = 0) =>
let success = 0;
let fail = 0;
const failedChunks: number[] = [];
let config = mainPackage[network];

while (currentSliceStart < batches.length) {
const batchToExecute = batches.slice(currentSliceStart, currentSliceStart + MAX_BATCH_SIZE);

const results = await executeConcurrently(
config,
batchToExecute,
{
sliceStart: currentSliceStart,
Expand Down Expand Up @@ -151,12 +155,12 @@ const executeMintsForBatches = async (batches: string[][], initialBatch = 0) =>
}


const executeConcurrently = async (slicedBatches: string[][], options: {
const executeConcurrently = async (config: PackageInfo, slicedBatches: string[][], options: {
sliceStart: number;
failedChunks: number[];
}) => {

const coins = await prepareCoinObjects(slicedBatches.length + 1); // does the splitting of coins with some extra space.
const coins = await prepareCoinObjects(slicedBatches.length + 1, config.client); // does the splitting of coins with some extra space.

if (!coins) {
console.error("Failed to prepare coins on slice: " + options.sliceStart);
Expand All @@ -165,7 +169,8 @@ const executeConcurrently = async (slicedBatches: string[][], options: {

return await Promise.all(
slicedBatches.map((slice, index) =>
mintDayOne({
mintDayOne(config.client,
{
id: options.sliceStart + index,
batch: slice,
coinObject: coins[index],
Expand Down
7 changes: 3 additions & 4 deletions scripts/airdrop/airdrop-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionBlock } from "@mysten/sui.js";
import { TransactionBlock } from "@mysten/sui.js/transactions";
import { batchToHash, executeTx, prepareSigner } from "./helper";
import { addressConfig, mainnetConfig } from "../config/day_one";
import { createDayOneDisplay, createDayOneTransferPolicy } from "../day_one/setup";
Expand Down Expand Up @@ -35,13 +35,12 @@ export const setupAirdrop = async (batches: string[][], network: Network): Promi
// add the DayOne Display.
createDayOneDisplay(tx, network);
// attach TransferPolicy to make it tradeable.
await createDayOneTransferPolicy(tx, suinsPackageConfig.provider, network);
await createDayOneTransferPolicy(tx, network);

// return if we're on multisig execution.
if(airdropConfig.isMainnet) return tx;

const signer = prepareSigner(mainPackage[network].provider);
await executeTx(signer, tx);
await executeTx(prepareSigner(), tx, mainPackage[network].client);
}


Expand Down
5 changes: 2 additions & 3 deletions scripts/airdrop/authorize-app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionBlock } from "@mysten/sui.js";
import { TransactionBlock } from "@mysten/sui.js/transactions";
import { executeTx, prepareSigner } from "./helper";
import { addressConfig, mainnetConfig } from "../config/day_one";
import { Network, mainPackage } from "../config/constants";
Expand All @@ -21,8 +21,7 @@ export const authorizeBogoApp = async (network: Network): Promise<TransactionBlo
// return if we're on multisig execution.
if(airdropConfig.isMainnet) return tx;

const signer = prepareSigner(mainPackage[network].provider);
await executeTx(signer, tx);
await executeTx(prepareSigner(), tx, mainPackage[network].client);
}


Expand Down
12 changes: 7 additions & 5 deletions scripts/airdrop/coins.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { RawSigner, TransactionBlock } from "@mysten/sui.js";
import { TransactionBlock } from "@mysten/sui.js/transactions";
import {executeTx } from "./helper";
import { AirdropConfig } from "../config/day_one";
import { Ed25519Keypair } from "@mysten/sui.js/keypairs/ed25519";
import { SuiClient } from "@mysten/sui.js/client";

// Merges all other coins to the coin defined in the config.
export const cleanUpCoins = async (signer: RawSigner, config: AirdropConfig) => {
export const cleanUpCoins = async (signer: Ed25519Keypair, config: AirdropConfig, client: SuiClient) => {
let hasNextPage = true;
let cursor = undefined;
let coins = [];

while (hasNextPage) {
const data = await signer.provider.getAllCoins({
const data = await client.getAllCoins({
owner: config.massMintingAddress,
cursor,
limit: 50
Expand All @@ -32,7 +34,7 @@ export const cleanUpCoins = async (signer: RawSigner, config: AirdropConfig) =>

while (count > 1) {
// get the base gas coin from the provider
const { data } = await signer.provider.getObject({
const { data } = await client.getObject({
id: config.baseCoinObjectId
});

Expand Down Expand Up @@ -63,7 +65,7 @@ export const cleanUpCoins = async (signer: RawSigner, config: AirdropConfig) =>
}))
]);

const res = await executeTx(signer, tx);
const res = await executeTx(signer, tx, client);
if(res) count = count - mergeAbleCoins.length -1;
}
}
5 changes: 2 additions & 3 deletions scripts/airdrop/deauthorize-app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionBlock } from "@mysten/sui.js";
import { TransactionBlock } from "@mysten/sui.js/transactions";
import { executeTx, prepareSigner } from "./helper";
import { addressConfig, mainnetConfig } from "../config/day_one";
import { Network, mainPackage } from "../config/constants";
Expand All @@ -21,8 +21,7 @@ export const deauthorizeBogoApp = async (network: Network): Promise<TransactionB
// return if we're on multisig execution.
if(airdropConfig.isMainnet) return tx;

const signer = prepareSigner(mainPackage[network].provider);
await executeTx(signer, tx);
await executeTx(prepareSigner(), tx, mainPackage[network].client);
}


Expand Down
Loading
Loading