From 5001e9c34c2edd6b281edc7c0ff703e53fa66111 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:17:53 +0300 Subject: [PATCH] Bump @mysten/sui from 1.4.0 to 1.8.0 (#165) * Bump @mysten/sui from 1.4.0 to 1.8.0 Bumps [@mysten/sui](https://github.com/MystenLabs/sui) from 1.4.0 to 1.8.0. - [Release notes](https://github.com/MystenLabs/sui/releases) - [Changelog](https://github.com/MystenLabs/sui/blob/main/RELEASES.md) - [Commits](https://github.com/MystenLabs/sui/compare/devnet-v1.4.0...devnet-v1.8.0) --- updated-dependencies: - dependency-name: "@mysten/sui" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Some trials to fix the e2e tests * Update @mysten/sui dep * Fix e2e tests --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Manolis Liolios --- .changeset/tough-lemons-design.md | 5 +++++ .github/workflows/sdk_test.yml | 3 ++- pnpm-lock.yaml | 18 +++++++++--------- scripts/init/init.ts | 4 +++- scripts/init/publish.ts | 18 +++++++++++++++--- scripts/init/setup.ts | 9 ++++++++- scripts/utils/utils.ts | 16 +++++++++++++--- sdk/package.json | 2 +- sdk/test/setup.ts | 12 +++++++++++- sdk/test/toolbox.ts | 18 ++++++++++++++++-- 10 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 .changeset/tough-lemons-design.md diff --git a/.changeset/tough-lemons-design.md b/.changeset/tough-lemons-design.md new file mode 100644 index 00000000..8633ec62 --- /dev/null +++ b/.changeset/tough-lemons-design.md @@ -0,0 +1,5 @@ +--- +"@mysten/suins": patch +--- + +Update @mysten/sui dependency to 1.8.0 diff --git a/.github/workflows/sdk_test.yml b/.github/workflows/sdk_test.yml index e0151bec..1507fed2 100644 --- a/.github/workflows/sdk_test.yml +++ b/.github/workflows/sdk_test.yml @@ -48,5 +48,6 @@ jobs: - name: Prepare local network & run SDK tests env: IS_CI_JOB: true + NETWORK: localnet run: | - ./sui start --with-faucet --force-regenesis --epoch-duration-ms 300000 > /dev/null 2>&1 & cd sdk && VITE_SUI_BIN="../sui" pnpm test:e2e + ./sui start --with-faucet --force-regenesis --epoch-duration-ms 10000000 > /dev/null 2>&1 & cd sdk && VITE_SUI_BIN="../sui" pnpm test:e2e diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 66b99d93..6700e2a5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -121,8 +121,8 @@ importers: sdk: dependencies: '@mysten/sui': - specifier: ^1.4.0 - version: 1.4.0(svelte@4.2.15)(typescript@5.4.5) + specifier: ^1.8.0 + version: 1.8.0(svelte@4.2.15)(typescript@5.4.5) devDependencies: '@types/tmp': specifier: ^0.2.3 @@ -1349,8 +1349,8 @@ packages: '@mysten/bcs@0.11.1': resolution: {integrity: sha512-xP85isNSYUCHd3O/g+TmZYmg4wK6cU8q/n/MebkIGP4CYVJZz2wU/G24xIZ3wI+0iTop4dfgA5kYrg/DQKCUzA==} - '@mysten/bcs@1.0.3': - resolution: {integrity: sha512-fc2xDj8eteP18zCNr6WStlE0Hxi7kYeY9yAzAN8oyz5EYOLas0JwScR9pAd9VR61BfIThJ+5vxQ6K7Y22lHDVQ==} + '@mysten/bcs@1.0.4': + resolution: {integrity: sha512-6JoQi59GN/dVEBCNq8Rj4uOR0niDrJqDx/2gNQWXANwJakHIGH0AMniHrXP41B2dF+mZ3HVmh9Hi3otiEVQTrQ==} '@mysten/kiosk@0.8.10': resolution: {integrity: sha512-YiU1SiabdArNyHSKX1elQxNKtpwGthw/bg6wYmR0i+wE8q7ER4JnUeJVxQQg1smyklswqgiLsYa56JmKF1rIeg==} @@ -1364,8 +1364,8 @@ packages: resolution: {integrity: sha512-TSmGIX7U9O/uS9EKIQdv7/S69KTbBhMJVelXCafJE6IJw8iB9cN9uLu0+uklkBSDrbRmLSEY70jMr3uRFjReIg==} engines: {node: '>=16'} - '@mysten/sui@1.4.0': - resolution: {integrity: sha512-j1JVdmL4pAqMmPQXw/RPAVJP0jqCfj/GVH4Z4NBPfl6nwcbLOJdcBczRhyY8WB/87rTog1N0guxPylfvU76gqw==} + '@mysten/sui@1.8.0': + resolution: {integrity: sha512-iL7yztpePS/GWFZ7yiD/Pl7ciuOD2ySyogJZmLFu4WxZfiIcXJX+U/U+Egq9VHvELk8+m+Z1OvvPlNQfuowMIg==} engines: {node: '>=18'} '@napi-rs/simple-git-android-arm-eabi@0.1.16': @@ -6593,7 +6593,7 @@ snapshots: dependencies: bs58: 5.0.0 - '@mysten/bcs@1.0.3': + '@mysten/bcs@1.0.4': dependencies: bs58: 6.0.0 @@ -6633,10 +6633,10 @@ snapshots: - svelte - typescript - '@mysten/sui@1.4.0(svelte@4.2.15)(typescript@5.4.5)': + '@mysten/sui@1.8.0(svelte@4.2.15)(typescript@5.4.5)': dependencies: '@graphql-typed-document-node/core': 3.2.0(graphql@16.9.0) - '@mysten/bcs': 1.0.3 + '@mysten/bcs': 1.0.4 '@noble/curves': 1.4.2 '@noble/hashes': 1.4.0 '@scure/bip32': 1.4.0 diff --git a/scripts/init/init.ts b/scripts/init/init.ts index 02adb9a8..1e48a33d 100644 --- a/scripts/init/init.ts +++ b/scripts/init/init.ts @@ -9,7 +9,9 @@ export const init = async (network: Network, isCIJob: boolean) => { throw new Error( 'Network not defined. Please run `export NETWORK=mainnet|testnet|devnet|localnet`', ); - const published = await publishPackages(network, isCIJob); + + const published = await publishPackages(network, isCIJob, process.env.CLIENT_CONFIG_FILE); + console.log('Published:', published); await setup(published, network); }; diff --git a/scripts/init/publish.ts b/scripts/init/publish.ts index eded24b7..43265c9d 100644 --- a/scripts/init/publish.ts +++ b/scripts/init/publish.ts @@ -1,6 +1,6 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -import { writeFileSync } from 'fs'; +import { existsSync, unlinkSync, writeFileSync } from 'fs'; import path from 'path'; import { TransactionBlock } from '@mysten/sui.js/transactions'; @@ -8,7 +8,7 @@ import { publishPackage, signAndExecute } from '../utils/utils'; import { Network, Packages } from './packages'; import { PackageInfo } from './types'; -export const publishPackages = async (network: Network, isCiJob = false) => { +export const publishPackages = async (network: Network, isCiJob = false, configPath?: string) => { const packages = Packages(isCiJob ? 'mainnet' : network); const contractsPath = path.resolve(__dirname, '../../packages'); const results: Record> = {}; @@ -23,16 +23,28 @@ export const publishPackages = async (network: Network, isCiJob = false) => { for (const [key, pkg] of list) { const packageFolder = path.resolve(contractsPath, pkg.folder); const manifestFile = path.resolve(packageFolder + '/Move.toml'); + // remove the lockfile on CI to allow fresh flows. + if (isCiJob) { + console.info('Removing lock file for CI job'); + const lockFile = path.resolve(packageFolder + '/Move.lock'); + if (existsSync(lockFile)) { + unlinkSync(lockFile); + console.info('Lock file removed'); + } + } + writeFileSync(manifestFile, pkg.manifest()); // save the manifest as is. const txb = new TransactionBlock(); - publishPackage(txb, packageFolder); + publishPackage(txb, packageFolder, configPath); const res = await signAndExecute(txb, network); // @ts-ignore-next-line const data = pkg.processPublish(res); results[key] = data; + console.info(`Published ${key} with packageId: ${data.packageId}`); + writeFileSync(manifestFile, pkg.manifest(data.packageId)); // update the manifest with the published-at field. } } diff --git a/scripts/init/setup.ts b/scripts/init/setup.ts index db67513d..a8664fd4 100644 --- a/scripts/init/setup.ts +++ b/scripts/init/setup.ts @@ -11,6 +11,9 @@ import { Network, Packages } from './packages'; import { queryRegistryTable } from './queries'; import { PackageInfo } from './types'; +// create a sleep async function +const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + export const setup = async (packageInfo: PackageInfo, network: Network) => { const packages = Packages(network); @@ -70,6 +73,8 @@ export const setup = async (packageInfo: PackageInfo, network: Network) => { }); try { + // TODO: Use "waitForTransaction" when we migrate to latest SDK. + await sleep(2000); await signAndExecute(txb, network); console.log('******* Packages set up successfully *******'); @@ -78,7 +83,8 @@ export const setup = async (packageInfo: PackageInfo, network: Network) => { const constants = JSON.parse( readFileSync(path.resolve(__dirname, '../constants.sdk.json'), 'utf8'), ); - + // TODO: Use "waitForTransaction" when we migrate to latest SDK. + await sleep(2000); constants.registryTableId = await queryRegistryTable( getClient(network), packageInfo.SuiNS.suins, @@ -93,6 +99,7 @@ export const setup = async (packageInfo: PackageInfo, network: Network) => { console.error( 'Error while updating sdk constants: Most likely the file does not exist if you run `setup` without publishing through this', ); + console.error(e); } } catch (e) { console.error('Something went wrong!'); diff --git a/scripts/utils/utils.ts b/scripts/utils/utils.ts index 67fb0827..f81947cb 100644 --- a/scripts/utils/utils.ts +++ b/scripts/utils/utils.ts @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 import { execFileSync, execSync } from 'child_process'; import fs, { readFileSync } from 'fs'; -import { homedir } from 'os'; +import { mkdtemp } from 'fs/promises'; +import { homedir, tmpdir } from 'os'; import path from 'path'; import { getFullnodeUrl, SuiClient } from '@mysten/sui.js/client'; import { decodeSuiPrivateKey } from '@mysten/sui.js/cryptography'; @@ -20,9 +21,18 @@ export const getActiveAddress = () => { return execSync(`${SUI} client active-address`, { encoding: 'utf8' }).trim(); }; -export const publishPackage = (txb: TransactionBlock, path: string) => { +export const publishPackage = (txb: TransactionBlock, path: string, configPath?: string) => { + const command = [ + 'move', + ...(configPath ? ['--client.config', configPath] : []), + 'build', + '--dump-bytecode-as-base64', + '--path', + path, + ]; + const { modules, dependencies } = JSON.parse( - execFileSync(SUI, ['move', 'build', '--dump-bytecode-as-base64', '--path', path], { + execFileSync(SUI, command, { encoding: 'utf-8', }), ); diff --git a/sdk/package.json b/sdk/package.json index b059d952..195d345a 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -44,7 +44,7 @@ "node": ">=16" }, "dependencies": { - "@mysten/sui": "^1.4.0" + "@mysten/sui": "^1.8.0" }, "devDependencies": { "@types/tmp": "^0.2.3", diff --git a/sdk/test/setup.ts b/sdk/test/setup.ts index a36c583e..c3212d14 100644 --- a/sdk/test/setup.ts +++ b/sdk/test/setup.ts @@ -25,7 +25,11 @@ export async function publishAndSetupSuinsContracts(toolbox: TestToolbox): Promi PRIVATE_KEY: toolbox.keypair.getSecretKey(), SUI_BINARY: SUI_BIN, NETWORK: 'localnet', + // we need to set this to a temp file, so that the client uses the correct config. + CLIENT_CONFIG_FILE: toolbox.configPath, }, + // stdio: 'inherit', + encoding: 'utf8', }); console.log('SuiNS Contract published & set up successfully.'); @@ -34,7 +38,7 @@ export async function publishAndSetupSuinsContracts(toolbox: TestToolbox): Promi } export async function execute(toolbox: TestToolbox, transaction: Transaction) { - return toolbox.client.signAndExecuteTransaction({ + const result = await toolbox.client.signAndExecuteTransaction({ transaction, signer: toolbox.keypair, options: { @@ -42,4 +46,10 @@ export async function execute(toolbox: TestToolbox, transaction: Transaction) { showObjectChanges: true, }, }); + + await toolbox.client.waitForTransaction({ + digest: result.digest, + }); + + return result; } diff --git a/sdk/test/toolbox.ts b/sdk/test/toolbox.ts index c57cf182..6ebfc48c 100644 --- a/sdk/test/toolbox.ts +++ b/sdk/test/toolbox.ts @@ -1,10 +1,17 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 +import { execSync } from 'child_process'; +import { mkdtemp } from 'fs/promises'; +import { tmpdir } from 'os'; +import path from 'path'; import { getFullnodeUrl, SuiClient } from '@mysten/sui/client'; import { FaucetRateLimitError, getFaucetHost, requestSuiFromFaucetV0 } from '@mysten/sui/faucet'; import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'; import { retry } from 'ts-retry-promise'; +//@ts-ignore-next-line +export const SUI_BIN = process.env.VITE_SUI_BIN ?? `sui`; + //@ts-ignore-next-line const DEFAULT_FAUCET_URL = process.env.VITE_FAUCET_URL ?? getFaucetHost('localnet'); //@ts-ignore-next-line @@ -13,10 +20,12 @@ const DEFAULT_FULLNODE_URL = process.env.VITE_FULLNODE_URL ?? getFullnodeUrl('lo export class TestToolbox { keypair: Ed25519Keypair; client: SuiClient; + configPath: string; - constructor(keypair: Ed25519Keypair, client: SuiClient) { + constructor(keypair: Ed25519Keypair, client: SuiClient, configPath: string) { this.keypair = keypair; this.client = client; + this.configPath = configPath; } address() { @@ -47,5 +56,10 @@ export async function setupSuiClient() { retryIf: (error: any) => !(error instanceof FaucetRateLimitError), logger: (msg) => console.warn('Retrying requesting from faucet: ' + msg), }); - return new TestToolbox(keypair, client); + + const tmpDirPath = path.join(tmpdir(), 'config-'); + const tmpDir = await mkdtemp(tmpDirPath); + const configPath = path.join(tmpDir, 'client.yaml'); + execSync(`${SUI_BIN} client --yes --client.config ${configPath}`, { encoding: 'utf-8' }); + return new TestToolbox(keypair, client, configPath); }