diff --git a/Safari Shared/Resources/inpage.js b/Safari Shared/Resources/inpage.js index 689309bc..f068af6c 100644 --- a/Safari Shared/Resources/inpage.js +++ b/Safari Shared/Resources/inpage.js @@ -22,5 +22,5 @@ var t=arguments[3],r=require("base64-js"),e=require("ieee754"),n=require("isarra },{}],"ZwKf":[function(require,module,exports) { "use strict";function e(e){if(!e)return!1;for(var r=0,t=e.length;r=194&&e[r]<=223){if(e[r+1]>>6==2){r+=2;continue}return!1}if((224===e[r]&&e[r+1]>=160&&e[r+1]<=191||237===e[r]&&e[r+1]>=128&&e[r+1]<=159)&&e[r+2]>>6==2)r+=3;else if((e[r]>=225&&e[r]<=236||e[r]>=238&&e[r]<=239)&&e[r+1]>>6==2&&e[r+2]>>6==2)r+=3;else{if(!(240===e[r]&&e[r+1]>=144&&e[r+1]<=191||e[r]>=241&&e[r]<=243&&e[r+1]>>6==2||244===e[r]&&e[r+1]>=128&&e[r+1]<=143)||e[r+2]>>6!=2||e[r+3]>>6!=2)return!1;r+=4}}return!0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var r=e;exports.default=r; },{}],"Focm":[function(require,module,exports) { -"use strict";var _rpc=_interopRequireDefault(require("./rpc")),_error=_interopRequireDefault(require("./error")),_utils=_interopRequireDefault(require("./utils")),_id_mapping=_interopRequireDefault(require("./id_mapping")),_events=require("events"),_isutf=_interopRequireDefault(require("isutf8"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n1&&void 0!==arguments[1])||arguments[1];return this.idMapping.tryIntifyId(e),new Promise(function(r,s){switch(e.id||(e.id=_utils.default.genId()),t.callbacks.set(e.id,function(e,t){e?s(e):r(t)}),t.wrapResults.set(e.id,n),e.method){case"eth_accounts":return t.sendResponse(e.id,t.eth_accounts());case"eth_coinbase":return t.sendResponse(e.id,t.eth_coinbase());case"net_version":return t.sendResponse(e.id,t.net_version());case"eth_chainId":return t.sendResponse(e.id,t.eth_chainId());case"eth_sign":return t.eth_sign(e);case"personal_sign":return t.personal_sign(e);case"personal_ecRecover":return t.personal_ecRecover(e);case"eth_signTypedData_v3":return t.eth_signTypedData(e,!1);case"eth_signTypedData":case"eth_signTypedData_v4":return t.eth_signTypedData(e,!0);case"eth_sendTransaction":return t.eth_sendTransaction(e);case"eth_requestAccounts":return t.eth_requestAccounts(e);case"wallet_addEthereumChain":return t.wallet_addEthereumChain(e);case"wallet_switchEthereumChain":return t.wallet_switchEthereumChain(e);case"wallet_watchAsset":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error.default(4200,"Tokenary does not support calling ".concat(e.method,". Please use your own solution"));default:return t.callbacks.delete(e.id),t.wrapResults.delete(e.id),t.rpc.call(e).then(function(e){r(n?e:e.result)}).catch(s)}})}},{key:"emitConnect",value:function(e){this.emit("connect",{chainId:e})}},{key:"eth_accounts",value:function(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function(){return this.address}},{key:"net_version",value:function(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function(){return this.chainId}},{key:"eth_sign",value:function(e){var t=_utils.default.messageToBuffer(e.params[1]),n=_utils.default.bufferToHex(t);(0,_isutf.default)(t)?this.postMessage("signPersonalMessage",e.id,{data:n}):this.postMessage("signMessage",e.id,{data:n})}},{key:"personal_sign",value:function(e){var t=e.params[0];if(0===_utils.default.messageToBuffer(t).length){var n=_utils.default.bufferToHex(t);this.postMessage("signPersonalMessage",e.id,{data:n})}else this.postMessage("signPersonalMessage",e.id,{data:t})}},{key:"personal_ecRecover",value:function(e){this.postMessage("ecRecover",e.id,{signature:e.params[1],message:e.params[0]})}},{key:"eth_signTypedData",value:function(e,t){this.postMessage("signTypedMessage",e.id,{raw:e.params[1]})}},{key:"eth_sendTransaction",value:function(e){this.postMessage("signTransaction",e.id,e.params[0])}},{key:"eth_requestAccounts",value:function(e){this.postMessage("requestAccounts",e.id,{})}},{key:"wallet_watchAsset",value:function(e){var t=e.params.options;this.postMessage("watchAsset",e.id,{type:e.type,contract:t.address,symbol:t.symbol,decimals:t.decimals||0})}},{key:"wallet_switchEthereumChain",value:function(e){this.chainId!=e.params[0].chainId&&this.postMessage("switchEthereumChain",e.id,e.params[0])}},{key:"wallet_addEthereumChain",value:function(e){this.postMessage("addEthereumChain",e.id,e.params[0])}},{key:"postMessage",value:function(e,t,n){if(this.ready||"requestAccounts"===e){var r={id:t,name:e,object:n,address:this.address,networkId:this.net_version(),host:window.location.host};window.tokenary.postMessage?window.tokenary.postMessage(r):window.webkit.messageHandlers[e].postMessage(r)}else this.sendError(t,new _error.default(4100,"provider is not ready"))}},{key:"sendResponse",value:function(e,t){var n=this.idMapping.tryPopId(e)||e,r=this.callbacks.get(e),s=this.wrapResults.get(e),a={jsonrpc:"2.0",id:n};if("object"===_typeof(t)&&t.jsonrpc&&t.result?a.result=t.result:a.result=t,r)r(null,s?a:t),this.callbacks.delete(e);else{console.log("callback id: ".concat(e," not found"));for(var o=0;o1&&void 0!==arguments[1])||arguments[1];return this.idMapping.tryIntifyId(e),new Promise(function(r,s){switch(e.id||(e.id=_utils.default.genId()),t.callbacks.set(e.id,function(e,t){e?s(e):r(t)}),t.wrapResults.set(e.id,n),e.method){case"eth_accounts":return t.sendResponse(e.id,t.eth_accounts());case"eth_coinbase":return t.sendResponse(e.id,t.eth_coinbase());case"net_version":return t.sendResponse(e.id,t.net_version());case"eth_chainId":return t.sendResponse(e.id,t.eth_chainId());case"eth_sign":return t.eth_sign(e);case"personal_sign":return t.personal_sign(e);case"personal_ecRecover":return t.personal_ecRecover(e);case"eth_signTypedData_v3":return t.eth_signTypedData(e,!1);case"eth_signTypedData":case"eth_signTypedData_v4":return t.eth_signTypedData(e,!0);case"eth_sendTransaction":return t.eth_sendTransaction(e);case"eth_requestAccounts":return t.eth_requestAccounts(e);case"wallet_addEthereumChain":return t.wallet_addEthereumChain(e);case"wallet_switchEthereumChain":return t.wallet_switchEthereumChain(e);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error.default(4200,"Tokenary does not support calling ".concat(e.method,". Please use your own solution"));default:return t.callbacks.delete(e.id),t.wrapResults.delete(e.id),t.rpc.call(e).then(function(e){r(n?e:e.result)}).catch(s)}})}},{key:"emitConnect",value:function(e){this.emit("connect",{chainId:e})}},{key:"eth_accounts",value:function(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function(){return this.address}},{key:"net_version",value:function(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function(){return this.chainId}},{key:"eth_sign",value:function(e){var t=_utils.default.messageToBuffer(e.params[1]),n=_utils.default.bufferToHex(t);(0,_isutf.default)(t)?this.postMessage("signPersonalMessage",e.id,{data:n}):this.postMessage("signMessage",e.id,{data:n})}},{key:"personal_sign",value:function(e){var t=e.params[0];if(0===_utils.default.messageToBuffer(t).length){var n=_utils.default.bufferToHex(t);this.postMessage("signPersonalMessage",e.id,{data:n})}else this.postMessage("signPersonalMessage",e.id,{data:t})}},{key:"personal_ecRecover",value:function(e){this.postMessage("ecRecover",e.id,{signature:e.params[1],message:e.params[0]})}},{key:"eth_signTypedData",value:function(e,t){this.postMessage("signTypedMessage",e.id,{raw:e.params[1]})}},{key:"eth_sendTransaction",value:function(e){this.postMessage("signTransaction",e.id,e.params[0])}},{key:"eth_requestAccounts",value:function(e){this.postMessage("requestAccounts",e.id,{})}},{key:"wallet_watchAsset",value:function(e){var t=e.params.options;this.postMessage("watchAsset",e.id,{type:e.type,contract:t.address,symbol:t.symbol,decimals:t.decimals||0})}},{key:"wallet_switchEthereumChain",value:function(e){this.chainId!=e.params[0].chainId&&this.postMessage("switchEthereumChain",e.id,e.params[0])}},{key:"wallet_addEthereumChain",value:function(e){this.postMessage("addEthereumChain",e.id,e.params[0])}},{key:"postMessage",value:function(e,t,n){if(this.ready||"requestAccounts"===e){var r={id:t,name:e,object:n,address:this.address,networkId:this.net_version(),host:window.location.host};window.tokenary.postMessage?window.tokenary.postMessage(r):window.webkit.messageHandlers[e].postMessage(r)}else this.sendError(t,new _error.default(4100,"provider is not ready"))}},{key:"sendResponse",value:function(e,t){var n=this.idMapping.tryPopId(e)||e,r=this.callbacks.get(e),s=this.wrapResults.get(e),a={jsonrpc:"2.0",id:n};if("object"===_typeof(t)&&t.jsonrpc&&t.result?a.result=t.result:a.result=t,r)r(null,s?a:t),this.callbacks.delete(e);else{console.log("callback id: ".concat(e," not found"));for(var o=0;o