@wagmi/core 0.2.0-next.6 → 0.2.0-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.d.ts +11 -1
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.js +15 -6
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.d.ts +11 -1
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.js +15 -6
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.d.ts +11 -1
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.js +15 -6
- package/dist/wagmi-core.cjs.d.ts +11 -1
- package/dist/wagmi-core.cjs.js +15 -6
- package/package.json +2 -3
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +0 -253
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +0 -253
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +0 -231
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +0 -304
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +0 -304
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +0 -295
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +0 -215
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +0 -215
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +0 -193
- package/dist/base-09a653f3.cjs.dev.js +0 -453
- package/dist/base-824c3b6d.esm.js +0 -430
- package/dist/base-d8123d5f.cjs.prod.js +0 -453
- package/dist/classPrivateMethodGet-0e9a7925.cjs.prod.js +0 -19
- package/dist/classPrivateMethodGet-38b54c7a.cjs.dev.js +0 -19
- package/dist/classPrivateMethodGet-c9db96d6.esm.js +0 -16
- package/dist/declarations/src/actions/accounts/connect.d.ts +0 -7
- package/dist/declarations/src/actions/accounts/disconnect.d.ts +0 -1
- package/dist/declarations/src/actions/accounts/fetchBalance.d.ts +0 -18
- package/dist/declarations/src/actions/accounts/fetchSigner.d.ts +0 -3
- package/dist/declarations/src/actions/accounts/getAccount.d.ts +0 -6
- package/dist/declarations/src/actions/accounts/getNetwork.d.ts +0 -9
- package/dist/declarations/src/actions/accounts/index.d.ts +0 -13
- package/dist/declarations/src/actions/accounts/signMessage.d.ts +0 -9
- package/dist/declarations/src/actions/accounts/signTypedData.d.ts +0 -13
- package/dist/declarations/src/actions/accounts/switchNetwork.d.ts +0 -6
- package/dist/declarations/src/actions/accounts/watchAccount.d.ts +0 -3
- package/dist/declarations/src/actions/accounts/watchBalance.d.ts +0 -3
- package/dist/declarations/src/actions/accounts/watchNetwork.d.ts +0 -3
- package/dist/declarations/src/actions/accounts/watchSigner.d.ts +0 -3
- package/dist/declarations/src/actions/contracts/getContract.d.ts +0 -11
- package/dist/declarations/src/actions/contracts/index.d.ts +0 -5
- package/dist/declarations/src/actions/contracts/readContract.d.ts +0 -11
- package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +0 -12
- package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +0 -7
- package/dist/declarations/src/actions/contracts/writeContract.d.ts +0 -11
- package/dist/declarations/src/actions/ens/fetchEnsAddress.d.ts +0 -6
- package/dist/declarations/src/actions/ens/fetchEnsAvatar.d.ts +0 -6
- package/dist/declarations/src/actions/ens/fetchEnsName.d.ts +0 -6
- package/dist/declarations/src/actions/ens/fetchEnsResolver.d.ts +0 -7
- package/dist/declarations/src/actions/ens/index.d.ts +0 -8
- package/dist/declarations/src/actions/ens/watchEnsAddress.d.ts +0 -3
- package/dist/declarations/src/actions/ens/watchEnsAvatar.d.ts +0 -3
- package/dist/declarations/src/actions/ens/watchEnsName.d.ts +0 -3
- package/dist/declarations/src/actions/ens/watchEnsResolver.d.ts +0 -3
- package/dist/declarations/src/actions/index.d.ts +0 -7
- package/dist/declarations/src/actions/network-status/fetchBlockNumber.d.ts +0 -2
- package/dist/declarations/src/actions/network-status/fetchFeeData.d.ts +0 -14
- package/dist/declarations/src/actions/network-status/index.d.ts +0 -4
- package/dist/declarations/src/actions/network-status/watchBlockNumber.d.ts +0 -6
- package/dist/declarations/src/actions/network-status/watchFeeData.d.ts +0 -7
- package/dist/declarations/src/actions/providers/getProvider.d.ts +0 -3
- package/dist/declarations/src/actions/providers/getWebSocketProvider.d.ts +0 -3
- package/dist/declarations/src/actions/providers/index.d.ts +0 -4
- package/dist/declarations/src/actions/providers/watchProvider.d.ts +0 -3
- package/dist/declarations/src/actions/providers/watchWebSocketProvider.d.ts +0 -3
- package/dist/declarations/src/actions/tokens/fetchToken.d.ts +0 -24
- package/dist/declarations/src/actions/tokens/index.d.ts +0 -2
- package/dist/declarations/src/actions/tokens/watchToken.d.ts +0 -3
- package/dist/declarations/src/actions/transactions/index.d.ts +0 -2
- package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +0 -7
- package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +0 -15
- package/dist/declarations/src/client.d.ts +0 -80
- package/dist/declarations/src/connectors/base.d.ts +0 -51
- package/dist/declarations/src/connectors/coinbaseWallet.d.ts +0 -43
- package/dist/declarations/src/connectors/index.d.ts +0 -2
- package/dist/declarations/src/connectors/injected.d.ts +0 -55
- package/dist/declarations/src/connectors/mock/connector.d.ts +0 -37
- package/dist/declarations/src/connectors/mock/index.d.ts +0 -2
- package/dist/declarations/src/connectors/mock/provider.d.ts +0 -40
- package/dist/declarations/src/connectors/walletConnect.d.ts +0 -32
- package/dist/declarations/src/constants/abis/erc1155.d.ts +0 -17
- package/dist/declarations/src/constants/abis/erc20.d.ts +0 -38
- package/dist/declarations/src/constants/abis/erc721.d.ts +0 -15
- package/dist/declarations/src/constants/abis/index.d.ts +0 -3
- package/dist/declarations/src/constants/chains.d.ts +0 -10
- package/dist/declarations/src/constants/index.d.ts +0 -3
- package/dist/declarations/src/constants/units.d.ts +0 -1
- package/dist/declarations/src/errors.d.ts +0 -28
- package/dist/declarations/src/index.d.ts +0 -9
- package/dist/declarations/src/storage.d.ts +0 -12
- package/dist/declarations/src/types/declarations.d.ts +0 -52
- package/dist/declarations/src/types/index.d.ts +0 -14
- package/dist/declarations/src/utils/getInjectedName.d.ts +0 -1
- package/dist/declarations/src/utils/index.d.ts +0 -2
- package/dist/declarations/src/utils/normalizeChainId.d.ts +0 -1
- package/dist/wagmi-core.cjs.dev.js +0 -1697
- package/dist/wagmi-core.cjs.prod.js +0 -1697
- package/dist/wagmi-core.esm.js +0 -1631
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
// are you seeing an error that a default export doesn't exist but your source file has a default export?
|
|
2
|
+
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
+
|
|
4
|
+
// curious why you need to?
|
|
5
|
+
// this file exists so that you can import from the entrypoint normally
|
|
6
|
+
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
+
// which means we need to re-export all of the modules from your source file
|
|
8
|
+
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
+
// to check for a default export and re-export it if it exists
|
|
10
|
+
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
+
export * from "../../../src/connectors/coinbaseWallet";
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../../src/connectors/coinbaseWallet.ts");
|
|
15
|
+
|
|
16
|
+
unregister();
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
// are you seeing an error that a default export doesn't exist but your source file has a default export?
|
|
2
|
+
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
+
|
|
4
|
+
// curious why you need to?
|
|
5
|
+
// this file exists so that you can import from the entrypoint normally
|
|
6
|
+
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
+
// which means we need to re-export all of the modules from your source file
|
|
8
|
+
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
+
// to check for a default export and re-export it if it exists
|
|
10
|
+
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
+
export * from "../../../src/connectors/mock/index";
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../../src/connectors/mock/index.ts");
|
|
15
|
+
|
|
16
|
+
unregister();
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
// are you seeing an error that a default export doesn't exist but your source file has a default export?
|
|
2
|
+
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
+
|
|
4
|
+
// curious why you need to?
|
|
5
|
+
// this file exists so that you can import from the entrypoint normally
|
|
6
|
+
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
+
// which means we need to re-export all of the modules from your source file
|
|
8
|
+
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
+
// to check for a default export and re-export it if it exists
|
|
10
|
+
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
+
export * from "../../../src/connectors/walletConnect";
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../../src/connectors/walletConnect.ts");
|
|
15
|
+
|
|
16
|
+
unregister();
|
package/dist/wagmi-core.cjs.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
// are you seeing an error that a default export doesn't exist but your source file has a default export?
|
|
2
|
+
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
+
|
|
4
|
+
// curious why you need to?
|
|
5
|
+
// this file exists so that you can import from the entrypoint normally
|
|
6
|
+
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
+
// which means we need to re-export all of the modules from your source file
|
|
8
|
+
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
+
// to check for a default export and re-export it if it exists
|
|
10
|
+
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
+
export * from "../src/index";
|
package/dist/wagmi-core.cjs.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../..", "..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../src/index.ts");
|
|
15
|
+
|
|
16
|
+
unregister();
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wagmi/core",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Vanilla JS Client for Ethereum",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.2.0-next.
|
|
5
|
+
"version": "0.2.0-next.9",
|
|
6
6
|
"ethereum": "awkweb.eth",
|
|
7
7
|
"repository": "tmm/wagmi",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@coinbase/wallet-sdk": "^3.0.1",
|
|
63
|
-
"@ethersproject/providers": "^5.5.1",
|
|
64
63
|
"@walletconnect/ethereum-provider": "1.7.5",
|
|
65
64
|
"ethers": "^5.5.1"
|
|
66
65
|
}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var base = require('../../../dist/base-09a653f3.cjs.dev.js');
|
|
6
|
-
var ethers = require('ethers');
|
|
7
|
-
var utils = require('ethers/lib/utils');
|
|
8
|
-
require('eventemitter3');
|
|
9
|
-
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n["default"] = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _client = /*#__PURE__*/new WeakMap();
|
|
29
|
-
|
|
30
|
-
var _provider = /*#__PURE__*/new WeakMap();
|
|
31
|
-
|
|
32
|
-
class CoinbaseWalletConnector extends base.Connector {
|
|
33
|
-
constructor(config) {
|
|
34
|
-
var _window$ethereum;
|
|
35
|
-
|
|
36
|
-
super(config);
|
|
37
|
-
|
|
38
|
-
base._defineProperty(this, "id", 'coinbaseWallet');
|
|
39
|
-
|
|
40
|
-
base._defineProperty(this, "name", 'Coinbase Wallet');
|
|
41
|
-
|
|
42
|
-
base._defineProperty(this, "ready", typeof window !== 'undefined' && !((_window$ethereum = window.ethereum) !== null && _window$ethereum !== void 0 && _window$ethereum.isCoinbaseWallet));
|
|
43
|
-
|
|
44
|
-
base._classPrivateFieldInitSpec(this, _client, {
|
|
45
|
-
writable: true,
|
|
46
|
-
value: void 0
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
base._classPrivateFieldInitSpec(this, _provider, {
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
base._defineProperty(this, "onAccountsChanged", accounts => {
|
|
55
|
-
if (accounts.length === 0) this.emit('disconnect');else this.emit('change', {
|
|
56
|
-
account: utils.getAddress(accounts[0])
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
base._defineProperty(this, "onChainChanged", chainId => {
|
|
61
|
-
var id = base.normalizeChainId(chainId);
|
|
62
|
-
var unsupported = this.isChainUnsupported(id);
|
|
63
|
-
this.emit('change', {
|
|
64
|
-
chain: {
|
|
65
|
-
id,
|
|
66
|
-
unsupported
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
base._defineProperty(this, "onDisconnect", () => {
|
|
72
|
-
this.emit('disconnect');
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
connect() {
|
|
77
|
-
var _this = this;
|
|
78
|
-
|
|
79
|
-
return base._asyncToGenerator(function* () {
|
|
80
|
-
try {
|
|
81
|
-
var provider = yield _this.getProvider();
|
|
82
|
-
provider.on('accountsChanged', _this.onAccountsChanged);
|
|
83
|
-
provider.on('chainChanged', _this.onChainChanged);
|
|
84
|
-
provider.on('disconnect', _this.onDisconnect);
|
|
85
|
-
|
|
86
|
-
_this.emit('connecting');
|
|
87
|
-
|
|
88
|
-
var accounts = yield provider.enable();
|
|
89
|
-
var account = utils.getAddress(accounts[0]);
|
|
90
|
-
var id = yield _this.getChainId();
|
|
91
|
-
|
|
92
|
-
var unsupported = _this.isChainUnsupported(id);
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
account,
|
|
96
|
-
chain: {
|
|
97
|
-
id,
|
|
98
|
-
unsupported
|
|
99
|
-
},
|
|
100
|
-
provider: new ethers.providers.Web3Provider(provider)
|
|
101
|
-
};
|
|
102
|
-
} catch (error) {
|
|
103
|
-
if (/user closed modal/i.test(error.message)) throw new base.UserRejectedRequestError();
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
})();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
disconnect() {
|
|
110
|
-
var _this2 = this;
|
|
111
|
-
|
|
112
|
-
return base._asyncToGenerator(function* () {
|
|
113
|
-
if (!base._classPrivateFieldGet(_this2, _provider)) return;
|
|
114
|
-
var provider = yield _this2.getProvider();
|
|
115
|
-
provider.removeListener('accountsChanged', _this2.onAccountsChanged);
|
|
116
|
-
provider.removeListener('chainChanged', _this2.onChainChanged);
|
|
117
|
-
provider.removeListener('disconnect', _this2.onDisconnect);
|
|
118
|
-
provider.disconnect();
|
|
119
|
-
provider.close();
|
|
120
|
-
|
|
121
|
-
if (typeof localStorage !== 'undefined') {
|
|
122
|
-
var n = localStorage.length;
|
|
123
|
-
|
|
124
|
-
while (n--) {
|
|
125
|
-
var key = localStorage.key(n);
|
|
126
|
-
if (!key) continue;
|
|
127
|
-
if (!/-walletlink/.test(key)) continue;
|
|
128
|
-
localStorage.removeItem(key);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
})();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
getAccount() {
|
|
135
|
-
var _this3 = this;
|
|
136
|
-
|
|
137
|
-
return base._asyncToGenerator(function* () {
|
|
138
|
-
var provider = yield _this3.getProvider();
|
|
139
|
-
var accounts = yield provider.request({
|
|
140
|
-
method: 'eth_accounts'
|
|
141
|
-
}); // return checksum address
|
|
142
|
-
|
|
143
|
-
return utils.getAddress(accounts[0]);
|
|
144
|
-
})();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
getChainId() {
|
|
148
|
-
var _this4 = this;
|
|
149
|
-
|
|
150
|
-
return base._asyncToGenerator(function* () {
|
|
151
|
-
var provider = yield _this4.getProvider();
|
|
152
|
-
var chainId = base.normalizeChainId(provider.chainId);
|
|
153
|
-
return chainId;
|
|
154
|
-
})();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
getProvider() {
|
|
158
|
-
var _this5 = this;
|
|
159
|
-
|
|
160
|
-
return base._asyncToGenerator(function* () {
|
|
161
|
-
if (!base._classPrivateFieldGet(_this5, _provider)) {
|
|
162
|
-
var {
|
|
163
|
-
CoinbaseWalletSDK
|
|
164
|
-
} = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@coinbase/wallet-sdk')); });
|
|
165
|
-
|
|
166
|
-
base._classPrivateFieldSet(_this5, _client, new CoinbaseWalletSDK(_this5.options));
|
|
167
|
-
|
|
168
|
-
base._classPrivateFieldSet(_this5, _provider, base._classPrivateFieldGet(_this5, _client).makeWeb3Provider(_this5.options.jsonRpcUrl));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return base._classPrivateFieldGet(_this5, _provider);
|
|
172
|
-
})();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
getSigner() {
|
|
176
|
-
var _this6 = this;
|
|
177
|
-
|
|
178
|
-
return base._asyncToGenerator(function* () {
|
|
179
|
-
var [provider, account] = yield Promise.all([_this6.getProvider(), _this6.getAccount()]);
|
|
180
|
-
return new ethers.providers.Web3Provider(provider).getSigner(account);
|
|
181
|
-
})();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
isAuthorized() {
|
|
185
|
-
var _this7 = this;
|
|
186
|
-
|
|
187
|
-
return base._asyncToGenerator(function* () {
|
|
188
|
-
try {
|
|
189
|
-
var account = yield _this7.getAccount();
|
|
190
|
-
return !!account;
|
|
191
|
-
} catch (_unused) {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
})();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
switchChain(chainId) {
|
|
198
|
-
var _this8 = this;
|
|
199
|
-
|
|
200
|
-
return base._asyncToGenerator(function* () {
|
|
201
|
-
var provider = yield _this8.getProvider();
|
|
202
|
-
var id = utils.hexValue(chainId);
|
|
203
|
-
|
|
204
|
-
try {
|
|
205
|
-
var _chains$find;
|
|
206
|
-
|
|
207
|
-
yield provider.request({
|
|
208
|
-
method: 'wallet_switchEthereumChain',
|
|
209
|
-
params: [{
|
|
210
|
-
chainId: id
|
|
211
|
-
}]
|
|
212
|
-
});
|
|
213
|
-
var chains = [..._this8.chains, ...base.allChains];
|
|
214
|
-
return (_chains$find = chains.find(x => x.id === chainId)) !== null && _chains$find !== void 0 ? _chains$find : {
|
|
215
|
-
id: chainId,
|
|
216
|
-
name: "Chain ".concat(id),
|
|
217
|
-
rpcUrls: []
|
|
218
|
-
};
|
|
219
|
-
} catch (error) {
|
|
220
|
-
if (/user rejected signature request/i.test(error.message)) throw new base.UserRejectedRequestError();else throw new base.SwitchChainError();
|
|
221
|
-
}
|
|
222
|
-
})();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
watchAsset(_ref) {
|
|
226
|
-
var _this9 = this;
|
|
227
|
-
|
|
228
|
-
return base._asyncToGenerator(function* () {
|
|
229
|
-
var {
|
|
230
|
-
address,
|
|
231
|
-
decimals = 18,
|
|
232
|
-
image,
|
|
233
|
-
symbol
|
|
234
|
-
} = _ref;
|
|
235
|
-
var provider = yield _this9.getProvider();
|
|
236
|
-
return yield provider.request({
|
|
237
|
-
method: 'wallet_watchAsset',
|
|
238
|
-
params: {
|
|
239
|
-
type: 'ERC20',
|
|
240
|
-
options: {
|
|
241
|
-
address,
|
|
242
|
-
decimals,
|
|
243
|
-
image,
|
|
244
|
-
symbol
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
})();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var base = require('../../../dist/base-d8123d5f.cjs.prod.js');
|
|
6
|
-
var ethers = require('ethers');
|
|
7
|
-
var utils = require('ethers/lib/utils');
|
|
8
|
-
require('eventemitter3');
|
|
9
|
-
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n["default"] = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _client = /*#__PURE__*/new WeakMap();
|
|
29
|
-
|
|
30
|
-
var _provider = /*#__PURE__*/new WeakMap();
|
|
31
|
-
|
|
32
|
-
class CoinbaseWalletConnector extends base.Connector {
|
|
33
|
-
constructor(config) {
|
|
34
|
-
var _window$ethereum;
|
|
35
|
-
|
|
36
|
-
super(config);
|
|
37
|
-
|
|
38
|
-
base._defineProperty(this, "id", 'coinbaseWallet');
|
|
39
|
-
|
|
40
|
-
base._defineProperty(this, "name", 'Coinbase Wallet');
|
|
41
|
-
|
|
42
|
-
base._defineProperty(this, "ready", typeof window !== 'undefined' && !((_window$ethereum = window.ethereum) !== null && _window$ethereum !== void 0 && _window$ethereum.isCoinbaseWallet));
|
|
43
|
-
|
|
44
|
-
base._classPrivateFieldInitSpec(this, _client, {
|
|
45
|
-
writable: true,
|
|
46
|
-
value: void 0
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
base._classPrivateFieldInitSpec(this, _provider, {
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
base._defineProperty(this, "onAccountsChanged", accounts => {
|
|
55
|
-
if (accounts.length === 0) this.emit('disconnect');else this.emit('change', {
|
|
56
|
-
account: utils.getAddress(accounts[0])
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
base._defineProperty(this, "onChainChanged", chainId => {
|
|
61
|
-
var id = base.normalizeChainId(chainId);
|
|
62
|
-
var unsupported = this.isChainUnsupported(id);
|
|
63
|
-
this.emit('change', {
|
|
64
|
-
chain: {
|
|
65
|
-
id,
|
|
66
|
-
unsupported
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
base._defineProperty(this, "onDisconnect", () => {
|
|
72
|
-
this.emit('disconnect');
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
connect() {
|
|
77
|
-
var _this = this;
|
|
78
|
-
|
|
79
|
-
return base._asyncToGenerator(function* () {
|
|
80
|
-
try {
|
|
81
|
-
var provider = yield _this.getProvider();
|
|
82
|
-
provider.on('accountsChanged', _this.onAccountsChanged);
|
|
83
|
-
provider.on('chainChanged', _this.onChainChanged);
|
|
84
|
-
provider.on('disconnect', _this.onDisconnect);
|
|
85
|
-
|
|
86
|
-
_this.emit('connecting');
|
|
87
|
-
|
|
88
|
-
var accounts = yield provider.enable();
|
|
89
|
-
var account = utils.getAddress(accounts[0]);
|
|
90
|
-
var id = yield _this.getChainId();
|
|
91
|
-
|
|
92
|
-
var unsupported = _this.isChainUnsupported(id);
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
account,
|
|
96
|
-
chain: {
|
|
97
|
-
id,
|
|
98
|
-
unsupported
|
|
99
|
-
},
|
|
100
|
-
provider: new ethers.providers.Web3Provider(provider)
|
|
101
|
-
};
|
|
102
|
-
} catch (error) {
|
|
103
|
-
if (/user closed modal/i.test(error.message)) throw new base.UserRejectedRequestError();
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
})();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
disconnect() {
|
|
110
|
-
var _this2 = this;
|
|
111
|
-
|
|
112
|
-
return base._asyncToGenerator(function* () {
|
|
113
|
-
if (!base._classPrivateFieldGet(_this2, _provider)) return;
|
|
114
|
-
var provider = yield _this2.getProvider();
|
|
115
|
-
provider.removeListener('accountsChanged', _this2.onAccountsChanged);
|
|
116
|
-
provider.removeListener('chainChanged', _this2.onChainChanged);
|
|
117
|
-
provider.removeListener('disconnect', _this2.onDisconnect);
|
|
118
|
-
provider.disconnect();
|
|
119
|
-
provider.close();
|
|
120
|
-
|
|
121
|
-
if (typeof localStorage !== 'undefined') {
|
|
122
|
-
var n = localStorage.length;
|
|
123
|
-
|
|
124
|
-
while (n--) {
|
|
125
|
-
var key = localStorage.key(n);
|
|
126
|
-
if (!key) continue;
|
|
127
|
-
if (!/-walletlink/.test(key)) continue;
|
|
128
|
-
localStorage.removeItem(key);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
})();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
getAccount() {
|
|
135
|
-
var _this3 = this;
|
|
136
|
-
|
|
137
|
-
return base._asyncToGenerator(function* () {
|
|
138
|
-
var provider = yield _this3.getProvider();
|
|
139
|
-
var accounts = yield provider.request({
|
|
140
|
-
method: 'eth_accounts'
|
|
141
|
-
}); // return checksum address
|
|
142
|
-
|
|
143
|
-
return utils.getAddress(accounts[0]);
|
|
144
|
-
})();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
getChainId() {
|
|
148
|
-
var _this4 = this;
|
|
149
|
-
|
|
150
|
-
return base._asyncToGenerator(function* () {
|
|
151
|
-
var provider = yield _this4.getProvider();
|
|
152
|
-
var chainId = base.normalizeChainId(provider.chainId);
|
|
153
|
-
return chainId;
|
|
154
|
-
})();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
getProvider() {
|
|
158
|
-
var _this5 = this;
|
|
159
|
-
|
|
160
|
-
return base._asyncToGenerator(function* () {
|
|
161
|
-
if (!base._classPrivateFieldGet(_this5, _provider)) {
|
|
162
|
-
var {
|
|
163
|
-
CoinbaseWalletSDK
|
|
164
|
-
} = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@coinbase/wallet-sdk')); });
|
|
165
|
-
|
|
166
|
-
base._classPrivateFieldSet(_this5, _client, new CoinbaseWalletSDK(_this5.options));
|
|
167
|
-
|
|
168
|
-
base._classPrivateFieldSet(_this5, _provider, base._classPrivateFieldGet(_this5, _client).makeWeb3Provider(_this5.options.jsonRpcUrl));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return base._classPrivateFieldGet(_this5, _provider);
|
|
172
|
-
})();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
getSigner() {
|
|
176
|
-
var _this6 = this;
|
|
177
|
-
|
|
178
|
-
return base._asyncToGenerator(function* () {
|
|
179
|
-
var [provider, account] = yield Promise.all([_this6.getProvider(), _this6.getAccount()]);
|
|
180
|
-
return new ethers.providers.Web3Provider(provider).getSigner(account);
|
|
181
|
-
})();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
isAuthorized() {
|
|
185
|
-
var _this7 = this;
|
|
186
|
-
|
|
187
|
-
return base._asyncToGenerator(function* () {
|
|
188
|
-
try {
|
|
189
|
-
var account = yield _this7.getAccount();
|
|
190
|
-
return !!account;
|
|
191
|
-
} catch (_unused) {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
})();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
switchChain(chainId) {
|
|
198
|
-
var _this8 = this;
|
|
199
|
-
|
|
200
|
-
return base._asyncToGenerator(function* () {
|
|
201
|
-
var provider = yield _this8.getProvider();
|
|
202
|
-
var id = utils.hexValue(chainId);
|
|
203
|
-
|
|
204
|
-
try {
|
|
205
|
-
var _chains$find;
|
|
206
|
-
|
|
207
|
-
yield provider.request({
|
|
208
|
-
method: 'wallet_switchEthereumChain',
|
|
209
|
-
params: [{
|
|
210
|
-
chainId: id
|
|
211
|
-
}]
|
|
212
|
-
});
|
|
213
|
-
var chains = [..._this8.chains, ...base.allChains];
|
|
214
|
-
return (_chains$find = chains.find(x => x.id === chainId)) !== null && _chains$find !== void 0 ? _chains$find : {
|
|
215
|
-
id: chainId,
|
|
216
|
-
name: "Chain ".concat(id),
|
|
217
|
-
rpcUrls: []
|
|
218
|
-
};
|
|
219
|
-
} catch (error) {
|
|
220
|
-
if (/user rejected signature request/i.test(error.message)) throw new base.UserRejectedRequestError();else throw new base.SwitchChainError();
|
|
221
|
-
}
|
|
222
|
-
})();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
watchAsset(_ref) {
|
|
226
|
-
var _this9 = this;
|
|
227
|
-
|
|
228
|
-
return base._asyncToGenerator(function* () {
|
|
229
|
-
var {
|
|
230
|
-
address,
|
|
231
|
-
decimals = 18,
|
|
232
|
-
image,
|
|
233
|
-
symbol
|
|
234
|
-
} = _ref;
|
|
235
|
-
var provider = yield _this9.getProvider();
|
|
236
|
-
return yield provider.request({
|
|
237
|
-
method: 'wallet_watchAsset',
|
|
238
|
-
params: {
|
|
239
|
-
type: 'ERC20',
|
|
240
|
-
options: {
|
|
241
|
-
address,
|
|
242
|
-
decimals,
|
|
243
|
-
image,
|
|
244
|
-
symbol
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
})();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
|