@cartridge/controller 0.7.11 → 0.7.12

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { WalletAccount as L, shortString as M, num as O } from "starknet";
2
- import { R as A, t as Y, K as $, P as W, B as H, N as u, p as K, A as q } from "./provider-CyO7_h7r.js";
3
- import { F as Oe, h as Ye, n as $e, a as We, b as He } from "./provider-CyO7_h7r.js";
2
+ import { R as A, t as Y, K as $, P as W, B as H, N as u, p as K, A as q } from "./provider-BN3lM6-S.js";
3
+ import { F as Oe, h as Ye, n as $e, a as We, b as He } from "./provider-BN3lM6-S.js";
4
4
  import { MetaMaskSDK as G } from "@metamask/sdk";
5
5
  import { Transaction as V } from "@solana/web3.js";
6
6
  import { connect as J } from "starknetkit";
@@ -86,10 +86,10 @@ var C;
86
86
  (function(o) {
87
87
  o.Fulfilled = "fulfilled", o.Rejected = "rejected";
88
88
  })(C || (C = {}));
89
- var E;
89
+ var R;
90
90
  (function(o) {
91
91
  o.ConnectionDestroyed = "ConnectionDestroyed", o.ConnectionTimeout = "ConnectionTimeout", o.NoIframeSrc = "NoIframeSrc";
92
- })(E || (E = {}));
92
+ })(R || (R = {}));
93
93
  var D;
94
94
  (function(o) {
95
95
  o.DataCloneError = "DataCloneError";
@@ -117,7 +117,7 @@ const Z = (o, e) => {
117
117
  "http:": "80",
118
118
  "https:": "443"
119
119
  }, ne = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, oe = ["file:", "data:"], re = (o) => {
120
- if (o && oe.find((s) => o.startsWith(s)))
120
+ if (o && oe.find((i) => o.startsWith(i)))
121
121
  return "null";
122
122
  const e = document.location, t = ne.exec(o);
123
123
  let n, r, a;
@@ -132,31 +132,31 @@ const Z = (o, e) => {
132
132
  const e = new Error();
133
133
  return Object.keys(o).forEach((t) => e[t] = o[t]), e;
134
134
  }, ie = (o, e, t) => {
135
- const { localName: n, local: r, remote: a, originForSending: c, originForReceiving: s } = o;
136
- let i = !1;
135
+ const { localName: n, local: r, remote: a, originForSending: c, originForReceiving: i } = o;
136
+ let s = !1;
137
137
  const l = (d) => {
138
138
  if (d.source !== a || d.data.penpal !== y.Call)
139
139
  return;
140
- if (s !== "*" && d.origin !== s) {
141
- t(`${n} received message from origin ${d.origin} which did not match expected origin ${s}`);
140
+ if (i !== "*" && d.origin !== i) {
141
+ t(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
142
142
  return;
143
143
  }
144
144
  const p = d.data, { methodName: h, args: g, id: f } = p;
145
145
  t(`${n}: Received ${h}() call`);
146
- const w = (b) => (k) => {
147
- if (t(`${n}: Sending ${h}() reply`), i) {
146
+ const v = (b) => (k) => {
147
+ if (t(`${n}: Sending ${h}() reply`), s) {
148
148
  t(`${n}: Unable to send ${h}() reply due to destroyed connection`);
149
149
  return;
150
150
  }
151
- const v = {
151
+ const w = {
152
152
  penpal: y.Reply,
153
153
  id: f,
154
154
  resolution: b,
155
155
  returnValue: k
156
156
  };
157
- b === C.Rejected && k instanceof Error && (v.returnValue = N(k), v.returnValueIsError = !0);
157
+ b === C.Rejected && k instanceof Error && (w.returnValue = N(k), w.returnValueIsError = !0);
158
158
  try {
159
- a.postMessage(v, c);
159
+ a.postMessage(w, c);
160
160
  } catch (m) {
161
161
  if (m.name === D.DataCloneError) {
162
162
  const I = {
@@ -171,10 +171,10 @@ const Z = (o, e) => {
171
171
  throw m;
172
172
  }
173
173
  };
174
- new Promise((b) => b(e[h].call(e, d.origin).apply(e, g))).then(w(C.Fulfilled), w(C.Rejected));
174
+ new Promise((b) => b(e[h].call(e, d.origin).apply(e, g))).then(v(C.Fulfilled), v(C.Rejected));
175
175
  };
176
176
  return r.addEventListener(_.Message, l), () => {
177
- i = !0, r.removeEventListener(_.Message, l);
177
+ s = !0, r.removeEventListener(_.Message, l);
178
178
  };
179
179
  };
180
180
  let se = 0;
@@ -196,42 +196,42 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
196
196
  le(e, t, o[t]);
197
197
  return e;
198
198
  }, me = (o, e, t, n, r) => {
199
- const { localName: a, local: c, remote: s, originForSending: i, originForReceiving: l } = e;
199
+ const { localName: a, local: c, remote: i, originForSending: s, originForReceiving: l } = e;
200
200
  let d = !1;
201
201
  r(`${a}: Connecting call sender`);
202
202
  const p = (g) => (...f) => {
203
203
  r(`${a}: Sending ${g}() call`);
204
- let w;
204
+ let v;
205
205
  try {
206
- s.closed && (w = !0);
206
+ i.closed && (v = !0);
207
207
  } catch {
208
- w = !0;
208
+ v = !0;
209
209
  }
210
- if (w && n(), d) {
210
+ if (v && n(), d) {
211
211
  const b = new Error(`Unable to send ${g}() call due to destroyed connection`);
212
- throw b.code = E.ConnectionDestroyed, b;
212
+ throw b.code = R.ConnectionDestroyed, b;
213
213
  }
214
214
  return new Promise((b, k) => {
215
- const v = ce(), m = (x) => {
216
- if (x.source !== s || x.data.penpal !== y.Reply || x.data.id !== v)
215
+ const w = ce(), m = (x) => {
216
+ if (x.source !== i || x.data.penpal !== y.Reply || x.data.id !== w)
217
217
  return;
218
218
  if (l !== "*" && x.origin !== l) {
219
219
  r(`${a} received message from origin ${x.origin} which did not match expected origin ${l}`);
220
220
  return;
221
221
  }
222
- const R = x.data;
222
+ const E = x.data;
223
223
  r(`${a}: Received ${g}() reply`), c.removeEventListener(_.Message, m);
224
- let P = R.returnValue;
225
- R.returnValueIsError && (P = ae(P)), (R.resolution === C.Fulfilled ? b : k)(P);
224
+ let P = E.returnValue;
225
+ E.returnValueIsError && (P = ae(P)), (E.resolution === C.Fulfilled ? b : k)(P);
226
226
  };
227
227
  c.addEventListener(_.Message, m);
228
228
  const I = {
229
229
  penpal: y.Call,
230
- id: v,
230
+ id: w,
231
231
  methodName: g,
232
232
  args: f
233
233
  };
234
- s.postMessage(I, i);
234
+ i.postMessage(I, s);
235
235
  });
236
236
  }, h = t.reduce((g, f) => (g[f] = p(f), g), {});
237
237
  return Object.assign(o, ge(h)), () => {
@@ -239,7 +239,7 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
239
239
  };
240
240
  }, he = (o, e, t, n, r) => {
241
241
  const { destroy: a, onDestroy: c } = n;
242
- let s, i;
242
+ let i, s;
243
243
  const l = {};
244
244
  return (d) => {
245
245
  if (e !== "*" && d.origin !== e) {
@@ -254,10 +254,10 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
254
254
  originForSending: t,
255
255
  originForReceiving: e
256
256
  };
257
- s && s(), s = ie(p, o, r), c(s), i && i.forEach((g) => {
257
+ i && i(), i = ie(p, o, r), c(i), s && s.forEach((g) => {
258
258
  delete l[g];
259
- }), i = d.data.methodNames;
260
- const h = me(l, p, i, a, r);
259
+ }), s = d.data.methodNames;
260
+ const h = me(l, p, s, a, r);
261
261
  return c(h), l;
262
262
  };
263
263
  }, fe = (o, e, t, n) => (r) => {
@@ -284,23 +284,23 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
284
284
  let t;
285
285
  return o !== void 0 && (t = window.setTimeout(() => {
286
286
  const n = new Error(`Connection timed out after ${o}ms`);
287
- n.code = E.ConnectionTimeout, e(n);
287
+ n.code = R.ConnectionTimeout, e(n);
288
288
  }, o)), () => {
289
289
  clearTimeout(t);
290
290
  };
291
- }, ve = (o) => {
291
+ }, we = (o) => {
292
292
  if (!o.src && !o.srcdoc) {
293
293
  const e = new Error("Iframe must have src or srcdoc property defined.");
294
- throw e.code = E.NoIframeSrc, e;
294
+ throw e.code = R.NoIframeSrc, e;
295
295
  }
296
- }, we = (o) => {
296
+ }, ve = (o) => {
297
297
  let { iframe: e, methods: t = {}, childOrigin: n, timeout: r, debug: a = !1 } = o;
298
- const c = ee(a), s = Z("Parent", c), { onDestroy: i, destroy: l } = s;
299
- n || (ve(e), n = re(e.src));
300
- const d = n === "null" ? "*" : n, p = T(t), h = fe(c, p, n, d), g = he(p, n, d, s, c);
298
+ const c = ee(a), i = Z("Parent", c), { onDestroy: s, destroy: l } = i;
299
+ n || (we(e), n = re(e.src));
300
+ const d = n === "null" ? "*" : n, p = T(t), h = fe(c, p, n, d), g = he(p, n, d, i, c);
301
301
  return {
302
- promise: new Promise((w, b) => {
303
- const k = ye(r, l), v = (m) => {
302
+ promise: new Promise((v, b) => {
303
+ const k = ye(r, l), w = (m) => {
304
304
  if (!(m.source !== e.contentWindow || !m.data)) {
305
305
  if (m.data.penpal === y.Syn) {
306
306
  h(m);
@@ -308,13 +308,13 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
308
308
  }
309
309
  if (m.data.penpal === y.Ack) {
310
310
  const I = g(m);
311
- I && (k(), w(I));
311
+ I && (k(), v(I));
312
312
  return;
313
313
  }
314
314
  }
315
315
  };
316
- window.addEventListener(_.Message, v), c("Parent: Awaiting handshake"), ue(e, s), i((m) => {
317
- window.removeEventListener(_.Message, v), m && b(m);
316
+ window.addEventListener(_.Message, w), c("Parent: Awaiting handshake"), ue(e, i), s((m) => {
317
+ window.removeEventListener(_.Message, w), m && b(m);
318
318
  });
319
319
  }),
320
320
  destroy() {
@@ -338,10 +338,10 @@ class Q {
338
338
  if (typeof document > "u")
339
339
  return;
340
340
  n && t.searchParams.set("preset", n), this.url = t;
341
- const s = document.createElement("iframe");
342
- s.src = t.toString(), s.id = e, s.style.border = "none", s.sandbox.add("allow-forms"), s.sandbox.add("allow-popups"), s.sandbox.add("allow-scripts"), s.sandbox.add("allow-same-origin"), s.allow = "publickey-credentials-create *; publickey-credentials-get *; clipboard-write", document.hasStorageAccess && s.sandbox.add("allow-storage-access-by-user-activation");
343
- const i = document.createElement("div");
344
- i.id = "controller", i.style.position = "fixed", i.style.height = "100%", i.style.width = "100%", i.style.top = "0", i.style.left = "0", i.style.zIndex = "10000", i.style.backgroundColor = "rgba(0,0,0,0.6)", i.style.display = "flex", i.style.alignItems = "center", i.style.justifyContent = "center", i.style.visibility = "hidden", i.style.opacity = "0", i.style.transition = "opacity 0.2s ease", i.style.pointerEvents = "auto", i.appendChild(s), this.iframe = s, this.container = i, we({
341
+ const i = document.createElement("iframe");
342
+ i.src = t.toString(), i.id = e, i.style.border = "none", i.sandbox.add("allow-forms"), i.sandbox.add("allow-popups"), i.sandbox.add("allow-scripts"), i.sandbox.add("allow-same-origin"), i.allow = "publickey-credentials-create *; publickey-credentials-get *; clipboard-write", document.hasStorageAccess && i.sandbox.add("allow-storage-access-by-user-activation");
343
+ const s = document.createElement("div");
344
+ s.id = "controller", s.style.position = "fixed", s.style.height = "100%", s.style.width = "100%", s.style.top = "0", s.style.left = "0", s.style.zIndex = "10000", s.style.backgroundColor = "rgba(0,0,0,0.6)", s.style.display = "flex", s.style.alignItems = "center", s.style.justifyContent = "center", s.style.visibility = "hidden", s.style.opacity = "0", s.style.transition = "opacity 0.2s ease", s.style.pointerEvents = "auto", s.appendChild(i), this.iframe = i, this.container = s, ve({
345
345
  iframe: this.iframe,
346
346
  methods: {
347
347
  close: (p) => () => this.close(),
@@ -359,14 +359,14 @@ class Q {
359
359
  }).promise.then(a), this.resize(), window.addEventListener("resize", () => this.resize());
360
360
  const l = new MutationObserver(() => {
361
361
  const p = document.getElementById("controller");
362
- document.body && (e === "controller-keychain" && !p || e === "controller-profile") && (document.body.appendChild(i), l.disconnect());
362
+ document.body && (e === "controller-keychain" && !p || e === "controller-profile") && (document.body.appendChild(s), l.disconnect());
363
363
  });
364
364
  l.observe(document.documentElement, {
365
365
  childList: !0,
366
366
  subtree: !0
367
367
  });
368
368
  const d = document.getElementById("controller");
369
- document.body && (e === "controller-keychain" && !d || e === "controller-profile") && document.body.appendChild(i), this.onClose = r;
369
+ document.body && (e === "controller-keychain" && !d || e === "controller-profile") && document.body.appendChild(s), this.onClose = r;
370
370
  }
371
371
  open() {
372
372
  this.container && (document.body.style.overflow = "hidden", this.container.style.visibility = "visible", this.container.style.opacity = "1");
@@ -733,7 +733,8 @@ class Ae {
733
733
  }
734
734
  class Ce {
735
735
  walletAdapters;
736
- connectedWallets = /* @__PURE__ */ new Map();
736
+ connectedWalletsByType = /* @__PURE__ */ new Map();
737
+ connectedWalletsByAddress = /* @__PURE__ */ new Map();
737
738
  constructor() {
738
739
  this.walletAdapters = /* @__PURE__ */ new Map(), this.walletAdapters.set("metamask", new _e()), this.walletAdapters.set("phantom", new ke()), this.walletAdapters.set("argent", new Ae()), typeof window < "u" && (window.wallet_bridge = this);
739
740
  }
@@ -752,64 +753,114 @@ class Ce {
752
753
  (t) => t.getInfo()
753
754
  );
754
755
  }
755
- getWalletAdapter(e) {
756
+ getWalletAdapterByType(e) {
756
757
  const t = this.walletAdapters.get(e);
757
758
  if (!t)
758
759
  throw new Error(`Unsupported wallet type: ${e}`);
759
760
  return t;
760
761
  }
761
- handleError(e, t, n) {
762
- const r = t instanceof Error ? t.message : "Unknown error";
763
- return console.error(`Error ${n} with ${e} wallet:`, t), { success: !1, wallet: e, error: r };
762
+ handleError(e, t, n, r) {
763
+ const a = t instanceof Error ? t.message : "Unknown error";
764
+ let c = "unknown";
765
+ if (typeof e == "string") {
766
+ const i = this.connectedWalletsByAddress.get(e);
767
+ c = r ?? i?.type ?? e;
768
+ } else
769
+ c = e;
770
+ return console.error(`Error ${n} with ${e} wallet:`, t), {
771
+ success: !1,
772
+ wallet: c,
773
+ error: a
774
+ };
764
775
  }
765
776
  async connectWallet(e) {
766
777
  try {
767
- const t = this.getWalletAdapter(e), n = await t.connect();
768
- return n.success && this.connectedWallets.set(e, t), n;
778
+ const t = this.getWalletAdapterByType(e), n = await t.connect();
779
+ if (n.success && n.account)
780
+ this.connectedWalletsByType.set(e, t), this.connectedWalletsByAddress.set(n.account, t), console.log(
781
+ `Wallet ${e} connected with address ${n.account}`
782
+ );
783
+ else if (n.success && !n.account)
784
+ return console.error(
785
+ `Wallet ${e} connected successfully but did not provide an address.`
786
+ ), {
787
+ ...n,
788
+ success: !1,
789
+ error: "Wallet connected but address not found."
790
+ };
791
+ return n;
769
792
  } catch (t) {
770
793
  return this.handleError(e, t, "connecting to");
771
794
  }
772
795
  }
796
+ getConnectedWalletAdapter(e) {
797
+ let t;
798
+ if (typeof e == "string" ? t = this.connectedWalletsByAddress.get(e) : t = this.connectedWalletsByType.get(e), !t && typeof e == "string" && (t = this.connectedWalletsByType.get(
799
+ e
800
+ )), !t)
801
+ throw new Error(
802
+ `Wallet with identifier ${e} is not connected or supported`
803
+ );
804
+ return t;
805
+ }
773
806
  async signMessage(e, t) {
807
+ let n;
774
808
  try {
775
- if (!this.connectedWallets.has(e))
776
- throw new Error(`Wallet ${e} is not connected`);
777
- const n = this.connectedWallets.get(e);
778
- if (!n.signMessage)
779
- throw new Error(`Wallet ${e} does not support signing messages`);
809
+ if (n = this.getConnectedWalletAdapter(e), !n.signMessage)
810
+ throw new Error(
811
+ `Wallet type ${n.type} (identifier: ${e}) does not support signing messages`
812
+ );
780
813
  return await n.signMessage(t);
781
- } catch (n) {
782
- return this.handleError(e, n, "signing message with");
814
+ } catch (r) {
815
+ return this.handleError(
816
+ e,
817
+ r,
818
+ "signing message with",
819
+ n?.type
820
+ );
783
821
  }
784
822
  }
785
823
  async signTypedData(e, t) {
824
+ let n;
786
825
  try {
787
- if (!this.connectedWallets.has(e))
788
- throw new Error(`Wallet ${e} is not connected`);
789
- const n = this.connectedWallets.get(e);
790
- if (!n.signTypedData)
791
- throw new Error(`Wallet ${e} does not support signing typed data`);
826
+ if (n = this.getConnectedWalletAdapter(e), !n.signTypedData)
827
+ throw new Error(
828
+ `Wallet type ${n.type} (identifier: ${e}) does not support signing typed data`
829
+ );
792
830
  return await n.signTypedData(t);
793
- } catch (n) {
794
- return this.handleError(e, n, "signing typed data with");
831
+ } catch (r) {
832
+ return this.handleError(
833
+ e,
834
+ r,
835
+ "signing typed data with",
836
+ n?.type
837
+ );
795
838
  }
796
839
  }
797
840
  async sendTransaction(e, t) {
841
+ let n;
798
842
  try {
799
- if (!this.connectedWallets.has(e))
800
- throw new Error(`Wallet ${e} is not connected`);
801
- return await this.connectedWallets.get(e).sendTransaction(t);
802
- } catch (n) {
803
- return this.handleError(e, n, "sending transaction with");
843
+ return n = this.getConnectedWalletAdapter(e), await n.sendTransaction(t);
844
+ } catch (r) {
845
+ return this.handleError(
846
+ e,
847
+ r,
848
+ "sending transaction with",
849
+ n?.type
850
+ );
804
851
  }
805
852
  }
806
853
  async getBalance(e, t) {
854
+ let n;
807
855
  try {
808
- if (!this.connectedWallets.has(e))
809
- throw new Error(`Wallet ${e} is not connected`);
810
- return await this.connectedWallets.get(e).getBalance(t);
811
- } catch (n) {
812
- return this.handleError(e, n, "getting balance from");
856
+ return n = this.getConnectedWalletAdapter(e), await n.getBalance(t);
857
+ } catch (r) {
858
+ return this.handleError(
859
+ e,
860
+ r,
861
+ "getting balance from",
862
+ n?.type
863
+ );
813
864
  }
814
865
  }
815
866
  }
@@ -825,7 +876,7 @@ class Ie extends Q {
825
876
  id: "controller-keychain",
826
877
  url: r,
827
878
  methods: a.getIFrameMethods()
828
- }), this.walletBridge = a;
879
+ }), this.walletBridge = a, typeof window < "u" && (window.external_wallets = this.walletBridge);
829
880
  }
830
881
  getWalletBridge() {
831
882
  return this.walletBridge;
@@ -839,19 +890,19 @@ class xe extends Q {
839
890
  username: r,
840
891
  slot: a,
841
892
  namespace: c,
842
- tokens: s,
843
- policies: i,
893
+ tokens: i,
894
+ policies: s,
844
895
  ...l
845
896
  }) {
846
897
  const d = (e || W).replace(/\/$/, "");
847
898
  let p = new URL(
848
899
  a ? `${d}/account/${r}/slot/${a}` : `${d}/account/${r}`
849
900
  );
850
- if (a && p.searchParams.set("ps", encodeURIComponent(a)), c && p.searchParams.set("ns", encodeURIComponent(c)), n && p.searchParams.set("v", encodeURIComponent(n)), p.searchParams.set("rpcUrl", encodeURIComponent(t)), s?.erc20 && p.searchParams.set(
901
+ if (a && p.searchParams.set("ps", encodeURIComponent(a)), c && p.searchParams.set("ns", encodeURIComponent(c)), n && p.searchParams.set("v", encodeURIComponent(n)), p.searchParams.set("rpcUrl", encodeURIComponent(t)), i?.erc20 && p.searchParams.set(
851
902
  "erc20",
852
- encodeURIComponent(s.erc20.toString())
853
- ), i?.contracts) {
854
- const h = Object.values(i.contracts).flatMap(
903
+ encodeURIComponent(i.erc20.toString())
904
+ ), s?.contracts) {
905
+ const h = Object.values(s.contracts).flatMap(
855
906
  (g) => g.methods
856
907
  );
857
908
  p.searchParams.set(
@@ -1047,7 +1098,7 @@ class Ne extends H {
1047
1098
  }
1048
1099
  this.iframes.profile.close(), this.iframes.keychain.open(), this.keychain.openPurchaseCredits();
1049
1100
  }
1050
- openStarterPack() {
1101
+ openStarterPack(e) {
1051
1102
  if (!this.keychain || !this.iframes.keychain) {
1052
1103
  console.error(new u().message);
1053
1104
  return;
@@ -1056,7 +1107,7 @@ class Ne extends H {
1056
1107
  console.error("Profile is not ready");
1057
1108
  return;
1058
1109
  }
1059
- this.iframes.profile.close(), this.iframes.keychain.open(), this.keychain.openStarterPack();
1110
+ this.iframes.profile.close(), this.iframes.keychain.open(), this.keychain.openStarterPack(e);
1060
1111
  }
1061
1112
  async openExecute(e, t) {
1062
1113
  if (!this.keychain || !this.iframes.keychain) {
@@ -1070,7 +1121,10 @@ class Ne extends H {
1070
1121
  let n = this.selectedChain;
1071
1122
  t && this.switchStarknetChain(t), this.iframes.profile?.sendBackward(), this.iframes.keychain.open(), this.iframes.profile?.close();
1072
1123
  const r = await this.keychain.execute(e, void 0, void 0, !0);
1073
- return this.iframes.profile?.open(), this.iframes.keychain.close(), this.iframes.profile?.sendForward(), t && this.switchStarknetChain(n), !(r && (r.code === A.NOT_CONNECTED || r.code === A.CANCELED));
1124
+ return this.iframes.profile?.open(), this.iframes.keychain.close(), this.iframes.profile?.sendForward(), t && this.switchStarknetChain(n), {
1125
+ status: !(r && (r.code === A.NOT_CONNECTED || r.code === A.CANCELED)),
1126
+ transactionHash: r?.transaction_hash
1127
+ };
1074
1128
  }
1075
1129
  async delegateAccount() {
1076
1130
  return this.keychain ? await this.keychain.delegateAccount() : (console.error(new u().message), null);