Skip to content

Commit

Permalink
Bump @mysten/sui from 1.4.0 to 1.8.0 (#165)
Browse files Browse the repository at this point in the history
* 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](MystenLabs/sui@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] <[email protected]>

* Some trials to fix the e2e tests

* Update @mysten/sui dep

* Fix e2e tests

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Manolis Liolios <[email protected]>
  • Loading branch information
dependabot[bot] and manolisliolios authored Sep 9, 2024
1 parent 0e01d4f commit 5001e9c
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-lemons-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mysten/suins": patch
---

Update @mysten/sui dependency to 1.8.0
3 changes: 2 additions & 1 deletion .github/workflows/sdk_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion scripts/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
18 changes: 15 additions & 3 deletions scripts/init/publish.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// 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';

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<string, Record<string, string>> = {};
Expand All @@ -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.
}
}
Expand Down
9 changes: 8 additions & 1 deletion scripts/init/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 *******');

Expand All @@ -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,
Expand All @@ -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!');
Expand Down
16 changes: 13 additions & 3 deletions scripts/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
}),
);
Expand Down
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"node": ">=16"
},
"dependencies": {
"@mysten/sui": "^1.4.0"
"@mysten/sui": "^1.8.0"
},
"devDependencies": {
"@types/tmp": "^0.2.3",
Expand Down
12 changes: 11 additions & 1 deletion sdk/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -34,12 +38,18 @@ 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: {
showEffects: true,
showObjectChanges: true,
},
});

await toolbox.client.waitForTransaction({
digest: result.digest,
});

return result;
}
18 changes: 16 additions & 2 deletions sdk/test/toolbox.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}

0 comments on commit 5001e9c

Please sign in to comment.