scatterjs-plugin-eosjs
Advanced tools
Comparing version 1.3.9 to 1.3.10
@@ -1,4 +0,3 @@ | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_scatterjsCore=require("scatterjs-core"),proxy=function(a,b){return new Proxy(a,b)},ScatterEOS=/*#__PURE__*/function(a){function b(){return(0,_classCallCheck2.default)(this,b),(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(b).call(this,_scatterjsCore.Blockchains.EOS,_scatterjsCore.PluginTypes.BLOCKCHAIN_SUPPORT))}return(0,_inherits2.default)(b,a),(0,_createClass2.default)(b,[{key:"hookProvider",value:function hookProvider(a){return function(b){return new Promise(function(c,d){var e=Object.assign(b,{blockchain:_scatterjsCore.Blockchains.EOS,network:a,requiredFields:{}});_scatterjsCore.SocketService.sendApiRequest({type:"requestSignature",payload:e}).then(function(a){return c(a.signatures)}).catch(function(a){return d(a)})})}}},{key:"signatureProvider",value:function signatureProvider(){var a=0>=arguments.length?void 0:arguments[0];// Protocol will be deprecated. | ||
return function(b,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(b=_scatterjsCore.Network.fromJson(b),!b.isValid())throw Error.noNetwork();var e,f="".concat(b.protocol,"://").concat(b.hostport()),g=b.hasOwnProperty("chainId")&&b.chainId.length?b.chainId:d.chainId,h=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function a(b){return _regenerator.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",e(b));case 1:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}();return proxy(c({httpEndpoint:f,chainId:g,signProvider:h}),{get:function get(c,d){if("function"!=typeof c[d])return c[d];var f=null;return function(){for(var g=arguments.length,h=Array(g),i=0;i<g;i++)h[i]=arguments[i];if(h.find(function(a){return a.hasOwnProperty("keyProvider")}))throw Error.usedKeyProvider();var j=/*#__PURE__*/function(){var c=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function c(d){var e,g,i,j;return _regenerator.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return a(),e=h.find(function(a){return a.hasOwnProperty("requiredFields")})||{requiredFields:{}},g=Object.assign(d,{blockchain:_scatterjsCore.Blockchains.EOS,network:b,requiredFields:e.requiredFields}),c.next=5,_scatterjsCore.SocketService.sendApiRequest({type:"requestSignature",payload:g});case 5:if(i=c.sent,i){c.next=8;break}return c.abrupt("return",null);case 8:if(!i.hasOwnProperty("signatures")){c.next=13;break}return f=i.returnedFields,j=h.find(function(a){return a.hasOwnProperty("signProvider")}),j&&i.signatures.push(j.signProvider(d.buf,d.sign)),c.abrupt("return",i.signatures);case 13:return c.abrupt("return",i);case 14:case"end":return c.stop();}},c,this)}));return function(){return c.apply(this,arguments)}}();return e=j,new Promise(function(a){c[d].apply(c,h).then(function(b){return b.hasOwnProperty("fc")?void a(proxy(b,{get:function get(a,b){return"then"===b?a[b]:function(){for(var c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return new Promise(/*#__PURE__*/function(){var c=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function c(e,g){return _regenerator.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:a[b].apply(a,d).then(function(a){e(Object.assign(a,{returnedFields:f}))}).catch(g);case 1:case"end":return c.stop();}},c,this)}));return function(){return c.apply(this,arguments)}}())}}})):a(Object.assign(b,{returnedFields:f}));// This is a contract | ||
})})}}});// Proxy | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_scatterjsCore=require("scatterjs-core"),proxy=function(a,b){return new Proxy(a,b)},ScatterEOS=/*#__PURE__*/function(a){function b(){return(0,_classCallCheck2.default)(this,b),(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(b).call(this,_scatterjsCore.Blockchains.EOS,_scatterjsCore.PluginTypes.BLOCKCHAIN_SUPPORT))}return(0,_inherits2.default)(b,a),(0,_createClass2.default)(b,[{key:"hookProvider",value:function hookProvider(a){return function(b){return new Promise(function(c,d){var e=Object.assign(b,{blockchain:_scatterjsCore.Blockchains.EOS,network:a,requiredFields:{}});_scatterjsCore.SocketService.sendApiRequest({type:"requestSignature",payload:e}).then(function(a){return c(a.signatures)}).catch(function(a){return d(a)})})}}},{key:"signatureProvider",value:function signatureProvider(){var a=0>=arguments.length?void 0:arguments[0];return function(b,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(b=_scatterjsCore.Network.fromJson(b),!b.isValid())throw Error.noNetwork();var e,f=b.hasOwnProperty("chainId")&&b.chainId.length?b.chainId:d.chainId,g=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function a(b){return _regenerator.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",e(b));case 1:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}();return proxy(c({httpEndpoint:b.fullhost(),chainId:f,signProvider:g}),{get:function get(c,d){if("function"!=typeof c[d])return c[d];var f=null;return function(){for(var g=arguments.length,h=Array(g),i=0;i<g;i++)h[i]=arguments[i];if(h.find(function(a){return a.hasOwnProperty("keyProvider")}))throw Error.usedKeyProvider();return e=/*#__PURE__*/function(){var c=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function c(d){var e,g,i,j;return _regenerator.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return a(),e=h.find(function(a){return a.hasOwnProperty("requiredFields")})||{requiredFields:{}},g=Object.assign(d,{blockchain:_scatterjsCore.Blockchains.EOS,network:b,requiredFields:e.requiredFields}),c.next=5,_scatterjsCore.SocketService.sendApiRequest({type:"requestSignature",payload:g});case 5:if(i=c.sent,i){c.next=8;break}return c.abrupt("return",null);case 8:if(!i.hasOwnProperty("signatures")){c.next=13;break}return f=i.returnedFields,j=h.find(function(a){return a.hasOwnProperty("signProvider")}),j&&i.signatures.push(j.signProvider(d.buf,d.sign)),c.abrupt("return",i.signatures);case 13:return c.abrupt("return",i);case 14:case"end":return c.stop();}},c,this)}));return function(){return c.apply(this,arguments)}}(),new Promise(function(a,b){c[d].apply(c,h).then(function(b){return b.hasOwnProperty("fc")?void a(proxy(b,{get:function get(a,b){return"then"===b?a[b]:function(){for(var c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return new Promise(/*#__PURE__*/function(){var c=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function c(e,g){return _regenerator.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:a[b].apply(a,d).then(function(a){e(Object.assign(a,{returnedFields:f}))}).catch(g);case 1:case"end":return c.stop();}},c,this)}));return function(){return c.apply(this,arguments)}}())}}})):a(Object.assign(b,{returnedFields:f}));// This is a contract | ||
}).catch(b)})}}});// Proxy | ||
}}}]),b}(_scatterjsCore.Plugin);Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;exports.default=ScatterEOS,"undefined"!=typeof window&&(window.ScatterEOS=ScatterEOS); |
{ | ||
"name": "scatterjs-plugin-eosjs", | ||
"version": "1.3.9", | ||
"version": "1.3.10", | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"gitHead": "8dfda95ef60cded21b78b446cde9a9e00eb6cd58" | ||
"gitHead": "b148dc9f9993f059c2a8050f82c65abc7e64c1fd" | ||
} |
@@ -34,3 +34,2 @@ import { | ||
// Protocol will be deprecated. | ||
return (network, _eos, _options = {}) => { | ||
@@ -40,3 +39,2 @@ | ||
if(!network.isValid()) throw Error.noNetwork(); | ||
const httpEndpoint = `${network.protocol}://${network.hostport()}`; | ||
@@ -46,3 +44,3 @@ const chainId = network.hasOwnProperty('chainId') && network.chainId.length ? network.chainId : _options.chainId; | ||
let prov, proxyProvider = async (args) => prov(args); | ||
return proxy(_eos({httpEndpoint, chainId, signProvider:proxyProvider}), { | ||
return proxy(_eos({httpEndpoint:network.fullhost(), chainId, signProvider:proxyProvider}), { | ||
get(instance, method) { | ||
@@ -57,29 +55,25 @@ | ||
const signProvider = async signargs => { | ||
throwIfNoIdentity(); | ||
prov = async signargs => { | ||
throwIfNoIdentity(); | ||
const requiredFields = args.find(arg => arg.hasOwnProperty('requiredFields')) || {requiredFields:{}}; | ||
const payload = Object.assign(signargs, { blockchain:Blockchains.EOS, network, requiredFields:requiredFields.requiredFields }); | ||
const result = await SocketService.sendApiRequest({ type:'requestSignature', payload }); | ||
const requiredFields = args.find(arg => arg.hasOwnProperty('requiredFields')) || {requiredFields:{}}; | ||
const payload = Object.assign(signargs, { blockchain:Blockchains.EOS, network, requiredFields:requiredFields.requiredFields }); | ||
const result = await SocketService.sendApiRequest({ type:'requestSignature', payload }); | ||
// No signature | ||
if(!result) return null; | ||
// No signature | ||
if(!result) return null; | ||
if(result.hasOwnProperty('signatures')){ | ||
returnedFields = result.returnedFields; | ||
let multiSigKeyProvider = args.find(arg => arg.hasOwnProperty('signProvider')); | ||
if(multiSigKeyProvider) result.signatures.push(multiSigKeyProvider.signProvider(signargs.buf, signargs.sign)); | ||
return result.signatures; | ||
} | ||
if(result.hasOwnProperty('signatures')){ | ||
returnedFields = result.returnedFields; | ||
let multiSigKeyProvider = args.find(arg => arg.hasOwnProperty('signProvider')); | ||
if(multiSigKeyProvider) result.signatures.push(multiSigKeyProvider.signProvider(signargs.buf, signargs.sign)); | ||
return result.signatures; | ||
} | ||
return result; | ||
}; | ||
return result; | ||
};; | ||
prov = signProvider; | ||
return new Promise((resolve, reject) => { | ||
instance[method](...args).then(result => { | ||
if(!result.hasOwnProperty('fc')){ | ||
return resolve(Object.assign(result, {returnedFields})); | ||
} | ||
if(!result.hasOwnProperty('fc')) return resolve(Object.assign(result, {returnedFields})); | ||
@@ -99,7 +93,5 @@ // This is a contract | ||
})); | ||
}) | ||
}).catch(reject); | ||
}) | ||
} | ||
} | ||
@@ -106,0 +98,0 @@ }); // Proxy |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
9804
96