[cosmwasm] Deploy tool: Add new commands (update contract admin + get contract info) (#473)

* add terra local config

* terra update admin and contract info

* osmosis update admin and contract info

* update deployer interface

* injective update admin and contract info

* refactor yargs structure

* update injective sdk ts library

* update readme.md

* error handling for update admin code

* fix typo

* move logging to the calling function

* comment the update admin method
This commit is contained in:
Dev Kalra 2023-01-12 18:06:37 +05:30 committed by GitHub
parent 5da094f864
commit e169da0a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 554 additions and 492 deletions

View File

@ -4,18 +4,19 @@ This directory contains the Pyth contract for CosmWasm and utilities to deploy i
## Deployment ## Deployment
Deploying the CosmWasm contract has two steps: Deploying the CosmWasm contract has three steps:
1. Upload the code. This step will give you a code id. 1. Upload the code. This step will give you a code id.
2. Either create a new contract or migrate an existing one: 2. Either create a new contract or migrate an existing one:
1. Create a new contract that has an address with a code id as its program. 1. Create a new contract that has an address with a code id as its program.
2. Migrating an existing contract code id to the new code id. 2. Migrating an existing contract code id to the new code id.
3. Update contract's admin to itself.
This directory includes a script to perform both steps. Read below for the details. This directory contains the code to perform all the steps. Read below for the details.
### Uploading the code ### Uploading the code
First, build the contracts within [the current directory](./): First, build the contracts within [the current directory](./). You must have Docker installed.
```sh ```sh
bash build.sh bash build.sh
@ -27,59 +28,95 @@ Then, to deploy the Pyth contract (`pyth_cosmwasm.wasm`), run the following comm
```sh ```sh
npm ci # Do it only once to install the required packages npm ci # Do it only once to install the required packages
npm run deploy-pyth -- --network terra_testnet --artifact ../artifacts/pyth_cosmwasm.wasm --mnemonic "..." 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: If successful, this command will print something along the lines of:
```sh ```sh
Storing WASM: ../artifacts/pyth_cosmwasm.wasm (367689 bytes) Deploying artifact
Deploy fee: 88446uluna Storing WASM: ../artifacts/pyth_cosmwasm.wasm (230813 bytes)
Code ID: 2435 Broadcasted transaction hash: "BBD2E5DF5046B24287E63C53852D251D4F7DDD7755E663C9EB67A9B5560DFE4C"
Deployed Code ID: 11
``` ```
If you do not pass any additional arguments to the script, it will only upload the code and return the code id. If you want to create a
new contract or upgrade an existing contract you should pass more arguments that are described below.
### Instantiating new contract ### Instantiating new contract
If you want to instantiate a new contract after your deployment, pass `--instantiate` to the above command. This command will upload the code and instantiates a new Pyth contract with the given code id:
This command will upload the code and instantiates a new Pyth contract with the resulting code id:
```sh ```sh
npm run deploy-pyth -- --network testnet --artifact ../artifacts/pyth_cosmwasm.wasm --mnemonic "..." --instantiate npm run deploy-pyth -- instantiate --network osmosis_local --code-id 10 --mnemonic "online prefer ..."
``` ```
If successful, the output should look like so: If successful, the output should look like so:
``` ```
Storing WASM: ../artifacts/pyth_cosmwasm.wasm (183749 bytes)
Deploy fee: 44682uluna
Code ID: 53199
Instantiating a contract Instantiating a contract
Sleeping for 10 seconds for store transaction to finalize. Broadcasted transaction hash: "5F9689ACEB5A57868F9B305A211962DEA826B1C47900904D39D61449A095ADE1"
Instantiated Pyth at terra123456789yelw23uh22nadqlyjvtl7s5527er97 (0x0000000000000000000000001234567896267ee5479752a7d683e49317ff4294) Instantiated pyth at osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d (0xb884f83f981dda1d2f9957cd68e1f19cb49d3c04aea2ecfbe833ddc6b7cac2f7)
Deployed Pyth contract at terra123456789yelw23uh22nadqlyjvtl7s5527er97 Deployed Pyth contract at osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d
``` ```
### Migrating existing contract ### Migrating existing contract
If you want to upgrade an existing contract pass `--migrate --contract terra123456xyzqwe..` to the above command. If you want to upgrade an existing contract pass use the `migrate` command as follows.
This command will upload the code, and with the resulting code id, will migrate the existing contract to the new one: This command will upload the code, and with the given code id, will migrate the existing contract to the new one:
```sh ```sh
npm run deploy-pyth -- --network testnet --artifact ../artifacts/pyth_cosmwasm.wasm --mnemonic "..." --migrate --contract "terra123..." npm run deploy-pyth -- migrate --network osmosis_local --code-id 9 --contract osmo1.. --mnemonic "online prefer ..."
``` ```
If successful, the output should look like so: If successful, the output should look like so:
``` ```
Storing WASM: ../artifacts/pyth_cosmwasm.wasm (183749 bytes) Migrating contract osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d to 9
Deploy fee: 44682uluna Broadcasted transaction hash: "8CF74A7FDBA4264DC58418289D6A256DEA3BBFB89ABD6C0D74C0CEBC29418E52"
Code ID: 53227 Contract osmo1hzz0s0ucrhdp6tue2lxk3c03nj6f60qy463we7lgx0wudd72ctms64096d code_id successfully updated to 9
Sleeping for 10 seconds for store transaction to finalize. ```
Migrating contract terra1rhjej5gkyelw23uh22nadqlyjvtl7s5527er97 to 53227
Contract terra1rhjej5gkyelw23uh22nadqlyjvtl7s5527er97 code_id successfully updated to 53227 ### Updating contract's admin
Pyth contracts are owner of their own. To update a smart contract's admin use the following command.
```sh
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
```
### Getting contract's info
If you want to check a contract details, use the following command.
```sh
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
}
``` ```
### Common Errors ### Common Errors
@ -89,11 +126,4 @@ While running the instantiation/migration commands you might get the following e
- Gateway timeout: This error means that the request timed out. It is good to double check with terra finder as sometimes transactions succeed despite being timed out. - Gateway timeout: This error means that the request timed out. It is good to double check with terra finder as sometimes transactions succeed despite being timed out.
- Account sequence mismatch: Transactions from an account should have an increasing sequence number. This error happens when a transaction from the same sender is not fully synchronized with the terra RPC and an old sequence number is used. This is likely to happen because the deploy script sends two transactions: one to submit the code, and one to do the instantiation/migration. - Account sequence mismatch: Transactions from an account should have an increasing sequence number. This error happens when a transaction from the same sender is not fully synchronized with the terra RPC and an old sequence number is used. This is likely to happen because the deploy script sends two transactions: one to submit the code, and one to do the instantiation/migration.
You can rerun your command if you encounter any of the above errors. If an error occurs after the new code is uploaded, you can avoid re-uploading the code and use the uploaded code for instantiation/migration. You can use the printed code id in the logs Sometimes the output might have some node.js warning. But if you see a similar output as mentioned above. Transaction was successful.
by passing `--code-id <codeId>` instead of `--artifact`. If you do so, the script will skip uploading the code and instantiate/migrate the contract with the given code id.
An example command using an existing code id looks like so:
```sh
npm run deploy-pyth -- --network testnet --code-id 50123 --mnemonic "..." --migrate --contract "terra123..."
```

View File

