-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: rust contract: use scripts instead of Makefile
- Loading branch information
Showing
7 changed files
with
153 additions
and
68 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { program } from "commander"; | ||
import fs from "fs/promises"; | ||
|
||
import { deployCwAddressList } from "./../network-setup/deployCwAddressList"; | ||
import { buildCosmos, startCosmosLocalnet } from "./cosmos"; | ||
import { teritoriLocalnetNetwork } from "../../networks/teritori-localnet"; | ||
|
||
const main = async () => { | ||
program.argument( | ||
"<repo-path>", | ||
"Path to the repo to build latest binary from", | ||
); | ||
program.parse(); | ||
const [repoPath] = program.args; | ||
|
||
const binary = await buildCosmos(repoPath, "teritorid"); | ||
|
||
const { home, kill, admSigner } = await startCosmosLocalnet(binary); | ||
if (!admSigner) { | ||
throw new Error("adm signer is undefined"); | ||
} | ||
|
||
await deployCwAddressList({ | ||
opts: { binaryPath: binary, home }, | ||
networkId: teritoriLocalnetNetwork.id, | ||
wallet: "testnet-adm", | ||
}); | ||
|
||
await kill(); | ||
await fs.rm(home, { recursive: true, force: true }); | ||
}; | ||
|
||
main(); |
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,115 @@ | ||
import { OfflineSigner } from "@cosmjs/proto-signing"; | ||
import { bech32 } from "bech32"; | ||
import { program } from "commander"; | ||
import { cloneDeep } from "lodash"; | ||
import os from "os"; | ||
import path from "path"; | ||
|
||
import { InstantiateMsg as CwAddressListInstantiateMsg } from "@/contracts-clients/cw-address-list"; | ||
import { | ||
allNetworks, | ||
CosmosNetworkInfo, | ||
getCosmosNetwork, | ||
getNetworkFeature, | ||
NetworkFeature, | ||
} from "@/networks"; | ||
import { execPromise } from "@/scripts/lib"; | ||
import { | ||
instantiateContract, | ||
storeWASM, | ||
} from "@/scripts/network-setup/deployLib"; | ||
|
||
// CONTRACT_ADDRESS_TESTNET = tori1x72plnprsjnmszylmdm3cnvu5h6u55fyf0pe02lye9p6q2ws05ps33qmft | ||
// CODE_ID_TESTNET = 63 | ||
|
||
export const deployCwAddressList = async ({ | ||
opts, | ||
networkId, | ||
wallet, | ||
}: { | ||
networkId: string; | ||
wallet: string; | ||
opts: { home: string; binaryPath: string; keyringBackend?: string }; | ||
}) => { | ||
const network = cloneDeep(getCosmosNetwork(networkId)); | ||
if (!network) { | ||
console.error(`Cosmos network ${networkId} not found`); | ||
process.exit(1); | ||
} | ||
console.log(`Deploying to ${network.displayName}`); | ||
|
||
let walletAddr = ( | ||
await execPromise( | ||
`${opts.binaryPath} keys show --keyring-backend ${opts.keyringBackend || "test"} -a ${wallet} --home ${opts.home}`, | ||
{ encoding: "utf-8" }, | ||
) | ||
).stdout.trim(); | ||
if (walletAddr.startsWith("Successfully migrated")) { | ||
walletAddr = walletAddr.substring(walletAddr.indexOf("\n")).trim(); | ||
} | ||
bech32.decode(walletAddr); | ||
console.log("Wallet address:", walletAddr); | ||
|
||
if (!network.cwAddressListContractAddress) { | ||
console.log("Storing cw address list"); | ||
const cwAddressListWasmFilePath = path.join( | ||
__dirname, | ||
"cw_address_list.wasm", | ||
); | ||
network.cwAdminFactoryCodeId = await storeWASM( | ||
opts, | ||
wallet, | ||
network, | ||
cwAddressListWasmFilePath, | ||
); | ||
|
||
console.log("Instantiating cw address list", network.cwAdminFactoryCodeId); | ||
network.cwAddressListContractAddress = await instantiateCwAddressList( | ||
opts, | ||
wallet, | ||
walletAddr, | ||
network, | ||
); | ||
} | ||
}; | ||
|
||
const instantiateCwAddressList = async ( | ||
opts: { home: string; binaryPath: string; keyringBackend?: string }, | ||
wallet: string, | ||
adminAddr: string, | ||
network: CosmosNetworkInfo, | ||
) => { | ||
const codeId = network.cwAdminFactoryCodeId; | ||
if (!codeId) { | ||
throw new Error("CW Address List code ID not found"); | ||
} | ||
return await instantiateContract( | ||
opts, | ||
wallet, | ||
network, | ||
codeId, | ||
adminAddr, | ||
"Teritori CW Address List", | ||
{}, | ||
); | ||
}; | ||
|
||
const main = async () => { | ||
program.argument("<network-id>", "Network id to deploy to"); | ||
program.argument("<wallet>", "Wallet to deploy from"); | ||
program.option("--keyring-backend [keyring-backend]", "Keyring backend"); | ||
program.parse(); | ||
const [networkId, wallet] = program.args; | ||
const { keyringBackend } = program.opts(); | ||
|
||
await deployCwAddressList({ | ||
opts: { | ||
home: path.join(os.homedir(), ".teritorid"), | ||
binaryPath: "teritorid", | ||
keyringBackend, | ||
}, | ||
networkId, | ||
wallet, | ||
}); | ||
}; | ||
main(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.