forked from cosmos/cosmjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy IBC contract to test port ID assignment
- Loading branch information
1 parent
004d880
commit 1cac9b8
Showing
7 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
775f9f8fe7d2ca1ac33ec47799e9b8fd25aa1bf3cf97961f49f091b99e62f85b cw1_subkeys.wasm | ||
3e3ea92c4ec35d90aa0bef344bdb0a94939120fce57265d5ff81bf8e8caec7e9 cw3_fixed_multisig.wasm | ||
a32acdcfe15a2b3c8ba6963cf1e4ab63347725cc35a0f2434696dd492d63fb5f hackatom.wasm | ||
089598e3cab468aff26233bc7363c713529124a0f7fd50320461cb58881a2da7 ibc_reflect.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env -S yarn node | ||
|
||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm-stargate"); | ||
const { DirectSecp256k1HdWallet } = require("@cosmjs/proto-signing"); | ||
const { calculateFee, GasPrice } = require("@cosmjs/stargate"); | ||
const fs = require("fs"); | ||
|
||
const endpoint = "http://localhost:26659"; | ||
const alice = { | ||
mnemonic: "enlist hip relief stomach skate base shallow young switch frequent cry park", | ||
address0: "wasm14qemq0vw6y3gc3u3e0aty2e764u4gs5lndxgyk", | ||
address1: "wasm1hhg2rlu9jscacku2wwckws7932qqqu8xm5ca8y", | ||
address2: "wasm1xv9tklw7d82sezh9haa573wufgy59vmwnxhnsl", | ||
address3: "wasm17yg9mssjenmc3jkqth6ulcwj9cxujrxxg9nmzk", | ||
address4: "wasm1f7j7ryulwjfe9ljplvhtcaxa6wqgula3nh873j", | ||
}; | ||
|
||
const codeMeta = { | ||
source: "https://crates.io/api/v1/crates/hackatom/not-yet-released/download", | ||
builder: "cosmwasm/rust-optimizer:0.10.8", | ||
}; | ||
|
||
const inits = [ | ||
{ | ||
label: "Instantiate IBC reflect", | ||
msg: { | ||
reflect_code_id: 222, // dummy value that will not work | ||
}, | ||
admin: undefined, | ||
}, | ||
]; | ||
|
||
async function main() { | ||
const gasPrice = GasPrice.fromString("0.025ucosm"); | ||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: "wasm" }); | ||
const client = await SigningCosmWasmClient.connectWithSigner(endpoint, wallet); | ||
|
||
const wasm = fs.readFileSync(__dirname + "/contracts/ibc_reflect.wasm"); | ||
const uploadFee = calculateFee(2_500_000, gasPrice); | ||
const uploadReceipt = await client.upload( | ||
alice.address0, | ||
wasm, | ||
uploadFee, | ||
codeMeta, | ||
"Upload IBC reflect contract", | ||
); | ||
console.info(`Upload succeeded. Receipt: ${JSON.stringify(uploadReceipt)}`); | ||
|
||
const instantiateFee = calculateFee(900_000, gasPrice); | ||
for (const { label, msg, admin } of inits) { | ||
const { contractAddress } = await client.instantiate( | ||
alice.address0, | ||
uploadReceipt.codeId, | ||
msg, | ||
label, | ||
instantiateFee, | ||
{ | ||
memo: `Create a ibc_reflect instance in deploy_ibc_reflect.js`, | ||
admin: admin, | ||
}, | ||
); | ||
console.info(`Contract instantiated at ${contractAddress}`); | ||
} | ||
} | ||
|
||
main().then( | ||
() => { | ||
console.info("All done, have fun with IBC."); | ||
process.exit(0); | ||
}, | ||
(error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters