浏览代码

Add terra migrate instructions

Csongor Kiss 3 年之前
父节点
当前提交
3fc065846e
共有 3 个文件被更改,包括 101 次插入1 次删除
  1. 6 1
      clients/token_bridge/main.ts
  2. 22 0
      terra/README.md
  3. 73 0
      terra/tools/migrate_testnet.js

+ 6 - 1
clients/token_bridge/main.ts

@@ -130,6 +130,11 @@ yargs(hideBin(process.argv))
                 type: "string",
                 required: true
             })
+            .option('guardian_secret', {
+                describe: 'Guardian\'s secret key',
+                type: "string",
+                default: "cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0"
+            })
     }, async (argv: any) => {
         let data = [
             "0x",
@@ -147,7 +152,7 @@ yargs(hideBin(process.argv))
             Math.floor(Math.random() * 100000000),
             data,
             [
-                "cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0"
+               argv.guardian_secret
             ],
             0,
             0

+ 22 - 0
terra/README.md

@@ -21,3 +21,25 @@ Storing WASM: ../artifacts/token_bridge.wasm (367689 bytes)
 Deploy fee:  88446uluna
 Code ID:  2435
 ```
+
+# Migrate
+
+## Mainnet
+
+Migrations on mainnet have to go through governance. Once the guardians sign the
+upgrade VAA, the contract can be upgraded by submitting the signed VAA to the
+appropriate contract. For example, to upgrade the token bridge on mainnet,
+in `wormhole/clients/token_bridge/`:
+
+``` sh
+node main.js terra execute_governance_vaa <signed VAA (hex)> --rpc "https://lcd.terra.dev" --chain_id "columbus-5" --mnemonic "..." --token_bridge "terra10nmmwe8r3g99a9newtqa7a75xfgs2e8z87r2sf"
+```
+
+## Testnet
+
+
+For example, to migrate the token bridge to 37262, run in `tools/`:
+
+``` sh
+node migrate_testnet.js --code_id 37262 --contract terra1pseddrv0yfsn76u4zxrjmtf45kdlmalswdv39a --mnemonic "..."
+```

+ 73 - 0
terra/tools/migrate_testnet.js

@@ -0,0 +1,73 @@
+import { LCDClient, MnemonicKey } from "@terra-money/terra.js";
+import {
+  MsgMigrateContract,
+} from "@terra-money/terra.js";
+import axios from "axios";
+import yargs from "yargs";
+import { hideBin } from "yargs/helpers";
+
+export const TERRA_GAS_PRICES_URL = "https://fcd.terra.dev/v1/txs/gas_prices";
+
+const argv = yargs(hideBin(process.argv))
+  .option('code_id', {
+    description: 'Which code id to upgrade to',
+    type: 'number',
+  })
+  .option('mnemonic', {
+    description: 'Mnemonic (private key)',
+    type: 'string',
+    required: true
+  })
+  .option('contract', {
+    description: 'Contract to upgrade',
+    type: 'string',
+    required: true
+  })
+  .help()
+  .alias('help', 'h').argv;
+
+/* Set up terra client & wallet */
+
+const terra_host = {
+  URL: "https://bombay-lcd.terra.dev",
+  chainID: "bombay-12",
+  name: "testnet",
+};
+
+const lcd = new LCDClient(terra_host);
+
+const feeDenoms = ["uluna"];
+
+const gasPrices = await axios
+  .get(TERRA_GAS_PRICES_URL)
+  .then((result) => result.data);
+
+const wallet = lcd.wallet(
+  new MnemonicKey({
+    mnemonic: argv.mnemonic
+  })
+);
+
+await wallet.sequence();
+
+/* Do upgrade */
+
+const tx = await wallet.createAndSignTx({
+  msgs: [
+    new MsgMigrateContract(
+      wallet.key.accAddress,
+      argv.contract,
+      argv.code_id,
+      {
+        "action": ""
+      },
+      { uluna: 1000 }
+    ),
+  ],
+  memo: "",
+  feeDenoms,
+  gasPrices,
+});
+
+const rs = await lcd.tx.broadcast(tx);
+console.log(rs);