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..17e0a920 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 }; }