From 3b9b342f5d8af7471d24c53d523b07abeba37fff Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Fri, 12 Jul 2024 13:21:34 +0530 Subject: [PATCH 1/2] refactor: add getContractBuild function --- src/tx-builder.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tx-builder.ts b/src/tx-builder.ts index 36bcf3aa..3b5a133d 100644 --- a/src/tx-builder.ts +++ b/src/tx-builder.ts @@ -243,20 +243,26 @@ class TxBuilder { }); } - async publishPackage(packageName: string, moveDir: string = `${__dirname}/../move`): Promise { + async getContractBuild(packageName: string, moveDir: string = `${__dirname}/../move`) { updateMoveToml(packageName, '0x0', moveDir); tmp.setGracefulCleanup(); const tmpobj = tmp.dirSync({ unsafeCleanup: true }); - const { modules, dependencies } = JSON.parse( + const { modules, dependencies, digest } = JSON.parse( execSync(`sui move build --dump-bytecode-as-base64 --path ${path.join(moveDir, packageName)} --install-dir ${tmpobj.name}`, { encoding: 'utf-8', stdio: 'pipe', // silent the output }), ); + return { modules, dependencies, digest }; + } + + async publishPackage(packageName: string, moveDir: string = `${__dirname}/../move`): Promise { + const { modules, dependencies } = await this.getContractBuild(packageName, moveDir); + return this.tx.publish({ modules, dependencies, From ac09ac65dcddcb108e7b26f9352eb4c98e16b2ed Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Fri, 12 Jul 2024 13:48:27 +0530 Subject: [PATCH 2/2] refactor: specify return type in getContractBuild function --- src/tx-builder.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tx-builder.ts b/src/tx-builder.ts index 3b5a133d..b60446dc 100644 --- a/src/tx-builder.ts +++ b/src/tx-builder.ts @@ -11,7 +11,7 @@ import { } from '@mysten/sui.js/client'; import { Keypair } from '@mysten/sui.js/dist/cjs/cryptography'; import { TransactionBlock, TransactionObjectInput, TransactionResult } from '@mysten/sui.js/transactions'; -import { utils as ethersUtils } from 'ethers'; +import { Bytes, utils as ethersUtils } from 'ethers'; import tmp from 'tmp'; import { updateMoveToml } from './utils'; @@ -243,7 +243,10 @@ class TxBuilder { }); } - async getContractBuild(packageName: string, moveDir: string = `${__dirname}/../move`) { + async getContractBuild( + packageName: string, + moveDir: string = `${__dirname}/../move`, + ): Promise<{ modules: string[]; dependencies: string[]; digest: Bytes }> { updateMoveToml(packageName, '0x0', moveDir); tmp.setGracefulCleanup();