@@ -2,14 +2,15 @@ import { AccountInterface } from '../account';
2
2
import { logger } from '../global/logger' ;
3
3
import {
4
4
Abi ,
5
- ArgsOrCalldataWithOptions ,
5
+ ArgsOrCalldata ,
6
6
CairoAssembly ,
7
7
CompiledContract ,
8
+ ContractOptions ,
8
9
ValidateType ,
9
10
} from '../types' ;
10
11
import assert from '../utils/assert' ;
11
12
import { CallData } from '../utils/calldata' ;
12
- import { Contract , getCalldata , splitArgsAndOptions } from './default' ;
13
+ import { Contract , getCalldata } from './default' ;
13
14
14
15
export type ContractFactoryParams = {
15
16
compiledContract : CompiledContract ;
@@ -18,6 +19,7 @@ export type ContractFactoryParams = {
18
19
classHash ?: string ;
19
20
compiledClassHash ?: string ;
20
21
abi ?: Abi ;
22
+ contractOptions ?: ContractOptions ;
21
23
} ;
22
24
23
25
export class ContractFactory {
@@ -35,6 +37,8 @@ export class ContractFactory {
35
37
36
38
private CallData : CallData ;
37
39
40
+ public contractOptions ?: ContractOptions ;
41
+
38
42
/**
39
43
* @param params CFParams
40
44
* - compiledContract: CompiledContract;
@@ -52,23 +56,24 @@ export class ContractFactory {
52
56
this . classHash = params . classHash ;
53
57
this . compiledClassHash = params . compiledClassHash ;
54
58
this . CallData = new CallData ( this . abi ) ;
59
+ this . contractOptions = params . contractOptions ;
55
60
}
56
61
57
62
/**
58
63
* Deploys contract and returns new instance of the Contract
59
64
*
60
65
* If contract is not declared it will first declare it, and then deploy
61
66
*/
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);
64
69
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 ) ;
69
74
}
70
75
logger . warn ( 'Call skipped parsing but provided rawArgs, possible malfunction request' ) ;
71
- return param ;
76
+ return args ;
72
77
} ) ;
73
78
74
79
const {
@@ -79,7 +84,7 @@ export class ContractFactory {
79
84
classHash : this . classHash ,
80
85
compiledClassHash : this . compiledClassHash ,
81
86
constructorCalldata,
82
- salt : options . addressSalt ,
87
+ salt : this . contractOptions ? .addressSalt ,
83
88
} ) ;
84
89
assert ( Boolean ( contract_address ) , 'Deployment of the contract failed' ) ;
85
90
0 commit comments