Skip to content

Commit 2d38e7e

Browse files
committed
build(pyth): hyphenate wasm artifact names
Cargo emits underscore filenames for hyphenated contract crates. Normalize the final CosmWasm artifacts after optimization so the packaged wasm names match the pyth-vaa and pyth-pro directories. Update local deployment and e2e artifact lookups to use the hyphenated names. Signed-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
1 parent ba133c7 commit 2d38e7e

3 files changed

Lines changed: 36 additions & 8 deletions

File tree

_run/init.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ if [[ -z "$CONTRACTS_DIR" ]]; then
2222
exit 1
2323
fi
2424

25-
PYTH_VAA_WASM="${CONTRACTS_DIR}/artifacts/pyth_vaa.wasm"
26-
PYTH_PRO_WASM="${CONTRACTS_DIR}/artifacts/pyth_pro.wasm"
25+
PYTH_VAA_WASM="${CONTRACTS_DIR}/artifacts/pyth-vaa.wasm"
26+
PYTH_PRO_WASM="${CONTRACTS_DIR}/artifacts/pyth-pro.wasm"
2727

2828
HERMES_MNEMONIC="wire museum tragic inmate final lady illegal father whisper margin sea cool soul half moon nut tissue strategy ladder come glory opera device elbow"
2929

make/cosmwasm.mk

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ build-contracts:
88
-v "$(AKASH_DEVCACHE)/cosmwasm/artifacts":/code/artifacts \
99
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
1010
$(COSMWASM_OPTIMIZER_IMAGE)
11+
@# Cargo normalizes hyphenated crate names to underscores. Keep the
12+
@# released artifact names aligned with the contract directories.
13+
@artifacts="$(AKASH_DEVCACHE)/cosmwasm/artifacts"; \
14+
for artifact in "pyth_vaa.wasm:pyth-vaa.wasm" "pyth_pro.wasm:pyth-pro.wasm"; do \
15+
old="$${artifact%%:*}"; \
16+
new="$${artifact##*:}"; \
17+
if [ ! -f "$$artifacts/$$old" ]; then \
18+
echo "error: expected $$artifacts/$$old from CosmWasm optimizer" >&2; \
19+
exit 1; \
20+
fi; \
21+
mv -f "$$artifacts/$$old" "$$artifacts/$$new"; \
22+
done; \
23+
if [ -f "$$artifacts/checksums.txt" ]; then \
24+
tmp="$$artifacts/checksums.txt.tmp"; \
25+
sed \
26+
-e 's/pyth_vaa\.wasm/pyth-vaa.wasm/g' \
27+
-e 's/pyth_pro\.wasm/pyth-pro.wasm/g' \
28+
"$$artifacts/checksums.txt" > "$$tmp"; \
29+
mv "$$tmp" "$$artifacts/checksums.txt"; \
30+
fi
1131

1232
.PHONY: generate-contracts
1333
generate-contracts: build-contracts

tests/e2e/pyth_contract_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ func (s *priceOracleContractTestSuite) TestStoreContractViaGovernance() {
198198
val := s.Network().Validators[0]
199199

200200
// Load the pyth-pro wasm contract.
201-
wasmPath := findWasmPath("pyth-pro", "pyth_pro.wasm")
201+
wasmPath := findWasmPath("pyth-pro", "pyth-pro.wasm")
202202
if wasmPath == "" {
203-
s.T().Skip("pyth_pro.wasm not found, skipping contract store test")
203+
s.T().Skip("pyth-pro.wasm not found, skipping contract store test")
204204
return
205205
}
206206

@@ -499,8 +499,8 @@ func (s *priceOracleContractTestSuite) TestAllContractsExist() {
499499
dir string
500500
wasmFile string
501501
}{
502-
{"pyth-vaa", "pyth-vaa", "pyth_vaa.wasm"},
503-
{"pyth-pro", "pyth-pro", "pyth_pro.wasm"},
502+
{"pyth-vaa", "pyth-vaa", "pyth-vaa.wasm"},
503+
{"pyth-pro", "pyth-pro", "pyth-pro.wasm"},
504504
}
505505

506506
for _, c := range contracts {
@@ -568,11 +568,19 @@ func (s *priceOracleContractTestSuite) TestRouterSignedVAAStructure() {
568568
func findWasmPath(contractDir, wasmFile string) string {
569569
// Try common paths relative to the test location
570570
paths := []string{
571+
filepath.Join("../../.cache/cosmwasm/artifacts", wasmFile),
572+
filepath.Join("../.cache/cosmwasm/artifacts", wasmFile),
573+
filepath.Join(".cache/cosmwasm/artifacts", wasmFile),
571574
filepath.Join("../../contracts", contractDir, "artifacts", wasmFile),
572575
filepath.Join("../contracts", contractDir, "artifacts", wasmFile),
573576
filepath.Join("contracts", contractDir, "artifacts", wasmFile),
574577
}
575578

579+
devcache := os.Getenv("AKASH_DEVCACHE")
580+
if devcache != "" {
581+
paths = append(paths, filepath.Join(devcache, "cosmwasm/artifacts", wasmFile))
582+
}
583+
576584
// Also try using GOPATH
577585
gopath := os.Getenv("GOPATH")
578586
if gopath != "" {
@@ -912,9 +920,9 @@ func (s *priceOracleContractTestSuite) TestStoreContractCodeViaGovernance() {
912920
s.Require().NoError(err)
913921

914922
// Step 1: Load contract WASM
915-
wasmPath := findWasmPath("pyth-pro", "pyth_pro.wasm")
923+
wasmPath := findWasmPath("pyth-pro", "pyth-pro.wasm")
916924
if wasmPath == "" {
917-
s.T().Skip("pyth_pro.wasm not found, skipping contract deployment test")
925+
s.T().Skip("pyth-pro.wasm not found, skipping contract deployment test")
918926
return
919927
}
920928
s.T().Logf("Found pyth-pro contract at: %s", wasmPath)

0 commit comments

Comments
 (0)