@@ -14,7 +14,18 @@ const codegen = (_codegen as any).default as typeof _codegen
14
14
15
15
type ReactResult = RequiredBy < Plugin , 'run' >
16
16
17
- export function react ( ) : ReactResult {
17
+ const DISABLED_APPSTRACT_APP_FOR_NAMESPACES_LIST = [ 'cw-plus' ]
18
+
19
+ type ReactOptions = {
20
+ disableAppstractAppFor ?: string [ ]
21
+ }
22
+
23
+ export function react ( options : ReactOptions = { } ) : ReactResult {
24
+ const disableAppstractAppFor = [
25
+ ...( options . disableAppstractAppFor ?? [ ] ) ,
26
+ ...DISABLED_APPSTRACT_APP_FOR_NAMESPACES_LIST ,
27
+ ]
28
+
18
29
return {
19
30
name : 'React' ,
20
31
async run ( { contracts, out, isTypeScript } ) {
@@ -24,7 +35,7 @@ export function react(): ReactResult {
24
35
contracts . some ( ( { name } ) => DISALLOWED_CONTRACT_NAMES . includes ( name ) )
25
36
)
26
37
throw new Error (
27
- '`proxy` and `manager` contract generations are disallowed. Use `@abstract-money/core` methods or `@abstract-money/react` methods ' ,
38
+ '`proxy` and `manager` contract generations are disallowed. Use `@abstract-money/core` methods or `@abstract-money/react` hooks. ' ,
28
39
)
29
40
30
41
// Prepare default config options
@@ -46,12 +57,37 @@ export function react(): ReactResult {
46
57
47
58
const cosmwasmCodegenDirPath = join ( out , 'cosmwasm-codegen' )
48
59
60
+ // Guard speicfic contracts to not have the abstract app generated
61
+ const guardedContracts = contracts . filter ( ( { namespace } ) =>
62
+ disableAppstractAppFor . includes ( namespace ) ,
63
+ )
64
+
49
65
await codegen ( {
50
66
options : codegenOptions ,
51
- contracts : contracts . map ( ( { name, path } ) => ( { name, dir : path } ) ) ,
67
+ contracts : contracts
68
+ . filter (
69
+ ( { namespace } ) =>
70
+ ! disableAppstractAppFor . includes ( namespace ) &&
71
+ guardedContracts . every (
72
+ ( guardedContract ) => guardedContract . namespace !== namespace ,
73
+ ) ,
74
+ )
75
+ . map ( ( { name, path } ) => ( { name, dir : path } ) ) ,
52
76
outPath : cosmwasmCodegenDirPath ,
53
77
} )
54
78
79
+ if ( guardedContracts . length !== 0 )
80
+ await codegen ( {
81
+ options : { ...codegenOptions , abstractApp : { enabled : false } } ,
82
+ contracts : [
83
+ ...guardedContracts ,
84
+ ...contracts . filter ( ( { namespace } ) =>
85
+ disableAppstractAppFor . includes ( namespace ) ,
86
+ ) ,
87
+ ] . map ( ( { name, path } ) => ( { name, dir : path } ) ) ,
88
+ outPath : cosmwasmCodegenDirPath ,
89
+ } )
90
+
55
91
const imports : string [ ] = [ ]
56
92
const content : string [ ] = [ ]
57
93
0 commit comments