Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@arcblock/did-util

Package Overview
Dependencies
Maintainers
2
Versions
577
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcblock/did-util - npm Package Compare versions

Comparing version 0.34.0 to 0.35.0

21

lib/index.d.ts

@@ -52,2 +52,12 @@ // Generate by [js2dts@0.3.3](https://github.com/whxaxes/js2dts#readme)

/**
* Generate an delegate address, eg: the did of the delegation
*
* @public
* @static
* @param {string} addr1 - delegator address
* @param {string} addr2 - delegatee address
* @returns {string} delegation address that can be used to retrieve delegation state
*/
declare function toDelegateAddress(addr1: string, addr2: string): string;
/**
* Generate an stake address, eg: the did of the stake

@@ -71,2 +81,11 @@ *

declare function toTetherAddress(hash: string): string;
/**
* Generate a swap address from the setup swap tx hash
*
* @public
* @static
* @param {string} hash - SetupSwapTx hash
* @returns {string} swap address without `did:abt:` prefix
*/
declare function toSwapAddress(hash: string): string;
declare const _Lib: _Lib.T100;

@@ -80,6 +99,8 @@ declare namespace _Lib {

toStakeAddress: typeof toStakeAddress;
toDelegateAddress: typeof toDelegateAddress;
toStakeDid: typeof toStakeDid;
toTetherAddress: typeof toTetherAddress;
toSwapAddress: typeof toSwapAddress;
}
}
export = _Lib;

@@ -93,2 +93,19 @@ /**

/**
* Generate an delegate address, eg: the did of the delegation
*
* @public
* @static
* @param {string} addr1 - delegator address
* @param {string} addr2 - delegatee address
* @returns {string} delegation address that can be used to retrieve delegation state
*/
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);
}
/**
* Generate a tether address from the deposit tether tx hash

@@ -106,2 +123,14 @@ *

/**
* Generate a swap address from the setup swap tx hash
*
* @public
* @static
* @param {string} hash - SetupSwapTx hash
* @returns {string} swap address without `did:abt:` prefix
*/
function toSwapAddress(hash) {
return fromHash(hash, types.RoleType.ROLE_SWAP);
}
/**
* Generate an stake address, eg: the did of the stake

@@ -125,4 +154,6 @@ *

toStakeAddress,
toDelegateAddress,
toStakeDid,
toTetherAddress,
toSwapAddress,
};

17

package.json
{
"name": "@arcblock/did-util",
"description": "Helper function to calculate did",
"version": "0.34.0",
"version": "0.35.0",
"author": {

@@ -21,8 +21,8 @@ "name": "wangshijun",

"dependencies": {
"@arcblock/did": "^0.34.0",
"@arcblock/forge-message": "^0.34.0",
"@arcblock/forge-proto": "^0.34.0",
"@arcblock/forge-util": "^0.34.0",
"@arcblock/forge-wallet": "^0.34.0",
"@arcblock/mcrypto": "^0.34.0"
"@arcblock/did": "^0.35.0",
"@arcblock/forge-message": "^0.35.0",
"@arcblock/forge-proto": "^0.35.0",
"@arcblock/forge-util": "^0.35.0",
"@arcblock/forge-wallet": "^0.35.0",
"@arcblock/mcrypto": "^0.35.0"
},

@@ -67,2 +67,3 @@ "devDependencies": {

"prepush": "CI=1 yarn test",
"upgrade": "yarn generate-dts && yarn generate-docs && yarn format-docs",
"generate-docs": "jsdoc2md lib/index.js > docs/README.md",

@@ -74,3 +75,3 @@ "generate-dts": "j2d lib/index.js",

},
"gitHead": "e2b48a5c0a28d6b9b2f2948935319365bbcf7dba"
"gitHead": "57a6fb9db075c208775443657fa78c12cfcafc0e"
}

@@ -9,9 +9,9 @@ ![did-util](https://www.arcblock.io/.netlify/functions/badge/?text=did-util)

## Table of Contents
- [Table of Contents](#Table-of-Contents)
- [Install](#Install)
- [Usage](#Usage)
- [Documentation](#Documentation)
- [Contributors](#Contributors)
* [Install](#install)
* [Usage](#usage)
* [Documentation](#documentation)
* [Contributors](#contributors)

@@ -18,0 +18,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc