当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ethers.utils类代码示例

本文整理汇总了TypeScript中ethers.utils的典型用法代码示例。如果您正苦于以下问题:TypeScript utils类的具体用法?TypeScript utils怎么用?TypeScript utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了utils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: deposit

  public async deposit(
    address: Address,
    amount: ethers.utils.BigNumber,
    threshold: ethers.utils.BigNumber
  ) {
    const stateChannelInfo = await this.queryStateChannel();
    const isPeerA =
      stateChannelInfo.data.stateChannel.freeBalance.alice === this.fromAddress;

    const signingKeys = [this.toAddress, this.fromAddress];
    const appInstance = new ETHBalanceRefundApp(address, signingKeys);
    const deposits = {
      [this.fromAddress]: ethers.utils.bigNumberify("0"),
      [this.toAddress]: ethers.utils.bigNumberify("0")
    };
    const state = [this.fromAddress, this.multisigAddress, threshold];

    const balanceRefund = await this.install(
      "ETHBalanceRefundApp",
      appInstance,
      deposits,
      state
    );
    await this.depositToMultisig(amount);
    await balanceRefund.uninstall({
      peerABalance: isPeerA ? amount : ethers.utils.bigNumberify(0),
      peerBBalance: isPeerA ? ethers.utils.bigNumberify(0) : amount
    });
  }
开发者ID:cylof22,项目名称:monorepo,代码行数:29,代码来源:channel.ts

示例2:

const signaturesAndDigests = ["sig1", "sig3", "sig2"].map(message => {
  const bytes = ethers.utils.toUtf8Bytes(message);
  const digest = ethers.utils.keccak256(bytes);
  const signature = signingKey.signDigest(digest);

  return {
    digest,
    signature
  };
});
开发者ID:cylof22,项目名称:monorepo,代码行数:10,代码来源:signature.spec.ts

示例3: terms

 public static terms(): Terms {
   // FIXME: Change implementation of free balance on contracts layer
   // https://github.com/counterfactual/monorepo/issues/118
   return new Terms(
     0, // 0 means ETH
     ethers.utils.parseEther("0.001"), // FIXME: un-hardcode (https://github.com/counterfactual/monorepo/issues/117)
     ethers.constants.AddressZero
   );
 }
开发者ID:cylof22,项目名称:monorepo,代码行数:9,代码来源:free-balance.ts

示例4: constructor

  constructor(appAddress: string, signingKeys: string[]) {
    const timeout = 100;
    const terms = new Terms(
      0,
      ethers.utils.bigNumberify("0"),
      ethers.constants.AddressZero
    );
    const abiEncodings = AppInstance.generateAbiEncodings(
      ETHBalanceRefundAppContract.abi
    );

    const appDefinition: AppDefinition = {
      address: appAddress,
      appStateEncoding: abiEncodings.appStateEncoding,
      appActionEncoding: abiEncodings.appActionEncoding
    };

    super(signingKeys, appDefinition, terms, timeout);
  }
开发者ID:cylof22,项目名称:monorepo,代码行数:19,代码来源:eth-balance-refund-app.ts

示例5: generateAbiEncodings

  // TODO: temp hack necessary until ethers support https://github.com/ethers-io/ethers.js/issues/325
  static generateAbiEncodings(
    abi: string | (string | ethers.utils.ParamType)[]
  ): AbiEncodings {
    const iface = new ethers.utils.Interface(abi);
    const appFunctionNames = Object.keys(iface.functions).filter(fn => {
      return fn.indexOf("(") === -1;
    });
    const appActions = appFunctionNames.map(fn => {
      const inputs = iface.functions[fn].inputs;
      const tuples = inputs.map(input => {
        return ethers.utils.formatParamType(input);
      });

      return `${fn}(${tuples.join(",")})`;
    });

    return {
      appStateEncoding: ethers.utils.formatParamType(
        iface.functions.resolve.inputs[0]
      ),
      appActionEncoding: JSON.stringify([appActions.join(",")])
    };
  }
开发者ID:cylof22,项目名称:monorepo,代码行数:24,代码来源:app-instance.ts

示例6: constructor

 constructor(
   readonly address: Address,
   balance: number | ethers.utils.BigNumber
 ) {
   this.balance = ethers.utils.bigNumberify(balance.toString());
 }
开发者ID:cylof22,项目名称:monorepo,代码行数:6,代码来源:peer-balance.ts

示例7:

const deserializeBigNumber = data => ethers.utils.bigNumberify(data._hex);
开发者ID:cylof22,项目名称:monorepo,代码行数:1,代码来源:serializer.ts

示例8:

 const tuples = inputs.map(input => {
   return ethers.utils.formatParamType(input);
 });
开发者ID:cylof22,项目名称:monorepo,代码行数:3,代码来源:app-instance.ts

示例9: encodePacked

export function encodePacked(types: string[], values: any[]) {
  return ethers.utils.solidityPack(types, values);
}
开发者ID:cylof22,项目名称:monorepo,代码行数:3,代码来源:abi.ts

示例10: signaturesToBytes

 sigs.sort((sigA, sigB) => {
   const addrA = ethers.utils.recoverAddress(digest, signaturesToBytes(sigA));
   const addrB = ethers.utils.recoverAddress(digest, signaturesToBytes(sigB));
   return new ethers.utils.BigNumber(addrA).lt(addrB) ? -1 : 1;
 });
开发者ID:cylof22,项目名称:monorepo,代码行数:5,代码来源:signature.ts


注:本文中的ethers.utils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。