|
|
2 роки тому | |
|---|---|---|
| .. | ||
| contracts | 93ca9c427a migration logic (#687) | 2 роки тому |
| devnet | 084acdb57e [refactor] Convert hyphen to underscore in the directory tree (#524) | 2 роки тому |
| examples | 40e42a5b21 [cosmwasm] pyth-sdk-cw update version v1.0.0 (#595) | 2 роки тому |
| pyth-sdk-cw | 04a8b75f80 add docs (#690) | 2 роки тому |
| sdk | b9430aee81 [sdk] Add new SDK packages to lerna (#630) | 2 роки тому |
| tools | 4c5d0d5e1b [refactor] Add global lerna (#546) | 2 роки тому |
| .dockerignore | 084acdb57e [refactor] Convert hyphen to underscore in the directory tree (#524) | 2 роки тому |
| .gitignore | 084acdb57e [refactor] Convert hyphen to underscore in the directory tree (#524) | 2 роки тому |
| Cargo.lock | 3e104b4184 [cosmwasm] address audit (#685) | 2 роки тому |
| Cargo.toml | 8e11caa1ee Bump wormhole rust crates to v2.14.8, remove rent adjustment (#601) | 2 роки тому |
| Dockerfile.build | 084acdb57e [refactor] Convert hyphen to underscore in the directory tree (#524) | 2 роки тому |
| README.md | 8ff1ada6dc [cosmwasm] Injective cosmwasm (#680) | 2 роки тому |
| build.sh | 138fbd924f fix build.sh script (#574) | 2 роки тому |
This directory contains the Pyth contract for CosmWasm and utilities to deploy it on CosmWasm chains.
Deploying the CosmWasm contract has three steps:
This directory contains the code to perform all the steps. Read below for the details.
First, build the contracts within the current directory. You must have Docker installed.
NOTE: In order to build for Injective. We need to enable a feature in Cargo.toml like this.
[features]
default=["injective"]
...
bash build.sh
This command will build and save the Pyth contract in the artifacts directory.
Then, to deploy the Pyth contract (pyth_cosmwasm.wasm), run the following command in the tools directory:
npm ci # Do it only once to install the required packages
npm run deploy-pyth -- deploy-artifact --network osmosis_local --mnemonic "online prefer ..." --artifact "../artifacts/pyth_cosmwasm.wasm"
If successful, this command will print something along the lines of:
Deploying artifact
Storing WASM: ../artifacts/pyth_cosmwasm.wasm (230813 bytes)
Broadcasted transaction hash: "BBD2E5DF5046B24287E63C53852D251D4F7DDD7755E663C9EB67A9B5560DFE4C"
Deployed Code ID: 11
This command will upload the code and instantiates a new Pyth contract with the given code id:
npm run deploy-pyth -- instantiate --network osmosis_local --code-id 10 --mnemonic "online prefer ..."
If successful, the output should look like so:
Instantiating a contract
Broadcasted transaction hash: "5F9689ACEB5A57868F9B305A211962DEA826B1C47900904D39D61449A095ADE1"
Instantiated pyth at osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d (0xb884f83f981dda1d2f9957cd68e1f19cb49d3c04aea2ecfbe833ddc6b7cac2f7)
Deployed Pyth contract at osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d
If you want to upgrade an existing contract pass use the migrate command as follows.
This command will upload the code, and with the given code id, will migrate the existing contract to the new one:
npm run deploy-pyth -- migrate --network osmosis_local --code-id 9 --contract osmo1.. --mnemonic "online prefer ..."
If successful, the output should look like so:
Migrating contract osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d to 9
Broadcasted transaction hash: "8CF74A7FDBA4264DC58418289D6A256DEA3BBFB89ABD6C0D74C0CEBC29418E52"
Contract osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d code_id successfully updated to 9
Pyth contracts are owner of their own. To update a smart contract's admin use the following command.
npm run deploy-pyth -- update-admin --network osmosis_local --new-admin osmo1.. --contract osmo1... --mnemonic "online prefer ..."
The output should be like.
Updating contract's admin
Broadcasted transaction hash: "B8AA9E25F3AF28858464622AFABA0C0157BD0CB1814C6DB62ACDD2D240E5B973"
{
codeId: 9,
address: 'osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d',
creator: 'osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks',
admin: 'osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d',
initMsg: undefined
}
Contract's admin successfully updates
If you want to check a contract details, use the following command.
npm run deploy-pyth -- get-contract-info --network osmosis_local --contract osmo1... --mnemonic "online prefer ..."
The output should be like:
Fetching contract info for: osmo1v6qjx5smfdxnh5gr8vprswl60rstyprj3wh4gz5mg7gcl7mtl5xqkm7gje
Fetched contract info for: osmo1v6qjx5smfdxnh5gr8vprswl60rstyprj3wh4gz5mg7gcl7mtl5xqkm7gje
{
codeId: 9,
address: 'osmo1v6qjx5smfdxnh5gr8vprswl60rstyprj3wh4gz5mg7gcl7mtl5xqkm7gje',
creator: 'osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks',
admin: 'osmo1v6qjx5smfdxnh5gr8vprswl60rstyprj3wh4gz5mg7gcl7mtl5xqkm7gje',
initMsg: undefined
}
While running the instantiation/migration commands you might get the following errors:
Sometimes the output might have some node.js warning. But if you see a similar output as mentioned above. Transaction was successful.