@wagmi/core 0.3.8 → 0.4.0-test.2
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/chains/dist/wagmi-core-chains.cjs.dev.js +1 -1
- package/chains/dist/wagmi-core-chains.cjs.prod.js +1 -1
- package/chains/dist/wagmi-core-chains.esm.js +1 -1
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +2 -3
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +2 -3
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +2 -3
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.d.ts +1 -0
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.dev.js +200 -0
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.js +7 -0
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.prod.js +200 -0
- package/connectors/injected/dist/wagmi-core-connectors-injected.esm.js +196 -0
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +3 -4
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +3 -4
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +3 -4
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +3 -8
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +3 -8
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +2 -3
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +3 -4
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +3 -4
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +3 -4
- package/connectors/walletLink/dist/wagmi-core-connectors-walletLink.cjs.d.ts +11 -0
- package/connectors/walletLink/dist/wagmi-core-connectors-walletLink.cjs.js +16 -0
- package/dist/base-7f682723.cjs.prod.js +623 -0
- package/dist/base-ae774f26.cjs.dev.js +623 -0
- package/dist/base-c546f171.esm.js +603 -0
- package/dist/{chains-b4a51a84.cjs.dev.js → chains-7e369752.cjs.dev.js} +6 -6
- package/dist/{chains-7204b2dd.cjs.prod.js → chains-d045862c.cjs.prod.js} +6 -6
- package/dist/{chains-42648bc5.esm.js → chains-fa406563.esm.js} +6 -6
- package/dist/{client-a774f14a.cjs.prod.js → client-42cf11b7.cjs.dev.js} +3 -2
- package/dist/{client-e01209d5.esm.js → client-60ee0298.esm.js} +3 -2
- package/dist/{client-d5a20a13.cjs.dev.js → client-ed3aaa6a.cjs.prod.js} +3 -2
- package/dist/declarations/src/client.d.ts +1 -1
- package/dist/declarations/src/connectors/base.d.ts +1 -1
- package/dist/declarations/src/connectors/mock/provider.d.ts +1 -2
- package/dist/declarations/src/types/index.d.ts +1 -0
- package/dist/declarations/src/utils/eventemitter.d.ts +135 -0
- package/dist/wagmi-core.cjs.dev.js +4 -5
- package/dist/wagmi-core.cjs.prod.js +4 -5
- package/dist/wagmi-core.esm.js +7 -8
- package/package.json +1 -2
- package/dist/base-4c248b82.esm.js +0 -267
- package/dist/base-9fa7951e.cjs.dev.js +0 -290
- package/dist/base-b7c3f31e.cjs.prod.js +0 -290
|
@@ -90,7 +90,7 @@ const ropsten = {
|
|
|
90
90
|
ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
|
|
91
91
|
nativeCurrency: {
|
|
92
92
|
name: 'Ropsten Ether',
|
|
93
|
-
symbol: '
|
|
93
|
+
symbol: 'ROP',
|
|
94
94
|
decimals: 18
|
|
95
95
|
},
|
|
96
96
|
rpcUrls: {
|
|
@@ -111,7 +111,7 @@ const rinkeby = {
|
|
|
111
111
|
ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
|
|
112
112
|
nativeCurrency: {
|
|
113
113
|
name: 'Rinkeby Ether',
|
|
114
|
-
symbol: '
|
|
114
|
+
symbol: 'RIN',
|
|
115
115
|
decimals: 18
|
|
116
116
|
},
|
|
117
117
|
rpcUrls: {
|
|
@@ -132,7 +132,7 @@ const goerli = {
|
|
|
132
132
|
ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
|
|
133
133
|
nativeCurrency: {
|
|
134
134
|
name: 'Goerli Ether',
|
|
135
|
-
symbol: '
|
|
135
|
+
symbol: 'GOR',
|
|
136
136
|
decimals: 18
|
|
137
137
|
},
|
|
138
138
|
rpcUrls: {
|
|
@@ -152,7 +152,7 @@ const kovan = {
|
|
|
152
152
|
network: 'kovan',
|
|
153
153
|
nativeCurrency: {
|
|
154
154
|
name: 'Kovan Ether',
|
|
155
|
-
symbol: '
|
|
155
|
+
symbol: 'KOV',
|
|
156
156
|
decimals: 18
|
|
157
157
|
},
|
|
158
158
|
rpcUrls: {
|
|
@@ -246,11 +246,11 @@ const polygonMumbai = {
|
|
|
246
246
|
};
|
|
247
247
|
const arbitrum = {
|
|
248
248
|
id: chainId.arbitrum,
|
|
249
|
-
name: 'Arbitrum',
|
|
249
|
+
name: 'Arbitrum One',
|
|
250
250
|
network: 'arbitrum',
|
|
251
251
|
nativeCurrency: {
|
|
252
252
|
name: 'Ether',
|
|
253
|
-
symbol: '
|
|
253
|
+
symbol: 'ETH',
|
|
254
254
|
decimals: 18
|
|
255
255
|
},
|
|
256
256
|
rpcUrls: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var base = require('./base-
|
|
3
|
+
var base = require('./base-ae774f26.cjs.dev.js');
|
|
4
4
|
var ethers = require('ethers');
|
|
5
5
|
var create = require('zustand/vanilla');
|
|
6
6
|
var middleware = require('zustand/middleware');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
|
-
var chains = require('./chains-
|
|
8
|
+
var chains = require('./chains-7e369752.cjs.dev.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
11
11
|
|
|
@@ -19,6 +19,7 @@ function getInjectedName(ethereum) {
|
|
|
19
19
|
const getName = provider => {
|
|
20
20
|
if (provider.isBraveWallet) return 'Brave Wallet';
|
|
21
21
|
if (provider.isCoinbaseWallet) return 'Coinbase Wallet';
|
|
22
|
+
if (provider.isExodus) return 'Exodus';
|
|
22
23
|
if (provider.isFrame) return 'Frame';
|
|
23
24
|
if (provider.isOpera) return 'Opera';
|
|
24
25
|
if (provider.isTally) return 'Tally';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { b as Connector, _ as _classPrivateMethodInitSpec, f as _defineProperty, g as _classPrivateFieldInitSpec, n as normalizeChainId, h as _classPrivateFieldGet, i as _classPrivateFieldSet, a as ConnectorNotFoundError, j as _classPrivateMethodGet, U as UserRejectedRequestError, R as ResourceUnavailableError, c as ChainNotConfiguredError, A as AddChainError, e as SwitchChainError } from './base-
|
|
1
|
+
import { b as Connector, _ as _classPrivateMethodInitSpec, f as _defineProperty, g as _classPrivateFieldInitSpec, n as normalizeChainId, h as _classPrivateFieldGet, i as _classPrivateFieldSet, a as ConnectorNotFoundError, j as _classPrivateMethodGet, U as UserRejectedRequestError, R as ResourceUnavailableError, c as ChainNotConfiguredError, A as AddChainError, e as SwitchChainError } from './base-c546f171.esm.js';
|
|
2
2
|
import { providers, getDefaultProvider } from 'ethers';
|
|
3
3
|
import create from 'zustand/vanilla';
|
|
4
4
|
import { subscribeWithSelector, persist } from 'zustand/middleware';
|
|
5
5
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
6
|
-
import { a as allChains } from './chains-
|
|
6
|
+
import { a as allChains } from './chains-fa406563.esm.js';
|
|
7
7
|
|
|
8
8
|
function getInjectedName(ethereum) {
|
|
9
9
|
var _ethereum$providers, _getName;
|
|
@@ -13,6 +13,7 @@ function getInjectedName(ethereum) {
|
|
|
13
13
|
const getName = provider => {
|
|
14
14
|
if (provider.isBraveWallet) return 'Brave Wallet';
|
|
15
15
|
if (provider.isCoinbaseWallet) return 'Coinbase Wallet';
|
|
16
|
+
if (provider.isExodus) return 'Exodus';
|
|
16
17
|
if (provider.isFrame) return 'Frame';
|
|
17
18
|
if (provider.isOpera) return 'Opera';
|
|
18
19
|
if (provider.isTally) return 'Tally';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var base = require('./base-
|
|
3
|
+
var base = require('./base-7f682723.cjs.prod.js');
|
|
4
4
|
var ethers = require('ethers');
|
|
5
5
|
var create = require('zustand/vanilla');
|
|
6
6
|
var middleware = require('zustand/middleware');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
|
-
var chains = require('./chains-
|
|
8
|
+
var chains = require('./chains-d045862c.cjs.prod.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
11
11
|
|
|
@@ -19,6 +19,7 @@ function getInjectedName(ethereum) {
|
|
|
19
19
|
const getName = provider => {
|
|
20
20
|
if (provider.isBraveWallet) return 'Brave Wallet';
|
|
21
21
|
if (provider.isCoinbaseWallet) return 'Coinbase Wallet';
|
|
22
|
+
if (provider.isExodus) return 'Exodus';
|
|
22
23
|
if (provider.isFrame) return 'Frame';
|
|
23
24
|
if (provider.isOpera) return 'Opera';
|
|
24
25
|
if (provider.isTally) return 'Tally';
|
|
@@ -62,7 +62,7 @@ export declare class Client<TProvider extends Provider = Provider, TWebSocketPro
|
|
|
62
62
|
get error(): Error | undefined;
|
|
63
63
|
get lastUsedChainId(): number | undefined;
|
|
64
64
|
get provider(): TProvider;
|
|
65
|
-
get status(): "
|
|
65
|
+
get status(): "connected" | "connecting" | "reconnecting" | "disconnected";
|
|
66
66
|
get subscribe(): {
|
|
67
67
|
(listener: (selectedState: State<TProvider, TWebSocketProvider>, previousSelectedState: State<TProvider, TWebSocketProvider>) => void): () => void;
|
|
68
68
|
<U>(selector: (state: State<TProvider, TWebSocketProvider>) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { default as EventEmitter } from 'eventemitter3';
|
|
2
1
|
import { Signer } from 'ethers/lib/ethers';
|
|
2
|
+
import { EventEmitter } from '../utils/eventemitter';
|
|
3
3
|
import { Chain } from '../types';
|
|
4
4
|
export declare type ConnectorData<Provider = any> = {
|
|
5
5
|
account?: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { default as EventEmitter } from 'eventemitter3';
|
|
2
1
|
import { Signer, providers } from 'ethers';
|
|
3
2
|
export declare type MockProviderOptions = {
|
|
4
3
|
chainId?: number;
|
|
@@ -18,7 +17,7 @@ declare type Events = {
|
|
|
18
17
|
declare type Event = keyof Events;
|
|
19
18
|
export declare class MockProvider extends providers.BaseProvider {
|
|
20
19
|
#private;
|
|
21
|
-
events:
|
|
20
|
+
events: import("../../utils/eventemitter")<Events, any>;
|
|
22
21
|
constructor(options: MockProviderOptions);
|
|
23
22
|
enable(): Promise<string[]>;
|
|
24
23
|
disconnect(): Promise<void>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
3
|
+
* `EventEmitter` interface.
|
|
4
|
+
*/
|
|
5
|
+
declare class EventEmitter<
|
|
6
|
+
EventTypes extends EventEmitter.ValidEventTypes = string | symbol,
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
8
|
+
Context extends any = any,
|
|
9
|
+
> {
|
|
10
|
+
static prefixed: string | boolean
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Return an array listing the events for which the emitter has registered
|
|
14
|
+
* listeners.
|
|
15
|
+
*/
|
|
16
|
+
eventNames(): Array<EventEmitter.EventNames<EventTypes>>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Return the listeners registered for a given event.
|
|
20
|
+
*/
|
|
21
|
+
listeners<T extends EventEmitter.EventNames<EventTypes>>(
|
|
22
|
+
event: T,
|
|
23
|
+
): Array<EventEmitter.EventListener<EventTypes, T>>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Return the number of listeners listening to a given event.
|
|
27
|
+
*/
|
|
28
|
+
listenerCount(event: EventEmitter.EventNames<EventTypes>): number
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Calls each of the listeners registered for a given event.
|
|
32
|
+
*/
|
|
33
|
+
emit<T extends EventEmitter.EventNames<EventTypes>>(
|
|
34
|
+
event: T,
|
|
35
|
+
...args: EventEmitter.EventArgs<EventTypes, T>
|
|
36
|
+
): boolean
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Add a listener for a given event.
|
|
40
|
+
*/
|
|
41
|
+
on<T extends EventEmitter.EventNames<EventTypes>>(
|
|
42
|
+
event: T,
|
|
43
|
+
fn: EventEmitter.EventListener<EventTypes, T>,
|
|
44
|
+
context?: Context,
|
|
45
|
+
): this
|
|
46
|
+
addListener<T extends EventEmitter.EventNames<EventTypes>>(
|
|
47
|
+
event: T,
|
|
48
|
+
fn: EventEmitter.EventListener<EventTypes, T>,
|
|
49
|
+
context?: Context,
|
|
50
|
+
): this
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Add a one-time listener for a given event.
|
|
54
|
+
*/
|
|
55
|
+
once<T extends EventEmitter.EventNames<EventTypes>>(
|
|
56
|
+
event: T,
|
|
57
|
+
fn: EventEmitter.EventListener<EventTypes, T>,
|
|
58
|
+
context?: Context,
|
|
59
|
+
): this
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Remove the listeners of a given event.
|
|
63
|
+
*/
|
|
64
|
+
removeListener<T extends EventEmitter.EventNames<EventTypes>>(
|
|
65
|
+
event: T,
|
|
66
|
+
fn?: EventEmitter.EventListener<EventTypes, T>,
|
|
67
|
+
context?: Context,
|
|
68
|
+
once?: boolean,
|
|
69
|
+
): this
|
|
70
|
+
off<T extends EventEmitter.EventNames<EventTypes>>(
|
|
71
|
+
event: T,
|
|
72
|
+
fn?: EventEmitter.EventListener<EventTypes, T>,
|
|
73
|
+
context?: Context,
|
|
74
|
+
once?: boolean,
|
|
75
|
+
): this
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Remove all listeners, or those of the specified event.
|
|
79
|
+
*/
|
|
80
|
+
removeAllListeners(event?: EventEmitter.EventNames<EventTypes>): this
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare namespace EventEmitter {
|
|
84
|
+
export interface ListenerFn<Args extends any[] = any[]> {
|
|
85
|
+
(...args: Args): void
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface EventEmitterStatic {
|
|
89
|
+
new <
|
|
90
|
+
EventTypes extends ValidEventTypes = string | symbol,
|
|
91
|
+
Context = any,
|
|
92
|
+
>(): EventEmitter<EventTypes, Context>
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* `object` should be in either of the following forms:
|
|
97
|
+
* ```
|
|
98
|
+
* interface EventTypes {
|
|
99
|
+
* 'event-with-parameters': any[]
|
|
100
|
+
* 'event-with-example-handler': (...args: any[]) => void
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export type ValidEventTypes = string | symbol | object
|
|
105
|
+
|
|
106
|
+
export type EventNames<T extends ValidEventTypes> = T extends string | symbol
|
|
107
|
+
? T
|
|
108
|
+
: keyof T
|
|
109
|
+
|
|
110
|
+
export type ArgumentMap<T extends object> = {
|
|
111
|
+
[K in keyof T]: T[K] extends (...args: any[]) => void
|
|
112
|
+
? Parameters<T[K]>
|
|
113
|
+
: T[K] extends any[]
|
|
114
|
+
? T[K]
|
|
115
|
+
: any[]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type EventListener<
|
|
119
|
+
T extends ValidEventTypes,
|
|
120
|
+
K extends EventNames<T>,
|
|
121
|
+
> = T extends string | symbol
|
|
122
|
+
? (...args: any[]) => void
|
|
123
|
+
: (
|
|
124
|
+
...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]
|
|
125
|
+
) => void
|
|
126
|
+
|
|
127
|
+
export type EventArgs<
|
|
128
|
+
T extends ValidEventTypes,
|
|
129
|
+
K extends EventNames<T>,
|
|
130
|
+
> = Parameters<EventListener<T, K>>
|
|
131
|
+
|
|
132
|
+
export const EventEmitter: EventEmitterStatic
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export = EventEmitter
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var client = require('./client-
|
|
6
|
-
var base = require('./base-
|
|
5
|
+
var client = require('./client-42cf11b7.cjs.dev.js');
|
|
6
|
+
var base = require('./base-ae774f26.cjs.dev.js');
|
|
7
7
|
var ethers$1 = require('ethers/lib/ethers');
|
|
8
8
|
var utils = require('ethers/lib/utils');
|
|
9
|
-
var chains = require('./chains-
|
|
9
|
+
var chains = require('./chains-7e369752.cjs.dev.js');
|
|
10
10
|
var ethers = require('ethers');
|
|
11
11
|
var rpcs = require('./rpcs-9c4eb960.cjs.dev.js');
|
|
12
12
|
require('zustand/vanilla');
|
|
13
13
|
require('zustand/middleware');
|
|
14
|
-
require('eventemitter3');
|
|
15
14
|
|
|
16
15
|
// https://ethereum.org/en/developers/docs/standards/tokens/erc-20
|
|
17
16
|
const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)']; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
|
|
@@ -413,7 +412,7 @@ async function readContract(contractConfig, functionName) {
|
|
|
413
412
|
});
|
|
414
413
|
const params = [...(Array.isArray(args) ? args : args ? [args] : []), ...(overrides ? [overrides] : [])];
|
|
415
414
|
const contractFunction = contract[functionName];
|
|
416
|
-
if (!contractFunction) console.warn("\"".concat(functionName, "\" does not in interface for contract \"").concat(contractConfig.addressOrName, "\""));
|
|
415
|
+
if (!contractFunction) console.warn("\"".concat(functionName, "\" does not exist in interface for contract \"").concat(contractConfig.addressOrName, "\""));
|
|
417
416
|
const response = await (contractFunction === null || contractFunction === void 0 ? void 0 : contractFunction(...params));
|
|
418
417
|
return response;
|
|
419
418
|
}
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var client = require('./client-
|
|
6
|
-
var base = require('./base-
|
|
5
|
+
var client = require('./client-ed3aaa6a.cjs.prod.js');
|
|
6
|
+
var base = require('./base-7f682723.cjs.prod.js');
|
|
7
7
|
var ethers$1 = require('ethers/lib/ethers');
|
|
8
8
|
var utils = require('ethers/lib/utils');
|
|
9
|
-
var chains = require('./chains-
|
|
9
|
+
var chains = require('./chains-d045862c.cjs.prod.js');
|
|
10
10
|
var ethers = require('ethers');
|
|
11
11
|
var rpcs = require('./rpcs-b3c52116.cjs.prod.js');
|
|
12
12
|
require('zustand/vanilla');
|
|
13
13
|
require('zustand/middleware');
|
|
14
|
-
require('eventemitter3');
|
|
15
14
|
|
|
16
15
|
// https://ethereum.org/en/developers/docs/standards/tokens/erc-20
|
|
17
16
|
const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)']; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
|
|
@@ -413,7 +412,7 @@ async function readContract(contractConfig, functionName) {
|
|
|
413
412
|
});
|
|
414
413
|
const params = [...(Array.isArray(args) ? args : args ? [args] : []), ...(overrides ? [overrides] : [])];
|
|
415
414
|
const contractFunction = contract[functionName];
|
|
416
|
-
if (!contractFunction) console.warn("\"".concat(functionName, "\" does not in interface for contract \"").concat(contractConfig.addressOrName, "\""));
|
|
415
|
+
if (!contractFunction) console.warn("\"".concat(functionName, "\" does not exist in interface for contract \"").concat(contractConfig.addressOrName, "\""));
|
|
417
416
|
const response = await (contractFunction === null || contractFunction === void 0 ? void 0 : contractFunction(...params));
|
|
418
417
|
return response;
|
|
419
418
|
}
|
package/dist/wagmi-core.esm.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { c as client, g as getClient } from './client-
|
|
2
|
-
export { C as Client, I as InjectedConnector, a as createClient, b as createStorage, n as noopStorage } from './client-
|
|
3
|
-
import { C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, U as UserRejectedRequestError, S as SwitchChainNotSupportedError } from './base-
|
|
4
|
-
export { A as AddChainError, c as ChainNotConfiguredError, b as Connector, C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, P as ProviderRpcError, R as ResourceUnavailableError, d as RpcError, e as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, n as normalizeChainId } from './base-
|
|
1
|
+
import { c as client, g as getClient } from './client-60ee0298.esm.js';
|
|
2
|
+
export { C as Client, I as InjectedConnector, a as createClient, b as createStorage, n as noopStorage } from './client-60ee0298.esm.js';
|
|
3
|
+
import { C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, U as UserRejectedRequestError, S as SwitchChainNotSupportedError } from './base-c546f171.esm.js';
|
|
4
|
+
export { A as AddChainError, c as ChainNotConfiguredError, b as Connector, C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, P as ProviderRpcError, R as ResourceUnavailableError, d as RpcError, e as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, n as normalizeChainId } from './base-c546f171.esm.js';
|
|
5
5
|
import { Contract } from 'ethers/lib/ethers';
|
|
6
6
|
import { formatUnits, getAddress } from 'ethers/lib/utils';
|
|
7
|
-
import { a as allChains } from './chains-
|
|
8
|
-
export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-
|
|
7
|
+
import { a as allChains } from './chains-fa406563.esm.js';
|
|
8
|
+
export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-fa406563.esm.js';
|
|
9
9
|
import { providers, Contract as Contract$1 } from 'ethers';
|
|
10
10
|
export { a as alchemyRpcUrls, i as infuraRpcUrls } from './rpcs-7cfbd91c.esm.js';
|
|
11
11
|
import 'zustand/vanilla';
|
|
12
12
|
import 'zustand/middleware';
|
|
13
|
-
import 'eventemitter3';
|
|
14
13
|
|
|
15
14
|
// https://ethereum.org/en/developers/docs/standards/tokens/erc-20
|
|
16
15
|
const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)']; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
|
|
@@ -412,7 +411,7 @@ async function readContract(contractConfig, functionName) {
|
|
|
412
411
|
});
|
|
413
412
|
const params = [...(Array.isArray(args) ? args : args ? [args] : []), ...(overrides ? [overrides] : [])];
|
|
414
413
|
const contractFunction = contract[functionName];
|
|
415
|
-
if (!contractFunction) console.warn("\"".concat(functionName, "\" does not in interface for contract \"").concat(contractConfig.addressOrName, "\""));
|
|
414
|
+
if (!contractFunction) console.warn("\"".concat(functionName, "\" does not exist in interface for contract \"").concat(contractConfig.addressOrName, "\""));
|
|
416
415
|
const response = await (contractFunction === null || contractFunction === void 0 ? void 0 : contractFunction(...params));
|
|
417
416
|
return response;
|
|
418
417
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@wagmi/core",
|
|
3
3
|
"description": "Vanilla JS library for Ethereum",
|
|
4
4
|
"license": "WAGMIT",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.4.0-test.2",
|
|
6
6
|
"repository": "tmm/wagmi",
|
|
7
7
|
"author": "awkweb.eth",
|
|
8
8
|
"ethereum": "awkweb.eth",
|
|
@@ -86,7 +86,6 @@
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"eventemitter3": "^4.0.7",
|
|
90
89
|
"zustand": "^4.0.0-rc.1"
|
|
91
90
|
},
|
|
92
91
|
"devDependencies": {
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import { d as defaultChains } from './chains-42648bc5.esm.js';
|
|
3
|
-
|
|
4
|
-
function _checkPrivateRedeclaration(obj, privateCollection) {
|
|
5
|
-
if (privateCollection.has(obj)) {
|
|
6
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function _classPrivateMethodInitSpec(obj, privateSet) {
|
|
11
|
-
_checkPrivateRedeclaration(obj, privateSet);
|
|
12
|
-
privateSet.add(obj);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) {
|
|
16
|
-
_checkPrivateRedeclaration(obj, privateMap);
|
|
17
|
-
privateMap.set(obj, value);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _defineProperty(obj, key, value) {
|
|
21
|
-
if (key in obj) {
|
|
22
|
-
Object.defineProperty(obj, key, {
|
|
23
|
-
value: value,
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
obj[key] = value;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return obj;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
36
|
-
if (descriptor.get) {
|
|
37
|
-
return descriptor.get.call(receiver);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return descriptor.value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
44
|
-
if (!privateMap.has(receiver)) {
|
|
45
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return privateMap.get(receiver);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function _classPrivateFieldGet(receiver, privateMap) {
|
|
52
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
53
|
-
return _classApplyDescriptorGet(receiver, descriptor);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) {
|
|
57
|
-
if (!privateSet.has(receiver)) {
|
|
58
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return fn;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
65
|
-
if (descriptor.set) {
|
|
66
|
-
descriptor.set.call(receiver, value);
|
|
67
|
-
} else {
|
|
68
|
-
if (!descriptor.writable) {
|
|
69
|
-
throw new TypeError("attempted to set read only private field");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
descriptor.value = value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
77
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
78
|
-
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
79
|
-
return value;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function normalizeChainId(chainId) {
|
|
83
|
-
if (typeof chainId === 'string') return Number.parseInt(chainId, chainId.trim().substring(0, 2) === '0x' ? 16 : 10);
|
|
84
|
-
return chainId;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Error subclass implementing JSON RPC 2.0 errors and Ethereum RPC errors per EIP-1474.
|
|
89
|
-
* @see https://eips.ethereum.org/EIPS/eip-1474
|
|
90
|
-
*/
|
|
91
|
-
class RpcError extends Error {
|
|
92
|
-
constructor(
|
|
93
|
-
/** Number error code */
|
|
94
|
-
code,
|
|
95
|
-
/** Human-readable string */
|
|
96
|
-
message,
|
|
97
|
-
/** Low-level error */
|
|
98
|
-
internal,
|
|
99
|
-
/** Other useful information about error */
|
|
100
|
-
data) {
|
|
101
|
-
if (!Number.isInteger(code)) throw new Error('"code" must be an integer.');
|
|
102
|
-
if (!message || typeof message !== 'string') throw new Error('"message" must be a nonempty string.');
|
|
103
|
-
super(message);
|
|
104
|
-
|
|
105
|
-
_defineProperty(this, "code", void 0);
|
|
106
|
-
|
|
107
|
-
_defineProperty(this, "data", void 0);
|
|
108
|
-
|
|
109
|
-
_defineProperty(this, "internal", void 0);
|
|
110
|
-
|
|
111
|
-
this.code = code;
|
|
112
|
-
this.data = data;
|
|
113
|
-
this.internal = internal;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Error subclass implementing Ethereum Provider errors per EIP-1193.
|
|
119
|
-
* @see https://eips.ethereum.org/EIPS/eip-1193
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
class ProviderRpcError extends RpcError {
|
|
123
|
-
/**
|
|
124
|
-
* Create an Ethereum Provider JSON-RPC error.
|
|
125
|
-
* `code` must be an integer in the 1000 <= 4999 range.
|
|
126
|
-
*/
|
|
127
|
-
constructor(
|
|
128
|
-
/**
|
|
129
|
-
* Number error code
|
|
130
|
-
* @see https://eips.ethereum.org/EIPS/eip-1193#error-standards
|
|
131
|
-
*/
|
|
132
|
-
code,
|
|
133
|
-
/** Human-readable string */
|
|
134
|
-
message,
|
|
135
|
-
/** Low-level error */
|
|
136
|
-
internal,
|
|
137
|
-
/** Other useful information about error */
|
|
138
|
-
data) {
|
|
139
|
-
if (!(Number.isInteger(code) && code >= 1000 && code <= 4999)) throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
|
|
140
|
-
super(code, message, internal, data);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
class AddChainError extends Error {
|
|
145
|
-
constructor() {
|
|
146
|
-
super(...arguments);
|
|
147
|
-
|
|
148
|
-
_defineProperty(this, "name", 'AddChainError');
|
|
149
|
-
|
|
150
|
-
_defineProperty(this, "message", 'Error adding chain');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
class ChainNotConfiguredError extends Error {
|
|
155
|
-
constructor() {
|
|
156
|
-
super(...arguments);
|
|
157
|
-
|
|
158
|
-
_defineProperty(this, "name", 'ChainNotConfigured');
|
|
159
|
-
|
|
160
|
-
_defineProperty(this, "message", 'Chain not configured');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
class ConnectorAlreadyConnectedError extends Error {
|
|
165
|
-
constructor() {
|
|
166
|
-
super(...arguments);
|
|
167
|
-
|
|
168
|
-
_defineProperty(this, "name", 'ConnectorAlreadyConnectedError');
|
|
169
|
-
|
|
170
|
-
_defineProperty(this, "message", 'Connector already connected');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
class ConnectorNotFoundError extends Error {
|
|
175
|
-
constructor() {
|
|
176
|
-
super(...arguments);
|
|
177
|
-
|
|
178
|
-
_defineProperty(this, "name", 'ConnectorNotFoundError');
|
|
179
|
-
|
|
180
|
-
_defineProperty(this, "message", 'Connector not found');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
class SwitchChainError extends ProviderRpcError {
|
|
185
|
-
constructor(error) {
|
|
186
|
-
super(4902, 'Error switching chain', error);
|
|
187
|
-
|
|
188
|
-
_defineProperty(this, "name", 'SwitchChainError');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
class SwitchChainNotSupportedError extends Error {
|
|
193
|
-
constructor() {
|
|
194
|
-
super(...arguments);
|
|
195
|
-
|
|
196
|
-
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
197
|
-
|
|
198
|
-
_defineProperty(this, "message", 'Switch chain not supported by connector');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
class UserRejectedRequestError extends ProviderRpcError {
|
|
203
|
-
constructor(error) {
|
|
204
|
-
super(4001, 'User rejected request', error);
|
|
205
|
-
|
|
206
|
-
_defineProperty(this, "name", 'UserRejectedRequestError');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
class ResourceUnavailableError extends RpcError {
|
|
211
|
-
constructor(error) {
|
|
212
|
-
super(-32002, 'Resource unavailable', error);
|
|
213
|
-
|
|
214
|
-
_defineProperty(this, "name", 'ResourceUnavailable');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
class Connector extends EventEmitter {
|
|
220
|
-
/** Unique connector id */
|
|
221
|
-
|
|
222
|
-
/** Connector name */
|
|
223
|
-
|
|
224
|
-
/** Chains connector supports */
|
|
225
|
-
|
|
226
|
-
/** Options to use with connector */
|
|
227
|
-
|
|
228
|
-
/** Whether connector is usable */
|
|
229
|
-
constructor(_ref) {
|
|
230
|
-
let {
|
|
231
|
-
chains = defaultChains,
|
|
232
|
-
options
|
|
233
|
-
} = _ref;
|
|
234
|
-
super();
|
|
235
|
-
|
|
236
|
-
_defineProperty(this, "id", void 0);
|
|
237
|
-
|
|
238
|
-
_defineProperty(this, "name", void 0);
|
|
239
|
-
|
|
240
|
-
_defineProperty(this, "chains", void 0);
|
|
241
|
-
|
|
242
|
-
_defineProperty(this, "options", void 0);
|
|
243
|
-
|
|
244
|
-
_defineProperty(this, "ready", void 0);
|
|
245
|
-
|
|
246
|
-
this.chains = chains;
|
|
247
|
-
this.options = options;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
getBlockExplorerUrls(chain) {
|
|
251
|
-
var _chain$blockExplorers;
|
|
252
|
-
|
|
253
|
-
const {
|
|
254
|
-
default: blockExplorer,
|
|
255
|
-
...blockExplorers
|
|
256
|
-
} = (_chain$blockExplorers = chain.blockExplorers) !== null && _chain$blockExplorers !== void 0 ? _chain$blockExplorers : {};
|
|
257
|
-
if (blockExplorer) return [blockExplorer.url, ...Object.values(blockExplorers).map(x => x.url)];
|
|
258
|
-
return [];
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
isChainUnsupported(chainId) {
|
|
262
|
-
return !this.chains.some(x => x.id === chainId);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export { AddChainError as A, ConnectorAlreadyConnectedError as C, ProviderRpcError as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _classPrivateMethodInitSpec as _, ConnectorNotFoundError as a, Connector as b, ChainNotConfiguredError as c, RpcError as d, SwitchChainError as e, _defineProperty as f, _classPrivateFieldInitSpec as g, _classPrivateFieldGet as h, _classPrivateFieldSet as i, _classPrivateMethodGet as j, normalizeChainId as n };
|