Admin 发布的文章

'use strict';
exports.main = async (event, context) => {
    let headers = event.headers
    delete headers.host
    const res = await uniCloud.httpclient.request(event.queryStringParameters.url, {
        method: event.httpMethod,
        headers: headers,
        content: event.body,
        rejectUnauthorized: false,
        followRedirect: true
    })
    return {
        // mpserverlessComposedResponse: true, // https://uniapp.dcloud.io/uniCloud/http?id=integrationresponse
        statusCode: res.status,
        headers: res.headers,
        body: res.data.toString()
    }
}

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Add network to keplr</title>
    <style>
      input {width: 256px; padding: 5px}
      td {padding: 5px}
    </style>
    <link rel="icon" type="image/svg+xml" href="https://docs.keplr.app/favicon-svg.svg">
  </head>
  <body>
    <div style="max-width: 512px; margin: 0 auto; padding-top: 100px">
      <table border="0">
        <tr>
          <td>chainId</td>
          <td><input id="chainId" value="xxxChain"></td>
        </tr>
        <tr>
          <td>rpc</td>
          <td><input id="rpc" value="http://ip:26657"></td>
        </tr>
        <tr>
          <td>rest</td>
          <td><input id="rest" value="http://ip:1317"></td>
        </tr>
        <tr>
          <td>prefix</td>
          <td><input id="prefix" value="jolt"></td>
        </tr>
        <tr>
          <td>coinDenom</td>
          <td><input id="coinDenom" value="VUSD"></td>
        </tr>
        <tr>
          <td>coinDecimals</td>
          <td><input id="coinDecimals" value="0"></td>
        </tr>
        <tr>
          <td>gasPriceStep</td>
          <td><input id="gasPriceStep" value="0.01"></td>
        </tr>
        <tr>
          <td>walletUrlForStaking</td>
          <td><input id="walletUrlForStaking" value="url"></td>
        </tr>
        <tr>
          <td><button onclick="submit()">Submit</button></td>
          <td></td>
        </tr>
      </table>
      <p>Usage: https://docs.keplr.app/api/suggest-chain.html</p>
    </div>
    <script>
      submit = async () => {
        if (!keplr) {
          alert("Please install keplr extension"); return
        }
        const prefix = document.getElementById('prefix').value
        const coinDenom = document.getElementById('coinDenom').value
        const coinDecimals = parseInt(document.getElementById('coinDecimals').value)
        const gasPriceStep = Number(document.getElementById('gasPriceStep').value)
        await keplr.experimentalSuggestChain({
          chainId: document.getElementById('chainId').value,
          chainName: document.getElementById('chainId').value,
          rpc: document.getElementById('rpc').value,
          rest: document.getElementById('rest').value,
          bip44: {
            coinType: 118,
          },
          bech32Config: {
            bech32PrefixAccAddr: prefix,
            bech32PrefixAccPub: prefix + "pub",
            bech32PrefixValAddr: prefix + "valoper",
            bech32PrefixValPub: prefix + "valoperpub",
            bech32PrefixConsAddr: prefix + "valcons",
            bech32PrefixConsPub: prefix + "valconspub",
          },
          currencies: [
            { 
              coinDenom: coinDenom,
              coinMinimalDenom: coinDenom,
              coinDecimals: coinDecimals
            }, 
          ],
          feeCurrencies: [
            {
              coinDenom: coinDenom, 
              coinMinimalDenom: coinDenom,
              coinDecimals: coinDecimals
            },
          ],
          stakeCurrency: {
            coinDenom: coinDenom,
            coinMinimalDenom: coinDenom,
            coinDecimals: coinDecimals
          },
          coinType: 118,
          gasPriceStep: { 
            low: gasPriceStep,
            average: gasPriceStep*2,
            high: gasPriceStep*3,
          },
          walletUrlForStaking: document.getElementById('walletUrlForStaking').value
        })
      }
    </script>
  </body>
</html>

https://medium.com/1milliondevs/compilererror-stack-too-deep-try-removing-local-variables-solved-a6bcecc16231

If you get this error it probably means you have too many function arguments, local variables or return values in your function.

Instead of declaring 6 local variables it declares a single local variable that is a struct holding the 6 variables. Here’s a snippet:

struct SlotInfo {
  uint originalSelectorSlotsLength;
  bytes32 selectorSlot;
  uint oldSelectorSlotsIndex;
  uint oldSelectorSlotIndex;
  bytes32 oldSelectorSlot;
  bool newSlot;
}
// Using the struct to avoid Stack too deep error
function diamondCut(bytes[] memory _diamondCut) public override {
  SlotInfo memory slot;
  slot.originalSelectorSlotsLength = $selectorSlotsLength; 
  ... code omitted 
  if(selectorSlotLength > 0) {
    slot.selectorSlot = $selectorSlots[selectorSlotsLength];
  }
  ... code omitted for simplicity

Ubuntu安装和管理NodeJS版本(兼容ARM版)

  1. 根据nmv官网(https://github.com/nvm-sh/nvm)的脚本安装nvm,例如

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

    建议根据官网去使用最新版本号

    安装完成可能需要配置环境变量,在安装完成的界面会有提示:

    运行 nvm -v 可查看版本号

  2. 用nvm命令行安装node:

    nvm install node # "node" is an alias for the latest version
    nvm install 14.18.2 # or 16.3.0, 12.22.1, etc

    nvm会根据你的系统是x86还是ARM安装对应版本,node官网列出了所有可用版本号:https://nodejs.org/en/download/releases/

    安装后查看版本,如果版本号不对,运行 nvm use node 使刚安装的版本生效。

  3. 安装完成后,运行 node -p process.arch 可以查看安装版本是x86还是ARM

以上就是全部教程。你可以在任何时候运行nvm命令安装其它版本的node并切换版本