@ -12,7 +12,7 @@
"@cosmjs/cosmwasm-stargate": "^0.29.5", "@cosmjs/cosmwasm-stargate": "^0.29.5",
"@cosmjs/encoding": "^0.26.2", "@cosmjs/encoding": "^0.26.2",
"@injectivelabs/networks": "^1.0.55", "@injectivelabs/networks": "^1.0.55",
"@injectivelabs/sdk-ts": "^1.0.330", "@injectivelabs/sdk-ts": "^1.0.354",
"@injectivelabs/utils": "^1.0.47", "@injectivelabs/utils": "^1.0.47",
"@terra-money/terra.js": "^3.1.3", "@terra-money/terra.js": "^3.1.3",
"chain-registry": "^1.6.0", "chain-registry": "^1.6.0",
@ -430,17 +430,6 @@
"ethereumjs-util": "^7.1.5" "ethereumjs-util": "^7.1.5"
} }
}, },
"node_modules/@ethereumjs/rlp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-4.0.0.tgz",
"integrity": "sha512-LM4jS5n33bJN60fM5EC8VeyhUgga6/DjCPBV2vWjnfVtobqtOiNC4SQ1MRFqyBSmJGGdB533JZWewyvlcdJtkQ==",
"bin": {
"rlp": "bin/rlp"
},
"engines": {
"node": ">=14"
}
},
"node_modules/@ethereumjs/tx": { "node_modules/@ethereumjs/tx": {
"version": "3.5.2", "version": "3.5.2",
"resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz", "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz",
@ -450,19 +439,6 @@
"ethereumjs-util": "^7.1.5" "ethereumjs-util": "^7.1.5"
} }
}, },
"node_modules/@ethereumjs/util": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.0.3.tgz",
"integrity": "sha512-0apCbwc8xAaie6W7q6QyogfyRS2BMU816a8KwpnpRw9Qrc6Bws+l7J3LfCLMt2iL6Wi8CYb0B29AeIr2N4vHnw==",
"dependencies": {
"@ethereumjs/rlp": "^4.0.0-beta.2",
"async": "^3.2.4",
"ethereum-cryptography": "^1.1.2"
},
"engines": {
"node": ">=14"
}
},
"node_modules/@ethersproject/abi": { "node_modules/@ethersproject/abi": {
"version": "5.7.0", "version": "5.7.0",
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz",
@ -1238,9 +1214,9 @@
} }
}, },
"node_modules/@injectivelabs/chain-api": { "node_modules/@injectivelabs/chain-api": {
"version": "1.8.3", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/@injectivelabs/chain-api/-/chain-api-1.8.3.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/chain-api/-/chain-api-1.9.1.tgz",
"integrity": "sha512-BIg87F9BTA5njxtvOkEOIHl/gpmsqnFpHJm1SrN6IHUsW97/Zj3jXdYOy9p4WCfgxC2VZC/5IOPnwyrLwSyCWg==", "integrity": "sha512-iu71oW6QWZrAGv/Tg8Can6hQz6r0FQSrOuLc9+KqtssN/MxExrS8YjPvJMLIAchiE6hnTx4rkvfASY8r9N50vg==",
"dependencies": { "dependencies": {
"@improbable-eng/grpc-web": "^0.13.0", "@improbable-eng/grpc-web": "^0.13.0",
"google-protobuf": "^3.13.0" "google-protobuf": "^3.13.0"
@ -1258,13 +1234,13 @@
} }
}, },
"node_modules/@injectivelabs/exceptions": { "node_modules/@injectivelabs/exceptions": {
"version": "1.0.32", "version": "1.0.42",
"resolved": "https://registry.npmjs.org/@injectivelabs/exceptions/-/exceptions-1.0.32.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/exceptions/-/exceptions-1.0.42.tgz",
"integrity": "sha512-g+7UIoVL6v5OIdRrJSWLoyfHYIpey3BpWwxeUpFwXyRBkzalHPkVyYnmx1twOJd6lZyhfZWG0k9M5PcJBsrDIw==", "integrity": "sha512-CKF8c+VH0S/Ipq8MHKjG9RB71UVx1D9bx5PauSO40JX/9NorIl+3/OGQOUbrK4gfzgGzodPhryl+5S8qxjzNXg==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@improbable-eng/grpc-web": "^0.15.0", "@improbable-eng/grpc-web": "^0.15.0",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"http-status-codes": "^2.2.0", "http-status-codes": "^2.2.0",
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
"shx": "^0.3.2" "shx": "^0.3.2"
@ -1291,14 +1267,14 @@
} }
}, },
"node_modules/@injectivelabs/networks": { "node_modules/@injectivelabs/networks": {
"version": "1.0.55", "version": "1.0.68",
"resolved": "https://registry.npmjs.org/@injectivelabs/networks/-/networks-1.0.55.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/networks/-/networks-1.0.68.tgz",
"integrity": "sha512-68KF4GuKC+jIfq3LHNz8YIU0BWySymcs+/20F9zkaeBD/jUw7ywLR1OICdV3lp9RWV6eeNK8207FcTHRvun0Jg==", "integrity": "sha512-CcWcLaRX1lJQyYs97+PPDmMaEFcXQgt/WjQ5raamcbQugJwMa/byC4eS18DZ0tIIZ24CoD+79zbgHDzfoe6/qg==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@injectivelabs/exceptions": "^1.0.32", "@injectivelabs/exceptions": "^1.0.42",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"@injectivelabs/utils": "^1.0.47", "@injectivelabs/utils": "^1.0.59",
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
"shx": "^0.3.2" "shx": "^0.3.2"
} }
@ -1313,9 +1289,9 @@
} }
}, },
"node_modules/@injectivelabs/sdk-ts": { "node_modules/@injectivelabs/sdk-ts": {
"version": "1.0.330", "version": "1.0.354",
"resolved": "https://registry.npmjs.org/@injectivelabs/sdk-ts/-/sdk-ts-1.0.330.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/sdk-ts/-/sdk-ts-1.0.354.tgz",
"integrity": "sha512-Sswvp9Ao2XjC3djf5HIFdGDaw/g9j/kLDw/XwUrrpTeg114hoG7sNhl1Pxlr8TrGYBdLBdcdXqHDTUmZ3gODoA==", "integrity": "sha512-bBm9eqrRHWu7rMhINd/t1EKs4LTI65krBzkkRM4so9uZT1feJkTBuTOU/MuGthJJZnzRuIkJSi6eHMHLS78IzQ==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@apollo/client": "^3.5.8", "@apollo/client": "^3.5.8",
@ -1327,15 +1303,15 @@
"@improbable-eng/grpc-web": "^0.15.0", "@improbable-eng/grpc-web": "^0.15.0",
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0", "@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
"@improbable-eng/grpc-web-react-native-transport": "^0.15.0", "@improbable-eng/grpc-web-react-native-transport": "^0.15.0",
"@injectivelabs/chain-api": "1.8.3", "@injectivelabs/chain-api": "1.9.1",
"@injectivelabs/exceptions": "^1.0.32", "@injectivelabs/exceptions": "^1.0.42",
"@injectivelabs/indexer-api": "1.0.32-rc", "@injectivelabs/indexer-api": "1.0.32-rc",
"@injectivelabs/networks": "^1.0.55", "@injectivelabs/networks": "^1.0.68",
"@injectivelabs/ninja-api": "^1.0.11", "@injectivelabs/ninja-api": "^1.0.11",
"@injectivelabs/token-metadata": "^1.0.91", "@injectivelabs/token-metadata": "^1.0.105",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"@injectivelabs/utils": "^1.0.47", "@injectivelabs/utils": "^1.0.59",
"@metamask/eth-sig-util": "^5.0.1", "@metamask/eth-sig-util": "^4.0.0",
"@types/google-protobuf": "^3.15.5", "@types/google-protobuf": "^3.15.5",
"axios": "^0.27.2", "axios": "^0.27.2",
"bech32": "^2.0.0", "bech32": "^2.0.0",
@ -1377,13 +1353,13 @@
} }
}, },
"node_modules/@injectivelabs/token-metadata": { "node_modules/@injectivelabs/token-metadata": {
"version": "1.0.91", "version": "1.0.105",
"resolved": "https://registry.npmjs.org/@injectivelabs/token-metadata/-/token-metadata-1.0.91.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/token-metadata/-/token-metadata-1.0.105.tgz",
"integrity": "sha512-YZBy6lKCv2O9tqmBy4PTC7zOynY8Derj5X6M18HLYLJnUEkiA1NTZ1xdpuR32bvNE1kdHEo2z2AUgjMoBe9clw==", "integrity": "sha512-Stw4z5UvjZEvcV9TmKtBdtT+zGfEYzD/boYZ01BBU+Iqo28+6vdMfr6jOHlZ4fllzEtnl5NJ6lGUHYg92caijA==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@injectivelabs/networks": "^1.0.55", "@injectivelabs/networks": "^1.0.68",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"@types/lodash.values": "^4.3.6", "@types/lodash.values": "^4.3.6",
"copyfiles": "^2.4.1", "copyfiles": "^2.4.1",
"jsonschema": "^1.4.0", "jsonschema": "^1.4.0",
@ -1394,9 +1370,9 @@
} }
}, },
"node_modules/@injectivelabs/ts-types": { "node_modules/@injectivelabs/ts-types": {
"version": "1.0.18", "version": "1.0.27",
"resolved": "https://registry.npmjs.org/@injectivelabs/ts-types/-/ts-types-1.0.18.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/ts-types/-/ts-types-1.0.27.tgz",
"integrity": "sha512-fffgHjSmssLXBiI6Z/K7JuBOKTnsDm3h6ysQ5KRasmSY3NDuMCAQ5URForvdOQ38SKvhMquxQus5a+tZIWnHfg==", "integrity": "sha512-nzs6RnY4zCs8EkvabKWjGTg334RUO0D+FDPPwNzk1ONY9+264JpcEHG8i6jc+f7f3pWA5V0k11fX3jNvQBYvEQ==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
@ -1404,15 +1380,16 @@
} }
}, },
"node_modules/@injectivelabs/utils": { "node_modules/@injectivelabs/utils": {
"version": "1.0.47", "version": "1.0.59",
"resolved": "https://registry.npmjs.org/@injectivelabs/utils/-/utils-1.0.47.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/utils/-/utils-1.0.59.tgz",
"integrity": "sha512-UDbqFDwn1KU+0M1pIr5UR4wTyXuU/NiakcizKiBFstlLdZkqzX3imklwFx7XV7IJ7xZt5EbyCxf7VLj6h/MfCA==", "integrity": "sha512-WK+p44wqi3YfVdJ/vRv6ZZk28i7XGMh9V39MkHi7f6zCi4V0ogrkPdCoweGTnUOLtLSl3g7v+xT6qyh+FlwrCQ==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@injectivelabs/exceptions": "^1.0.32", "@injectivelabs/exceptions": "^1.0.42",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"axios": "^0.21.1", "axios": "^0.21.1",
"bignumber.js": "^9.0.1", "bignumber.js": "^9.0.1",
"http-status-codes": "^2.2.0",
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
"shx": "^0.3.2", "shx": "^0.3.2",
"snakecase-keys": "^5.1.2", "snakecase-keys": "^5.1.2",
@ -1453,19 +1430,40 @@
} }
}, },
"node_modules/@metamask/eth-sig-util": { "node_modules/@metamask/eth-sig-util": {
"version": "5.0.2", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-5.0.2.tgz", "resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz",
"integrity": "sha512-RU6fG/H6/UlBol221uBkq5C7w3TwLK611nEZliO2u+kO0vHKGBXnIPlhI0tzKUigjhUeOd9mhCNbNvhh0LKt9Q==", "integrity": "sha512-tghyZKLHZjcdlDqCA3gNZmLeR0XvOE9U1qoQO9ohyAZT6Pya+H9vkBPcsyXytmYLNgVoin7CKCmweo/R43V+tQ==",
"dependencies": { "dependencies": {
"@ethereumjs/util": "^8.0.0", "ethereumjs-abi": "^0.6.8",
"bn.js": "^4.11.8", "ethereumjs-util": "^6.2.1",
"ethereum-cryptography": "^1.1.2",
"ethjs-util": "^0.1.6", "ethjs-util": "^0.1.6",
"tweetnacl": "^1.0.3", "tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1" "tweetnacl-util": "^0.15.1"
}, },
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=12.0.0"
}
},
"node_modules/@metamask/eth-sig-util/node_modules/@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@metamask/eth-sig-util/node_modules/ethereumjs-util": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
"integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==",
"dependencies": {
"@types/bn.js": "^4.11.3",
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"elliptic": "^6.5.2",
"ethereum-cryptography": "^0.1.3",
"ethjs-util": "0.1.6",
"rlp": "^2.2.3"
} }
}, },
"node_modules/@noble/hashes": { "node_modules/@noble/hashes": {
@ -1479,17 +1477,6 @@
} }
] ]
}, },
"node_modules/@noble/secp256k1": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.6.3.tgz",
"integrity": "sha512-T04e4iTurVy7I8Sw4+c5OSN9/RkPlo1uKxAomtxQNLq8j1uPAqnsqG1bqvY3Jv7c13gyr6dui0zmh/I3+f/JaQ==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
]
},
"node_modules/@nodelib/fs.scandir": { "node_modules/@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -1579,48 +1566,6 @@
"resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw=="
}, },
"node_modules/@scure/base": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.1.tgz",
"integrity": "sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
]
},
"node_modules/@scure/bip32": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.1.0.tgz",
"integrity": "sha512-ftTW3kKX54YXLCxH6BB7oEEoJfoE2pIgw7MINKAs5PsS6nqKPuKk1haTF/EuHmYqG330t5GSrdmtRuHaY1a62Q==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"dependencies": {
"@noble/hashes": "~1.1.1",
"@noble/secp256k1": "~1.6.0",
"@scure/base": "~1.1.0"
}
},
"node_modules/@scure/bip39": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.1.0.tgz",
"integrity": "sha512-pwrPOS16VeTKg98dYXQyIjJEcWfz7/1YJIwxUEPFfQPtc86Ym/1sVgQ2RLoD43AazMk2l/unK4ITySSpW2+82w==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"dependencies": {
"@noble/hashes": "~1.1.1",
"@scure/base": "~1.1.0"
}
},
"node_modules/@terra-money/legacy.proto": { "node_modules/@terra-money/legacy.proto": {
"name": "@terra-money/terra.proto", "name": "@terra-money/terra.proto",
"version": "0.1.7", "version": "0.1.7",
@ -2083,11 +2028,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/async": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
},
"node_modules/asynckit": { "node_modules/asynckit": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@ -3118,45 +3058,6 @@
} }
}, },
"node_modules/ethereum-cryptography": { "node_modules/ethereum-cryptography": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz",
"integrity": "sha512-XDSJlg4BD+hq9N2FjvotwUET9Tfxpxc3kWGE2AqUG5vcbeunnbImVk3cj6e/xT3phdW21mE8R5IugU4fspQDcQ==",
"dependencies": {
"@noble/hashes": "1.1.2",
"@noble/secp256k1": "1.6.3",
"@scure/bip32": "1.1.0",
"@scure/bip39": "1.1.0"
}
},
"node_modules/ethereum-cryptography/node_modules/@noble/hashes": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz",
"integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
]
},
"node_modules/ethereumjs-abi": {
"version": "0.6.8",
"resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz",
"integrity": "sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==",
"dependencies": {
"bn.js": "^4.11.8",
"ethereumjs-util": "^6.0.0"
}
},
"node_modules/ethereumjs-abi/node_modules/@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/ethereumjs-abi/node_modules/ethereum-cryptography": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz", "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz",
"integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==", "integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==",
@ -3178,6 +3079,23 @@
"setimmediate": "^1.0.5" "setimmediate": "^1.0.5"
} }
}, },
"node_modules/ethereumjs-abi": {
"version": "0.6.8",
"resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz",
"integrity": "sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==",
"dependencies": {
"bn.js": "^4.11.8",
"ethereumjs-util": "^6.0.0"
}
},
"node_modules/ethereumjs-abi/node_modules/@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/ethereumjs-abi/node_modules/ethereumjs-util": { "node_modules/ethereumjs-abi/node_modules/ethereumjs-util": {
"version": "6.2.1", "version": "6.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
@ -3212,28 +3130,6 @@
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz",
"integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ=="
}, },
"node_modules/ethereumjs-util/node_modules/ethereum-cryptography": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz",
"integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==",
"dependencies": {
"@types/pbkdf2": "^3.0.0",
"@types/secp256k1": "^4.0.1",
"blakejs": "^1.1.0",
"browserify-aes": "^1.2.0",
"bs58check": "^2.1.2",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"hash.js": "^1.1.7",
"keccak": "^3.0.0",
"pbkdf2": "^3.0.17",
"randombytes": "^2.1.0",
"safe-buffer": "^5.1.2",
"scrypt-js": "^3.0.0",
"secp256k1": "^4.0.1",
"setimmediate": "^1.0.5"
}
},
"node_modules/ethers": { "node_modules/ethers": {
"version": "5.7.2", "version": "5.7.2",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-5.7.2.tgz", "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.7.2.tgz",
@ -5731,11 +5627,6 @@
"ethereumjs-util": "^7.1.5" "ethereumjs-util": "^7.1.5"
} }
}, },
"@ethereumjs/rlp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-4.0.0.tgz",
"integrity": "sha512-LM4jS5n33bJN60fM5EC8VeyhUgga6/DjCPBV2vWjnfVtobqtOiNC4SQ1MRFqyBSmJGGdB533JZWewyvlcdJtkQ=="
},
"@ethereumjs/tx": { "@ethereumjs/tx": {
"version": "3.5.2", "version": "3.5.2",
"resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz", "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz",
@ -5745,16 +5636,6 @@
"ethereumjs-util": "^7.1.5" "ethereumjs-util": "^7.1.5"
} }
}, },
"@ethereumjs/util": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.0.3.tgz",
"integrity": "sha512-0apCbwc8xAaie6W7q6QyogfyRS2BMU816a8KwpnpRw9Qrc6Bws+l7J3LfCLMt2iL6Wi8CYb0B29AeIr2N4vHnw==",
"requires": {
"@ethereumjs/rlp": "^4.0.0-beta.2",
"async": "^3.2.4",
"ethereum-cryptography": "^1.1.2"
}
},
"@ethersproject/abi": { "@ethersproject/abi": {
"version": "5.7.0", "version": "5.7.0",
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz",
@ -6203,9 +6084,9 @@
"requires": {} "requires": {}
}, },
"@injectivelabs/chain-api": { "@injectivelabs/chain-api": {
"version": "1.8.3", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/@injectivelabs/chain-api/-/chain-api-1.8.3.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/chain-api/-/chain-api-1.9.1.tgz",
"integrity": "sha512-BIg87F9BTA5njxtvOkEOIHl/gpmsqnFpHJm1SrN6IHUsW97/Zj3jXdYOy9p4WCfgxC2VZC/5IOPnwyrLwSyCWg==", "integrity": "sha512-iu71oW6QWZrAGv/Tg8Can6hQz6r0FQSrOuLc9+KqtssN/MxExrS8YjPvJMLIAchiE6hnTx4rkvfASY8r9N50vg==",
"requires": { "requires": {
"@improbable-eng/grpc-web": "^0.13.0", "@improbable-eng/grpc-web": "^0.13.0",
"google-protobuf": "^3.13.0" "google-protobuf": "^3.13.0"
@ -6222,12 +6103,12 @@
} }
}, },
"@injectivelabs/exceptions": { "@injectivelabs/exceptions": {
"version": "1.0.32", "version": "1.0.42",
"resolved": "https://registry.npmjs.org/@injectivelabs/exceptions/-/exceptions-1.0.32.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/exceptions/-/exceptions-1.0.42.tgz",
"integrity": "sha512-g+7UIoVL6v5OIdRrJSWLoyfHYIpey3BpWwxeUpFwXyRBkzalHPkVyYnmx1twOJd6lZyhfZWG0k9M5PcJBsrDIw==", "integrity": "sha512-CKF8c+VH0S/Ipq8MHKjG9RB71UVx1D9bx5PauSO40JX/9NorIl+3/OGQOUbrK4gfzgGzodPhryl+5S8qxjzNXg==",
"requires": { "requires": {
"@improbable-eng/grpc-web": "^0.15.0", "@improbable-eng/grpc-web": "^0.15.0",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"http-status-codes": "^2.2.0", "http-status-codes": "^2.2.0",
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
"shx": "^0.3.2" "shx": "^0.3.2"
@ -6253,13 +6134,13 @@
} }
}, },
"@injectivelabs/networks": { "@injectivelabs/networks": {
"version": "1.0.55", "version": "1.0.68",
"resolved": "https://registry.npmjs.org/@injectivelabs/networks/-/networks-1.0.55.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/networks/-/networks-1.0.68.tgz",
"integrity": "sha512-68KF4GuKC+jIfq3LHNz8YIU0BWySymcs+/20F9zkaeBD/jUw7ywLR1OICdV3lp9RWV6eeNK8207FcTHRvun0Jg==", "integrity": "sha512-CcWcLaRX1lJQyYs97+PPDmMaEFcXQgt/WjQ5raamcbQugJwMa/byC4eS18DZ0tIIZ24CoD+79zbgHDzfoe6/qg==",
"requires": { "requires": {
"@injectivelabs/exceptions": "^1.0.32", "@injectivelabs/exceptions": "^1.0.42",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"@injectivelabs/utils": "^1.0.47", "@injectivelabs/utils": "^1.0.59",
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
"shx": "^0.3.2" "shx": "^0.3.2"
} }
@ -6274,9 +6155,9 @@
} }
}, },
"@injectivelabs/sdk-ts": { "@injectivelabs/sdk-ts": {
"version": "1.0.330", "version": "1.0.354",
"resolved": "https://registry.npmjs.org/@injectivelabs/sdk-ts/-/sdk-ts-1.0.330.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/sdk-ts/-/sdk-ts-1.0.354.tgz",
"integrity": "sha512-Sswvp9Ao2XjC3djf5HIFdGDaw/g9j/kLDw/XwUrrpTeg114hoG7sNhl1Pxlr8TrGYBdLBdcdXqHDTUmZ3gODoA==", "integrity": "sha512-bBm9eqrRHWu7rMhINd/t1EKs4LTI65krBzkkRM4so9uZT1feJkTBuTOU/MuGthJJZnzRuIkJSi6eHMHLS78IzQ==",
"requires": { "requires": {
"@apollo/client": "^3.5.8", "@apollo/client": "^3.5.8",
"@cosmjs/amino": "^0.29.5", "@cosmjs/amino": "^0.29.5",
@ -6287,15 +6168,15 @@
"@improbable-eng/grpc-web": "^0.15.0", "@improbable-eng/grpc-web": "^0.15.0",
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0", "@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
"@improbable-eng/grpc-web-react-native-transport": "^0.15.0", "@improbable-eng/grpc-web-react-native-transport": "^0.15.0",
"@injectivelabs/chain-api": "1.8.3", "@injectivelabs/chain-api": "1.9.1",
"@injectivelabs/exceptions": "^1.0.32", "@injectivelabs/exceptions": "^1.0.42",
"@injectivelabs/indexer-api": "1.0.32-rc", "@injectivelabs/indexer-api": "1.0.32-rc",
"@injectivelabs/networks": "^1.0.55", "@injectivelabs/networks": "^1.0.68",
"@injectivelabs/ninja-api": "^1.0.11", "@injectivelabs/ninja-api": "^1.0.11",
"@injectivelabs/token-metadata": "^1.0.91", "@injectivelabs/token-metadata": "^1.0.105",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"@injectivelabs/utils": "^1.0.47", "@injectivelabs/utils": "^1.0.59",
"@metamask/eth-sig-util": "^5.0.1", "@metamask/eth-sig-util": "^4.0.0",
"@types/google-protobuf": "^3.15.5", "@types/google-protobuf": "^3.15.5",
"axios": "^0.27.2", "axios": "^0.27.2",
"bech32": "^2.0.0", "bech32": "^2.0.0",
@ -6336,12 +6217,12 @@
} }
}, },
"@injectivelabs/token-metadata": { "@injectivelabs/token-metadata": {
"version": "1.0.91", "version": "1.0.105",
"resolved": "https://registry.npmjs.org/@injectivelabs/token-metadata/-/token-metadata-1.0.91.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/token-metadata/-/token-metadata-1.0.105.tgz",
"integrity": "sha512-YZBy6lKCv2O9tqmBy4PTC7zOynY8Derj5X6M18HLYLJnUEkiA1NTZ1xdpuR32bvNE1kdHEo2z2AUgjMoBe9clw==", "integrity": "sha512-Stw4z5UvjZEvcV9TmKtBdtT+zGfEYzD/boYZ01BBU+Iqo28+6vdMfr6jOHlZ4fllzEtnl5NJ6lGUHYg92caijA==",
"requires": { "requires": {
"@injectivelabs/networks": "^1.0.55", "@injectivelabs/networks": "^1.0.68",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"@types/lodash.values": "^4.3.6", "@types/lodash.values": "^4.3.6",
"copyfiles": "^2.4.1", "copyfiles": "^2.4.1",
"jsonschema": "^1.4.0", "jsonschema": "^1.4.0",
@ -6352,23 +6233,24 @@
} }
}, },
"@injectivelabs/ts-types": { "@injectivelabs/ts-types": {
"version": "1.0.18", "version": "1.0.27",
"resolved": "https://registry.npmjs.org/@injectivelabs/ts-types/-/ts-types-1.0.18.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/ts-types/-/ts-types-1.0.27.tgz",
"integrity": "sha512-fffgHjSmssLXBiI6Z/K7JuBOKTnsDm3h6ysQ5KRasmSY3NDuMCAQ5URForvdOQ38SKvhMquxQus5a+tZIWnHfg==", "integrity": "sha512-nzs6RnY4zCs8EkvabKWjGTg334RUO0D+FDPPwNzk1ONY9+264JpcEHG8i6jc+f7f3pWA5V0k11fX3jNvQBYvEQ==",
"requires": { "requires": {
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
"shx": "^0.3.2" "shx": "^0.3.2"
} }
}, },
"@injectivelabs/utils": { "@injectivelabs/utils": {
"version": "1.0.47", "version": "1.0.59",
"resolved": "https://registry.npmjs.org/@injectivelabs/utils/-/utils-1.0.47.tgz", "resolved": "https://registry.npmjs.org/@injectivelabs/utils/-/utils-1.0.59.tgz",
"integrity": "sha512-UDbqFDwn1KU+0M1pIr5UR4wTyXuU/NiakcizKiBFstlLdZkqzX3imklwFx7XV7IJ7xZt5EbyCxf7VLj6h/MfCA==", "integrity": "sha512-WK+p44wqi3YfVdJ/vRv6ZZk28i7XGMh9V39MkHi7f6zCi4V0ogrkPdCoweGTnUOLtLSl3g7v+xT6qyh+FlwrCQ==",
"requires": { "requires": {
"@injectivelabs/exceptions": "^1.0.32", "@injectivelabs/exceptions": "^1.0.42",
"@injectivelabs/ts-types": "^1.0.18", "@injectivelabs/ts-types": "^1.0.27",
"axios": "^0.21.1", "axios": "^0.21.1",
"bignumber.js": "^9.0.1", "bignumber.js": "^9.0.1",
"http-status-codes": "^2.2.0",
"link-module-alias": "^1.2.0", "link-module-alias": "^1.2.0",
"shx": "^0.3.2", "shx": "^0.3.2",
"snakecase-keys": "^5.1.2", "snakecase-keys": "^5.1.2",
@ -6408,16 +6290,39 @@
} }
}, },
"@metamask/eth-sig-util": { "@metamask/eth-sig-util": {
"version": "5.0.2", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-5.0.2.tgz", "resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz",
"integrity": "sha512-RU6fG/H6/UlBol221uBkq5C7w3TwLK611nEZliO2u+kO0vHKGBXnIPlhI0tzKUigjhUeOd9mhCNbNvhh0LKt9Q==", "integrity": "sha512-tghyZKLHZjcdlDqCA3gNZmLeR0XvOE9U1qoQO9ohyAZT6Pya+H9vkBPcsyXytmYLNgVoin7CKCmweo/R43V+tQ==",
"requires": { "requires": {
"@ethereumjs/util": "^8.0.0", "ethereumjs-abi": "^0.6.8",
"bn.js": "^4.11.8", "ethereumjs-util": "^6.2.1",
"ethereum-cryptography": "^1.1.2",
"ethjs-util": "^0.1.6", "ethjs-util": "^0.1.6",
"tweetnacl": "^1.0.3", "tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1" "tweetnacl-util": "^0.15.1"
},
"dependencies": {
"@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"requires": {
"@types/node": "*"
}
},
"ethereumjs-util": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
"integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==",
"requires": {
"@types/bn.js": "^4.11.3",
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"elliptic": "^6.5.2",
"ethereum-cryptography": "^0.1.3",
"ethjs-util": "0.1.6",
"rlp": "^2.2.3"
}
}
} }
}, },
"@noble/hashes": { "@noble/hashes": {
@ -6425,11 +6330,6 @@
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.5.tgz", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.5.tgz",
"integrity": "sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==" "integrity": "sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ=="
}, },
"@noble/secp256k1": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.6.3.tgz",
"integrity": "sha512-T04e4iTurVy7I8Sw4+c5OSN9/RkPlo1uKxAomtxQNLq8j1uPAqnsqG1bqvY3Jv7c13gyr6dui0zmh/I3+f/JaQ=="
},
"@nodelib/fs.scandir": { "@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -6510,30 +6410,6 @@
"resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw=="
}, },
"@scure/base": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.1.tgz",
"integrity": "sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA=="
},
"@scure/bip32": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.1.0.tgz",
"integrity": "sha512-ftTW3kKX54YXLCxH6BB7oEEoJfoE2pIgw7MINKAs5PsS6nqKPuKk1haTF/EuHmYqG330t5GSrdmtRuHaY1a62Q==",
"requires": {
"@noble/hashes": "~1.1.1",
"@noble/secp256k1": "~1.6.0",
"@scure/base": "~1.1.0"
}
},
"@scure/bip39": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.1.0.tgz",
"integrity": "sha512-pwrPOS16VeTKg98dYXQyIjJEcWfz7/1YJIwxUEPFfQPtc86Ym/1sVgQ2RLoD43AazMk2l/unK4ITySSpW2+82w==",
"requires": {
"@noble/hashes": "~1.1.1",
"@scure/base": "~1.1.0"
}
},
"@terra-money/legacy.proto": { "@terra-money/legacy.proto": {
"version": "npm:@terra-money/terra.proto@0.1.7", "version": "npm:@terra-money/terra.proto@0.1.7",
"resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz", "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz",
@ -6867,11 +6743,6 @@
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true "dev": true
}, },
"async": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
},
"asynckit": { "asynckit": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@ -7713,21 +7584,25 @@
} }
}, },
"ethereum-cryptography": { "ethereum-cryptography": {
"version": "1.1.2", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz", "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz",
"integrity": "sha512-XDSJlg4BD+hq9N2FjvotwUET9Tfxpxc3kWGE2AqUG5vcbeunnbImVk3cj6e/xT3phdW21mE8R5IugU4fspQDcQ==", "integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==",
"requires": { "requires": {
"@noble/hashes": "1.1.2", "@types/pbkdf2": "^3.0.0",
"@noble/secp256k1": "1.6.3", "@types/secp256k1": "^4.0.1",
"@scure/bip32": "1.1.0", "blakejs": "^1.1.0",
"@scure/bip39": "1.1.0" "browserify-aes": "^1.2.0",
}, "bs58check": "^2.1.2",
"dependencies": { "create-hash": "^1.2.0",
"@noble/hashes": { "create-hmac": "^1.1.7",
"version": "1.1.2", "hash.js": "^1.1.7",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz", "keccak": "^3.0.0",
"integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==" "pbkdf2": "^3.0.17",
} "randombytes": "^2.1.0",
"safe-buffer": "^5.1.2",
"scrypt-js": "^3.0.0",
"secp256k1": "^4.0.1",
"setimmediate": "^1.0.5"
} }
}, },
"ethereumjs-abi": { "ethereumjs-abi": {
@ -7747,28 +7622,6 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"ethereum-cryptography": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz",
"integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==",
"requires": {
"@types/pbkdf2": "^3.0.0",
"@types/secp256k1": "^4.0.1",
"blakejs": "^1.1.0",
"browserify-aes": "^1.2.0",
"bs58check": "^2.1.2",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"hash.js": "^1.1.7",
"keccak": "^3.0.0",
"pbkdf2": "^3.0.17",
"randombytes": "^2.1.0",
"safe-buffer": "^5.1.2",
"scrypt-js": "^3.0.0",
"secp256k1": "^4.0.1",
"setimmediate": "^1.0.5"
}
},
"ethereumjs-util": { "ethereumjs-util": {
"version": "6.2.1", "version": "6.2.1",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
@ -7801,28 +7654,6 @@
"version": "5.2.1", "version": "5.2.1",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz",
"integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ=="
},
"ethereum-cryptography": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz",
"integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==",
"requires": {
"@types/pbkdf2": "^3.0.0",
"@types/secp256k1": "^4.0.1",
"blakejs": "^1.1.0",
"browserify-aes": "^1.2.0",
"bs58check": "^2.1.2",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"hash.js": "^1.1.7",
"keccak": "^3.0.0",
"pbkdf2": "^3.0.17",
"randombytes": "^2.1.0",
"safe-buffer": "^5.1.2",
"scrypt-js": "^3.0.0",
"secp256k1": "^4.0.1",
"setimmediate": "^1.0.5"
}
} }
} }
}, },

