diff --git a/package.json b/package.json index be14cf06214d827c598826aefea29a9cb37b76e0..f38dd2bcf1834e3b2ee316a7f90d99c9636315c1 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "debug": "^2.6.8", "detect-node": "^2.0.3", "ecurve": "^1.0.5", + "jsbi": "^3.1.4", "lodash": "^4.16.4", "retry": "^0.12.0", "secure-random": "^1.1.2", diff --git a/src/api/methods.js b/src/api/methods.js index 377a7195336b9fbaaa17f67583d34a62db79fd94..8997b4c9310526227d84a688d81a89c988fa98d7 100644 --- a/src/api/methods.js +++ b/src/api/methods.js @@ -214,6 +214,11 @@ export default [ "method": "get_account_history", "params": ["account", "from", "limit"] }, + { + "api": "database_api", + "method": "get_account_history", + "params": ["account", "from", "limit", "operation_filter_low", "operation_filter_high"], + }, { "api": "database_api", "method": "get_owner_history", diff --git a/src/api/transports/http.js b/src/api/transports/http.js index 9ce59e7830fd7c95c49f7979dea9f1c9ce088f7b..7a23b2dc0a62eb685ed615a9d643389ce430c17c 100644 --- a/src/api/transports/http.js +++ b/src/api/transports/http.js @@ -58,7 +58,19 @@ export default class HttpTransport extends Transport { } debug('Steem::send', api, data); const id = data.id || this.id++; - const params = [api, data.method, data.params]; + let params = [api, data.method, data.params]; + //SPECIAL CODE - can be removed after all API node operators upgrade to get the updated get_account_history api call + if (this.options.uri !== 'https://api.hive.blog' && data.method === 'get_account_history' && data.params.length >= 4) + { + //We are experimenting with a new version of get_account_history that can now take up to 5 params + //but this is only deployed on api.hive.blog nodes, so if this particular request is going to a different + //backend, just strip the extra parameters off the call to avoid breaking it. Once all API nodes have upgraded + //this code can be removed. + while (data.params.length > 3) + data.params.pop(); + params = [api, data.method, data.params]; + } + //END SPECIAL CODE const retriable = this.retriable(api, data); const fetchMethod = this.options.fetchMethod; if (retriable) { diff --git a/src/auth/serializer/index.js b/src/auth/serializer/index.js index 72bf10221191b6c020439e1094d396dddbfe69d0..b7dd671700072dc38ffded116db470a699911b3d 100644 --- a/src/auth/serializer/index.js +++ b/src/auth/serializer/index.js @@ -16,4 +16,8 @@ module.exports = { template: require('./src/template'), number_utils: require('./src/number_utils'), + + ChainTypes: require ('./src/ChainTypes'), + + makeBitMaskFilter: require('./src/makeBitMaskFilter'), } diff --git a/src/auth/serializer/src/ChainTypes.js b/src/auth/serializer/src/ChainTypes.js index 4bb77066c5696a6c5354d6d7a3e86e86d3b9bc26..d82fba8245666e93748af46798d9dcea0e2a0a99 100644 --- a/src/auth/serializer/src/ChainTypes.js +++ b/src/auth/serializer/src/ChainTypes.js @@ -1,6 +1,4 @@ -var ChainTypes; - -module.exports = ChainTypes = {}; +var ChainTypes = {}; ChainTypes.reserved_spaces = { relative_protocol_ids: 0, @@ -86,3 +84,5 @@ ChainTypes.object_type = { "null": 0, base: 1, }; + +module.exports = ChainTypes; diff --git a/src/auth/serializer/src/makeBitMaskFilter.js b/src/auth/serializer/src/makeBitMaskFilter.js new file mode 100644 index 0000000000000000000000000000000000000000..33aac6524bb50bd907cd12581e9f9341c3613377 --- /dev/null +++ b/src/auth/serializer/src/makeBitMaskFilter.js @@ -0,0 +1,9 @@ +import JSBI from 'jsbi'; + +let makeBitMaskFilter = (allowedOperations) => { + return allowedOperations.reduce(([low, high], allowedOperation) => allowedOperation < 64 ? [JSBI.bitwiseOr(low, JSBI.leftShift(JSBI.BigInt(1), JSBI.BigInt(allowedOperation))), high] + : [low, JSBI.bitwiseOr(high, JSBI.leftShift(JSBI.BigInt(1), JSBI.BigInt(allowedOperation-64)))], + [JSBI.BigInt(0), JSBI.BigInt(0)]).map(value => JSBI.notEqual(value, JSBI.BigInt(0)) ? value.toString() : null); +}; + +module.exports = makeBitMaskFilter; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 7e5e097c61649af2cfc3dcf2a5e21f3d6be944b7..92efaf1697f2e6991d4bd05654824e298fbfad49 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1997,6 +1997,11 @@ js-yaml@^3.5.1: argparse "^1.0.7" esprima "^4.0.0" +jsbi@^3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/jsbi/-/jsbi-3.1.4.tgz#9654dd02207a66a4911b4e4bb74265bc2cbc9dd0" + integrity sha512-52QRRFSsi9impURE8ZUbzAMCLjPm4THO7H2fcuIvaaeFTbSysvkodbQQXIVsNgq/ypDbq6dJiuGKL0vZ/i9hUg== + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"