How to use the @0xcert/utils.toTuple function in @0xcert/utils

To help you get started, we’ve selected a few @0xcert/utils 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 / actions-order.ts View on Github external
export function createSignatureTuple(claim: string[] | string) {
  if (typeof claim === 'string') {
    const [kind, signature] = claim.split(':');
    const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
    const signatureData = {
      r: signature.substr(0, 66),
      s: `0x${signature.substr(66, 64)}`,
      v: parseInt(`0x${signature.substr(130, 2)}`),
      k,
    };

    if (signatureData.v < 27) {
      signatureData.v = signatureData.v + 27;
    }
    return toTuple(signatureData);
  } else {
    const signatures = [];
    claim.forEach((c) => {
      const [kind, signature] = c.split(':');
      const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
      const signatureData = {
        r: signature.substr(0, 66),
        s: `0x${signature.substr(66, 64)}`,
        v: parseInt(`0x${signature.substr(130, 2)}`),
        k,
      };

      if (signatureData.v < 27) {
        signatureData.v = signatureData.v + 27;
      }
      signatures.push(signatureData);
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / asset-ledger-deploy-order.ts View on Github external
export function createSignatureTuple(claim: string) {
  const [kind, signature] = claim.split(':');
  const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;

  const signatureData = {
    r: signature.substr(0, 66),
    s: `0x${signature.substr(66, 64)}`,
    v: parseInt(`0x${signature.substr(130, 2)}`),
    k,
  };

  if (signatureData.v < 27) {
    signatureData.v = signatureData.v + 27;
  }

  return toTuple(signatureData);
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / actions-order.ts View on Github external
claim.forEach((c) => {
      const [kind, signature] = c.split(':');
      const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
      const signatureData = {
        r: signature.substr(0, 66),
        s: `0x${signature.substr(66, 64)}`,
        v: parseInt(`0x${signature.substr(130, 2)}`),
        k,
      };

      if (signatureData.v < 27) {
        signatureData.v = signatureData.v + 27;
      }
      signatures.push(signatureData);
    });
    return toTuple(signatures);
  }
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / value-ledger-deploy-order.ts View on Github external
export function createSignatureTuple(claim: string) {
  const [kind, signature] = claim.split(':');
  const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;

  const signatureData = {
    r: signature.substr(0, 66),
    s: `0x${signature.substr(66, 64)}`,
    v: parseInt(`0x${signature.substr(130, 2)}`),
    k,
  };

  if (signatureData.v < 27) {
    signatureData.v = signatureData.v + 27;
  }

  return toTuple(signatureData);
}
github 0xcert / framework / packages / 0xcert-ethereum-deploy-gateway / src / lib / deploy.ts View on Github external
export function createSignatureTuple(claim: string) {
  const [kind, signature] = claim.split(':');
  const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;

  const signatureData = {
    r: signature.substr(0, 66),
    s: `0x${signature.substr(66, 64)}`,
    v: parseInt(`0x${signature.substr(130, 2)}`),
    k,
  };

  if (signatureData.v < 27) {
    signatureData.v = signatureData.v + 27;
  }

  return toTuple(signatureData);
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / asset-ledger-deploy-order.ts View on Github external
uriPrefix: order.assetLedgerData.uriPrefix,
      uriPostfix: order.assetLedgerData.uriPostfix,
      schemaId: `0x${order.assetLedgerData.schemaId}`,
      capabilities: order.assetLedgerData.capabilities.map((c) => { return getInterfaceCode(c); }),
      owner: order.assetLedgerData.ownerId,
    },
    transferData: {
      token: order.tokenTransferData.ledgerId,
      to: order.tokenTransferData.receiverId,
      value: getValue(order.tokenTransferData.value),
    },
    seed: toInteger(order.seed),
    expirationTimestamp: toSeconds(order.expiration),
  };

  return toTuple(recipeData);
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / value-ledger-deploy-order.ts View on Github external
name: order.valueLedgerData.name,
      symbol: order.valueLedgerData.symbol,
      supply: order.valueLedgerData.supply,
      decimals: order.valueLedgerData.decimals,
      owner: order.valueLedgerData.ownerId,
    },
    transferData: {
      token: order.tokenTransferData.ledgerId,
      to: order.tokenTransferData.receiverId,
      value: getValue(order.tokenTransferData.value),
    },
    seed: toInteger(order.seed),
    expirationTimestamp: toSeconds(order.expiration),
  };

  return toTuple(recipeData);
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / lib / actions-order.ts View on Github external
export function createRecipeTuple(gateway: Gateway, order: ActionsOrder) {
  const actions = (order.actions as ActionsOrderAction[]).map((action) => {
    return {
      proxyId: getActionProxy(gateway, action),
      contractAddress: action.ledgerId,
      params: getActionParams(action, order.signers),
    };
  });

  const recipeData = {
    signers: order.signers,
    actions,
    seed: toInteger(order.seed),
    expirationTimestamp: toSeconds(order.expiration),
  };
  return toTuple(recipeData);
}
github 0xcert / framework / packages / 0xcert-ethereum-deploy-gateway / src / lib / deploy.ts View on Github external
symbol: deploy.assetLedgerData.symbol,
      uriBase: deploy.assetLedgerData.uriBase,
      schemaId: deploy.assetLedgerData.schemaId,
      capabilities: deploy.assetLedgerData.capabilities.map((c) => { return getInterfaceCode(c); }),
      owner: deploy.assetLedgerData.owner,
    },
    transferData: {
      token: deploy.tokenTransferData.ledgerId,
      to: deploy.tokenTransferData.receiverId,
      value: getValue(deploy.tokenTransferData.value),
    },
    seed: toInteger(deploy.seed),
    expirationTimestamp: toSeconds(deploy.expiration),
  };

  return toTuple(recipeData);
}

@0xcert/utils

General utility module with common helper functions.

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis