Explorar o código

[cosmwasm] wormhole stub (#770)

* docker file to build wormhole contracts

* move to wormhole stub

* add comment

* update readme
Dev Kalra %!s(int64=2) %!d(string=hai) anos
pai
achega
259f0124f1

+ 8 - 0
target_chains/cosmwasm/README.md

@@ -49,6 +49,14 @@ Deployed Code ID:  11
 
 ### Instantiating new contract
 
+Pyth contract needs the Wormhole core contract deployed on the same chain. Some chains won't have it deployed.
+In that case, you have to deploy wormhole contract yourself. You can build the contract using the scripts given in `wormhole-stub`.
+Run and you will get the compiled contract code in `wormhole-stub/artifacts`
+
+```sh
+./build.sh
+```
+
 This command will upload the code and instantiates a new Pyth contract with the given code id:
 
 ```sh

+ 27 - 0
target_chains/cosmwasm/wormhole-stub/Dockerfile.wormhole

@@ -0,0 +1,27 @@
+# Run with:
+# docker build -f Dockerfile.wormhole -o artifacts .
+
+# Source: https://github.com/CosmWasm/rust-optimizer#notice
+# Arm images are released to ease development and testing on Mac M1 machines.
+# For release / production use, only contracts built with the Intel optimizers must be used.
+# In order to test on mac m1 uncomment the below line
+# FROM cosmwasm/workspace-optimizer-arm64:0.12.11@sha256:a00c01c2fdae8c74d6a9db95fa7b0cbb8e81101ce23a78487012e363d632fee9 AS builder
+# and comment this one
+FROM cosmwasm/workspace-optimizer:0.12.11@sha256:b6b0b1d5ed76dafd0ec0d3812a1e7a275316cf862fd6d0a918f14d71c4cb187f AS builder
+
+WORKDIR /tmp/wormhole-repo
+
+ARG WORMHOLE_REV=2.14.9
+ADD https://github.com/certusone/wormhole/archive/refs/tags/v${WORMHOLE_REV}.tar.gz .
+RUN tar -xvf v${WORMHOLE_REV}.tar.gz
+RUN mv wormhole-${WORMHOLE_REV}/cosmwasm/Cargo.lock /code/
+RUN mv wormhole-${WORMHOLE_REV}/cosmwasm/Cargo.toml /code/
+RUN mv wormhole-${WORMHOLE_REV}/cosmwasm/contracts /code/contracts
+RUN mv wormhole-${WORMHOLE_REV}/cosmwasm/packages /code/packages
+RUN mv wormhole-${WORMHOLE_REV}/sdk /sdk
+
+WORKDIR /code
+RUN --mount=type=cache,target=/code/target,id=cosmwasm_wormhole_target --mount=type=cache,target=/usr/local/cargo/registry optimize_workspace.sh
+
+FROM scratch AS export-stage
+COPY --from=builder /code/artifacts/wormhole* /

+ 3 - 0
target_chains/cosmwasm/wormhole-stub/build.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker build -f Dockerfile.wormhole -o artifacts .