@web3auth/metamask-adapter
Advanced tools
Comparing version 3.0.0 to 3.0.4
@@ -105,5 +105,3 @@ /******/ (() => { // webpackBootstrap | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = getPrototypeOf_default()(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -113,30 +111,16 @@ | ||
var MetamaskAdapter = /*#__PURE__*/function (_BaseEvmAdapter) { | ||
inherits_default()(MetamaskAdapter, _BaseEvmAdapter); | ||
var _super = _createSuper(MetamaskAdapter); | ||
function MetamaskAdapter(adapterOptions) { | ||
var _this; | ||
classCallCheck_default()(this, MetamaskAdapter); | ||
_this = _super.call(this, adapterOptions); | ||
defineProperty_default()(assertThisInitialized_default()(_this), "adapterNamespace", base_namespaceObject.ADAPTER_NAMESPACES.EIP155); | ||
defineProperty_default()(assertThisInitialized_default()(_this), "currentChainNamespace", base_namespaceObject.CHAIN_NAMESPACES.EIP155); | ||
defineProperty_default()(assertThisInitialized_default()(_this), "type", base_namespaceObject.ADAPTER_CATEGORY.EXTERNAL); | ||
defineProperty_default()(assertThisInitialized_default()(_this), "name", base_namespaceObject.WALLET_ADAPTERS.METAMASK); | ||
defineProperty_default()(assertThisInitialized_default()(_this), "status", base_namespaceObject.ADAPTER_STATUS.NOT_READY); | ||
defineProperty_default()(assertThisInitialized_default()(_this), "rehydrated", false); | ||
defineProperty_default()(assertThisInitialized_default()(_this), "metamaskProvider", null); | ||
_this.chainConfig = (adapterOptions === null || adapterOptions === void 0 ? void 0 : adapterOptions.chainConfig) || null; | ||
@@ -146,3 +130,2 @@ _this.sessionTime = (adapterOptions === null || adapterOptions === void 0 ? void 0 : adapterOptions.sessionTime) || 86400; | ||
} | ||
createClass_default()(MetamaskAdapter, [{ | ||
@@ -154,3 +137,2 @@ key: "provider", | ||
} | ||
return null; | ||
@@ -170,3 +152,2 @@ }, | ||
get_default()(getPrototypeOf_default()(MetamaskAdapter.prototype), "checkInitializationRequirements", this).call(this); | ||
_context.next = 3; | ||
@@ -176,6 +157,4 @@ return detect_provider_default()({ | ||
}); | ||
case 3: | ||
this.metamaskProvider = _context.sent; | ||
if (this.metamaskProvider) { | ||
@@ -185,5 +164,3 @@ _context.next = 6; | ||
} | ||
throw base_namespaceObject.WalletInitializationError.notInstalled("Metamask extension is not installed"); | ||
case 6: | ||
@@ -194,3 +171,2 @@ this.status = base_namespaceObject.ADAPTER_STATUS.READY; | ||
base_namespaceObject.log.debug("initializing metamask adapter"); | ||
if (!options.autoConnect) { | ||
@@ -200,11 +176,8 @@ _context.next = 14; | ||
} | ||
this.rehydrated = true; | ||
_context.next = 14; | ||
return this.connect(); | ||
case 14: | ||
_context.next = 19; | ||
break; | ||
case 16: | ||
@@ -214,3 +187,2 @@ _context.prev = 16; | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.ERRORED, _context.t0); | ||
case 19: | ||
@@ -223,7 +195,5 @@ case "end": | ||
})); | ||
function init(_x) { | ||
return _init.apply(this, arguments); | ||
} | ||
return init; | ||
@@ -235,7 +205,5 @@ }() | ||
if (this.status === base_namespaceObject.ADAPTER_STATUS.READY) return; | ||
if (options !== null && options !== void 0 && options.sessionTime) { | ||
this.sessionTime = options.sessionTime; | ||
} | ||
if (options !== null && options !== void 0 && options.clientId) { | ||
@@ -250,3 +218,2 @@ this.clientId = options.clientId; | ||
var _this2 = this; | ||
var chainId; | ||
@@ -257,5 +224,4 @@ return regenerator_default().wrap(function _callee2$(_context2) { | ||
case 0: | ||
get_default()(getPrototypeOf_default()(MetamaskAdapter.prototype), "checkConnectionRequirements", this).call(this); // set default to mainnet | ||
get_default()(getPrototypeOf_default()(MetamaskAdapter.prototype), "checkConnectionRequirements", this).call(this); | ||
// set default to mainnet | ||
if (!this.chainConfig) this.chainConfig = (0,base_namespaceObject.getChainConfig)(base_namespaceObject.CHAIN_NAMESPACES.EIP155, 1); | ||
@@ -266,3 +232,2 @@ this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTING; | ||
}); | ||
if (this.metamaskProvider) { | ||
@@ -272,5 +237,3 @@ _context2.next = 6; | ||
} | ||
throw base_namespaceObject.WalletLoginError.notConnectedError("Not able to connect with metamask"); | ||
case 6: | ||
@@ -282,6 +245,4 @@ _context2.prev = 6; | ||
}); | ||
case 9: | ||
chainId = this.metamaskProvider.chainId; | ||
if (!(chainId !== this.chainConfig.chainId)) { | ||
@@ -291,9 +252,6 @@ _context2.next = 13; | ||
} | ||
_context2.next = 13; | ||
return this.switchChain(this.chainConfig); | ||
case 13: | ||
this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTED; | ||
if (this.provider) { | ||
@@ -303,5 +261,3 @@ _context2.next = 16; | ||
} | ||
throw base_namespaceObject.WalletLoginError.notConnectedError("Failed to connect with provider"); | ||
case 16: | ||
@@ -317,3 +273,2 @@ this.provider.once("disconnect", function () { | ||
return _context2.abrupt("return", this.provider); | ||
case 21: | ||
@@ -327,3 +282,2 @@ _context2.prev = 21; | ||
throw base_namespaceObject.WalletLoginError.connectionError("Failed to login with metamask wallet"); | ||
case 27: | ||
@@ -336,7 +290,5 @@ case "end": | ||
})); | ||
function connect() { | ||
return _connect.apply(this, arguments); | ||
} | ||
return connect; | ||
@@ -349,5 +301,4 @@ }() | ||
var _this$provider; | ||
var options, | ||
_args3 = arguments; | ||
_args3 = arguments; | ||
return regenerator_default().wrap(function _callee3$(_context3) { | ||
@@ -362,6 +313,4 @@ while (1) { | ||
return get_default()(getPrototypeOf_default()(MetamaskAdapter.prototype), "disconnect", this).call(this); | ||
case 3: | ||
(_this$provider = this.provider) === null || _this$provider === void 0 ? void 0 : _this$provider.removeAllListeners(); | ||
if (options.cleanup) { | ||
@@ -374,6 +323,4 @@ this.status = base_namespaceObject.ADAPTER_STATUS.NOT_READY; | ||
} | ||
this.rehydrated = false; | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.DISCONNECTED); | ||
case 7: | ||
@@ -386,7 +333,5 @@ case "end": | ||
})); | ||
function disconnect() { | ||
return _disconnect.apply(this, arguments); | ||
} | ||
return disconnect; | ||
@@ -406,8 +351,5 @@ }() | ||
} | ||
throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet, Please login/connect first"); | ||
case 2: | ||
return _context4.abrupt("return", {}); | ||
case 3: | ||
@@ -420,7 +362,5 @@ case "end": | ||
})); | ||
function getUserInfo() { | ||
return _getUserInfo.apply(this, arguments); | ||
} | ||
return getUserInfo; | ||
@@ -440,5 +380,3 @@ }() | ||
} | ||
throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet"); | ||
case 2: | ||
@@ -453,11 +391,8 @@ _context5.prev = 2; | ||
}); | ||
case 5: | ||
_context5.next = 15; | ||
break; | ||
case 7: | ||
_context5.prev = 7; | ||
_context5.t0 = _context5["catch"](2); | ||
if (!(_context5.t0.code === 4902)) { | ||
@@ -467,3 +402,2 @@ _context5.next = 14; | ||
} | ||
_context5.next = 12; | ||
@@ -478,10 +412,7 @@ return this.metamaskProvider.request({ | ||
}); | ||
case 12: | ||
_context5.next = 15; | ||
break; | ||
case 14: | ||
throw _context5.t0; | ||
case 15: | ||
@@ -494,15 +425,11 @@ case "end": | ||
})); | ||
function switchChain(_x2) { | ||
return _switchChain.apply(this, arguments); | ||
} | ||
return switchChain; | ||
}() | ||
}]); | ||
return MetamaskAdapter; | ||
}(base_evm_adapter_namespaceObject.BaseEvmAdapter); | ||
;// CONCATENATED MODULE: ./src/index.ts | ||
@@ -509,0 +436,0 @@ |
@@ -16,31 +16,17 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var MetamaskAdapter = /*#__PURE__*/function (_BaseEvmAdapter) { | ||
_inherits(MetamaskAdapter, _BaseEvmAdapter); | ||
var _super = _createSuper(MetamaskAdapter); | ||
function MetamaskAdapter(adapterOptions) { | ||
var _this; | ||
_classCallCheck(this, MetamaskAdapter); | ||
_this = _super.call(this, adapterOptions); | ||
_defineProperty(_assertThisInitialized(_this), "adapterNamespace", ADAPTER_NAMESPACES.EIP155); | ||
_defineProperty(_assertThisInitialized(_this), "currentChainNamespace", CHAIN_NAMESPACES.EIP155); | ||
_defineProperty(_assertThisInitialized(_this), "type", ADAPTER_CATEGORY.EXTERNAL); | ||
_defineProperty(_assertThisInitialized(_this), "name", WALLET_ADAPTERS.METAMASK); | ||
_defineProperty(_assertThisInitialized(_this), "status", ADAPTER_STATUS.NOT_READY); | ||
_defineProperty(_assertThisInitialized(_this), "rehydrated", false); | ||
_defineProperty(_assertThisInitialized(_this), "metamaskProvider", null); | ||
_this.chainConfig = (adapterOptions === null || adapterOptions === void 0 ? void 0 : adapterOptions.chainConfig) || null; | ||
@@ -50,3 +36,2 @@ _this.sessionTime = (adapterOptions === null || adapterOptions === void 0 ? void 0 : adapterOptions.sessionTime) || 86400; | ||
} | ||
_createClass(MetamaskAdapter, [{ | ||
@@ -58,3 +43,2 @@ key: "provider", | ||
} | ||
return null; | ||
@@ -74,3 +58,2 @@ }, | ||
_get(_getPrototypeOf(MetamaskAdapter.prototype), "checkInitializationRequirements", this).call(this); | ||
_context.next = 3; | ||
@@ -80,6 +63,4 @@ return detectEthereumProvider({ | ||
}); | ||
case 3: | ||
this.metamaskProvider = _context.sent; | ||
if (this.metamaskProvider) { | ||
@@ -89,5 +70,3 @@ _context.next = 6; | ||
} | ||
throw WalletInitializationError.notInstalled("Metamask extension is not installed"); | ||
case 6: | ||
@@ -98,3 +77,2 @@ this.status = ADAPTER_STATUS.READY; | ||
log.debug("initializing metamask adapter"); | ||
if (!options.autoConnect) { | ||
@@ -104,11 +82,8 @@ _context.next = 14; | ||
} | ||
this.rehydrated = true; | ||
_context.next = 14; | ||
return this.connect(); | ||
case 14: | ||
_context.next = 19; | ||
break; | ||
case 16: | ||
@@ -118,3 +93,2 @@ _context.prev = 16; | ||
this.emit(ADAPTER_EVENTS.ERRORED, _context.t0); | ||
case 19: | ||
@@ -127,7 +101,5 @@ case "end": | ||
})); | ||
function init(_x) { | ||
return _init.apply(this, arguments); | ||
} | ||
return init; | ||
@@ -139,7 +111,5 @@ }() | ||
if (this.status === ADAPTER_STATUS.READY) return; | ||
if (options !== null && options !== void 0 && options.sessionTime) { | ||
this.sessionTime = options.sessionTime; | ||
} | ||
if (options !== null && options !== void 0 && options.clientId) { | ||
@@ -154,3 +124,2 @@ this.clientId = options.clientId; | ||
var _this2 = this; | ||
var chainId; | ||
@@ -161,5 +130,4 @@ return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
case 0: | ||
_get(_getPrototypeOf(MetamaskAdapter.prototype), "checkConnectionRequirements", this).call(this); // set default to mainnet | ||
_get(_getPrototypeOf(MetamaskAdapter.prototype), "checkConnectionRequirements", this).call(this); | ||
// set default to mainnet | ||
if (!this.chainConfig) this.chainConfig = getChainConfig(CHAIN_NAMESPACES.EIP155, 1); | ||
@@ -170,3 +138,2 @@ this.status = ADAPTER_STATUS.CONNECTING; | ||
}); | ||
if (this.metamaskProvider) { | ||
@@ -176,5 +143,3 @@ _context2.next = 6; | ||
} | ||
throw WalletLoginError.notConnectedError("Not able to connect with metamask"); | ||
case 6: | ||
@@ -186,6 +151,4 @@ _context2.prev = 6; | ||
}); | ||
case 9: | ||
chainId = this.metamaskProvider.chainId; | ||
if (!(chainId !== this.chainConfig.chainId)) { | ||
@@ -195,9 +158,6 @@ _context2.next = 13; | ||
} | ||
_context2.next = 13; | ||
return this.switchChain(this.chainConfig); | ||
case 13: | ||
this.status = ADAPTER_STATUS.CONNECTED; | ||
if (this.provider) { | ||
@@ -207,5 +167,3 @@ _context2.next = 16; | ||
} | ||
throw WalletLoginError.notConnectedError("Failed to connect with provider"); | ||
case 16: | ||
@@ -221,3 +179,2 @@ this.provider.once("disconnect", function () { | ||
return _context2.abrupt("return", this.provider); | ||
case 21: | ||
@@ -231,3 +188,2 @@ _context2.prev = 21; | ||
throw WalletLoginError.connectionError("Failed to login with metamask wallet"); | ||
case 27: | ||
@@ -240,7 +196,5 @@ case "end": | ||
})); | ||
function connect() { | ||
return _connect.apply(this, arguments); | ||
} | ||
return connect; | ||
@@ -253,5 +207,4 @@ }() | ||
var _this$provider; | ||
var options, | ||
_args3 = arguments; | ||
_args3 = arguments; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
@@ -266,6 +219,4 @@ while (1) { | ||
return _get(_getPrototypeOf(MetamaskAdapter.prototype), "disconnect", this).call(this); | ||
case 3: | ||
(_this$provider = this.provider) === null || _this$provider === void 0 ? void 0 : _this$provider.removeAllListeners(); | ||
if (options.cleanup) { | ||
@@ -278,6 +229,4 @@ this.status = ADAPTER_STATUS.NOT_READY; | ||
} | ||
this.rehydrated = false; | ||
this.emit(ADAPTER_EVENTS.DISCONNECTED); | ||
case 7: | ||
@@ -290,7 +239,5 @@ case "end": | ||
})); | ||
function disconnect() { | ||
return _disconnect.apply(this, arguments); | ||
} | ||
return disconnect; | ||
@@ -310,8 +257,5 @@ }() | ||
} | ||
throw WalletLoginError.notConnectedError("Not connected with wallet, Please login/connect first"); | ||
case 2: | ||
return _context4.abrupt("return", {}); | ||
case 3: | ||
@@ -324,7 +268,5 @@ case "end": | ||
})); | ||
function getUserInfo() { | ||
return _getUserInfo.apply(this, arguments); | ||
} | ||
return getUserInfo; | ||
@@ -344,5 +286,3 @@ }() | ||
} | ||
throw WalletLoginError.notConnectedError("Not connected with wallet"); | ||
case 2: | ||
@@ -357,11 +297,8 @@ _context5.prev = 2; | ||
}); | ||
case 5: | ||
_context5.next = 15; | ||
break; | ||
case 7: | ||
_context5.prev = 7; | ||
_context5.t0 = _context5["catch"](2); | ||
if (!(_context5.t0.code === 4902)) { | ||
@@ -371,3 +308,2 @@ _context5.next = 14; | ||
} | ||
_context5.next = 12; | ||
@@ -382,10 +318,7 @@ return this.metamaskProvider.request({ | ||
}); | ||
case 12: | ||
_context5.next = 15; | ||
break; | ||
case 14: | ||
throw _context5.t0; | ||
case 15: | ||
@@ -398,11 +331,8 @@ case "end": | ||
})); | ||
function switchChain(_x2) { | ||
return _switchChain.apply(this, arguments); | ||
} | ||
return switchChain; | ||
}() | ||
}]); | ||
return MetamaskAdapter; | ||
@@ -409,0 +339,0 @@ }(BaseEvmAdapter); |
{ | ||
"name": "@web3auth/metamask-adapter", | ||
"version": "3.0.0", | ||
"version": "3.0.4", | ||
"description": "metamask wallet adapter for web3auth", | ||
@@ -39,4 +39,4 @@ "keywords": [ | ||
"@metamask/detect-provider": "^2.0.0", | ||
"@web3auth/base": "^3.0.0", | ||
"@web3auth/base-evm-adapter": "^3.0.0" | ||
"@web3auth/base": "^3.0.4", | ||
"@web3auth/base-evm-adapter": "^3.0.4" | ||
}, | ||
@@ -59,3 +59,3 @@ "lint-staged": { | ||
}, | ||
"gitHead": "8716a03717f1ef663252c92816c97a42ef1b2d3a" | ||
"gitHead": "791717d94e9926e309dbaa0f61efc402e71238ef" | ||
} |
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 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
865806
1440
Updated@web3auth/base@^3.0.4