tulipe
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -1,19 +0,68 @@ | ||
import { computed as k, getCurrentInstance as N, watch as w, isRef as W, ref as m, resolveComponent as C, openBlock as l, createBlock as g, withCtx as R, createElementVNode as c, toDisplayString as f, unref as o, createVNode as O, createTextVNode as $, createElementBlock as u, Fragment as v, renderList as S, shallowRef as Q, withDirectives as V, vModelText as B, createCommentVNode as E, normalizeClass as J, renderSlot as y, pushScopeId as X, popScopeId as tt, vModelSelect as et, markRaw as L, onUnmounted as A } from "vue"; | ||
import { ethers as x } from "ethers"; | ||
class st { | ||
import { computed as O, getCurrentInstance as U, watch as k, isRef as T, ref as y, resolveComponent as E, openBlock as u, createBlock as g, withCtx as S, createElementVNode as l, toDisplayString as f, unref as o, createVNode as R, createTextVNode as $, createElementBlock as d, Fragment as w, renderList as v, shallowRef as J, withDirectives as B, vModelText as L, createCommentVNode as I, normalizeClass as X, renderSlot as _, pushScopeId as tt, popScopeId as et, vModelSelect as st, markRaw as nt, onUnmounted as W } from "vue"; | ||
import { ethers as N } from "ethers"; | ||
class at { | ||
constructor() { | ||
const t = a.config.wallets.getAvailable(); | ||
for (const e of t) { | ||
const s = Me[e.id]; | ||
s && (this[e.id] = new s()); | ||
} | ||
} | ||
} | ||
class it { | ||
constructor() { | ||
for (const t of a.config.networks.getAll()) | ||
if (t.contracts) | ||
for (const e of Object.keys(t.contracts)) | ||
this[e] = new F(e); | ||
} | ||
getAll() { | ||
const t = {}; | ||
for (const [e, s] of Object.entries(this)) | ||
s instanceof F && (t[e] = s); | ||
return t; | ||
} | ||
} | ||
class rt { | ||
constructor() { | ||
this.contracts = {}, this.wallets = {}; | ||
} | ||
async _asyncInit() { | ||
a.provider.onSafe(() => { | ||
a.provider.on("block", async function(t) { | ||
const e = await a.provider.getBlockWithTransactions(t); | ||
for (const s of e.transactions) | ||
Object.keys(this.contracts).includes(s.to) ? this.contracts[s.to].update() : Object.keys(this.wallets).includes(s.to) && this.wallets[s.to].update(), Object.keys(this.contracts).includes(s.from) ? this.contracts[s.from].update() : Object.keys(this.wallets).includes(s.from) && this.wallets[s.from].update(); | ||
}); | ||
}); | ||
} | ||
addContractWatcher(t) { | ||
Object.keys(this.contracts).includes(t.address) || (this.contracts[t.address] = new De(t)); | ||
} | ||
removeContractWatcher(t) { | ||
Object.keys(this.contracts).includes(t.address) && delete this.contracts[t.address]; | ||
} | ||
addWalletWatcher(t) { | ||
Object.keys(this.wallets).includes(t) || (this.wallets[t] = new Pe(t)); | ||
} | ||
removeContractWatcher(t) { | ||
Object.keys(this.wallets).includes(t) && delete this.wallets[t]; | ||
} | ||
} | ||
class ot { | ||
constructor() { | ||
} | ||
init(t = null) { | ||
this.config = new ve(t), this.status = new P("dapp", [ | ||
this.config = new Ee(t), this.status = new P("dapp", [ | ||
"UNSAFE", | ||
"ERROR", | ||
"INITIALIZED" | ||
]), this.isSafe = k(() => this.status.is("INITIALIZED")), this.OnSafe = ee, this.chainWatchers = new Ne(), this.wallets = new We(), this.provider = new ge(), this.pro = this.provider, this.signer = new Ce(), this.sig = this.signer, this.contracts = new pe(), this.con = this.contracts; | ||
]), this.isSafe = O(() => this.status.is("INITIALIZED")), this.OnSafe = oe, this.chainWatchers = new rt(), this.wallets = new at(), this.provider = new ke(), this.pro = this.provider, this.signer = new Ne(), this.sig = this.signer, this.contracts = new it(), this.con = this.contracts; | ||
} | ||
onSafe(t) { | ||
const e = N(); | ||
const e = U(); | ||
if (this.isSafe.value) | ||
t(e); | ||
else { | ||
const s = w(this.isSafe, () => { | ||
const s = k(this.isSafe, () => { | ||
this.isSafe.value && (t(e), s()); | ||
@@ -24,21 +73,21 @@ }); | ||
} | ||
const a = new st(); | ||
function M(r) { | ||
return r && typeof r == "object" && !Array.isArray(r); | ||
const a = new ot(); | ||
function V(i) { | ||
return i && typeof i == "object" && !Array.isArray(i); | ||
} | ||
function D(r, ...t) { | ||
function A(i, ...t) { | ||
if (!t.length) | ||
return r; | ||
return i; | ||
const e = t.shift(); | ||
if (M(r) && M(e)) | ||
if (V(i) && V(e)) | ||
for (const s in e) | ||
M(e[s]) ? (r[s] || Object.assign(r, { | ||
V(e[s]) ? (i[s] || Object.assign(i, { | ||
[s]: {} | ||
}), D(r[s], e[s])) : Object.assign(r, { | ||
}), A(i[s], e[s])) : Object.assign(i, { | ||
[s]: e[s] | ||
}); | ||
return D(r, ...t); | ||
return A(i, ...t); | ||
} | ||
function nt(r) { | ||
const t = r.split(" "); | ||
function lt(i) { | ||
const t = i.split(" "); | ||
for (let e = 0; e < t.length; e++) | ||
@@ -48,16 +97,16 @@ t[e] = t[e][0].toUpperCase() + t[e].substring(1); | ||
} | ||
function T(r) { | ||
return W(r) ? T(r.value) : r; | ||
function D(i) { | ||
return T(i) ? D(i.value) : i; | ||
} | ||
function I(r, t) { | ||
W(r) ? r.value = t : r = t; | ||
function C(i, t) { | ||
T(i) ? i.value = t : i = t; | ||
} | ||
const at = { | ||
const ct = { | ||
required: !1, | ||
type: String, | ||
default: "minimal", | ||
validator(r) { | ||
return ["unstylized", "minimal", "opinionated"].includes(r); | ||
validator(i) { | ||
return ["unstylized", "minimal", "opinionated"].includes(i); | ||
} | ||
}, rt = { class: "ContractInteractor" }, ot = /* @__PURE__ */ $(" Methods : "), it = /* @__PURE__ */ c("br", null, null, -1), ct = /* @__PURE__ */ $(" Events : "), lt = /* @__PURE__ */ c("br", null, null, -1), Ue = { | ||
}, ut = { class: "ContractInteractor" }, dt = /* @__PURE__ */ $(" Methods : "), ht = /* @__PURE__ */ l("br", null, null, -1), pt = /* @__PURE__ */ $(" Events : "), ft = /* @__PURE__ */ l("br", null, null, -1), Le = { | ||
__name: "ContractInteractor", | ||
@@ -70,5 +119,5 @@ props: { | ||
}, | ||
setup(r) { | ||
const t = r, e = a.contracts[t.contract]; | ||
let s = m("not owned"); | ||
setup(i) { | ||
const t = i, e = a.contracts[t.contract]; | ||
let s = y("not owned"); | ||
return a.contracts[t.contract].onReadSafe(async function() { | ||
@@ -79,23 +128,23 @@ try { | ||
} | ||
}), (n, i) => { | ||
const d = C("OnContractReadSafe"); | ||
return l(), g(d, { | ||
}), (n, r) => { | ||
const c = E("OnContractReadSafe"); | ||
return u(), g(c, { | ||
contract: t.contract | ||
}, { | ||
default: R(() => [ | ||
c("div", rt, [ | ||
c("ul", null, [ | ||
c("li", null, "Address : " + f(o(e).address), 1), | ||
c("li", null, "Owner : " + f(o(s)), 1), | ||
c("li", null, [ | ||
ot, | ||
it, | ||
O(o(dt), { | ||
default: S(() => [ | ||
l("div", ut, [ | ||
l("ul", null, [ | ||
l("li", null, "Address : " + f(o(e).address), 1), | ||
l("li", null, "Owner : " + f(o(s)), 1), | ||
l("li", null, [ | ||
dt, | ||
ht, | ||
R(o(yt), { | ||
contract: t.contract | ||
}, null, 8, ["contract"]) | ||
]), | ||
c("li", null, [ | ||
ct, | ||
lt, | ||
O(o(Ct), { | ||
l("li", null, [ | ||
pt, | ||
ft, | ||
R(o(Nt), { | ||
contract: t.contract | ||
@@ -111,3 +160,3 @@ }, null, 8, ["contract"]) | ||
} | ||
}, ut = { class: "MethodsInteractor" }, dt = { | ||
}, mt = { class: "MethodsInteractor" }, yt = { | ||
__name: "MethodsInteractor", | ||
@@ -120,14 +169,14 @@ props: { | ||
}, | ||
setup(r) { | ||
const t = r, e = a.contracts[t.contract]; | ||
setup(i) { | ||
const t = i, e = a.contracts[t.contract]; | ||
return (s, n) => { | ||
const i = C("OnContractReadSafe"); | ||
return l(), g(i, { | ||
const r = E("OnContractReadSafe"); | ||
return u(), g(r, { | ||
contract: t.contract | ||
}, { | ||
default: R(() => [ | ||
c("div", ut, [ | ||
c("ul", null, [ | ||
(l(!0), u(v, null, S(o(e).interface.functions, (d, h) => (l(), u("li", null, [ | ||
O(o(Rt), { | ||
default: S(() => [ | ||
l("div", mt, [ | ||
l("ul", null, [ | ||
(u(!0), d(w, null, v(o(e).interface.functions, (c, h) => (u(), d("li", null, [ | ||
R(o(Rt), { | ||
contract: t.contract, | ||
@@ -144,3 +193,3 @@ method: h | ||
} | ||
}, ht = { class: "MethodInteractor" }, pt = { key: 0 }, ft = /* @__PURE__ */ c("p", null, "Inputs :", -1), mt = ["onUpdate:modelValue", "placeholder"], yt = { key: 0 }, _t = { key: 1 }, vt = /* @__PURE__ */ c("p", null, "Outputs :", -1), wt = ["onUpdate:modelValue", "placeholder"], St = ["placeholder"], gt = { key: 2 }, Rt = { | ||
}, _t = { class: "MethodInteractor" }, wt = { key: 0 }, vt = /* @__PURE__ */ l("p", null, "Inputs :", -1), gt = ["onUpdate:modelValue", "placeholder"], St = { key: 0 }, It = { key: 1 }, Et = /* @__PURE__ */ l("p", null, "Outputs :", -1), Ct = ["onUpdate:modelValue", "placeholder"], bt = ["placeholder"], kt = { key: 2 }, Rt = { | ||
__name: "MethodInteractor", | ||
@@ -157,57 +206,57 @@ props: { | ||
}, | ||
setup(r) { | ||
const t = r, e = Q(new H(t.contract, t.method)); | ||
setup(i) { | ||
const t = i, e = J(new K(t.contract, t.method)); | ||
function s(n) { | ||
return `${n.name && n.name !== "null" ? n.name : ""} (${n.type})`; | ||
} | ||
return (n, i) => { | ||
const d = C("OnContractReadSafe"); | ||
return l(), g(d, { | ||
return (n, r) => { | ||
const c = E("OnContractReadSafe"); | ||
return u(), g(c, { | ||
contract: t.contract | ||
}, { | ||
default: R(() => [ | ||
c("div", ht, [ | ||
O(o(Pt), { | ||
default: S(() => [ | ||
l("div", _t, [ | ||
R(o(Bt), { | ||
contract: t.contract, | ||
method: t.method, | ||
modelValue: o(e), | ||
"onUpdate:modelValue": i[0] || (i[0] = (h) => W(e) ? e.value = h : null), | ||
"onUpdate:modelValue": r[0] || (r[0] = (h) => T(e) ? e.value = h : null), | ||
configs: { content: t.method, notx: !0, noerror: !0 } | ||
}, null, 8, ["contract", "method", "modelValue", "configs"]), | ||
c("small", null, f(o(e).methodInfos.stateMutability), 1), | ||
Object.keys(o(e).methodInfos.inputs).length > 0 || o(e).methodInfos.payable ? (l(), u("div", pt, [ | ||
ft, | ||
c("ul", null, [ | ||
(l(!0), u(v, null, S(o(e).methodInfos.inputs, (h, p) => (l(), u("li", null, [ | ||
V(c("input", { | ||
"onUpdate:modelValue": (_) => o(e).args.value[p] = _, | ||
l("small", null, f(o(e).methodInfos.stateMutability), 1), | ||
Object.keys(o(e).methodInfos.inputs).length > 0 || o(e).methodInfos.payable ? (u(), d("div", wt, [ | ||
vt, | ||
l("ul", null, [ | ||
(u(!0), d(w, null, v(o(e).methodInfos.inputs, (h, p) => (u(), d("li", null, [ | ||
B(l("input", { | ||
"onUpdate:modelValue": (m) => o(e).args.value[p] = m, | ||
type: "text", | ||
placeholder: s(h) | ||
}, null, 8, mt), [ | ||
[B, o(e).args.value[p]] | ||
}, null, 8, gt), [ | ||
[L, o(e).args.value[p]] | ||
]), | ||
$(" " + f(o(e).args.value[p]) + " " + f(typeof o(e).args.value[p]), 1) | ||
]))), 256)), | ||
o(e).methodInfos.payable ? (l(), u("li", yt, [ | ||
O(o(he), { | ||
o(e).methodInfos.payable ? (u(), d("li", St, [ | ||
R(o(we), { | ||
modelValue: o(e).txArgs.value.value, | ||
"onUpdate:modelValue": i[1] || (i[1] = (h) => o(e).txArgs.value.value = h) | ||
"onUpdate:modelValue": r[1] || (r[1] = (h) => o(e).txArgs.value.value = h) | ||
}, null, 8, ["modelValue"]), | ||
$(" " + f(o(e).txArgs.value.value) + " " + f(typeof o(e).txArgs.value.value), 1) | ||
])) : E("", !0) | ||
])) : I("", !0) | ||
]) | ||
])) : E("", !0), | ||
Object.keys(o(e).methodInfos.outputs).length > 0 ? (l(), u("div", _t, [ | ||
vt, | ||
c("ul", null, [ | ||
(l(!0), u(v, null, S(o(e).methodInfos.outputs, (h, p) => (l(), u("li", null, [ | ||
o(e).data.value ? V((l(), u("input", { | ||
])) : I("", !0), | ||
Object.keys(o(e).methodInfos.outputs).length > 0 ? (u(), d("div", It, [ | ||
Et, | ||
l("ul", null, [ | ||
(u(!0), d(w, null, v(o(e).methodInfos.outputs, (h, p) => (u(), d("li", null, [ | ||
o(e).data.value ? B((u(), d("input", { | ||
key: 0, | ||
"onUpdate:modelValue": (_) => o(e).data.value[p] = _, | ||
"onUpdate:modelValue": (m) => o(e).data.value[p] = m, | ||
type: "text", | ||
placeholder: s(h), | ||
disabled: "" | ||
}, null, 8, wt)), [ | ||
[B, o(e).data.value[p]] | ||
]) : (l(), u("input", { | ||
}, null, 8, Ct)), [ | ||
[L, o(e).data.value[p]] | ||
]) : (u(), d("input", { | ||
key: 1, | ||
@@ -217,7 +266,7 @@ type: "text", | ||
disabled: "" | ||
}, null, 8, St)) | ||
}, null, 8, bt)) | ||
]))), 256)) | ||
]) | ||
])) : E("", !0), | ||
o(e).status.is("ERROR") ? (l(), u("p", gt, f(o(e).error.value.reason), 1)) : E("", !0) | ||
])) : I("", !0), | ||
o(e).status.is("ERROR") ? (u(), d("p", kt, f(o(e).error.value.reason), 1)) : I("", !0) | ||
]) | ||
@@ -229,3 +278,3 @@ ]), | ||
} | ||
}, Et = { class: "EventsInteractor" }, Ct = { | ||
}, xt = { class: "EventsInteractor" }, Nt = { | ||
__name: "EventsInteractor", | ||
@@ -238,14 +287,14 @@ props: { | ||
}, | ||
setup(r) { | ||
const t = r, e = a.contracts[t.contract]; | ||
setup(i) { | ||
const t = i, e = a.contracts[t.contract]; | ||
return (s, n) => { | ||
const i = C("OnContractReadSafe"); | ||
return l(), g(i, { | ||
const r = E("OnContractReadSafe"); | ||
return u(), g(r, { | ||
contract: t.contract | ||
}, { | ||
default: R(() => [ | ||
c("div", Et, [ | ||
c("ul", null, [ | ||
(l(!0), u(v, null, S(o(e).interface.events, (d, h) => (l(), u("li", null, [ | ||
O(o(Ot), { | ||
default: S(() => [ | ||
l("div", xt, [ | ||
l("ul", null, [ | ||
(u(!0), d(w, null, v(o(e).interface.events, (c, h) => (u(), d("li", null, [ | ||
R(o(At), { | ||
contract: t.contract, | ||
@@ -262,3 +311,3 @@ event: h | ||
} | ||
}, It = { class: "EventInteractor" }, kt = /* @__PURE__ */ $("Logs: "), Ot = { | ||
}, Ot = { class: "EventInteractor" }, $t = /* @__PURE__ */ $("Logs: "), At = { | ||
__name: "EventInteractor", | ||
@@ -275,27 +324,27 @@ props: { | ||
}, | ||
setup(r) { | ||
const t = r, e = a.contracts[t.contract]; | ||
let s = m({}), n = m({}), i = m(0), d = m([]); | ||
setup(i) { | ||
const t = i, e = a.contracts[t.contract]; | ||
let s = y({}), n = y({}), r = y(0), c = y([]); | ||
return e.onReadSafe(() => { | ||
s.value = e.interface.events[t.event], n.value = e.filters[s.value.name], e.on(n.value, (h) => { | ||
i.value++; | ||
r.value++; | ||
let p = `Block ${h.blockNumber} -> {`; | ||
for (const _ of s.value.inputs) | ||
p += `${_.name}:${h.args[_.name]}, `; | ||
p = p.substring(0, p.length - 2) + "}", d.value.push(p); | ||
for (const m of s.value.inputs) | ||
p += `${m.name}:${h.args[m.name]}, `; | ||
p = p.substring(0, p.length - 2) + "}", c.value.push(p); | ||
}); | ||
}), (h, p) => { | ||
const _ = C("OnContractReadSafe"); | ||
return l(), g(_, { | ||
const m = E("OnContractReadSafe"); | ||
return u(), g(m, { | ||
contract: t.contract | ||
}, { | ||
default: R(() => [ | ||
c("div", It, [ | ||
c("p", null, f(o(s).name), 1), | ||
c("ul", null, [ | ||
c("li", null, "Count : " + f(o(i)), 1), | ||
c("li", null, [ | ||
kt, | ||
c("ul", null, [ | ||
(l(!0), u(v, null, S(o(d), (z) => (l(), u("li", null, f(z), 1))), 256)) | ||
default: S(() => [ | ||
l("div", Ot, [ | ||
l("p", null, f(o(s).name), 1), | ||
l("ul", null, [ | ||
l("li", null, "Count : " + f(o(r)), 1), | ||
l("li", null, [ | ||
$t, | ||
l("ul", null, [ | ||
(u(!0), d(w, null, v(o(c), (G) => (u(), d("li", null, f(G), 1))), 256)) | ||
]) | ||
@@ -310,12 +359,12 @@ ]) | ||
} | ||
}, bt = { class: "TransactButton" }, Nt = { | ||
}, Tt = { class: "TransactButton" }, Dt = { | ||
key: 1, | ||
disabled: "" | ||
}, xt = { | ||
}, Pt = { | ||
key: 2, | ||
disabled: "" | ||
}, $t = { | ||
}, Wt = { | ||
key: 3, | ||
disabled: "" | ||
}, Dt = { key: 4 }, Pt = { | ||
}, Ut = { key: 4 }, Bt = { | ||
__name: "Transact", | ||
@@ -346,30 +395,30 @@ props: { | ||
emits: ["update:modelValue"], | ||
setup(r, { emit: t }) { | ||
const e = r, s = a.contracts[e.contract]; | ||
let n = k({ | ||
setup(i, { emit: t }) { | ||
const e = i, s = a.contracts[e.contract]; | ||
let n = O({ | ||
get() { | ||
return e.modelValue; | ||
}, | ||
set(d) { | ||
t("update:modelValue", d); | ||
set(c) { | ||
t("update:modelValue", c); | ||
} | ||
}); | ||
function i() { | ||
const d = e.args ? e.args : [], h = e.txArgs ? e.txArgs : {}; | ||
n.value.send(d, h); | ||
function r() { | ||
const c = e.args ? e.args : [], h = e.txArgs ? e.txArgs : {}; | ||
n.value.send(c, h); | ||
} | ||
return e.config && e.configs.notx && s.onReadSafe(() => { | ||
n = new H(e.contract, e.method); | ||
}), (d, h) => { | ||
const p = C("OnContractReadSafe"); | ||
return l(), g(p, { | ||
n = new K(e.contract, e.method); | ||
}), (c, h) => { | ||
const p = E("OnContractReadSafe"); | ||
return u(), g(p, { | ||
contract: e.contract | ||
}, { | ||
default: R(() => [ | ||
c("div", bt, [ | ||
o(n).status.is("READY") ? (l(), u("button", { | ||
default: S(() => [ | ||
l("div", Tt, [ | ||
o(n).status.is("READY") ? (u(), d("button", { | ||
key: 0, | ||
onClick: i | ||
}, f(e.configs && e.configs.content ? e.configs.content : "Transact"), 1)) : o(n).status.is("SENT") ? (l(), u("button", Nt, "Transaction sent...")) : o(n).status.is("ERROR") ? (l(), u("button", xt, "Transaction error!")) : o(n).status.is("SUCCESS") ? (l(), u("button", $t, "Success !")) : E("", !0), | ||
!(e.configs && e.configs.noerror) && o(n).status.is("ERROR") ? (l(), u("p", Dt, f(o(n).error.value.reason), 1)) : E("", !0) | ||
onClick: r | ||
}, f(e.configs && e.configs.content ? e.configs.content : "Transact"), 1)) : o(n).status.is("SENT") ? (u(), d("button", Dt, "Transaction sent...")) : o(n).status.is("ERROR") ? (u(), d("button", Pt, "Transaction error!")) : o(n).status.is("SUCCESS") ? (u(), d("button", Wt, "Success !")) : I("", !0), | ||
!(e.configs && e.configs.noerror) && o(n).status.is("ERROR") ? (u(), d("p", Ut, f(o(n).error.value.reason), 1)) : I("", !0) | ||
]) | ||
@@ -382,42 +431,19 @@ ]), | ||
}; | ||
const q = (r, t) => { | ||
const e = r.__vccOpts || r; | ||
const H = (i, t) => { | ||
const e = i.__vccOpts || i; | ||
for (const [s, n] of t) | ||
e[s] = n; | ||
return e; | ||
}, Wt = { | ||
key: 1, | ||
disabled: "" | ||
}, Tt = { | ||
key: 2, | ||
disabled: "" | ||
}, At = { | ||
key: 3, | ||
disabled: "" | ||
}, Vt = { | ||
key: 4, | ||
disabled: "" | ||
}, Ut = { | ||
}, Mt = { | ||
__name: "ConnectWalletButton", | ||
props: { | ||
styleLevel: at | ||
styleLevel: ct | ||
}, | ||
setup(r) { | ||
const t = r; | ||
let e = m({}); | ||
return a.provider.onSafe(async function() { | ||
e.value = await a.config.networks.getCurrent(); | ||
}), (s, n) => (l(), g(o(a).provider.OnSafe, null, { | ||
default: R(() => [ | ||
c("div", { | ||
class: J(["ConnectWalletButton", `ve-${t.styleLevel}`]) | ||
}, [ | ||
o(a).signer.status.is("DISCONNECTED") ? (l(), u("button", { | ||
key: 0, | ||
onClick: n[0] || (n[0] = (i) => o(a).signer.connectWallet(o(a).wallets.metamask)) | ||
}, "Connect Wallet")) : o(a).signer.status.is("REQUESTED") ? (l(), u("button", Wt, "Connection requested...")) : o(a).signer.status.is("REFUSED") ? (l(), u("button", Tt, "Connection refused!")) : o(a).signer.status.is("ERROR") ? (l(), u("button", At, "Connection error!")) : o(a).provider.status.is("WRONG") ? (l(), u("button", Vt, "Wrong network! (" + f(o(e) ? o(e).displayName : "unknown") + ")", 1)) : o(a).signer.status.is("CONNECTED") ? (l(), u("button", { | ||
key: 5, | ||
onClick: n[1] || (n[1] = (...i) => o(a).signer.disconnectWallet && o(a).signer.disconnectWallet(...i)) | ||
}, "Disconnect")) : E("", !0) | ||
], 2) | ||
setup(i) { | ||
const t = i; | ||
return (e, s) => (u(), g(o(a).provider.OnSafe, null, { | ||
default: S(() => [ | ||
l("div", { | ||
class: X(["ConnectWalletButton", `ve-${t.styleLevel}`]) | ||
}, null, 2) | ||
]), | ||
@@ -427,39 +453,60 @@ _: 1 | ||
} | ||
}, Me = /* @__PURE__ */ q(Ut, [["__scopeId", "data-v-b6827a89"]]), Mt = { class: "SelectWalletDropdown" }, Bt = { key: 0 }, jt = ["src", "alt"], Lt = { key: 1 }, Gt = /* @__PURE__ */ c("p", null, "Select a wallet", -1), qt = [ | ||
Gt | ||
], Ft = ["onClick"], Ht = ["src", "alt"], Be = { | ||
}, qe = /* @__PURE__ */ H(Mt, [["__scopeId", "data-v-a10b4efb"]]), jt = { class: "SelectWalletDropdown" }, Vt = { key: 0 }, Lt = /* @__PURE__ */ l("p", null, "Connection requested...", -1), qt = [ | ||
Lt | ||
], Gt = { key: 1 }, Ft = /* @__PURE__ */ l("p", null, "Connection refused!", -1), Ht = [ | ||
Ft | ||
], zt = { key: 2 }, Kt = /* @__PURE__ */ l("p", null, "Select a wallet", -1), Yt = [ | ||
Kt | ||
], Zt = ["src", "alt"], Qt = ["onClick"], Jt = ["src", "alt"], Ge = { | ||
__name: "SelectWalletDropdown", | ||
setup(r) { | ||
let t = m({}), e = m([]), s = m(!1); | ||
setup(i) { | ||
let t = y(null), e = y([]), s = y(!1), n = y({}); | ||
a.onSafe(async function() { | ||
t.value = await a.config.wallets.getCurrent(), e.value = a.config.wallets.getAvailable().filter((i) => i !== t.value); | ||
e.value = a.config.wallets.getAvailable(); | ||
}), a.provider.onSafe(async function() { | ||
n.value = await a.config.networks.getCurrent(); | ||
}), a.signer.onSafe(async function() { | ||
t.value = await a.config.wallets.getCurrent(), console.log(t.value); | ||
try { | ||
e.value = a.config.wallets.getAvailable().filter((c) => c.id !== t.value.id); | ||
} catch { | ||
e.value = a.config.wallets.getAvailable(); | ||
} | ||
}); | ||
function n() { | ||
function r() { | ||
s.value = !s.value; | ||
} | ||
return (i, d) => { | ||
const h = C("OnDappSafe"); | ||
return l(), g(h, null, { | ||
default: R(() => [ | ||
c("div", Mt, [ | ||
c("ul", { onClick: n }, [ | ||
o(t) ? (l(), u("li", Bt, [ | ||
c("img", { | ||
return (c, h) => { | ||
const p = E("OnDappSafe"); | ||
return u(), g(p, null, { | ||
default: S(() => [ | ||
l("div", jt, [ | ||
l("ul", null, [ | ||
o(a).signer.status.is("REQUESTED") ? (u(), d("li", Vt, qt)) : o(a).signer.status.is("REFUSED") ? (u(), d("li", Gt, Ht)) : o(a).provider.status.is("WRONG_NETWORK") ? (u(), d("li", zt, [ | ||
l("p", null, "Wrong network! (" + f(o(n) ? o(n).displayName : "unknown") + ")", 1) | ||
])) : o(a).signer.status.is("DISCONNECTED") || !o(t) ? (u(), d("li", { | ||
key: 3, | ||
onClick: r | ||
}, Yt)) : o(a).signer.status.is("CONNECTED") ? (u(), d("li", { | ||
key: 4, | ||
onClick: r | ||
}, [ | ||
l("img", { | ||
width: "40", | ||
src: o(t).icon ? o(t).icon : o(a).config.defaults.wallets.icon, | ||
alt: o(t).displayName + " logo" | ||
}, null, 8, jt), | ||
c("p", null, "cur" + f(o(t).displayName), 1) | ||
])) : (l(), u("li", Lt, qt)), | ||
o(s) ? (l(!0), u(v, { key: 2 }, S(o(e), (p) => (l(), u("li", { | ||
key: p.id, | ||
onClick: (_) => o(a).signer.connectWallet(o(a).wallets[p.id]) | ||
}, null, 8, Zt), | ||
l("p", null, f(o(t).displayName), 1) | ||
])) : I("", !0), | ||
o(s) ? (u(!0), d(w, { key: 5 }, v(o(e), (m) => (u(), d("li", { | ||
key: m.id, | ||
onClick: (G) => o(a).signer.connectWallet(m.id) | ||
}, [ | ||
c("img", { | ||
l("img", { | ||
width: "40", | ||
src: p.icon ? p.icon : o(a).config.defaults.wallets.icon, | ||
alt: p.displayName + " logo" | ||
}, null, 8, Ht), | ||
c("p", null, f(p.displayName), 1) | ||
], 8, Ft))), 128)) : E("", !0) | ||
src: m.icon ? m.icon : o(a).config.defaults.wallets.icon, | ||
alt: m.displayName + " logo" | ||
}, null, 8, Jt), | ||
l("p", null, f(m.displayName), 1) | ||
], 8, Qt))), 128)) : I("", !0) | ||
]) | ||
@@ -472,10 +519,12 @@ ]) | ||
} | ||
}, Zt = { class: "SelectNetworkDropdown" }, Yt = { key: 0 }, Kt = ["src", "alt"], zt = { key: 1 }, Qt = /* @__PURE__ */ c("p", null, "Select a network", -1), Jt = [ | ||
Qt | ||
], Xt = ["onClick"], te = ["src", "alt"], je = { | ||
}, Xt = { class: "SelectNetworkDropdown" }, te = { key: 0 }, ee = ["src", "alt"], se = { key: 1 }, ne = /* @__PURE__ */ l("p", null, "Select a network", -1), ae = [ | ||
ne | ||
], ie = ["onClick"], re = ["src", "alt"], Fe = { | ||
__name: "SelectNetworkDropdown", | ||
setup(r) { | ||
let t = m({}), e = m([]), s = m(!1); | ||
setup(i) { | ||
let t = y({}), e = y([]), s = y(!1); | ||
a.onSafe(async function() { | ||
t.value = await a.config.networks.getCurrent(), e.value = a.config.networks.getAvailable().filter((i) => i.id !== t.value.id); | ||
e.value = a.config.networks.getAvailable(); | ||
}), a.provider.onSafe(async function() { | ||
t.value = await a.config.networks.getCurrent(), e.value = a.config.networks.getAvailable().filter((r) => r.id !== t.value.id); | ||
}); | ||
@@ -485,27 +534,27 @@ function n() { | ||
} | ||
return (i, d) => { | ||
const h = C("OnDappSafe"); | ||
return l(), g(h, null, { | ||
default: R(() => [ | ||
c("div", Zt, [ | ||
c("ul", { onClick: n }, [ | ||
o(t) ? (l(), u("li", Yt, [ | ||
c("img", { | ||
return (r, c) => { | ||
const h = E("OnDappSafe"); | ||
return u(), g(h, null, { | ||
default: S(() => [ | ||
l("div", Xt, [ | ||
l("ul", { onClick: n }, [ | ||
o(t) ? (u(), d("li", te, [ | ||
l("img", { | ||
width: "40", | ||
src: o(t).icon ? o(t).icon : o(a).config.defaults.networks.icon, | ||
alt: o(t).displayName + " logo" | ||
}, null, 8, Kt), | ||
c("p", null, f(o(t).displayName), 1) | ||
])) : (l(), u("li", zt, Jt)), | ||
o(s) ? (l(!0), u(v, { key: 2 }, S(o(e), (p) => (l(), u("li", { | ||
}, null, 8, ee), | ||
l("p", null, f(o(t).displayName), 1) | ||
])) : (u(), d("li", se, ae)), | ||
o(s) ? (u(!0), d(w, { key: 2 }, v(o(e), (p) => (u(), d("li", { | ||
key: p.id, | ||
onClick: (_) => o(a).provider.changeNetwork(p.id) | ||
onClick: (m) => o(a).provider.changeNetwork(p.id) | ||
}, [ | ||
c("img", { | ||
l("img", { | ||
width: "40", | ||
src: p.icon ? p.icon : o(a).config.defaults.networks.icon, | ||
alt: p.displayName + " logo" | ||
}, null, 8, te), | ||
c("p", null, f(p.displayName), 1) | ||
], 8, Xt))), 128)) : E("", !0) | ||
}, null, 8, re), | ||
l("p", null, f(p.displayName), 1) | ||
], 8, ie))), 128)) : I("", !0) | ||
]) | ||
@@ -518,43 +567,27 @@ ]) | ||
} | ||
}, ee = { | ||
}, oe = { | ||
__name: "OnDappSafe", | ||
setup(r) { | ||
return (t, e) => o(a).isSafe.value ? (l(), u(v, { key: 0 }, [ | ||
y(t.$slots, "default"), | ||
y(t.$slots, "safe") | ||
], 64)) : y(t.$slots, "unsafe", { key: 1 }); | ||
setup(i) { | ||
return (t, e) => o(a).isSafe.value ? (u(), d(w, { key: 0 }, [ | ||
_(t.$slots, "default"), | ||
_(t.$slots, "safe") | ||
], 64)) : _(t.$slots, "unsafe", { key: 1 }); | ||
} | ||
}, se = { | ||
}, le = { | ||
__name: "OnProviderSafe", | ||
setup(r) { | ||
return (t, e) => o(a).provider.isSafe.value ? (l(), u(v, { key: 0 }, [ | ||
y(t.$slots, "default"), | ||
y(t.$slots, "safe") | ||
], 64)) : y(t.$slots, "unsafe", { key: 1 }); | ||
setup(i) { | ||
return (t, e) => o(a).provider.isSafe.value ? (u(), d(w, { key: 0 }, [ | ||
_(t.$slots, "default"), | ||
_(t.$slots, "safe") | ||
], 64)) : _(t.$slots, "unsafe", { key: 1 }); | ||
} | ||
}, ne = { | ||
}, ce = { | ||
__name: "OnSignerSafe", | ||
setup(r) { | ||
return (t, e) => o(a).signer.isSafe.value ? (l(), u(v, { key: 0 }, [ | ||
y(t.$slots, "default"), | ||
y(t.$slots, "safe") | ||
], 64)) : y(t.$slots, "unsafe", { key: 1 }); | ||
setup(i) { | ||
return (t, e) => o(a).signer.isSafe.value ? (u(), d(w, { key: 0 }, [ | ||
_(t.$slots, "default"), | ||
_(t.$slots, "safe") | ||
], 64)) : _(t.$slots, "unsafe", { key: 1 }); | ||
} | ||
}, Le = { | ||
__name: "OnContractsReadSafe", | ||
setup(r) { | ||
return (t, e) => o(a).contracts.areReadSafe.value ? (l(), u(v, { key: 0 }, [ | ||
y(t.$slots, "default"), | ||
y(t.$slots, "safe") | ||
], 64)) : y(t.$slots, "unsafe", { key: 1 }); | ||
} | ||
}, Ge = { | ||
__name: "OnContractsWriteSafe", | ||
setup(r) { | ||
return (t, e) => o(a).contracts.areWriteSafe.value ? (l(), u(v, { key: 0 }, [ | ||
y(t.$slots, "default"), | ||
y(t.$slots, "safe") | ||
], 64)) : y(t.$slots, "unsafe", { key: 1 }); | ||
} | ||
}, ae = { | ||
}, ue = { | ||
__name: "OnContractReadSafe", | ||
@@ -567,10 +600,10 @@ props: { | ||
}, | ||
setup(r) { | ||
const t = r; | ||
return (e, s) => o(a).contracts[t.contract].isReadSafe.value ? (l(), u(v, { key: 0 }, [ | ||
y(e.$slots, "default"), | ||
y(e.$slots, "safe") | ||
], 64)) : y(e.$slots, "unsafe", { key: 1 }); | ||
setup(i) { | ||
const t = i; | ||
return (e, s) => o(a).contracts[t.contract].isReadSafe.value ? (u(), d(w, { key: 0 }, [ | ||
_(e.$slots, "default"), | ||
_(e.$slots, "safe") | ||
], 64)) : _(e.$slots, "unsafe", { key: 1 }); | ||
} | ||
}, re = { | ||
}, de = { | ||
__name: "OnContractWriteSafe", | ||
@@ -583,31 +616,29 @@ props: { | ||
}, | ||
setup(r) { | ||
const t = r; | ||
return (e, s) => o(a).contracts[t.contract].isWriteSafe.value ? (l(), u(v, { key: 0 }, [ | ||
y(e.$slots, "default"), | ||
y(e.$slots, "safe") | ||
], 64)) : y(e.$slots, "unsafe", { key: 1 }); | ||
setup(i) { | ||
const t = i; | ||
return (e, s) => o(a).contracts[t.contract].isWriteSafe.value ? (u(), d(w, { key: 0 }, [ | ||
_(e.$slots, "default"), | ||
_(e.$slots, "safe") | ||
], 64)) : _(e.$slots, "unsafe", { key: 1 }); | ||
} | ||
}; | ||
const F = (r) => (X("data-v-8361140f"), r = r(), tt(), r), oe = /* @__PURE__ */ F(() => /* @__PURE__ */ c("h3", null, "Safe Runners", -1)), ie = /* @__PURE__ */ F(() => /* @__PURE__ */ c("h3", null, "Status", -1)), ce = { | ||
const z = (i) => (tt("data-v-a24ac687"), i = i(), et(), i), he = /* @__PURE__ */ z(() => /* @__PURE__ */ l("h3", null, "Safe Runners", -1)), pe = /* @__PURE__ */ z(() => /* @__PURE__ */ l("h3", null, "Status", -1)), fe = { | ||
__name: "DebugBar", | ||
setup(r) { | ||
setup(i) { | ||
return (t, e) => { | ||
const s = C("OnDappSafe"); | ||
return l(), g(s, null, { | ||
default: R(() => [ | ||
c("section", null, [ | ||
c("div", null, [ | ||
oe, | ||
c("ul", null, [ | ||
c("li", null, "DApp safe : " + f(o(a).isSafe), 1), | ||
c("li", null, "Provider safe : " + f(o(a).provider.isSafe), 1), | ||
c("li", null, "Signer safe : " + f(o(a).signer.isSafe), 1), | ||
c("li", null, "Contracts read safe : " + f(o(a).contracts.areReadSafe), 1), | ||
c("li", null, "Contracts write safe : " + f(o(a).contracts.areWriteSafe), 1), | ||
(l(!0), u(v, null, S(o(a).contracts.getAll(), (n, i) => (l(), u("li", null, [ | ||
$(" contract " + f(i) + " : ", 1), | ||
c("ul", null, [ | ||
c("li", null, "read safe : " + f(n.isReadSafe), 1), | ||
c("li", null, "write safe : " + f(n.isWriteSafe), 1) | ||
const s = E("OnDappSafe"); | ||
return u(), g(s, null, { | ||
default: S(() => [ | ||
l("section", null, [ | ||
l("div", null, [ | ||
he, | ||
l("ul", null, [ | ||
l("li", null, "DApp safe : " + f(o(a).isSafe), 1), | ||
l("li", null, "Provider safe : " + f(o(a).provider.isSafe), 1), | ||
l("li", null, "Signer safe : " + f(o(a).signer.isSafe), 1), | ||
(u(!0), d(w, null, v(o(a).contracts.getAll(), (n, r) => (u(), d("li", null, [ | ||
$(" contract " + f(r) + " : ", 1), | ||
l("ul", null, [ | ||
l("li", null, "read safe : " + f(n.isReadSafe), 1), | ||
l("li", null, "write safe : " + f(n.isWriteSafe), 1) | ||
]) | ||
@@ -617,10 +648,9 @@ ]))), 256)) | ||
]), | ||
c("div", null, [ | ||
ie, | ||
c("ul", null, [ | ||
c("li", null, "dapp : " + f(o(a).status.get()), 1), | ||
c("li", null, "provider : " + f(o(a).provider.status.get()), 1), | ||
c("li", null, "signer : " + f(o(a).signer.status.get()), 1), | ||
c("li", null, "contracts : " + f(o(a).contracts.status.get()), 1), | ||
(l(!0), u(v, null, S(o(a).contracts.getAll(), (n, i) => (l(), u("li", null, " contract " + f(i) + " : " + f(n.status.get()), 1))), 256)) | ||
l("div", null, [ | ||
pe, | ||
l("ul", null, [ | ||
l("li", null, "dapp : " + f(o(a).status.get()), 1), | ||
l("li", null, "provider : " + f(o(a).provider.status.get()), 1), | ||
l("li", null, "signer : " + f(o(a).signer.status.get()), 1), | ||
(u(!0), d(w, null, v(o(a).contracts.getAll(), (n, r) => (u(), d("li", null, " contract " + f(r) + " : " + f(n.status.get()), 1))), 256)) | ||
]) | ||
@@ -634,3 +664,3 @@ ]) | ||
} | ||
}, qe = /* @__PURE__ */ q(ce, [["__scopeId", "data-v-8361140f"]]), le = { class: "InputUnits" }, ue = ["placeholder"], de = ["value"], he = { | ||
}, He = /* @__PURE__ */ H(fe, [["__scopeId", "data-v-a24ac687"]]), me = { class: "InputUnits" }, ye = ["placeholder"], _e = ["value"], we = { | ||
__name: "InputUnits", | ||
@@ -644,29 +674,29 @@ props: { | ||
emits: ["update:modelValue"], | ||
setup(r, { emit: t }) { | ||
const e = r; | ||
let s = m(null); | ||
setup(i, { emit: t }) { | ||
const e = i; | ||
let s = y(null); | ||
const n = ["wei", "gwei", "ether"]; | ||
let i = m("wei"); | ||
function d() { | ||
let r = y("wei"); | ||
function c() { | ||
if (s.value) { | ||
const h = x.utils.parseUnits(s.value, i.value); | ||
const h = N.utils.parseUnits(s.value, r.value); | ||
t("update:modelValue", h); | ||
} | ||
} | ||
return (h, p) => (l(), u("div", le, [ | ||
V(c("input", { | ||
onInput: d, | ||
"onUpdate:modelValue": p[0] || (p[0] = (_) => W(s) ? s.value = _ : s = _), | ||
return (h, p) => (u(), d("div", me, [ | ||
B(l("input", { | ||
onInput: c, | ||
"onUpdate:modelValue": p[0] || (p[0] = (m) => T(s) ? s.value = m : s = m), | ||
type: "text", | ||
placeholder: o(e).placeholder | ||
}, null, 40, ue), [ | ||
[B, o(s)] | ||
}, null, 40, ye), [ | ||
[L, o(s)] | ||
]), | ||
V(c("select", { | ||
onChange: d, | ||
"onUpdate:modelValue": p[1] || (p[1] = (_) => W(i) ? i.value = _ : i = _) | ||
B(l("select", { | ||
onChange: c, | ||
"onUpdate:modelValue": p[1] || (p[1] = (m) => T(r) ? r.value = m : r = m) | ||
}, [ | ||
(l(), u(v, null, S(n, (_) => c("option", { value: _ }, f(_), 9, de)), 64)) | ||
(u(), d(w, null, v(n, (m) => l("option", { value: m }, f(m), 9, _e)), 64)) | ||
], 544), [ | ||
[et, o(i)] | ||
[st, o(r)] | ||
]) | ||
@@ -682,3 +712,3 @@ ])); | ||
this.states.push(this._formatState(s)); | ||
this._state = m(this.states[0]); | ||
this._state = y(this.states[0]); | ||
} | ||
@@ -698,3 +728,3 @@ _formatState(t) { | ||
get() { | ||
return T(this._state); | ||
return D(this._state); | ||
} | ||
@@ -707,3 +737,3 @@ getRef() { | ||
throw `The state given to the set() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${t}`; | ||
I(this._state, t), console.log(`Status '${this._name}' set to '${T(this._state)}'`); | ||
C(this._state, t), console.log(`Status '${this._name}' set to '${D(this._state)}'`); | ||
} | ||
@@ -728,3 +758,3 @@ is(t) { | ||
throw s; | ||
w(this._state, () => { | ||
return k(this._state, () => { | ||
this.isIn(t) && e(this.get()); | ||
@@ -735,3 +765,3 @@ }); | ||
throw s; | ||
w(this._state, () => { | ||
return k(this._state, () => { | ||
this.is(t) && e(this.get()); | ||
@@ -742,49 +772,6 @@ }); | ||
watchAny(t) { | ||
this.watch(this.states, t); | ||
return this.watch(this.states, t); | ||
} | ||
} | ||
class pe { | ||
constructor() { | ||
this.status = new P("contracts", [ | ||
"NO_PROVIDER", | ||
"WRONG_PROVIDER", | ||
"ERROR", | ||
"INITIALIZED" | ||
]), a.provider.status.watchAny((t) => { | ||
t === "WRONG" ? this.status.set("WRONG_PROVIDER") : ["DISCONNECTED", "ERROR"].includes(t) && this.status.set("NO_PROVIDER"); | ||
}); | ||
for (const t of a.config.networks.getAll()) | ||
if (t.contracts) | ||
for (const e of Object.keys(t.contracts)) | ||
this[e] = new G(e); | ||
this.areReadSafe = k(() => a.provider.isSafe.value && this.status.is("INITIALIZED")), this.areWriteSafe = k(() => a.signer.isSafe.value && this.status.is("INITIALIZED")), this.status.set("INITIALIZED"); | ||
} | ||
getAll() { | ||
const t = {}; | ||
for (const [e, s] of Object.entries(this)) | ||
s instanceof G && (t[e] = s); | ||
return t; | ||
} | ||
onReadSafe(t) { | ||
const e = N(); | ||
if (this.areReadSafe.value) | ||
t(e); | ||
else { | ||
const s = w(this.areReadSafe, () => { | ||
this.areReadSafe.value && (t(e), s()); | ||
}); | ||
} | ||
} | ||
onWriteSafe(t) { | ||
const e = N(); | ||
if (this.areWriteSafe.value) | ||
t(e); | ||
else { | ||
const s = w(this.areWriteSafe, () => { | ||
this.areWriteSafe.value && (t(e), s()); | ||
}); | ||
} | ||
} | ||
} | ||
const b = { | ||
const x = { | ||
style: { | ||
@@ -1270,6 +1257,6 @@ level: "minimal" | ||
}; | ||
class fe { | ||
class ve { | ||
constructor(t = null) { | ||
let e = {}; | ||
return t ? e = D({ ...b.style }, { ...t }) : e = b.style, window.addEventListener("load", () => { | ||
return t ? e = A({ ...x.style }, { ...t }) : e = x.style, window.addEventListener("load", () => { | ||
const s = document.getElementsByClassName("ve-app"); | ||
@@ -1282,3 +1269,3 @@ if (s) | ||
} | ||
class me { | ||
class ge { | ||
constructor(t = null) { | ||
@@ -1288,7 +1275,7 @@ if (this._list = [], t) { | ||
if (e.id) { | ||
const s = b.networks.find((i) => i.id === e.id), n = D({ ...s }, { ...e }); | ||
const s = x.networks.find((r) => r.id === e.id), n = A({ ...s }, { ...e }); | ||
n.available !== !1 && (n.available = !0), n.displayName || (n.displayName = n.name), this._list.push(n); | ||
} | ||
} | ||
for (const e of b.networks) | ||
for (const e of x.networks) | ||
this._list.find((n) => n.id === e.id) || (e.available = !1, this._list.push(e)); | ||
@@ -1324,3 +1311,3 @@ } | ||
} | ||
class ye { | ||
class Se { | ||
constructor(t = null) { | ||
@@ -1330,15 +1317,11 @@ if (this._list = [], t) { | ||
if (e.id) { | ||
const s = b.wallets.find((i) => i.id === e.id), n = D({ ...s }, { ...e }); | ||
const s = x.wallets.find((r) => r.id === e.id), n = A({ ...s }, { ...e }); | ||
n.available !== !1 && (n.available = !0), n.displayName || (n.displayName = n.id), this._list.push(n); | ||
} | ||
} | ||
for (const e of b.wallets) | ||
for (const e of x.wallets) | ||
this._list.find((n) => n.id === e.id) || (e.available = !1, this._list.push(e)); | ||
} | ||
async getCurrent() { | ||
if (a.signer.proxy.ethersInstance) { | ||
const t = a.provider.connection.url; | ||
return this.getById(t); | ||
} | ||
return null; | ||
getCurrent() { | ||
return console.log("GET CURRENT, id = " + a.signer.id), a.signer.proxy.ethersInstance ? this.getById(a.signer.id) : null; | ||
} | ||
@@ -1358,103 +1341,131 @@ getById(t) { | ||
} | ||
class _e { | ||
class Ie { | ||
constructor(t = null) { | ||
let e = {}; | ||
return t ? e = D({ ...b.defaults }, { ...t }) : e = b.defaults, e; | ||
return t ? e = A({ ...x.defaults }, { ...t }) : e = x.defaults, e; | ||
} | ||
} | ||
class ve { | ||
class Ee { | ||
constructor(t = null) { | ||
this.style = new fe(t ? t.style : null), this.networks = new me(t ? t.networks : null), this.wallets = new ye(t ? t.wallets : null), this.defaults = new _e(t ? t.defaults : null); | ||
this.style = new ve(t ? t.style : null), this.networks = new ge(t ? t.networks : null), this.wallets = new Se(t ? t.wallets : null), this.defaults = new Ie(t ? t.defaults : null); | ||
} | ||
} | ||
class U { | ||
class M { | ||
constructor(t = null, e = null, s = null) { | ||
const n = new Proxy(this, { | ||
get: function(r, c, h) { | ||
if (c === "proxy") | ||
return r.proxy; | ||
if (r.proxy.ethersInstance && r.proxy.ethersInstance[c] !== void 0) | ||
return typeof r.proxy.ethersInstance[c] == "function" ? r.proxy.ethersInstance[c].bind(r.proxy.ethersInstance) : r.proxy.ethersInstance[c]; | ||
if (r.proxy.ethersInstance && r.proxy.extensionInstance && r.proxy.extensionInstance[c] !== void 0) | ||
return typeof r.proxy.extensionInstance[c] == "function" ? r.proxy.extensionInstance[c].bind(h) : r.proxy.extensionInstance[c]; | ||
if (r.proxy.placeholderInstance && r.proxy.placeholderInstance[c] !== void 0) | ||
return typeof r.proxy.placeholderInstance[c] == "function" ? r.proxy.placeholderInstance[c].bind(h) : r.proxy.placeholderInstance[c]; | ||
}, | ||
set: function(r, c, h, p) { | ||
if (r.proxy.ethersInstance && r.proxy.ethersInstance[c] !== void 0) | ||
return r.proxy.ethersInstance[c] = h, !0; | ||
if (r.proxy.extensionInstance && r.proxy.extensionInstance[c] !== void 0) | ||
return r.proxy.extensionInstance[c] = h, !0; | ||
if (r.proxy.placeholderInstance && r.proxy.placeholderInstance[c] !== void 0) | ||
return r.proxy.placeholderInstance[c] = h, !0; | ||
throw console.log(r.proxy.placeholderInstance), console.log(r.proxy.placeholderInstance[c]), `New properties cannot be set on TulipeProxy instances. Please define '${c}' in constructor firstly.`; | ||
} | ||
}); | ||
return this.proxy = { | ||
_ethersInstance: t && L(t), | ||
_initIsRunning: !1, | ||
_ethersInstance: null, | ||
get ethersInstance() { | ||
return this._ethersInstance; | ||
}, | ||
set ethersInstance(n) { | ||
this._ethersInstance = n && L(n); | ||
set ethersInstance(r) { | ||
this.placeholderInstance._ars.oldEthersInstance = { ...this._ethersInstance }, this._ethersInstance = r && nt(r), this._initIsRunning || n._asyncInit(); | ||
}, | ||
extensionInstance: e, | ||
placeholderInstance: s | ||
}, new Proxy(this, { | ||
get: function(n, i, d) { | ||
if (i === "proxy") | ||
return n.proxy; | ||
if (n.proxy.ethersInstance && n.proxy.ethersInstance[i]) | ||
return typeof n.proxy.ethersInstance[i] == "function" ? n.proxy.ethersInstance[i].bind(n.proxy.ethersInstance) : n.proxy.ethersInstance[i]; | ||
if (n.proxy.ethersInstance && n.proxy.extensionInstance && n.proxy.extensionInstance[i]) | ||
return typeof n.proxy.extensionInstance[i] == "function" ? n.proxy.extensionInstance[i].bind(d) : n.proxy.extensionInstance[i]; | ||
if (n.proxy.placeholderInstance && n.proxy.placeholderInstance[i]) | ||
return typeof n.proxy.placeholderInstance[i] == "function" ? n.proxy.placeholderInstance[i].bind(d) : n.proxy.placeholderInstance[i]; | ||
}, | ||
set: function(n, i, d, h) { | ||
if (n.proxy.ethersInstance && n.proxy.ethersInstance[i]) | ||
return n.proxy.ethersInstance[i] = d, !0; | ||
if (n.proxy.extensionInstance && n.proxy.extensionInstance[i]) | ||
return n.proxy.extensionInstance[i] = d, !0; | ||
if (n.proxy.placeholderInstance && n.proxy.placeholderInstance[i]) | ||
return n.proxy.placeholderInstance[i] = d, !0; | ||
throw "New properties cannot be set on TulipeProxy instances. Please define them in instances constructor firstly."; | ||
} | ||
}); | ||
}, this.proxy.ethersInstance = t, n; | ||
} | ||
} | ||
class we { | ||
class Ce { | ||
} | ||
class Se { | ||
class j { | ||
constructor() { | ||
this.status = new P("provider", [ | ||
this._ars = {}; | ||
} | ||
_purgeARS() { | ||
if (this._ars.unwatchers) | ||
for (const t of this._ars.unwatchers) | ||
t(); | ||
if (this._ars.unwatchers = [], this._ars.oldEthersInstance && this._ars.events) | ||
for (const [t, e] of Object.entries(this._ars.events)) | ||
this._ars.oldEthersInstance.off(t, e); | ||
} | ||
_initEthersInstanceARS() { | ||
} | ||
_initPlaceholderInstanceARS() { | ||
} | ||
_initARS() { | ||
this._purgeARS(), this.proxy.ethersInstance && this._initEthersInstanceARS(), this._initPlaceholderInstanceARS(); | ||
} | ||
onSafe(t) { | ||
const e = U(); | ||
if (this.isSafe.value) | ||
t(e); | ||
else { | ||
const s = k(this.isSafe, () => { | ||
this.isSafe.value && (t(e), s()); | ||
}); | ||
} | ||
} | ||
} | ||
class be extends j { | ||
constructor() { | ||
super(), this.status = new P("provider", [ | ||
"DISCONNECTED", | ||
"WRONG", | ||
"ERROR", | ||
"WRONG_NETWORK", | ||
"CONNECTED" | ||
]), this.isSafe = k(() => a.isSafe.value && !this.status.isIn(["DISCONNECTED", "ERROR"])), this.OnSafe = se; | ||
]), this.isSafe = O(() => a.isSafe.value && !this.status.isIn(["DISCONNECTED", "ERROR"])), this.OnSafe = le; | ||
} | ||
async _getProviderFromWebWallet() { | ||
_autoInstantiateFromWallet() { | ||
for (const t of Object.values(a.wallets)) | ||
if (t) { | ||
const e = t.getProvider(); | ||
if (e) | ||
return e; | ||
} | ||
return null; | ||
t && t.provider && (this.proxy.ethersInstance = t.provider); | ||
} | ||
async _initProviderConnection() { | ||
const t = await this._getProviderFromWebWallet(); | ||
if (t) | ||
this.proxy.ethersInstance = new x.providers.Web3Provider(t, "any"); | ||
else { | ||
const e = a.config.networks.getDefault(); | ||
e && e.defaultRPC && (this.proxy.ethersInstance = new x.providers.JsonRpcProvider(e.defaultRPC)); | ||
} | ||
_autoInstantiateFromDefaultConfig() { | ||
const t = a.config.networks.getDefault(); | ||
t && t.defaultRPC && (this.proxy.ethersInstance = new N.providers.JsonRpcProvider(t.defaultRPC)); | ||
} | ||
_autoInstantiate() { | ||
this._autoInstantiateFromWallet(), this.proxy.ethersInstance || this._autoInstantiateFromDefaultConfig(); | ||
} | ||
_initARS() { | ||
this.on("network", (t, e) => { | ||
e && e !== t && window.location.reload(); | ||
}), this.on("error", () => { | ||
this.status.set("ERROR"); | ||
}); | ||
} | ||
async _asyncInit() { | ||
if (await this._initProviderConnection(), !this.proxy.ethersInstance) | ||
this.status.set("DISCONNECTED"); | ||
else { | ||
const t = await this.getNetwork(); | ||
let e = await a.config.networks.getById(t.chainId); | ||
if (e) | ||
this.status.set("CONNECTED"); | ||
else if (this.status.set("WRONG"), e = a.config.networks.getAll().find((s) => s.id === t.id), !e) { | ||
const s = { | ||
name: t.name, | ||
displayName: nt(t.name), | ||
id: t.chainId | ||
}; | ||
console.log(s), a.config.networks.add(s); | ||
} | ||
e && e.pollingInterval && (this.pollingInterval = e.pollingInterval), this._initARS(); | ||
async _checkNetwork() { | ||
if (!this.proxy.ethersInstance) | ||
throw "<TulipeProviderProxy instance>._checkNetwork() method must not be called if the ethersInstance is null (if not connected to any network)."; | ||
const t = await this.getNetwork(); | ||
let e = await a.config.networks.getById(t.chainId); | ||
if (e) | ||
this.status.set("CONNECTED"); | ||
else if (this.status.set("WRONG_NETWORK"), e = a.config.networks.getAll().find((s) => s.id === t.id), !e) { | ||
const s = { | ||
name: t.name, | ||
displayName: lt(t.name), | ||
id: t.chainId | ||
}; | ||
console.log(s), a.config.networks.add(s); | ||
} | ||
} | ||
async _setNetworkSettings() { | ||
const t = await this.getNetwork(); | ||
let e = await a.config.networks.getById(t.chainId); | ||
e && e && e.pollingInterval && (this.pollingInterval = e.pollingInterval); | ||
} | ||
async _asyncInit() { | ||
this.proxy._initIsRunning = !0, this.proxy.ethersInstance || this._autoInstantiate(), this.proxy.ethersInstance ? (await this._checkNetwork(), await this._setNetworkSettings(), this._initARS()) : this.status.set("DISCONNECTED"), this.proxy._initIsRunning = !1; | ||
} | ||
async changeNetwork(t) { | ||
@@ -1464,16 +1475,10 @@ const e = await a.config.wallets.getCurrent(); | ||
} | ||
onSafe(t) { | ||
const e = N(); | ||
if (this.isSafe.value) | ||
t(e); | ||
else { | ||
const s = w(this.isSafe, () => { | ||
this.isSafe.value && (t(e), s()); | ||
}); | ||
} | ||
} | ||
} | ||
class ge extends U { | ||
constructor(t, e = null, s = null, n = null) { | ||
s = s || new we(), n = n || new Se(), super(e, s, n), this._asyncInit(); | ||
class ke extends M { | ||
constructor(t = null, e = null, s = null) { | ||
super( | ||
t, | ||
e || new Ce(), | ||
s || new be() | ||
), this._asyncInit(); | ||
} | ||
@@ -1483,5 +1488,6 @@ } | ||
} | ||
class Ee { | ||
class xe extends j { | ||
constructor() { | ||
this.address = m(null), this.status = new P("signer", [ | ||
super(), this.id = null, this.address = y(null), this.status = new P("signer", [ | ||
"NO_PROVIDER", | ||
"DISCONNECTED", | ||
@@ -1491,10 +1497,11 @@ "REQUESTED", | ||
"ERROR", | ||
"NO_PROVIDER", | ||
"WRONG_PROVIDER", | ||
"WRONG_NETWORK", | ||
"CONNECTED" | ||
]), this.isSafe = k(() => a.provider.isSafe.value && this.status.is("CONNECTED")), this.OnSafe = ne; | ||
]), this.isSafe = O(() => a.provider.isSafe.value && this.status.is("CONNECTED")), this.OnSafe = ce; | ||
} | ||
initARS() { | ||
_initEthersInstanceARS() { | ||
} | ||
_initPlaceholderInstanceARS() { | ||
a.provider.status.watchAny((t) => { | ||
t === "WRONG" ? this.status.set("WRONG_PROVIDER") : ["DISCONNECTED", "ERROR"].includes(t) && this.status.set("NO_PROVIDER"); | ||
t === "WRONG_NETWORK" ? this.status.set("WRONG_NETWORK") : ["DISCONNECTED", "ERROR"].includes(t) && this.status.set("NO_PROVIDER"); | ||
}), this.status.watch(["REFUSED", "ERROR"], () => { | ||
@@ -1506,39 +1513,36 @@ setTimeout(() => { | ||
} | ||
async _autoInstantiate() { | ||
console.log(a.wallets); | ||
for (const t of Object.keys(a.wallets)) | ||
if (a.wallets[t].lazyConnectAvailable && (await this.connectWallet(t, !0), this.proxy.ethersInstance)) | ||
break; | ||
} | ||
async _asyncInit() { | ||
const t = this; | ||
a.provider.onSafe(async function() { | ||
for (const e of Object.values(a.wallets)) | ||
await t.connectWallet(e, !0); | ||
}), this.initARS(); | ||
this.proxy._initIsRunning = !0, a.provider.onSafe(async function() { | ||
this.proxy.ethersInstance || await this._autoInstantiate(), this.proxy.ethersInstance || this.status.set("DISCONNECTED"), this._initARS(), this.proxy._initIsRunning = !1; | ||
}.bind(this)); | ||
} | ||
onSafe(t) { | ||
const e = N(); | ||
if (this.isSafe.value) | ||
t(e); | ||
else { | ||
const s = w(this.isSafe, () => { | ||
this.isSafe.value && (t(e), s()); | ||
}); | ||
} | ||
async _setSignerDatas(t) { | ||
const e = await t.getSigner(), s = await e.getAddress(); | ||
this.address.value = s, a.signer.proxy.ethersInstance = e, this.id = t.id, a.signer.status.set("CONNECTED"); | ||
} | ||
async connectWallet(t, e = !1) { | ||
if (a.signer.status.is("DISCONNECTED")) | ||
try { | ||
const s = await a.provider.getSigner(), n = await s.getAddress(); | ||
a.signer.proxy.ethersInstance = s, this.address.value = n, a.signer.status.set("CONNECTED"); | ||
} catch { | ||
if (e === !0) | ||
a.signer.status.set("DISCONNECTED"); | ||
else { | ||
this.status.set("REQUESTED"); | ||
try { | ||
await t.connect(), this.status.set("CONNECTED"); | ||
} catch (n) { | ||
if (n instanceof j) | ||
this.status.set("REFUSED"); | ||
else | ||
throw this.status.set("ERROR"), n; | ||
} | ||
} | ||
console.log("CONNECT lazy = " + e); | ||
const s = a.wallets[t]; | ||
if (s.lazyConnectAvailable) { | ||
if (await s.connect(!0), await s.isConnected()) | ||
await this._setSignerDatas(s); | ||
else if (e) { | ||
a.signer.status.set("DISCONNECTED"); | ||
return; | ||
} | ||
} | ||
try { | ||
this.status.set("REQUESTED"), await s.connect(!1), await this._setSignerDatas(s); | ||
} catch (n) { | ||
if (n instanceof q) | ||
this.status.set("REFUSED"); | ||
else | ||
throw this.status.set("ERROR"), n; | ||
} | ||
} | ||
@@ -1549,8 +1553,12 @@ disconnectWallet() { | ||
} | ||
class Ce extends U { | ||
constructor(t, e = null, s = null, n = null) { | ||
s = s || new Re(), n = n || new Ee(), super(e, s, n), this._asyncInit(); | ||
class Ne extends M { | ||
constructor(t = null, e = null, s = null) { | ||
super( | ||
t, | ||
e || new Re(), | ||
s || new xe() | ||
), this._asyncInit(); | ||
} | ||
} | ||
class Ie { | ||
class Oe { | ||
_watch(t, e, s = null) { | ||
@@ -1560,14 +1568,14 @@ return Object.keys(a.chainWatchers.contracts).includes(this.address) || a.chainWatchers.addContractWatcher(this), a.chainWatchers.contracts[this.address].add(t, e, s); | ||
watch(t, e, s, n = null) { | ||
const i = this._watch(t, e, s); | ||
return n ? A(() => { | ||
a.chainWatchers.contracts[this.address].remove(t, e, i); | ||
}, n) : A(() => { | ||
a.chainWatchers.contracts[this.address].remove(t, e, i); | ||
}), a.chainWatchers.contracts[this.address].remove.bind(a.chainWatchers.contracts[this.address], t, e, i); | ||
const r = this._watch(t, e, s); | ||
return n ? W(() => { | ||
a.chainWatchers.contracts[this.address].remove(t, e, r); | ||
}, n) : W(() => { | ||
a.chainWatchers.contracts[this.address].remove(t, e, r); | ||
}), a.chainWatchers.contracts[this.address].remove.bind(a.chainWatchers.contracts[this.address], t, e, r); | ||
} | ||
watchRef(t, e, s = null) { | ||
const n = this._watch(t, e, null); | ||
return s ? A(() => { | ||
return s ? W(() => { | ||
a.chainWatchers.contracts[this.address].remove(t, e, n); | ||
}, s) : A(() => { | ||
}, s) : W(() => { | ||
a.chainWatchers.contracts[this.address].remove(t, e, n); | ||
@@ -1577,17 +1585,20 @@ }), a.chainWatchers.contracts[this.address].getRef(t, e); | ||
} | ||
class ke { | ||
constructor(t) { | ||
this.name = t, this.status = new P(`contract:${t}`, [ | ||
class $e extends j { | ||
constructor() { | ||
super(), this.name = "TODO", this.status = new P(`contract:${name}`, [ | ||
"NO_PROVIDER", | ||
"WRONG_PROVIDER", | ||
"UNAVAILABLE", | ||
"ERROR", | ||
"INITIALIZED" | ||
]), this.isReadSafe = k(() => a.provider.isSafe.value && this.status.is("INITIALIZED")), this.isWriteSafe = k(() => a.signer.isSafe.value && this.status.is("INITIALIZED")), this.OnReadSafe = O(ae, { contract: this.name }), this.OnWriteSafe = O(re, { contract: this.name }); | ||
]), this.isReadSafe = O(() => a.provider.isSafe.value && this.status.is("INITIALIZED")), this.isWriteSafe = O(() => a.signer.isSafe.value && this.status.is("INITIALIZED")), this.OnReadSafe = R(ue, { contract: this.name }), this.OnWriteSafe = R(de, { contract: this.name }); | ||
} | ||
onSafe(t) { | ||
throw "TulipeContract instances don't have 'onSafe()' method, use 'onReadSafe()' and 'onWriteSafe()' instead."; | ||
} | ||
onReadSafe(t) { | ||
const e = N(); | ||
const e = U(); | ||
if (this.isReadSafe.value) | ||
t(e); | ||
else { | ||
const s = w(this.isReadSafe, () => { | ||
const s = k(this.isReadSafe, () => { | ||
this.isReadSafe.value && (t(e), s()); | ||
@@ -1598,7 +1609,7 @@ }); | ||
onWriteSafe(t) { | ||
const e = N(); | ||
const e = U(); | ||
if (this.isWriteSafe.value) | ||
t(e); | ||
else { | ||
const s = w(this.isWriteSafe, () => { | ||
const s = k(this.isWriteSafe, () => { | ||
this.isWriteSafe.value && (t(e), s()); | ||
@@ -1610,5 +1621,5 @@ }); | ||
if (a.signer.isSafe.value) | ||
this.proxy.ethersInstance = new x.Contract(t, e, a.signer.proxy.ethersInstance); | ||
this.proxy.ethersInstance = new N.Contract(t, e, a.signer.proxy.ethersInstance); | ||
else if (a.provider.isSafe.value) | ||
this.proxy.ethersInstance = new x.Contract(t, e, a.provider.proxy.ethersInstance); | ||
this.proxy.ethersInstance = new N.Contract(t, e, a.provider.proxy.ethersInstance); | ||
else | ||
@@ -1618,33 +1629,32 @@ throw `_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`; | ||
_initARS(t, e) { | ||
a.provider.status.watchAny((s) => { | ||
s === "WRONG" ? this.status.set("WRONG_PROVIDER") : ["DISCONNECTED", "ERROR"].includes(s) && this.status.set("NO_PROVIDER"); | ||
}), w([a.signer.isSafe], (s, n) => { | ||
s !== n && (this.proxy.ethersInstance = null, this._updateContract(t, e)); | ||
}); | ||
this._purgeARS(), this._ars.unwatchers.push( | ||
a.provider.status.watchAny((s) => { | ||
s === "WRONG_NETWORK" ? this.status.set("UNAVAILABLE") : ["DISCONNECTED", "ERROR"].includes(s) && this.status.set("NO_PROVIDER"); | ||
}) | ||
), this._ars.unwatchers.push( | ||
k([a.signer.isSafe], (s, n) => { | ||
s !== n && (this.proxy.ethersInstance = null, this._updateContract(t, e)); | ||
}) | ||
); | ||
} | ||
async _asyncInit() { | ||
a.provider.onSafe(async function() { | ||
try { | ||
const t = await a.config.networks.getCurrent(); | ||
if (t && t.contracts && Object.keys(t.contracts).includes(this.name)) { | ||
const e = t.contracts[this.name]; | ||
this._updateContract(e.address, e.abi), this._initARS(e.address, e.abi), this.status.set("INITIALIZED"); | ||
} else | ||
this.status.set("WRONG_PROVIDER"); | ||
} catch (t) { | ||
throw this.status.set("ERROR"), t; | ||
} | ||
this.proxy._initIsRunning = !0, a.provider.onSafe(async function() { | ||
this.proxy.ethersInstance ? this._initARS() : this.status.set("UNAVAILABLE"), this.proxy._initIsRunning = !1; | ||
}.bind(this)); | ||
} | ||
} | ||
class G extends U { | ||
class F extends M { | ||
constructor(t, e = null, s = null, n = null) { | ||
s = s || new Ie(), n = n || new ke(t), super(e, s, n), this._asyncInit(); | ||
super( | ||
e, | ||
s || new Oe(), | ||
n || new $e(t) | ||
), this._asyncInit(); | ||
} | ||
} | ||
class Oe { | ||
class Ae { | ||
} | ||
class be { | ||
class Te extends j { | ||
constructor(t, e, s = [], n = { value: 0 }) { | ||
this.contractName = t, this.methodName = e, this.methodInfos = {}, this.args = m(s), this.txArgs = m(n), this.data = m([]), this.error = m(null), this.call = null, this.status = new P(`tx:${t}:${e}`, [ | ||
super(), this.contractName = t, this.methodName = e, this.methodInfos = {}, this.args = y(s), this.txArgs = y(n), this.data = y([]), this.error = y(null), this.call = null, this.status = new P(`tx:${t}:${e}`, [ | ||
"NOT_READY", | ||
@@ -1665,5 +1675,5 @@ "READY", | ||
_asyncInit() { | ||
a.contracts[this.contractName].isReadSafe.value && this._initEthersInstance(), a.contracts[this.contractName].onReadSafe(() => { | ||
this.proxy._initIsRunning = !0, a.contracts[this.contractName].isReadSafe.value && this._initEthersInstance(), a.contracts[this.contractName].onReadSafe(() => { | ||
this._initEthersInstance(); | ||
}), this.initARS(); | ||
}), this.initARS(), this.proxy._initIsRunning = !1; | ||
} | ||
@@ -1674,46 +1684,24 @@ _initEthersInstance() { | ||
send(t = null, e = null) { | ||
t = t && t.length > 0 ? t : T(this.args), t ? Array.isArray(t) ? this.call = this.proxy.ethersInstance(...t, e) : this.call = this.proxy.ethersInstance(t, e) : this.call = this.proxy.ethersInstance(e), this.status.set("SENT"), this.methodInfos.constant ? this.call.then((s) => { | ||
Array.isArray(s) || (s = [s]), I(this.data, s), I(this.error, null), this.status.set("SUCCESS"); | ||
t = t && t.length > 0 ? t : D(this.args), t ? Array.isArray(t) ? this.call = this.proxy.ethersInstance(...t, e) : this.call = this.proxy.ethersInstance(t, e) : this.call = this.proxy.ethersInstance(e), this.status.set("SENT"), this.methodInfos.constant ? this.call.then((s) => { | ||
Array.isArray(s) || (s = [s]), C(this.data, s), C(this.error, null), this.status.set("SUCCESS"); | ||
}).catch((s) => { | ||
I(this.error, s), this.status.set("ERROR"); | ||
C(this.error, s), this.status.set("ERROR"); | ||
}) : this.call.then((s) => s.wait()).then((s) => { | ||
Array.isArray(s) || (s = [s]), I(this.data, s), I(this.error, null), this.status.set("SUCCESS"); | ||
Array.isArray(s) || (s = [s]), C(this.data, s), C(this.error, null), this.status.set("SUCCESS"); | ||
}).catch((s) => { | ||
I(this.error, s), this.status.set("ERROR"), console.log(s); | ||
C(this.error, s), this.status.set("ERROR"), console.log(s); | ||
}); | ||
} | ||
} | ||
class H extends U { | ||
constructor(t, e, s = [], n = { value: 0 }, i = null, d = null, h = null) { | ||
d = d || new Oe(), h = h || new be(t, e, s = [], n = { value: 0 }), super(i, d, h), this._asyncInit(); | ||
class K extends M { | ||
constructor(t, e, s = [], n = { value: 0 }, r = null, c = null, h = null) { | ||
super( | ||
r, | ||
c || new Ae(), | ||
h || new Te(t, e, s = [], n = { value: 0 }) | ||
), this._asyncInit(); | ||
} | ||
} | ||
class Ne { | ||
class Y { | ||
constructor() { | ||
this.contracts = {}, this.wallets = {}; | ||
} | ||
async _asyncInit() { | ||
a.provider.onSafe(() => { | ||
a.provider.on("block", async function(t) { | ||
const e = await a.provider.getBlockWithTransactions(t); | ||
for (const s of e.transactions) | ||
Object.keys(this.contracts).includes(s.to) ? this.contracts[s.to].update() : Object.keys(this.wallets).includes(s.to) && this.wallets[s.to].update(), Object.keys(this.contracts).includes(s.from) ? this.contracts[s.from].update() : Object.keys(this.wallets).includes(s.from) && this.wallets[s.from].update(); | ||
}); | ||
}); | ||
} | ||
addContractWatcher(t) { | ||
Object.keys(this.contracts).includes(t.address) || (this.contracts[t.address] = new xe(t)); | ||
} | ||
removeContractWatcher(t) { | ||
Object.keys(this.contracts).includes(t.address) && delete this.contracts[t.address]; | ||
} | ||
addWalletWatcher(t) { | ||
Object.keys(this.wallets).includes(t) || (this.wallets[t] = new $e(t)); | ||
} | ||
removeContractWatcher(t) { | ||
Object.keys(this.wallets).includes(t) && delete this.wallets[t]; | ||
} | ||
} | ||
class Z { | ||
constructor() { | ||
this.lastUpdateBlock = 0, this.sources = {}; | ||
@@ -1744,3 +1732,3 @@ } | ||
} | ||
class xe extends Z { | ||
class De extends Y { | ||
constructor(t) { | ||
@@ -1764,13 +1752,13 @@ super(), this.contract = t; | ||
const n = this._buildSourceName(t, e); | ||
let i = !1; | ||
let r = !1; | ||
Object.keys(this.sources).includes(n) || (this.sources[n] = { | ||
name: t, | ||
args: e, | ||
state: m(null), | ||
state: y(null), | ||
dependents: {} | ||
}, i = !0); | ||
let d = null; | ||
s && (d = w(this.sources[n].state, s)); | ||
}, r = !0); | ||
let c = null; | ||
s && (c = k(this.sources[n].state, s)); | ||
const h = this._generateDependentUUID(); | ||
return this.sources[n].dependents[h] = d, i && this._updateState(this.sources[n]), h; | ||
return this.sources[n].dependents[h] = c, r && this._updateState(this.sources[n]), h; | ||
} | ||
@@ -1780,4 +1768,4 @@ remove(t, e, s) { | ||
if (Object.keys(this.sources).includes(n) && Object.keys(this.sources[n].dependents).includes(s)) { | ||
const i = this.sources[n].dependents[s]; | ||
i && i(), delete this.sources[n].dependents[s]; | ||
const r = this.sources[n].dependents[s]; | ||
r && r(), delete this.sources[n].dependents[s]; | ||
} | ||
@@ -1791,3 +1779,3 @@ Object.keys(this.sources[n].dependents).length === 0 && delete this.sources[n]; | ||
} | ||
class $e extends Z { | ||
class Pe extends Y { | ||
constructor(t) { | ||
@@ -1816,6 +1804,6 @@ super(), this.address = t, this.availableSources = ["balance"]; | ||
}, newSource = !0); | ||
let i = null; | ||
s && (i = watch(this.sources[n].state, s)); | ||
const d = this._generateDependentUUID(); | ||
return this.sources[n].dependents[d] = i, newSource && this._updateState(this.sources[n]), d; | ||
let r = null; | ||
s && (r = watch(this.sources[n].state, s)); | ||
const c = this._generateDependentUUID(); | ||
return this.sources[n].dependents[c] = r, newSource && this._updateState(this.sources[n]), c; | ||
} | ||
@@ -1825,4 +1813,4 @@ remove(t, e, s) { | ||
if (Object.keys(this.sources).includes(n) && Object.keys(this.sources[n].dependents).includes(s)) { | ||
const i = this.sources[n].dependents[s]; | ||
i && i(), delete this.sources[n].dependents[s]; | ||
const r = this.sources[n].dependents[s]; | ||
r && r(), delete this.sources[n].dependents[s]; | ||
} | ||
@@ -1836,35 +1824,75 @@ Object.keys(this.sources[n].dependents).length === 0 && delete this.sources[n]; | ||
} | ||
class Y { | ||
constructor() { | ||
this.provider = null, this.id = ""; | ||
class q extends Error { | ||
constructor(t, ...e) { | ||
super(t, ...e), this.message = `'${t}' wallet has rejected the connection request.`; | ||
} | ||
} | ||
class b extends Error { | ||
constructor(t, ...e) { | ||
super(walletId, ...e), this.message = t; | ||
} | ||
} | ||
class Z { | ||
constructor(t) { | ||
this.id = t, this.lazyConnectAvailable = !0; | ||
} | ||
isConnected() { | ||
throw new b(`isConnected() method is not implemented in ${this.id} wallet class.`); | ||
} | ||
getProvider() { | ||
return null; | ||
throw new b(`getProvider() method is not implemented in ${this.id} wallet class.`); | ||
} | ||
async connect() { | ||
throw `connect() method of ${this.id} wallet is not implemented.`; | ||
getSigner(t = !1) { | ||
throw new b(`getSigner() method is not implemented in ${this.id} wallet class.`); | ||
} | ||
} | ||
class j extends Error { | ||
constructor(t, ...e) { | ||
super(t, ...e), this.message = `${t} wallet has rejected the connection request.`; | ||
async connect(t = !1) { | ||
throw new b(`connect() method is not implemented in ${this.id} wallet class.`); | ||
} | ||
addNetwork(t) { | ||
throw new b(`addNetwork() method is not implemented in ${this.id} wallet class.`); | ||
} | ||
switchNetwork(t, e = !1) { | ||
throw new b(`switchNetwork() method is not implemented in ${this.id} wallet class.`); | ||
} | ||
} | ||
class K extends Y { | ||
constructor() { | ||
super(), this.id = "metamask", this.provider = this.getProvider(); | ||
class Q extends Z { | ||
constructor(t, e = null) { | ||
super(t), this.exposedObject = e; | ||
} | ||
async isConnected() { | ||
if (this.exposedObject && this.getSigner()) | ||
try { | ||
const e = await this.exposedObject.request({ method: "eth_accounts" }); | ||
if (e && e.length > 0) | ||
return console.log(e), !0; | ||
} catch { | ||
} | ||
return !1; | ||
} | ||
getProvider() { | ||
return window.ethereum; | ||
return this.exposedObject ? new N.providers.Web3Provider(this.exposedObject, "any") : null; | ||
} | ||
async connect() { | ||
try { | ||
await this.provider.request({ method: "eth_requestAccounts" }); | ||
} catch (t) { | ||
throw t.code === 4001 ? j(this.id) : t; | ||
async getSigner() { | ||
if (this.exposedObject) { | ||
const t = this.getProvider(); | ||
if (t) | ||
return await t.getSigner(); | ||
} | ||
return null; | ||
} | ||
async connect(t = !1) { | ||
if (this.exposedObject) { | ||
if (await this.isConnected() || t) | ||
return; | ||
try { | ||
await this.exposedObject.request({ method: "eth_requestAccounts" }); | ||
} catch (e) { | ||
throw e.code === 4001 ? new q(this.id) : e; | ||
} | ||
} | ||
throw "exposedObject not available"; | ||
} | ||
async addNetwork(t) { | ||
const e = a.config.networks.getById(t); | ||
await window.ethereum.request({ | ||
await this.exposedObject.request({ | ||
method: "wallet_addEthereumChain", | ||
@@ -1884,7 +1912,7 @@ params: [{ | ||
} | ||
async changeNetwork(t) { | ||
async changeNetwork(t, e = !1) { | ||
if (a.config.networks.getById(t)) { | ||
t = x.utils.hexlify(parseInt(t)).toString(), t = x.utils.hexValue(t); | ||
t = N.utils.hexlify(parseInt(t)).toString(), t = N.utils.hexValue(t); | ||
try { | ||
await window.ethereum.request({ | ||
await this.exposedObject.request({ | ||
method: "wallet_switchEthereumChain", | ||
@@ -1895,7 +1923,7 @@ params: [{ | ||
}); | ||
} catch (s) { | ||
if (s.code === 4902) | ||
} catch (n) { | ||
if (n.code === 4902) | ||
this.addNetwork(t); | ||
else | ||
throw s; | ||
throw n; | ||
} | ||
@@ -1905,10 +1933,15 @@ } | ||
} | ||
class De extends Y { | ||
class We extends Q { | ||
constructor() { | ||
super("metamask", window.ethereum); | ||
} | ||
} | ||
class Ue extends Z { | ||
constructor(t, e = {}) { | ||
super(), this.id = "coinbase"; | ||
const s = e.appName || "", n = e.appLogoUrl, i = e.darkMode || !1; | ||
const s = e.appName || "", n = e.appLogoUrl, r = e.darkMode || !1; | ||
this.coinbaseWalletSdk = new t({ | ||
appName: s, | ||
appLogoUrl: n, | ||
darkMode: i | ||
darkMode: r | ||
}), this.provider = this.getProvider(); | ||
@@ -1927,32 +1960,24 @@ } | ||
} catch { | ||
throw j(this.id); | ||
throw q(this.id); | ||
} | ||
} | ||
} | ||
class Pe extends K { | ||
class Be extends Q { | ||
constructor() { | ||
super(), this.id = "binanceChain"; | ||
super("binanceChain", window.BinanceChain), this.lazyConnectAvailable = !1; | ||
} | ||
getProvider() { | ||
return window.BinanceChain; | ||
async isConnected() { | ||
throw new b("isConnected() method is not available for BinanceChainWallet class since lazy connection is not available."); | ||
} | ||
async connect() { | ||
super.connect.call(this); | ||
async connect(t = !1) { | ||
if (t) | ||
throw new b("connect() with 'lazy=true' is not available for BinanceChainWallet class because isConnected() is not available on this class."); | ||
} | ||
} | ||
class We { | ||
constructor() { | ||
const t = a.config.wallets.getAvailable(); | ||
for (const e of t) { | ||
const s = Te[e.id]; | ||
s && (this[e.id] = new s()); | ||
} | ||
} | ||
} | ||
const Te = { | ||
metamask: K, | ||
coinbase: De, | ||
binanceChain: Pe | ||
const Me = { | ||
metamask: We, | ||
coinbase: Ue, | ||
binanceChain: Be | ||
}; | ||
async function Fe(r, t) { | ||
async function ze(i, t) { | ||
const e = t; | ||
@@ -1964,47 +1989,42 @@ try { | ||
} | ||
r.config.globalProperties.dapp = a, r.config.globalProperties.rGet = T, r.config.globalProperties.rSet = I, window.dapp = a; | ||
const s = await import("./index.25897989.mjs"); | ||
r.component("OnDappSafe", s.OnDappSafe), r.component("OnProviderSafe", s.OnProviderSafe), r.component("OnSignerSafe", s.OnSignerSafe), r.component("OnContractsReadSafe", s.OnContractsReadSafe), r.component("OnContractsWriteSafe", s.OnContractsWriteSafe), r.component("OnContractReadSafe", s.OnContractReadSafe), r.component("OnContractWriteSafe", s.OnContractWriteSafe), a.status.set("INITIALIZED"); | ||
i.config.globalProperties.dapp = a, i.config.globalProperties.rGet = D, i.config.globalProperties.rSet = C, window.dapp = a; | ||
const s = await import("./index.4436a015.mjs"); | ||
i.component("OnDappSafe", s.OnDappSafe), i.component("OnProviderSafe", s.OnProviderSafe), i.component("OnSignerSafe", s.OnSignerSafe), i.component("OnContractReadSafe", s.OnContractReadSafe), i.component("OnContractWriteSafe", s.OnContractWriteSafe), a.status.set("INITIALIZED"); | ||
} | ||
export { | ||
Ne as ChainWatchersList, | ||
Me as ConnectWalletButton, | ||
Ue as ContractInteractor, | ||
xe as ContractWatcher, | ||
pe as ContractsList, | ||
qe as DebugBar, | ||
Ot as EventInteractor, | ||
Ct as EventsInteractor, | ||
he as InputUnits, | ||
qe as ConnectWalletButton, | ||
Le as ContractInteractor, | ||
De as ContractWatcher, | ||
He as DebugBar, | ||
At as EventInteractor, | ||
Nt as EventsInteractor, | ||
we as InputUnits, | ||
Rt as MethodInteractor, | ||
dt as MethodsInteractor, | ||
ae as OnContractReadSafe, | ||
re as OnContractWriteSafe, | ||
Le as OnContractsReadSafe, | ||
Ge as OnContractsWriteSafe, | ||
ee as OnDappSafe, | ||
se as OnProviderSafe, | ||
ne as OnSignerSafe, | ||
je as SelectNetworkDropdown, | ||
Be as SelectWalletDropdown, | ||
yt as MethodsInteractor, | ||
ue as OnContractReadSafe, | ||
de as OnContractWriteSafe, | ||
oe as OnDappSafe, | ||
le as OnProviderSafe, | ||
ce as OnSignerSafe, | ||
Fe as SelectNetworkDropdown, | ||
Ge as SelectWalletDropdown, | ||
P as Status, | ||
Pt as Transact, | ||
ve as TulipeConfig, | ||
G as TulipeContract, | ||
ge as TulipeProvider, | ||
U as TulipeProxy, | ||
Ce as TulipeSigner, | ||
H as TulipeTransaction, | ||
j as WalletConnectionRejected, | ||
$e as WalletWatcher, | ||
We as WalletsList, | ||
nt as capitalizeWords, | ||
Bt as Transact, | ||
Ee as TulipeConfig, | ||
F as TulipeContractProxy, | ||
ke as TulipeProviderProxy, | ||
M as TulipeProxy, | ||
Ne as TulipeSignerProxy, | ||
K as TulipeTransactionProxy, | ||
q as WalletConnectionRejected, | ||
Pe as WalletWatcher, | ||
lt as capitalizeWords, | ||
a as dapp, | ||
D as deepMerge, | ||
Fe as initTulipe, | ||
M as isObject, | ||
T as rGet, | ||
I as rSet, | ||
at as styleLevelProp, | ||
Te as wallets | ||
A as deepMerge, | ||
ze as initTulipe, | ||
V as isObject, | ||
D as rGet, | ||
C as rSet, | ||
ct as styleLevelProp, | ||
Me as wallets | ||
}; |
@@ -1,1 +0,1 @@ | ||
var Tulipe=function(l,t,m){"use strict";class at{constructor(){}init(e=null){this.config=new Y(e),this.status=new _("dapp",["UNSAFE","ERROR","INITIALIZED"]),this.isSafe=t.computed(()=>this.status.is("INITIALIZED")),this.OnSafe=b,this.chainWatchers=new Q,this.wallets=new nt,this.provider=new z,this.pro=this.provider,this.signer=new K,this.sig=this.signer,this.contracts=new Z,this.con=this.contracts}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}const r=new at;function g(o){return o&&typeof o=="object"&&!Array.isArray(o)}function y(o,...e){if(!e.length)return o;const n=e.shift();if(g(o)&&g(n))for(const s in n)g(n[s])?(o[s]||Object.assign(o,{[s]:{}}),y(o[s],n[s])):Object.assign(o,{[s]:n[s]});return y(o,...e)}function x(o){const e=o.split(" ");for(let n=0;n<e.length;n++)e[n]=e[n][0].toUpperCase()+e[n].substring(1);return e.join(" ")}function S(o){return t.isRef(o)?S(o.value):o}function f(o,e){t.isRef(o)?o.value=e:o=e}const me="",k={required:!1,type:String,default:"minimal",validator(o){return["unstylized","minimal","opinionated"].includes(o)}},rt={class:"ContractInteractor"},ot=t.createTextVNode(" Methods : "),it=t.createElementVNode("br",null,null,-1),lt=t.createTextVNode(" Events : "),ct=t.createElementVNode("br",null,null,-1),A={__name:"ContractInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];let s=t.ref("not owned");return r.contracts[e.contract].onReadSafe(async function(){try{s.value=await n.owner()}catch{}}),(a,i)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",rt,[t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Address : "+t.toDisplayString(t.unref(n).address),1),t.createElementVNode("li",null,"Owner : "+t.toDisplayString(t.unref(s)),1),t.createElementVNode("li",null,[ot,it,t.createVNode(t.unref(C),{contract:e.contract},null,8,["contract"])]),t.createElementVNode("li",null,[lt,ct,t.createVNode(t.unref(R),{contract:e.contract},null,8,["contract"])])])])]),_:1},8,["contract"])}}},dt={class:"MethodsInteractor"},C={__name:"MethodsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];return(s,a)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",dt,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.functions,(c,d)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(N),{contract:e.contract,method:d},null,8,["contract","method"])]))),256))])])]),_:1},8,["contract"])}}},ht={class:"MethodInteractor"},ut={key:0},ft=t.createElementVNode("p",null,"Inputs :",-1),pt=["onUpdate:modelValue","placeholder"],mt={key:0},yt={key:1},_t=t.createElementVNode("p",null,"Outputs :",-1),St=["onUpdate:modelValue","placeholder"],Et=["placeholder"],gt={key:2},N={__name:"MethodInteractor",props:{contract:{type:String,required:!0},method:{type:String,required:!0}},setup(o){const e=o,n=t.shallowRef(new P(e.contract,e.method));function s(a){return`${a.name&&a.name!=="null"?a.name:""} (${a.type})`}return(a,i)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ht,[t.createVNode(t.unref(O),{contract:e.contract,method:e.method,modelValue:t.unref(n),"onUpdate:modelValue":i[0]||(i[0]=d=>t.isRef(n)?n.value=d:null),configs:{content:e.method,notx:!0,noerror:!0}},null,8,["contract","method","modelValue","configs"]),t.createElementVNode("small",null,t.toDisplayString(t.unref(n).methodInfos.stateMutability),1),Object.keys(t.unref(n).methodInfos.inputs).length>0||t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("div",ut,[ft,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.inputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":u=>t.unref(n).args.value[h]=u,type:"text",placeholder:s(d)},null,8,pt),[[t.vModelText,t.unref(n).args.value[h]]]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).args.value[h])+" "+t.toDisplayString(typeof t.unref(n).args.value[h]),1)]))),256)),t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("li",mt,[t.createVNode(t.unref(W),{modelValue:t.unref(n).txArgs.value.value,"onUpdate:modelValue":i[1]||(i[1]=d=>t.unref(n).txArgs.value.value=d)},null,8,["modelValue"]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).txArgs.value.value)+" "+t.toDisplayString(typeof t.unref(n).txArgs.value.value),1)])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),Object.keys(t.unref(n).methodInfos.outputs).length>0?(t.openBlock(),t.createElementBlock("div",yt,[_t,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.outputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.unref(n).data.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:0,"onUpdate:modelValue":u=>t.unref(n).data.value[h]=u,type:"text",placeholder:s(d),disabled:""},null,8,St)),[[t.vModelText,t.unref(n).data.value[h]]]):(t.openBlock(),t.createElementBlock("input",{key:1,type:"text",placeholder:s(d),disabled:""},null,8,Et))]))),256))])])):t.createCommentVNode("",!0),t.unref(n).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",gt,t.toDisplayString(t.unref(n).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},wt={class:"EventsInteractor"},R={__name:"EventsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];return(s,a)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",wt,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.events,(c,d)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(I),{contract:e.contract,event:d},null,8,["contract","event"])]))),256))])])]),_:1},8,["contract"])}}},kt={class:"EventInteractor"},Ct=t.createTextVNode("Logs: "),I={__name:"EventInteractor",props:{contract:{type:String,required:!0},event:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];let s=t.ref({}),a=t.ref({}),i=t.ref(0),c=t.ref([]);return n.onReadSafe(()=>{s.value=n.interface.events[e.event],a.value=n.filters[s.value.name],n.on(a.value,d=>{i.value++;let h=`Block ${d.blockNumber} -> {`;for(const u of s.value.inputs)h+=`${u.name}:${d.args[u.name]}, `;h=h.substring(0,h.length-2)+"}",c.value.push(h)})}),(d,h)=>{const u=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(u,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",kt,[t.createElementVNode("p",null,t.toDisplayString(t.unref(s).name),1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Count : "+t.toDisplayString(t.unref(i)),1),t.createElementVNode("li",null,[Ct,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(c),pe=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(pe),1))),256))])])])])]),_:1},8,["contract"])}}},Nt={class:"TransactButton"},Rt={key:1,disabled:""},It={key:2,disabled:""},Ot={key:3,disabled:""},bt={key:4},O={__name:"Transact",props:{modelValue:{},contract:{type:String,required:!0},method:{type:String,required:!0},args:{type:Array,required:!1},txArgs:{type:Object,required:!1},configs:{type:Object,required:!1}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=r.contracts[n.contract];let a=t.computed({get(){return n.modelValue},set(c){e("update:modelValue",c)}});function i(){const c=n.args?n.args:[],d=n.txArgs?n.txArgs:{};a.value.send(c,d)}return n.config&&n.configs.notx&&s.onReadSafe(()=>{a=new P(n.contract,n.method)}),(c,d)=>{const h=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(h,{contract:n.contract},{default:t.withCtx(()=>[t.createElementVNode("div",Nt,[t.unref(a).status.is("READY")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:i},t.toDisplayString(n.configs&&n.configs.content?n.configs.content:"Transact"),1)):t.unref(a).status.is("SENT")?(t.openBlock(),t.createElementBlock("button",Rt,"Transaction sent...")):t.unref(a).status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",It,"Transaction error!")):t.unref(a).status.is("SUCCESS")?(t.openBlock(),t.createElementBlock("button",Ot,"Success !")):t.createCommentVNode("",!0),!(n.configs&&n.configs.noerror)&&t.unref(a).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",bt,t.toDisplayString(t.unref(a).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},ye="",M=(o,e)=>{const n=o.__vccOpts||o;for(const[s,a]of e)n[s]=a;return n},Bt={key:1,disabled:""},Dt={key:2,disabled:""},Vt={key:3,disabled:""},Tt={key:4,disabled:""},U=M({__name:"ConnectWalletButton",props:{styleLevel:k},setup(o){const e=o;let n=t.ref({});return r.provider.onSafe(async function(){n.value=await r.config.networks.getCurrent()}),(s,a)=>(t.openBlock(),t.createBlock(t.unref(r).provider.OnSafe,null,{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(["ConnectWalletButton",`ve-${e.styleLevel}`])},[t.unref(r).signer.status.is("DISCONNECTED")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:a[0]||(a[0]=i=>t.unref(r).signer.connectWallet(t.unref(r).wallets.metamask))},"Connect Wallet")):t.unref(r).signer.status.is("REQUESTED")?(t.openBlock(),t.createElementBlock("button",Bt,"Connection requested...")):t.unref(r).signer.status.is("REFUSED")?(t.openBlock(),t.createElementBlock("button",Dt,"Connection refused!")):t.unref(r).signer.status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",Vt,"Connection error!")):t.unref(r).provider.status.is("WRONG")?(t.openBlock(),t.createElementBlock("button",Tt,"Wrong network! ("+t.toDisplayString(t.unref(n)?t.unref(n).displayName:"unknown")+")",1)):t.unref(r).signer.status.is("CONNECTED")?(t.openBlock(),t.createElementBlock("button",{key:5,onClick:a[1]||(a[1]=(...i)=>t.unref(r).signer.disconnectWallet&&t.unref(r).signer.disconnectWallet(...i))},"Disconnect")):t.createCommentVNode("",!0)],2)]),_:1}))}},[["__scopeId","data-v-b6827a89"]]),Wt={class:"SelectWalletDropdown"},$t={key:0},Pt=["src","alt"],xt={key:1},At=[t.createElementVNode("p",null,"Select a wallet",-1)],Mt=["onClick"],Ut=["src","alt"],L={__name:"SelectWalletDropdown",setup(o){let e=t.ref({}),n=t.ref([]),s=t.ref(!1);r.onSafe(async function(){e.value=await r.config.wallets.getCurrent(),n.value=r.config.wallets.getAvailable().filter(i=>i!==e.value)});function a(){s.value=!s.value}return(i,c)=>{const d=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(d,null,{default:t.withCtx(()=>[t.createElementVNode("div",Wt,[t.createElementVNode("ul",{onClick:a},[t.unref(e)?(t.openBlock(),t.createElementBlock("li",$t,[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(r).config.defaults.wallets.icon,alt:t.unref(e).displayName+" logo"},null,8,Pt),t.createElementVNode("p",null,"cur"+t.toDisplayString(t.unref(e).displayName),1)])):(t.openBlock(),t.createElementBlock("li",xt,At)),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:2},t.renderList(t.unref(n),h=>(t.openBlock(),t.createElementBlock("li",{key:h.id,onClick:u=>t.unref(r).signer.connectWallet(t.unref(r).wallets[h.id])},[t.createElementVNode("img",{width:"40",src:h.icon?h.icon:t.unref(r).config.defaults.wallets.icon,alt:h.displayName+" logo"},null,8,Ut),t.createElementVNode("p",null,t.toDisplayString(h.displayName),1)],8,Mt))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},Lt={class:"SelectNetworkDropdown"},jt={key:0},Ft=["src","alt"],Gt={key:1},qt=[t.createElementVNode("p",null,"Select a network",-1)],Ht=["onClick"],Zt=["src","alt"],j={__name:"SelectNetworkDropdown",setup(o){let e=t.ref({}),n=t.ref([]),s=t.ref(!1);r.onSafe(async function(){e.value=await r.config.networks.getCurrent(),n.value=r.config.networks.getAvailable().filter(i=>i.id!==e.value.id)});function a(){s.value=!s.value}return(i,c)=>{const d=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(d,null,{default:t.withCtx(()=>[t.createElementVNode("div",Lt,[t.createElementVNode("ul",{onClick:a},[t.unref(e)?(t.openBlock(),t.createElementBlock("li",jt,[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(r).config.defaults.networks.icon,alt:t.unref(e).displayName+" logo"},null,8,Ft),t.createElementVNode("p",null,t.toDisplayString(t.unref(e).displayName),1)])):(t.openBlock(),t.createElementBlock("li",Gt,qt)),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:2},t.renderList(t.unref(n),h=>(t.openBlock(),t.createElementBlock("li",{key:h.id,onClick:u=>t.unref(r).provider.changeNetwork(h.id)},[t.createElementVNode("img",{width:"40",src:h.icon?h.icon:t.unref(r).config.defaults.networks.icon,alt:h.displayName+" logo"},null,8,Zt),t.createElementVNode("p",null,t.toDisplayString(h.displayName),1)],8,Ht))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},b={__name:"OnDappSafe",setup(o){return(e,n)=>t.unref(r).isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},B={__name:"OnProviderSafe",setup(o){return(e,n)=>t.unref(r).provider.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},D={__name:"OnSignerSafe",setup(o){return(e,n)=>t.unref(r).signer.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},F={__name:"OnContractsReadSafe",setup(o){return(e,n)=>t.unref(r).contracts.areReadSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},G={__name:"OnContractsWriteSafe",setup(o){return(e,n)=>t.unref(r).contracts.areWriteSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},V={__name:"OnContractReadSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(r).contracts[e.contract].isReadSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},T={__name:"OnContractWriteSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(r).contracts[e.contract].isWriteSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},ge="",q=o=>(t.pushScopeId("data-v-8361140f"),o=o(),t.popScopeId(),o),Yt=q(()=>t.createElementVNode("h3",null,"Safe Runners",-1)),zt=q(()=>t.createElementVNode("h3",null,"Status",-1)),H=M({__name:"DebugBar",setup(o){return(e,n)=>{const s=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(s,null,{default:t.withCtx(()=>[t.createElementVNode("section",null,[t.createElementVNode("div",null,[Yt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"DApp safe : "+t.toDisplayString(t.unref(r).isSafe),1),t.createElementVNode("li",null,"Provider safe : "+t.toDisplayString(t.unref(r).provider.isSafe),1),t.createElementVNode("li",null,"Signer safe : "+t.toDisplayString(t.unref(r).signer.isSafe),1),t.createElementVNode("li",null,"Contracts read safe : "+t.toDisplayString(t.unref(r).contracts.areReadSafe),1),t.createElementVNode("li",null,"Contracts write safe : "+t.toDisplayString(t.unref(r).contracts.areWriteSafe),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(r).contracts.getAll(),(a,i)=>(t.openBlock(),t.createElementBlock("li",null,[t.createTextVNode(" contract "+t.toDisplayString(i)+" : ",1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"read safe : "+t.toDisplayString(a.isReadSafe),1),t.createElementVNode("li",null,"write safe : "+t.toDisplayString(a.isWriteSafe),1)])]))),256))])]),t.createElementVNode("div",null,[zt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"dapp : "+t.toDisplayString(t.unref(r).status.get()),1),t.createElementVNode("li",null,"provider : "+t.toDisplayString(t.unref(r).provider.status.get()),1),t.createElementVNode("li",null,"signer : "+t.toDisplayString(t.unref(r).signer.status.get()),1),t.createElementVNode("li",null,"contracts : "+t.toDisplayString(t.unref(r).contracts.status.get()),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(r).contracts.getAll(),(a,i)=>(t.openBlock(),t.createElementBlock("li",null," contract "+t.toDisplayString(i)+" : "+t.toDisplayString(a.status.get()),1))),256))])])])]),_:1})}}},[["__scopeId","data-v-8361140f"]]),Kt={class:"InputUnits"},Qt=["placeholder"],Jt=["value"],W={__name:"InputUnits",props:{modelValue:{},placeholder:{type:String}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o;let s=t.ref(null);const a=["wei","gwei","ether"];let i=t.ref("wei");function c(){if(s.value){const d=m.ethers.utils.parseUnits(s.value,i.value);e("update:modelValue",d)}}return(d,h)=>(t.openBlock(),t.createElementBlock("div",Kt,[t.withDirectives(t.createElementVNode("input",{onInput:c,"onUpdate:modelValue":h[0]||(h[0]=u=>t.isRef(s)?s.value=u:s=u),type:"text",placeholder:t.unref(n).placeholder},null,40,Qt),[[t.vModelText,t.unref(s)]]),t.withDirectives(t.createElementVNode("select",{onChange:c,"onUpdate:modelValue":h[1]||(h[1]=u=>t.isRef(i)?i.value=u:i=u)},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(a,u=>t.createElementVNode("option",{value:u},t.toDisplayString(u),9,Jt)),64))],544),[[t.vModelSelect,t.unref(i)]])]))}},Xt=Object.freeze(Object.defineProperty({__proto__:null,InputUnits:W,styleLevelProp:k,ContractInteractor:A,MethodsInteractor:C,MethodInteractor:N,EventsInteractor:R,EventInteractor:I,Transact:O,ConnectWalletButton:U,SelectWalletDropdown:L,SelectNetworkDropdown:j,OnDappSafe:b,OnProviderSafe:B,OnSignerSafe:D,OnContractsReadSafe:F,OnContractsWriteSafe:G,OnContractReadSafe:V,OnContractWriteSafe:T,DebugBar:H},Symbol.toStringTag,{value:"Module"}));class _{constructor(e,n){if(this._name=e,this.states=[],!Array.isArray(n))throw`The 'states' parameter of a Status instance '${e}' must an array of strings. Got: ${n}`;for(const s of n)this.states.push(this._formatState(s));this._state=t.ref(this.states[0])}_formatState(e){return e.toString().toUpperCase()}_isStateValid(e){return!!this.states.includes(this._formatState(e))}_areStatesValid(e){for(const n of e)if(!this._isStateValid(n))return!1;return!0}get(){return S(this._state)}getRef(){return this._state}set(e){if(e=this._formatState(e),!this._isStateValid(e))throw`The state given to the set() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;f(this._state,e),console.log(`Status '${this._name}' set to '${S(this._state)}'`)}is(e){if(!this._isStateValid(e))throw`The state given to the is() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;return this.get()==this._formatState(e)}isIn(e){if(!this._areStatesValid(e))throw`The states given to the isIn() method of Status instance '${this._name}' must be an array with values in ${this.states}. Got: ${e}`;for(const n of e)if(this.is(n))return!0;return!1}watch(e,n){let s=`The states given to the watch() method of Status instance '${this._name}' must be a string or an array with values in ${this.states}. Got: ${e}`;if(Array.isArray(e)){if(!this._areStatesValid(e))throw s;t.watch(this._state,()=>{this.isIn(e)&&n(this.get())})}else{if(!this._isStateValid(e))throw s;t.watch(this._state,()=>{this.is(e)&&n(this.get())})}}watchAny(e){this.watch(this.states,e)}}class Z{constructor(){this.status=new _("contracts",["NO_PROVIDER","WRONG_PROVIDER","ERROR","INITIALIZED"]),r.provider.status.watchAny(e=>{e==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(e)&&this.status.set("NO_PROVIDER")});for(const e of r.config.networks.getAll())if(e.contracts)for(const n of Object.keys(e.contracts))this[n]=new $(n);this.areReadSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("INITIALIZED")),this.areWriteSafe=t.computed(()=>r.signer.isSafe.value&&this.status.is("INITIALIZED")),this.status.set("INITIALIZED")}getAll(){const e={};for(const[n,s]of Object.entries(this))s instanceof $&&(e[n]=s);return e}onReadSafe(e){const n=t.getCurrentInstance();if(this.areReadSafe.value)e(n);else{const s=t.watch(this.areReadSafe,()=>{this.areReadSafe.value&&(e(n),s())})}}onWriteSafe(e){const n=t.getCurrentInstance();if(this.areWriteSafe.value)e(n);else{const s=t.watch(this.areWriteSafe,()=>{this.areWriteSafe.value&&(e(n),s())})}}}const p={style:{level:"minimal"},networks:[{name:"Ethereum Mainnet",displayName:"Ethereum",id:1,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/ethereum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.infura.io/v3/"},{name:"Ropsten",displayName:"Ropsten (Ethereum Testnet)",id:3,type:"testnet",icon:null,currency:{name:"Ropsten Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://ropsten.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://ropsten.infura.io/v3/"},{name:"Rinkeby",displayName:"Rinkeby (Ethereum Testnet)",id:4,type:"testnet",icon:null,currency:{name:"Rinkeby Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://rinkeby.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://rinkeby.infura.io/v3/"},{name:"G\xF6rli",displayName:"G\xF6rli (Ethereum Testnet)",id:5,type:"testnet",icon:null,currency:{name:"G\xF6rli Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://goerli.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://goerli.infura.io/v3/"},{name:"Optimism",id:10,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/optimism.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://optimistic.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.optimism.io/"},{name:"Cronos Mainnet Beta",displayName:"Cronos",id:25,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/cronos.svg",currency:{name:"Cronos",symbol:"CRO",decimals:18},contracts:null,explorer:{name:"Cronos Explorer",url:"https://cronos.org/explorer",standard:"EIP3091"},defaultRPC:"https://evm.cronos.org"},{name:"Telos EVM Mainnet",displayName:"Telos",id:40,type:"mainnet",icon:null,currency:{name:"Telos",symbol:"TLOS",decimals:18},contracts:null,explorer:{name:"Teloscan",url:"https://teloscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.telos.net/evm"},{name:"Binance Smart Chain Mainnet",displayName:"BSC",id:56,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/bsc.svg",currency:{name:"Binance Chain Native Token",symbol:"BNB",decimals:18},contracts:null,explorer:{name:"Bscscan",url:"https://bscscan.com/",standard:"EIP3091"},defaultRPC:"https://bsc-dataseed1.binance.org/"},{name:"Gnosis Chain",displayName:"Gnosis",id:100,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/gnosis.svg",currency:{name:"xDAI",symbol:"xDAI",decimals:18},contracts:null,explorer:{name:"Blockscout",url:"https://blockscout.com/xdai/mainnet/",standard:"EIP3091"},defaultRPC:"https://rpc.gnosischain.com"},{name:"Fuse Mainnet",displayName:"Fuse",id:122,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fuse.svg",currency:{name:"Fuse",symbol:"FUSE",decimals:18},contracts:null,explorer:{name:"Fuse Explorer",url:"https://explorer.fuse.io/",standard:"EIP3091"},defaultRPC:"https://rpc.fuse.io"},{name:"Huobi ECO Chain Mainnet",displayName:"HECO",id:128,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/heco.svg",currency:{name:"Huobi ECO Chain Native Token",symbol:"HT",decimals:18},contracts:null,explorer:{name:"Hecoinfo",url:"https://hecoinfo.com",standard:"EIP3091"},defaultRPC:"https://http-mainnet.hecochain.com"},{name:"Polygon Mainnet",displayName:"Polygon",id:137,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/polygon.svg",currency:{name:"MATIC",symbol:"MATIC",decimals:18},contracts:null,explorer:{name:"Polygonscan",url:"https://polygonscan.com/",standard:"EIP3091"},defaultRPC:"https://polygon-rpc.com/"},{name:"Fantom Opera",displayName:"Fantom",id:250,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fantom.svg",currency:{name:"Fantom",symbol:"FTM",decimals:18},contracts:null,explorer:{name:"Ftmscan",url:"https://ftmscan.com/",standard:"EIP3091"},defaultRPC:"https://rpc.ftm.tools"},{name:"Metis Andromeda Mainnet",displayName:"Metis",id:1088,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/metis.svg",currency:{name:"Metis",symbol:"METIS",decimals:18},contracts:null,explorer:{name:"Metis Explorer",url:"https://andromeda-explorer.metis.io",standard:"EIP3091"},defaultRPC:"https://andromeda.metis.io/?owner=1088"},{name:"Moonbeam",id:1284,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonbeam.svg",currency:{name:"Glimmer",symbol:"GLMR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonbeam.moonscan.io",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonbeam.network"},{name:"Moonriver",id:1285,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonriver.svg",currency:{name:"Moonriver",symbol:"MOVR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonriver.moonscan.io/",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonriver.moonbeam.network"},{name:"Klaytn Mainnet Cypress",displayName:"Klaytn",id:8217,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/klaytn.svg",currency:{name:"KLAY",symbol:"KLAY",decimals:18},contracts:null,explorer:{name:"Klaytnscope",url:"https://scope.klaytn.com",standard:"EIP3091"},defaultRPC:"https://public-node-api.klaytnapi.com/v1/cypress"},{name:"Hardhat",displayName:"Hardhat",id:31337,type:"testnet",icon:null,currency:{name:"GoChain Coin",symbol:"GO",decimals:18},contracts:null,explorer:null,defaultRPC:"http://127.0.0.1:8545/"},{name:"Arbitrum One",displayName:"Arbitrum",id:42161,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/arbitrum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Arbiscan",url:"https://arbiscan.io/",standard:"EIP3091"},defaultRPC:"https://arbitrum-mainnet.infura.io/v3/"},{name:"Celo Mainnet",displayName:"Celo",id:42220,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/celo.svg",currency:{name:"CELO",symbol:"CELO",decimals:18},contracts:null,explorer:{name:"Celo Explorer",url:"https://explorer.celo.org/",standard:"EIP3091"},defaultRPC:"https://forno.celo.org"},{name:"Emerald Paratime Mainnet",displayName:"Emerald",id:42262,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/emerald.svg",currency:{name:"Emerald Rose",symbol:"ROSE",decimals:18},contracts:null,explorer:{name:"Emerald Explorer",url:"https://explorer.emerald.oasis.dev/",standard:"EIP3091"},defaultRPC:"https://emerald.oasis.dev"},{name:"Avalanche C-Chain",displayName:"Avalanche",id:43114,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/avalanche.svg",currency:{name:"Avalanche",symbol:"AVAX",decimals:18},contracts:null,explorer:{name:"Snowtrace",url:"https://snowtrace.io/",standard:"EIP3091"},defaultRPC:"https://api.avax.network/ext/bc/C/rpc"},{name:"Aurora Mainnet",displayName:"Aurora",id:1313161554,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/aurora.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Aurorascan",url:"https://aurorascan.dev",standard:"EIP3091"},defaultRPC:"https://mainnet.aurora.dev"},{name:"Harmony Mainnet Shard 0",displayName:"Harmony",id:16666e5,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/harmony.svg",currency:{name:"ONE",symbol:"ONE",decimals:18},contracts:null,explorer:{name:"Harmony Block Explorer",url:"https://explorer.harmony.one",standard:"EIP3091"},defaultRPC:"https://api.harmony.one"}],wallets:[{id:"metamask",displayName:"Metamask",icon:null},{id:"binanceChain",displayName:"Binance Chain",icon:null},{id:"coinbase",displayName:"Coinbase",icon:null}],defaults:{networks:{icon:"https://static.tuli.pe/icons/networks/unknown.svg"},wallets:{icon:"TODO"}}};class vt{constructor(e=null){let n={};return e?n=y({...p.style},{...e}):n=p.style,window.addEventListener("load",()=>{const s=document.getElementsByClassName("ve-app");if(s)for(const a of s)a&&a.classList.add(`ve-${n.level}`)}),n}}class te{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=p.networks.find(i=>i.id===n.id),a=y({...s},{...n});a.available!==!1&&(a.available=!0),a.displayName||(a.displayName=a.name),this._list.push(a)}}for(const n of p.networks)this._list.find(a=>a.id===n.id)||(n.available=!1,this._list.push(n))}add(e){this._list.push(e)}async getCurrent(){if(r.provider.proxy.ethersInstance){const e=await r.provider.getNetwork().then(n=>n.chainId);return this.getById(e)}return null}getById(e){try{e=parseInt(e)}catch{throw"'id' given to getById() method must be an integer or any data type that can be parsed to interger."}return this._list.find(n=>n.id===parseInt(e))}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ee{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=p.wallets.find(i=>i.id===n.id),a=y({...s},{...n});a.available!==!1&&(a.available=!0),a.displayName||(a.displayName=a.id),this._list.push(a)}}for(const n of p.wallets)this._list.find(a=>a.id===n.id)||(n.available=!1,this._list.push(n))}async getCurrent(){if(r.signer.proxy.ethersInstance){const e=r.provider.connection.url;return this.getById(e)}return null}getById(e){return this._list.find(n=>n.id===e)}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ne{constructor(e=null){let n={};return e?n=y({...p.defaults},{...e}):n=p.defaults,n}}class Y{constructor(e=null){this.style=new vt(e?e.style:null),this.networks=new te(e?e.networks:null),this.wallets=new ee(e?e.wallets:null),this.defaults=new ne(e?e.defaults:null)}}class E{constructor(e=null,n=null,s=null){return this.proxy={_ethersInstance:e&&t.markRaw(e),get ethersInstance(){return this._ethersInstance},set ethersInstance(a){this._ethersInstance=a&&t.markRaw(a)},extensionInstance:n,placeholderInstance:s},new Proxy(this,{get:function(a,i,c){if(i==="proxy")return a.proxy;if(a.proxy.ethersInstance&&a.proxy.ethersInstance[i])return typeof a.proxy.ethersInstance[i]=="function"?a.proxy.ethersInstance[i].bind(a.proxy.ethersInstance):a.proxy.ethersInstance[i];if(a.proxy.ethersInstance&&a.proxy.extensionInstance&&a.proxy.extensionInstance[i])return typeof a.proxy.extensionInstance[i]=="function"?a.proxy.extensionInstance[i].bind(c):a.proxy.extensionInstance[i];if(a.proxy.placeholderInstance&&a.proxy.placeholderInstance[i])return typeof a.proxy.placeholderInstance[i]=="function"?a.proxy.placeholderInstance[i].bind(c):a.proxy.placeholderInstance[i]},set:function(a,i,c,d){if(a.proxy.ethersInstance&&a.proxy.ethersInstance[i])return a.proxy.ethersInstance[i]=c,!0;if(a.proxy.extensionInstance&&a.proxy.extensionInstance[i])return a.proxy.extensionInstance[i]=c,!0;if(a.proxy.placeholderInstance&&a.proxy.placeholderInstance[i])return a.proxy.placeholderInstance[i]=c,!0;throw"New properties cannot be set on TulipeProxy instances. Please define them in instances constructor firstly."}})}}class se{}class ae{constructor(){this.status=new _("provider",["DISCONNECTED","WRONG","ERROR","CONNECTED"]),this.isSafe=t.computed(()=>r.isSafe.value&&!this.status.isIn(["DISCONNECTED","ERROR"])),this.OnSafe=B}async _getProviderFromWebWallet(){for(const e of Object.values(r.wallets))if(e){const n=e.getProvider();if(n)return n}return null}async _initProviderConnection(){const e=await this._getProviderFromWebWallet();if(e)this.proxy.ethersInstance=new m.ethers.providers.Web3Provider(e,"any");else{const n=r.config.networks.getDefault();n&&n.defaultRPC&&(this.proxy.ethersInstance=new m.ethers.providers.JsonRpcProvider(n.defaultRPC))}}_initARS(){this.on("network",(e,n)=>{n&&n!==e&&window.location.reload()}),this.on("error",()=>{this.status.set("ERROR")})}async _asyncInit(){if(await this._initProviderConnection(),!this.proxy.ethersInstance)this.status.set("DISCONNECTED");else{const e=await this.getNetwork();let n=await r.config.networks.getById(e.chainId);if(n)this.status.set("CONNECTED");else if(this.status.set("WRONG"),n=r.config.networks.getAll().find(s=>s.id===e.id),!n){const s={name:e.name,displayName:x(e.name),id:e.chainId};console.log(s),r.config.networks.add(s)}n&&n.pollingInterval&&(this.pollingInterval=n.pollingInterval),this._initARS()}}async changeNetwork(e){const n=await r.config.wallets.getCurrent();n&&r.wallets[n.id].changeNetwork(e)}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}class z extends E{constructor(e,n=null,s=null,a=null){s=s||new se,a=a||new ae,super(n,s,a),this._asyncInit()}}class re{}class oe{constructor(){this.address=t.ref(null),this.status=new _("signer",["DISCONNECTED","REQUESTED","REFUSED","ERROR","NO_PROVIDER","WRONG_PROVIDER","CONNECTED"]),this.isSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("CONNECTED")),this.OnSafe=D}initARS(){r.provider.status.watchAny(e=>{e==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(e)&&this.status.set("NO_PROVIDER")}),this.status.watch(["REFUSED","ERROR"],()=>{setTimeout(()=>{this.status.set("DISCONNECTED")},5e3)})}async _asyncInit(){const e=this;r.provider.onSafe(async function(){for(const n of Object.values(r.wallets))await e.connectWallet(n,!0)}),this.initARS()}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}async connectWallet(e,n=!1){if(r.signer.status.is("DISCONNECTED"))try{const s=await r.provider.getSigner(),a=await s.getAddress();r.signer.proxy.ethersInstance=s,this.address.value=a,r.signer.status.set("CONNECTED")}catch{if(n===!0)r.signer.status.set("DISCONNECTED");else{this.status.set("REQUESTED");try{await e.connect(),this.status.set("CONNECTED")}catch(a){if(a instanceof w)this.status.set("REFUSED");else throw this.status.set("ERROR"),a}}}}disconnectWallet(){r.signer.proxy.ethersInstance=null,this.address.value=null,r.signer.status.set("DISCONNECTED")}}class K extends E{constructor(e,n=null,s=null,a=null){s=s||new re,a=a||new oe,super(n,s,a),this._asyncInit()}}class ie{_watch(e,n,s=null){return Object.keys(r.chainWatchers.contracts).includes(this.address)||r.chainWatchers.addContractWatcher(this),r.chainWatchers.contracts[this.address].add(e,n,s)}watch(e,n,s,a=null){const i=this._watch(e,n,s);return a?t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,i)},a):t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,i)}),r.chainWatchers.contracts[this.address].remove.bind(r.chainWatchers.contracts[this.address],e,n,i)}watchRef(e,n,s=null){const a=this._watch(e,n,null);return s?t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,a)},s):t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,a)}),r.chainWatchers.contracts[this.address].getRef(e,n)}}class le{constructor(e){this.name=e,this.status=new _(`contract:${e}`,["NO_PROVIDER","WRONG_PROVIDER","ERROR","INITIALIZED"]),this.isReadSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("INITIALIZED")),this.isWriteSafe=t.computed(()=>r.signer.isSafe.value&&this.status.is("INITIALIZED")),this.OnReadSafe=t.createVNode(V,{contract:this.name}),this.OnWriteSafe=t.createVNode(T,{contract:this.name})}onReadSafe(e){const n=t.getCurrentInstance();if(this.isReadSafe.value)e(n);else{const s=t.watch(this.isReadSafe,()=>{this.isReadSafe.value&&(e(n),s())})}}onWriteSafe(e){const n=t.getCurrentInstance();if(this.isWriteSafe.value)e(n);else{const s=t.watch(this.isWriteSafe,()=>{this.isWriteSafe.value&&(e(n),s())})}}_updateContract(e,n){if(r.signer.isSafe.value)this.proxy.ethersInstance=new m.ethers.Contract(e,n,r.signer.proxy.ethersInstance);else if(r.provider.isSafe.value)this.proxy.ethersInstance=new m.ethers.Contract(e,n,r.provider.proxy.ethersInstance);else throw`_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`}_initARS(e,n){r.provider.status.watchAny(s=>{s==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(s)&&this.status.set("NO_PROVIDER")}),t.watch([r.signer.isSafe],(s,a)=>{s!==a&&(this.proxy.ethersInstance=null,this._updateContract(e,n))})}async _asyncInit(){r.provider.onSafe(async function(){try{const e=await r.config.networks.getCurrent();if(e&&e.contracts&&Object.keys(e.contracts).includes(this.name)){const n=e.contracts[this.name];this._updateContract(n.address,n.abi),this._initARS(n.address,n.abi),this.status.set("INITIALIZED")}else this.status.set("WRONG_PROVIDER")}catch(e){throw this.status.set("ERROR"),e}}.bind(this))}}class $ extends E{constructor(e,n=null,s=null,a=null){s=s||new ie,a=a||new le(e),super(n,s,a),this._asyncInit()}}class ce{}class de{constructor(e,n,s=[],a={value:0}){this.contractName=e,this.methodName=n,this.methodInfos={},this.args=t.ref(s),this.txArgs=t.ref(a),this.data=t.ref([]),this.error=t.ref(null),this.call=null,this.status=new _(`tx:${e}:${n}`,["NOT_READY","READY","SENT","ERROR","SUCCESS"])}initARS(){this.status.watch(["ERROR","SUCCESS"],()=>{setTimeout(()=>{this.status.set("READY")},3e3)})}_asyncInit(){r.contracts[this.contractName].isReadSafe.value&&this._initEthersInstance(),r.contracts[this.contractName].onReadSafe(()=>{this._initEthersInstance()}),this.initARS()}_initEthersInstance(){this.methodInfos=r.contracts[this.contractName].interface.functions[this.methodName],this.methodInfos.inputs.forEach(e=>this.args.value.push(null)),this.methodInfos.outputs.forEach(e=>this.data.value.push(null)),this.proxy.ethersInstance=r.contracts[this.contractName][this.methodName],this.status.set("READY")}send(e=null,n=null){e=e&&e.length>0?e:S(this.args),e?Array.isArray(e)?this.call=this.proxy.ethersInstance(...e,n):this.call=this.proxy.ethersInstance(e,n):this.call=this.proxy.ethersInstance(n),this.status.set("SENT"),this.methodInfos.constant?this.call.then(s=>{Array.isArray(s)||(s=[s]),f(this.data,s),f(this.error,null),this.status.set("SUCCESS")}).catch(s=>{f(this.error,s),this.status.set("ERROR")}):this.call.then(s=>s.wait()).then(s=>{Array.isArray(s)||(s=[s]),f(this.data,s),f(this.error,null),this.status.set("SUCCESS")}).catch(s=>{f(this.error,s),this.status.set("ERROR"),console.log(s)})}}class P extends E{constructor(e,n,s=[],a={value:0},i=null,c=null,d=null){c=c||new ce,d=d||new de(e,n,s=[],a={value:0}),super(i,c,d),this._asyncInit()}}class Q{constructor(){this.contracts={},this.wallets={}}async _asyncInit(){r.provider.onSafe(()=>{r.provider.on("block",async function(e){const n=await r.provider.getBlockWithTransactions(e);for(const s of n.transactions)Object.keys(this.contracts).includes(s.to)?this.contracts[s.to].update():Object.keys(this.wallets).includes(s.to)&&this.wallets[s.to].update(),Object.keys(this.contracts).includes(s.from)?this.contracts[s.from].update():Object.keys(this.wallets).includes(s.from)&&this.wallets[s.from].update()})})}addContractWatcher(e){Object.keys(this.contracts).includes(e.address)||(this.contracts[e.address]=new X(e))}removeContractWatcher(e){Object.keys(this.contracts).includes(e.address)&&delete this.contracts[e.address]}addWalletWatcher(e){Object.keys(this.wallets).includes(e)||(this.wallets[e]=new v(e))}removeContractWatcher(e){Object.keys(this.wallets).includes(e)&&delete this.wallets[e]}}class J{constructor(){this.lastUpdateBlock=0,this.sources={}}_generateDependentUUID(){return"xxxxxxxx".replace(/[xy]/g,function(e){var n=Math.random()*16|0,s=e=="x"?n:n&3|8;return s.toString(16)})}async requiresUpdate(){if(!r.provider.isSafe.value)return!1;const e=await r.provider.getBlockNumber();return this.lastUpdateBlock<e}async updateLastUpdateBlock(){const e=await r.provider.getBlockNumber();this.lastUpdateBlock=e}async _update(){throw"_update() method not implemented in that ChainWatcher child class."}update(){this._update()}}class X extends J{constructor(e){super(),this.contract=e}_buildSourceName(e,n){return`${e}:${n?n.toString():""}`}async _updateState(e){e.args?e.state.value=await this.contract[e.name](...e.args):e.state.value=await this.contract[e.name]()}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){const a=this._buildSourceName(e,n);let i=!1;Object.keys(this.sources).includes(a)||(this.sources[a]={name:e,args:n,state:t.ref(null),dependents:{}},i=!0);let c=null;s&&(c=t.watch(this.sources[a].state,s));const d=this._generateDependentUUID();return this.sources[a].dependents[d]=c,i&&this._updateState(this.sources[a]),d}remove(e,n,s){const a=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(a)&&Object.keys(this.sources[a].dependents).includes(s)){const i=this.sources[a].dependents[s];i&&i(),delete this.sources[a].dependents[s]}Object.keys(this.sources[a].dependents).length===0&&delete this.sources[a]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class v extends J{constructor(e){super(),this.address=e,this.availableSources=["balance"]}async _updateState(e){e.name==="balance"&&(e.state.value=await r.provider.getBalance(this.address))}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))await this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){if(!this.availableSources.includes(e))throw`Sources added to a ChainWalletWatcher must be in ${this.availableSources}. Got ${e}`;const a=this._buildSourceName(e,n);newSource=!1,Object.keys(this.sources).includes(a)||(this.sources[a]={name:e,args:n,state:ref(null),dependents:{}},newSource=!0);let i=null;s&&(i=watch(this.sources[a].state,s));const c=this._generateDependentUUID();return this.sources[a].dependents[c]=i,newSource&&this._updateState(this.sources[a]),c}remove(e,n,s){const a=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(a)&&Object.keys(this.sources[a].dependents).includes(s)){const i=this.sources[a].dependents[s];i&&i(),delete this.sources[a].dependents[s]}Object.keys(this.sources[a].dependents).length===0&&delete this.sources[a]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class tt{constructor(){this.provider=null,this.id=""}getProvider(){return null}async connect(){throw`connect() method of ${this.id} wallet is not implemented.`}}class w extends Error{constructor(e,...n){super(e,...n),this.message=`${e} wallet has rejected the connection request.`}}class et extends tt{constructor(){super(),this.id="metamask",this.provider=this.getProvider()}getProvider(){return window.ethereum}async connect(){try{await this.provider.request({method:"eth_requestAccounts"})}catch(e){throw e.code===4001?w(this.id):e}}async addNetwork(e){const n=r.config.networks.getById(e);await window.ethereum.request({method:"wallet_addEthereumChain",params:[{chainId:e,rpcUrls:[n.defaultRPC],chainName:n.name,nativeCurrency:{name:n.currency.symbol,symbol:n.currency.symbol,decimals:n.currency.decimals},blockExplorerUrls:n.explorer&&n.explorer.url!==""?[n.explorer.url]:null}]})}async changeNetwork(e){if(r.config.networks.getById(e)){e=m.ethers.utils.hexlify(parseInt(e)).toString(),e=m.ethers.utils.hexValue(e);try{await window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:e}]})}catch(s){if(s.code===4902)this.addNetwork(e);else throw s}}}}class he extends tt{constructor(e,n={}){super(),this.id="coinbase";const s=n.appName||"",a=n.appLogoUrl,i=n.darkMode||!1;this.coinbaseWalletSdk=new e({appName:s,appLogoUrl:a,darkMode:i}),this.provider=this.getProvider()}getProvider(){try{return this.coinbaseWalletSdk.makeWeb3Provider()}catch(e){return console.log(e),null}}async connect(){try{await this.provider.send("eth_requestAccounts")}catch{throw w(this.id)}}}class ue extends et{constructor(){super(),this.id="binanceChain"}getProvider(){return window.BinanceChain}async connect(){super.connect.call(this)}}class nt{constructor(){const e=r.config.wallets.getAvailable();for(const n of e){const s=st[n.id];s&&(this[n.id]=new s)}}}const st={metamask:et,coinbase:he,binanceChain:ue};async function fe(o,e){const n=e;try{r.init(n)}catch(a){throw r&&r.status&&r.status.set("ERROR"),a}o.config.globalProperties.dapp=r,o.config.globalProperties.rGet=S,o.config.globalProperties.rSet=f,window.dapp=r;const s=await Promise.resolve().then(()=>Xt);o.component("OnDappSafe",s.OnDappSafe),o.component("OnProviderSafe",s.OnProviderSafe),o.component("OnSignerSafe",s.OnSignerSafe),o.component("OnContractsReadSafe",s.OnContractsReadSafe),o.component("OnContractsWriteSafe",s.OnContractsWriteSafe),o.component("OnContractReadSafe",s.OnContractReadSafe),o.component("OnContractWriteSafe",s.OnContractWriteSafe),r.status.set("INITIALIZED")}return l.ChainWatchersList=Q,l.ConnectWalletButton=U,l.ContractInteractor=A,l.ContractWatcher=X,l.ContractsList=Z,l.DebugBar=H,l.EventInteractor=I,l.EventsInteractor=R,l.InputUnits=W,l.MethodInteractor=N,l.MethodsInteractor=C,l.OnContractReadSafe=V,l.OnContractWriteSafe=T,l.OnContractsReadSafe=F,l.OnContractsWriteSafe=G,l.OnDappSafe=b,l.OnProviderSafe=B,l.OnSignerSafe=D,l.SelectNetworkDropdown=j,l.SelectWalletDropdown=L,l.Status=_,l.Transact=O,l.TulipeConfig=Y,l.TulipeContract=$,l.TulipeProvider=z,l.TulipeProxy=E,l.TulipeSigner=K,l.TulipeTransaction=P,l.WalletConnectionRejected=w,l.WalletWatcher=v,l.WalletsList=nt,l.capitalizeWords=x,l.dapp=r,l.deepMerge=y,l.initTulipe=fe,l.isObject=g,l.rGet=S,l.rSet=f,l.styleLevelProp=k,l.wallets=st,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),l}({},vue,ethers); | ||
var Tulipe=function(d,t,y){"use strict";class nt{constructor(){const e=a.config.wallets.getAvailable();for(const n of e){const s=tt[n.id];s&&(this[n.id]=new s)}}}class st{constructor(){for(const e of a.config.networks.getAll())if(e.contracts)for(const n of Object.keys(e.contracts))this[n]=new A(n)}getAll(){const e={};for(const[n,s]of Object.entries(this))s instanceof A&&(e[n]=s);return e}}class at{constructor(){this.contracts={},this.wallets={}}async _asyncInit(){a.provider.onSafe(()=>{a.provider.on("block",async function(e){const n=await a.provider.getBlockWithTransactions(e);for(const s of n.transactions)Object.keys(this.contracts).includes(s.to)?this.contracts[s.to].update():Object.keys(this.wallets).includes(s.to)&&this.wallets[s.to].update(),Object.keys(this.contracts).includes(s.from)?this.contracts[s.from].update():Object.keys(this.wallets).includes(s.from)&&this.wallets[s.from].update()})})}addContractWatcher(e){Object.keys(this.contracts).includes(e.address)||(this.contracts[e.address]=new Q(e))}removeContractWatcher(e){Object.keys(this.contracts).includes(e.address)&&delete this.contracts[e.address]}addWalletWatcher(e){Object.keys(this.wallets).includes(e)||(this.wallets[e]=new J(e))}removeContractWatcher(e){Object.keys(this.wallets).includes(e)&&delete this.wallets[e]}}class rt{constructor(){}init(e=null){this.config=new z(e),this.status=new g("dapp",["UNSAFE","ERROR","INITIALIZED"]),this.isSafe=t.computed(()=>this.status.is("INITIALIZED")),this.OnSafe=B,this.chainWatchers=new at,this.wallets=new nt,this.provider=new K,this.pro=this.provider,this.signer=new Y,this.sig=this.signer,this.contracts=new st,this.con=this.contracts}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}const a=new rt;function E(o){return o&&typeof o=="object"&&!Array.isArray(o)}function _(o,...e){if(!e.length)return o;const n=e.shift();if(E(o)&&E(n))for(const s in n)E(n[s])?(o[s]||Object.assign(o,{[s]:{}}),_(o[s],n[s])):Object.assign(o,{[s]:n[s]});return _(o,...e)}function U(o){const e=o.split(" ");for(let n=0;n<e.length;n++)e[n]=e[n][0].toUpperCase()+e[n].substring(1);return e.join(" ")}function w(o){return t.isRef(o)?w(o.value):o}function p(o,e){t.isRef(o)?o.value=e:o=e}const me="",I={required:!1,type:String,default:"minimal",validator(o){return["unstylized","minimal","opinionated"].includes(o)}},ot={class:"ContractInteractor"},it=t.createTextVNode(" Methods : "),lt=t.createElementVNode("br",null,null,-1),ct=t.createTextVNode(" Events : "),dt=t.createElementVNode("br",null,null,-1),M={__name:"ContractInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];let s=t.ref("not owned");return a.contracts[e.contract].onReadSafe(async function(){try{s.value=await n.owner()}catch{}}),(r,i)=>{const l=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(l,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ot,[t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Address : "+t.toDisplayString(t.unref(n).address),1),t.createElementVNode("li",null,"Owner : "+t.toDisplayString(t.unref(s)),1),t.createElementVNode("li",null,[it,lt,t.createVNode(t.unref(C),{contract:e.contract},null,8,["contract"])]),t.createElementVNode("li",null,[ct,dt,t.createVNode(t.unref(R),{contract:e.contract},null,8,["contract"])])])])]),_:1},8,["contract"])}}},ht={class:"MethodsInteractor"},C={__name:"MethodsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];return(s,r)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ht,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.functions,(l,c)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(b),{contract:e.contract,method:c},null,8,["contract","method"])]))),256))])])]),_:1},8,["contract"])}}},ut={class:"MethodInteractor"},pt={key:0},ft=t.createElementVNode("p",null,"Inputs :",-1),mt=["onUpdate:modelValue","placeholder"],yt={key:0},_t={key:1},wt=t.createElementVNode("p",null,"Outputs :",-1),gt=["onUpdate:modelValue","placeholder"],St=["placeholder"],Et={key:2},b={__name:"MethodInteractor",props:{contract:{type:String,required:!0},method:{type:String,required:!0}},setup(o){const e=o,n=t.shallowRef(new W(e.contract,e.method));function s(r){return`${r.name&&r.name!=="null"?r.name:""} (${r.type})`}return(r,i)=>{const l=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(l,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ut,[t.createVNode(t.unref(x),{contract:e.contract,method:e.method,modelValue:t.unref(n),"onUpdate:modelValue":i[0]||(i[0]=c=>t.isRef(n)?n.value=c:null),configs:{content:e.method,notx:!0,noerror:!0}},null,8,["contract","method","modelValue","configs"]),t.createElementVNode("small",null,t.toDisplayString(t.unref(n).methodInfos.stateMutability),1),Object.keys(t.unref(n).methodInfos.inputs).length>0||t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("div",pt,[ft,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.inputs,(c,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":u=>t.unref(n).args.value[h]=u,type:"text",placeholder:s(c)},null,8,mt),[[t.vModelText,t.unref(n).args.value[h]]]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).args.value[h])+" "+t.toDisplayString(typeof t.unref(n).args.value[h]),1)]))),256)),t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("li",yt,[t.createVNode(t.unref($),{modelValue:t.unref(n).txArgs.value.value,"onUpdate:modelValue":i[1]||(i[1]=c=>t.unref(n).txArgs.value.value=c)},null,8,["modelValue"]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).txArgs.value.value)+" "+t.toDisplayString(typeof t.unref(n).txArgs.value.value),1)])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),Object.keys(t.unref(n).methodInfos.outputs).length>0?(t.openBlock(),t.createElementBlock("div",_t,[wt,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.outputs,(c,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.unref(n).data.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:0,"onUpdate:modelValue":u=>t.unref(n).data.value[h]=u,type:"text",placeholder:s(c),disabled:""},null,8,gt)),[[t.vModelText,t.unref(n).data.value[h]]]):(t.openBlock(),t.createElementBlock("input",{key:1,type:"text",placeholder:s(c),disabled:""},null,8,St))]))),256))])])):t.createCommentVNode("",!0),t.unref(n).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",Et,t.toDisplayString(t.unref(n).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},kt={class:"EventsInteractor"},R={__name:"EventsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];return(s,r)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",kt,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.events,(l,c)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(O),{contract:e.contract,event:c},null,8,["contract","event"])]))),256))])])]),_:1},8,["contract"])}}},Nt={class:"EventInteractor"},It=t.createTextVNode("Logs: "),O={__name:"EventInteractor",props:{contract:{type:String,required:!0},event:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];let s=t.ref({}),r=t.ref({}),i=t.ref(0),l=t.ref([]);return n.onReadSafe(()=>{s.value=n.interface.events[e.event],r.value=n.filters[s.value.name],n.on(r.value,c=>{i.value++;let h=`Block ${c.blockNumber} -> {`;for(const u of s.value.inputs)h+=`${u.name}:${c.args[u.name]}, `;h=h.substring(0,h.length-2)+"}",l.value.push(h)})}),(c,h)=>{const u=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(u,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",Nt,[t.createElementVNode("p",null,t.toDisplayString(t.unref(s).name),1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Count : "+t.toDisplayString(t.unref(i)),1),t.createElementVNode("li",null,[It,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(l),et=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(et),1))),256))])])])])]),_:1},8,["contract"])}}},Ct={class:"TransactButton"},bt={key:1,disabled:""},Rt={key:2,disabled:""},Ot={key:3,disabled:""},xt={key:4},x={__name:"Transact",props:{modelValue:{},contract:{type:String,required:!0},method:{type:String,required:!0},args:{type:Array,required:!1},txArgs:{type:Object,required:!1},configs:{type:Object,required:!1}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=a.contracts[n.contract];let r=t.computed({get(){return n.modelValue},set(l){e("update:modelValue",l)}});function i(){const l=n.args?n.args:[],c=n.txArgs?n.txArgs:{};r.value.send(l,c)}return n.config&&n.configs.notx&&s.onReadSafe(()=>{r=new W(n.contract,n.method)}),(l,c)=>{const h=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(h,{contract:n.contract},{default:t.withCtx(()=>[t.createElementVNode("div",Ct,[t.unref(r).status.is("READY")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:i},t.toDisplayString(n.configs&&n.configs.content?n.configs.content:"Transact"),1)):t.unref(r).status.is("SENT")?(t.openBlock(),t.createElementBlock("button",bt,"Transaction sent...")):t.unref(r).status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",Rt,"Transaction error!")):t.unref(r).status.is("SUCCESS")?(t.openBlock(),t.createElementBlock("button",Ot,"Success !")):t.createCommentVNode("",!0),!(n.configs&&n.configs.noerror)&&t.unref(r).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",xt,t.toDisplayString(t.unref(r).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},ye="",j=(o,e)=>{const n=o.__vccOpts||o;for(const[s,r]of e)n[s]=r;return n},L=j({__name:"ConnectWalletButton",props:{styleLevel:I},setup(o){const e=o;return(n,s)=>(t.openBlock(),t.createBlock(t.unref(a).provider.OnSafe,null,{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(["ConnectWalletButton",`ve-${e.styleLevel}`])},null,2)]),_:1}))}},[["__scopeId","data-v-a10b4efb"]]),Bt={class:"SelectWalletDropdown"},Dt={key:0},Vt=[t.createElementVNode("p",null,"Connection requested...",-1)],Tt={key:1},Pt=[t.createElementVNode("p",null,"Connection refused!",-1)],$t={key:2},At=[t.createElementVNode("p",null,"Select a wallet",-1)],Wt=["src","alt"],Ut=["onClick"],Mt=["src","alt"],F={__name:"SelectWalletDropdown",setup(o){let e=t.ref(null),n=t.ref([]),s=t.ref(!1),r=t.ref({});a.onSafe(async function(){n.value=a.config.wallets.getAvailable()}),a.provider.onSafe(async function(){r.value=await a.config.networks.getCurrent()}),a.signer.onSafe(async function(){e.value=await a.config.wallets.getCurrent(),console.log(e.value);try{n.value=a.config.wallets.getAvailable().filter(l=>l.id!==e.value.id)}catch{n.value=a.config.wallets.getAvailable()}});function i(){s.value=!s.value}return(l,c)=>{const h=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(h,null,{default:t.withCtx(()=>[t.createElementVNode("div",Bt,[t.createElementVNode("ul",null,[t.unref(a).signer.status.is("REQUESTED")?(t.openBlock(),t.createElementBlock("li",Dt,Vt)):t.unref(a).signer.status.is("REFUSED")?(t.openBlock(),t.createElementBlock("li",Tt,Pt)):t.unref(a).provider.status.is("WRONG_NETWORK")?(t.openBlock(),t.createElementBlock("li",$t,[t.createElementVNode("p",null,"Wrong network! ("+t.toDisplayString(t.unref(r)?t.unref(r).displayName:"unknown")+")",1)])):t.unref(a).signer.status.is("DISCONNECTED")||!t.unref(e)?(t.openBlock(),t.createElementBlock("li",{key:3,onClick:i},At)):t.unref(a).signer.status.is("CONNECTED")?(t.openBlock(),t.createElementBlock("li",{key:4,onClick:i},[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(a).config.defaults.wallets.icon,alt:t.unref(e).displayName+" logo"},null,8,Wt),t.createElementVNode("p",null,t.toDisplayString(t.unref(e).displayName),1)])):t.createCommentVNode("",!0),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:5},t.renderList(t.unref(n),u=>(t.openBlock(),t.createElementBlock("li",{key:u.id,onClick:et=>t.unref(a).signer.connectWallet(u.id)},[t.createElementVNode("img",{width:"40",src:u.icon?u.icon:t.unref(a).config.defaults.wallets.icon,alt:u.displayName+" logo"},null,8,Mt),t.createElementVNode("p",null,t.toDisplayString(u.displayName),1)],8,Ut))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},jt={class:"SelectNetworkDropdown"},Lt={key:0},Ft=["src","alt"],qt={key:1},Gt=[t.createElementVNode("p",null,"Select a network",-1)],Ht=["onClick"],zt=["src","alt"],q={__name:"SelectNetworkDropdown",setup(o){let e=t.ref({}),n=t.ref([]),s=t.ref(!1);a.onSafe(async function(){n.value=a.config.networks.getAvailable()}),a.provider.onSafe(async function(){e.value=await a.config.networks.getCurrent(),n.value=a.config.networks.getAvailable().filter(i=>i.id!==e.value.id)});function r(){s.value=!s.value}return(i,l)=>{const c=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(c,null,{default:t.withCtx(()=>[t.createElementVNode("div",jt,[t.createElementVNode("ul",{onClick:r},[t.unref(e)?(t.openBlock(),t.createElementBlock("li",Lt,[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(a).config.defaults.networks.icon,alt:t.unref(e).displayName+" logo"},null,8,Ft),t.createElementVNode("p",null,t.toDisplayString(t.unref(e).displayName),1)])):(t.openBlock(),t.createElementBlock("li",qt,Gt)),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:2},t.renderList(t.unref(n),h=>(t.openBlock(),t.createElementBlock("li",{key:h.id,onClick:u=>t.unref(a).provider.changeNetwork(h.id)},[t.createElementVNode("img",{width:"40",src:h.icon?h.icon:t.unref(a).config.defaults.networks.icon,alt:h.displayName+" logo"},null,8,zt),t.createElementVNode("p",null,t.toDisplayString(h.displayName),1)],8,Ht))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},B={__name:"OnDappSafe",setup(o){return(e,n)=>t.unref(a).isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},D={__name:"OnProviderSafe",setup(o){return(e,n)=>t.unref(a).provider.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},V={__name:"OnSignerSafe",setup(o){return(e,n)=>t.unref(a).signer.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},T={__name:"OnContractReadSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(a).contracts[e.contract].isReadSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},P={__name:"OnContractWriteSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(a).contracts[e.contract].isWriteSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},ke="",G=o=>(t.pushScopeId("data-v-a24ac687"),o=o(),t.popScopeId(),o),Kt=G(()=>t.createElementVNode("h3",null,"Safe Runners",-1)),Yt=G(()=>t.createElementVNode("h3",null,"Status",-1)),H=j({__name:"DebugBar",setup(o){return(e,n)=>{const s=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(s,null,{default:t.withCtx(()=>[t.createElementVNode("section",null,[t.createElementVNode("div",null,[Kt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"DApp safe : "+t.toDisplayString(t.unref(a).isSafe),1),t.createElementVNode("li",null,"Provider safe : "+t.toDisplayString(t.unref(a).provider.isSafe),1),t.createElementVNode("li",null,"Signer safe : "+t.toDisplayString(t.unref(a).signer.isSafe),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(a).contracts.getAll(),(r,i)=>(t.openBlock(),t.createElementBlock("li",null,[t.createTextVNode(" contract "+t.toDisplayString(i)+" : ",1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"read safe : "+t.toDisplayString(r.isReadSafe),1),t.createElementVNode("li",null,"write safe : "+t.toDisplayString(r.isWriteSafe),1)])]))),256))])]),t.createElementVNode("div",null,[Yt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"dapp : "+t.toDisplayString(t.unref(a).status.get()),1),t.createElementVNode("li",null,"provider : "+t.toDisplayString(t.unref(a).provider.status.get()),1),t.createElementVNode("li",null,"signer : "+t.toDisplayString(t.unref(a).signer.status.get()),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(a).contracts.getAll(),(r,i)=>(t.openBlock(),t.createElementBlock("li",null," contract "+t.toDisplayString(i)+" : "+t.toDisplayString(r.status.get()),1))),256))])])])]),_:1})}}},[["__scopeId","data-v-a24ac687"]]),Zt={class:"InputUnits"},Qt=["placeholder"],Jt=["value"],$={__name:"InputUnits",props:{modelValue:{},placeholder:{type:String}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o;let s=t.ref(null);const r=["wei","gwei","ether"];let i=t.ref("wei");function l(){if(s.value){const c=y.ethers.utils.parseUnits(s.value,i.value);e("update:modelValue",c)}}return(c,h)=>(t.openBlock(),t.createElementBlock("div",Zt,[t.withDirectives(t.createElementVNode("input",{onInput:l,"onUpdate:modelValue":h[0]||(h[0]=u=>t.isRef(s)?s.value=u:s=u),type:"text",placeholder:t.unref(n).placeholder},null,40,Qt),[[t.vModelText,t.unref(s)]]),t.withDirectives(t.createElementVNode("select",{onChange:l,"onUpdate:modelValue":h[1]||(h[1]=u=>t.isRef(i)?i.value=u:i=u)},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(r,u=>t.createElementVNode("option",{value:u},t.toDisplayString(u),9,Jt)),64))],544),[[t.vModelSelect,t.unref(i)]])]))}},Xt=Object.freeze(Object.defineProperty({__proto__:null,InputUnits:$,styleLevelProp:I,ContractInteractor:M,MethodsInteractor:C,MethodInteractor:b,EventsInteractor:R,EventInteractor:O,Transact:x,ConnectWalletButton:L,SelectWalletDropdown:F,SelectNetworkDropdown:q,OnDappSafe:B,OnProviderSafe:D,OnSignerSafe:V,OnContractReadSafe:T,OnContractWriteSafe:P,DebugBar:H},Symbol.toStringTag,{value:"Module"}));class g{constructor(e,n){if(this._name=e,this.states=[],!Array.isArray(n))throw`The 'states' parameter of a Status instance '${e}' must an array of strings. Got: ${n}`;for(const s of n)this.states.push(this._formatState(s));this._state=t.ref(this.states[0])}_formatState(e){return e.toString().toUpperCase()}_isStateValid(e){return!!this.states.includes(this._formatState(e))}_areStatesValid(e){for(const n of e)if(!this._isStateValid(n))return!1;return!0}get(){return w(this._state)}getRef(){return this._state}set(e){if(e=this._formatState(e),!this._isStateValid(e))throw`The state given to the set() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;p(this._state,e),console.log(`Status '${this._name}' set to '${w(this._state)}'`)}is(e){if(!this._isStateValid(e))throw`The state given to the is() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;return this.get()==this._formatState(e)}isIn(e){if(!this._areStatesValid(e))throw`The states given to the isIn() method of Status instance '${this._name}' must be an array with values in ${this.states}. Got: ${e}`;for(const n of e)if(this.is(n))return!0;return!1}watch(e,n){let s=`The states given to the watch() method of Status instance '${this._name}' must be a string or an array with values in ${this.states}. Got: ${e}`;if(Array.isArray(e)){if(!this._areStatesValid(e))throw s;return t.watch(this._state,()=>{this.isIn(e)&&n(this.get())})}else{if(!this._isStateValid(e))throw s;return t.watch(this._state,()=>{this.is(e)&&n(this.get())})}}watchAny(e){return this.watch(this.states,e)}}const f={style:{level:"minimal"},networks:[{name:"Ethereum Mainnet",displayName:"Ethereum",id:1,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/ethereum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.infura.io/v3/"},{name:"Ropsten",displayName:"Ropsten (Ethereum Testnet)",id:3,type:"testnet",icon:null,currency:{name:"Ropsten Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://ropsten.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://ropsten.infura.io/v3/"},{name:"Rinkeby",displayName:"Rinkeby (Ethereum Testnet)",id:4,type:"testnet",icon:null,currency:{name:"Rinkeby Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://rinkeby.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://rinkeby.infura.io/v3/"},{name:"G\xF6rli",displayName:"G\xF6rli (Ethereum Testnet)",id:5,type:"testnet",icon:null,currency:{name:"G\xF6rli Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://goerli.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://goerli.infura.io/v3/"},{name:"Optimism",id:10,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/optimism.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://optimistic.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.optimism.io/"},{name:"Cronos Mainnet Beta",displayName:"Cronos",id:25,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/cronos.svg",currency:{name:"Cronos",symbol:"CRO",decimals:18},contracts:null,explorer:{name:"Cronos Explorer",url:"https://cronos.org/explorer",standard:"EIP3091"},defaultRPC:"https://evm.cronos.org"},{name:"Telos EVM Mainnet",displayName:"Telos",id:40,type:"mainnet",icon:null,currency:{name:"Telos",symbol:"TLOS",decimals:18},contracts:null,explorer:{name:"Teloscan",url:"https://teloscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.telos.net/evm"},{name:"Binance Smart Chain Mainnet",displayName:"BSC",id:56,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/bsc.svg",currency:{name:"Binance Chain Native Token",symbol:"BNB",decimals:18},contracts:null,explorer:{name:"Bscscan",url:"https://bscscan.com/",standard:"EIP3091"},defaultRPC:"https://bsc-dataseed1.binance.org/"},{name:"Gnosis Chain",displayName:"Gnosis",id:100,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/gnosis.svg",currency:{name:"xDAI",symbol:"xDAI",decimals:18},contracts:null,explorer:{name:"Blockscout",url:"https://blockscout.com/xdai/mainnet/",standard:"EIP3091"},defaultRPC:"https://rpc.gnosischain.com"},{name:"Fuse Mainnet",displayName:"Fuse",id:122,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fuse.svg",currency:{name:"Fuse",symbol:"FUSE",decimals:18},contracts:null,explorer:{name:"Fuse Explorer",url:"https://explorer.fuse.io/",standard:"EIP3091"},defaultRPC:"https://rpc.fuse.io"},{name:"Huobi ECO Chain Mainnet",displayName:"HECO",id:128,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/heco.svg",currency:{name:"Huobi ECO Chain Native Token",symbol:"HT",decimals:18},contracts:null,explorer:{name:"Hecoinfo",url:"https://hecoinfo.com",standard:"EIP3091"},defaultRPC:"https://http-mainnet.hecochain.com"},{name:"Polygon Mainnet",displayName:"Polygon",id:137,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/polygon.svg",currency:{name:"MATIC",symbol:"MATIC",decimals:18},contracts:null,explorer:{name:"Polygonscan",url:"https://polygonscan.com/",standard:"EIP3091"},defaultRPC:"https://polygon-rpc.com/"},{name:"Fantom Opera",displayName:"Fantom",id:250,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fantom.svg",currency:{name:"Fantom",symbol:"FTM",decimals:18},contracts:null,explorer:{name:"Ftmscan",url:"https://ftmscan.com/",standard:"EIP3091"},defaultRPC:"https://rpc.ftm.tools"},{name:"Metis Andromeda Mainnet",displayName:"Metis",id:1088,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/metis.svg",currency:{name:"Metis",symbol:"METIS",decimals:18},contracts:null,explorer:{name:"Metis Explorer",url:"https://andromeda-explorer.metis.io",standard:"EIP3091"},defaultRPC:"https://andromeda.metis.io/?owner=1088"},{name:"Moonbeam",id:1284,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonbeam.svg",currency:{name:"Glimmer",symbol:"GLMR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonbeam.moonscan.io",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonbeam.network"},{name:"Moonriver",id:1285,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonriver.svg",currency:{name:"Moonriver",symbol:"MOVR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonriver.moonscan.io/",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonriver.moonbeam.network"},{name:"Klaytn Mainnet Cypress",displayName:"Klaytn",id:8217,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/klaytn.svg",currency:{name:"KLAY",symbol:"KLAY",decimals:18},contracts:null,explorer:{name:"Klaytnscope",url:"https://scope.klaytn.com",standard:"EIP3091"},defaultRPC:"https://public-node-api.klaytnapi.com/v1/cypress"},{name:"Hardhat",displayName:"Hardhat",id:31337,type:"testnet",icon:null,currency:{name:"GoChain Coin",symbol:"GO",decimals:18},contracts:null,explorer:null,defaultRPC:"http://127.0.0.1:8545/"},{name:"Arbitrum One",displayName:"Arbitrum",id:42161,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/arbitrum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Arbiscan",url:"https://arbiscan.io/",standard:"EIP3091"},defaultRPC:"https://arbitrum-mainnet.infura.io/v3/"},{name:"Celo Mainnet",displayName:"Celo",id:42220,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/celo.svg",currency:{name:"CELO",symbol:"CELO",decimals:18},contracts:null,explorer:{name:"Celo Explorer",url:"https://explorer.celo.org/",standard:"EIP3091"},defaultRPC:"https://forno.celo.org"},{name:"Emerald Paratime Mainnet",displayName:"Emerald",id:42262,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/emerald.svg",currency:{name:"Emerald Rose",symbol:"ROSE",decimals:18},contracts:null,explorer:{name:"Emerald Explorer",url:"https://explorer.emerald.oasis.dev/",standard:"EIP3091"},defaultRPC:"https://emerald.oasis.dev"},{name:"Avalanche C-Chain",displayName:"Avalanche",id:43114,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/avalanche.svg",currency:{name:"Avalanche",symbol:"AVAX",decimals:18},contracts:null,explorer:{name:"Snowtrace",url:"https://snowtrace.io/",standard:"EIP3091"},defaultRPC:"https://api.avax.network/ext/bc/C/rpc"},{name:"Aurora Mainnet",displayName:"Aurora",id:1313161554,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/aurora.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Aurorascan",url:"https://aurorascan.dev",standard:"EIP3091"},defaultRPC:"https://mainnet.aurora.dev"},{name:"Harmony Mainnet Shard 0",displayName:"Harmony",id:16666e5,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/harmony.svg",currency:{name:"ONE",symbol:"ONE",decimals:18},contracts:null,explorer:{name:"Harmony Block Explorer",url:"https://explorer.harmony.one",standard:"EIP3091"},defaultRPC:"https://api.harmony.one"}],wallets:[{id:"metamask",displayName:"Metamask",icon:null},{id:"binanceChain",displayName:"Binance Chain",icon:null},{id:"coinbase",displayName:"Coinbase",icon:null}],defaults:{networks:{icon:"https://static.tuli.pe/icons/networks/unknown.svg"},wallets:{icon:"TODO"}}};class vt{constructor(e=null){let n={};return e?n=_({...f.style},{...e}):n=f.style,window.addEventListener("load",()=>{const s=document.getElementsByClassName("ve-app");if(s)for(const r of s)r&&r.classList.add(`ve-${n.level}`)}),n}}class te{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=f.networks.find(i=>i.id===n.id),r=_({...s},{...n});r.available!==!1&&(r.available=!0),r.displayName||(r.displayName=r.name),this._list.push(r)}}for(const n of f.networks)this._list.find(r=>r.id===n.id)||(n.available=!1,this._list.push(n))}add(e){this._list.push(e)}async getCurrent(){if(a.provider.proxy.ethersInstance){const e=await a.provider.getNetwork().then(n=>n.chainId);return this.getById(e)}return null}getById(e){try{e=parseInt(e)}catch{throw"'id' given to getById() method must be an integer or any data type that can be parsed to interger."}return this._list.find(n=>n.id===parseInt(e))}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ee{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=f.wallets.find(i=>i.id===n.id),r=_({...s},{...n});r.available!==!1&&(r.available=!0),r.displayName||(r.displayName=r.id),this._list.push(r)}}for(const n of f.wallets)this._list.find(r=>r.id===n.id)||(n.available=!1,this._list.push(n))}getCurrent(){return console.log("GET CURRENT, id = "+a.signer.id),a.signer.proxy.ethersInstance?this.getById(a.signer.id):null}getById(e){return this._list.find(n=>n.id===e)}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ne{constructor(e=null){let n={};return e?n=_({...f.defaults},{...e}):n=f.defaults,n}}class z{constructor(e=null){this.style=new vt(e?e.style:null),this.networks=new te(e?e.networks:null),this.wallets=new ee(e?e.wallets:null),this.defaults=new ne(e?e.defaults:null)}}class S{constructor(e=null,n=null,s=null){const r=new Proxy(this,{get:function(i,l,c){if(l==="proxy")return i.proxy;if(i.proxy.ethersInstance&&i.proxy.ethersInstance[l]!==void 0)return typeof i.proxy.ethersInstance[l]=="function"?i.proxy.ethersInstance[l].bind(i.proxy.ethersInstance):i.proxy.ethersInstance[l];if(i.proxy.ethersInstance&&i.proxy.extensionInstance&&i.proxy.extensionInstance[l]!==void 0)return typeof i.proxy.extensionInstance[l]=="function"?i.proxy.extensionInstance[l].bind(c):i.proxy.extensionInstance[l];if(i.proxy.placeholderInstance&&i.proxy.placeholderInstance[l]!==void 0)return typeof i.proxy.placeholderInstance[l]=="function"?i.proxy.placeholderInstance[l].bind(c):i.proxy.placeholderInstance[l]},set:function(i,l,c,h){if(i.proxy.ethersInstance&&i.proxy.ethersInstance[l]!==void 0)return i.proxy.ethersInstance[l]=c,!0;if(i.proxy.extensionInstance&&i.proxy.extensionInstance[l]!==void 0)return i.proxy.extensionInstance[l]=c,!0;if(i.proxy.placeholderInstance&&i.proxy.placeholderInstance[l]!==void 0)return i.proxy.placeholderInstance[l]=c,!0;throw console.log(i.proxy.placeholderInstance),console.log(i.proxy.placeholderInstance[l]),`New properties cannot be set on TulipeProxy instances. Please define '${l}' in constructor firstly.`}});return this.proxy={_initIsRunning:!1,_ethersInstance:null,get ethersInstance(){return this._ethersInstance},set ethersInstance(i){this.placeholderInstance._ars.oldEthersInstance={...this._ethersInstance},this._ethersInstance=i&&t.markRaw(i),this._initIsRunning||r._asyncInit()},extensionInstance:n,placeholderInstance:s},this.proxy.ethersInstance=e,r}}class se{}class k{constructor(){this._ars={}}_purgeARS(){if(this._ars.unwatchers)for(const e of this._ars.unwatchers)e();if(this._ars.unwatchers=[],this._ars.oldEthersInstance&&this._ars.events)for(const[e,n]of Object.entries(this._ars.events))this._ars.oldEthersInstance.off(e,n)}_initEthersInstanceARS(){}_initPlaceholderInstanceARS(){}_initARS(){this._purgeARS(),this.proxy.ethersInstance&&this._initEthersInstanceARS(),this._initPlaceholderInstanceARS()}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}class ae extends k{constructor(){super(),this.status=new g("provider",["DISCONNECTED","ERROR","WRONG_NETWORK","CONNECTED"]),this.isSafe=t.computed(()=>a.isSafe.value&&!this.status.isIn(["DISCONNECTED","ERROR"])),this.OnSafe=D}_autoInstantiateFromWallet(){for(const e of Object.values(a.wallets))e&&e.provider&&(this.proxy.ethersInstance=e.provider)}_autoInstantiateFromDefaultConfig(){const e=a.config.networks.getDefault();e&&e.defaultRPC&&(this.proxy.ethersInstance=new y.ethers.providers.JsonRpcProvider(e.defaultRPC))}_autoInstantiate(){this._autoInstantiateFromWallet(),this.proxy.ethersInstance||this._autoInstantiateFromDefaultConfig()}_initARS(){this.on("network",(e,n)=>{n&&n!==e&&window.location.reload()})}async _checkNetwork(){if(!this.proxy.ethersInstance)throw"<TulipeProviderProxy instance>._checkNetwork() method must not be called if the ethersInstance is null (if not connected to any network).";const e=await this.getNetwork();let n=await a.config.networks.getById(e.chainId);if(n)this.status.set("CONNECTED");else if(this.status.set("WRONG_NETWORK"),n=a.config.networks.getAll().find(s=>s.id===e.id),!n){const s={name:e.name,displayName:U(e.name),id:e.chainId};console.log(s),a.config.networks.add(s)}}async _setNetworkSettings(){const e=await this.getNetwork();let n=await a.config.networks.getById(e.chainId);n&&n&&n.pollingInterval&&(this.pollingInterval=n.pollingInterval)}async _asyncInit(){this.proxy._initIsRunning=!0,this.proxy.ethersInstance||this._autoInstantiate(),this.proxy.ethersInstance?(await this._checkNetwork(),await this._setNetworkSettings(),this._initARS()):this.status.set("DISCONNECTED"),this.proxy._initIsRunning=!1}async changeNetwork(e){const n=await a.config.wallets.getCurrent();n&&a.wallets[n.id].changeNetwork(e)}}class K extends S{constructor(e=null,n=null,s=null){super(e,n||new se,s||new ae),this._asyncInit()}}class re{}class oe extends k{constructor(){super(),this.id=null,this.address=t.ref(null),this.status=new g("signer",["NO_PROVIDER","DISCONNECTED","REQUESTED","REFUSED","ERROR","WRONG_NETWORK","CONNECTED"]),this.isSafe=t.computed(()=>a.provider.isSafe.value&&this.status.is("CONNECTED")),this.OnSafe=V}_initEthersInstanceARS(){}_initPlaceholderInstanceARS(){a.provider.status.watchAny(e=>{e==="WRONG_NETWORK"?this.status.set("WRONG_NETWORK"):["DISCONNECTED","ERROR"].includes(e)&&this.status.set("NO_PROVIDER")}),this.status.watch(["REFUSED","ERROR"],()=>{setTimeout(()=>{this.status.set("DISCONNECTED")},5e3)})}async _autoInstantiate(){console.log(a.wallets);for(const e of Object.keys(a.wallets))if(a.wallets[e].lazyConnectAvailable&&(await this.connectWallet(e,!0),this.proxy.ethersInstance))break}async _asyncInit(){this.proxy._initIsRunning=!0,a.provider.onSafe(async function(){this.proxy.ethersInstance||await this._autoInstantiate(),this.proxy.ethersInstance||this.status.set("DISCONNECTED"),this._initARS(),this.proxy._initIsRunning=!1}.bind(this))}async _setSignerDatas(e){const n=await e.getSigner(),s=await n.getAddress();this.address.value=s,a.signer.proxy.ethersInstance=n,this.id=e.id,a.signer.status.set("CONNECTED")}async connectWallet(e,n=!1){console.log("CONNECT lazy = "+n);const s=a.wallets[e];if(s.lazyConnectAvailable){if(await s.connect(!0),await s.isConnected())await this._setSignerDatas(s);else if(n){a.signer.status.set("DISCONNECTED");return}}try{this.status.set("REQUESTED"),await s.connect(!1),await this._setSignerDatas(s)}catch(r){if(r instanceof N)this.status.set("REFUSED");else throw this.status.set("ERROR"),r}}disconnectWallet(){a.signer.proxy.ethersInstance=null,this.address.value=null,a.signer.status.set("DISCONNECTED")}}class Y extends S{constructor(e=null,n=null,s=null){super(e,n||new re,s||new oe),this._asyncInit()}}class ie{_watch(e,n,s=null){return Object.keys(a.chainWatchers.contracts).includes(this.address)||a.chainWatchers.addContractWatcher(this),a.chainWatchers.contracts[this.address].add(e,n,s)}watch(e,n,s,r=null){const i=this._watch(e,n,s);return r?t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,i)},r):t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,i)}),a.chainWatchers.contracts[this.address].remove.bind(a.chainWatchers.contracts[this.address],e,n,i)}watchRef(e,n,s=null){const r=this._watch(e,n,null);return s?t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,r)},s):t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,r)}),a.chainWatchers.contracts[this.address].getRef(e,n)}}class le extends k{constructor(){super(),this.name="TODO",this.status=new g(`contract:${name}`,["NO_PROVIDER","UNAVAILABLE","ERROR","INITIALIZED"]),this.isReadSafe=t.computed(()=>a.provider.isSafe.value&&this.status.is("INITIALIZED")),this.isWriteSafe=t.computed(()=>a.signer.isSafe.value&&this.status.is("INITIALIZED")),this.OnReadSafe=t.createVNode(T,{contract:this.name}),this.OnWriteSafe=t.createVNode(P,{contract:this.name})}onSafe(e){throw"TulipeContract instances don't have 'onSafe()' method, use 'onReadSafe()' and 'onWriteSafe()' instead."}onReadSafe(e){const n=t.getCurrentInstance();if(this.isReadSafe.value)e(n);else{const s=t.watch(this.isReadSafe,()=>{this.isReadSafe.value&&(e(n),s())})}}onWriteSafe(e){const n=t.getCurrentInstance();if(this.isWriteSafe.value)e(n);else{const s=t.watch(this.isWriteSafe,()=>{this.isWriteSafe.value&&(e(n),s())})}}_updateContract(e,n){if(a.signer.isSafe.value)this.proxy.ethersInstance=new y.ethers.Contract(e,n,a.signer.proxy.ethersInstance);else if(a.provider.isSafe.value)this.proxy.ethersInstance=new y.ethers.Contract(e,n,a.provider.proxy.ethersInstance);else throw`_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`}_initARS(e,n){this._purgeARS(),this._ars.unwatchers.push(a.provider.status.watchAny(s=>{s==="WRONG_NETWORK"?this.status.set("UNAVAILABLE"):["DISCONNECTED","ERROR"].includes(s)&&this.status.set("NO_PROVIDER")})),this._ars.unwatchers.push(t.watch([a.signer.isSafe],(s,r)=>{s!==r&&(this.proxy.ethersInstance=null,this._updateContract(e,n))}))}async _asyncInit(){this.proxy._initIsRunning=!0,a.provider.onSafe(async function(){this.proxy.ethersInstance?this._initARS():this.status.set("UNAVAILABLE"),this.proxy._initIsRunning=!1}.bind(this))}}class A extends S{constructor(e,n=null,s=null,r=null){super(n,s||new ie,r||new le(e)),this._asyncInit()}}class ce{}class de extends k{constructor(e,n,s=[],r={value:0}){super(),this.contractName=e,this.methodName=n,this.methodInfos={},this.args=t.ref(s),this.txArgs=t.ref(r),this.data=t.ref([]),this.error=t.ref(null),this.call=null,this.status=new g(`tx:${e}:${n}`,["NOT_READY","READY","SENT","ERROR","SUCCESS"])}initARS(){this.status.watch(["ERROR","SUCCESS"],()=>{setTimeout(()=>{this.status.set("READY")},3e3)})}_asyncInit(){this.proxy._initIsRunning=!0,a.contracts[this.contractName].isReadSafe.value&&this._initEthersInstance(),a.contracts[this.contractName].onReadSafe(()=>{this._initEthersInstance()}),this.initARS(),this.proxy._initIsRunning=!1}_initEthersInstance(){this.methodInfos=a.contracts[this.contractName].interface.functions[this.methodName],this.methodInfos.inputs.forEach(e=>this.args.value.push(null)),this.methodInfos.outputs.forEach(e=>this.data.value.push(null)),this.proxy.ethersInstance=a.contracts[this.contractName][this.methodName],this.status.set("READY")}send(e=null,n=null){e=e&&e.length>0?e:w(this.args),e?Array.isArray(e)?this.call=this.proxy.ethersInstance(...e,n):this.call=this.proxy.ethersInstance(e,n):this.call=this.proxy.ethersInstance(n),this.status.set("SENT"),this.methodInfos.constant?this.call.then(s=>{Array.isArray(s)||(s=[s]),p(this.data,s),p(this.error,null),this.status.set("SUCCESS")}).catch(s=>{p(this.error,s),this.status.set("ERROR")}):this.call.then(s=>s.wait()).then(s=>{Array.isArray(s)||(s=[s]),p(this.data,s),p(this.error,null),this.status.set("SUCCESS")}).catch(s=>{p(this.error,s),this.status.set("ERROR"),console.log(s)})}}class W extends S{constructor(e,n,s=[],r={value:0},i=null,l=null,c=null){super(i,l||new ce,c||new de(e,n,s=[],r={value:0})),this._asyncInit()}}class Z{constructor(){this.lastUpdateBlock=0,this.sources={}}_generateDependentUUID(){return"xxxxxxxx".replace(/[xy]/g,function(e){var n=Math.random()*16|0,s=e=="x"?n:n&3|8;return s.toString(16)})}async requiresUpdate(){if(!a.provider.isSafe.value)return!1;const e=await a.provider.getBlockNumber();return this.lastUpdateBlock<e}async updateLastUpdateBlock(){const e=await a.provider.getBlockNumber();this.lastUpdateBlock=e}async _update(){throw"_update() method not implemented in that ChainWatcher child class."}update(){this._update()}}class Q extends Z{constructor(e){super(),this.contract=e}_buildSourceName(e,n){return`${e}:${n?n.toString():""}`}async _updateState(e){e.args?e.state.value=await this.contract[e.name](...e.args):e.state.value=await this.contract[e.name]()}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){const r=this._buildSourceName(e,n);let i=!1;Object.keys(this.sources).includes(r)||(this.sources[r]={name:e,args:n,state:t.ref(null),dependents:{}},i=!0);let l=null;s&&(l=t.watch(this.sources[r].state,s));const c=this._generateDependentUUID();return this.sources[r].dependents[c]=l,i&&this._updateState(this.sources[r]),c}remove(e,n,s){const r=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(r)&&Object.keys(this.sources[r].dependents).includes(s)){const i=this.sources[r].dependents[s];i&&i(),delete this.sources[r].dependents[s]}Object.keys(this.sources[r].dependents).length===0&&delete this.sources[r]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class J extends Z{constructor(e){super(),this.address=e,this.availableSources=["balance"]}async _updateState(e){e.name==="balance"&&(e.state.value=await a.provider.getBalance(this.address))}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))await this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){if(!this.availableSources.includes(e))throw`Sources added to a ChainWalletWatcher must be in ${this.availableSources}. Got ${e}`;const r=this._buildSourceName(e,n);newSource=!1,Object.keys(this.sources).includes(r)||(this.sources[r]={name:e,args:n,state:ref(null),dependents:{}},newSource=!0);let i=null;s&&(i=watch(this.sources[r].state,s));const l=this._generateDependentUUID();return this.sources[r].dependents[l]=i,newSource&&this._updateState(this.sources[r]),l}remove(e,n,s){const r=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(r)&&Object.keys(this.sources[r].dependents).includes(s)){const i=this.sources[r].dependents[s];i&&i(),delete this.sources[r].dependents[s]}Object.keys(this.sources[r].dependents).length===0&&delete this.sources[r]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class N extends Error{constructor(e,...n){super(e,...n),this.message=`'${e}' wallet has rejected the connection request.`}}class m extends Error{constructor(e,...n){super(walletId,...n),this.message=e}}class X{constructor(e){this.id=e,this.lazyConnectAvailable=!0}isConnected(){throw new m(`isConnected() method is not implemented in ${this.id} wallet class.`)}getProvider(){throw new m(`getProvider() method is not implemented in ${this.id} wallet class.`)}getSigner(e=!1){throw new m(`getSigner() method is not implemented in ${this.id} wallet class.`)}async connect(e=!1){throw new m(`connect() method is not implemented in ${this.id} wallet class.`)}addNetwork(e){throw new m(`addNetwork() method is not implemented in ${this.id} wallet class.`)}switchNetwork(e,n=!1){throw new m(`switchNetwork() method is not implemented in ${this.id} wallet class.`)}}class v extends X{constructor(e,n=null){super(e),this.exposedObject=n}async isConnected(){if(this.exposedObject&&this.getSigner())try{const n=await this.exposedObject.request({method:"eth_accounts"});if(n&&n.length>0)return console.log(n),!0}catch{}return!1}getProvider(){return this.exposedObject?new y.ethers.providers.Web3Provider(this.exposedObject,"any"):null}async getSigner(){if(this.exposedObject){const e=this.getProvider();if(e)return await e.getSigner()}return null}async connect(e=!1){if(this.exposedObject){if(await this.isConnected()||e)return;try{await this.exposedObject.request({method:"eth_requestAccounts"})}catch(n){throw n.code===4001?new N(this.id):n}}throw"exposedObject not available"}async addNetwork(e){const n=a.config.networks.getById(e);await this.exposedObject.request({method:"wallet_addEthereumChain",params:[{chainId:e,rpcUrls:[n.defaultRPC],chainName:n.name,nativeCurrency:{name:n.currency.symbol,symbol:n.currency.symbol,decimals:n.currency.decimals},blockExplorerUrls:n.explorer&&n.explorer.url!==""?[n.explorer.url]:null}]})}async changeNetwork(e,n=!1){if(a.config.networks.getById(e)){e=y.ethers.utils.hexlify(parseInt(e)).toString(),e=y.ethers.utils.hexValue(e);try{await this.exposedObject.request({method:"wallet_switchEthereumChain",params:[{chainId:e}]})}catch(r){if(r.code===4902)this.addNetwork(e);else throw r}}}}class he extends v{constructor(){super("metamask",window.ethereum)}}class ue extends X{constructor(e,n={}){super(),this.id="coinbase";const s=n.appName||"",r=n.appLogoUrl,i=n.darkMode||!1;this.coinbaseWalletSdk=new e({appName:s,appLogoUrl:r,darkMode:i}),this.provider=this.getProvider()}getProvider(){try{return this.coinbaseWalletSdk.makeWeb3Provider()}catch(e){return console.log(e),null}}async connect(){try{await this.provider.send("eth_requestAccounts")}catch{throw N(this.id)}}}class pe extends v{constructor(){super("binanceChain",window.BinanceChain),this.lazyConnectAvailable=!1}async isConnected(){throw new m("isConnected() method is not available for BinanceChainWallet class since lazy connection is not available.")}async connect(e=!1){if(e)throw new m("connect() with 'lazy=true' is not available for BinanceChainWallet class because isConnected() is not available on this class.")}}const tt={metamask:he,coinbase:ue,binanceChain:pe};async function fe(o,e){const n=e;try{a.init(n)}catch(r){throw a&&a.status&&a.status.set("ERROR"),r}o.config.globalProperties.dapp=a,o.config.globalProperties.rGet=w,o.config.globalProperties.rSet=p,window.dapp=a;const s=await Promise.resolve().then(()=>Xt);o.component("OnDappSafe",s.OnDappSafe),o.component("OnProviderSafe",s.OnProviderSafe),o.component("OnSignerSafe",s.OnSignerSafe),o.component("OnContractReadSafe",s.OnContractReadSafe),o.component("OnContractWriteSafe",s.OnContractWriteSafe),a.status.set("INITIALIZED")}return d.ConnectWalletButton=L,d.ContractInteractor=M,d.ContractWatcher=Q,d.DebugBar=H,d.EventInteractor=O,d.EventsInteractor=R,d.InputUnits=$,d.MethodInteractor=b,d.MethodsInteractor=C,d.OnContractReadSafe=T,d.OnContractWriteSafe=P,d.OnDappSafe=B,d.OnProviderSafe=D,d.OnSignerSafe=V,d.SelectNetworkDropdown=q,d.SelectWalletDropdown=F,d.Status=g,d.Transact=x,d.TulipeConfig=z,d.TulipeContractProxy=A,d.TulipeProviderProxy=K,d.TulipeProxy=S,d.TulipeSignerProxy=Y,d.TulipeTransactionProxy=W,d.WalletConnectionRejected=N,d.WalletWatcher=J,d.capitalizeWords=U,d.dapp=a,d.deepMerge=_,d.initTulipe=fe,d.isObject=E,d.rGet=w,d.rSet=p,d.styleLevelProp=I,d.wallets=tt,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),d}({},vue,ethers); |
@@ -1,1 +0,1 @@ | ||
(function(l,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("ethers")):typeof define=="function"&&define.amd?define(["exports","vue","ethers"],t):(l=typeof globalThis<"u"?globalThis:l||self,t(l.Tulipe={},l.vue,l.ethers))})(this,function(l,t,m){"use strict";class at{constructor(){}init(e=null){this.config=new Y(e),this.status=new _("dapp",["UNSAFE","ERROR","INITIALIZED"]),this.isSafe=t.computed(()=>this.status.is("INITIALIZED")),this.OnSafe=b,this.chainWatchers=new Q,this.wallets=new nt,this.provider=new z,this.pro=this.provider,this.signer=new K,this.sig=this.signer,this.contracts=new Z,this.con=this.contracts}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}const r=new at;function g(o){return o&&typeof o=="object"&&!Array.isArray(o)}function y(o,...e){if(!e.length)return o;const n=e.shift();if(g(o)&&g(n))for(const s in n)g(n[s])?(o[s]||Object.assign(o,{[s]:{}}),y(o[s],n[s])):Object.assign(o,{[s]:n[s]});return y(o,...e)}function P(o){const e=o.split(" ");for(let n=0;n<e.length;n++)e[n]=e[n][0].toUpperCase()+e[n].substring(1);return e.join(" ")}function S(o){return t.isRef(o)?S(o.value):o}function f(o,e){t.isRef(o)?o.value=e:o=e}const me="",k={required:!1,type:String,default:"minimal",validator(o){return["unstylized","minimal","opinionated"].includes(o)}},rt={class:"ContractInteractor"},ot=t.createTextVNode(" Methods : "),it=t.createElementVNode("br",null,null,-1),lt=t.createTextVNode(" Events : "),ct=t.createElementVNode("br",null,null,-1),A={__name:"ContractInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];let s=t.ref("not owned");return r.contracts[e.contract].onReadSafe(async function(){try{s.value=await n.owner()}catch{}}),(a,i)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",rt,[t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Address : "+t.toDisplayString(t.unref(n).address),1),t.createElementVNode("li",null,"Owner : "+t.toDisplayString(t.unref(s)),1),t.createElementVNode("li",null,[ot,it,t.createVNode(t.unref(C),{contract:e.contract},null,8,["contract"])]),t.createElementVNode("li",null,[lt,ct,t.createVNode(t.unref(R),{contract:e.contract},null,8,["contract"])])])])]),_:1},8,["contract"])}}},dt={class:"MethodsInteractor"},C={__name:"MethodsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];return(s,a)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",dt,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.functions,(c,d)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(N),{contract:e.contract,method:d},null,8,["contract","method"])]))),256))])])]),_:1},8,["contract"])}}},ht={class:"MethodInteractor"},ut={key:0},ft=t.createElementVNode("p",null,"Inputs :",-1),pt=["onUpdate:modelValue","placeholder"],mt={key:0},yt={key:1},_t=t.createElementVNode("p",null,"Outputs :",-1),St=["onUpdate:modelValue","placeholder"],Et=["placeholder"],gt={key:2},N={__name:"MethodInteractor",props:{contract:{type:String,required:!0},method:{type:String,required:!0}},setup(o){const e=o,n=t.shallowRef(new $(e.contract,e.method));function s(a){return`${a.name&&a.name!=="null"?a.name:""} (${a.type})`}return(a,i)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ht,[t.createVNode(t.unref(O),{contract:e.contract,method:e.method,modelValue:t.unref(n),"onUpdate:modelValue":i[0]||(i[0]=d=>t.isRef(n)?n.value=d:null),configs:{content:e.method,notx:!0,noerror:!0}},null,8,["contract","method","modelValue","configs"]),t.createElementVNode("small",null,t.toDisplayString(t.unref(n).methodInfos.stateMutability),1),Object.keys(t.unref(n).methodInfos.inputs).length>0||t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("div",ut,[ft,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.inputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":u=>t.unref(n).args.value[h]=u,type:"text",placeholder:s(d)},null,8,pt),[[t.vModelText,t.unref(n).args.value[h]]]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).args.value[h])+" "+t.toDisplayString(typeof t.unref(n).args.value[h]),1)]))),256)),t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("li",mt,[t.createVNode(t.unref(x),{modelValue:t.unref(n).txArgs.value.value,"onUpdate:modelValue":i[1]||(i[1]=d=>t.unref(n).txArgs.value.value=d)},null,8,["modelValue"]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).txArgs.value.value)+" "+t.toDisplayString(typeof t.unref(n).txArgs.value.value),1)])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),Object.keys(t.unref(n).methodInfos.outputs).length>0?(t.openBlock(),t.createElementBlock("div",yt,[_t,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.outputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.unref(n).data.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:0,"onUpdate:modelValue":u=>t.unref(n).data.value[h]=u,type:"text",placeholder:s(d),disabled:""},null,8,St)),[[t.vModelText,t.unref(n).data.value[h]]]):(t.openBlock(),t.createElementBlock("input",{key:1,type:"text",placeholder:s(d),disabled:""},null,8,Et))]))),256))])])):t.createCommentVNode("",!0),t.unref(n).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",gt,t.toDisplayString(t.unref(n).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},wt={class:"EventsInteractor"},R={__name:"EventsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];return(s,a)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",wt,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.events,(c,d)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(I),{contract:e.contract,event:d},null,8,["contract","event"])]))),256))])])]),_:1},8,["contract"])}}},kt={class:"EventInteractor"},Ct=t.createTextVNode("Logs: "),I={__name:"EventInteractor",props:{contract:{type:String,required:!0},event:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];let s=t.ref({}),a=t.ref({}),i=t.ref(0),c=t.ref([]);return n.onReadSafe(()=>{s.value=n.interface.events[e.event],a.value=n.filters[s.value.name],n.on(a.value,d=>{i.value++;let h=`Block ${d.blockNumber} -> {`;for(const u of s.value.inputs)h+=`${u.name}:${d.args[u.name]}, `;h=h.substring(0,h.length-2)+"}",c.value.push(h)})}),(d,h)=>{const u=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(u,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",kt,[t.createElementVNode("p",null,t.toDisplayString(t.unref(s).name),1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Count : "+t.toDisplayString(t.unref(i)),1),t.createElementVNode("li",null,[Ct,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(c),pe=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(pe),1))),256))])])])])]),_:1},8,["contract"])}}},Nt={class:"TransactButton"},Rt={key:1,disabled:""},It={key:2,disabled:""},Ot={key:3,disabled:""},bt={key:4},O={__name:"Transact",props:{modelValue:{},contract:{type:String,required:!0},method:{type:String,required:!0},args:{type:Array,required:!1},txArgs:{type:Object,required:!1},configs:{type:Object,required:!1}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=r.contracts[n.contract];let a=t.computed({get(){return n.modelValue},set(c){e("update:modelValue",c)}});function i(){const c=n.args?n.args:[],d=n.txArgs?n.txArgs:{};a.value.send(c,d)}return n.config&&n.configs.notx&&s.onReadSafe(()=>{a=new $(n.contract,n.method)}),(c,d)=>{const h=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(h,{contract:n.contract},{default:t.withCtx(()=>[t.createElementVNode("div",Nt,[t.unref(a).status.is("READY")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:i},t.toDisplayString(n.configs&&n.configs.content?n.configs.content:"Transact"),1)):t.unref(a).status.is("SENT")?(t.openBlock(),t.createElementBlock("button",Rt,"Transaction sent...")):t.unref(a).status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",It,"Transaction error!")):t.unref(a).status.is("SUCCESS")?(t.openBlock(),t.createElementBlock("button",Ot,"Success !")):t.createCommentVNode("",!0),!(n.configs&&n.configs.noerror)&&t.unref(a).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",bt,t.toDisplayString(t.unref(a).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},ye="",M=(o,e)=>{const n=o.__vccOpts||o;for(const[s,a]of e)n[s]=a;return n},Bt={key:1,disabled:""},Dt={key:2,disabled:""},Vt={key:3,disabled:""},Tt={key:4,disabled:""},U=M({__name:"ConnectWalletButton",props:{styleLevel:k},setup(o){const e=o;let n=t.ref({});return r.provider.onSafe(async function(){n.value=await r.config.networks.getCurrent()}),(s,a)=>(t.openBlock(),t.createBlock(t.unref(r).provider.OnSafe,null,{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(["ConnectWalletButton",`ve-${e.styleLevel}`])},[t.unref(r).signer.status.is("DISCONNECTED")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:a[0]||(a[0]=i=>t.unref(r).signer.connectWallet(t.unref(r).wallets.metamask))},"Connect Wallet")):t.unref(r).signer.status.is("REQUESTED")?(t.openBlock(),t.createElementBlock("button",Bt,"Connection requested...")):t.unref(r).signer.status.is("REFUSED")?(t.openBlock(),t.createElementBlock("button",Dt,"Connection refused!")):t.unref(r).signer.status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",Vt,"Connection error!")):t.unref(r).provider.status.is("WRONG")?(t.openBlock(),t.createElementBlock("button",Tt,"Wrong network! ("+t.toDisplayString(t.unref(n)?t.unref(n).displayName:"unknown")+")",1)):t.unref(r).signer.status.is("CONNECTED")?(t.openBlock(),t.createElementBlock("button",{key:5,onClick:a[1]||(a[1]=(...i)=>t.unref(r).signer.disconnectWallet&&t.unref(r).signer.disconnectWallet(...i))},"Disconnect")):t.createCommentVNode("",!0)],2)]),_:1}))}},[["__scopeId","data-v-b6827a89"]]),xt={class:"SelectWalletDropdown"},Wt={key:0},$t=["src","alt"],Pt={key:1},At=[t.createElementVNode("p",null,"Select a wallet",-1)],Mt=["onClick"],Ut=["src","alt"],L={__name:"SelectWalletDropdown",setup(o){let e=t.ref({}),n=t.ref([]),s=t.ref(!1);r.onSafe(async function(){e.value=await r.config.wallets.getCurrent(),n.value=r.config.wallets.getAvailable().filter(i=>i!==e.value)});function a(){s.value=!s.value}return(i,c)=>{const d=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(d,null,{default:t.withCtx(()=>[t.createElementVNode("div",xt,[t.createElementVNode("ul",{onClick:a},[t.unref(e)?(t.openBlock(),t.createElementBlock("li",Wt,[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(r).config.defaults.wallets.icon,alt:t.unref(e).displayName+" logo"},null,8,$t),t.createElementVNode("p",null,"cur"+t.toDisplayString(t.unref(e).displayName),1)])):(t.openBlock(),t.createElementBlock("li",Pt,At)),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:2},t.renderList(t.unref(n),h=>(t.openBlock(),t.createElementBlock("li",{key:h.id,onClick:u=>t.unref(r).signer.connectWallet(t.unref(r).wallets[h.id])},[t.createElementVNode("img",{width:"40",src:h.icon?h.icon:t.unref(r).config.defaults.wallets.icon,alt:h.displayName+" logo"},null,8,Ut),t.createElementVNode("p",null,t.toDisplayString(h.displayName),1)],8,Mt))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},Lt={class:"SelectNetworkDropdown"},jt={key:0},Ft=["src","alt"],Gt={key:1},qt=[t.createElementVNode("p",null,"Select a network",-1)],Ht=["onClick"],Zt=["src","alt"],j={__name:"SelectNetworkDropdown",setup(o){let e=t.ref({}),n=t.ref([]),s=t.ref(!1);r.onSafe(async function(){e.value=await r.config.networks.getCurrent(),n.value=r.config.networks.getAvailable().filter(i=>i.id!==e.value.id)});function a(){s.value=!s.value}return(i,c)=>{const d=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(d,null,{default:t.withCtx(()=>[t.createElementVNode("div",Lt,[t.createElementVNode("ul",{onClick:a},[t.unref(e)?(t.openBlock(),t.createElementBlock("li",jt,[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(r).config.defaults.networks.icon,alt:t.unref(e).displayName+" logo"},null,8,Ft),t.createElementVNode("p",null,t.toDisplayString(t.unref(e).displayName),1)])):(t.openBlock(),t.createElementBlock("li",Gt,qt)),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:2},t.renderList(t.unref(n),h=>(t.openBlock(),t.createElementBlock("li",{key:h.id,onClick:u=>t.unref(r).provider.changeNetwork(h.id)},[t.createElementVNode("img",{width:"40",src:h.icon?h.icon:t.unref(r).config.defaults.networks.icon,alt:h.displayName+" logo"},null,8,Zt),t.createElementVNode("p",null,t.toDisplayString(h.displayName),1)],8,Ht))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},b={__name:"OnDappSafe",setup(o){return(e,n)=>t.unref(r).isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},B={__name:"OnProviderSafe",setup(o){return(e,n)=>t.unref(r).provider.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},D={__name:"OnSignerSafe",setup(o){return(e,n)=>t.unref(r).signer.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},F={__name:"OnContractsReadSafe",setup(o){return(e,n)=>t.unref(r).contracts.areReadSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},G={__name:"OnContractsWriteSafe",setup(o){return(e,n)=>t.unref(r).contracts.areWriteSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},V={__name:"OnContractReadSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(r).contracts[e.contract].isReadSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},T={__name:"OnContractWriteSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(r).contracts[e.contract].isWriteSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},ge="",q=o=>(t.pushScopeId("data-v-8361140f"),o=o(),t.popScopeId(),o),Yt=q(()=>t.createElementVNode("h3",null,"Safe Runners",-1)),zt=q(()=>t.createElementVNode("h3",null,"Status",-1)),H=M({__name:"DebugBar",setup(o){return(e,n)=>{const s=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(s,null,{default:t.withCtx(()=>[t.createElementVNode("section",null,[t.createElementVNode("div",null,[Yt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"DApp safe : "+t.toDisplayString(t.unref(r).isSafe),1),t.createElementVNode("li",null,"Provider safe : "+t.toDisplayString(t.unref(r).provider.isSafe),1),t.createElementVNode("li",null,"Signer safe : "+t.toDisplayString(t.unref(r).signer.isSafe),1),t.createElementVNode("li",null,"Contracts read safe : "+t.toDisplayString(t.unref(r).contracts.areReadSafe),1),t.createElementVNode("li",null,"Contracts write safe : "+t.toDisplayString(t.unref(r).contracts.areWriteSafe),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(r).contracts.getAll(),(a,i)=>(t.openBlock(),t.createElementBlock("li",null,[t.createTextVNode(" contract "+t.toDisplayString(i)+" : ",1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"read safe : "+t.toDisplayString(a.isReadSafe),1),t.createElementVNode("li",null,"write safe : "+t.toDisplayString(a.isWriteSafe),1)])]))),256))])]),t.createElementVNode("div",null,[zt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"dapp : "+t.toDisplayString(t.unref(r).status.get()),1),t.createElementVNode("li",null,"provider : "+t.toDisplayString(t.unref(r).provider.status.get()),1),t.createElementVNode("li",null,"signer : "+t.toDisplayString(t.unref(r).signer.status.get()),1),t.createElementVNode("li",null,"contracts : "+t.toDisplayString(t.unref(r).contracts.status.get()),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(r).contracts.getAll(),(a,i)=>(t.openBlock(),t.createElementBlock("li",null," contract "+t.toDisplayString(i)+" : "+t.toDisplayString(a.status.get()),1))),256))])])])]),_:1})}}},[["__scopeId","data-v-8361140f"]]),Kt={class:"InputUnits"},Qt=["placeholder"],Jt=["value"],x={__name:"InputUnits",props:{modelValue:{},placeholder:{type:String}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o;let s=t.ref(null);const a=["wei","gwei","ether"];let i=t.ref("wei");function c(){if(s.value){const d=m.ethers.utils.parseUnits(s.value,i.value);e("update:modelValue",d)}}return(d,h)=>(t.openBlock(),t.createElementBlock("div",Kt,[t.withDirectives(t.createElementVNode("input",{onInput:c,"onUpdate:modelValue":h[0]||(h[0]=u=>t.isRef(s)?s.value=u:s=u),type:"text",placeholder:t.unref(n).placeholder},null,40,Qt),[[t.vModelText,t.unref(s)]]),t.withDirectives(t.createElementVNode("select",{onChange:c,"onUpdate:modelValue":h[1]||(h[1]=u=>t.isRef(i)?i.value=u:i=u)},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(a,u=>t.createElementVNode("option",{value:u},t.toDisplayString(u),9,Jt)),64))],544),[[t.vModelSelect,t.unref(i)]])]))}},Xt=Object.freeze(Object.defineProperty({__proto__:null,InputUnits:x,styleLevelProp:k,ContractInteractor:A,MethodsInteractor:C,MethodInteractor:N,EventsInteractor:R,EventInteractor:I,Transact:O,ConnectWalletButton:U,SelectWalletDropdown:L,SelectNetworkDropdown:j,OnDappSafe:b,OnProviderSafe:B,OnSignerSafe:D,OnContractsReadSafe:F,OnContractsWriteSafe:G,OnContractReadSafe:V,OnContractWriteSafe:T,DebugBar:H},Symbol.toStringTag,{value:"Module"}));class _{constructor(e,n){if(this._name=e,this.states=[],!Array.isArray(n))throw`The 'states' parameter of a Status instance '${e}' must an array of strings. Got: ${n}`;for(const s of n)this.states.push(this._formatState(s));this._state=t.ref(this.states[0])}_formatState(e){return e.toString().toUpperCase()}_isStateValid(e){return!!this.states.includes(this._formatState(e))}_areStatesValid(e){for(const n of e)if(!this._isStateValid(n))return!1;return!0}get(){return S(this._state)}getRef(){return this._state}set(e){if(e=this._formatState(e),!this._isStateValid(e))throw`The state given to the set() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;f(this._state,e),console.log(`Status '${this._name}' set to '${S(this._state)}'`)}is(e){if(!this._isStateValid(e))throw`The state given to the is() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;return this.get()==this._formatState(e)}isIn(e){if(!this._areStatesValid(e))throw`The states given to the isIn() method of Status instance '${this._name}' must be an array with values in ${this.states}. Got: ${e}`;for(const n of e)if(this.is(n))return!0;return!1}watch(e,n){let s=`The states given to the watch() method of Status instance '${this._name}' must be a string or an array with values in ${this.states}. Got: ${e}`;if(Array.isArray(e)){if(!this._areStatesValid(e))throw s;t.watch(this._state,()=>{this.isIn(e)&&n(this.get())})}else{if(!this._isStateValid(e))throw s;t.watch(this._state,()=>{this.is(e)&&n(this.get())})}}watchAny(e){this.watch(this.states,e)}}class Z{constructor(){this.status=new _("contracts",["NO_PROVIDER","WRONG_PROVIDER","ERROR","INITIALIZED"]),r.provider.status.watchAny(e=>{e==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(e)&&this.status.set("NO_PROVIDER")});for(const e of r.config.networks.getAll())if(e.contracts)for(const n of Object.keys(e.contracts))this[n]=new W(n);this.areReadSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("INITIALIZED")),this.areWriteSafe=t.computed(()=>r.signer.isSafe.value&&this.status.is("INITIALIZED")),this.status.set("INITIALIZED")}getAll(){const e={};for(const[n,s]of Object.entries(this))s instanceof W&&(e[n]=s);return e}onReadSafe(e){const n=t.getCurrentInstance();if(this.areReadSafe.value)e(n);else{const s=t.watch(this.areReadSafe,()=>{this.areReadSafe.value&&(e(n),s())})}}onWriteSafe(e){const n=t.getCurrentInstance();if(this.areWriteSafe.value)e(n);else{const s=t.watch(this.areWriteSafe,()=>{this.areWriteSafe.value&&(e(n),s())})}}}const p={style:{level:"minimal"},networks:[{name:"Ethereum Mainnet",displayName:"Ethereum",id:1,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/ethereum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.infura.io/v3/"},{name:"Ropsten",displayName:"Ropsten (Ethereum Testnet)",id:3,type:"testnet",icon:null,currency:{name:"Ropsten Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://ropsten.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://ropsten.infura.io/v3/"},{name:"Rinkeby",displayName:"Rinkeby (Ethereum Testnet)",id:4,type:"testnet",icon:null,currency:{name:"Rinkeby Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://rinkeby.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://rinkeby.infura.io/v3/"},{name:"G\xF6rli",displayName:"G\xF6rli (Ethereum Testnet)",id:5,type:"testnet",icon:null,currency:{name:"G\xF6rli Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://goerli.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://goerli.infura.io/v3/"},{name:"Optimism",id:10,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/optimism.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://optimistic.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.optimism.io/"},{name:"Cronos Mainnet Beta",displayName:"Cronos",id:25,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/cronos.svg",currency:{name:"Cronos",symbol:"CRO",decimals:18},contracts:null,explorer:{name:"Cronos Explorer",url:"https://cronos.org/explorer",standard:"EIP3091"},defaultRPC:"https://evm.cronos.org"},{name:"Telos EVM Mainnet",displayName:"Telos",id:40,type:"mainnet",icon:null,currency:{name:"Telos",symbol:"TLOS",decimals:18},contracts:null,explorer:{name:"Teloscan",url:"https://teloscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.telos.net/evm"},{name:"Binance Smart Chain Mainnet",displayName:"BSC",id:56,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/bsc.svg",currency:{name:"Binance Chain Native Token",symbol:"BNB",decimals:18},contracts:null,explorer:{name:"Bscscan",url:"https://bscscan.com/",standard:"EIP3091"},defaultRPC:"https://bsc-dataseed1.binance.org/"},{name:"Gnosis Chain",displayName:"Gnosis",id:100,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/gnosis.svg",currency:{name:"xDAI",symbol:"xDAI",decimals:18},contracts:null,explorer:{name:"Blockscout",url:"https://blockscout.com/xdai/mainnet/",standard:"EIP3091"},defaultRPC:"https://rpc.gnosischain.com"},{name:"Fuse Mainnet",displayName:"Fuse",id:122,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fuse.svg",currency:{name:"Fuse",symbol:"FUSE",decimals:18},contracts:null,explorer:{name:"Fuse Explorer",url:"https://explorer.fuse.io/",standard:"EIP3091"},defaultRPC:"https://rpc.fuse.io"},{name:"Huobi ECO Chain Mainnet",displayName:"HECO",id:128,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/heco.svg",currency:{name:"Huobi ECO Chain Native Token",symbol:"HT",decimals:18},contracts:null,explorer:{name:"Hecoinfo",url:"https://hecoinfo.com",standard:"EIP3091"},defaultRPC:"https://http-mainnet.hecochain.com"},{name:"Polygon Mainnet",displayName:"Polygon",id:137,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/polygon.svg",currency:{name:"MATIC",symbol:"MATIC",decimals:18},contracts:null,explorer:{name:"Polygonscan",url:"https://polygonscan.com/",standard:"EIP3091"},defaultRPC:"https://polygon-rpc.com/"},{name:"Fantom Opera",displayName:"Fantom",id:250,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fantom.svg",currency:{name:"Fantom",symbol:"FTM",decimals:18},contracts:null,explorer:{name:"Ftmscan",url:"https://ftmscan.com/",standard:"EIP3091"},defaultRPC:"https://rpc.ftm.tools"},{name:"Metis Andromeda Mainnet",displayName:"Metis",id:1088,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/metis.svg",currency:{name:"Metis",symbol:"METIS",decimals:18},contracts:null,explorer:{name:"Metis Explorer",url:"https://andromeda-explorer.metis.io",standard:"EIP3091"},defaultRPC:"https://andromeda.metis.io/?owner=1088"},{name:"Moonbeam",id:1284,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonbeam.svg",currency:{name:"Glimmer",symbol:"GLMR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonbeam.moonscan.io",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonbeam.network"},{name:"Moonriver",id:1285,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonriver.svg",currency:{name:"Moonriver",symbol:"MOVR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonriver.moonscan.io/",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonriver.moonbeam.network"},{name:"Klaytn Mainnet Cypress",displayName:"Klaytn",id:8217,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/klaytn.svg",currency:{name:"KLAY",symbol:"KLAY",decimals:18},contracts:null,explorer:{name:"Klaytnscope",url:"https://scope.klaytn.com",standard:"EIP3091"},defaultRPC:"https://public-node-api.klaytnapi.com/v1/cypress"},{name:"Hardhat",displayName:"Hardhat",id:31337,type:"testnet",icon:null,currency:{name:"GoChain Coin",symbol:"GO",decimals:18},contracts:null,explorer:null,defaultRPC:"http://127.0.0.1:8545/"},{name:"Arbitrum One",displayName:"Arbitrum",id:42161,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/arbitrum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Arbiscan",url:"https://arbiscan.io/",standard:"EIP3091"},defaultRPC:"https://arbitrum-mainnet.infura.io/v3/"},{name:"Celo Mainnet",displayName:"Celo",id:42220,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/celo.svg",currency:{name:"CELO",symbol:"CELO",decimals:18},contracts:null,explorer:{name:"Celo Explorer",url:"https://explorer.celo.org/",standard:"EIP3091"},defaultRPC:"https://forno.celo.org"},{name:"Emerald Paratime Mainnet",displayName:"Emerald",id:42262,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/emerald.svg",currency:{name:"Emerald Rose",symbol:"ROSE",decimals:18},contracts:null,explorer:{name:"Emerald Explorer",url:"https://explorer.emerald.oasis.dev/",standard:"EIP3091"},defaultRPC:"https://emerald.oasis.dev"},{name:"Avalanche C-Chain",displayName:"Avalanche",id:43114,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/avalanche.svg",currency:{name:"Avalanche",symbol:"AVAX",decimals:18},contracts:null,explorer:{name:"Snowtrace",url:"https://snowtrace.io/",standard:"EIP3091"},defaultRPC:"https://api.avax.network/ext/bc/C/rpc"},{name:"Aurora Mainnet",displayName:"Aurora",id:1313161554,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/aurora.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Aurorascan",url:"https://aurorascan.dev",standard:"EIP3091"},defaultRPC:"https://mainnet.aurora.dev"},{name:"Harmony Mainnet Shard 0",displayName:"Harmony",id:16666e5,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/harmony.svg",currency:{name:"ONE",symbol:"ONE",decimals:18},contracts:null,explorer:{name:"Harmony Block Explorer",url:"https://explorer.harmony.one",standard:"EIP3091"},defaultRPC:"https://api.harmony.one"}],wallets:[{id:"metamask",displayName:"Metamask",icon:null},{id:"binanceChain",displayName:"Binance Chain",icon:null},{id:"coinbase",displayName:"Coinbase",icon:null}],defaults:{networks:{icon:"https://static.tuli.pe/icons/networks/unknown.svg"},wallets:{icon:"TODO"}}};class vt{constructor(e=null){let n={};return e?n=y({...p.style},{...e}):n=p.style,window.addEventListener("load",()=>{const s=document.getElementsByClassName("ve-app");if(s)for(const a of s)a&&a.classList.add(`ve-${n.level}`)}),n}}class te{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=p.networks.find(i=>i.id===n.id),a=y({...s},{...n});a.available!==!1&&(a.available=!0),a.displayName||(a.displayName=a.name),this._list.push(a)}}for(const n of p.networks)this._list.find(a=>a.id===n.id)||(n.available=!1,this._list.push(n))}add(e){this._list.push(e)}async getCurrent(){if(r.provider.proxy.ethersInstance){const e=await r.provider.getNetwork().then(n=>n.chainId);return this.getById(e)}return null}getById(e){try{e=parseInt(e)}catch{throw"'id' given to getById() method must be an integer or any data type that can be parsed to interger."}return this._list.find(n=>n.id===parseInt(e))}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ee{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=p.wallets.find(i=>i.id===n.id),a=y({...s},{...n});a.available!==!1&&(a.available=!0),a.displayName||(a.displayName=a.id),this._list.push(a)}}for(const n of p.wallets)this._list.find(a=>a.id===n.id)||(n.available=!1,this._list.push(n))}async getCurrent(){if(r.signer.proxy.ethersInstance){const e=r.provider.connection.url;return this.getById(e)}return null}getById(e){return this._list.find(n=>n.id===e)}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ne{constructor(e=null){let n={};return e?n=y({...p.defaults},{...e}):n=p.defaults,n}}class Y{constructor(e=null){this.style=new vt(e?e.style:null),this.networks=new te(e?e.networks:null),this.wallets=new ee(e?e.wallets:null),this.defaults=new ne(e?e.defaults:null)}}class E{constructor(e=null,n=null,s=null){return this.proxy={_ethersInstance:e&&t.markRaw(e),get ethersInstance(){return this._ethersInstance},set ethersInstance(a){this._ethersInstance=a&&t.markRaw(a)},extensionInstance:n,placeholderInstance:s},new Proxy(this,{get:function(a,i,c){if(i==="proxy")return a.proxy;if(a.proxy.ethersInstance&&a.proxy.ethersInstance[i])return typeof a.proxy.ethersInstance[i]=="function"?a.proxy.ethersInstance[i].bind(a.proxy.ethersInstance):a.proxy.ethersInstance[i];if(a.proxy.ethersInstance&&a.proxy.extensionInstance&&a.proxy.extensionInstance[i])return typeof a.proxy.extensionInstance[i]=="function"?a.proxy.extensionInstance[i].bind(c):a.proxy.extensionInstance[i];if(a.proxy.placeholderInstance&&a.proxy.placeholderInstance[i])return typeof a.proxy.placeholderInstance[i]=="function"?a.proxy.placeholderInstance[i].bind(c):a.proxy.placeholderInstance[i]},set:function(a,i,c,d){if(a.proxy.ethersInstance&&a.proxy.ethersInstance[i])return a.proxy.ethersInstance[i]=c,!0;if(a.proxy.extensionInstance&&a.proxy.extensionInstance[i])return a.proxy.extensionInstance[i]=c,!0;if(a.proxy.placeholderInstance&&a.proxy.placeholderInstance[i])return a.proxy.placeholderInstance[i]=c,!0;throw"New properties cannot be set on TulipeProxy instances. Please define them in instances constructor firstly."}})}}class se{}class ae{constructor(){this.status=new _("provider",["DISCONNECTED","WRONG","ERROR","CONNECTED"]),this.isSafe=t.computed(()=>r.isSafe.value&&!this.status.isIn(["DISCONNECTED","ERROR"])),this.OnSafe=B}async _getProviderFromWebWallet(){for(const e of Object.values(r.wallets))if(e){const n=e.getProvider();if(n)return n}return null}async _initProviderConnection(){const e=await this._getProviderFromWebWallet();if(e)this.proxy.ethersInstance=new m.ethers.providers.Web3Provider(e,"any");else{const n=r.config.networks.getDefault();n&&n.defaultRPC&&(this.proxy.ethersInstance=new m.ethers.providers.JsonRpcProvider(n.defaultRPC))}}_initARS(){this.on("network",(e,n)=>{n&&n!==e&&window.location.reload()}),this.on("error",()=>{this.status.set("ERROR")})}async _asyncInit(){if(await this._initProviderConnection(),!this.proxy.ethersInstance)this.status.set("DISCONNECTED");else{const e=await this.getNetwork();let n=await r.config.networks.getById(e.chainId);if(n)this.status.set("CONNECTED");else if(this.status.set("WRONG"),n=r.config.networks.getAll().find(s=>s.id===e.id),!n){const s={name:e.name,displayName:P(e.name),id:e.chainId};console.log(s),r.config.networks.add(s)}n&&n.pollingInterval&&(this.pollingInterval=n.pollingInterval),this._initARS()}}async changeNetwork(e){const n=await r.config.wallets.getCurrent();n&&r.wallets[n.id].changeNetwork(e)}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}class z extends E{constructor(e,n=null,s=null,a=null){s=s||new se,a=a||new ae,super(n,s,a),this._asyncInit()}}class re{}class oe{constructor(){this.address=t.ref(null),this.status=new _("signer",["DISCONNECTED","REQUESTED","REFUSED","ERROR","NO_PROVIDER","WRONG_PROVIDER","CONNECTED"]),this.isSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("CONNECTED")),this.OnSafe=D}initARS(){r.provider.status.watchAny(e=>{e==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(e)&&this.status.set("NO_PROVIDER")}),this.status.watch(["REFUSED","ERROR"],()=>{setTimeout(()=>{this.status.set("DISCONNECTED")},5e3)})}async _asyncInit(){const e=this;r.provider.onSafe(async function(){for(const n of Object.values(r.wallets))await e.connectWallet(n,!0)}),this.initARS()}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}async connectWallet(e,n=!1){if(r.signer.status.is("DISCONNECTED"))try{const s=await r.provider.getSigner(),a=await s.getAddress();r.signer.proxy.ethersInstance=s,this.address.value=a,r.signer.status.set("CONNECTED")}catch{if(n===!0)r.signer.status.set("DISCONNECTED");else{this.status.set("REQUESTED");try{await e.connect(),this.status.set("CONNECTED")}catch(a){if(a instanceof w)this.status.set("REFUSED");else throw this.status.set("ERROR"),a}}}}disconnectWallet(){r.signer.proxy.ethersInstance=null,this.address.value=null,r.signer.status.set("DISCONNECTED")}}class K extends E{constructor(e,n=null,s=null,a=null){s=s||new re,a=a||new oe,super(n,s,a),this._asyncInit()}}class ie{_watch(e,n,s=null){return Object.keys(r.chainWatchers.contracts).includes(this.address)||r.chainWatchers.addContractWatcher(this),r.chainWatchers.contracts[this.address].add(e,n,s)}watch(e,n,s,a=null){const i=this._watch(e,n,s);return a?t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,i)},a):t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,i)}),r.chainWatchers.contracts[this.address].remove.bind(r.chainWatchers.contracts[this.address],e,n,i)}watchRef(e,n,s=null){const a=this._watch(e,n,null);return s?t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,a)},s):t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,a)}),r.chainWatchers.contracts[this.address].getRef(e,n)}}class le{constructor(e){this.name=e,this.status=new _(`contract:${e}`,["NO_PROVIDER","WRONG_PROVIDER","ERROR","INITIALIZED"]),this.isReadSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("INITIALIZED")),this.isWriteSafe=t.computed(()=>r.signer.isSafe.value&&this.status.is("INITIALIZED")),this.OnReadSafe=t.createVNode(V,{contract:this.name}),this.OnWriteSafe=t.createVNode(T,{contract:this.name})}onReadSafe(e){const n=t.getCurrentInstance();if(this.isReadSafe.value)e(n);else{const s=t.watch(this.isReadSafe,()=>{this.isReadSafe.value&&(e(n),s())})}}onWriteSafe(e){const n=t.getCurrentInstance();if(this.isWriteSafe.value)e(n);else{const s=t.watch(this.isWriteSafe,()=>{this.isWriteSafe.value&&(e(n),s())})}}_updateContract(e,n){if(r.signer.isSafe.value)this.proxy.ethersInstance=new m.ethers.Contract(e,n,r.signer.proxy.ethersInstance);else if(r.provider.isSafe.value)this.proxy.ethersInstance=new m.ethers.Contract(e,n,r.provider.proxy.ethersInstance);else throw`_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`}_initARS(e,n){r.provider.status.watchAny(s=>{s==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(s)&&this.status.set("NO_PROVIDER")}),t.watch([r.signer.isSafe],(s,a)=>{s!==a&&(this.proxy.ethersInstance=null,this._updateContract(e,n))})}async _asyncInit(){r.provider.onSafe(async function(){try{const e=await r.config.networks.getCurrent();if(e&&e.contracts&&Object.keys(e.contracts).includes(this.name)){const n=e.contracts[this.name];this._updateContract(n.address,n.abi),this._initARS(n.address,n.abi),this.status.set("INITIALIZED")}else this.status.set("WRONG_PROVIDER")}catch(e){throw this.status.set("ERROR"),e}}.bind(this))}}class W extends E{constructor(e,n=null,s=null,a=null){s=s||new ie,a=a||new le(e),super(n,s,a),this._asyncInit()}}class ce{}class de{constructor(e,n,s=[],a={value:0}){this.contractName=e,this.methodName=n,this.methodInfos={},this.args=t.ref(s),this.txArgs=t.ref(a),this.data=t.ref([]),this.error=t.ref(null),this.call=null,this.status=new _(`tx:${e}:${n}`,["NOT_READY","READY","SENT","ERROR","SUCCESS"])}initARS(){this.status.watch(["ERROR","SUCCESS"],()=>{setTimeout(()=>{this.status.set("READY")},3e3)})}_asyncInit(){r.contracts[this.contractName].isReadSafe.value&&this._initEthersInstance(),r.contracts[this.contractName].onReadSafe(()=>{this._initEthersInstance()}),this.initARS()}_initEthersInstance(){this.methodInfos=r.contracts[this.contractName].interface.functions[this.methodName],this.methodInfos.inputs.forEach(e=>this.args.value.push(null)),this.methodInfos.outputs.forEach(e=>this.data.value.push(null)),this.proxy.ethersInstance=r.contracts[this.contractName][this.methodName],this.status.set("READY")}send(e=null,n=null){e=e&&e.length>0?e:S(this.args),e?Array.isArray(e)?this.call=this.proxy.ethersInstance(...e,n):this.call=this.proxy.ethersInstance(e,n):this.call=this.proxy.ethersInstance(n),this.status.set("SENT"),this.methodInfos.constant?this.call.then(s=>{Array.isArray(s)||(s=[s]),f(this.data,s),f(this.error,null),this.status.set("SUCCESS")}).catch(s=>{f(this.error,s),this.status.set("ERROR")}):this.call.then(s=>s.wait()).then(s=>{Array.isArray(s)||(s=[s]),f(this.data,s),f(this.error,null),this.status.set("SUCCESS")}).catch(s=>{f(this.error,s),this.status.set("ERROR"),console.log(s)})}}class $ extends E{constructor(e,n,s=[],a={value:0},i=null,c=null,d=null){c=c||new ce,d=d||new de(e,n,s=[],a={value:0}),super(i,c,d),this._asyncInit()}}class Q{constructor(){this.contracts={},this.wallets={}}async _asyncInit(){r.provider.onSafe(()=>{r.provider.on("block",async function(e){const n=await r.provider.getBlockWithTransactions(e);for(const s of n.transactions)Object.keys(this.contracts).includes(s.to)?this.contracts[s.to].update():Object.keys(this.wallets).includes(s.to)&&this.wallets[s.to].update(),Object.keys(this.contracts).includes(s.from)?this.contracts[s.from].update():Object.keys(this.wallets).includes(s.from)&&this.wallets[s.from].update()})})}addContractWatcher(e){Object.keys(this.contracts).includes(e.address)||(this.contracts[e.address]=new X(e))}removeContractWatcher(e){Object.keys(this.contracts).includes(e.address)&&delete this.contracts[e.address]}addWalletWatcher(e){Object.keys(this.wallets).includes(e)||(this.wallets[e]=new v(e))}removeContractWatcher(e){Object.keys(this.wallets).includes(e)&&delete this.wallets[e]}}class J{constructor(){this.lastUpdateBlock=0,this.sources={}}_generateDependentUUID(){return"xxxxxxxx".replace(/[xy]/g,function(e){var n=Math.random()*16|0,s=e=="x"?n:n&3|8;return s.toString(16)})}async requiresUpdate(){if(!r.provider.isSafe.value)return!1;const e=await r.provider.getBlockNumber();return this.lastUpdateBlock<e}async updateLastUpdateBlock(){const e=await r.provider.getBlockNumber();this.lastUpdateBlock=e}async _update(){throw"_update() method not implemented in that ChainWatcher child class."}update(){this._update()}}class X extends J{constructor(e){super(),this.contract=e}_buildSourceName(e,n){return`${e}:${n?n.toString():""}`}async _updateState(e){e.args?e.state.value=await this.contract[e.name](...e.args):e.state.value=await this.contract[e.name]()}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){const a=this._buildSourceName(e,n);let i=!1;Object.keys(this.sources).includes(a)||(this.sources[a]={name:e,args:n,state:t.ref(null),dependents:{}},i=!0);let c=null;s&&(c=t.watch(this.sources[a].state,s));const d=this._generateDependentUUID();return this.sources[a].dependents[d]=c,i&&this._updateState(this.sources[a]),d}remove(e,n,s){const a=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(a)&&Object.keys(this.sources[a].dependents).includes(s)){const i=this.sources[a].dependents[s];i&&i(),delete this.sources[a].dependents[s]}Object.keys(this.sources[a].dependents).length===0&&delete this.sources[a]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class v extends J{constructor(e){super(),this.address=e,this.availableSources=["balance"]}async _updateState(e){e.name==="balance"&&(e.state.value=await r.provider.getBalance(this.address))}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))await this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){if(!this.availableSources.includes(e))throw`Sources added to a ChainWalletWatcher must be in ${this.availableSources}. Got ${e}`;const a=this._buildSourceName(e,n);newSource=!1,Object.keys(this.sources).includes(a)||(this.sources[a]={name:e,args:n,state:ref(null),dependents:{}},newSource=!0);let i=null;s&&(i=watch(this.sources[a].state,s));const c=this._generateDependentUUID();return this.sources[a].dependents[c]=i,newSource&&this._updateState(this.sources[a]),c}remove(e,n,s){const a=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(a)&&Object.keys(this.sources[a].dependents).includes(s)){const i=this.sources[a].dependents[s];i&&i(),delete this.sources[a].dependents[s]}Object.keys(this.sources[a].dependents).length===0&&delete this.sources[a]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class tt{constructor(){this.provider=null,this.id=""}getProvider(){return null}async connect(){throw`connect() method of ${this.id} wallet is not implemented.`}}class w extends Error{constructor(e,...n){super(e,...n),this.message=`${e} wallet has rejected the connection request.`}}class et extends tt{constructor(){super(),this.id="metamask",this.provider=this.getProvider()}getProvider(){return window.ethereum}async connect(){try{await this.provider.request({method:"eth_requestAccounts"})}catch(e){throw e.code===4001?w(this.id):e}}async addNetwork(e){const n=r.config.networks.getById(e);await window.ethereum.request({method:"wallet_addEthereumChain",params:[{chainId:e,rpcUrls:[n.defaultRPC],chainName:n.name,nativeCurrency:{name:n.currency.symbol,symbol:n.currency.symbol,decimals:n.currency.decimals},blockExplorerUrls:n.explorer&&n.explorer.url!==""?[n.explorer.url]:null}]})}async changeNetwork(e){if(r.config.networks.getById(e)){e=m.ethers.utils.hexlify(parseInt(e)).toString(),e=m.ethers.utils.hexValue(e);try{await window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:e}]})}catch(s){if(s.code===4902)this.addNetwork(e);else throw s}}}}class he extends tt{constructor(e,n={}){super(),this.id="coinbase";const s=n.appName||"",a=n.appLogoUrl,i=n.darkMode||!1;this.coinbaseWalletSdk=new e({appName:s,appLogoUrl:a,darkMode:i}),this.provider=this.getProvider()}getProvider(){try{return this.coinbaseWalletSdk.makeWeb3Provider()}catch(e){return console.log(e),null}}async connect(){try{await this.provider.send("eth_requestAccounts")}catch{throw w(this.id)}}}class ue extends et{constructor(){super(),this.id="binanceChain"}getProvider(){return window.BinanceChain}async connect(){super.connect.call(this)}}class nt{constructor(){const e=r.config.wallets.getAvailable();for(const n of e){const s=st[n.id];s&&(this[n.id]=new s)}}}const st={metamask:et,coinbase:he,binanceChain:ue};async function fe(o,e){const n=e;try{r.init(n)}catch(a){throw r&&r.status&&r.status.set("ERROR"),a}o.config.globalProperties.dapp=r,o.config.globalProperties.rGet=S,o.config.globalProperties.rSet=f,window.dapp=r;const s=await Promise.resolve().then(()=>Xt);o.component("OnDappSafe",s.OnDappSafe),o.component("OnProviderSafe",s.OnProviderSafe),o.component("OnSignerSafe",s.OnSignerSafe),o.component("OnContractsReadSafe",s.OnContractsReadSafe),o.component("OnContractsWriteSafe",s.OnContractsWriteSafe),o.component("OnContractReadSafe",s.OnContractReadSafe),o.component("OnContractWriteSafe",s.OnContractWriteSafe),r.status.set("INITIALIZED")}l.ChainWatchersList=Q,l.ConnectWalletButton=U,l.ContractInteractor=A,l.ContractWatcher=X,l.ContractsList=Z,l.DebugBar=H,l.EventInteractor=I,l.EventsInteractor=R,l.InputUnits=x,l.MethodInteractor=N,l.MethodsInteractor=C,l.OnContractReadSafe=V,l.OnContractWriteSafe=T,l.OnContractsReadSafe=F,l.OnContractsWriteSafe=G,l.OnDappSafe=b,l.OnProviderSafe=B,l.OnSignerSafe=D,l.SelectNetworkDropdown=j,l.SelectWalletDropdown=L,l.Status=_,l.Transact=O,l.TulipeConfig=Y,l.TulipeContract=W,l.TulipeProvider=z,l.TulipeProxy=E,l.TulipeSigner=K,l.TulipeTransaction=$,l.WalletConnectionRejected=w,l.WalletWatcher=v,l.WalletsList=nt,l.capitalizeWords=P,l.dapp=r,l.deepMerge=y,l.initTulipe=fe,l.isObject=g,l.rGet=S,l.rSet=f,l.styleLevelProp=k,l.wallets=st,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(c,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("ethers")):typeof define=="function"&&define.amd?define(["exports","vue","ethers"],t):(c=typeof globalThis<"u"?globalThis:c||self,t(c.Tulipe={},c.vue,c.ethers))})(this,function(c,t,y){"use strict";class nt{constructor(){const e=a.config.wallets.getAvailable();for(const n of e){const s=tt[n.id];s&&(this[n.id]=new s)}}}class st{constructor(){for(const e of a.config.networks.getAll())if(e.contracts)for(const n of Object.keys(e.contracts))this[n]=new A(n)}getAll(){const e={};for(const[n,s]of Object.entries(this))s instanceof A&&(e[n]=s);return e}}class at{constructor(){this.contracts={},this.wallets={}}async _asyncInit(){a.provider.onSafe(()=>{a.provider.on("block",async function(e){const n=await a.provider.getBlockWithTransactions(e);for(const s of n.transactions)Object.keys(this.contracts).includes(s.to)?this.contracts[s.to].update():Object.keys(this.wallets).includes(s.to)&&this.wallets[s.to].update(),Object.keys(this.contracts).includes(s.from)?this.contracts[s.from].update():Object.keys(this.wallets).includes(s.from)&&this.wallets[s.from].update()})})}addContractWatcher(e){Object.keys(this.contracts).includes(e.address)||(this.contracts[e.address]=new Q(e))}removeContractWatcher(e){Object.keys(this.contracts).includes(e.address)&&delete this.contracts[e.address]}addWalletWatcher(e){Object.keys(this.wallets).includes(e)||(this.wallets[e]=new J(e))}removeContractWatcher(e){Object.keys(this.wallets).includes(e)&&delete this.wallets[e]}}class rt{constructor(){}init(e=null){this.config=new z(e),this.status=new g("dapp",["UNSAFE","ERROR","INITIALIZED"]),this.isSafe=t.computed(()=>this.status.is("INITIALIZED")),this.OnSafe=B,this.chainWatchers=new at,this.wallets=new nt,this.provider=new K,this.pro=this.provider,this.signer=new Y,this.sig=this.signer,this.contracts=new st,this.con=this.contracts}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}const a=new rt;function E(o){return o&&typeof o=="object"&&!Array.isArray(o)}function _(o,...e){if(!e.length)return o;const n=e.shift();if(E(o)&&E(n))for(const s in n)E(n[s])?(o[s]||Object.assign(o,{[s]:{}}),_(o[s],n[s])):Object.assign(o,{[s]:n[s]});return _(o,...e)}function U(o){const e=o.split(" ");for(let n=0;n<e.length;n++)e[n]=e[n][0].toUpperCase()+e[n].substring(1);return e.join(" ")}function w(o){return t.isRef(o)?w(o.value):o}function p(o,e){t.isRef(o)?o.value=e:o=e}const me="",I={required:!1,type:String,default:"minimal",validator(o){return["unstylized","minimal","opinionated"].includes(o)}},ot={class:"ContractInteractor"},it=t.createTextVNode(" Methods : "),lt=t.createElementVNode("br",null,null,-1),ct=t.createTextVNode(" Events : "),dt=t.createElementVNode("br",null,null,-1),M={__name:"ContractInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];let s=t.ref("not owned");return a.contracts[e.contract].onReadSafe(async function(){try{s.value=await n.owner()}catch{}}),(r,i)=>{const l=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(l,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ot,[t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Address : "+t.toDisplayString(t.unref(n).address),1),t.createElementVNode("li",null,"Owner : "+t.toDisplayString(t.unref(s)),1),t.createElementVNode("li",null,[it,lt,t.createVNode(t.unref(C),{contract:e.contract},null,8,["contract"])]),t.createElementVNode("li",null,[ct,dt,t.createVNode(t.unref(R),{contract:e.contract},null,8,["contract"])])])])]),_:1},8,["contract"])}}},ht={class:"MethodsInteractor"},C={__name:"MethodsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];return(s,r)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ht,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.functions,(l,d)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(b),{contract:e.contract,method:d},null,8,["contract","method"])]))),256))])])]),_:1},8,["contract"])}}},ut={class:"MethodInteractor"},pt={key:0},ft=t.createElementVNode("p",null,"Inputs :",-1),mt=["onUpdate:modelValue","placeholder"],yt={key:0},_t={key:1},wt=t.createElementVNode("p",null,"Outputs :",-1),gt=["onUpdate:modelValue","placeholder"],St=["placeholder"],Et={key:2},b={__name:"MethodInteractor",props:{contract:{type:String,required:!0},method:{type:String,required:!0}},setup(o){const e=o,n=t.shallowRef(new W(e.contract,e.method));function s(r){return`${r.name&&r.name!=="null"?r.name:""} (${r.type})`}return(r,i)=>{const l=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(l,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",ut,[t.createVNode(t.unref(O),{contract:e.contract,method:e.method,modelValue:t.unref(n),"onUpdate:modelValue":i[0]||(i[0]=d=>t.isRef(n)?n.value=d:null),configs:{content:e.method,notx:!0,noerror:!0}},null,8,["contract","method","modelValue","configs"]),t.createElementVNode("small",null,t.toDisplayString(t.unref(n).methodInfos.stateMutability),1),Object.keys(t.unref(n).methodInfos.inputs).length>0||t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("div",pt,[ft,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.inputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":u=>t.unref(n).args.value[h]=u,type:"text",placeholder:s(d)},null,8,mt),[[t.vModelText,t.unref(n).args.value[h]]]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).args.value[h])+" "+t.toDisplayString(typeof t.unref(n).args.value[h]),1)]))),256)),t.unref(n).methodInfos.payable?(t.openBlock(),t.createElementBlock("li",yt,[t.createVNode(t.unref($),{modelValue:t.unref(n).txArgs.value.value,"onUpdate:modelValue":i[1]||(i[1]=d=>t.unref(n).txArgs.value.value=d)},null,8,["modelValue"]),t.createTextVNode(" "+t.toDisplayString(t.unref(n).txArgs.value.value)+" "+t.toDisplayString(typeof t.unref(n).txArgs.value.value),1)])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),Object.keys(t.unref(n).methodInfos.outputs).length>0?(t.openBlock(),t.createElementBlock("div",_t,[wt,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).methodInfos.outputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.unref(n).data.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:0,"onUpdate:modelValue":u=>t.unref(n).data.value[h]=u,type:"text",placeholder:s(d),disabled:""},null,8,gt)),[[t.vModelText,t.unref(n).data.value[h]]]):(t.openBlock(),t.createElementBlock("input",{key:1,type:"text",placeholder:s(d),disabled:""},null,8,St))]))),256))])])):t.createCommentVNode("",!0),t.unref(n).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",Et,t.toDisplayString(t.unref(n).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},kt={class:"EventsInteractor"},R={__name:"EventsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];return(s,r)=>{const i=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(i,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",kt,[t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n).interface.events,(l,d)=>(t.openBlock(),t.createElementBlock("li",null,[t.createVNode(t.unref(x),{contract:e.contract,event:d},null,8,["contract","event"])]))),256))])])]),_:1},8,["contract"])}}},Nt={class:"EventInteractor"},It=t.createTextVNode("Logs: "),x={__name:"EventInteractor",props:{contract:{type:String,required:!0},event:{type:String,required:!0}},setup(o){const e=o,n=a.contracts[e.contract];let s=t.ref({}),r=t.ref({}),i=t.ref(0),l=t.ref([]);return n.onReadSafe(()=>{s.value=n.interface.events[e.event],r.value=n.filters[s.value.name],n.on(r.value,d=>{i.value++;let h=`Block ${d.blockNumber} -> {`;for(const u of s.value.inputs)h+=`${u.name}:${d.args[u.name]}, `;h=h.substring(0,h.length-2)+"}",l.value.push(h)})}),(d,h)=>{const u=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(u,{contract:e.contract},{default:t.withCtx(()=>[t.createElementVNode("div",Nt,[t.createElementVNode("p",null,t.toDisplayString(t.unref(s).name),1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Count : "+t.toDisplayString(t.unref(i)),1),t.createElementVNode("li",null,[It,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(l),et=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(et),1))),256))])])])])]),_:1},8,["contract"])}}},Ct={class:"TransactButton"},bt={key:1,disabled:""},Rt={key:2,disabled:""},xt={key:3,disabled:""},Ot={key:4},O={__name:"Transact",props:{modelValue:{},contract:{type:String,required:!0},method:{type:String,required:!0},args:{type:Array,required:!1},txArgs:{type:Object,required:!1},configs:{type:Object,required:!1}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=a.contracts[n.contract];let r=t.computed({get(){return n.modelValue},set(l){e("update:modelValue",l)}});function i(){const l=n.args?n.args:[],d=n.txArgs?n.txArgs:{};r.value.send(l,d)}return n.config&&n.configs.notx&&s.onReadSafe(()=>{r=new W(n.contract,n.method)}),(l,d)=>{const h=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(h,{contract:n.contract},{default:t.withCtx(()=>[t.createElementVNode("div",Ct,[t.unref(r).status.is("READY")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:i},t.toDisplayString(n.configs&&n.configs.content?n.configs.content:"Transact"),1)):t.unref(r).status.is("SENT")?(t.openBlock(),t.createElementBlock("button",bt,"Transaction sent...")):t.unref(r).status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",Rt,"Transaction error!")):t.unref(r).status.is("SUCCESS")?(t.openBlock(),t.createElementBlock("button",xt,"Success !")):t.createCommentVNode("",!0),!(n.configs&&n.configs.noerror)&&t.unref(r).status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",Ot,t.toDisplayString(t.unref(r).error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},ye="",j=(o,e)=>{const n=o.__vccOpts||o;for(const[s,r]of e)n[s]=r;return n},L=j({__name:"ConnectWalletButton",props:{styleLevel:I},setup(o){const e=o;return(n,s)=>(t.openBlock(),t.createBlock(t.unref(a).provider.OnSafe,null,{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(["ConnectWalletButton",`ve-${e.styleLevel}`])},null,2)]),_:1}))}},[["__scopeId","data-v-a10b4efb"]]),Bt={class:"SelectWalletDropdown"},Dt={key:0},Vt=[t.createElementVNode("p",null,"Connection requested...",-1)],Tt={key:1},Pt=[t.createElementVNode("p",null,"Connection refused!",-1)],$t={key:2},At=[t.createElementVNode("p",null,"Select a wallet",-1)],Wt=["src","alt"],Ut=["onClick"],Mt=["src","alt"],F={__name:"SelectWalletDropdown",setup(o){let e=t.ref(null),n=t.ref([]),s=t.ref(!1),r=t.ref({});a.onSafe(async function(){n.value=a.config.wallets.getAvailable()}),a.provider.onSafe(async function(){r.value=await a.config.networks.getCurrent()}),a.signer.onSafe(async function(){e.value=await a.config.wallets.getCurrent(),console.log(e.value);try{n.value=a.config.wallets.getAvailable().filter(l=>l.id!==e.value.id)}catch{n.value=a.config.wallets.getAvailable()}});function i(){s.value=!s.value}return(l,d)=>{const h=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(h,null,{default:t.withCtx(()=>[t.createElementVNode("div",Bt,[t.createElementVNode("ul",null,[t.unref(a).signer.status.is("REQUESTED")?(t.openBlock(),t.createElementBlock("li",Dt,Vt)):t.unref(a).signer.status.is("REFUSED")?(t.openBlock(),t.createElementBlock("li",Tt,Pt)):t.unref(a).provider.status.is("WRONG_NETWORK")?(t.openBlock(),t.createElementBlock("li",$t,[t.createElementVNode("p",null,"Wrong network! ("+t.toDisplayString(t.unref(r)?t.unref(r).displayName:"unknown")+")",1)])):t.unref(a).signer.status.is("DISCONNECTED")||!t.unref(e)?(t.openBlock(),t.createElementBlock("li",{key:3,onClick:i},At)):t.unref(a).signer.status.is("CONNECTED")?(t.openBlock(),t.createElementBlock("li",{key:4,onClick:i},[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(a).config.defaults.wallets.icon,alt:t.unref(e).displayName+" logo"},null,8,Wt),t.createElementVNode("p",null,t.toDisplayString(t.unref(e).displayName),1)])):t.createCommentVNode("",!0),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:5},t.renderList(t.unref(n),u=>(t.openBlock(),t.createElementBlock("li",{key:u.id,onClick:et=>t.unref(a).signer.connectWallet(u.id)},[t.createElementVNode("img",{width:"40",src:u.icon?u.icon:t.unref(a).config.defaults.wallets.icon,alt:u.displayName+" logo"},null,8,Mt),t.createElementVNode("p",null,t.toDisplayString(u.displayName),1)],8,Ut))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},jt={class:"SelectNetworkDropdown"},Lt={key:0},Ft=["src","alt"],qt={key:1},Gt=[t.createElementVNode("p",null,"Select a network",-1)],Ht=["onClick"],zt=["src","alt"],q={__name:"SelectNetworkDropdown",setup(o){let e=t.ref({}),n=t.ref([]),s=t.ref(!1);a.onSafe(async function(){n.value=a.config.networks.getAvailable()}),a.provider.onSafe(async function(){e.value=await a.config.networks.getCurrent(),n.value=a.config.networks.getAvailable().filter(i=>i.id!==e.value.id)});function r(){s.value=!s.value}return(i,l)=>{const d=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(d,null,{default:t.withCtx(()=>[t.createElementVNode("div",jt,[t.createElementVNode("ul",{onClick:r},[t.unref(e)?(t.openBlock(),t.createElementBlock("li",Lt,[t.createElementVNode("img",{width:"40",src:t.unref(e).icon?t.unref(e).icon:t.unref(a).config.defaults.networks.icon,alt:t.unref(e).displayName+" logo"},null,8,Ft),t.createElementVNode("p",null,t.toDisplayString(t.unref(e).displayName),1)])):(t.openBlock(),t.createElementBlock("li",qt,Gt)),t.unref(s)?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:2},t.renderList(t.unref(n),h=>(t.openBlock(),t.createElementBlock("li",{key:h.id,onClick:u=>t.unref(a).provider.changeNetwork(h.id)},[t.createElementVNode("img",{width:"40",src:h.icon?h.icon:t.unref(a).config.defaults.networks.icon,alt:h.displayName+" logo"},null,8,zt),t.createElementVNode("p",null,t.toDisplayString(h.displayName),1)],8,Ht))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},B={__name:"OnDappSafe",setup(o){return(e,n)=>t.unref(a).isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},D={__name:"OnProviderSafe",setup(o){return(e,n)=>t.unref(a).provider.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},V={__name:"OnSignerSafe",setup(o){return(e,n)=>t.unref(a).signer.isSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(e.$slots,"default"),t.renderSlot(e.$slots,"safe")],64)):t.renderSlot(e.$slots,"unsafe",{key:1})}},T={__name:"OnContractReadSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(a).contracts[e.contract].isReadSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},P={__name:"OnContractWriteSafe",props:{contract:{type:String,required:!0}},setup(o){const e=o;return(n,s)=>t.unref(a).contracts[e.contract].isWriteSafe.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(n.$slots,"default"),t.renderSlot(n.$slots,"safe")],64)):t.renderSlot(n.$slots,"unsafe",{key:1})}},ke="",G=o=>(t.pushScopeId("data-v-a24ac687"),o=o(),t.popScopeId(),o),Kt=G(()=>t.createElementVNode("h3",null,"Safe Runners",-1)),Yt=G(()=>t.createElementVNode("h3",null,"Status",-1)),H=j({__name:"DebugBar",setup(o){return(e,n)=>{const s=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(s,null,{default:t.withCtx(()=>[t.createElementVNode("section",null,[t.createElementVNode("div",null,[Kt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"DApp safe : "+t.toDisplayString(t.unref(a).isSafe),1),t.createElementVNode("li",null,"Provider safe : "+t.toDisplayString(t.unref(a).provider.isSafe),1),t.createElementVNode("li",null,"Signer safe : "+t.toDisplayString(t.unref(a).signer.isSafe),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(a).contracts.getAll(),(r,i)=>(t.openBlock(),t.createElementBlock("li",null,[t.createTextVNode(" contract "+t.toDisplayString(i)+" : ",1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"read safe : "+t.toDisplayString(r.isReadSafe),1),t.createElementVNode("li",null,"write safe : "+t.toDisplayString(r.isWriteSafe),1)])]))),256))])]),t.createElementVNode("div",null,[Yt,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"dapp : "+t.toDisplayString(t.unref(a).status.get()),1),t.createElementVNode("li",null,"provider : "+t.toDisplayString(t.unref(a).provider.status.get()),1),t.createElementVNode("li",null,"signer : "+t.toDisplayString(t.unref(a).signer.status.get()),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(a).contracts.getAll(),(r,i)=>(t.openBlock(),t.createElementBlock("li",null," contract "+t.toDisplayString(i)+" : "+t.toDisplayString(r.status.get()),1))),256))])])])]),_:1})}}},[["__scopeId","data-v-a24ac687"]]),Zt={class:"InputUnits"},Qt=["placeholder"],Jt=["value"],$={__name:"InputUnits",props:{modelValue:{},placeholder:{type:String}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o;let s=t.ref(null);const r=["wei","gwei","ether"];let i=t.ref("wei");function l(){if(s.value){const d=y.ethers.utils.parseUnits(s.value,i.value);e("update:modelValue",d)}}return(d,h)=>(t.openBlock(),t.createElementBlock("div",Zt,[t.withDirectives(t.createElementVNode("input",{onInput:l,"onUpdate:modelValue":h[0]||(h[0]=u=>t.isRef(s)?s.value=u:s=u),type:"text",placeholder:t.unref(n).placeholder},null,40,Qt),[[t.vModelText,t.unref(s)]]),t.withDirectives(t.createElementVNode("select",{onChange:l,"onUpdate:modelValue":h[1]||(h[1]=u=>t.isRef(i)?i.value=u:i=u)},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(r,u=>t.createElementVNode("option",{value:u},t.toDisplayString(u),9,Jt)),64))],544),[[t.vModelSelect,t.unref(i)]])]))}},Xt=Object.freeze(Object.defineProperty({__proto__:null,InputUnits:$,styleLevelProp:I,ContractInteractor:M,MethodsInteractor:C,MethodInteractor:b,EventsInteractor:R,EventInteractor:x,Transact:O,ConnectWalletButton:L,SelectWalletDropdown:F,SelectNetworkDropdown:q,OnDappSafe:B,OnProviderSafe:D,OnSignerSafe:V,OnContractReadSafe:T,OnContractWriteSafe:P,DebugBar:H},Symbol.toStringTag,{value:"Module"}));class g{constructor(e,n){if(this._name=e,this.states=[],!Array.isArray(n))throw`The 'states' parameter of a Status instance '${e}' must an array of strings. Got: ${n}`;for(const s of n)this.states.push(this._formatState(s));this._state=t.ref(this.states[0])}_formatState(e){return e.toString().toUpperCase()}_isStateValid(e){return!!this.states.includes(this._formatState(e))}_areStatesValid(e){for(const n of e)if(!this._isStateValid(n))return!1;return!0}get(){return w(this._state)}getRef(){return this._state}set(e){if(e=this._formatState(e),!this._isStateValid(e))throw`The state given to the set() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;p(this._state,e),console.log(`Status '${this._name}' set to '${w(this._state)}'`)}is(e){if(!this._isStateValid(e))throw`The state given to the is() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${e}`;return this.get()==this._formatState(e)}isIn(e){if(!this._areStatesValid(e))throw`The states given to the isIn() method of Status instance '${this._name}' must be an array with values in ${this.states}. Got: ${e}`;for(const n of e)if(this.is(n))return!0;return!1}watch(e,n){let s=`The states given to the watch() method of Status instance '${this._name}' must be a string or an array with values in ${this.states}. Got: ${e}`;if(Array.isArray(e)){if(!this._areStatesValid(e))throw s;return t.watch(this._state,()=>{this.isIn(e)&&n(this.get())})}else{if(!this._isStateValid(e))throw s;return t.watch(this._state,()=>{this.is(e)&&n(this.get())})}}watchAny(e){return this.watch(this.states,e)}}const f={style:{level:"minimal"},networks:[{name:"Ethereum Mainnet",displayName:"Ethereum",id:1,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/ethereum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.infura.io/v3/"},{name:"Ropsten",displayName:"Ropsten (Ethereum Testnet)",id:3,type:"testnet",icon:null,currency:{name:"Ropsten Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://ropsten.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://ropsten.infura.io/v3/"},{name:"Rinkeby",displayName:"Rinkeby (Ethereum Testnet)",id:4,type:"testnet",icon:null,currency:{name:"Rinkeby Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://rinkeby.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://rinkeby.infura.io/v3/"},{name:"G\xF6rli",displayName:"G\xF6rli (Ethereum Testnet)",id:5,type:"testnet",icon:null,currency:{name:"G\xF6rli Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://goerli.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://goerli.infura.io/v3/"},{name:"Optimism",id:10,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/optimism.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Etherscan",url:"https://optimistic.etherscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.optimism.io/"},{name:"Cronos Mainnet Beta",displayName:"Cronos",id:25,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/cronos.svg",currency:{name:"Cronos",symbol:"CRO",decimals:18},contracts:null,explorer:{name:"Cronos Explorer",url:"https://cronos.org/explorer",standard:"EIP3091"},defaultRPC:"https://evm.cronos.org"},{name:"Telos EVM Mainnet",displayName:"Telos",id:40,type:"mainnet",icon:null,currency:{name:"Telos",symbol:"TLOS",decimals:18},contracts:null,explorer:{name:"Teloscan",url:"https://teloscan.io/",standard:"EIP3091"},defaultRPC:"https://mainnet.telos.net/evm"},{name:"Binance Smart Chain Mainnet",displayName:"BSC",id:56,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/bsc.svg",currency:{name:"Binance Chain Native Token",symbol:"BNB",decimals:18},contracts:null,explorer:{name:"Bscscan",url:"https://bscscan.com/",standard:"EIP3091"},defaultRPC:"https://bsc-dataseed1.binance.org/"},{name:"Gnosis Chain",displayName:"Gnosis",id:100,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/gnosis.svg",currency:{name:"xDAI",symbol:"xDAI",decimals:18},contracts:null,explorer:{name:"Blockscout",url:"https://blockscout.com/xdai/mainnet/",standard:"EIP3091"},defaultRPC:"https://rpc.gnosischain.com"},{name:"Fuse Mainnet",displayName:"Fuse",id:122,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fuse.svg",currency:{name:"Fuse",symbol:"FUSE",decimals:18},contracts:null,explorer:{name:"Fuse Explorer",url:"https://explorer.fuse.io/",standard:"EIP3091"},defaultRPC:"https://rpc.fuse.io"},{name:"Huobi ECO Chain Mainnet",displayName:"HECO",id:128,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/heco.svg",currency:{name:"Huobi ECO Chain Native Token",symbol:"HT",decimals:18},contracts:null,explorer:{name:"Hecoinfo",url:"https://hecoinfo.com",standard:"EIP3091"},defaultRPC:"https://http-mainnet.hecochain.com"},{name:"Polygon Mainnet",displayName:"Polygon",id:137,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/polygon.svg",currency:{name:"MATIC",symbol:"MATIC",decimals:18},contracts:null,explorer:{name:"Polygonscan",url:"https://polygonscan.com/",standard:"EIP3091"},defaultRPC:"https://polygon-rpc.com/"},{name:"Fantom Opera",displayName:"Fantom",id:250,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/fantom.svg",currency:{name:"Fantom",symbol:"FTM",decimals:18},contracts:null,explorer:{name:"Ftmscan",url:"https://ftmscan.com/",standard:"EIP3091"},defaultRPC:"https://rpc.ftm.tools"},{name:"Metis Andromeda Mainnet",displayName:"Metis",id:1088,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/metis.svg",currency:{name:"Metis",symbol:"METIS",decimals:18},contracts:null,explorer:{name:"Metis Explorer",url:"https://andromeda-explorer.metis.io",standard:"EIP3091"},defaultRPC:"https://andromeda.metis.io/?owner=1088"},{name:"Moonbeam",id:1284,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonbeam.svg",currency:{name:"Glimmer",symbol:"GLMR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonbeam.moonscan.io",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonbeam.network"},{name:"Moonriver",id:1285,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/moonriver.svg",currency:{name:"Moonriver",symbol:"MOVR",decimals:18},contracts:null,explorer:{name:"Moonscan",url:"https://moonriver.moonscan.io/",standard:"EIP3091"},defaultRPC:"https://rpc.api.moonriver.moonbeam.network"},{name:"Klaytn Mainnet Cypress",displayName:"Klaytn",id:8217,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/klaytn.svg",currency:{name:"KLAY",symbol:"KLAY",decimals:18},contracts:null,explorer:{name:"Klaytnscope",url:"https://scope.klaytn.com",standard:"EIP3091"},defaultRPC:"https://public-node-api.klaytnapi.com/v1/cypress"},{name:"Hardhat",displayName:"Hardhat",id:31337,type:"testnet",icon:null,currency:{name:"GoChain Coin",symbol:"GO",decimals:18},contracts:null,explorer:null,defaultRPC:"http://127.0.0.1:8545/"},{name:"Arbitrum One",displayName:"Arbitrum",id:42161,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/arbitrum.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Arbiscan",url:"https://arbiscan.io/",standard:"EIP3091"},defaultRPC:"https://arbitrum-mainnet.infura.io/v3/"},{name:"Celo Mainnet",displayName:"Celo",id:42220,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/celo.svg",currency:{name:"CELO",symbol:"CELO",decimals:18},contracts:null,explorer:{name:"Celo Explorer",url:"https://explorer.celo.org/",standard:"EIP3091"},defaultRPC:"https://forno.celo.org"},{name:"Emerald Paratime Mainnet",displayName:"Emerald",id:42262,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/emerald.svg",currency:{name:"Emerald Rose",symbol:"ROSE",decimals:18},contracts:null,explorer:{name:"Emerald Explorer",url:"https://explorer.emerald.oasis.dev/",standard:"EIP3091"},defaultRPC:"https://emerald.oasis.dev"},{name:"Avalanche C-Chain",displayName:"Avalanche",id:43114,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/avalanche.svg",currency:{name:"Avalanche",symbol:"AVAX",decimals:18},contracts:null,explorer:{name:"Snowtrace",url:"https://snowtrace.io/",standard:"EIP3091"},defaultRPC:"https://api.avax.network/ext/bc/C/rpc"},{name:"Aurora Mainnet",displayName:"Aurora",id:1313161554,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/aurora.svg",currency:{name:"Ether",symbol:"ETH",decimals:18},contracts:null,explorer:{name:"Aurorascan",url:"https://aurorascan.dev",standard:"EIP3091"},defaultRPC:"https://mainnet.aurora.dev"},{name:"Harmony Mainnet Shard 0",displayName:"Harmony",id:16666e5,type:"mainnet",icon:"https://static.tuli.pe/icons/networks/harmony.svg",currency:{name:"ONE",symbol:"ONE",decimals:18},contracts:null,explorer:{name:"Harmony Block Explorer",url:"https://explorer.harmony.one",standard:"EIP3091"},defaultRPC:"https://api.harmony.one"}],wallets:[{id:"metamask",displayName:"Metamask",icon:null},{id:"binanceChain",displayName:"Binance Chain",icon:null},{id:"coinbase",displayName:"Coinbase",icon:null}],defaults:{networks:{icon:"https://static.tuli.pe/icons/networks/unknown.svg"},wallets:{icon:"TODO"}}};class vt{constructor(e=null){let n={};return e?n=_({...f.style},{...e}):n=f.style,window.addEventListener("load",()=>{const s=document.getElementsByClassName("ve-app");if(s)for(const r of s)r&&r.classList.add(`ve-${n.level}`)}),n}}class te{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=f.networks.find(i=>i.id===n.id),r=_({...s},{...n});r.available!==!1&&(r.available=!0),r.displayName||(r.displayName=r.name),this._list.push(r)}}for(const n of f.networks)this._list.find(r=>r.id===n.id)||(n.available=!1,this._list.push(n))}add(e){this._list.push(e)}async getCurrent(){if(a.provider.proxy.ethersInstance){const e=await a.provider.getNetwork().then(n=>n.chainId);return this.getById(e)}return null}getById(e){try{e=parseInt(e)}catch{throw"'id' given to getById() method must be an integer or any data type that can be parsed to interger."}return this._list.find(n=>n.id===parseInt(e))}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ee{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.id){const s=f.wallets.find(i=>i.id===n.id),r=_({...s},{...n});r.available!==!1&&(r.available=!0),r.displayName||(r.displayName=r.id),this._list.push(r)}}for(const n of f.wallets)this._list.find(r=>r.id===n.id)||(n.available=!1,this._list.push(n))}getCurrent(){return console.log("GET CURRENT, id = "+a.signer.id),a.signer.proxy.ethersInstance?this.getById(a.signer.id):null}getById(e){return this._list.find(n=>n.id===e)}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class ne{constructor(e=null){let n={};return e?n=_({...f.defaults},{...e}):n=f.defaults,n}}class z{constructor(e=null){this.style=new vt(e?e.style:null),this.networks=new te(e?e.networks:null),this.wallets=new ee(e?e.wallets:null),this.defaults=new ne(e?e.defaults:null)}}class S{constructor(e=null,n=null,s=null){const r=new Proxy(this,{get:function(i,l,d){if(l==="proxy")return i.proxy;if(i.proxy.ethersInstance&&i.proxy.ethersInstance[l]!==void 0)return typeof i.proxy.ethersInstance[l]=="function"?i.proxy.ethersInstance[l].bind(i.proxy.ethersInstance):i.proxy.ethersInstance[l];if(i.proxy.ethersInstance&&i.proxy.extensionInstance&&i.proxy.extensionInstance[l]!==void 0)return typeof i.proxy.extensionInstance[l]=="function"?i.proxy.extensionInstance[l].bind(d):i.proxy.extensionInstance[l];if(i.proxy.placeholderInstance&&i.proxy.placeholderInstance[l]!==void 0)return typeof i.proxy.placeholderInstance[l]=="function"?i.proxy.placeholderInstance[l].bind(d):i.proxy.placeholderInstance[l]},set:function(i,l,d,h){if(i.proxy.ethersInstance&&i.proxy.ethersInstance[l]!==void 0)return i.proxy.ethersInstance[l]=d,!0;if(i.proxy.extensionInstance&&i.proxy.extensionInstance[l]!==void 0)return i.proxy.extensionInstance[l]=d,!0;if(i.proxy.placeholderInstance&&i.proxy.placeholderInstance[l]!==void 0)return i.proxy.placeholderInstance[l]=d,!0;throw console.log(i.proxy.placeholderInstance),console.log(i.proxy.placeholderInstance[l]),`New properties cannot be set on TulipeProxy instances. Please define '${l}' in constructor firstly.`}});return this.proxy={_initIsRunning:!1,_ethersInstance:null,get ethersInstance(){return this._ethersInstance},set ethersInstance(i){this.placeholderInstance._ars.oldEthersInstance={...this._ethersInstance},this._ethersInstance=i&&t.markRaw(i),this._initIsRunning||r._asyncInit()},extensionInstance:n,placeholderInstance:s},this.proxy.ethersInstance=e,r}}class se{}class k{constructor(){this._ars={}}_purgeARS(){if(this._ars.unwatchers)for(const e of this._ars.unwatchers)e();if(this._ars.unwatchers=[],this._ars.oldEthersInstance&&this._ars.events)for(const[e,n]of Object.entries(this._ars.events))this._ars.oldEthersInstance.off(e,n)}_initEthersInstanceARS(){}_initPlaceholderInstanceARS(){}_initARS(){this._purgeARS(),this.proxy.ethersInstance&&this._initEthersInstanceARS(),this._initPlaceholderInstanceARS()}onSafe(e){const n=t.getCurrentInstance();if(this.isSafe.value)e(n);else{const s=t.watch(this.isSafe,()=>{this.isSafe.value&&(e(n),s())})}}}class ae extends k{constructor(){super(),this.status=new g("provider",["DISCONNECTED","ERROR","WRONG_NETWORK","CONNECTED"]),this.isSafe=t.computed(()=>a.isSafe.value&&!this.status.isIn(["DISCONNECTED","ERROR"])),this.OnSafe=D}_autoInstantiateFromWallet(){for(const e of Object.values(a.wallets))e&&e.provider&&(this.proxy.ethersInstance=e.provider)}_autoInstantiateFromDefaultConfig(){const e=a.config.networks.getDefault();e&&e.defaultRPC&&(this.proxy.ethersInstance=new y.ethers.providers.JsonRpcProvider(e.defaultRPC))}_autoInstantiate(){this._autoInstantiateFromWallet(),this.proxy.ethersInstance||this._autoInstantiateFromDefaultConfig()}_initARS(){this.on("network",(e,n)=>{n&&n!==e&&window.location.reload()})}async _checkNetwork(){if(!this.proxy.ethersInstance)throw"<TulipeProviderProxy instance>._checkNetwork() method must not be called if the ethersInstance is null (if not connected to any network).";const e=await this.getNetwork();let n=await a.config.networks.getById(e.chainId);if(n)this.status.set("CONNECTED");else if(this.status.set("WRONG_NETWORK"),n=a.config.networks.getAll().find(s=>s.id===e.id),!n){const s={name:e.name,displayName:U(e.name),id:e.chainId};console.log(s),a.config.networks.add(s)}}async _setNetworkSettings(){const e=await this.getNetwork();let n=await a.config.networks.getById(e.chainId);n&&n&&n.pollingInterval&&(this.pollingInterval=n.pollingInterval)}async _asyncInit(){this.proxy._initIsRunning=!0,this.proxy.ethersInstance||this._autoInstantiate(),this.proxy.ethersInstance?(await this._checkNetwork(),await this._setNetworkSettings(),this._initARS()):this.status.set("DISCONNECTED"),this.proxy._initIsRunning=!1}async changeNetwork(e){const n=await a.config.wallets.getCurrent();n&&a.wallets[n.id].changeNetwork(e)}}class K extends S{constructor(e=null,n=null,s=null){super(e,n||new se,s||new ae),this._asyncInit()}}class re{}class oe extends k{constructor(){super(),this.id=null,this.address=t.ref(null),this.status=new g("signer",["NO_PROVIDER","DISCONNECTED","REQUESTED","REFUSED","ERROR","WRONG_NETWORK","CONNECTED"]),this.isSafe=t.computed(()=>a.provider.isSafe.value&&this.status.is("CONNECTED")),this.OnSafe=V}_initEthersInstanceARS(){}_initPlaceholderInstanceARS(){a.provider.status.watchAny(e=>{e==="WRONG_NETWORK"?this.status.set("WRONG_NETWORK"):["DISCONNECTED","ERROR"].includes(e)&&this.status.set("NO_PROVIDER")}),this.status.watch(["REFUSED","ERROR"],()=>{setTimeout(()=>{this.status.set("DISCONNECTED")},5e3)})}async _autoInstantiate(){console.log(a.wallets);for(const e of Object.keys(a.wallets))if(a.wallets[e].lazyConnectAvailable&&(await this.connectWallet(e,!0),this.proxy.ethersInstance))break}async _asyncInit(){this.proxy._initIsRunning=!0,a.provider.onSafe(async function(){this.proxy.ethersInstance||await this._autoInstantiate(),this.proxy.ethersInstance||this.status.set("DISCONNECTED"),this._initARS(),this.proxy._initIsRunning=!1}.bind(this))}async _setSignerDatas(e){const n=await e.getSigner(),s=await n.getAddress();this.address.value=s,a.signer.proxy.ethersInstance=n,this.id=e.id,a.signer.status.set("CONNECTED")}async connectWallet(e,n=!1){console.log("CONNECT lazy = "+n);const s=a.wallets[e];if(s.lazyConnectAvailable){if(await s.connect(!0),await s.isConnected())await this._setSignerDatas(s);else if(n){a.signer.status.set("DISCONNECTED");return}}try{this.status.set("REQUESTED"),await s.connect(!1),await this._setSignerDatas(s)}catch(r){if(r instanceof N)this.status.set("REFUSED");else throw this.status.set("ERROR"),r}}disconnectWallet(){a.signer.proxy.ethersInstance=null,this.address.value=null,a.signer.status.set("DISCONNECTED")}}class Y extends S{constructor(e=null,n=null,s=null){super(e,n||new re,s||new oe),this._asyncInit()}}class ie{_watch(e,n,s=null){return Object.keys(a.chainWatchers.contracts).includes(this.address)||a.chainWatchers.addContractWatcher(this),a.chainWatchers.contracts[this.address].add(e,n,s)}watch(e,n,s,r=null){const i=this._watch(e,n,s);return r?t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,i)},r):t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,i)}),a.chainWatchers.contracts[this.address].remove.bind(a.chainWatchers.contracts[this.address],e,n,i)}watchRef(e,n,s=null){const r=this._watch(e,n,null);return s?t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,r)},s):t.onUnmounted(()=>{a.chainWatchers.contracts[this.address].remove(e,n,r)}),a.chainWatchers.contracts[this.address].getRef(e,n)}}class le extends k{constructor(){super(),this.name="TODO",this.status=new g(`contract:${name}`,["NO_PROVIDER","UNAVAILABLE","ERROR","INITIALIZED"]),this.isReadSafe=t.computed(()=>a.provider.isSafe.value&&this.status.is("INITIALIZED")),this.isWriteSafe=t.computed(()=>a.signer.isSafe.value&&this.status.is("INITIALIZED")),this.OnReadSafe=t.createVNode(T,{contract:this.name}),this.OnWriteSafe=t.createVNode(P,{contract:this.name})}onSafe(e){throw"TulipeContract instances don't have 'onSafe()' method, use 'onReadSafe()' and 'onWriteSafe()' instead."}onReadSafe(e){const n=t.getCurrentInstance();if(this.isReadSafe.value)e(n);else{const s=t.watch(this.isReadSafe,()=>{this.isReadSafe.value&&(e(n),s())})}}onWriteSafe(e){const n=t.getCurrentInstance();if(this.isWriteSafe.value)e(n);else{const s=t.watch(this.isWriteSafe,()=>{this.isWriteSafe.value&&(e(n),s())})}}_updateContract(e,n){if(a.signer.isSafe.value)this.proxy.ethersInstance=new y.ethers.Contract(e,n,a.signer.proxy.ethersInstance);else if(a.provider.isSafe.value)this.proxy.ethersInstance=new y.ethers.Contract(e,n,a.provider.proxy.ethersInstance);else throw`_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`}_initARS(e,n){this._purgeARS(),this._ars.unwatchers.push(a.provider.status.watchAny(s=>{s==="WRONG_NETWORK"?this.status.set("UNAVAILABLE"):["DISCONNECTED","ERROR"].includes(s)&&this.status.set("NO_PROVIDER")})),this._ars.unwatchers.push(t.watch([a.signer.isSafe],(s,r)=>{s!==r&&(this.proxy.ethersInstance=null,this._updateContract(e,n))}))}async _asyncInit(){this.proxy._initIsRunning=!0,a.provider.onSafe(async function(){this.proxy.ethersInstance?this._initARS():this.status.set("UNAVAILABLE"),this.proxy._initIsRunning=!1}.bind(this))}}class A extends S{constructor(e,n=null,s=null,r=null){super(n,s||new ie,r||new le(e)),this._asyncInit()}}class ce{}class de extends k{constructor(e,n,s=[],r={value:0}){super(),this.contractName=e,this.methodName=n,this.methodInfos={},this.args=t.ref(s),this.txArgs=t.ref(r),this.data=t.ref([]),this.error=t.ref(null),this.call=null,this.status=new g(`tx:${e}:${n}`,["NOT_READY","READY","SENT","ERROR","SUCCESS"])}initARS(){this.status.watch(["ERROR","SUCCESS"],()=>{setTimeout(()=>{this.status.set("READY")},3e3)})}_asyncInit(){this.proxy._initIsRunning=!0,a.contracts[this.contractName].isReadSafe.value&&this._initEthersInstance(),a.contracts[this.contractName].onReadSafe(()=>{this._initEthersInstance()}),this.initARS(),this.proxy._initIsRunning=!1}_initEthersInstance(){this.methodInfos=a.contracts[this.contractName].interface.functions[this.methodName],this.methodInfos.inputs.forEach(e=>this.args.value.push(null)),this.methodInfos.outputs.forEach(e=>this.data.value.push(null)),this.proxy.ethersInstance=a.contracts[this.contractName][this.methodName],this.status.set("READY")}send(e=null,n=null){e=e&&e.length>0?e:w(this.args),e?Array.isArray(e)?this.call=this.proxy.ethersInstance(...e,n):this.call=this.proxy.ethersInstance(e,n):this.call=this.proxy.ethersInstance(n),this.status.set("SENT"),this.methodInfos.constant?this.call.then(s=>{Array.isArray(s)||(s=[s]),p(this.data,s),p(this.error,null),this.status.set("SUCCESS")}).catch(s=>{p(this.error,s),this.status.set("ERROR")}):this.call.then(s=>s.wait()).then(s=>{Array.isArray(s)||(s=[s]),p(this.data,s),p(this.error,null),this.status.set("SUCCESS")}).catch(s=>{p(this.error,s),this.status.set("ERROR"),console.log(s)})}}class W extends S{constructor(e,n,s=[],r={value:0},i=null,l=null,d=null){super(i,l||new ce,d||new de(e,n,s=[],r={value:0})),this._asyncInit()}}class Z{constructor(){this.lastUpdateBlock=0,this.sources={}}_generateDependentUUID(){return"xxxxxxxx".replace(/[xy]/g,function(e){var n=Math.random()*16|0,s=e=="x"?n:n&3|8;return s.toString(16)})}async requiresUpdate(){if(!a.provider.isSafe.value)return!1;const e=await a.provider.getBlockNumber();return this.lastUpdateBlock<e}async updateLastUpdateBlock(){const e=await a.provider.getBlockNumber();this.lastUpdateBlock=e}async _update(){throw"_update() method not implemented in that ChainWatcher child class."}update(){this._update()}}class Q extends Z{constructor(e){super(),this.contract=e}_buildSourceName(e,n){return`${e}:${n?n.toString():""}`}async _updateState(e){e.args?e.state.value=await this.contract[e.name](...e.args):e.state.value=await this.contract[e.name]()}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){const r=this._buildSourceName(e,n);let i=!1;Object.keys(this.sources).includes(r)||(this.sources[r]={name:e,args:n,state:t.ref(null),dependents:{}},i=!0);let l=null;s&&(l=t.watch(this.sources[r].state,s));const d=this._generateDependentUUID();return this.sources[r].dependents[d]=l,i&&this._updateState(this.sources[r]),d}remove(e,n,s){const r=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(r)&&Object.keys(this.sources[r].dependents).includes(s)){const i=this.sources[r].dependents[s];i&&i(),delete this.sources[r].dependents[s]}Object.keys(this.sources[r].dependents).length===0&&delete this.sources[r]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class J extends Z{constructor(e){super(),this.address=e,this.availableSources=["balance"]}async _updateState(e){e.name==="balance"&&(e.state.value=await a.provider.getBalance(this.address))}async _update(){if(await this.requiresUpdate()){for(const e of Object.values(this.sources))await this._updateState(e);await this.updateLastUpdateBlock()}}add(e,n,s=null){if(!this.availableSources.includes(e))throw`Sources added to a ChainWalletWatcher must be in ${this.availableSources}. Got ${e}`;const r=this._buildSourceName(e,n);newSource=!1,Object.keys(this.sources).includes(r)||(this.sources[r]={name:e,args:n,state:ref(null),dependents:{}},newSource=!0);let i=null;s&&(i=watch(this.sources[r].state,s));const l=this._generateDependentUUID();return this.sources[r].dependents[l]=i,newSource&&this._updateState(this.sources[r]),l}remove(e,n,s){const r=this._buildSourceName(e,n);if(Object.keys(this.sources).includes(r)&&Object.keys(this.sources[r].dependents).includes(s)){const i=this.sources[r].dependents[s];i&&i(),delete this.sources[r].dependents[s]}Object.keys(this.sources[r].dependents).length===0&&delete this.sources[r]}getRef(e,n){const s=this._buildSourceName(e,n);return this.sources[s].state}}class N extends Error{constructor(e,...n){super(e,...n),this.message=`'${e}' wallet has rejected the connection request.`}}class m extends Error{constructor(e,...n){super(walletId,...n),this.message=e}}class X{constructor(e){this.id=e,this.lazyConnectAvailable=!0}isConnected(){throw new m(`isConnected() method is not implemented in ${this.id} wallet class.`)}getProvider(){throw new m(`getProvider() method is not implemented in ${this.id} wallet class.`)}getSigner(e=!1){throw new m(`getSigner() method is not implemented in ${this.id} wallet class.`)}async connect(e=!1){throw new m(`connect() method is not implemented in ${this.id} wallet class.`)}addNetwork(e){throw new m(`addNetwork() method is not implemented in ${this.id} wallet class.`)}switchNetwork(e,n=!1){throw new m(`switchNetwork() method is not implemented in ${this.id} wallet class.`)}}class v extends X{constructor(e,n=null){super(e),this.exposedObject=n}async isConnected(){if(this.exposedObject&&this.getSigner())try{const n=await this.exposedObject.request({method:"eth_accounts"});if(n&&n.length>0)return console.log(n),!0}catch{}return!1}getProvider(){return this.exposedObject?new y.ethers.providers.Web3Provider(this.exposedObject,"any"):null}async getSigner(){if(this.exposedObject){const e=this.getProvider();if(e)return await e.getSigner()}return null}async connect(e=!1){if(this.exposedObject){if(await this.isConnected()||e)return;try{await this.exposedObject.request({method:"eth_requestAccounts"})}catch(n){throw n.code===4001?new N(this.id):n}}throw"exposedObject not available"}async addNetwork(e){const n=a.config.networks.getById(e);await this.exposedObject.request({method:"wallet_addEthereumChain",params:[{chainId:e,rpcUrls:[n.defaultRPC],chainName:n.name,nativeCurrency:{name:n.currency.symbol,symbol:n.currency.symbol,decimals:n.currency.decimals},blockExplorerUrls:n.explorer&&n.explorer.url!==""?[n.explorer.url]:null}]})}async changeNetwork(e,n=!1){if(a.config.networks.getById(e)){e=y.ethers.utils.hexlify(parseInt(e)).toString(),e=y.ethers.utils.hexValue(e);try{await this.exposedObject.request({method:"wallet_switchEthereumChain",params:[{chainId:e}]})}catch(r){if(r.code===4902)this.addNetwork(e);else throw r}}}}class he extends v{constructor(){super("metamask",window.ethereum)}}class ue extends X{constructor(e,n={}){super(),this.id="coinbase";const s=n.appName||"",r=n.appLogoUrl,i=n.darkMode||!1;this.coinbaseWalletSdk=new e({appName:s,appLogoUrl:r,darkMode:i}),this.provider=this.getProvider()}getProvider(){try{return this.coinbaseWalletSdk.makeWeb3Provider()}catch(e){return console.log(e),null}}async connect(){try{await this.provider.send("eth_requestAccounts")}catch{throw N(this.id)}}}class pe extends v{constructor(){super("binanceChain",window.BinanceChain),this.lazyConnectAvailable=!1}async isConnected(){throw new m("isConnected() method is not available for BinanceChainWallet class since lazy connection is not available.")}async connect(e=!1){if(e)throw new m("connect() with 'lazy=true' is not available for BinanceChainWallet class because isConnected() is not available on this class.")}}const tt={metamask:he,coinbase:ue,binanceChain:pe};async function fe(o,e){const n=e;try{a.init(n)}catch(r){throw a&&a.status&&a.status.set("ERROR"),r}o.config.globalProperties.dapp=a,o.config.globalProperties.rGet=w,o.config.globalProperties.rSet=p,window.dapp=a;const s=await Promise.resolve().then(()=>Xt);o.component("OnDappSafe",s.OnDappSafe),o.component("OnProviderSafe",s.OnProviderSafe),o.component("OnSignerSafe",s.OnSignerSafe),o.component("OnContractReadSafe",s.OnContractReadSafe),o.component("OnContractWriteSafe",s.OnContractWriteSafe),a.status.set("INITIALIZED")}c.ConnectWalletButton=L,c.ContractInteractor=M,c.ContractWatcher=Q,c.DebugBar=H,c.EventInteractor=x,c.EventsInteractor=R,c.InputUnits=$,c.MethodInteractor=b,c.MethodsInteractor=C,c.OnContractReadSafe=T,c.OnContractWriteSafe=P,c.OnDappSafe=B,c.OnProviderSafe=D,c.OnSignerSafe=V,c.SelectNetworkDropdown=q,c.SelectWalletDropdown=F,c.Status=g,c.Transact=O,c.TulipeConfig=z,c.TulipeContractProxy=A,c.TulipeProviderProxy=K,c.TulipeProxy=S,c.TulipeSignerProxy=Y,c.TulipeTransactionProxy=W,c.WalletConnectionRejected=N,c.WalletWatcher=J,c.capitalizeWords=U,c.dapp=a,c.deepMerge=_,c.initTulipe=fe,c.isObject=E,c.rGet=w,c.rSet=p,c.styleLevelProp=I,c.wallets=tt,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "tulipe", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "A DApp frontend framework for Vue3 built with Ethers.js", |
@@ -38,3 +38,3 @@ **<h1 align="center">Tulipe</h1>** | ||
| | ||
<a href="https://tuli.pe/changelog/">Changelog</a> | ||
<a href="https://github.com/0Lilian/tulipe/blob/main/CHANGELOG.md">Changelog</a> | ||
</h3> | ||
@@ -83,3 +83,3 @@ | ||
### Auto-instanciations | ||
### Auto-instantiations | ||
When your DApp loads, Tulipe will read your `tulipe.config.js` file and populates, if possible, the `dapp` object with all the [Ethers.js](https://ethers.org/) instances your DApp requires. | ||
@@ -98,3 +98,3 @@ ```js | ||
You don't have anymore to deal with multiple manual instanciations. | ||
You don't have anymore to deal with multiple manual instantiations. | ||
@@ -169,2 +169,2 @@ ### ARS (Automated Relations Safety) | ||
## Contributions | ||
See : [CONTRIBUTING](/CONTRIBUTING.md) | ||
See : [CONTRIBUTING](https://github.com/0Lilian/tulipe/blob/main/CONTRIBUTING.md) |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
167840
2375
0