@cartridge/controller 0.7.11 → 0.7.13-alpha.1

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-BDCJkGu6.js";
3
+ import { F as Oe, h as Ye, n as $e, a as We, b as He } from "./provider-BDCJkGu6.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 S;
90
90
  (function(o) {
91
91
  o.ConnectionDestroyed = "ConnectionDestroyed", o.ConnectionTimeout = "ConnectionTimeout", o.NoIframeSrc = "NoIframeSrc";
92
- })(E || (E = {}));
92
+ })(S || (S = {}));
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 = S.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 = S.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 = S.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");
@@ -610,7 +610,7 @@ class ke {
610
610
  if (!this.isAvailable() || !this.account)
611
611
  throw new Error("Phantom is not connected");
612
612
  try {
613
- const t = V.from(Buffer.from(e, "base64")), r = await this.getProvider().signAndSendTransaction(t);
613
+ const t = V.from(e), r = await this.getProvider().signAndSendTransaction(t);
614
614
  return {
615
615
  success: !0,
616
616
  wallet: this.type,
@@ -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);
@@ -1102,7 +1156,7 @@ class Ne extends H {
1102
1156
  });
1103
1157
  }
1104
1158
  }
1105
- const S = /* @__PURE__ */ new Map();
1159
+ const R = /* @__PURE__ */ new Map();
1106
1160
  async function F(o) {
1107
1161
  if (!o.addresses?.length && !o.usernames?.length)
1108
1162
  return { results: [] };
@@ -1118,22 +1172,22 @@ async function F(o) {
1118
1172
  return e.json();
1119
1173
  }
1120
1174
  async function je(o) {
1121
- const e = o.filter((t) => !S.has(t));
1175
+ const e = o.filter((t) => !R.has(t));
1122
1176
  return e.length > 0 && (await F({ usernames: e })).results.forEach((n) => {
1123
- S.set(n.username, n.addresses[0]);
1177
+ R.set(n.username, n.addresses[0]);
1124
1178
  }), new Map(
1125
- o.map((t) => [t, S.get(t)]).filter((t) => t[1] !== void 0)
1179
+ o.map((t) => [t, R.get(t)]).filter((t) => t[1] !== void 0)
1126
1180
  );
1127
1181
  }
1128
1182
  async function Be(o) {
1129
1183
  o = o.map(O.toHex);
1130
- const e = o.filter((t) => !S.has(t));
1184
+ const e = o.filter((t) => !R.has(t));
1131
1185
  return e.length > 0 && (await F({
1132
1186
  addresses: e
1133
1187
  })).results.forEach((n) => {
1134
- S.set(n.addresses[0], n.username);
1188
+ R.set(n.addresses[0], n.username);
1135
1189
  }), new Map(
1136
- o.map((t) => [t, S.get(t)]).filter((t) => t[1] !== void 0)
1190
+ o.map((t) => [t, R.get(t)]).filter((t) => t[1] !== void 0)
1137
1191
  );
1138
1192
  }
1139
1193
  var U = {
@@ -1540,7 +1594,7 @@ var U = {
1540
1594
  },
1541
1595
  cover: "https://static.cartridge.gg/presets/bytebeasts-tamagotchi/cover.png",
1542
1596
  icon: "https://static.cartridge.gg/presets/bytebeasts-tamagotchi/icon.png",
1543
- name: "ByteBeasts-Tamagotchi",
1597
+ name: "Tamagotchi",
1544
1598
  optimizedCover: {
1545
1599
  webp: {
1546
1600
  768: "cover@768.webp",
@@ -1887,36 +1941,30 @@ var U = {
1887
1941
  SN_MAIN: {
1888
1942
  policies: {
1889
1943
  contracts: {
1890
- "0x0320f977f47f0885e376b781d9e244d9f59f10154ce844ae1815c919f0374726": {
1891
- name: "game_systems",
1944
+ "0x051Fea4450Da9D6aeE758BDEbA88B2f665bCbf549D2C61421AA724E9AC0Ced8F": {
1945
+ name: "VRF Provider",
1946
+ description: "Provides verifiable random functions",
1892
1947
  methods: [
1893
1948
  {
1894
- entrypoint: "mint"
1895
- },
1896
- {
1897
- entrypoint: "start_game"
1949
+ name: "Request Random",
1950
+ description: "Request a random number",
1951
+ entrypoint: "request_random"
1898
1952
  }
1899
1953
  ]
1900
1954
  },
1901
- "0x0062cfee20a5be4b305f610a23291aa27f3fca7a5fd14bd8e2d0389556003e12": {
1902
- name: "battle_systems",
1955
+ "0x0444834e7b71749832f0db8c64f17ed1c3af8462c1682c10dcd6068b1c57494b": {
1956
+ name: "game_systems",
1957
+ description: "Game mechanics",
1903
1958
  methods: [
1904
1959
  {
1905
- entrypoint: "battle_actions"
1906
- }
1907
- ]
1908
- },
1909
- "0x00ae7393b60ad9fd5c26851341b9a4afe61c6ae34326dee79cf5d096e9f55a36": {
1910
- name: "draft_systems",
1911
- methods: [
1960
+ entrypoint: "mint"
1961
+ },
1962
+ {
1963
+ entrypoint: "start_game"
1964
+ },
1912
1965
  {
1913
1966
  entrypoint: "pick_card"
1914
- }
1915
- ]
1916
- },
1917
- "0x07c9a684813410b39c776c49544d8ecb2d39f0b91bd83ffec31ebc938e053e25": {
1918
- name: "map_systems",
1919
- methods: [
1967
+ },
1920
1968
  {
1921
1969
  entrypoint: "generate_tree"
1922
1970
  },
@@ -1924,6 +1972,15 @@ var U = {
1924
1972
  entrypoint: "select_node"
1925
1973
  }
1926
1974
  ]
1975
+ },
1976
+ "0x06633dc0c8e3956fd8d87f68e5a4324cb20270b442a532f4d4179d85c389b324": {
1977
+ name: "battle_systems",
1978
+ description: "Battle mechanics",
1979
+ methods: [
1980
+ {
1981
+ entrypoint: "battle_actions"
1982
+ }
1983
+ ]
1927
1984
  }
1928
1985
  }
1929
1986
  }
@@ -2108,7 +2165,7 @@ var U = {
2108
2165
  SN_MAIN: {
2109
2166
  policies: {
2110
2167
  contracts: {
2111
- "0x62525c1337037a6a50a61f12045630a271758a350e57616e79a6ed14004ce74": {
2168
+ "0x05553fcb6da57decacce3306d8e0b3bf65b656dceda96c90ba55bde8980253ce": {
2112
2169
  name: "Achievement Systems",
2113
2170
  description: "Allows you to interact with achievement features.",
2114
2171
  methods: [
@@ -2119,7 +2176,7 @@ var U = {
2119
2176
  }
2120
2177
  ]
2121
2178
  },
2122
- "0xa5a3284a1e3ce9887b50876acee14a1af9705659b3ad053deff80d84c5555a": {
2179
+ "0x059ffaee1d7068332ea8f084a9685b99a5c2a74197ef99e093a10fa25f887402": {
2123
2180
  name: "Dragon Systems",
2124
2181
  description: "Allows you to interact with dragon features.",
2125
2182
  methods: [
@@ -2133,11 +2190,6 @@ var U = {
2133
2190
  description: "A method to deactivate Dragark NFT out of the game.",
2134
2191
  entrypoint: "deactivate_dragon"
2135
2192
  },
2136
- {
2137
- name: "Claim Default Dragon",
2138
- description: "A method to claim the default Dragark.",
2139
- entrypoint: "claim_default_dragon"
2140
- },
2141
2193
  {
2142
2194
  name: "Upgrade Dragon",
2143
2195
  description: "A method to upgrade the Dragark's level.",
@@ -2145,7 +2197,7 @@ var U = {
2145
2197
  }
2146
2198
  ]
2147
2199
  },
2148
- "0x456e9a70c1a8ce2e340592d1a885f2ac152349d785a6aef4d640d9a09f9a1bd": {
2200
+ "0x0760d029c7b49069ece425285afb592152da1fff59038e697a5554f1b94150f2": {
2149
2201
  name: "Island Systems",
2150
2202
  description: "Allows you to interact with island features.",
2151
2203
  methods: [
@@ -2161,7 +2213,7 @@ var U = {
2161
2213
  }
2162
2214
  ]
2163
2215
  },
2164
- "0x2f77a88ac64fd1473ea067ea176ae3805224a2ba5173c63c77d0f214c01ac5d": {
2216
+ "0x000ccb9e596c7d3298b670d91b6c3ed305aeed3eb1335d702265f53f1d0ad68a": {
2165
2217
  name: "Journey Systems",
2166
2218
  description: "Allows you to interact with journey features.",
2167
2219
  methods: [
@@ -2177,7 +2229,7 @@ var U = {
2177
2229
  }
2178
2230
  ]
2179
2231
  },
2180
- "0x1ca130b614f063a24dafad53db11cbb914fa7cff2eac23df1c32f5ff71a8ec2": {
2232
+ "0x0002d12498d7b7f5e4d57a9895f8684fa58f4edb06ba6edb879723d8acb16507": {
2181
2233
  name: "Map Systems",
2182
2234
  description: "Allows you to interact with map features.",
2183
2235
  methods: [
@@ -2185,15 +2237,10 @@ var U = {
2185
2237
  name: "Join Map",
2186
2238
  description: "A method to join the map.",
2187
2239
  entrypoint: "join_map"
2188
- },
2189
- {
2190
- name: "Rejoin Map",
2191
- description: "A method to rejoin the map.",
2192
- entrypoint: "re_join_map"
2193
2240
  }
2194
2241
  ]
2195
2242
  },
2196
- "0x272741bbe4abc02c8be4b094ca642e1df573e99e06f85f649bc35dd26ae4543": {
2243
+ "0x01ba78267fd97db89b8ac0316ce0a2d71aaef87ad4f300e5468dc20232a2ff20": {
2197
2244
  name: "Mission Systems",
2198
2245
  description: "Allows you to interact with mission features.",
2199
2246
  methods: [
@@ -2204,7 +2251,7 @@ var U = {
2204
2251
  }
2205
2252
  ]
2206
2253
  },
2207
- "0x54ad7af1fc62a786c9023d9f3ef8e8abf8cf332649b784188c1b25d2cb384b2": {
2254
+ "0x063b168f01cbac52b5d2ad82696eeaddde33b38d24364523ad0a3ca400361489": {
2208
2255
  name: "Player Systems",
2209
2256
  description: "Allows you to interact with player features.",
2210
2257
  methods: [
@@ -2233,16 +2280,6 @@ var U = {
2233
2280
  description: "A method to redeem invite code.",
2234
2281
  entrypoint: "redeem_invite_code"
2235
2282
  },
2236
- {
2237
- name: "Buy Resources Pack",
2238
- description: "A method to buy resources pack.",
2239
- entrypoint: "buy_resources_pack"
2240
- },
2241
- {
2242
- name: "Activate Element NFT",
2243
- description: "A method to activate the Element NFT into the game.",
2244
- entrypoint: "activate_element_nft"
2245
- },
2246
2283
  {
2247
2284
  name: "Claim Pool Share Reward",
2248
2285
  description: "A method to claim your Pool Share reward.",
@@ -2250,7 +2287,7 @@ var U = {
2250
2287
  }
2251
2288
  ]
2252
2289
  },
2253
- "0x68717880bd76fda6790e895e937e2c638213e7b9aa07385231bbf17dfe8a78c": {
2290
+ "0x03284bb4684703a368db8fd538c39b30e51822dbab9ad398e66311e820318444": {
2254
2291
  name: "Scout Systems",
2255
2292
  description: "Allows you to interact with scout features.",
2256
2293
  methods: [
@@ -2261,7 +2298,7 @@ var U = {
2261
2298
  }
2262
2299
  ]
2263
2300
  },
2264
- "0x14705481d28fab7bb37d6cb19d3392d39f838a1d5572b8c8f18e85e0c4b8918": {
2301
+ "0x04a8b7e4106719e75653595c1e55da9ac88fbf1ae29124fca325c0537f00e908": {
2265
2302
  name: "Shield Systems",
2266
2303
  description: "Allows you to interact with shield features.",
2267
2304
  methods: [
@@ -2282,7 +2319,7 @@ var U = {
2282
2319
  }
2283
2320
  ]
2284
2321
  },
2285
- "0x23d6a41c06e2d7b60437ba4da3eca857cf9a0b94f3548396829365a0a299c63": {
2322
+ "0x060a67334aed80a5403bd2b727337f29ccdcbf51784cc7ddb73f10ceb92e61f1": {
2286
2323
  name: "Star Shop Systems",
2287
2324
  description: "Allows you to interact with star shop features.",
2288
2325
  methods: [
@@ -2293,7 +2330,7 @@ var U = {
2293
2330
  }
2294
2331
  ]
2295
2332
  },
2296
- "0x511a78a1c4b33bedc4ff7d9b37eb7481bcdff77c5c2cb6f67390d43657749d0": {
2333
+ "0x0655a9a38cb8dd7087a206b7d885528f8994e03dd6449105ef0f068caa502d25": {
2297
2334
  name: "Treasure Hunt Systems",
2298
2335
  description: "Allows you to interact with treasure hunt features.",
2299
2336
  methods: [
@@ -3676,6 +3713,45 @@ var U = {
3676
3713
  }
3677
3714
  }
3678
3715
  },
3716
+ wardens: {
3717
+ origin: "app.wardens.xyz",
3718
+ theme: {
3719
+ colors: {
3720
+ primary: "#f7ac18"
3721
+ },
3722
+ cover: "https://static.cartridge.gg/presets/wardens/cover.jpg",
3723
+ icon: "https://static.cartridge.gg/presets/wardens/icon.png",
3724
+ name: "Wardens",
3725
+ optimizedCover: {
3726
+ webp: {
3727
+ 768: "cover@768.webp",
3728
+ 1024: "cover@1024.webp",
3729
+ 1440: "cover@1440.webp"
3730
+ },
3731
+ jpg: {
3732
+ 768: "cover@768.jpg",
3733
+ 1024: "cover@1024.jpg",
3734
+ 1440: "cover@1440.jpg"
3735
+ }
3736
+ },
3737
+ optimizedIcon: {
3738
+ webp: {
3739
+ 16: "icon@16.webp",
3740
+ 32: "icon@32.webp",
3741
+ 64: "icon@64.webp",
3742
+ 128: "icon@128.webp",
3743
+ 256: "icon@256.webp"
3744
+ },
3745
+ png: {
3746
+ 16: "icon@16.png",
3747
+ 32: "icon@32.png",
3748
+ 64: "icon@64.png",
3749
+ 128: "icon@128.png",
3750
+ 256: "icon@256.png"
3751
+ }
3752
+ }
3753
+ }
3754
+ },
3679
3755
  zkastle: {
3680
3756
  origin: "zkastle.vercel.app",
3681
3757
  theme: {
@@ -3815,7 +3891,7 @@ var U = {
3815
3891
  }
3816
3892
  }
3817
3893
  }
3818
- }, Se = [
3894
+ }, Re = [
3819
3895
  {
3820
3896
  name: "Wrapped BTC",
3821
3897
  symbol: "WBTC",
@@ -4361,7 +4437,7 @@ var U = {
4361
4437
  hidden: !0,
4362
4438
  logo_url: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/6deef27f-df40-4248-4e1b-ed1d79a3f000/logo"
4363
4439
  }
4364
- ], Te = U, Qe = Se, Fe = U.cartridge.theme;
4440
+ ], Te = U, Qe = Re, Fe = U.cartridge.theme;
4365
4441
  export {
4366
4442
  Ae as ArgentWallet,
4367
4443
  Oe as FeeSource,