@coinbase/cdp-wagmi 0.0.55 → 0.0.56
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/dist/esm/index.js +7 -3
- package/dist/esm/index10.js +37 -0
- package/dist/esm/index11.js +23 -0
- package/dist/esm/index12.js +4 -0
- package/dist/esm/index13.js +6 -0
- package/dist/esm/index2.js +55 -174
- package/dist/esm/index3.js +4 -0
- package/dist/esm/index4.js +179 -0
- package/dist/esm/index5.js +7 -0
- package/dist/esm/index6.js +50 -0
- package/dist/esm/index7.js +41 -0
- package/dist/esm/index8.js +4 -0
- package/dist/esm/index9.js +72 -0
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Analytics as r } from "./index2.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { VERSION as e } from "./index3.js";
|
|
4
|
+
import { CDP_CONNECTOR_ID as C, createCDPEmbeddedWalletConnector as c } from "./index4.js";
|
|
5
|
+
r.registerPackageVersion("wagmi", e);
|
|
2
6
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
C as CDP_CONNECTOR_ID,
|
|
8
|
+
c as createCDPEmbeddedWalletConnector
|
|
5
9
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var o, u;
|
|
2
|
+
function c() {
|
|
3
|
+
if (u) return o;
|
|
4
|
+
u = 1;
|
|
5
|
+
var t = {
|
|
6
|
+
// UTF-8 encoding
|
|
7
|
+
utf8: {
|
|
8
|
+
// Convert a string to a byte array
|
|
9
|
+
stringToBytes: function(n) {
|
|
10
|
+
return t.bin.stringToBytes(unescape(encodeURIComponent(n)));
|
|
11
|
+
},
|
|
12
|
+
// Convert a byte array to a string
|
|
13
|
+
bytesToString: function(n) {
|
|
14
|
+
return decodeURIComponent(escape(t.bin.bytesToString(n)));
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
// Binary encoding
|
|
18
|
+
bin: {
|
|
19
|
+
// Convert a string to a byte array
|
|
20
|
+
stringToBytes: function(n) {
|
|
21
|
+
for (var e = [], r = 0; r < n.length; r++)
|
|
22
|
+
e.push(n.charCodeAt(r) & 255);
|
|
23
|
+
return e;
|
|
24
|
+
},
|
|
25
|
+
// Convert a byte array to a string
|
|
26
|
+
bytesToString: function(n) {
|
|
27
|
+
for (var e = [], r = 0; r < n.length; r++)
|
|
28
|
+
e.push(String.fromCharCode(n[r]));
|
|
29
|
+
return e.join("");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return o = t, o;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
c as __require
|
|
37
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Determine if an object is a Buffer
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
var f, e;
|
|
8
|
+
function t() {
|
|
9
|
+
if (e) return f;
|
|
10
|
+
e = 1, f = function(r) {
|
|
11
|
+
return r != null && (u(r) || n(r) || !!r._isBuffer);
|
|
12
|
+
};
|
|
13
|
+
function u(r) {
|
|
14
|
+
return !!r.constructor && typeof r.constructor.isBuffer == "function" && r.constructor.isBuffer(r);
|
|
15
|
+
}
|
|
16
|
+
function n(r) {
|
|
17
|
+
return typeof r.readFloatLE == "function" && typeof r.slice == "function" && u(r.slice(0, 0));
|
|
18
|
+
}
|
|
19
|
+
return f;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
t as __require
|
|
23
|
+
};
|
package/dist/esm/index2.js
CHANGED
|
@@ -1,179 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import p from "./index5.js";
|
|
2
|
+
import { getFramework as m } from "./index6.js";
|
|
3
|
+
const y = "1f8d3e558f493e38a037dbfadb8ba344", v = "d473b1dcc969105adab157226cd9cf63", i = Symbol.for("@coinbase/cdp-analytics");
|
|
4
|
+
function g() {
|
|
5
|
+
const t = globalThis;
|
|
6
|
+
return t[i] || (t[i] = {
|
|
7
|
+
identifier: "",
|
|
8
|
+
enabled: !0,
|
|
9
|
+
isProduction: !1,
|
|
10
|
+
isUsingMocks: !1,
|
|
11
|
+
sendEvent: o,
|
|
12
|
+
sendActionCallEvent: (e) => o({ ...e, type: "action_call" }),
|
|
13
|
+
sendHookCallEvent: (e) => o({ ...e, type: "hook_call" }),
|
|
14
|
+
sendComponentCallEvent: (e) => o({ ...e, type: "component_call" }),
|
|
15
|
+
versionRegistry: {},
|
|
16
|
+
registerPackageVersion: (e, s) => {
|
|
17
|
+
n.versionRegistry[e] = s;
|
|
11
18
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return { accounts: d, chainId: i };
|
|
44
|
-
if (!d?.length && !t)
|
|
45
|
-
throw new Error(
|
|
46
|
-
"Please use our hooks / SignIn component to connect your wallet. See the README for more details."
|
|
47
|
-
);
|
|
48
|
-
return e && i !== e && (i = (await this.switchChain({ chainId: e }).catch(
|
|
49
|
-
(a) => {
|
|
50
|
-
if (a.code === l.provider.userRejectedRequest) throw a;
|
|
51
|
-
return { id: i };
|
|
52
|
-
}
|
|
53
|
-
))?.id ?? i), { accounts: d, chainId: i };
|
|
54
|
-
} catch (v) {
|
|
55
|
-
const a = v;
|
|
56
|
-
throw a.code === l.provider.userRejectedRequest ? new y(
|
|
57
|
-
l.provider.userRejectedRequest,
|
|
58
|
-
a.message
|
|
59
|
-
) : a;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
/**
|
|
63
|
-
* Disconnects the user, cleans up the connector's event listeners and calls
|
|
64
|
-
* the embedded wallet's destroy method
|
|
65
|
-
*/
|
|
66
|
-
async disconnect() {
|
|
67
|
-
const e = await this.getProvider();
|
|
68
|
-
await e.request({ method: "wallet_disconnect" }), o && (e.removeListener("disconnect", o), o = void 0), c && (e.removeListener("accountsChanged", c), c = void 0), r && (e.removeListener("chainChanged", r), r = void 0), n || (n = this.onConnect.bind(this), e.on("connect", n));
|
|
69
|
-
},
|
|
70
|
-
/**
|
|
71
|
-
* Get the accounts of the user
|
|
72
|
-
*
|
|
73
|
-
* @returns {Address[]} The accounts of the user
|
|
74
|
-
*/
|
|
75
|
-
async getAccounts() {
|
|
76
|
-
return await (await this.getProvider()).request({
|
|
77
|
-
method: "eth_accounts"
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
/**
|
|
81
|
-
* Get the chain id of the user
|
|
82
|
-
*
|
|
83
|
-
* @returns {number} The chain id of the user
|
|
84
|
-
*/
|
|
85
|
-
async getChainId() {
|
|
86
|
-
const e = await this.getProvider();
|
|
87
|
-
return Number(await e.request({ method: "eth_chainId" }));
|
|
88
|
-
},
|
|
89
|
-
/**
|
|
90
|
-
* Get the provider, which internally is sensitive to the signed in user
|
|
91
|
-
*
|
|
92
|
-
* @returns {EIP1193Provider} The 1193 provider
|
|
93
|
-
*/
|
|
94
|
-
async getProvider() {
|
|
95
|
-
return await w(), m || (m = I({
|
|
96
|
-
chains: C,
|
|
97
|
-
transports: u.providerConfig.transports
|
|
98
|
-
})), m.provider;
|
|
99
|
-
},
|
|
100
|
-
/**
|
|
101
|
-
* Checks if the user is authorized
|
|
102
|
-
*
|
|
103
|
-
* @returns {boolean} Whether the user is authorized
|
|
104
|
-
*/
|
|
105
|
-
async isAuthorized() {
|
|
106
|
-
try {
|
|
107
|
-
return !!(await this.getAccounts()).length;
|
|
108
|
-
} catch {
|
|
109
|
-
return !1;
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
/**
|
|
113
|
-
* Below we have thin internal methods that ensure we emit the events to wagmi's
|
|
114
|
-
* internal event emitter, which it uses to update the wagmi store.
|
|
115
|
-
*
|
|
116
|
-
* We bind these to the EIP1193 provider's event emission in `setup()`
|
|
117
|
-
*/
|
|
118
|
-
/**
|
|
119
|
-
* Handle accounts changed events ensuring we emit the events to wagmi
|
|
120
|
-
*
|
|
121
|
-
* @param accounts - {readonly string[]} - The accounts of the user (wagmi expects readonly string, not 0xstring)
|
|
122
|
-
*/
|
|
123
|
-
onAccountsChanged(e) {
|
|
124
|
-
s.emitter.emit("change", {
|
|
125
|
-
accounts: e.map((t) => D(t))
|
|
126
|
-
});
|
|
127
|
-
},
|
|
128
|
-
/**
|
|
129
|
-
* Handle chain changed events ensuring we emit the events to wagmi
|
|
130
|
-
*
|
|
131
|
-
* @param chain - {string} - The chain of the user
|
|
132
|
-
*/
|
|
133
|
-
onChainChanged(e) {
|
|
134
|
-
const t = Number(e);
|
|
135
|
-
s.emitter.emit("change", { chainId: t });
|
|
136
|
-
},
|
|
137
|
-
/**
|
|
138
|
-
* Handle connect events ensuring we emit the events to wagmi
|
|
139
|
-
*
|
|
140
|
-
* @param args - The connect info
|
|
141
|
-
* @param args.chainId - {string} - The chain id to connect to
|
|
142
|
-
*/
|
|
143
|
-
async onConnect({ chainId: e }) {
|
|
144
|
-
const t = await this.getAccounts();
|
|
145
|
-
t.length !== 0 && s.emitter.emit("connect", { accounts: t, chainId: Number(e) });
|
|
146
|
-
},
|
|
147
|
-
/**
|
|
148
|
-
* Handle disconnect events ensuring we emit the events to wagmi
|
|
149
|
-
*/
|
|
150
|
-
async onDisconnect() {
|
|
151
|
-
s.emitter.emit("disconnect");
|
|
152
|
-
},
|
|
153
|
-
/**
|
|
154
|
-
* Switches the user to the specified chain
|
|
155
|
-
*
|
|
156
|
-
* @param args - The switch chain args
|
|
157
|
-
* @param args.chainId - {number} - The chain id to switch to
|
|
158
|
-
* @returns {Promise<Chain>} The chain that was switched to
|
|
159
|
-
*/
|
|
160
|
-
async switchChain({ chainId: e }) {
|
|
161
|
-
const t = C.find((i) => i.id === e);
|
|
162
|
-
if (!t) throw new f(new Error("Chain not configured"));
|
|
163
|
-
return await (await this.getProvider()).request({
|
|
164
|
-
method: "wallet_switchEthereumChain",
|
|
165
|
-
params: [{ chainId: b(e) }]
|
|
166
|
-
}), t;
|
|
167
|
-
},
|
|
168
|
-
// Below are temporary values while we dev
|
|
169
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEyIDJMMiA3VjE3TDEyIDIyTDIyIDE3VjdMMTIgMloiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",
|
|
170
|
-
id: E,
|
|
171
|
-
name: "CDP",
|
|
172
|
-
type: "injected"
|
|
173
|
-
};
|
|
19
|
+
}), t[i];
|
|
20
|
+
}
|
|
21
|
+
const n = g();
|
|
22
|
+
async function o(t) {
|
|
23
|
+
if (!n.enabled || !n.identifier)
|
|
24
|
+
return;
|
|
25
|
+
const e = Date.now(), r = [{
|
|
26
|
+
user_id: n.identifier,
|
|
27
|
+
event_type: t.type,
|
|
28
|
+
platform: c() ? "web" : "native",
|
|
29
|
+
timestamp: e,
|
|
30
|
+
event_properties: {
|
|
31
|
+
project_name: "cdp-embedded-wallet",
|
|
32
|
+
framework: m(),
|
|
33
|
+
isLocalHost: u(),
|
|
34
|
+
isUsingMocks: n.isUsingMocks,
|
|
35
|
+
package_versions: n.versionRegistry,
|
|
36
|
+
...t
|
|
37
|
+
}
|
|
38
|
+
}], a = JSON.stringify(r), d = e.toString(), l = p(a + d), f = {
|
|
39
|
+
client: n.isProduction ? v : y,
|
|
40
|
+
e: a,
|
|
41
|
+
checksum: l
|
|
42
|
+
};
|
|
43
|
+
await fetch("https://cca-lite.coinbase.com/amp", {
|
|
44
|
+
method: "POST",
|
|
45
|
+
mode: "no-cors",
|
|
46
|
+
headers: {
|
|
47
|
+
"Content-Type": "application/json"
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify(f)
|
|
174
50
|
});
|
|
175
51
|
}
|
|
52
|
+
function c() {
|
|
53
|
+
return typeof window < "u" && typeof document < "u";
|
|
54
|
+
}
|
|
55
|
+
function u() {
|
|
56
|
+
return c() ? window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" : !1;
|
|
57
|
+
}
|
|
176
58
|
export {
|
|
177
|
-
|
|
178
|
-
M as createCDPEmbeddedWalletConnector
|
|
59
|
+
n as Analytics
|
|
179
60
|
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { createCDPEmbeddedWallet as I, STANDARD_ERROR_CODES as l, EIP1193ProviderError as y, initialize as p } from "@coinbase/cdp-core";
|
|
2
|
+
import { SwitchChainError as f, numberToHex as b, getAddress as D } from "viem";
|
|
3
|
+
import { createConnector as P } from "wagmi";
|
|
4
|
+
const E = "cdp-embedded-wallet";
|
|
5
|
+
function M(u) {
|
|
6
|
+
return P((s) => {
|
|
7
|
+
const C = u.providerConfig?.chains ?? s.chains ?? [];
|
|
8
|
+
let m, r, o, n, c, g;
|
|
9
|
+
async function w() {
|
|
10
|
+
g || (g = p(u.cdpConfig)), await g;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
/**
|
|
14
|
+
* Sets up the connector by binding the 1193's internal events to the connector's methods,
|
|
15
|
+
* is called as soon as app mounts.
|
|
16
|
+
*
|
|
17
|
+
* Core sdk must be initialised before 1193 provider is created,
|
|
18
|
+
* this.getProvider internally awaits the stored initPromise
|
|
19
|
+
*/
|
|
20
|
+
async setup() {
|
|
21
|
+
const e = await this.getProvider();
|
|
22
|
+
n || (n = this.onConnect.bind(this), e.on("connect", n));
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Connector function called when the user connects their wallet.
|
|
26
|
+
* On app mount, if the user was previously connected, this will be called
|
|
27
|
+
* with `isReconnecting` set to true.
|
|
28
|
+
*
|
|
29
|
+
* @param args - connect args
|
|
30
|
+
* @param args.chainId - {string} - the target chain id to connect to
|
|
31
|
+
* @param args.isReconnecting - {boolean} - whether the user was previously connected
|
|
32
|
+
* @returns The accounts and chain id of the now-connected user
|
|
33
|
+
*/
|
|
34
|
+
async connect({
|
|
35
|
+
chainId: e,
|
|
36
|
+
isReconnecting: t
|
|
37
|
+
} = {}) {
|
|
38
|
+
let d = [], i = await this.getChainId();
|
|
39
|
+
const h = await this.getProvider();
|
|
40
|
+
n && (h.removeListener("connect", n), n = void 0), c || (c = this.onAccountsChanged.bind(this), h.on("accountsChanged", c)), r || (r = this.onChainChanged.bind(this), h.on("chainChanged", r)), o || (o = this.onDisconnect.bind(this), h.on("disconnect", o));
|
|
41
|
+
try {
|
|
42
|
+
if (d = await this.getAccounts(), t)
|
|
43
|
+
return { accounts: d, chainId: i };
|
|
44
|
+
if (!d?.length && !t)
|
|
45
|
+
throw new Error(
|
|
46
|
+
"Please use our hooks / SignIn component to connect your wallet. See the README for more details."
|
|
47
|
+
);
|
|
48
|
+
return e && i !== e && (i = (await this.switchChain({ chainId: e }).catch(
|
|
49
|
+
(a) => {
|
|
50
|
+
if (a.code === l.provider.userRejectedRequest) throw a;
|
|
51
|
+
return { id: i };
|
|
52
|
+
}
|
|
53
|
+
))?.id ?? i), { accounts: d, chainId: i };
|
|
54
|
+
} catch (v) {
|
|
55
|
+
const a = v;
|
|
56
|
+
throw a.code === l.provider.userRejectedRequest ? new y(
|
|
57
|
+
l.provider.userRejectedRequest,
|
|
58
|
+
a.message
|
|
59
|
+
) : a;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Disconnects the user, cleans up the connector's event listeners and calls
|
|
64
|
+
* the embedded wallet's destroy method
|
|
65
|
+
*/
|
|
66
|
+
async disconnect() {
|
|
67
|
+
const e = await this.getProvider();
|
|
68
|
+
await e.request({ method: "wallet_disconnect" }), o && (e.removeListener("disconnect", o), o = void 0), c && (e.removeListener("accountsChanged", c), c = void 0), r && (e.removeListener("chainChanged", r), r = void 0), n || (n = this.onConnect.bind(this), e.on("connect", n));
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Get the accounts of the user
|
|
72
|
+
*
|
|
73
|
+
* @returns {Address[]} The accounts of the user
|
|
74
|
+
*/
|
|
75
|
+
async getAccounts() {
|
|
76
|
+
return await (await this.getProvider()).request({
|
|
77
|
+
method: "eth_accounts"
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* Get the chain id of the user
|
|
82
|
+
*
|
|
83
|
+
* @returns {number} The chain id of the user
|
|
84
|
+
*/
|
|
85
|
+
async getChainId() {
|
|
86
|
+
const e = await this.getProvider();
|
|
87
|
+
return Number(await e.request({ method: "eth_chainId" }));
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Get the provider, which internally is sensitive to the signed in user
|
|
91
|
+
*
|
|
92
|
+
* @returns {EIP1193Provider} The 1193 provider
|
|
93
|
+
*/
|
|
94
|
+
async getProvider() {
|
|
95
|
+
return await w(), m || (m = I({
|
|
96
|
+
chains: C,
|
|
97
|
+
transports: u.providerConfig.transports
|
|
98
|
+
})), m.provider;
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Checks if the user is authorized
|
|
102
|
+
*
|
|
103
|
+
* @returns {boolean} Whether the user is authorized
|
|
104
|
+
*/
|
|
105
|
+
async isAuthorized() {
|
|
106
|
+
try {
|
|
107
|
+
return !!(await this.getAccounts()).length;
|
|
108
|
+
} catch {
|
|
109
|
+
return !1;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Below we have thin internal methods that ensure we emit the events to wagmi's
|
|
114
|
+
* internal event emitter, which it uses to update the wagmi store.
|
|
115
|
+
*
|
|
116
|
+
* We bind these to the EIP1193 provider's event emission in `setup()`
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* Handle accounts changed events ensuring we emit the events to wagmi
|
|
120
|
+
*
|
|
121
|
+
* @param accounts - {readonly string[]} - The accounts of the user (wagmi expects readonly string, not 0xstring)
|
|
122
|
+
*/
|
|
123
|
+
onAccountsChanged(e) {
|
|
124
|
+
s.emitter.emit("change", {
|
|
125
|
+
accounts: e.map((t) => D(t))
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Handle chain changed events ensuring we emit the events to wagmi
|
|
130
|
+
*
|
|
131
|
+
* @param chain - {string} - The chain of the user
|
|
132
|
+
*/
|
|
133
|
+
onChainChanged(e) {
|
|
134
|
+
const t = Number(e);
|
|
135
|
+
s.emitter.emit("change", { chainId: t });
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* Handle connect events ensuring we emit the events to wagmi
|
|
139
|
+
*
|
|
140
|
+
* @param args - The connect info
|
|
141
|
+
* @param args.chainId - {string} - The chain id to connect to
|
|
142
|
+
*/
|
|
143
|
+
async onConnect({ chainId: e }) {
|
|
144
|
+
const t = await this.getAccounts();
|
|
145
|
+
t.length !== 0 && s.emitter.emit("connect", { accounts: t, chainId: Number(e) });
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* Handle disconnect events ensuring we emit the events to wagmi
|
|
149
|
+
*/
|
|
150
|
+
async onDisconnect() {
|
|
151
|
+
s.emitter.emit("disconnect");
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Switches the user to the specified chain
|
|
155
|
+
*
|
|
156
|
+
* @param args - The switch chain args
|
|
157
|
+
* @param args.chainId - {number} - The chain id to switch to
|
|
158
|
+
* @returns {Promise<Chain>} The chain that was switched to
|
|
159
|
+
*/
|
|
160
|
+
async switchChain({ chainId: e }) {
|
|
161
|
+
const t = C.find((i) => i.id === e);
|
|
162
|
+
if (!t) throw new f(new Error("Chain not configured"));
|
|
163
|
+
return await (await this.getProvider()).request({
|
|
164
|
+
method: "wallet_switchEthereumChain",
|
|
165
|
+
params: [{ chainId: b(e) }]
|
|
166
|
+
}), t;
|
|
167
|
+
},
|
|
168
|
+
// Below are temporary values while we dev
|
|
169
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEyIDJMMiA3VjE3TDEyIDIyTDIyIDE3VjdMMTIgMloiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",
|
|
170
|
+
id: E,
|
|
171
|
+
name: "CDP",
|
|
172
|
+
type: "injected"
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
E as CDP_CONNECTOR_ID,
|
|
178
|
+
M as createCDPEmbeddedWalletConnector
|
|
179
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function n() {
|
|
2
|
+
try {
|
|
3
|
+
return typeof navigator < "u" && navigator.product === "ReactNative";
|
|
4
|
+
} catch {
|
|
5
|
+
return !1;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function r() {
|
|
9
|
+
try {
|
|
10
|
+
if (typeof window > "u")
|
|
11
|
+
return typeof process < "u" && process.env && "__NEXT_PROCESSED_ENV" in process.env;
|
|
12
|
+
const e = window;
|
|
13
|
+
return !!(e.__NEXT_DATA__ || e.next || document.getElementById("__next"));
|
|
14
|
+
} catch {
|
|
15
|
+
return !1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function o() {
|
|
19
|
+
try {
|
|
20
|
+
if (typeof window > "u")
|
|
21
|
+
return !1;
|
|
22
|
+
const e = window;
|
|
23
|
+
return !!(e.__VUE__ || e.__VUE_DEVTOOLS_GLOBAL_HOOK__ || document.querySelector("[data-v-]"));
|
|
24
|
+
} catch {
|
|
25
|
+
return !1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function u() {
|
|
29
|
+
try {
|
|
30
|
+
if (typeof window > "u")
|
|
31
|
+
return !1;
|
|
32
|
+
const e = window;
|
|
33
|
+
return e.__REACT_DEVTOOLS_GLOBAL_HOOK__ || e.React ? !0 : !!document.querySelector(
|
|
34
|
+
"[data-reactroot], [data-reactid], ._reactRoot, ._reactRootContainer"
|
|
35
|
+
);
|
|
36
|
+
} catch {
|
|
37
|
+
return !1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function a() {
|
|
41
|
+
return u() ? "react" : n() ? "react-native" : r() ? "nextjs" : o() ? "vue" : "unknown";
|
|
42
|
+
}
|
|
43
|
+
let t = null;
|
|
44
|
+
function i() {
|
|
45
|
+
return t === null && (t = a()), t;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
a as detectFramework,
|
|
49
|
+
i as getFramework
|
|
50
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __module as h } from "./index8.js";
|
|
2
|
+
import { __require as S } from "./index9.js";
|
|
3
|
+
import { __require as q } from "./index10.js";
|
|
4
|
+
import { __require as w } from "./index11.js";
|
|
5
|
+
var x;
|
|
6
|
+
function G() {
|
|
7
|
+
return x ? h.exports : (x = 1, function() {
|
|
8
|
+
var v = S(), p = q().utf8, B = w(), F = q().bin, d = function(o, f) {
|
|
9
|
+
o.constructor == String ? f && f.encoding === "binary" ? o = F.stringToBytes(o) : o = p.stringToBytes(o) : B(o) ? o = Array.prototype.slice.call(o, 0) : !Array.isArray(o) && o.constructor !== Uint8Array && (o = o.toString());
|
|
10
|
+
for (var u = v.bytesToWords(o), a = o.length * 8, n = 1732584193, r = -271733879, i = -1732584194, t = 271733878, e = 0; e < u.length; e++)
|
|
11
|
+
u[e] = (u[e] << 8 | u[e] >>> 24) & 16711935 | (u[e] << 24 | u[e] >>> 8) & 4278255360;
|
|
12
|
+
u[a >>> 5] |= 128 << a % 32, u[(a + 64 >>> 9 << 4) + 14] = a;
|
|
13
|
+
for (var _ = d._ff, c = d._gg, l = d._hh, y = d._ii, e = 0; e < u.length; e += 16) {
|
|
14
|
+
var T = n, b = r, A = i, I = t;
|
|
15
|
+
n = _(n, r, i, t, u[e + 0], 7, -680876936), t = _(t, n, r, i, u[e + 1], 12, -389564586), i = _(i, t, n, r, u[e + 2], 17, 606105819), r = _(r, i, t, n, u[e + 3], 22, -1044525330), n = _(n, r, i, t, u[e + 4], 7, -176418897), t = _(t, n, r, i, u[e + 5], 12, 1200080426), i = _(i, t, n, r, u[e + 6], 17, -1473231341), r = _(r, i, t, n, u[e + 7], 22, -45705983), n = _(n, r, i, t, u[e + 8], 7, 1770035416), t = _(t, n, r, i, u[e + 9], 12, -1958414417), i = _(i, t, n, r, u[e + 10], 17, -42063), r = _(r, i, t, n, u[e + 11], 22, -1990404162), n = _(n, r, i, t, u[e + 12], 7, 1804603682), t = _(t, n, r, i, u[e + 13], 12, -40341101), i = _(i, t, n, r, u[e + 14], 17, -1502002290), r = _(r, i, t, n, u[e + 15], 22, 1236535329), n = c(n, r, i, t, u[e + 1], 5, -165796510), t = c(t, n, r, i, u[e + 6], 9, -1069501632), i = c(i, t, n, r, u[e + 11], 14, 643717713), r = c(r, i, t, n, u[e + 0], 20, -373897302), n = c(n, r, i, t, u[e + 5], 5, -701558691), t = c(t, n, r, i, u[e + 10], 9, 38016083), i = c(i, t, n, r, u[e + 15], 14, -660478335), r = c(r, i, t, n, u[e + 4], 20, -405537848), n = c(n, r, i, t, u[e + 9], 5, 568446438), t = c(t, n, r, i, u[e + 14], 9, -1019803690), i = c(i, t, n, r, u[e + 3], 14, -187363961), r = c(r, i, t, n, u[e + 8], 20, 1163531501), n = c(n, r, i, t, u[e + 13], 5, -1444681467), t = c(t, n, r, i, u[e + 2], 9, -51403784), i = c(i, t, n, r, u[e + 7], 14, 1735328473), r = c(r, i, t, n, u[e + 12], 20, -1926607734), n = l(n, r, i, t, u[e + 5], 4, -378558), t = l(t, n, r, i, u[e + 8], 11, -2022574463), i = l(i, t, n, r, u[e + 11], 16, 1839030562), r = l(r, i, t, n, u[e + 14], 23, -35309556), n = l(n, r, i, t, u[e + 1], 4, -1530992060), t = l(t, n, r, i, u[e + 4], 11, 1272893353), i = l(i, t, n, r, u[e + 7], 16, -155497632), r = l(r, i, t, n, u[e + 10], 23, -1094730640), n = l(n, r, i, t, u[e + 13], 4, 681279174), t = l(t, n, r, i, u[e + 0], 11, -358537222), i = l(i, t, n, r, u[e + 3], 16, -722521979), r = l(r, i, t, n, u[e + 6], 23, 76029189), n = l(n, r, i, t, u[e + 9], 4, -640364487), t = l(t, n, r, i, u[e + 12], 11, -421815835), i = l(i, t, n, r, u[e + 15], 16, 530742520), r = l(r, i, t, n, u[e + 2], 23, -995338651), n = y(n, r, i, t, u[e + 0], 6, -198630844), t = y(t, n, r, i, u[e + 7], 10, 1126891415), i = y(i, t, n, r, u[e + 14], 15, -1416354905), r = y(r, i, t, n, u[e + 5], 21, -57434055), n = y(n, r, i, t, u[e + 12], 6, 1700485571), t = y(t, n, r, i, u[e + 3], 10, -1894986606), i = y(i, t, n, r, u[e + 10], 15, -1051523), r = y(r, i, t, n, u[e + 1], 21, -2054922799), n = y(n, r, i, t, u[e + 8], 6, 1873313359), t = y(t, n, r, i, u[e + 15], 10, -30611744), i = y(i, t, n, r, u[e + 6], 15, -1560198380), r = y(r, i, t, n, u[e + 13], 21, 1309151649), n = y(n, r, i, t, u[e + 4], 6, -145523070), t = y(t, n, r, i, u[e + 11], 10, -1120210379), i = y(i, t, n, r, u[e + 2], 15, 718787259), r = y(r, i, t, n, u[e + 9], 21, -343485551), n = n + T >>> 0, r = r + b >>> 0, i = i + A >>> 0, t = t + I >>> 0;
|
|
16
|
+
}
|
|
17
|
+
return v.endian([n, r, i, t]);
|
|
18
|
+
};
|
|
19
|
+
d._ff = function(o, f, u, a, n, r, i) {
|
|
20
|
+
var t = o + (f & u | ~f & a) + (n >>> 0) + i;
|
|
21
|
+
return (t << r | t >>> 32 - r) + f;
|
|
22
|
+
}, d._gg = function(o, f, u, a, n, r, i) {
|
|
23
|
+
var t = o + (f & a | u & ~a) + (n >>> 0) + i;
|
|
24
|
+
return (t << r | t >>> 32 - r) + f;
|
|
25
|
+
}, d._hh = function(o, f, u, a, n, r, i) {
|
|
26
|
+
var t = o + (f ^ u ^ a) + (n >>> 0) + i;
|
|
27
|
+
return (t << r | t >>> 32 - r) + f;
|
|
28
|
+
}, d._ii = function(o, f, u, a, n, r, i) {
|
|
29
|
+
var t = o + (u ^ (f | ~a)) + (n >>> 0) + i;
|
|
30
|
+
return (t << r | t >>> 32 - r) + f;
|
|
31
|
+
}, d._blocksize = 16, d._digestsize = 16, h.exports = function(o, f) {
|
|
32
|
+
if (o == null)
|
|
33
|
+
throw new Error("Illegal argument " + o);
|
|
34
|
+
var u = v.wordsToBytes(d(o, f));
|
|
35
|
+
return f && f.asBytes ? u : f && f.asString ? F.bytesToString(u) : v.bytesToHex(u);
|
|
36
|
+
};
|
|
37
|
+
}(), h.exports);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
G as __require
|
|
41
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { __module as a } from "./index12.js";
|
|
2
|
+
var h;
|
|
3
|
+
function c() {
|
|
4
|
+
return h ? a.exports : (h = 1, function() {
|
|
5
|
+
var f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", u = {
|
|
6
|
+
// Bit-wise rotation left
|
|
7
|
+
rotl: function(r, t) {
|
|
8
|
+
return r << t | r >>> 32 - t;
|
|
9
|
+
},
|
|
10
|
+
// Bit-wise rotation right
|
|
11
|
+
rotr: function(r, t) {
|
|
12
|
+
return r << 32 - t | r >>> t;
|
|
13
|
+
},
|
|
14
|
+
// Swap big-endian to little-endian and vice versa
|
|
15
|
+
endian: function(r) {
|
|
16
|
+
if (r.constructor == Number)
|
|
17
|
+
return u.rotl(r, 8) & 16711935 | u.rotl(r, 24) & 4278255360;
|
|
18
|
+
for (var t = 0; t < r.length; t++)
|
|
19
|
+
r[t] = u.endian(r[t]);
|
|
20
|
+
return r;
|
|
21
|
+
},
|
|
22
|
+
// Generate an array of any length of random bytes
|
|
23
|
+
randomBytes: function(r) {
|
|
24
|
+
for (var t = []; r > 0; r--)
|
|
25
|
+
t.push(Math.floor(Math.random() * 256));
|
|
26
|
+
return t;
|
|
27
|
+
},
|
|
28
|
+
// Convert a byte array to big-endian 32-bit words
|
|
29
|
+
bytesToWords: function(r) {
|
|
30
|
+
for (var t = [], n = 0, o = 0; n < r.length; n++, o += 8)
|
|
31
|
+
t[o >>> 5] |= r[n] << 24 - o % 32;
|
|
32
|
+
return t;
|
|
33
|
+
},
|
|
34
|
+
// Convert big-endian 32-bit words to a byte array
|
|
35
|
+
wordsToBytes: function(r) {
|
|
36
|
+
for (var t = [], n = 0; n < r.length * 32; n += 8)
|
|
37
|
+
t.push(r[n >>> 5] >>> 24 - n % 32 & 255);
|
|
38
|
+
return t;
|
|
39
|
+
},
|
|
40
|
+
// Convert a byte array to a hex string
|
|
41
|
+
bytesToHex: function(r) {
|
|
42
|
+
for (var t = [], n = 0; n < r.length; n++)
|
|
43
|
+
t.push((r[n] >>> 4).toString(16)), t.push((r[n] & 15).toString(16));
|
|
44
|
+
return t.join("");
|
|
45
|
+
},
|
|
46
|
+
// Convert a hex string to a byte array
|
|
47
|
+
hexToBytes: function(r) {
|
|
48
|
+
for (var t = [], n = 0; n < r.length; n += 2)
|
|
49
|
+
t.push(parseInt(r.substr(n, 2), 16));
|
|
50
|
+
return t;
|
|
51
|
+
},
|
|
52
|
+
// Convert a byte array to a base-64 string
|
|
53
|
+
bytesToBase64: function(r) {
|
|
54
|
+
for (var t = [], n = 0; n < r.length; n += 3)
|
|
55
|
+
for (var o = r[n] << 16 | r[n + 1] << 8 | r[n + 2], e = 0; e < 4; e++)
|
|
56
|
+
n * 8 + e * 6 <= r.length * 8 ? t.push(f.charAt(o >>> 6 * (3 - e) & 63)) : t.push("=");
|
|
57
|
+
return t.join("");
|
|
58
|
+
},
|
|
59
|
+
// Convert a base-64 string to a byte array
|
|
60
|
+
base64ToBytes: function(r) {
|
|
61
|
+
r = r.replace(/[^A-Z0-9+\/]/ig, "");
|
|
62
|
+
for (var t = [], n = 0, o = 0; n < r.length; o = ++n % 4)
|
|
63
|
+
o != 0 && t.push((f.indexOf(r.charAt(n - 1)) & Math.pow(2, -2 * o + 8) - 1) << o * 2 | f.indexOf(r.charAt(n)) >>> 6 - o * 2);
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
a.exports = u;
|
|
68
|
+
}(), a.exports);
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
c as __require
|
|
72
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-wagmi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"react": ">=18.2.0",
|
|
20
20
|
"viem": "^2.33.0",
|
|
21
21
|
"wagmi": "^2.16.0",
|
|
22
|
-
"@coinbase/cdp-core": "^0.0.
|
|
22
|
+
"@coinbase/cdp-core": "^0.0.56"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@size-limit/webpack": "^11.2.0",
|
|
36
36
|
"@size-limit/webpack-why": "^11.2.0",
|
|
37
37
|
"size-limit": "^11.2.0",
|
|
38
|
-
"@coinbase/cdp-core": "^0.0.
|
|
38
|
+
"@coinbase/cdp-core": "^0.0.56"
|
|
39
39
|
},
|
|
40
40
|
"size-limit": [
|
|
41
41
|
{
|