View File

@ -14,7 +14,7 @@
"@cosmjs/cosmwasm-stargate": "^0.29.5", "@cosmjs/cosmwasm-stargate": "^0.29.5",
"@cosmjs/encoding": "^0.26.2", "@cosmjs/encoding": "^0.26.2",
"@injectivelabs/networks": "^1.0.55", "@injectivelabs/networks": "^1.0.55",
"@injectivelabs/sdk-ts": "^1.0.330", "@injectivelabs/sdk-ts": "^1.0.354",
"@injectivelabs/utils": "^1.0.47", "@injectivelabs/utils": "^1.0.47",
"@terra-money/terra.js": "^3.1.3", "@terra-money/terra.js": "^3.1.3",
"chain-registry": "^1.6.0", "chain-registry": "^1.6.0",

View File

@ -1,115 +1,181 @@
import yargs from "yargs"; import yargs from "yargs";
import { hideBin } from "yargs/helpers"; import { hideBin } from "yargs/helpers";
import { Deployer, DeployerFactory } from "./deployer"; import { Deployer, DeployerFactory } from "./deployer";
import { NETWORKS_OPTIONS } from "./network"; import { NETWORKS, NETWORKS_OPTIONS } from "./network";
import { CONFIG as PythConfig } from "./pyth_config"; import { CONFIG as PythConfig } from "./pyth_config";
import { CONFIG as NetworkConfig } from "./deployer/config"; import { CONFIG as NetworkConfig } from "./deployer/config";
const argv = yargs(hideBin(process.argv)) const sharedOptions: { [key: string]: yargs.Options } = {
.option("network", { network: {
description: "Which network to deploy to", describe: "Which network to deploy to",
choices: NETWORKS_OPTIONS, choices: NETWORKS_OPTIONS,
required: true, demandOption: true,
}) },
.option("artifact", { mnemonic: {
description: "Path to Pyth artifact",
type: "string", type: "string",
required: false, demandOption: true,
}) describe: "Mnemonic (private key)",
.option("mnemonic", { },
description: "Mnemonic (private key)", };
type: "string",
required: true, const argv = yargs(hideBin(process.argv))
}) .usage("USAGE: npm run deploy-pyth -- <command>")
.option("instantiate", { .command(
description: "Instantiate contract if set (default: disabled)", "deploy-artifact",
type: "boolean", "to deploy artifacts (.wasm files)",
default: false, {
required: false, artifact: {
}) type: "string",
.option("migrate", { demandOption: true,
description: "Migrate an existing contract if set (default: disabled)", describe: "Path to contract artifact",
type: "boolean", },
default: false, ...sharedOptions,
required: false, },
}) deployArtifactHandler
.option("contract", { )
description: "Contract address, used only for migration", .example(
type: "string", 'npm run deploy-pyth -- deploy-artifact --network osmosis_local --mnemonic "online prefer ..." --artifact "../artifacts/pyth_cosmwasm.wasm"',
required: false, ""
default: "", )
}) .command(
.option("code-id", { "instantiate",
description: "to instantiate contract",
"Code Id, if provided this will be used for migrate/instantiate and no code will be uploaded", {
type: "number", "code-id": {
requred: false, describe: "code-id requred to instantiate contract",
}) type: "number",
demandOption: true,
},
...sharedOptions,
},
instantiateHandler
)
.example(
'npm run deploy-pyth -- instantiate --network osmosis_local --code-id 10 --mnemonic "online prefer ..."',
""
)
.command(
"migrate",
"to migrate given contract",
{
"code-id": {
describe: "code-id to which to migrate contract",
type: "number",
demandOption: true,
},
contract: {
description: "contract address is required",
type: "string",
demandOption: true,
},
...sharedOptions,
},
migrateHandler
)
.example(
'npm run deploy-pyth -- migrate --network osmosis_local --code-id 9 --contract osmo1.. --mnemonic "online prefer ..."',
""
)
.command(
"update-admin",
"to update a contract's admin",
{
"new-admin": {
description: "please input he new admin address",
type: "string",
demandOption: true,
},
contract: {
description: "contract address is required",
type: "string",
demandOption: true,
},
...sharedOptions,
},
updateAdminHandler
)
.example(
'npm run deploy-pyth -- update-admin --network osmosis_local --new-admin osmo1.. --contract osmo1... --mnemonic "online prefer ..."',
""
)
.command(
"get-contract-info",
"get a contract info",
{
contract: {
description: "contract address is required",
type: "string",
demandOption: true,
},
...sharedOptions,
},
getContractInfoHandler
)
.example(
'npm run deploy-pyth -- get-contract-info --network osmosis_local --contract osmo1... --mnemonic "online prefer ..."',
""
)
.demandCommand()
.help() .help()
.alias("help", "h") .alias("help", "h")
.parseSync(); .wrap(yargs.terminalWidth())
.parse();
const { function getDeployer(network: NETWORKS, mnemonic: string): Deployer {
artifact, const networkConfig = NetworkConfig[network];
network, return DeployerFactory.create(networkConfig, mnemonic);
mnemonic,
codeId: inputCodeId,
instantiate,
migrate,
contract,
} = argv;
const pythConfig = PythConfig[network];
const networkConfig = NetworkConfig[network];
const deployer: Deployer = DeployerFactory.create(networkConfig, mnemonic);
// checks
if (inputCodeId === undefined && artifact === undefined)
raiseCLError("Please provide either artifact or code id");
function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
} }
function raiseCLError(message: string) { async function deployArtifactHandler(argv: any) {
console.error(message); const { network, mnemonic, artifact } = argv;
process.exit(1); console.log("Deploying artifact");
const codeId = await getDeployer(
network as NETWORKS,
mnemonic as string
).deployArtifact(artifact);
console.log("Deployed Code ID: ", codeId);
} }
async function run() { async function instantiateHandler(argv: any) {
let codeId: number; const { network, mnemonic, codeId } = argv;
if (inputCodeId === undefined) { const pythConfig = PythConfig[network as NETWORKS];
console.log("Deploying artifact"); console.log("Instantiating a contract");
codeId = await deployer.deployArtifact(artifact!); const contractAddress = await getDeployer(
console.log("Deployed Code ID: ", codeId); network as NETWORKS,
mnemonic as string
// sleep only when a new artifact is deployed ).instantiate(codeId, pythConfig, "pyth");
if (instantiate || migrate) { console.log(`Deployed Pyth contract at ${contractAddress}`);
console.log("Sleeping for 10 seconds for store transaction to finalize.");
await sleep(10000);
}
} else codeId = inputCodeId;
if (instantiate) {
console.log("Instantiating a contract");
const contractAddress = await deployer.instantiate(
codeId,
pythConfig,
"pyth"
);
console.log(`Deployed Pyth contract at ${contractAddress}`);
}
if (migrate) {
if (contract === "")
raiseCLError(
"Contract address is not provided. Provide it using --contract"
);
console.log(`Migrating contract ${contract} to ${codeId}`);
await deployer.migrate(contract, codeId);
console.log(
`Contract ${contract} code_id successfully updated to ${codeId}`
);
}
} }
run(); async function migrateHandler(argv: any) {
const { network, mnemonic, codeId, contract } = argv;
console.log(`Migrating contract ${contract} to ${codeId}`);
await getDeployer(network as NETWORKS, mnemonic as string).migrate(
contract,
codeId
);
console.log(`Contract ${contract} code_id successfully updated to ${codeId}`);
}
async function updateAdminHandler(argv: any) {
const { network, mnemonic, newAdmin, contract } = argv;
console.log("Updating contract's admin");
const deployer = getDeployer(network as NETWORKS, mnemonic as string);
await deployer.updateAdmin(newAdmin, contract);
const info = await deployer.getContractInfo(contract);
console.log(info);
console.log("Contract's admin successfully updates");
}
async function getContractInfoHandler(argv: any) {
const { network, mnemonic, contract } = argv;
console.log(`Fetching contract info for: ${contract}`);
const info = await getDeployer(
network as NETWORKS,
mnemonic as string
).getContractInfo(contract);
console.log(`Fetched contract info for: ${contract}`);
console.log(info);
}

View File

@ -5,7 +5,8 @@
import { readdirSync } from "fs"; import { readdirSync } from "fs";
import { DeployerFactory } from "./deployer"; import { DeployerFactory } from "./deployer";
import { CONFIG_TYPE, NetworkConfig } from "./deployer/config"; import { CONFIG as NetworkConfig } from "./deployer/config";
import { NETWORKS } from "./network";
const ARTIFACT_DIR = "../artifacts/"; const ARTIFACT_DIR = "../artifacts/";
@ -53,16 +54,8 @@ async function deploy() {
} }
/* Set up terra deployer */ /* Set up terra deployer */
const networkConfig: NetworkConfig = {
type: CONFIG_TYPE.TERRA,
host: {
URL: "http://localhost:1317",
chainID: "localterra",
name: "localterra",
},
};
const deployer = DeployerFactory.create( const deployer = DeployerFactory.create(
networkConfig, NetworkConfig[NETWORKS.TERRA_LOCAL],
"notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius" "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius"
); );

