1
- import { Contract , ContractBuilder } from './contract' ;
2
- import { CommonOptions , withCommonDefaults } from './common-options' ;
1
+ import type { Contract } from './contract' ;
2
+ import { ContractBuilder } from './contract' ;
3
+ import type { CommonOptions } from './common-options' ;
4
+ import { withCommonDefaults } from './common-options' ;
3
5
import { defaults as commonDefaults } from './common-options' ;
4
6
import { setAccountUpgradeable } from './set-upgradeable' ;
5
7
import { setInfo } from './set-info' ;
6
8
import { defineComponents } from './utils/define-components' ;
7
9
import { printContract } from './print' ;
8
10
import { addSRC5Component } from './common-components' ;
9
11
10
-
11
12
export const accountTypes = [ 'stark' , 'eth' ] as const ;
12
- export type Account = typeof accountTypes [ number ] ;
13
+ export type Account = ( typeof accountTypes ) [ number ] ;
13
14
14
15
export const defaults : Required < AccountOptions > = {
15
16
name : 'MyAccount' ,
@@ -19,7 +20,7 @@ export const defaults: Required<AccountOptions> = {
19
20
pubkey : true ,
20
21
outsideExecution : true ,
21
22
upgradeable : commonDefaults . upgradeable ,
22
- info : commonDefaults . info
23
+ info : commonDefaults . info ,
23
24
} as const ;
24
25
25
26
export function printAccount ( opts : AccountOptions = defaults ) : string {
@@ -42,8 +43,8 @@ function withDefaults(opts: AccountOptions): Required<AccountOptions> {
42
43
declare : opts . declare ?? defaults . declare ,
43
44
deploy : opts . deploy ?? defaults . deploy ,
44
45
pubkey : opts . pubkey ?? defaults . pubkey ,
45
- outsideExecution : opts . outsideExecution ?? defaults . outsideExecution
46
- }
46
+ outsideExecution : opts . outsideExecution ?? defaults . outsideExecution ,
47
+ } ;
47
48
}
48
49
49
50
export function buildAccount ( opts : AccountOptions ) : Contract {
@@ -157,11 +158,14 @@ function addAccountMixin(c: ContractBuilder, accountType: Account) {
157
158
}
158
159
159
160
function getBaseCompAndCompType ( accountType : Account ) : [ string , typeof componentType ] {
160
- const [ baseComponent , componentType ] = accountType === 'stark' ? [ 'AccountComponent' , components . AccountComponent ] : [ 'EthAccountComponent' , components . EthAccountComponent ] ;
161
+ const [ baseComponent , componentType ] =
162
+ accountType === 'stark'
163
+ ? [ 'AccountComponent' , components . AccountComponent ]
164
+ : [ 'EthAccountComponent' , components . EthAccountComponent ] ;
161
165
return [ baseComponent , componentType ] ;
162
166
}
163
167
164
- const components = defineComponents ( {
168
+ const components = defineComponents ( {
165
169
AccountComponent : {
166
170
path : 'openzeppelin::account' ,
167
171
substorage : {
@@ -172,11 +176,13 @@ const components = defineComponents( {
172
176
name : 'AccountEvent' ,
173
177
type : 'AccountComponent::Event' ,
174
178
} ,
175
- impls : [ {
176
- name : 'AccountInternalImpl' ,
177
- embed : false ,
178
- value : 'AccountComponent::InternalImpl<ContractState>' ,
179
- } ] ,
179
+ impls : [
180
+ {
181
+ name : 'AccountInternalImpl' ,
182
+ embed : false ,
183
+ value : 'AccountComponent::InternalImpl<ContractState>' ,
184
+ } ,
185
+ ] ,
180
186
} ,
181
187
EthAccountComponent : {
182
188
path : 'openzeppelin::account::eth_account' ,
@@ -188,11 +194,13 @@ const components = defineComponents( {
188
194
name : 'EthAccountEvent' ,
189
195
type : 'EthAccountComponent::Event' ,
190
196
} ,
191
- impls : [ {
192
- name : 'EthAccountInternalImpl' ,
193
- embed : false ,
194
- value : 'EthAccountComponent::InternalImpl<ContractState>' ,
195
- } ]
197
+ impls : [
198
+ {
199
+ name : 'EthAccountInternalImpl' ,
200
+ embed : false ,
201
+ value : 'EthAccountComponent::InternalImpl<ContractState>' ,
202
+ } ,
203
+ ] ,
196
204
} ,
197
205
SRC9Component : {
198
206
path : 'openzeppelin::account::extensions' ,
@@ -204,13 +212,16 @@ const components = defineComponents( {
204
212
name : 'SRC9Event' ,
205
213
type : 'SRC9Component::Event' ,
206
214
} ,
207
- impls : [ {
208
- name : 'OutsideExecutionV2Impl' ,
209
- value : 'SRC9Component::OutsideExecutionV2Impl<ContractState>' ,
210
- } , {
211
- name : 'OutsideExecutionInternalImpl' ,
212
- embed : false ,
213
- value : 'SRC9Component::InternalImpl<ContractState>' ,
214
- } ]
215
- }
215
+ impls : [
216
+ {
217
+ name : 'OutsideExecutionV2Impl' ,
218
+ value : 'SRC9Component::OutsideExecutionV2Impl<ContractState>' ,
219
+ } ,
220
+ {
221
+ name : 'OutsideExecutionInternalImpl' ,
222
+ embed : false ,
223
+ value : 'SRC9Component::InternalImpl<ContractState>' ,
224
+ } ,
225
+ ] ,
226
+ } ,
216
227
} ) ;
0 commit comments