@@ -12,20 +12,26 @@ const argv = yargs(hideBin(process.argv))
1212 . option ( "injective" , {
1313 type : "boolean" ,
1414 } )
15+ . option ( "osmosis" , {
16+ type : "boolean" ,
17+ } )
18+ . option ( "arm64" , {
19+ type : "boolean" ,
20+ } )
1521 . help ( )
1622 . alias ( "help" , "h" )
1723 . wrap ( yargs . terminalWidth ( ) )
1824 . parseSync ( ) ;
1925
20- // we need to update the toml file to have a feature on - default=['injective' ]
21- // editing and writing the toml file before building the contract for injective
22- function injectivePreSetup ( contractTomlFilePath : string ) {
26+ // we need to update the toml file to have a feature on - default=[feature (passed as parameter) ]
27+ // editing and writing the toml file before building the contract for other than cosmwasm
28+ function cargoPreSetup ( contractTomlFilePath : string , feature : string ) {
2329 const originalTomlContentStr = readFileSync ( contractTomlFilePath , "utf-8" ) ;
2430 const parsedToml = toml . parse ( originalTomlContentStr ) ;
2531
26- // add injective feature to the cargo.toml
32+ // add default feature to the cargo.toml
2733 // @ts -ignore
28- parsedToml . features . default = [ "injective" ] ;
34+ parsedToml . features . default = [ feature ] ;
2935
3036 // @ts -ignore
3137 const updatedToml = toml . stringify ( parsedToml , {
@@ -40,29 +46,44 @@ function injectivePreSetup(contractTomlFilePath: string) {
4046 writeFileSync ( contractTomlFilePath , updatedToml ) ;
4147
4248 // after contract compilation we need to reset the original content of the toml file
43- return function injectivePostCleanup ( ) {
49+ return function cargoPostCleanup ( ) {
4450 writeFileSync ( contractTomlFilePath , originalTomlContentStr ) ;
4551 } ;
4652}
4753
4854function build ( ) {
49- if ( argv . cosmwasm !== true && argv . injective !== true ) {
50- console . log ( "Please provide one of the options: ['cosmwasm', 'injective']" ) ;
51- return ;
52- }
53-
5455 const contractTomlFilePath = "../contracts/pyth/Cargo.toml" ;
5556
5657 let cleanup = ( ) => { } ;
57- if ( argv . injective === true )
58- cleanup = injectivePreSetup ( contractTomlFilePath ) ;
58+ if ( argv . cosmwasm !== true ) {
59+ const feature =
60+ argv . osmosis === true
61+ ? "osmosis"
62+ : argv . injective === true
63+ ? "injective"
64+ : undefined ;
65+
66+ if ( feature === undefined ) {
67+ console . log (
68+ "Please provide one of the options: ['cosmwasm', 'injective', 'osmosis']"
69+ ) ;
70+ return ;
71+ }
72+
73+ cleanup = cargoPreSetup ( contractTomlFilePath , feature ) ;
74+ }
75+
76+ const dockerImage =
77+ argv . arm64 === true
78+ ? "cosmwasm/workspace-optimizer-arm64:0.12.11"
79+ : "cosmwasm/workspace-optimizer:0.12.11" ;
5980
6081 const buildCommand = `
6182 docker run --rm -v "$(cd ..; pwd)":/code \
62- -v $(cd ../../../wormhole_attester; pwd):/wormhole_attester \
83+ -v " $(cd ../../../wormhole_attester; pwd)" :/wormhole_attester \
6384 --mount type=volume,source="$(basename "$(cd ..; pwd)")_cache",target=/code/target \
6485 --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
65- cosmwasm/workspace-optimizer:0.12.11
86+ ${ dockerImage }
6687 ` ;
6788
6889 // build contract by running the command
0 commit comments