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

TypeScript cf.js.utils类代码示例

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

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



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

示例1: setCommitment

  /**
   * Sets the commitment at the end of a protocol's execution.
   * @param internalMessage
   * @param next
   * @param context
   * @throws Error if the counterparty's signature is not set
   */
  public async setCommitment(
    internalMessage: InternalMessage,
    next: Function,
    context: Context
  ) {
    let appId;
    const action: cf.legacy.node.ActionName = internalMessage.actionName;
    const operation = context.intermediateResults.operation!;
    let appCommitments: AppCommitments;

    const incomingMessage = this.incomingMessage(internalMessage, context);

    if (action === cf.legacy.node.ActionName.SETUP) {
      appId = internalMessage.clientMessage.multisigAddress;
    } else if (action === cf.legacy.node.ActionName.INSTALL) {
      const proposal = context.intermediateResults.proposedStateTransition!;
      appId = proposal.cfAddr;
    } else {
      appId = internalMessage.clientMessage.appId;
    }

    if (this.store.has(appId)) {
      appCommitments = AppCommitments.deserialize(appId, this.store.get(appId));
    } else {
      appCommitments = new AppCommitments(appId);
      this.appCount += 1;
      this.store.put(appId, Object(appCommitments.serialize()));
    }

    const signature = context.intermediateResults.signature!;

    const counterpartySignature = incomingMessage!.signature!;
    if (
      counterpartySignature === undefined ||
      cf.utils.signaturesToBytes(signature) ===
        cf.utils.signaturesToBytes(counterpartySignature)
    ) {
      // FIXME: these errors should be handled more gracefully
      // https://github.com/counterfactual/monorepo/issues/99
      throw Error(
        `Cannot make commitment for operation ${action}.
        The counterparty hasn't signed the commitment.`
      );
    }

    await appCommitments.addCommitment(action, operation, [
      signature,
      counterpartySignature
    ]);
    this.store.put(appId, Object(appCommitments.serialize()));
    next();
  }
开发者ID:cylof22,项目名称:monorepo,代码行数:59,代码来源:test-commitment-store.ts


示例2: constructSetStateData

function constructSetStateData(signatures: ethers.utils.Signature[]): string {
  return constructContractCall(
    "proxyCall(address,bytes32,bytes)",
    TEST_NETWORK_CONTEXT.registryAddr,
    TEST_APP_INSTANCE.cfAddress(),
    constructContractCall(
      "setState(bytes32,uint256,uint256,bytes)",
      TEST_APP_STATE_HASH,
      TEST_LOCAL_NONCE,
      TEST_TIMEOUT,
      cf.utils.signaturesToBytes(...signatures)
    )
  );
}
开发者ID:cylof22,项目名称:monorepo,代码行数:14,代码来源:set-state.spec.ts


示例3: constructMultisigExecTransaction

export function constructMultisigExecTransaction(
  operation: "delegatecall" | "call",
  to: string,
  value: string | number,
  transactionData: string,
  signatures: ethers.utils.Signature[]
): string {
  return constructContractCall(
    "execTransaction(address, uint256, bytes, uint8, bytes)",
    to,
    value,
    transactionData,
    operation === "delegatecall" ? 1 : 0,
    cf.utils.signaturesToBytes(...signatures)
  );
}
开发者ID:cylof22,项目名称:monorepo,代码行数:16,代码来源:fixture.ts


示例4: transaction

 public transaction(sigs: ethers.utils.Signature[]): Transaction {
   const multisigInput = this.multisigInput();
   const signatureBytes = cf.utils.signaturesToSortedBytes(
     this.hashToSign(),
     ...sigs
   );
   const txData = new ethers.utils.Interface(
     MinimumViableMultisigJson.abi
   ).functions.execTransaction.encode([
     multisigInput.to,
     multisigInput.val,
     multisigInput.data,
     multisigInput.op,
     signatureBytes
   ]);
   return new Transaction(this.multisig, 0, txData);
 }
开发者ID:cylof22,项目名称:monorepo,代码行数:17,代码来源:multisig-tx-op.ts


示例5: transaction

 /**
  * @returns a tx that executes a proxyCall through the registry to call
  *          `setState` on AppInstance.sol.
  */
 public transaction(sigs: ethers.utils.Signature[]): Transaction {
   const appCfAddr = new cf.legacy.app.AppInstance(
     this.ctx,
     this.multisig,
     this.signingKeys,
     this.app,
     this.terms,
     this.timeout,
     this.appUniqueId
   ).cfAddress();
   const to = this.ctx.registryAddr;
   const val = 0;
   const data = common.proxyCallSetStateData(
     this.ctx,
     this.appStateHash,
     appCfAddr,
     this.appLocalNonce,
     this.timeout,
     cf.utils.signaturesToSortedBytes(this.hashToSign(), ...sigs)
   );
   return new Transaction(to, val, data);
 }
开发者ID:cylof22,项目名称:monorepo,代码行数:26,代码来源:op-set-state.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.TdLoadingService类代码示例发布时间:2022-05-28
下一篇:
TypeScript reporters.parser_warn函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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