@eth-sdk/utils
Advanced tools
Comparing version 0.1.4 to 0.1.5
import { IItemParam, IDecoded } from './interfaces'; | ||
export declare function decode<T = IDecoded>(params: IItemParam[], data: string): T; | ||
export declare function decode<T = IDecoded>(params: IItemParam[], data: string, indexed?: boolean): T; |
@@ -46,8 +46,10 @@ "use strict"; | ||
} | ||
function decode(params, data) { | ||
function decode(params, data, indexed = true) { | ||
let result = null; | ||
if (hex_1.isHex(data, 'data')) { | ||
result = { | ||
length: 0, | ||
}; | ||
result = indexed | ||
? { | ||
length: params.length, | ||
} | ||
: {}; | ||
data = data.slice(2); | ||
@@ -87,4 +89,6 @@ for (let i = 0; i < params.length; i += 1) { | ||
} | ||
result = Object.assign(Object.assign({}, result), { [name]: value, [i]: value }); | ||
result.length += 1; | ||
result = Object.assign(Object.assign({}, result), { [name]: value }); | ||
if (indexed) { | ||
result = Object.assign(Object.assign({}, result), { [i]: value }); | ||
} | ||
} | ||
@@ -91,0 +95,0 @@ } |
@@ -30,3 +30,3 @@ import { TType, TItemStateMutability, TItemType } from './types'; | ||
[key: number]: any; | ||
length: number; | ||
length?: number; | ||
} |
{ | ||
"name": "@eth-sdk/utils", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Eth sdk utils", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
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
67173
1075