@@ -2,14 +2,15 @@ import { AccountInterface } from '../account';
22import { logger } from '../global/logger' ;
33import {
44 Abi ,
5- ArgsOrCalldataWithOptions ,
5+ ArgsOrCalldata ,
66 CairoAssembly ,
77 CompiledContract ,
8+ ContractOptions ,
89 ValidateType ,
910} from '../types' ;
1011import assert from '../utils/assert' ;
1112import { CallData } from '../utils/calldata' ;
12- import { Contract , getCalldata , splitArgsAndOptions } from './default' ;
13+ import { Contract , getCalldata } from './default' ;
1314
1415export type ContractFactoryParams = {
1516 compiledContract : CompiledContract ;
@@ -18,6 +19,7 @@ export type ContractFactoryParams = {
1819 classHash ?: string ;
1920 compiledClassHash ?: string ;
2021 abi ?: Abi ;
22+ contractOptions ?: ContractOptions ;
2123} ;
2224
2325export class ContractFactory {
@@ -35,6 +37,8 @@ export class ContractFactory {
3537
3638 private CallData : CallData ;
3739
40+ public contractOptions ?: ContractOptions ;
41+
3842 /**
3943 * @param params CFParams
4044 * - compiledContract: CompiledContract;
@@ -52,23 +56,24 @@ export class ContractFactory {
5256 this . classHash = params . classHash ;
5357 this . compiledClassHash = params . compiledClassHash ;
5458 this . CallData = new CallData ( this . abi ) ;
59+ this . contractOptions = params . contractOptions ;
5560 }
5661
5762 /**
5863 * Deploys contract and returns new instance of the Contract
5964 *
6065 * If contract is not declared it will first declare it, and then deploy
6166 */
62- public async deploy ( ...args : ArgsOrCalldataWithOptions ) : Promise < Contract > {
63- const { args : param , options = { parseRequest : true } } = splitArgsAndOptions ( args ) ;
67+ public async deploy ( ...args : ArgsOrCalldata ) : Promise < Contract > {
68+ // const { args: param, options = { parseRequest: true } } = args; // splitArgsAndOptions(args);
6469
65- const constructorCalldata = getCalldata ( param , ( ) => {
66- if ( options . parseRequest ) {
67- this . CallData . validate ( ValidateType . DEPLOY , 'constructor' , param ) ;
68- return this . CallData . compile ( 'constructor' , param ) ;
70+ const constructorCalldata = getCalldata ( args , ( ) => {
71+ if ( this . contractOptions ? .parseRequest ) {
72+ this . CallData . validate ( ValidateType . DEPLOY , 'constructor' , args ) ;
73+ return this . CallData . compile ( 'constructor' , args ) ;
6974 }
7075 logger . warn ( 'Call skipped parsing but provided rawArgs, possible malfunction request' ) ;
71- return param ;
76+ return args ;
7277 } ) ;
7378
7479 const {
@@ -79,7 +84,7 @@ export class ContractFactory {
7984 classHash : this . classHash ,
8085 compiledClassHash : this . compiledClassHash ,
8186 constructorCalldata,
82- salt : options . addressSalt ,
87+ salt : this . contractOptions ? .addressSalt ,
8388 } ) ;
8489 assert ( Boolean ( contract_address ) , 'Deployment of the contract failed' ) ;
8590
0 commit comments