• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ethers.ethers.utils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: it

    it("transfers the funds conditionally if true", async () => {
      const randomTarget = Utils.randomETHAddress();
      const tx = ct.interface.functions.executeSimpleConditionalTransaction.encode(
        [
          makeCondition(ethers.constants.HashZero, true),
          {
            value: [Utils.UNIT_ETH],
            assetType: 0,
            to: [randomTarget],
            token: ethers.constants.AddressZero,
            data: []
          }
        ]
      );

      await testDelegateProxy.functions.delegate(
        ct.address,
        tx,
        Utils.HIGH_GAS_LIMIT
      );

      const balTarget = await provider.getBalance(randomTarget);
      expect(balTarget.toHexString()).to.be.eql(
        ethers.utils.hexStripZeros(Utils.UNIT_ETH.toHexString())
      );

      const emptyBalance = new ethers.utils.BigNumber(0);
      const balDelegate = await provider.getBalance(testDelegateProxy.address);
      expect(balDelegate.toHexString()).to.be.eql(
        ethers.utils.hexStripZeros(emptyBalance.toHexString())
      );
    });
开发者ID:cylof22,项目名称:monorepo,代码行数:32,代码来源:conditionalTransaction.spec.ts


示例2:

const computeStateHash = (stateHash: string, nonce: number, timeout: number) =>
  ethers.utils.keccak256(
    ethers.utils.solidityPack(
      ["bytes1", "address[]", "uint256", "uint256", "bytes32"],
      ["0x19", [A.address, B.address], nonce, timeout, stateHash]
    )
  );
开发者ID:cylof22,项目名称:monorepo,代码行数:7,代码来源:countingGame.spec.ts


示例3: propose

  public static propose(message: InternalMessage): StateProposal {
    const toAddress = message.clientMessage.toAddress;
    const fromAddress = message.clientMessage.fromAddress;

    const balances = cf.legacy.utils.PeerBalance.balances(
      toAddress,
      ethers.utils.bigNumberify(0),
      fromAddress,
      ethers.utils.bigNumberify(0)
    );
    const localNonce = 0;
    const freeBalance = new cf.legacy.utils.FreeBalance(
      balances.peerA.address,
      balances.peerA.balance,
      balances.peerB.address,
      balances.peerB.balance,
      FREE_BALANCE_UNIQUE_ID,
      localNonce,
      FREE_BALANCE_TIMEOUT,
      new cf.legacy.utils.Nonce(false, FREE_BALANCE_UNIQUE_ID, 0)
    );
    const stateChannel = new StateChannelInfoImpl(
      toAddress,
      fromAddress,
      message.clientMessage.multisigAddress,
      {},
      freeBalance
    );
    return {
      state: {
        [String(message.clientMessage.multisigAddress)]: stateChannel
      }
    };
  }
开发者ID:cylof22,项目名称:monorepo,代码行数:34,代码来源:setup-proposer.ts


示例4: signMessageBytes

export function signMessageBytes(message: string, wallet: ethers.Wallet) {
  const [v, r, s] = signMessageVRS(message, wallet);
  return (
    ethers.utils.hexlify(ethers.utils.padZeros(r, 32)).substring(2) +
    ethers.utils.hexlify(ethers.utils.padZeros(s, 32)).substring(2) +
    v.toString(16)
  );
}
开发者ID:cylof22,项目名称:monorepo,代码行数:8,代码来源:misc.ts


示例5: it

 it("reverts if the target is not a contract", async () => {
   await Utils.assertRejects(
     testCaller.functions.execStaticCall(
       ethers.utils.hexlify(ethers.utils.randomBytes(20)),
       echo.interface.functions.helloWorld.sighash,
       "0x"
     )
   );
 });
开发者ID:cylof22,项目名称:monorepo,代码行数:9,代码来源:staticCall.spec.ts


示例6: validateInstallInfos

function validateInstallInfos(
  infos: cf.legacy.channel.StateChannelInfos,
  expectedCfAddr: cf.legacy.utils.H256
) {
  const stateChannel = infos[UNUSED_FUNDED_ACCOUNT];

  expect(stateChannel.freeBalance.aliceBalance.toNumber()).toEqual(15);
  expect(stateChannel.freeBalance.bobBalance.toNumber()).toEqual(17);

  const app = infos[UNUSED_FUNDED_ACCOUNT].appInstances[expectedCfAddr];
  const expectedSalt =
    "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6";

  expect(app.id).toEqual(expectedCfAddr);
  expect(app.peerA.address).toEqual(A_ADDRESS);
  expect(app.peerA.balance.toNumber()).toEqual(5);
  expect(app.peerB.address).toEqual(B_ADDRESS);
  expect(app.keyA).toEqual(KEY_A);
  expect(app.keyB).toEqual(KEY_B);
  expect(app.encodedState).toEqual("0x0");
  expect(app.localNonce).toEqual(1);
  expect(app.timeout).toEqual(100);
  expect(app.terms.assetType).toEqual(0);
  expect(app.terms.limit).toEqual(ethers.utils.bigNumberify(8));
  expect(app.terms.token).toEqual(TOKEN_ADDRESS);
  expect(app.cfApp.address).toEqual(APP_ADDRESS);
  expect(app.cfApp.applyAction).toEqual(APPLY_ACTION);
  expect(app.cfApp.resolve).toEqual(RESOLVE);
  expect(app.cfApp.getTurnTaker).toEqual(TURN);
  expect(app.cfApp.isStateTerminal).toEqual(IS_STATE_TERMINAL);
  expect(app.dependencyNonce.salt).toEqual(expectedSalt);
  expect(app.dependencyNonce.nonceValue).toEqual(0);
}
开发者ID:cylof22,项目名称:monorepo,代码行数:33,代码来源:state-transition.spec.ts


示例7: installClientMsg

function installClientMsg(): cf.legacy.node.ClientActionMessage {
  return {
    requestId: "0",
    appId: "0",
    action: cf.legacy.node.ActionName.INSTALL,
    data: {
      peerA: new cf.legacy.utils.PeerBalance(A_ADDRESS, 5),
      peerB: new cf.legacy.utils.PeerBalance(B_ADDRESS, 3),
      keyA: KEY_A,
      keyB: KEY_B,
      encodedAppState: "0x0",
      terms: new cf.legacy.app.Terms(
        0,
        ethers.utils.bigNumberify(8),
        TOKEN_ADDRESS
      ),
      app: new cf.legacy.app.AppInterface(
        APP_ADDRESS,
        APPLY_ACTION,
        RESOLVE,
        TURN,
        IS_STATE_TERMINAL,
        ABI_ENCODING
      ),
      timeout: 100
    },
    multisigAddress: UNUSED_FUNDED_ACCOUNT,
    fromAddress: B_ADDRESS,
    toAddress: A_ADDRESS,
    stateChannel: undefined,
    seq: 0
  };
}
开发者ID:cylof22,项目名称:monorepo,代码行数:33,代码来源:state-transition.spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ethers.utils类代码示例发布时间:2022-05-25
下一篇:
TypeScript ethers.ethers.ContractFactory类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap