@aurum-sdk/core 0.2.8 → 0.3.0
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/{Aurum-B0Okb4Qv.d.mts → Aurum-BoIhHFKm.d.mts} +25 -2
- package/dist/{Aurum-B0Okb4Qv.d.ts → Aurum-BoIhHFKm.d.ts} +25 -2
- package/dist/BraveAdapter-ALBZR2RG.js +153 -0
- package/dist/BraveAdapter-BPD5PDJH.mjs +153 -0
- package/dist/CoinbaseWalletAdapter-BLUJR23D.js +144 -0
- package/dist/CoinbaseWalletAdapter-IDB2DFH4.mjs +144 -0
- package/dist/EmailAdapter-RUV6JG6Z.mjs +212 -0
- package/dist/EmailAdapter-SY65VHGK.js +212 -0
- package/dist/MetaMaskAdapter-4V3XM6J2.js +152 -0
- package/dist/MetaMaskAdapter-KPNRCMOF.mjs +152 -0
- package/dist/PhantomAdapter-7MB32F5M.mjs +151 -0
- package/dist/PhantomAdapter-YTN5PUDI.js +151 -0
- package/dist/RabbyAdapter-QVNCSWYC.mjs +146 -0
- package/dist/RabbyAdapter-SOLYF74M.js +146 -0
- package/dist/WalletConnectAdapter-5YL5KFGI.mjs +540 -0
- package/dist/WalletConnectAdapter-VMN6R5LO.js +540 -0
- package/dist/{chunk-GMFEFDGS.mjs → chunk-222UJ3OP.mjs} +348 -6778
- package/dist/chunk-4S5E6KOY.mjs +21 -0
- package/dist/{chunk-K64T6WW3.js → chunk-MRORL6L3.js} +420 -6850
- package/dist/chunk-PFK6YHOX.mjs +15 -0
- package/dist/chunk-QOCN4F47.js +21 -0
- package/dist/chunk-RRUPCUSZ.mjs +6558 -0
- package/dist/chunk-XUD6VNF7.js +6558 -0
- package/dist/chunk-XVRTCAR4.js +15 -0
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +304 -1573
- package/dist/index.mjs +243 -1512
- package/dist/{index.web-Q2L3EMC3.mjs → index.web-NX7JZBIY.mjs} +267 -267
- package/dist/{index.web-V7DLWC7H.js → index.web-OPNRZHYZ.js} +267 -267
- package/dist/widgets.d.mts +1 -1
- package/dist/widgets.d.ts +1 -1
- package/dist/widgets.js +14 -12
- package/dist/widgets.mjs +3 -1
- package/package.json +3 -7
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WalletId,
|
|
3
|
+
WalletName,
|
|
4
|
+
getLogoDataUri,
|
|
5
|
+
sentryLogger
|
|
6
|
+
} from "./chunk-RRUPCUSZ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
init_polyfills
|
|
9
|
+
} from "./chunk-J6XFKNJN.mjs";
|
|
10
|
+
|
|
11
|
+
// src/wallet-adapters/MetaMaskAdapter.ts
|
|
12
|
+
init_polyfills();
|
|
13
|
+
var METAMASK_RDNS = "io.metamask";
|
|
14
|
+
var MetaMaskAdapter = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.id = WalletId.MetaMask;
|
|
17
|
+
this.name = WalletName.MetaMask;
|
|
18
|
+
this.icon = getLogoDataUri(WalletId.MetaMask, "brand") ?? "";
|
|
19
|
+
this.hide = false;
|
|
20
|
+
this.downloadUrl = "https://metamask.io/download";
|
|
21
|
+
this.wcDeepLinkUrl = "metamask://wc?uri=";
|
|
22
|
+
this.provider = null;
|
|
23
|
+
this.accountsChangedCallback = null;
|
|
24
|
+
this.providerPromise = null;
|
|
25
|
+
this.providerPromise = this.discoverProvider();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Uses EIP-6963 to discover the MetaMask provider by its RDNS identifier.
|
|
29
|
+
* Falls back to window.ethereum for in-app browser support (MetaMask Mobile).
|
|
30
|
+
* This prevents other wallets (like Rabby) from hijacking the connection.
|
|
31
|
+
*/
|
|
32
|
+
discoverProvider() {
|
|
33
|
+
if (typeof window === "undefined") return Promise.resolve(null);
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let resolved = false;
|
|
36
|
+
const onAnnouncement = (event) => {
|
|
37
|
+
const { detail } = event;
|
|
38
|
+
if (detail.info.rdns === METAMASK_RDNS) {
|
|
39
|
+
resolved = true;
|
|
40
|
+
this.provider = detail.provider;
|
|
41
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
42
|
+
resolve(detail.provider);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
window.addEventListener("eip6963:announceProvider", onAnnouncement);
|
|
46
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
if (!resolved) {
|
|
49
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
50
|
+
const legacyProvider = this.detectLegacyProvider();
|
|
51
|
+
if (legacyProvider) {
|
|
52
|
+
this.provider = legacyProvider;
|
|
53
|
+
}
|
|
54
|
+
resolve(legacyProvider);
|
|
55
|
+
}
|
|
56
|
+
}, 100);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Fallback detection for in-app browsers (MetaMask Mobile) that don't support EIP-6963.
|
|
61
|
+
* Checks window.ethereum for MetaMask-specific flags.
|
|
62
|
+
*/
|
|
63
|
+
detectLegacyProvider() {
|
|
64
|
+
const ethereum = window.ethereum;
|
|
65
|
+
if (!ethereum) return null;
|
|
66
|
+
if (ethereum.providers?.length) {
|
|
67
|
+
const metaMaskProvider = ethereum.providers.find((p) => p.isMetaMask && !p.isBraveWallet);
|
|
68
|
+
if (metaMaskProvider) return metaMaskProvider;
|
|
69
|
+
}
|
|
70
|
+
if (ethereum.isMetaMask && !ethereum.isBraveWallet) {
|
|
71
|
+
return ethereum;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
isInstalled() {
|
|
76
|
+
return Boolean(this.provider ?? this.detectLegacyProvider());
|
|
77
|
+
}
|
|
78
|
+
async connect() {
|
|
79
|
+
if (!this.provider && this.providerPromise) {
|
|
80
|
+
await this.providerPromise;
|
|
81
|
+
}
|
|
82
|
+
if (!this.provider) {
|
|
83
|
+
sentryLogger.error("MetaMask is not available");
|
|
84
|
+
throw new Error("MetaMask is not available");
|
|
85
|
+
}
|
|
86
|
+
await this.provider.request({
|
|
87
|
+
method: "wallet_requestPermissions",
|
|
88
|
+
params: [{ eth_accounts: {} }]
|
|
89
|
+
});
|
|
90
|
+
const accounts = await this.provider.request({
|
|
91
|
+
method: "eth_requestAccounts",
|
|
92
|
+
params: []
|
|
93
|
+
});
|
|
94
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
95
|
+
sentryLogger.error("No accounts returned from MetaMask");
|
|
96
|
+
throw new Error("No accounts returned from MetaMask");
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
address: accounts[0],
|
|
100
|
+
provider: this.provider,
|
|
101
|
+
walletId: this.id
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async tryRestoreConnection() {
|
|
105
|
+
if (!this.provider && this.providerPromise) {
|
|
106
|
+
await this.providerPromise;
|
|
107
|
+
}
|
|
108
|
+
if (!this.provider) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const accounts = await this.provider.request({
|
|
113
|
+
method: "eth_accounts",
|
|
114
|
+
params: []
|
|
115
|
+
});
|
|
116
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
address: accounts[0],
|
|
121
|
+
provider: this.provider,
|
|
122
|
+
walletId: this.id
|
|
123
|
+
};
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async disconnect() {
|
|
129
|
+
}
|
|
130
|
+
getProvider() {
|
|
131
|
+
return this.provider;
|
|
132
|
+
}
|
|
133
|
+
// Called by Aurum when user connects wallet
|
|
134
|
+
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
135
|
+
onAccountsChanged(callback) {
|
|
136
|
+
if (!this.provider?.on) return;
|
|
137
|
+
if (this.accountsChangedCallback) {
|
|
138
|
+
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
139
|
+
}
|
|
140
|
+
this.accountsChangedCallback = callback;
|
|
141
|
+
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
142
|
+
}
|
|
143
|
+
removeListeners() {
|
|
144
|
+
if (!this.provider?.removeListener || !this.accountsChangedCallback) return;
|
|
145
|
+
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
146
|
+
this.accountsChangedCallback = null;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
MetaMaskAdapter
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=MetaMaskAdapter-KPNRCMOF.mjs.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WalletId,
|
|
3
|
+
WalletName,
|
|
4
|
+
getLogoDataUri,
|
|
5
|
+
sentryLogger
|
|
6
|
+
} from "./chunk-RRUPCUSZ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
init_polyfills
|
|
9
|
+
} from "./chunk-J6XFKNJN.mjs";
|
|
10
|
+
|
|
11
|
+
// src/wallet-adapters/PhantomAdapter.ts
|
|
12
|
+
init_polyfills();
|
|
13
|
+
var PHANTOM_RDNS = "app.phantom";
|
|
14
|
+
var PhantomAdapter = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.id = WalletId.Phantom;
|
|
17
|
+
this.name = WalletName.Phantom;
|
|
18
|
+
this.icon = getLogoDataUri(WalletId.Phantom, "brand") ?? "";
|
|
19
|
+
this.hide = false;
|
|
20
|
+
this.downloadUrl = "https://phantom.com/download";
|
|
21
|
+
this.wcDeepLinkUrl = "phantom://wc?uri=";
|
|
22
|
+
this.provider = null;
|
|
23
|
+
this.accountsChangedCallback = null;
|
|
24
|
+
this.providerPromise = null;
|
|
25
|
+
this.providerPromise = this.discoverProvider();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Uses EIP-6963 to discover the Phantom provider by its RDNS identifier.
|
|
29
|
+
* Falls back to window.phantom.ethereum for in-app browser support (Phantom Mobile).
|
|
30
|
+
* This prevents other wallets from hijacking the connection.
|
|
31
|
+
*/
|
|
32
|
+
discoverProvider() {
|
|
33
|
+
if (typeof window === "undefined") return Promise.resolve(null);
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let resolved = false;
|
|
36
|
+
const onAnnouncement = (event) => {
|
|
37
|
+
const { detail } = event;
|
|
38
|
+
if (detail.info.rdns === PHANTOM_RDNS) {
|
|
39
|
+
resolved = true;
|
|
40
|
+
this.provider = detail.provider;
|
|
41
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
42
|
+
resolve(detail.provider);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
window.addEventListener("eip6963:announceProvider", onAnnouncement);
|
|
46
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
if (!resolved) {
|
|
49
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
50
|
+
const legacyProvider = this.detectLegacyProvider();
|
|
51
|
+
if (legacyProvider) {
|
|
52
|
+
this.provider = legacyProvider;
|
|
53
|
+
}
|
|
54
|
+
resolve(legacyProvider);
|
|
55
|
+
}
|
|
56
|
+
}, 100);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Fallback detection for in-app browsers (Phantom Mobile) that don't support EIP-6963.
|
|
61
|
+
* Checks window.phantom.ethereum and window.ethereum for Phantom-specific flags.
|
|
62
|
+
*/
|
|
63
|
+
detectLegacyProvider() {
|
|
64
|
+
const phantom = window.phantom;
|
|
65
|
+
if (phantom?.ethereum?.isPhantom) {
|
|
66
|
+
return phantom.ethereum;
|
|
67
|
+
}
|
|
68
|
+
const ethereum = window.ethereum;
|
|
69
|
+
if (ethereum?.isPhantom) {
|
|
70
|
+
return ethereum;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
isInstalled() {
|
|
75
|
+
return Boolean(this.provider ?? this.detectLegacyProvider());
|
|
76
|
+
}
|
|
77
|
+
async connect() {
|
|
78
|
+
if (!this.provider && this.providerPromise) {
|
|
79
|
+
await this.providerPromise;
|
|
80
|
+
}
|
|
81
|
+
if (!this.provider) {
|
|
82
|
+
sentryLogger.error("Phantom is not available");
|
|
83
|
+
throw new Error("Phantom is not available");
|
|
84
|
+
}
|
|
85
|
+
await this.provider.request({
|
|
86
|
+
method: "wallet_requestPermissions",
|
|
87
|
+
params: [{ eth_accounts: {} }]
|
|
88
|
+
});
|
|
89
|
+
const accounts = await this.provider.request({
|
|
90
|
+
method: "eth_requestAccounts",
|
|
91
|
+
params: []
|
|
92
|
+
});
|
|
93
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
94
|
+
sentryLogger.error("No accounts returned from Phantom");
|
|
95
|
+
throw new Error("No accounts returned from Phantom");
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
address: accounts[0],
|
|
99
|
+
provider: this.provider,
|
|
100
|
+
walletId: this.id
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async tryRestoreConnection() {
|
|
104
|
+
if (!this.provider && this.providerPromise) {
|
|
105
|
+
await this.providerPromise;
|
|
106
|
+
}
|
|
107
|
+
if (!this.provider) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const accounts = await this.provider.request({
|
|
112
|
+
method: "eth_accounts",
|
|
113
|
+
params: []
|
|
114
|
+
});
|
|
115
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
address: accounts[0],
|
|
120
|
+
provider: this.provider,
|
|
121
|
+
walletId: this.id
|
|
122
|
+
};
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async disconnect() {
|
|
128
|
+
}
|
|
129
|
+
getProvider() {
|
|
130
|
+
return this.provider;
|
|
131
|
+
}
|
|
132
|
+
// Called by Aurum when user connects wallet
|
|
133
|
+
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
134
|
+
onAccountsChanged(callback) {
|
|
135
|
+
if (!this.provider?.on) return;
|
|
136
|
+
if (this.accountsChangedCallback) {
|
|
137
|
+
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
138
|
+
}
|
|
139
|
+
this.accountsChangedCallback = callback;
|
|
140
|
+
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
141
|
+
}
|
|
142
|
+
removeListeners() {
|
|
143
|
+
if (!this.provider?.removeListener || !this.accountsChangedCallback) return;
|
|
144
|
+
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
145
|
+
this.accountsChangedCallback = null;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
export {
|
|
149
|
+
PhantomAdapter
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=PhantomAdapter-7MB32F5M.mjs.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkXUD6VNF7js = require('./chunk-XUD6VNF7.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkQIPVNM7Tjs = require('./chunk-QIPVNM7T.js');
|
|
10
|
+
|
|
11
|
+
// src/wallet-adapters/PhantomAdapter.ts
|
|
12
|
+
_chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
13
|
+
var PHANTOM_RDNS = "app.phantom";
|
|
14
|
+
var PhantomAdapter = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.id = _chunkXUD6VNF7js.WalletId.Phantom;
|
|
17
|
+
this.name = _chunkXUD6VNF7js.WalletName.Phantom;
|
|
18
|
+
this.icon = _nullishCoalesce(_chunkXUD6VNF7js.getLogoDataUri.call(void 0, _chunkXUD6VNF7js.WalletId.Phantom, "brand"), () => ( ""));
|
|
19
|
+
this.hide = false;
|
|
20
|
+
this.downloadUrl = "https://phantom.com/download";
|
|
21
|
+
this.wcDeepLinkUrl = "phantom://wc?uri=";
|
|
22
|
+
this.provider = null;
|
|
23
|
+
this.accountsChangedCallback = null;
|
|
24
|
+
this.providerPromise = null;
|
|
25
|
+
this.providerPromise = this.discoverProvider();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Uses EIP-6963 to discover the Phantom provider by its RDNS identifier.
|
|
29
|
+
* Falls back to window.phantom.ethereum for in-app browser support (Phantom Mobile).
|
|
30
|
+
* This prevents other wallets from hijacking the connection.
|
|
31
|
+
*/
|
|
32
|
+
discoverProvider() {
|
|
33
|
+
if (typeof window === "undefined") return Promise.resolve(null);
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let resolved = false;
|
|
36
|
+
const onAnnouncement = (event) => {
|
|
37
|
+
const { detail } = event;
|
|
38
|
+
if (detail.info.rdns === PHANTOM_RDNS) {
|
|
39
|
+
resolved = true;
|
|
40
|
+
this.provider = detail.provider;
|
|
41
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
42
|
+
resolve(detail.provider);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
window.addEventListener("eip6963:announceProvider", onAnnouncement);
|
|
46
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
if (!resolved) {
|
|
49
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
50
|
+
const legacyProvider = this.detectLegacyProvider();
|
|
51
|
+
if (legacyProvider) {
|
|
52
|
+
this.provider = legacyProvider;
|
|
53
|
+
}
|
|
54
|
+
resolve(legacyProvider);
|
|
55
|
+
}
|
|
56
|
+
}, 100);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Fallback detection for in-app browsers (Phantom Mobile) that don't support EIP-6963.
|
|
61
|
+
* Checks window.phantom.ethereum and window.ethereum for Phantom-specific flags.
|
|
62
|
+
*/
|
|
63
|
+
detectLegacyProvider() {
|
|
64
|
+
const phantom = window.phantom;
|
|
65
|
+
if (_optionalChain([phantom, 'optionalAccess', _ => _.ethereum, 'optionalAccess', _2 => _2.isPhantom])) {
|
|
66
|
+
return phantom.ethereum;
|
|
67
|
+
}
|
|
68
|
+
const ethereum = window.ethereum;
|
|
69
|
+
if (_optionalChain([ethereum, 'optionalAccess', _3 => _3.isPhantom])) {
|
|
70
|
+
return ethereum;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
isInstalled() {
|
|
75
|
+
return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
|
|
76
|
+
}
|
|
77
|
+
async connect() {
|
|
78
|
+
if (!this.provider && this.providerPromise) {
|
|
79
|
+
await this.providerPromise;
|
|
80
|
+
}
|
|
81
|
+
if (!this.provider) {
|
|
82
|
+
_chunkXUD6VNF7js.sentryLogger.error("Phantom is not available");
|
|
83
|
+
throw new Error("Phantom is not available");
|
|
84
|
+
}
|
|
85
|
+
await this.provider.request({
|
|
86
|
+
method: "wallet_requestPermissions",
|
|
87
|
+
params: [{ eth_accounts: {} }]
|
|
88
|
+
});
|
|
89
|
+
const accounts = await this.provider.request({
|
|
90
|
+
method: "eth_requestAccounts",
|
|
91
|
+
params: []
|
|
92
|
+
});
|
|
93
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
94
|
+
_chunkXUD6VNF7js.sentryLogger.error("No accounts returned from Phantom");
|
|
95
|
+
throw new Error("No accounts returned from Phantom");
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
address: accounts[0],
|
|
99
|
+
provider: this.provider,
|
|
100
|
+
walletId: this.id
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async tryRestoreConnection() {
|
|
104
|
+
if (!this.provider && this.providerPromise) {
|
|
105
|
+
await this.providerPromise;
|
|
106
|
+
}
|
|
107
|
+
if (!this.provider) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const accounts = await this.provider.request({
|
|
112
|
+
method: "eth_accounts",
|
|
113
|
+
params: []
|
|
114
|
+
});
|
|
115
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
address: accounts[0],
|
|
120
|
+
provider: this.provider,
|
|
121
|
+
walletId: this.id
|
|
122
|
+
};
|
|
123
|
+
} catch (e) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async disconnect() {
|
|
128
|
+
}
|
|
129
|
+
getProvider() {
|
|
130
|
+
return this.provider;
|
|
131
|
+
}
|
|
132
|
+
// Called by Aurum when user connects wallet
|
|
133
|
+
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
134
|
+
onAccountsChanged(callback) {
|
|
135
|
+
if (!_optionalChain([this, 'access', _4 => _4.provider, 'optionalAccess', _5 => _5.on])) return;
|
|
136
|
+
if (this.accountsChangedCallback) {
|
|
137
|
+
_optionalChain([this, 'access', _6 => _6.provider, 'access', _7 => _7.removeListener, 'optionalCall', _8 => _8("accountsChanged", this.accountsChangedCallback)]);
|
|
138
|
+
}
|
|
139
|
+
this.accountsChangedCallback = callback;
|
|
140
|
+
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
141
|
+
}
|
|
142
|
+
removeListeners() {
|
|
143
|
+
if (!_optionalChain([this, 'access', _9 => _9.provider, 'optionalAccess', _10 => _10.removeListener]) || !this.accountsChangedCallback) return;
|
|
144
|
+
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
145
|
+
this.accountsChangedCallback = null;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
exports.PhantomAdapter = PhantomAdapter;
|
|
151
|
+
//# sourceMappingURL=PhantomAdapter-YTN5PUDI.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WalletId,
|
|
3
|
+
WalletName,
|
|
4
|
+
getLogoDataUri,
|
|
5
|
+
sentryLogger
|
|
6
|
+
} from "./chunk-RRUPCUSZ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
init_polyfills
|
|
9
|
+
} from "./chunk-J6XFKNJN.mjs";
|
|
10
|
+
|
|
11
|
+
// src/wallet-adapters/RabbyAdapter.ts
|
|
12
|
+
init_polyfills();
|
|
13
|
+
var RABBY_RDNS = "io.rabby";
|
|
14
|
+
var RabbyAdapter = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.id = WalletId.Rabby;
|
|
17
|
+
this.name = WalletName.Rabby;
|
|
18
|
+
this.icon = getLogoDataUri(WalletId.Rabby, "brand") ?? "";
|
|
19
|
+
this.hide = false;
|
|
20
|
+
this.downloadUrl = "https://rabby.io";
|
|
21
|
+
this.wcDeepLinkUrl = null;
|
|
22
|
+
this.provider = null;
|
|
23
|
+
this.accountsChangedCallback = null;
|
|
24
|
+
this.providerPromise = null;
|
|
25
|
+
this.providerPromise = this.discoverProvider();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Uses EIP-6963 to discover the Rabby provider by its RDNS identifier.
|
|
29
|
+
* Falls back to window.ethereum for legacy detection.
|
|
30
|
+
*/
|
|
31
|
+
discoverProvider() {
|
|
32
|
+
if (typeof window === "undefined") return Promise.resolve(null);
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
let resolved = false;
|
|
35
|
+
const onAnnouncement = (event) => {
|
|
36
|
+
const { detail } = event;
|
|
37
|
+
if (detail.info.rdns === RABBY_RDNS) {
|
|
38
|
+
resolved = true;
|
|
39
|
+
this.provider = detail.provider;
|
|
40
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
41
|
+
resolve(detail.provider);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
window.addEventListener("eip6963:announceProvider", onAnnouncement);
|
|
45
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
if (!resolved) {
|
|
48
|
+
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
49
|
+
const legacyProvider = this.detectLegacyProvider();
|
|
50
|
+
if (legacyProvider) {
|
|
51
|
+
this.provider = legacyProvider;
|
|
52
|
+
}
|
|
53
|
+
resolve(legacyProvider);
|
|
54
|
+
}
|
|
55
|
+
}, 100);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Fallback detection for legacy Rabby installations.
|
|
60
|
+
* Checks window.ethereum for Rabby-specific flags.
|
|
61
|
+
*/
|
|
62
|
+
detectLegacyProvider() {
|
|
63
|
+
const ethereum = window.ethereum;
|
|
64
|
+
if (ethereum?.isRabby) {
|
|
65
|
+
return ethereum;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
isInstalled() {
|
|
70
|
+
return Boolean(this.provider ?? this.detectLegacyProvider());
|
|
71
|
+
}
|
|
72
|
+
async connect() {
|
|
73
|
+
if (!this.provider && this.providerPromise) {
|
|
74
|
+
await this.providerPromise;
|
|
75
|
+
}
|
|
76
|
+
if (!this.provider) {
|
|
77
|
+
sentryLogger.error("Rabby is not available");
|
|
78
|
+
throw new Error("Rabby is not available");
|
|
79
|
+
}
|
|
80
|
+
await this.provider.request({
|
|
81
|
+
method: "wallet_requestPermissions",
|
|
82
|
+
params: [{ eth_accounts: {} }]
|
|
83
|
+
});
|
|
84
|
+
const accounts = await this.provider.request({
|
|
85
|
+
method: "eth_requestAccounts",
|
|
86
|
+
params: []
|
|
87
|
+
});
|
|
88
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
89
|
+
sentryLogger.error("No accounts returned from Rabby");
|
|
90
|
+
throw new Error("No accounts returned from Rabby");
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
address: accounts[0],
|
|
94
|
+
provider: this.provider,
|
|
95
|
+
walletId: this.id
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async tryRestoreConnection() {
|
|
99
|
+
if (!this.provider && this.providerPromise) {
|
|
100
|
+
await this.providerPromise;
|
|
101
|
+
}
|
|
102
|
+
if (!this.provider) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const accounts = await this.provider.request({
|
|
107
|
+
method: "eth_accounts",
|
|
108
|
+
params: []
|
|
109
|
+
});
|
|
110
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
address: accounts[0],
|
|
115
|
+
provider: this.provider,
|
|
116
|
+
walletId: this.id
|
|
117
|
+
};
|
|
118
|
+
} catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async disconnect() {
|
|
123
|
+
}
|
|
124
|
+
getProvider() {
|
|
125
|
+
return this.provider;
|
|
126
|
+
}
|
|
127
|
+
// Called by Aurum when user connects wallet
|
|
128
|
+
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
129
|
+
onAccountsChanged(callback) {
|
|
130
|
+
if (!this.provider?.on) return;
|
|
131
|
+
if (this.accountsChangedCallback) {
|
|
132
|
+
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
133
|
+
}
|
|
134
|
+
this.accountsChangedCallback = callback;
|
|
135
|
+
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
136
|
+
}
|
|
137
|
+
removeListeners() {
|
|
138
|
+
if (!this.provider?.removeListener || !this.accountsChangedCallback) return;
|
|
139
|
+
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
140
|
+
this.accountsChangedCallback = null;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export {
|
|
144
|
+
RabbyAdapter
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=RabbyAdapter-QVNCSWYC.mjs.map
|