How to use the @arcblock/did.fromHash function in @arcblock/did

To help you get started, we’ve selected a few @arcblock/did 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 ArcBlock / forge-js / did / did-util / lib / index.js View on Github external
function toItxAddress(itx, type, role = types.RoleType.ROLE_TX) {
  if (transactions.indexOf(type) === -1) {
    throw new Error(`Unsupported itx type ${type}`);
  }

  const message = createMessage(type, itx);
  // console.log({ message: message.toObject(), itx });
  const itxBytes = message.serializeBinary();
  const hash = Hasher.SHA3.hash256(itxBytes);
  const address = fromHash(hash, role);
  return address;
}
github ArcBlock / forge-js / did / did-util / lib / index.js View on Github external
function toTetherAddress(hash) {
  return fromHash(hash, types.RoleType.ROLE_TETHER);
}
github ArcBlock / forge-js / did / did-util / lib / index.js View on Github external
function toSwapAddress(hash) {
  return fromHash(hash, types.RoleType.ROLE_SWAP);
}
github ArcBlock / forge-js / did / did-util / lib / index.js View on Github external
function toStakeAddress(sender, receiver) {
  const senderBuffer = Buffer.from(sender);
  const receiverBuffer = Buffer.from(receiver);
  const buffer = Buffer.concat([senderBuffer, receiverBuffer]);
  const hash = Hasher.SHA3.hash256(buffer);
  return fromHash(hash, types.RoleType.ROLE_STAKE);
}
github ArcBlock / forge-js / did / did-util / lib / index.js View on Github external
function toDelegateAddress(addr1, addr2) {
  const addr1Buffer = Buffer.from(addr1);
  const addr2Buffer = Buffer.from(addr2);
  const buffer = Buffer.concat([addr1Buffer, addr2Buffer]);
  const hash = Hasher.SHA3.hash256(buffer);
  return fromHash(hash, types.RoleType.ROLE_DELEGATE);
}