From 337351438d83184a7f38ab436f8e30f7d9dc5bb6 Mon Sep 17 00:00:00 2001 From: Foivos Date: Mon, 15 Jul 2024 18:14:17 +0300 Subject: [PATCH 1/2] add the util --- .gitignore | 3 +-- src/utils.ts | 8 ++++++++ test/utils.js | 8 +++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f01e2714..cdab30af 100644 --- a/.gitignore +++ b/.gitignore @@ -69,5 +69,4 @@ target/ *.pdb # dist and move_compile -dist -move_comile +move_compile diff --git a/src/utils.ts b/src/utils.ts index 69bec017..f434c17e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -76,6 +76,14 @@ export function updateMoveToml(packageName: string, packageId: string, moveDir: fs.writeFileSync(path, toml); } +export function copyMovePackage(packageName: string, fromDir: null | string, toDir: string) { + if(fromDir == null) { + fromDir = `${__dirname}/../move` + } + + fs.cpSync(`${fromDir}/${packageName}`,`${toDir}/${packageName}`, {recursive: true}); +} + export function parseEnv(arg: string) { switch (arg?.toLowerCase()) { case 'localnet': diff --git a/test/utils.js b/test/utils.js index a7721d3e..f479b78e 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,17 +1,19 @@ const { keccak256, defaultAbiCoder } = require('ethers/lib/utils'); const { TxBuilder } = require('../dist/tx-builder'); -const { updateMoveToml } = require('../dist/utils'); +const { updateMoveToml, copyMovePackage } = require('../dist/utils'); const chai = require('chai'); const { expect } = chai; async function publishPackage(client, keypair, packageName) { + const compileDir = `${__dirname}/../move_compile`; + copyMovePackage(packageName, null, compileDir); const builder = new TxBuilder(client); - await builder.publishPackageAndTransferCap(packageName, keypair.toSuiAddress()); + await builder.publishPackageAndTransferCap(packageName, keypair.toSuiAddress(), compileDir); const publishTxn = await builder.signAndExecute(keypair); const packageId = (publishTxn.objectChanges?.find((a) => a.type === 'published') ?? []).packageId; - updateMoveToml(packageName, packageId); + updateMoveToml(packageName, packageId, compileDir); return { packageId, publishTxn }; } From 93609c3f0557fe4f74df211d1894982d45b9bf0d Mon Sep 17 00:00:00 2001 From: Foivos Date: Tue, 16 Jul 2024 16:02:12 +0300 Subject: [PATCH 2/2] made lint happy --- src/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index f434c17e..17e0a920 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -77,11 +77,11 @@ export function updateMoveToml(packageName: string, packageId: string, moveDir: } export function copyMovePackage(packageName: string, fromDir: null | string, toDir: string) { - if(fromDir == null) { - fromDir = `${__dirname}/../move` + if (fromDir == null) { + fromDir = `${__dirname}/../move`; } - fs.cpSync(`${fromDir}/${packageName}`,`${toDir}/${packageName}`, {recursive: true}); + fs.cpSync(`${fromDir}/${packageName}`, `${toDir}/${packageName}`, { recursive: true }); } export function parseEnv(arg: string) {