How to use the @0xcert/ethereum-gateway.OrderKind.SIGNED_FIXED_ACTIONS_ORDER function in @0xcert/ethereum-gateway

To help you get started, we’ve selected a few @0xcert/ethereum-gateway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xcert / framework / packages / 0xcert-client / src / core / controllers / orders-controller.ts View on Github external
orderActions.push({
      kind: ActionsOrderActionKind.TRANSFER_VALUE,
      senderId: order.payerId,
      receiverId: this.context.payment.receiverAddress,
      value: value.toFixed(0),
      ledgerId: this.context.payment.tokenAddress,
    } as FrameworkActionsOrderAction);

    // Parse signers into valid API structure.
    const signers: Signer[] = order.signersIds.map((s) => { return { accountId: s, claim: '' }; });

    // Check if account is specified as signer and generate its claim.
    const accountSignerIndex = signers.findIndex((s) => s.accountId.toLowerCase() === this.context.provider.accountId.toLowerCase());
    if (accountSignerIndex !== -1) {
      const claimOrder = {
        kind: order.wildcardSigner ? OrderKind.SIGNED_DYNAMIC_ACTIONS_ORDER : OrderKind.SIGNED_FIXED_ACTIONS_ORDER,
        seed: date,
        signers: order.signersIds,
        expiration,
        actions: orderActions,
      } as FrameworkActionsOrder;

      signers[accountSignerIndex].claim = await orderGateway.sign(claimOrder);
    }

    return clientFetch(`${this.context.apiUrl}/orders`, {
      method: 'POST',
      body: JSON.stringify({
        priority,
        order: {
          seed: date,
          signers,