Comparing version 1.4.2 to 1.4.3
{ | ||
"name": "slopes", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "AVA Platform JS Library", | ||
@@ -5,0 +5,0 @@ "main": "typings/src/index.js", |
@@ -169,5 +169,5 @@ /** | ||
* | ||
* @returns Promise with the balance of the assetID on the provided address for the blockchain. | ||
* @returns Promise with the balance of the assetID as a {@link https://github.com/indutny/bn.js/|BN} on the provided address for the blockchain. | ||
*/ | ||
getBalance = async (address:string, assetID:string):Promise<number> => { | ||
getBalance = async (address:string, assetID:string):Promise<BN> => { | ||
if(typeof this.parseAddress(address) === "undefined"){ | ||
@@ -182,3 +182,3 @@ /* istanbul ignore next */ | ||
return this.callMethod("avm.getBalance", params).then((response:RequestResponseData) => { | ||
return parseInt(response.data["result"]["balance"]); | ||
return new BN(response.data["result"]["balance"], 10); | ||
}); | ||
@@ -411,9 +411,9 @@ } | ||
/** | ||
* Lists all assets for an address. | ||
* Retrieves all assets for an address on a server and their associated balances. | ||
* | ||
* @param address The address to get a list of assets | ||
* | ||
* @returns Promise of an array of assetIDs for the address on the blockchain. | ||
* @returns Promise of an array of objects mapping assetID strings with {@link https://github.com/indutny/bn.js/|BN} balance for the address on the blockchain. | ||
*/ | ||
listAssets = async (address:string):Promise<Array<string>> => { | ||
getAllBalances = async (address:string):Promise<object> => { | ||
if(typeof this.parseAddress(address) === "undefined"){ | ||
@@ -426,4 +426,9 @@ /* istanbul ignore next */ | ||
}; | ||
return this.callMethod("avm.listAssets", params).then((response:RequestResponseData) => { | ||
return response.data["result"]["assets"]; | ||
return this.callMethod("avm.getAllBalances", params).then((response:RequestResponseData) => { | ||
let r = response.data["result"]["assets"]; | ||
let assetIDs = Object.keys(r); | ||
for(let i = 0; i < assetIDs.length; i++){ | ||
r[assetIDs[i]] = new BN(r[assetIDs[i]], 10); | ||
} | ||
return r; | ||
}); | ||
@@ -430,0 +435,0 @@ } |
@@ -89,5 +89,5 @@ import mockAxios from 'jest-mock-axios'; | ||
test('listAssets', async ()=>{ | ||
let assets = ['ATH','ETH']; | ||
let assets = {'ATH': new BN(1) ,'ETH': new BN(3)}; | ||
let result:Promise<Array<string>> = api.listAssets(addrA); | ||
let result:Promise<object> = api.getAllBalances(addrA); | ||
let payload:object = { | ||
@@ -103,3 +103,3 @@ "result": { | ||
mockAxios.mockResponse(responseObj); | ||
let response:Array<string> = await result; | ||
let response:object = await result; | ||
@@ -151,5 +151,5 @@ expect(mockAxios.request).toHaveBeenCalledTimes(1); | ||
test('getBalance', async ()=>{ | ||
let balance = 100; | ||
let balance = new BN("100", 10); | ||
let result:Promise<number> = api.getBalance(addrA, 'ATH'); | ||
let result:Promise<BN> = api.getBalance(addrA, 'ATH'); | ||
let payload:object = { | ||
@@ -165,3 +165,3 @@ "result": { | ||
mockAxios.mockResponse(responseObj); | ||
let response:number = await result; | ||
let response:BN = await result; | ||
@@ -168,0 +168,0 @@ expect(mockAxios.request).toHaveBeenCalledTimes(1); |
@@ -105,5 +105,5 @@ /** | ||
* | ||
* @returns Promise with the balance of the assetID on the provided address for the blockchain. | ||
* @returns Promise with the balance of the assetID as a {@link https://github.com/indutny/bn.js/|BN} on the provided address for the blockchain. | ||
*/ | ||
getBalance: (address: string, assetID: string) => Promise<number>; | ||
getBalance: (address: string, assetID: string) => Promise<BN>; | ||
/** | ||
@@ -228,9 +228,9 @@ * Creates an address (and associated private keys) on a user on a blockchain. | ||
/** | ||
* Lists all assets for an address. | ||
* Retrieves all assets for an address on a server and their associated balances. | ||
* | ||
* @param address The address to get a list of assets | ||
* | ||
* @returns Promise of an array of assetIDs for the address on the blockchain. | ||
* @returns Promise of an array of objects mapping assetID strings with {@link https://github.com/indutny/bn.js/|BN} balance for the address on the blockchain. | ||
*/ | ||
listAssets: (address: string) => Promise<string[]>; | ||
getAllBalances: (address: string) => Promise<object>; | ||
/** | ||
@@ -237,0 +237,0 @@ * Retrieves an assets name and symbol. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9895908
16707