View File

@ -27,6 +27,14 @@ export const CONFIG: Config = {
name: "testnet", name: "testnet",
}, },
}, },
[NETWORKS.TERRA_LOCAL]: {
type: CONFIG_TYPE.TERRA,
host: {
URL: "http://localhost:1317",
chainID: "localterra",
name: "localterra",
},
},
[NETWORKS.INJECTIVE_TESTNET]: { [NETWORKS.INJECTIVE_TESTNET]: {
type: CONFIG_TYPE.INJECTIVE, type: CONFIG_TYPE.INJECTIVE,
host: { host: {

View File

@ -1,9 +1,16 @@
import { CONFIG, CONFIG_TYPE, NetworkConfig } from "./config"; import { CONFIG_TYPE, NetworkConfig } from "./config";
import { TerraDeployer } from "./terra"; import { TerraDeployer } from "./terra";
import { InjectiveDeployer } from "./injective"; import { InjectiveDeployer } from "./injective";
import { NETWORKS } from "../network";
import { OsmosisDeployer } from "./osmosis"; import { OsmosisDeployer } from "./osmosis";
export type ContractInfo = {
codeId: number;
address: string;
creator: string;
admin: string | undefined;
initMsg: any;
};
export interface Deployer { export interface Deployer {
deployArtifact(artifact: string): Promise<number>; deployArtifact(artifact: string): Promise<number>;
instantiate( instantiate(
@ -12,6 +19,8 @@ export interface Deployer {
label: string label: string
): Promise<string>; ): Promise<string>;
migrate(contract: string, codeId: number): Promise<void>; migrate(contract: string, codeId: number): Promise<void>;
updateAdmin(newAdmin: string, contract: string): Promise<void>;
getContractInfo(contract: string): Promise<ContractInfo>;
} }
export class DeployerFactory { export class DeployerFactory {

View File

@ -12,9 +12,11 @@ import {
TxResponse, TxResponse,
Msgs, Msgs,
MsgMigrateContract, MsgMigrateContract,
MsgUpdateAdmin,
createTransactionForAddressAndMsg, createTransactionForAddressAndMsg,
ChainGrpcWasmApi,
} from "@injectivelabs/sdk-ts"; } from "@injectivelabs/sdk-ts";
import { Deployer } from "."; import { ContractInfo, Deployer } from ".";
export type InjectiveHost = { export type InjectiveHost = {
network: Network; network: Network;
@ -34,13 +36,12 @@ export class InjectiveDeployer implements Deployer {
} }
private async signAndBroadcastMsg( private async signAndBroadcastMsg(
msg: Msgs | MsgMigrateContract, msg: Msgs,
fee = DEFAULT_STD_FEE fee = DEFAULT_STD_FEE
): Promise<TxResponse> { ): Promise<TxResponse> {
const networkInfo = getNetworkInfo(this.network); const networkInfo = getNetworkInfo(this.network);
const { signBytes, txRaw } = await createTransactionForAddressAndMsg({ const { signBytes, txRaw } = await createTransactionForAddressAndMsg({
// @ts-ignore
message: msg, message: msg,
address: this.injectiveAddress(), address: this.injectiveAddress(),
endpoint: networkInfo.rest, endpoint: networkInfo.rest,
@ -169,6 +170,37 @@ export class InjectiveDeployer implements Deployer {
} }
} }
async updateAdmin(newAdmin: string, contract: string): Promise<void> {
const currAdmin = this.injectiveAddress();
const updateAdminMsg = new MsgUpdateAdmin({
sender: currAdmin,
newAdmin,
contract,
});
await this.signAndBroadcastMsg(updateAdminMsg);
}
async getContractInfo(contract: string): Promise<ContractInfo> {
const { grpc } = getNetworkInfo(this.network);
const api = new ChainGrpcWasmApi(grpc);
const contractInfo = await api.fetchContractInfo(contract);
if (contractInfo === undefined)
throw new Error("error fetching contract info");
const { codeId, creator, admin } = contractInfo;
return {
codeId,
address: contract,
creator: creator,
admin: admin,
initMsg: undefined,
};
}
static fromHostAndMnemonic(host: InjectiveHost, mnemonic: string) { static fromHostAndMnemonic(host: InjectiveHost, mnemonic: string) {
const wallet = PrivateKey.fromMnemonic(mnemonic); const wallet = PrivateKey.fromMnemonic(mnemonic);
return new InjectiveDeployer(host.network, wallet); return new InjectiveDeployer(host.network, wallet);

View File

@ -1,14 +1,13 @@
import { getSigningOsmosisClient } from "osmojs"; import { getSigningOsmosisClient, cosmwasm, estimateOsmoFee } from "osmojs";
import { getOfflineSignerProto as getOfflineSigner } from "cosmjs-utils"; import { getOfflineSignerProto as getOfflineSigner } from "cosmjs-utils";
import { chains } from "chain-registry"; import { chains } from "chain-registry";
import { Chain } from "@chain-registry/types"; import { Chain } from "@chain-registry/types";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import { cosmwasm, estimateOsmoFee } from "osmojs"; import { DeliverTxResponse, calculateFee } from "@cosmjs/stargate";
import { DeliverTxResponse } from "@cosmjs/stargate";
import { wasmTypes } from "@cosmjs/cosmwasm-stargate/build/modules/wasm/messages"; import { wasmTypes } from "@cosmjs/cosmwasm-stargate/build/modules/wasm/messages";
import assert from "assert"; import assert from "assert";
import { Deployer } from "."; import { ContractInfo, Deployer } from ".";
import { convert_terra_address_to_hex, extractFromRawLog } from "./terra"; import { convert_terra_address_to_hex, extractFromRawLog } from "./terra";
import { EncodeObject } from "@cosmjs/proto-signing"; import { EncodeObject } from "@cosmjs/proto-signing";
import Long from "long"; import Long from "long";
@ -51,7 +50,22 @@ export class OsmosisDeployer implements Deployer {
}); });
const address = await this.getAccountAddress(); const address = await this.getAccountAddress();
const fee = await estimateOsmoFee(client, address, [msg], "estimate fee"); const { gas } = await estimateOsmoFee(
client,
address,
[msg],
"estimate fee"
);
// libraries output more gas than simulated by multiplying with a constant
// osmojs multiplies by 1.3
// which seems to be not enough
// hence again multiplying by 1.3
const fee = calculateFee(
parseInt((parseInt(gas) * 1.3).toFixed()),
"0.025uosmo"
);
const rs = await client.signAndBroadcast(address, [msg], fee); const rs = await client.signAndBroadcast(address, [msg], fee);
if (rs.code !== 0) { if (rs.code !== 0) {
@ -166,6 +180,40 @@ export class OsmosisDeployer implements Deployer {
} }
} }
async updateAdmin(newAdmin: string, contract: string): Promise<void> {
const currAdmin = await this.getAccountAddress();
const updateAdminMsg =
cosmwasm.wasm.v1.MessageComposer.withTypeUrl.updateAdmin({
sender: currAdmin,
newAdmin,
contract,
});
const rs = await this.signAndBroadcast(updateAdminMsg);
if (rs.rawLog === undefined)
throw new Error("error parsing raw logs: rawLog undefined");
}
async getContractInfo(contract: string): Promise<ContractInfo> {
const { createRPCQueryClient } = cosmwasm.ClientFactory;
const client = await createRPCQueryClient({ rpcEndpoint: this.endpoint });
const { address, contractInfo } =
await client.cosmwasm.wasm.v1.contractInfo({ address: contract });
if (contractInfo === undefined)
throw new Error("error fetching contract info");
const { codeId, creator, admin } = contractInfo;
return {
codeId: codeId.toNumber(),
address: address,
creator: creator,
admin: admin,
initMsg: undefined,
};
}
static fromHostAndMnemonic(host: OsmosisHost, mnemonic: string) { static fromHostAndMnemonic(host: OsmosisHost, mnemonic: string) {
return new OsmosisDeployer(host.endpoint, mnemonic); return new OsmosisDeployer(host.endpoint, mnemonic);
} }

View File

@ -5,6 +5,7 @@ import {
MsgInstantiateContract, MsgInstantiateContract,
MsgMigrateContract, MsgMigrateContract,
MsgStoreCode, MsgStoreCode,
MsgUpdateContractAdmin,
WaitTxBroadcastResult, WaitTxBroadcastResult,
Wallet, Wallet,
isTxError, isTxError,
@ -13,7 +14,7 @@ import { readFileSync } from "fs";
import { Bech32, toHex } from "@cosmjs/encoding"; import { Bech32, toHex } from "@cosmjs/encoding";
import { zeroPad } from "ethers/lib/utils.js"; import { zeroPad } from "ethers/lib/utils.js";
import assert from "assert"; import assert from "assert";
import { Deployer } from "."; import { ContractInfo, Deployer } from ".";
export type TerraHost = { export type TerraHost = {
URL: string; URL: string;
@ -135,6 +136,34 @@ export class TerraDeployer implements Deployer {
} }
} }
/**
* update Admin assumes that the deployer instance is the owner of this contract
* and may result in error if this isn't the case
*/
async updateAdmin(newAdmin: string, contract: string): Promise<void> {
const currAdmin = this.wallet.key.accAddress;
const updateAdminMsg = new MsgUpdateContractAdmin(
currAdmin,
newAdmin,
contract
);
await this.signAndBroadcastMsg(updateAdminMsg);
}
async getContractInfo(contract: string): Promise<ContractInfo> {
const { code_id, address, creator, admin, init_msg } =
await this.wallet.lcd.wasm.contractInfo(contract);
return {
codeId: code_id,
address: address ?? contract,
creator: creator,
admin: admin,
initMsg: init_msg,
};
}
static fromHostAndMnemonic(host: TerraHost, mnemonic: string) { static fromHostAndMnemonic(host: TerraHost, mnemonic: string) {
const lcd = new LCDClient(host); const lcd = new LCDClient(host);
const wallet = lcd.wallet( const wallet = lcd.wallet(

View File

@ -1,6 +1,7 @@
export enum NETWORKS { export enum NETWORKS {
TERRA_MAINNET = "terra_mainnet", TERRA_MAINNET = "terra_mainnet",
TERRA_TESTNET = "terra_testnet", TERRA_TESTNET = "terra_testnet",
TERRA_LOCAL = "terra_local",
INJECTIVE_TESTNET = "injective_testnet", INJECTIVE_TESTNET = "injective_testnet",
OSMOSIS_LOCAL = "osmosis_local", OSMOSIS_LOCAL = "osmosis_local",
} }

View File

@ -102,6 +102,21 @@ export const CONFIG: Config = {
}, },
...PYTH_SOURCES_TESTNET, ...PYTH_SOURCES_TESTNET,
}, },
[NETWORKS.TERRA_LOCAL]: {
// random contract for local testing
wormhole_contract:
"terra19nv3xr5lrmmr7egvrk2kqgw4kcn43xrtd5g0mpgwwvhetusk4k7s66jyv0",
governance_source_index: 0,
governance_sequence_number: 0,
chain_id: 18,
valid_time_period_secs: 60,
fee: {
amount: "1",
denom: "uluna",
},
// invalid contract info for local testing
...PYTH_SOURCES_TESTNET,
},
[NETWORKS.INJECTIVE_TESTNET]: { [NETWORKS.INJECTIVE_TESTNET]: {
wormhole_contract: "inj1xx3aupmgv3ce537c0yce8zzd3sz567syuyedpg", wormhole_contract: "inj1xx3aupmgv3ce537c0yce8zzd3sz567syuyedpg",
governance_source_index: 0, governance_source_index: 0,