diff --git a/src/account.ts b/src/account.ts index d136b56e..0fc7eded 100644 --- a/src/account.ts +++ b/src/account.ts @@ -397,7 +397,7 @@ export abstract class Account { * Declare the contract class corresponding to the `contractFactory` * @param contractFactory * @param options - * @returns the hash of the declared class + * @returns transaction hash */ public async declare( contractFactory: StarknetContractFactory, diff --git a/src/types/index.ts b/src/types/index.ts index f2fe71bf..31b19034 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -365,7 +365,7 @@ export class StarknetContractFactory { /** * Declare a contract class. * @param options optional arguments to class declaration - * @returns the class hash as a hex string + * @returns transaction hash as a hex string */ async declare(options: DeclareOptions = {}): Promise { const executed = await this.hre.starknetWrapper.declare({ @@ -382,14 +382,13 @@ export class StarknetContractFactory { } const executedOutput = executed.stdout.toString(); - const classHash = extractClassHash(executedOutput); const txHash = extractTxHash(executedOutput); return new Promise((resolve, reject) => { iterativelyCheckStatus( txHash, this.hre.starknetWrapper, - () => resolve(classHash), + () => resolve(txHash), (error) => { reject(new StarknetPluginError(`Declare transaction ${txHash}: ${error}`)); } diff --git a/www/docs/intro.md b/www/docs/intro.md index 457321c4..a654a18b 100644 --- a/www/docs/intro.md +++ b/www/docs/intro.md @@ -218,10 +218,8 @@ describe("My Test", function () { // not compatible with accounts deployed with Starknet CLI const account = await starknet.OpenZeppelinAccount.getAccountFromAddress(...); const contractFactory = await starknet.getContractFactory("MyContract"); - const classHash = await account.declare(contractFactory); // class declaration - - // two ways to obtain the class hash - expect(classHash).to.equal(await contractFactory.getClassHash()); + const txHash = await account.declare(contractFactory); // class declaration + const classHash = await contractFactory.getClassHash(); const constructorArgs = { initial_balance: 0 }; const options = { maxFee: ... }; @@ -307,8 +305,9 @@ it("should estimate fee", async function () { it("should forward to the implementation contract", async function () { const implementationFactory = await starknet.getContractFactory("contract"); const account = ...; - const implementationClassHash = await account.declare(implementationFactory); - + const txHash = await account.declare(implementationFactory); + const implementationClassHash = await implementationFactory.getClassHash(); + const proxyFactory = await starknet.getContractFactory("delegate_proxy"); await account.declare(proxyFactory); const proxy = await account.deploy(proxyFactory, {