How to use the @0xcert/scaffold.ProviderIssue.WRONG_INPUT function in @0xcert/scaffold

To help you get started, we’ve selected a few @0xcert/scaffold 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-ethereum-gateway / src / lib / value-ledger-deploy-order.ts View on Github external
export function normalizeOrderIds(order: ValueLedgerDeployOrder, provider: GenericProvider): ValueLedgerDeployOrder {
  order = JSON.parse(JSON.stringify(order));
  let dynamic = false;

  if (!order.takerId) {
    order.takerId = zeroAddress;
    dynamic = true;
  } else {
    order.takerId = provider.encoder.normalizeAddress(order.takerId);
  }
  order.makerId = provider.encoder.normalizeAddress(order.makerId);
  order.tokenTransferData.ledgerId = provider.encoder.normalizeAddress(order.tokenTransferData.ledgerId);

  if (!order.tokenTransferData.receiverId) {
    if (!dynamic) {
      throw new ProviderError(ProviderIssue.WRONG_INPUT, 'receiverId is not set.');
    }
    order.tokenTransferData.receiverId = zeroAddress;
  } else {
    order.tokenTransferData.receiverId = provider.encoder.normalizeAddress(order.tokenTransferData.receiverId);
  }
  order.valueLedgerData.ownerId = provider.encoder.normalizeAddress(order.valueLedgerData.ownerId);
  return order;
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / asset-ledger-deploy-order.ts View on Github external
export function normalizeOrderIds(order: AssetLedgerDeployOrder, provider: GenericProvider): AssetLedgerDeployOrder {
  order = JSON.parse(JSON.stringify(order));
  let dynamic = false;

  if (!order.takerId) {
    order.takerId = zeroAddress;
    dynamic = true;
  } else {
    order.takerId = provider.encoder.normalizeAddress(order.takerId);
  }
  order.makerId = provider.encoder.normalizeAddress(order.makerId);
  order.tokenTransferData.ledgerId = provider.encoder.normalizeAddress(order.tokenTransferData.ledgerId);

  if (!order.tokenTransferData.receiverId) {
    if (!dynamic) {
      throw new ProviderError(ProviderIssue.WRONG_INPUT, 'receiverId is not set.');
    }
    order.tokenTransferData.receiverId = zeroAddress;
  } else {
    order.tokenTransferData.receiverId = provider.encoder.normalizeAddress(order.tokenTransferData.receiverId);
  }
  order.assetLedgerData.ownerId = provider.encoder.normalizeAddress(order.assetLedgerData.ownerId);
  return order;
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / actions-order.ts View on Github external
order.actions.forEach((action) => {
      action.ledgerId = provider.encoder.normalizeAddress(action.ledgerId);
      action['senderId'] = action['senderId'] ? provider.encoder.normalizeAddress(action['senderId']) : action['senderId'] = ZERO_ADDRESS;
      if (action.kind !== ActionsOrderActionKind.UPDATE_ASSET_IMPRINT && action.kind !== ActionsOrderActionKind.DESTROY_ASSET) {
        action['receiverId'] = action['receiverId'] ? provider.encoder.normalizeAddress(action['receiverId']) : action['receiverId'] = ZERO_ADDRESS;
        if (action['senderId'] === ZERO_ADDRESS && action['receiverId'] === ZERO_ADDRESS) {
          throw new ProviderError(ProviderIssue.WRONG_INPUT, 'Both senderId and receiverId missing.');
        }
      }
    });
  }
github 0xcert / framework / packages / 0xcert-ethereum-deploy-gateway / src / lib / deploy.ts View on Github external
export function normalizeDeployIds(deploy: Deploy, provider: GenericProvider): Deploy {
  deploy = JSON.parse(JSON.stringify(deploy));
  let dynamic = false;

  if (!deploy.takerId) {
    deploy.takerId = zeroAddress;
    dynamic = true;
  } else {
    deploy.takerId = provider.encoder.normalizeAddress(deploy.takerId);
  }
  deploy.makerId = provider.encoder.normalizeAddress(deploy.makerId);
  deploy.tokenTransferData.ledgerId = provider.encoder.normalizeAddress(deploy.tokenTransferData.ledgerId);

  if (!deploy.tokenTransferData.receiverId) {
    if (!dynamic) {
      throw new ProviderError(ProviderIssue.WRONG_INPUT, 'receiverId is not set.');
    }
    deploy.tokenTransferData.receiverId = zeroAddress;
  } else {
    deploy.tokenTransferData.receiverId = provider.encoder.normalizeAddress(deploy.tokenTransferData.receiverId);
  }
  deploy.assetLedgerData.owner = provider.encoder.normalizeAddress(deploy.assetLedgerData.owner);
  return deploy;
}