liquidity-invoice-generation
Advanced tools
Comparing version 1.1.3 to 1.2.0
19
index.js
@@ -38,3 +38,3 @@ const BigNumber = require('bignumber.js') | ||
{type: 'uint256', value: invoice.amount.toFixed(0)}, | ||
{type: 'bytes4', value: invoice.currency}, | ||
{type: 'bytes32', value: invoice.tokenAddress}, | ||
{type: 'bytes32', value: invoice.details}, | ||
@@ -52,8 +52,11 @@ ) | ||
* @param receiver {{networkId: number, contractAddress: string, publicKey: string}} - Details of the receiver | ||
* @param amount {number} - Amount to be paid in the smallest division supported by the currency | ||
* @param amount {number} - Amount to be paid in the smallest division supported by the tokenAddress | ||
* @param details {string} - Details to be hashed | ||
* @param currency {string} - Currency to be used for the payment | ||
* @returns {{invoice: {uuid: string, destinations: {networkId: number, contractAddress: string, walletAddresses: string[]}[], amount, currency: string, details: string}, nonce: string}} | ||
* @param tokenAddress {string} - tokenAddress to be used for the payment | ||
* @returns {{invoice: {uuid: string, destinations: {networkId: number, contractAddress: string, walletAddresses: string[]}[], amount, tokenAddress: string, details: string}, nonce: string}} | ||
*/ | ||
const createInvoice = (receiver, amount, details = '', currency = 'ETH') => { | ||
const createInvoice = (receiver, amount, details = '', tokenAddress) => { | ||
if (typeof tokenAddress === 'undefined') { | ||
tokenAddress = receiver.hubAddress | ||
} | ||
const invoice = { | ||
@@ -69,3 +72,3 @@ uuid: uuid().split('-').join(''), | ||
amount: new BigNumber(amount), | ||
currency: currency, | ||
tokenAddress: tokenAddress, | ||
details: web3Utils.soliditySha3(details) | ||
@@ -92,3 +95,3 @@ } | ||
invoice.amount.toString(), | ||
invoice.currency, | ||
invoice.tokenAddress, | ||
invoice.details, | ||
@@ -117,3 +120,3 @@ ].join('|') | ||
amount: new BigNumber(data[2]), | ||
currency: data[3], | ||
tokenAddress: data[3], | ||
details: data[4], | ||
@@ -120,0 +123,0 @@ } |
{ | ||
"name": "liquidity-invoice-generation", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Invoice generation system compatible with Liquidity Network", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
14515
149