@@ -12,20 +12,26 @@ const argv = yargs(hideBin(process.argv))
12
12
. option ( "injective" , {
13
13
type : "boolean" ,
14
14
} )
15
+ . option ( "osmosis" , {
16
+ type : "boolean" ,
17
+ } )
18
+ . option ( "arm64" , {
19
+ type : "boolean" ,
20
+ } )
15
21
. help ( )
16
22
. alias ( "help" , "h" )
17
23
. wrap ( yargs . terminalWidth ( ) )
18
24
. parseSync ( ) ;
19
25
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 ) {
23
29
const originalTomlContentStr = readFileSync ( contractTomlFilePath , "utf-8" ) ;
24
30
const parsedToml = toml . parse ( originalTomlContentStr ) ;
25
31
26
- // add injective feature to the cargo.toml
32
+ // add default feature to the cargo.toml
27
33
// @ts -ignore
28
- parsedToml . features . default = [ "injective" ] ;
34
+ parsedToml . features . default = [ feature ] ;
29
35
30
36
// @ts -ignore
31
37
const updatedToml = toml . stringify ( parsedToml , {
@@ -40,29 +46,44 @@ function injectivePreSetup(contractTomlFilePath: string) {
40
46
writeFileSync ( contractTomlFilePath , updatedToml ) ;
41
47
42
48
// after contract compilation we need to reset the original content of the toml file
43
- return function injectivePostCleanup ( ) {
49
+ return function cargoPostCleanup ( ) {
44
50
writeFileSync ( contractTomlFilePath , originalTomlContentStr ) ;
45
51
} ;
46
52
}
47
53
48
54
function build ( ) {
49
- if ( argv . cosmwasm !== true && argv . injective !== true ) {
50
- console . log ( "Please provide one of the options: ['cosmwasm', 'injective']" ) ;
51
- return ;
52
- }
53
-
54
55
const contractTomlFilePath = "../contracts/pyth/Cargo.toml" ;
55
56
56
57
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" ;
59
80
60
81
const buildCommand = `
61
82
docker run --rm -v "$(cd ..; pwd)":/code \
62
- -v $(cd ../../../wormhole_attester; pwd):/wormhole_attester \
83
+ -v " $(cd ../../../wormhole_attester; pwd)" :/wormhole_attester \
63
84
--mount type=volume,source="$(basename "$(cd ..; pwd)")_cache",target=/code/target \
64
85
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
65
- cosmwasm/workspace-optimizer:0.12.11
86
+ ${ dockerImage }
66
87
` ;
67
88
68
89
// build contract by running the command
0 commit comments