-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
409 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
MNEMONIC='' | ||
CONTRACT_ADDR='' | ||
MNEMONIC='' |
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,58 @@ | ||
import dotenv from "dotenv"; | ||
import yargs from "yargs/yargs"; | ||
import { MnemonicKey } from "@terra-money/terra.js"; | ||
import { Network, getLcd, storeCode, instantiateContract } from "./helpers"; | ||
|
||
const argv = yargs(process.argv) | ||
.options({ | ||
network: { | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
"hub-code-id": { | ||
type: "number", | ||
demandOption: false, | ||
}, | ||
"nft-code-id": { | ||
type: "number", | ||
demandOption: false, | ||
}, | ||
}) | ||
.parseSync(); | ||
|
||
(async function main() { | ||
dotenv.config(); | ||
const network = Network.Testnet; | ||
const terra = getLcd(network); | ||
const deployer = terra.wallet(new MnemonicKey({ mnemonic: process.env.MNEMONIC })); | ||
console.log("deployer address:", deployer.key.accAddress); | ||
|
||
process.stdout.write("ready to execute; press any key to continue, CTRL+C to abort..."); | ||
process.stdin.once("data", async function () { | ||
let hubCodeId: number; | ||
if (argv["hub-code-id"]) { | ||
hubCodeId = argv["hub-code-id"]; | ||
} else { | ||
process.stdout.write("hub code id not provided! storing code... "); | ||
hubCodeId = await storeCode(terra, deployer, "../artifacts/trophy_hub.wasm"); | ||
} | ||
console.log("hub code id:", hubCodeId); | ||
|
||
let nftCodeId: number; | ||
if (argv["nft-code-id"]) { | ||
nftCodeId = argv["nft-code-id"]; | ||
} else { | ||
process.stdout.write("hub code id not provided! storing code... "); | ||
nftCodeId = await storeCode(terra, deployer, "../artifacts/trophy_nft.wasm"); | ||
} | ||
console.log("nft code id:", nftCodeId); | ||
|
||
process.stdout.write("instantiating hub contract... "); | ||
const hubAddress = await instantiateContract(terra, deployer, hubCodeId, { | ||
nft_code_id: nftCodeId, | ||
}); | ||
console.log("success! contract address:", hubAddress); | ||
|
||
process.exit(0); | ||
}); | ||
})(); |
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,55 @@ | ||
import dotenv from "dotenv"; | ||
import yargs from "yargs/yargs"; | ||
import { MnemonicKey, MsgMigrateContract } from "@terra-money/terra.js"; | ||
import { Network, getLcd, sendTransaction, storeCode } from "./helpers"; | ||
import { number } from "yargs"; | ||
|
||
const argv = yargs(process.argv) | ||
.options({ | ||
network: { | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
"nft-address": { | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
"code-id": { | ||
type: "number", | ||
demandOption: false, | ||
}, | ||
}) | ||
.parseSync(); | ||
|
||
(async function main() { | ||
if (argv.network !== "mainnet" && argv.network !== "testnet") { | ||
throw new Error("invalid network! must be `mainnet` or `testnet`"); | ||
} | ||
const terra = getLcd(argv.network === "mainnet" ? Network.Mainnet : Network.Testnet); | ||
|
||
dotenv.config(); | ||
const deployer = terra.wallet(new MnemonicKey({ mnemonic: process.env.MNEMONIC })); | ||
console.log("deployer address:", deployer.key.accAddress); | ||
|
||
const nftAddress = argv["nft-address"]; | ||
console.log("nft address:", nftAddress); | ||
|
||
let codeId: number; | ||
if (argv["code-id"]) { | ||
codeId = argv["code-id"]; | ||
} else { | ||
process.stdout.write("code id not provided! storing code... "); | ||
codeId = await storeCode(terra, deployer, "../artifacts/trophy_nft.wasm"); | ||
} | ||
console.log("code id:", codeId); | ||
|
||
process.stdout.write("ready to execute; press any key to continue, CTRL+C to abort..."); | ||
process.stdin.once("data", async function () { | ||
process.stdout.write("migrating nft contract... "); | ||
const { txhash } = await sendTransaction(terra, deployer, [ | ||
new MsgMigrateContract(deployer.key.accAddress, nftAddress, codeId, {}), | ||
]); | ||
console.log("success! txhash:", txhash); | ||
process.exit(0); | ||
}); | ||
})(); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.