Socket
Socket
Sign inDemoInstall

tulipe

Package Overview
Dependencies
386
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.1 to 1.5.0

dist/index.25897989.mjs

1536

dist/tulipe.es.js

@@ -1,2 +0,2 @@

import { computed as C, getCurrentInstance as N, watch as w, isRef as G, ref as y, resolveComponent as b, openBlock as c, createBlock as E, withCtx as g, createElementVNode as o, toDisplayString as p, unref as l, createVNode as I, createTextVNode as T, createElementBlock as u, Fragment as v, renderList as S, shallowRef as z, withDirectives as j, vModelText as U, createCommentVNode as O, normalizeClass as Q, renderSlot as _, pushScopeId as J, popScopeId as X, vModelSelect as tt, markRaw as et, onUnmounted as W } from "vue";
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";

@@ -7,7 +7,7 @@ class st {

init(t = null) {
this.config = new ie(t), this.status = new P("dapp", [
this.config = new ve(t), this.status = new P("dapp", [
"UNSAFE",
"ERROR",
"INITIALIZED"
]), this.isSafe = C(() => this.status.is("INITIALIZED")), this.OnSafe = Ft, this.chainWatchers = new ce(), this.wallets = new we(), this.provider = new fe(), this.pro = this.provider, this.signer = new _e(), this.sig = this.signer, this.contracts = new ge(), this.con = this.contracts;
]), 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;
}

@@ -26,3 +26,3 @@ onSafe(t) {

const a = new st();
function V(r) {
function M(r) {
return r && typeof r == "object" && !Array.isArray(r);

@@ -34,5 +34,5 @@ }

const e = t.shift();
if (V(r) && V(e))
if (M(r) && M(e))
for (const s in e)
V(e[s]) ? (r[s] || Object.assign(r, {
M(e[s]) ? (r[s] || Object.assign(r, {
[s]: {}

@@ -50,7 +50,7 @@ }), D(r[s], e[s])) : Object.assign(r, {

}
function $(r) {
return G(r) ? r.value : r;
function T(r) {
return W(r) ? T(r.value) : r;
}
function R(r, t) {
G(r) ? r.value = t : r = t;
function I(r, t) {
W(r) ? r.value = t : r = t;
}

@@ -64,3 +64,3 @@ const at = {

}
}, rt = { class: "ContractInteractor" }, ot = /* @__PURE__ */ T(" Methods : "), it = /* @__PURE__ */ o("br", null, null, -1), ct = /* @__PURE__ */ T(" Events : "), lt = /* @__PURE__ */ o("br", null, null, -1), Ce = {
}, rt = { class: "ContractInteractor" }, ot = /* @__PURE__ */ $(" Methods : "), it = /* @__PURE__ */ c("br", null, null, -1), ct = /* @__PURE__ */ $(" Events : "), lt = /* @__PURE__ */ c("br", null, null, -1), Ue = {
__name: "ContractInteractor",

@@ -75,3 +75,3 @@ props: {

const t = r, e = a.contracts[t.contract];
let s = y("not owned");
let s = m("not owned");
return a.contracts[t.contract].onReadSafe(async function() {

@@ -83,22 +83,22 @@ try {

}), (n, i) => {
const h = b("OnContractReadSafe");
return c(), E(h, {
const d = C("OnContractReadSafe");
return l(), g(d, {
contract: t.contract
}, {
default: g(() => [
o("div", rt, [
o("ul", null, [
o("li", null, "Address : " + p(l(e).address), 1),
o("li", null, "Owner : " + p(s.value), 1),
o("li", null, [
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,
I(l(ht), {
O(o(dt), {
contract: t.contract
}, null, 8, ["contract"])
]),
o("li", null, [
c("li", null, [
ct,
lt,
I(l(bt), {
O(o(Ct), {
contract: t.contract

@@ -114,3 +114,3 @@ }, null, 8, ["contract"])

}
}, ut = { class: "MethodsInteractor" }, ht = {
}, ut = { class: "MethodsInteractor" }, dt = {
__name: "MethodsInteractor",

@@ -126,13 +126,13 @@ props: {

return (s, n) => {
const i = b("OnContractReadSafe");
return c(), E(i, {
const i = C("OnContractReadSafe");
return l(), g(i, {
contract: t.contract
}, {
default: g(() => [
o("div", ut, [
o("ul", null, [
(c(!0), u(v, null, S(l(e).interface.functions, (h, d) => (c(), u("li", null, [
I(l(gt), {
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), {
contract: t.contract,
method: d
method: h
}, null, 8, ["contract", "method"])

@@ -147,3 +147,3 @@ ]))), 256))

}
}, dt = { class: "MethodInteractor" }, pt = { key: 0 }, ft = /* @__PURE__ */ o("p", null, "Inputs :", -1), mt = ["onUpdate:modelValue", "placeholder"], _t = { key: 0 }, yt = { key: 1 }, vt = /* @__PURE__ */ o("p", null, "Outputs :", -1), wt = ["onUpdate:modelValue", "placeholder"], St = ["placeholder"], Et = { key: 2 }, gt = {
}, 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 = {
__name: "MethodInteractor",

@@ -161,3 +161,3 @@ props: {

setup(r) {
const t = r, e = z(new K(t.contract, t.method));
const t = r, e = Q(new H(t.contract, t.method));
function s(n) {

@@ -167,52 +167,54 @@ return `${n.name && n.name !== "null" ? n.name : ""} (${n.type})`;

return (n, i) => {
const h = b("OnContractReadSafe");
return c(), E(h, {
const d = C("OnContractReadSafe");
return l(), g(d, {
contract: t.contract
}, {
default: g(() => [
o("div", dt, [
I(l($t), {
default: R(() => [
c("div", ht, [
O(o(Pt), {
contract: t.contract,
method: t.method,
modelValue: e.value,
"onUpdate:modelValue": i[0] || (i[0] = (d) => e.value = d),
modelValue: o(e),
"onUpdate:modelValue": i[0] || (i[0] = (h) => W(e) ? e.value = h : null),
configs: { content: t.method, notx: !0, noerror: !0 }
}, null, 8, ["contract", "method", "modelValue", "configs"]),
o("small", null, p(e.value.methodInfos.stateMutability), 1),
Object.keys(e.value.methodInfos.inputs).length > 0 || e.value.methodInfos.payable ? (c(), u("div", pt, [
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,
o("ul", null, [
(c(!0), u(v, null, S(e.value.methodInfos.inputs, (d, f) => (c(), u("li", null, [
j(o("input", {
"onUpdate:modelValue": (m) => e.value.args[f] = m,
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] = _,
type: "text",
placeholder: s(d)
placeholder: s(h)
}, null, 8, mt), [
[U, e.value.args[f]]
])
[B, o(e).args.value[p]]
]),
$(" " + f(o(e).args.value[p]) + " " + f(typeof o(e).args.value[p]), 1)
]))), 256)),
e.value.methodInfos.payable ? (c(), u("li", _t, [
I(l(se), {
modelValue: e.value.txArgs.value.value,
"onUpdate:modelValue": i[1] || (i[1] = (d) => e.value.txArgs.value.value = d)
}, null, 8, ["modelValue"])
])) : O("", !0)
o(e).methodInfos.payable ? (l(), u("li", yt, [
O(o(he), {
modelValue: o(e).txArgs.value.value,
"onUpdate:modelValue": i[1] || (i[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)
])
])) : O("", !0),
Object.keys(e.value.methodInfos.outputs).length > 0 ? (c(), u("div", yt, [
])) : E("", !0),
Object.keys(o(e).methodInfos.outputs).length > 0 ? (l(), u("div", _t, [
vt,
o("ul", null, [
(c(!0), u(v, null, S(e.value.methodInfos.outputs, (d, f) => (c(), u("li", null, [
e.value.data.value ? j((c(), u("input", {
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", {
key: 0,
"onUpdate:modelValue": (m) => e.value.data.value[f] = m,
"onUpdate:modelValue": (_) => o(e).data.value[p] = _,
type: "text",
placeholder: s(d),
placeholder: s(h),
disabled: ""
}, null, 8, wt)), [
[U, e.value.data.value[f]]
]) : (c(), u("input", {
[B, o(e).data.value[p]]
]) : (l(), u("input", {
key: 1,
type: "text",
placeholder: s(d),
placeholder: s(h),
disabled: ""

@@ -222,4 +224,4 @@ }, null, 8, St))

])
])) : O("", !0),
e.value.status.is("ERROR") ? (c(), u("p", Et, p(e.value.error.value.reason), 1)) : O("", !0)
])) : E("", !0),
o(e).status.is("ERROR") ? (l(), u("p", gt, f(o(e).error.value.reason), 1)) : E("", !0)
])

@@ -231,3 +233,3 @@ ]),

}
}, Ot = { class: "EventsInteractor" }, bt = {
}, Et = { class: "EventsInteractor" }, Ct = {
__name: "EventsInteractor",

@@ -243,13 +245,13 @@ props: {

return (s, n) => {
const i = b("OnContractReadSafe");
return c(), E(i, {
const i = C("OnContractReadSafe");
return l(), g(i, {
contract: t.contract
}, {
default: g(() => [
o("div", Ot, [
o("ul", null, [
(c(!0), u(v, null, S(l(e).interface.events, (h, d) => (c(), u("li", null, [
I(l(It), {
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), {
contract: t.contract,
event: d
event: h
}, null, 8, ["contract", "event"])

@@ -264,3 +266,3 @@ ]))), 256))

}
}, Rt = { class: "EventInteractor" }, Ct = /* @__PURE__ */ T("Logs: "), It = {
}, It = { class: "EventInteractor" }, kt = /* @__PURE__ */ $("Logs: "), Ot = {
__name: "EventInteractor",

@@ -279,25 +281,25 @@ props: {

const t = r, e = a.contracts[t.contract];
let s = y({}), n = y({}), i = y(0), h = y([]);
let s = m({}), n = m({}), i = m(0), d = m([]);
return e.onReadSafe(() => {
s.value = e.interface.events[t.event], n.value = e.filters[s.value.name], e.on(n.value, (d) => {
s.value = e.interface.events[t.event], n.value = e.filters[s.value.name], e.on(n.value, (h) => {
i.value++;
let f = `Block ${d.blockNumber} -> {`;
for (const m of s.value.inputs)
f += `${m.name}:${d.args[m.name]}, `;
f = f.substring(0, f.length - 2) + "}", h.value.push(f);
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);
});
}), (d, f) => {
const m = b("OnContractReadSafe");
return c(), E(m, {
}), (h, p) => {
const _ = C("OnContractReadSafe");
return l(), g(_, {
contract: t.contract
}, {
default: g(() => [
o("div", Rt, [
o("p", null, p(s.value.name), 1),
o("ul", null, [
o("li", null, "Count : " + p(i.value), 1),
o("li", null, [
Ct,
o("ul", null, [
(c(!0), u(v, null, S(h.value, (B) => (c(), u("li", null, p(B), 1))), 256))
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))
])

@@ -312,3 +314,3 @@ ])

}
}, kt = { class: "TransactButton" }, Nt = {
}, bt = { class: "TransactButton" }, Nt = {
key: 1,

@@ -319,6 +321,6 @@ disabled: ""

disabled: ""
}, Dt = {
}, $t = {
key: 3,
disabled: ""
}, Pt = { key: 4 }, $t = {
}, Dt = { key: 4 }, Pt = {
__name: "Transact",

@@ -351,28 +353,28 @@ props: {

const e = r, s = a.contracts[e.contract];
let n = C({
let n = k({
get() {
return e.modelValue;
},
set(h) {
t("update:modelValue", h);
set(d) {
t("update:modelValue", d);
}
});
function i() {
const h = e.args ? e.args : [], d = e.txArgs ? e.txArgs : {};
n.value.send(h, d);
const d = e.args ? e.args : [], h = e.txArgs ? e.txArgs : {};
n.value.send(d, h);
}
return e.config && e.configs.notx && s.onReadSafe(() => {
n = new K(e.contract, e.method);
}), (h, d) => {
const f = b("OnContractReadSafe");
return c(), E(f, {
n = new H(e.contract, e.method);
}), (d, h) => {
const p = C("OnContractReadSafe");
return l(), g(p, {
contract: e.contract
}, {
default: g(() => [
o("div", kt, [
l(n).status.is("READY") ? (c(), u("button", {
default: R(() => [
c("div", bt, [
o(n).status.is("READY") ? (l(), u("button", {
key: 0,
onClick: i
}, p(e.configs && e.configs.content ? e.configs.content : "Transact"), 1)) : l(n).status.is("SENT") ? (c(), u("button", Nt, "Transaction sent...")) : l(n).status.is("ERROR") ? (c(), u("button", xt, "Transaction error!")) : l(n).status.is("SUCCESS") ? (c(), u("button", Dt, "Success !")) : O("", !0),
!(e.configs && e.configs.noerror) && l(n).status.is("ERROR") ? (c(), u("p", Pt, p(l(n).error.value.reason), 1)) : O("", !0)
}, 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)
])

@@ -393,12 +395,12 @@ ]),

disabled: ""
}, jt = {
}, Tt = {
key: 2,
disabled: ""
}, Tt = {
}, At = {
key: 3,
disabled: ""
}, At = {
}, Vt = {
key: 4,
disabled: ""
}, Vt = {
}, Ut = {
__name: "ConnectWalletButton",

@@ -410,17 +412,17 @@ props: {

const t = r;
let e = y({});
let e = m({});
return a.provider.onSafe(async function() {
e.value = await a.config.networks.getCurrent();
}), (s, n) => (c(), E(l(a).provider.OnSafe, null, {
default: g(() => [
o("div", {
class: Q(["ConnectWalletButton", `ve-${t.styleLevel}`])
}), (s, n) => (l(), g(o(a).provider.OnSafe, null, {
default: R(() => [
c("div", {
class: J(["ConnectWalletButton", `ve-${t.styleLevel}`])
}, [
l(a).signer.status.is("DISCONNECTED") ? (c(), u("button", {
o(a).signer.status.is("DISCONNECTED") ? (l(), u("button", {
key: 0,
onClick: n[0] || (n[0] = (i) => l(a).signer.connectWallet(l(a).wallets.metamask))
}, "Connect Wallet")) : l(a).signer.status.is("REQUESTED") ? (c(), u("button", Wt, "Connection requested...")) : l(a).signer.status.is("REFUSED") ? (c(), u("button", jt, "Connection refused!")) : l(a).signer.status.is("ERROR") ? (c(), u("button", Tt, "Connection error!")) : l(a).provider.status.is("WRONG") ? (c(), u("button", At, "Wrong network! (" + p(l(e) ? l(e).value.displayName : "unknown") + ")", 1)) : l(a).signer.status.is("CONNECTED") ? (c(), u("button", {
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) => l(a).signer.disconnectWallet && l(a).signer.disconnectWallet(...i))
}, "Disconnect")) : O("", !0)
onClick: n[1] || (n[1] = (...i) => o(a).signer.disconnectWallet && o(a).signer.disconnectWallet(...i))
}, "Disconnect")) : E("", !0)
], 2)

@@ -431,12 +433,40 @@ ]),

}
}, Ie = /* @__PURE__ */ q(Vt, [["__scopeId", "data-v-2b282558"]]), Ut = /* @__PURE__ */ o("p", null, "Available wallets :", -1), ke = {
__name: "AvailableWallets",
}, 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 = {
__name: "SelectWalletDropdown",
setup(r) {
return (t, e) => {
const s = b("OnDappSafe");
return c(), E(s, null, {
default: g(() => [
Ut,
o("ul", null, [
(c(!0), u(v, null, S(l(a).wallets, (n) => (c(), u("li", null, p(n.name), 1))), 256))
let t = m({}), e = m([]), s = m(!1);
a.onSafe(async function() {
t.value = await a.config.wallets.getCurrent(), e.value = a.config.wallets.getAvailable().filter((i) => i !== t.value);
});
function n() {
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", {
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])
}, [
c("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)
])
])

@@ -448,70 +478,39 @@ ]),

}
}, Mt = { class: "SelectNetworkDropdown" }, Bt = {
key: 0,
selected: ""
}, Lt = ["src", "alt"], Gt = ["onClick"], qt = ["src", "alt"], Ne = {
}, 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 = {
__name: "SelectNetworkDropdown",
setup(r) {
let t = y({}), e = y([]);
let t = m({}), e = m([]), s = m(!1);
a.onSafe(async function() {
t.value = await a.config.networks.getCurrent(), e.value = a.config.networks.getAvailable(), e.value = e.value.filter((h) => h != t.value);
t.value = await a.config.networks.getCurrent(), e.value = a.config.networks.getAvailable().filter((i) => i.id !== t.value.id);
});
async function s(h) {
const d = e.value.find((f) => f.chainId === parseInt(h));
if (d) {
h = x.utils.hexlify(parseInt(h)).toString(), h = x.utils.hexValue(h);
try {
await window.ethereum.request({
method: "wallet_switchEthereumChain",
params: [{
chainId: h
}]
});
} catch (f) {
f.code === 4902 && await window.ethereum.request({
method: "wallet_addEthereumChain",
params: [{
chainId: h,
rpcUrls: [d.defaultRPC],
chainName: d.name,
nativeCurrency: {
name: d.currency.symbol,
symbol: d.currency.symbol,
decimals: d.currency.decimals
},
blockExplorerUrls: d.explorer && d.explorer.url !== "" ? [d.explorer.url] : null
}]
});
}
}
}
function n() {
i.value = !i.value;
s.value = !s.value;
}
let i = y(!1);
return (h, d) => {
const f = b("OnDappSafe");
return c(), E(f, null, {
default: g(() => [
o("div", Mt, [
o("ul", { onClick: n }, [
t.value ? (c(), u("li", Bt, [
o("img", {
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", {
width: "40",
src: t.value.icon ? t.value.icon : l(a).config.defaults.networks.icon,
alt: t.value.name + " logo"
}, null, 8, Lt),
o("p", null, p(t.value.displayName), 1)
])) : O("", !0),
i.value ? (c(!0), u(v, { key: 1 }, S(e.value, (m) => (c(), u("li", {
key: m.chainId,
onClick: (B) => s(m.chainId)
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", {
key: p.id,
onClick: (_) => o(a).provider.changeNetwork(p.id)
}, [
o("img", {
c("img", {
width: "40",
src: m.icon ? m.icon : l(a).config.defaults.networks.icon,
alt: m.name + " logo"
}, null, 8, qt),
o("p", null, p(m.displayName), 1)
], 8, Gt))), 128)) : O("", !0)
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)
])

@@ -524,43 +523,43 @@ ])

}
}, Ft = {
}, ee = {
__name: "OnDappSafe",
setup(r) {
return (t, e) => l(a).isSafe.value ? (c(), u(v, { key: 0 }, [
_(t.$slots, "default"),
_(t.$slots, "safe")
], 64)) : _(t.$slots, "unsafe", { key: 1 });
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 });
}
}, Ht = {
}, se = {
__name: "OnProviderSafe",
setup(r) {
return (t, e) => l(a).provider.isSafe.value ? (c(), u(v, { key: 0 }, [
_(t.$slots, "default"),
_(t.$slots, "safe")
], 64)) : _(t.$slots, "unsafe", { key: 1 });
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 });
}
}, Zt = {
}, ne = {
__name: "OnSignerSafe",
setup(r) {
return (t, e) => l(a).signer.isSafe.value ? (c(), u(v, { key: 0 }, [
_(t.$slots, "default"),
_(t.$slots, "safe")
], 64)) : _(t.$slots, "unsafe", { key: 1 });
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 });
}
}, xe = {
}, Le = {
__name: "OnContractsReadSafe",
setup(r) {
return (t, e) => l(a).contracts.areReadSafe.value ? (c(), u(v, { key: 0 }, [
_(t.$slots, "default"),
_(t.$slots, "safe")
], 64)) : _(t.$slots, "unsafe", { key: 1 });
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 });
}
}, De = {
}, Ge = {
__name: "OnContractsWriteSafe",
setup(r) {
return (t, e) => l(a).contracts.areWriteSafe.value ? (c(), u(v, { key: 0 }, [
_(t.$slots, "default"),
_(t.$slots, "safe")
], 64)) : _(t.$slots, "unsafe", { key: 1 });
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 });
}
}, Yt = {
}, ae = {
__name: "OnContractReadSafe",

@@ -575,8 +574,8 @@ props: {

const t = r;
return (e, s) => l(a).contracts[t.contract].isReadSafe.value ? (c(), u(v, { key: 0 }, [
_(e.$slots, "default"),
_(e.$slots, "safe")
], 64)) : _(e.$slots, "unsafe", { key: 1 });
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 });
}
}, Kt = {
}, re = {
__name: "OnContractWriteSafe",

@@ -591,29 +590,29 @@ props: {

const t = r;
return (e, s) => l(a).contracts[t.contract].isWriteSafe.value ? (c(), u(v, { key: 0 }, [
_(e.$slots, "default"),
_(e.$slots, "safe")
], 64)) : _(e.$slots, "unsafe", { key: 1 });
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 });
}
};
const F = (r) => (J("data-v-d83f3980"), r = r(), X(), r), zt = /* @__PURE__ */ F(() => /* @__PURE__ */ o("h3", null, "Safe Runners", -1)), Qt = /* @__PURE__ */ F(() => /* @__PURE__ */ o("h3", null, "Status", -1)), Jt = {
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 = {
__name: "DebugBar",
setup(r) {
return (t, e) => {
const s = b("OnDappSafe");
return c(), E(s, null, {
default: g(() => [
o("section", null, [
o("div", null, [
zt,
o("ul", null, [
o("li", null, "DApp safe : " + p(l(a).isSafe), 1),
o("li", null, "Network safe : " + p(l(a).provider.isSafe), 1),
o("li", null, "Wallet safe : " + p(l(a).signer.isSafe), 1),
o("li", null, "Contracts read safe : " + p(l(a).contracts.areReadSafe), 1),
o("li", null, "Contracts write safe : " + p(l(a).contracts.areWriteSafe), 1),
(c(!0), u(v, null, S(l(a).contracts.getAll(), (n, i) => (c(), u("li", null, [
T(" contract " + p(i) + " : ", 1),
o("ul", null, [
o("li", null, "read safe : " + p(n.isReadSafe), 1),
o("li", null, "write safe : " + p(n.isWriteSafe), 1)
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)
])

@@ -623,10 +622,10 @@ ]))), 256))

]),
o("div", null, [
Qt,
o("ul", null, [
o("li", null, "dapp : " + p(l(a).status.get()), 1),
o("li", null, "provider : " + p(l(a).provider.status.get()), 1),
o("li", null, "signer : " + p(l(a).signer.status.get()), 1),
o("li", null, "contracts : " + p(l(a).contracts.status.get()), 1),
(c(!0), u(v, null, S(l(a).contracts.getAll(), (n, i) => (c(), u("li", null, " contract " + p(i) + " : " + p(n.status.get()), 1))), 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))
])

@@ -640,3 +639,3 @@ ])

}
}, Pe = /* @__PURE__ */ q(Jt, [["__scopeId", "data-v-d83f3980"]]), Xt = { class: "InputUnits" }, te = ["placeholder"], ee = ["value"], se = {
}, qe = /* @__PURE__ */ q(ce, [["__scopeId", "data-v-8361140f"]]), le = { class: "InputUnits" }, ue = ["placeholder"], de = ["value"], he = {
__name: "InputUnits",

@@ -652,27 +651,27 @@ props: {

const e = r;
let s = y(null);
let s = m(null);
const n = ["wei", "gwei", "ether"];
let i = y("wei");
function h() {
let i = m("wei");
function d() {
if (s.value) {
const d = x.utils.parseUnits(s.value, i.value);
t("update:modelValue", d);
const h = x.utils.parseUnits(s.value, i.value);
t("update:modelValue", h);
}
}
return (d, f) => (c(), u("div", Xt, [
j(o("input", {
onInput: h,
"onUpdate:modelValue": f[0] || (f[0] = (m) => s.value = m),
return (h, p) => (l(), u("div", le, [
V(c("input", {
onInput: d,
"onUpdate:modelValue": p[0] || (p[0] = (_) => W(s) ? s.value = _ : s = _),
type: "text",
placeholder: l(e).placeholder
}, null, 40, te), [
[U, s.value]
placeholder: o(e).placeholder
}, null, 40, ue), [
[B, o(s)]
]),
j(o("select", {
onChange: h,
"onUpdate:modelValue": f[1] || (f[1] = (m) => i.value = m)
V(c("select", {
onChange: d,
"onUpdate:modelValue": p[1] || (p[1] = (_) => W(i) ? i.value = _ : i = _)
}, [
(c(), u(v, null, S(n, (m) => o("option", { value: m }, p(m), 9, ee)), 64))
(l(), u(v, null, S(n, (_) => c("option", { value: _ }, f(_), 9, de)), 64))
], 544), [
[tt, i.value]
[et, o(i)]
])

@@ -688,3 +687,3 @@ ]));

this.states.push(this._formatState(s));
this._state = y(this.states[0]);
this._state = m(this.states[0]);
}

@@ -704,3 +703,3 @@ _formatState(t) {

get() {
return $(this._state);
return T(this._state);
}

@@ -713,3 +712,3 @@ getRef() {

throw `The state given to the set() method of Status instance '${this._name}' must a value in ${this.states}. Got: ${t}`;
R(this._state, t), console.log(`Status '${this._name}' set to '${$(this._state)}'`);
I(this._state, t), console.log(`Status '${this._name}' set to '${T(this._state)}'`);
}

@@ -749,3 +748,46 @@ is(t) {

}
const k = {
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 = {
style: {

@@ -758,3 +800,3 @@ level: "minimal"

displayName: "Ethereum",
chainId: 1,
id: 1,
type: "mainnet",

@@ -778,3 +820,3 @@ icon: "https://static.tuli.pe/icons/networks/ethereum.svg",

displayName: "Ropsten (Ethereum Testnet)",
chainId: 3,
id: 3,
type: "testnet",

@@ -798,3 +840,3 @@ icon: null,

displayName: "Rinkeby (Ethereum Testnet)",
chainId: 4,
id: 4,
type: "testnet",

@@ -818,3 +860,3 @@ icon: null,

displayName: "G\xF6rli (Ethereum Testnet)",
chainId: 5,
id: 5,
type: "testnet",

@@ -837,3 +879,3 @@ icon: null,

name: "Optimism",
chainId: 10,
id: 10,
type: "mainnet",

@@ -857,3 +899,3 @@ icon: "https://static.tuli.pe/icons/networks/optimism.svg",

displayName: "Cronos",
chainId: 25,
id: 25,
type: "mainnet",

@@ -877,3 +919,3 @@ icon: "https://static.tuli.pe/icons/networks/cronos.svg",

displayName: "Telos",
chainId: 40,
id: 40,
type: "mainnet",

@@ -897,3 +939,3 @@ icon: null,

displayName: "BSC",
chainId: 56,
id: 56,
type: "mainnet",

@@ -917,3 +959,3 @@ icon: "https://static.tuli.pe/icons/networks/bsc.svg",

displayName: "Gnosis",
chainId: 100,
id: 100,
type: "mainnet",

@@ -937,3 +979,3 @@ icon: "https://static.tuli.pe/icons/networks/gnosis.svg",

displayName: "Fuse",
chainId: 122,
id: 122,
type: "mainnet",

@@ -957,3 +999,3 @@ icon: "https://static.tuli.pe/icons/networks/fuse.svg",

displayName: "HECO",
chainId: 128,
id: 128,
type: "mainnet",

@@ -977,3 +1019,3 @@ icon: "https://static.tuli.pe/icons/networks/heco.svg",

displayName: "Polygon",
chainId: 137,
id: 137,
type: "mainnet",

@@ -997,3 +1039,3 @@ icon: "https://static.tuli.pe/icons/networks/polygon.svg",

displayName: "Fantom",
chainId: 250,
id: 250,
type: "mainnet",

@@ -1017,3 +1059,3 @@ icon: "https://static.tuli.pe/icons/networks/fantom.svg",

displayName: "Metis",
chainId: 1088,
id: 1088,
type: "mainnet",

@@ -1036,3 +1078,3 @@ icon: "https://static.tuli.pe/icons/networks/metis.svg",

name: "Moonbeam",
chainId: 1284,
id: 1284,
type: "mainnet",

@@ -1055,3 +1097,3 @@ icon: "https://static.tuli.pe/icons/networks/moonbeam.svg",

name: "Moonriver",
chainId: 1285,
id: 1285,
type: "mainnet",

@@ -1075,3 +1117,3 @@ icon: "https://static.tuli.pe/icons/networks/moonriver.svg",

displayName: "Klaytn",
chainId: 8217,
id: 8217,
type: "mainnet",

@@ -1095,3 +1137,3 @@ icon: "https://static.tuli.pe/icons/networks/klaytn.svg",

displayName: "Hardhat",
chainId: 31337,
id: 31337,
type: "testnet",

@@ -1111,3 +1153,3 @@ icon: null,

displayName: "Arbitrum",
chainId: 42161,
id: 42161,
type: "mainnet",

@@ -1131,3 +1173,3 @@ icon: "https://static.tuli.pe/icons/networks/arbitrum.svg",

displayName: "Celo",
chainId: 42220,
id: 42220,
type: "mainnet",

@@ -1151,3 +1193,3 @@ icon: "https://static.tuli.pe/icons/networks/celo.svg",

displayName: "Emerald",
chainId: 42262,
id: 42262,
type: "mainnet",

@@ -1171,3 +1213,3 @@ icon: "https://static.tuli.pe/icons/networks/emerald.svg",

displayName: "Avalanche",
chainId: 43114,
id: 43114,
type: "mainnet",

@@ -1191,3 +1233,3 @@ icon: "https://static.tuli.pe/icons/networks/avalanche.svg",

displayName: "Aurora",
chainId: 1313161554,
id: 1313161554,
type: "mainnet",

@@ -1211,3 +1253,3 @@ icon: "https://static.tuli.pe/icons/networks/aurora.svg",

displayName: "Harmony",
chainId: 16666e5,
id: 16666e5,
type: "mainnet",

@@ -1231,3 +1273,3 @@ icon: "https://static.tuli.pe/icons/networks/harmony.svg",

{
name: "metamask",
id: "metamask",
displayName: "Metamask",

@@ -1237,3 +1279,3 @@ icon: null

{
name: "binanceChain",
id: "binanceChain",
displayName: "Binance Chain",

@@ -1243,3 +1285,3 @@ icon: null

{
name: "coinbase",
id: "coinbase",
displayName: "Coinbase",

@@ -1258,6 +1300,6 @@ icon: null

};
class ne {
class fe {
constructor(t = null) {
let e = {};
return t ? e = D({ ...k.style }, { ...t }) : e = k.style, window.addEventListener("load", () => {
return t ? e = D({ ...b.style }, { ...t }) : e = b.style, window.addEventListener("load", () => {
const s = document.getElementsByClassName("ve-app");

@@ -1270,21 +1312,32 @@ if (s)

}
class ae {
class me {
constructor(t = null) {
if (this._list = [], t) {
for (const e of t)
if (e.chainId) {
const s = k.networks.find((i) => i.chainId === e.chainId), n = D({ ...s }, { ...e });
if (e.id) {
const s = b.networks.find((i) => i.id === e.id), n = D({ ...s }, { ...e });
n.available !== !1 && (n.available = !0), n.displayName || (n.displayName = n.name), this._list.push(n);
}
}
for (const e of k.networks)
this._list.find((n) => n.chainId === e.chainId) || (e.available = !1, this._list.push(e));
for (const e of b.networks)
this._list.find((n) => n.id === e.id) || (e.available = !1, this._list.push(e));
}
add(t) {
this._list.push(t);
}
async getCurrent() {
if (a.provider.proxy.getEthersObject()) {
if (a.provider.proxy.ethersInstance) {
const t = await a.provider.getNetwork().then((e) => e.chainId);
return this._list.find((e) => e.chainId === t);
return this.getById(t);
}
return null;
}
getById(t) {
try {
t = parseInt(t);
} 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((e) => e.id === parseInt(t));
}
getDefault() {

@@ -1300,21 +1353,24 @@ return this._list.find((t) => t.default === !0);

}
class re {
class ye {
constructor(t = null) {
if (this._list = [], t) {
for (const e of t)
if (e.name) {
const s = k.wallets.find((i) => i.name === e.name), n = D({ ...s }, { ...e });
n.available !== !1 && (n.available = !0), n.displayName || (n.displayName = n.name), this._list.push(n);
if (e.id) {
const s = b.wallets.find((i) => i.id === e.id), n = D({ ...s }, { ...e });
n.available !== !1 && (n.available = !0), n.displayName || (n.displayName = n.id), this._list.push(n);
}
}
for (const e of k.wallets)
this._list.find((n) => n.name === e.name) || (e.available = !1, this._list.push(e));
for (const e of b.wallets)
this._list.find((n) => n.id === e.id) || (e.available = !1, this._list.push(e));
}
async getCurrent() {
if (a.signer.getEthersObject()) {
const t = a.signer.name;
return this._list.find((e) => e.name === t);
if (a.signer.proxy.ethersInstance) {
const t = a.provider.connection.url;
return this.getById(t);
}
return null;
}
getById(t) {
return this._list.find((e) => e.id === t);
}
getDefault() {

@@ -1330,15 +1386,324 @@ return this._list.find((t) => t.default === !0);

}
class oe {
class _e {
constructor(t = null) {
let e = {};
return t ? e = D({ ...k.defaults }, { ...t }) : e = k.defaults, e;
return t ? e = D({ ...b.defaults }, { ...t }) : e = b.defaults, e;
}
}
class ie {
class ve {
constructor(t = null) {
this.style = new ne(t ? t.style : null), this.networks = new ae(t ? t.networks : null), this.wallets = new re(t ? t.wallets : null), this.defaults = new oe(t ? t.defaults : 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);
}
}
class ce {
class U {
constructor(t = null, e = null, s = null) {
return this.proxy = {
_ethersInstance: t && L(t),
get ethersInstance() {
return this._ethersInstance;
},
set ethersInstance(n) {
this._ethersInstance = n && L(n);
},
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.";
}
});
}
}
class we {
}
class Se {
constructor() {
this.status = new P("provider", [
"DISCONNECTED",
"WRONG",
"ERROR",
"CONNECTED"
]), this.isSafe = k(() => a.isSafe.value && !this.status.isIn(["DISCONNECTED", "ERROR"])), this.OnSafe = se;
}
async _getProviderFromWebWallet() {
for (const t of Object.values(a.wallets))
if (t) {
const e = t.getProvider();
if (e)
return e;
}
return null;
}
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));
}
}
_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 changeNetwork(t) {
const e = await a.config.wallets.getCurrent();
e && a.wallets[e.id].changeNetwork(t);
}
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 Re {
}
class Ee {
constructor() {
this.address = m(null), this.status = new P("signer", [
"DISCONNECTED",
"REQUESTED",
"REFUSED",
"ERROR",
"NO_PROVIDER",
"WRONG_PROVIDER",
"CONNECTED"
]), this.isSafe = k(() => a.provider.isSafe.value && this.status.is("CONNECTED")), this.OnSafe = ne;
}
initARS() {
a.provider.status.watchAny((t) => {
t === "WRONG" ? this.status.set("WRONG_PROVIDER") : ["DISCONNECTED", "ERROR"].includes(t) && this.status.set("NO_PROVIDER");
}), this.status.watch(["REFUSED", "ERROR"], () => {
setTimeout(() => {
this.status.set("DISCONNECTED");
}, 5e3);
});
}
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();
}
onSafe(t) {
const e = N();
if (this.isSafe.value)
t(e);
else {
const s = w(this.isSafe, () => {
this.isSafe.value && (t(e), s());
});
}
}
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;
}
}
}
}
disconnectWallet() {
a.signer.proxy.ethersInstance = null, this.address.value = null, a.signer.status.set("DISCONNECTED");
}
}
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 Ie {
_watch(t, e, s = null) {
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);
}
watchRef(t, e, s = null) {
const n = this._watch(t, e, null);
return s ? A(() => {
a.chainWatchers.contracts[this.address].remove(t, e, n);
}, s) : A(() => {
a.chainWatchers.contracts[this.address].remove(t, e, n);
}), a.chainWatchers.contracts[this.address].getRef(t, e);
}
}
class ke {
constructor(t) {
this.name = t, this.status = new P(`contract:${t}`, [
"NO_PROVIDER",
"WRONG_PROVIDER",
"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 });
}
onReadSafe(t) {
const e = N();
if (this.isReadSafe.value)
t(e);
else {
const s = w(this.isReadSafe, () => {
this.isReadSafe.value && (t(e), s());
});
}
}
onWriteSafe(t) {
const e = N();
if (this.isWriteSafe.value)
t(e);
else {
const s = w(this.isWriteSafe, () => {
this.isWriteSafe.value && (t(e), s());
});
}
}
_updateContract(t, e) {
if (a.signer.isSafe.value)
this.proxy.ethersInstance = new x.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);
else
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));
});
}
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;
}
}.bind(this));
}
}
class G extends U {
constructor(t, e = null, s = null, n = null) {
s = s || new Ie(), n = n || new ke(t), super(e, s, n), this._asyncInit();
}
}
class Oe {
}
class be {
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}`, [
"NOT_READY",
"READY",
"SENT",
"ERROR",
"SUCCESS"
]);
}
initARS() {
this.status.watch(["ERROR", "SUCCESS"], () => {
setTimeout(() => {
this.status.set("READY");
}, 3e3);
});
}
_asyncInit() {
a.contracts[this.contractName].isReadSafe.value && this._initEthersInstance(), a.contracts[this.contractName].onReadSafe(() => {
this._initEthersInstance();
}), this.initARS();
}
_initEthersInstance() {
this.methodInfos = a.contracts[this.contractName].interface.functions[this.methodName], this.methodInfos.inputs.forEach((t) => this.args.value.push(null)), this.methodInfos.outputs.forEach((t) => this.data.value.push(null)), this.proxy.ethersInstance = a.contracts[this.contractName][this.methodName], this.status.set("READY");
}
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");
}).catch((s) => {
I(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");
}).catch((s) => {
I(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 Ne {
constructor() {
this.contracts = {}, this.wallets = {};

@@ -1356,3 +1721,3 @@ }

addContractWatcher(t) {
Object.keys(this.contracts).includes(t.address) || (this.contracts[t.address] = new le(t));
Object.keys(this.contracts).includes(t.address) || (this.contracts[t.address] = new xe(t));
}

@@ -1363,3 +1728,3 @@ removeContractWatcher(t) {

addWalletWatcher(t) {
Object.keys(this.wallets).includes(t) || (this.wallets[t] = new ue(t));
Object.keys(this.wallets).includes(t) || (this.wallets[t] = new $e(t));
}

@@ -1370,3 +1735,3 @@ removeContractWatcher(t) {

}
class H {
class Z {
constructor() {

@@ -1398,3 +1763,3 @@ this.lastUpdateBlock = 0, this.sources = {};

}
class le extends H {
class xe extends Z {
constructor(t) {

@@ -1422,9 +1787,9 @@ super(), this.contract = t;

args: e,
state: y(null),
state: m(null),
dependents: {}
}, i = !0);
let h = null;
s && (h = w(this.sources[n].state, s));
const d = this._generateDependentUUID();
return this.sources[n].dependents[d] = h, i && this._updateState(this.sources[n]), d;
let d = null;
s && (d = w(this.sources[n].state, s));
const h = this._generateDependentUUID();
return this.sources[n].dependents[h] = d, i && this._updateState(this.sources[n]), h;
}

@@ -1444,3 +1809,3 @@ remove(t, e, s) {

}
class ue extends H {
class $e extends Z {
constructor(t) {

@@ -1471,4 +1836,4 @@ super(), this.address = t, this.availableSources = ["balance"];

s && (i = watch(this.sources[n].state, s));
const h = this._generateDependentUUID();
return this.sources[n].dependents[h] = i, newSource && this._updateState(this.sources[n]), h;
const d = this._generateDependentUUID();
return this.sources[n].dependents[d] = i, newSource && this._updateState(this.sources[n]), d;
}

@@ -1488,184 +1853,5 @@ remove(t, e, s) {

}
function he(r) {
for (var t = []; r && r !== Object.prototype; )
t.push.apply(t, Object.getOwnPropertyNames(r)), r = Object.getPrototypeOf(r);
return t;
}
class de {
constructor(t) {
this._parent = t;
}
setEthersObject(t) {
this._parent._ethersObject = t && et(t), this.extendsEthersObject();
}
getEthersObject() {
return this._parent._ethersObject;
}
extendsEthersObject() {
if (this._parent._ethersObject && this._parent._extensionObject) {
const t = he(this._parent._extensionObject);
for (const e of t)
if (e !== "constructor")
try {
this._parent._ethersObject[e] = this._parent._extensionObject[e].bind(this._parent._ethersObject);
} catch (s) {
if (s instanceof TypeError)
this._parent._ethersObject[e] = this._parent._extensionObject[e];
else
throw s;
}
}
}
}
class A {
constructor(t = null, e = null) {
return this._ethersObject = null, this._extensionObject = e, this.proxy = new de(this), this.proxy.setEthersObject(t), new Proxy(this, {
get: function(s, n, i) {
if (s._ethersObject && s._ethersObject[n])
try {
return s._ethersObject[n].bind(s._ethersObject);
} catch (h) {
if (h.message.includes(".bind is not a function"))
return s._ethersObject[n];
throw h;
}
else if (s[n])
return s[n];
},
set: function(s, n, i) {
return s._ethersObject && s._ethersObject[n] ? (s._ethersObject[n] = i, !0) : (s[n] = i, !0);
}
});
}
}
class pe {
}
class fe extends A {
constructor(t = null) {
const e = new pe();
super(t, e), this.status = new P("provider", [
"DISCONNECTED",
"WRONG",
"ERROR",
"CONNECTED"
]), this.isSafe = C(() => a.isSafe.value && !this.status.isIn(["DISCONNECTED", "ERROR"])), this.OnSafe = Ht, this._asyncInit();
}
async _getProviderFromWebWallet() {
for (const t of Object.values(a.wallets))
if (t) {
const e = t.getProvider();
if (e)
return e;
}
return null;
}
async _initProviderConnection() {
const t = await this._getProviderFromWebWallet();
if (t)
this.proxy.setEthersObject(new x.providers.Web3Provider(t, "any"));
else {
const e = a.config.networks.getDefault();
e && e.defaultRPC && this.proxy.setEthersObject(new x.providers.JsonRpcProvider(e.defaultRPC));
}
}
async _asyncInit() {
if (await this._initProviderConnection(), !this._ethersObject)
this.status.set("DISCONNECTED");
else {
const t = await this.getNetwork();
let e = await a.config.networks.getAvailable().find((s) => s.chainId === t.chainId);
if (e)
this.status.set("CONNECTED");
else if (this.status.set("WRONG"), e = a.config.networks.getAll().find((s) => s.chainId === t.chainId), !e) {
const s = {
name: t.name,
displayName: nt(t.name),
chainId: t.chainId
};
a.config.network.append(s);
}
this.on("network", (s, n) => {
n && n !== s && window.location.reload();
}), this.on("error", () => {
this.status.set("ERROR");
}), e && e.pollingInterval && (this.pollingInterval = e.pollingInterval);
}
}
onSafe(t) {
const e = N();
if (this.isSafe.value)
t(e);
else {
const s = w(this.isSafe, () => {
this.isSafe.value && (t(e), s());
});
}
}
}
class me {
}
class _e extends A {
constructor(t = null) {
const e = new me();
super(t, e), this.status = new P("signer", [
"DISCONNECTED",
"REQUESTED",
"REFUSED",
"ERROR",
"NO_PROVIDER",
"WRONG_PROVIDER",
"CONNECTED"
]), a.provider.status.watchAny((s) => {
s === "WRONG" ? this.status.set("WRONG_PROVIDER") : ["DISCONNECTED", "ERROR"].includes(s) && this.status.set("NO_PROVIDER");
}), this.status.watch(["REFUSED", "ERROR"], () => {
setTimeout(() => {
this.status.set("DISCONNECTED");
}, 5e3);
}), this.isSafe = C(() => a.provider.isSafe.value && this.status.is("CONNECTED")), this.OnSafe = Zt, this.address = y(null), this._asyncInit();
}
async _asyncInit() {
const t = this;
a.provider.onSafe(async function() {
for (const e of Object.values(a.wallets))
await t.connectWallet(e, !0);
});
}
onSafe(t) {
const e = N();
if (this.isSafe.value)
t(e);
else {
const s = w(this.isSafe, () => {
this.isSafe.value && (t(e), s());
});
}
}
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.setEthersObject(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 M)
this.status.set("REFUSED");
else
throw this.status.set("ERROR"), n;
}
}
}
}
disconnectWallet() {
a.signer.proxy.setEthersObject(null), this.address.value = null, a.signer.status.set("DISCONNECTED");
}
}
class Z {
class Y {
constructor() {
this.provider = null, this.name = "";
this.provider = null, this.id = "";
}

@@ -1676,6 +1862,6 @@ getProvider() {

async connect() {
throw `connect() method of ${this.name} wallet is not implemented.`;
throw `connect() method of ${this.id} wallet is not implemented.`;
}
}
class M extends Error {
class j extends Error {
constructor(t, ...e) {

@@ -1685,5 +1871,5 @@ super(t, ...e), this.message = `${t} wallet has rejected the connection request.`;

}
class Y extends Z {
class K extends Y {
constructor() {
super(), this.name = "Metamask", this.provider = this.getProvider();
super(), this.id = "metamask", this.provider = this.getProvider();
}

@@ -1697,9 +1883,44 @@ getProvider() {

} catch (t) {
throw t.code === 4001 ? M(this.name) : t;
throw t.code === 4001 ? j(this.id) : t;
}
}
async addNetwork(t) {
const e = a.config.networks.getById(t);
await window.ethereum.request({
method: "wallet_addEthereumChain",
params: [{
chainId: t,
rpcUrls: [e.defaultRPC],
chainName: e.name,
nativeCurrency: {
name: e.currency.symbol,
symbol: e.currency.symbol,
decimals: e.currency.decimals
},
blockExplorerUrls: e.explorer && e.explorer.url !== "" ? [e.explorer.url] : null
}]
});
}
async changeNetwork(t) {
if (a.config.networks.getById(t)) {
t = x.utils.hexlify(parseInt(t)).toString(), t = x.utils.hexValue(t);
try {
await window.ethereum.request({
method: "wallet_switchEthereumChain",
params: [{
chainId: t
}]
});
} catch (s) {
if (s.code === 4902)
this.addNetwork(t);
else
throw s;
}
}
}
}
class ye extends Z {
class De extends Y {
constructor(t, e = {}) {
super(), this.name = "Coinbase";
super(), this.id = "coinbase";
const s = e.appName || "", n = e.appLogoUrl, i = e.darkMode || !1;

@@ -1723,9 +1944,9 @@ this.coinbaseWalletSdk = new t({

} catch {
throw M(this.name);
throw j(this.id);
}
}
}
class ve extends Y {
class Pe extends K {
constructor() {
super(), this.name = "BinanceChain";
super(), this.id = "binanceChain";
}

@@ -1735,179 +1956,21 @@ getProvider() {

}
async connect() {
super.connect.call(this);
}
}
class we {
class We {
constructor() {
const t = a.config.wallets.getAvailable();
for (const e of t) {
const s = Se[e.name];
s && (this[e.name] = new s());
const s = Te[e.id];
s && (this[e.id] = new s());
}
}
}
const Se = {
metamask: Y,
coinbase: ye,
binanceChain: ve
const Te = {
metamask: K,
coinbase: De,
binanceChain: Pe
};
class Ee {
_watch(t, e, s = null) {
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 ? W(() => {
a.chainWatchers.contracts[this.address].remove(t, e, i);
}, n) : W(() => {
a.chainWatchers.contracts[this.address].remove(t, e, i);
}), a.chainWatchers.contracts[this.address].remove.bind(a.chainWatchers.contracts[this.address], t, e, i);
}
watchRef(t, e, s = null) {
const n = this._watch(t, e, null);
return s ? W(() => {
a.chainWatchers.contracts[this.address].remove(t, e, n);
}, s) : W(() => {
a.chainWatchers.contracts[this.address].remove(t, e, n);
}), a.chainWatchers.contracts[this.address].getRef(t, e);
}
}
class L extends A {
constructor(t, e) {
const s = new Ee();
super(e, s), this.name = t, this.status = new P(`contract:${t}`, [
"NO_PROVIDER",
"WRONG_PROVIDER",
"ERROR",
"INITIALIZED"
]), a.provider.status.watchAny((n) => {
n === "WRONG" ? this.status.set("WRONG_PROVIDER") : ["DISCONNECTED", "ERROR"].includes(n) && this.status.set("NO_PROVIDER");
}), this.isReadSafe = C(() => a.provider.isSafe.value && this.status.is("INITIALIZED")), this.isWriteSafe = C(() => a.signer.isSafe.value && this.status.is("INITIALIZED")), this.OnReadSafe = I(Yt, { contract: this.name }), this.OnWriteSafe = I(Kt, { contract: this.name }), this._asyncInit();
}
_watchSignerChanges(t, e) {
w([a.signer.isSafe], (s, n) => {
console.log("Refresh contract " + this.name), s !== n && (this.proxy.setEthersObject(null), this._updateContract(t, e));
});
}
_updateContract(t, e) {
if (a.signer.isSafe.value)
this.proxy.setEthersObject(new x.Contract(t, e, a.signer.proxy.getEthersObject()));
else if (a.provider.isSafe.value)
this.proxy.setEthersObject(new x.Contract(t, e, a.provider.proxy.getEthersObject()));
else
throw `_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`;
}
async _asyncInit() {
const t = this;
a.provider.onSafe(async function() {
try {
const e = await a.config.networks.getCurrent();
if (e.contracts && Object.keys(e.contracts).includes(t.name)) {
const s = e.contracts[t.name];
t._updateContract(s.address, s.abi), t._watchSignerChanges(s.address, s.abi), t.status.set("INITIALIZED");
} else
t.status.set("WRONG_PROVIDER");
} catch (e) {
throw t.status.set("ERROR"), e;
}
});
}
onReadSafe(t) {
const e = N();
if (this.isReadSafe.value)
t(e);
else {
const s = w(this.isReadSafe, () => {
this.isReadSafe.value && (t(e), s());
});
}
}
onWriteSafe(t) {
const e = N();
if (this.isWriteSafe.value)
t(e);
else {
const s = w(this.isWriteSafe, () => {
this.isWriteSafe.value && (t(e), s());
});
}
}
}
class ge {
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 L(e);
this.areReadSafe = C(() => a.provider.isSafe.value && this.status.is("INITIALIZED")), this.areWriteSafe = C(() => 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 L && (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());
});
}
}
}
class Oe {
}
class K extends A {
constructor(t, e, s = [], n = { value: 0 }) {
super(null, new Oe()), this.contractName = t, this.methodName = e, this.methodInfos = {}, this.args = y(s), this.txArgs = y(n), this.status = new P(`tx:${t}:${e}`, [
"NOT_READY",
"READY",
"SENT",
"ERROR",
"SUCCESS"
]), this.status.watch(["ERROR", "SUCCESS"], () => {
setTimeout(() => {
this.status.set("READY");
}, 3e3);
}), this.data = y([]), this.error = y(null), this.call = null, this._init();
}
_init() {
a.contracts[this.contractName].isReadSafe.value && this._initEthersObject(), a.contracts[this.contractName].onReadSafe(() => {
this._initEthersObject();
});
}
_initEthersObject() {
this.methodInfos = a.contracts[this.contractName].interface.functions[this.methodName], this.methodInfos.inputs.forEach((t) => this.args.value.push(null)), this.methodInfos.outputs.forEach((t) => this.data.value.push(null)), this.proxy.setEthersObject(a.contracts[this.contractName][this.methodName]), this.status.set("READY");
}
send(t = null, e = null) {
t = t || $(this.args), e = e || $(this.txArgs), t ? Array.isArray(t) ? this.call = this.proxy.getEthersObject()(...t, e) : this.call = this.proxy.getEthersObject()(t, e) : this.call = this.proxy.getEthersObject()(e), this.status.set("SENT"), this.methodInfos.constant ? this.call.then((s) => {
Array.isArray(s) || (s = [s]), R(this.data, s), R(this.error, null), this.status.set("SUCCESS");
}).catch((s) => {
R(this.error, s), this.status.set("ERROR");
}) : this.call.then((s) => s.wait()).then((s) => {
Array.isArray(s) || (s = [s]), R(this.data, s), R(this.error, null), this.status.set("SUCCESS");
}).catch((s) => {
R(this.error, s), this.status.set("ERROR");
});
}
}
async function $e(r, t) {
async function Fe(r, t) {
const e = t;

@@ -1919,46 +1982,47 @@ try {

}
r.config.globalProperties.dapp = a, r.config.globalProperties.rGet = $, r.config.globalProperties.rSet = R, window.dapp = a;
const s = await import("./index.90b55ef3.js");
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");
}
export {
ke as AvailableWallets,
ce as ChainWatchersList,
Ie as ConnectWalletButton,
Ce as ContractInteractor,
le as ContractWatcher,
ge as ContractsList,
Pe as DebugBar,
L as EthersContractProxy,
fe as EthersProviderProxy,
_e as EthersSignerProxy,
K as EthersTransactionProxy,
It as EventInteractor,
bt as EventsInteractor,
se as InputUnits,
gt as MethodInteractor,
ht as MethodsInteractor,
Yt as OnContractReadSafe,
Kt as OnContractWriteSafe,
xe as OnContractsReadSafe,
De as OnContractsWriteSafe,
Ft as OnDappSafe,
Ht as OnProviderSafe,
Zt as OnSignerSafe,
Ne as SelectNetworkDropdown,
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,
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,
P as Status,
$t as Transact,
ie as TulipeConfig,
M as WalletConnectionRejected,
ue as WalletWatcher,
we as WalletsList,
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,
a as dapp,
D as deepMerge,
$e as initTulipe,
V as isObject,
$ as rGet,
R as rSet,
Fe as initTulipe,
M as isObject,
T as rGet,
I as rSet,
at as styleLevelProp,
Se as wallets
Te as wallets
};

@@ -1,1 +0,1 @@

var Tulipe=function(i,t,f){"use strict";class rt{constructor(){}init(e=null){this.config=new Z(e),this.status=new y("dapp",["UNSAFE","ERROR","INITIALIZED"]),this.isSafe=t.computed(()=>this.status.is("INITIALIZED")),this.OnSafe=R,this.chainWatchers=new Y,this.wallets=new et,this.provider=new J,this.pro=this.provider,this.signer=new X,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 r=new rt;function S(o){return o&&typeof o=="object"&&!Array.isArray(o)}function _(o,...e){if(!e.length)return o;const n=e.shift();if(S(o)&&S(n))for(const s in n)S(n[s])?(o[s]||Object.assign(o,{[s]:{}}),_(o[s],n[s])):Object.assign(o,{[s]:n[s]});return _(o,...e)}function T(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 E(o){return t.isRef(o)?o.value:o}function m(o,e){t.isRef(o)?o.value=e:o=e}const re="",k={required:!1,type:String,default:"minimal",validator(o){return["unstylized","minimal","opinionated"].includes(o)}},ot={class:"ContractInteractor"},ct=t.createTextVNode(" Methods : "),it=t.createElementVNode("br",null,null,-1),lt=t.createTextVNode(" Events : "),dt=t.createElementVNode("br",null,null,-1),j={__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,c)=>{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(s.value),1),t.createElementVNode("li",null,[ct,it,t.createVNode(t.unref(C),{contract:e.contract},null,8,["contract"])]),t.createElementVNode("li",null,[lt,dt,t.createVNode(t.unref(b),{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=r.contracts[e.contract];return(s,a)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{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(O),{contract:e.contract,method:d},null,8,["contract","method"])]))),256))])])]),_:1},8,["contract"])}}},ut={class:"MethodInteractor"},mt={key:0},pt=t.createElementVNode("p",null,"Inputs :",-1),ft=["onUpdate:modelValue","placeholder"],_t={key:0},yt={key:1},Et=t.createElementVNode("p",null,"Outputs :",-1),St=["onUpdate:modelValue","placeholder"],gt=["placeholder"],wt={key:2},O={__name:"MethodInteractor",props:{contract:{type:String,required:!0},method:{type:String,required:!0}},setup(o){const e=o,n=t.shallowRef(new x(e.contract,e.method));function s(a){return`${a.name&&a.name!=="null"?a.name:""} (${a.type})`}return(a,c)=>{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(I),{contract:e.contract,method:e.method,modelValue:n.value,"onUpdate:modelValue":c[0]||(c[0]=d=>n.value=d),configs:{content:e.method,notx:!0,noerror:!0}},null,8,["contract","method","modelValue","configs"]),t.createElementVNode("small",null,t.toDisplayString(n.value.methodInfos.stateMutability),1),Object.keys(n.value.methodInfos.inputs).length>0||n.value.methodInfos.payable?(t.openBlock(),t.createElementBlock("div",mt,[pt,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.value.methodInfos.inputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":u=>n.value.args[h]=u,type:"text",placeholder:s(d)},null,8,ft),[[t.vModelText,n.value.args[h]]])]))),256)),n.value.methodInfos.payable?(t.openBlock(),t.createElementBlock("li",_t,[t.createVNode(t.unref(W),{modelValue:n.value.txArgs.value.value,"onUpdate:modelValue":c[1]||(c[1]=d=>n.value.txArgs.value.value=d)},null,8,["modelValue"])])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),Object.keys(n.value.methodInfos.outputs).length>0?(t.openBlock(),t.createElementBlock("div",yt,[Et,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.value.methodInfos.outputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[n.value.data.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:0,"onUpdate:modelValue":u=>n.value.data.value[h]=u,type:"text",placeholder:s(d),disabled:""},null,8,St)),[[t.vModelText,n.value.data.value[h]]]):(t.openBlock(),t.createElementBlock("input",{key:1,type:"text",placeholder:s(d),disabled:""},null,8,gt))]))),256))])])):t.createCommentVNode("",!0),n.value.status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",wt,t.toDisplayString(n.value.error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},kt={class:"EventsInteractor"},b={__name:"EventsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];return(s,a)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{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(N),{contract:e.contract,event:d},null,8,["contract","event"])]))),256))])])]),_:1},8,["contract"])}}},Ct={class:"EventInteractor"},Ot=t.createTextVNode("Logs: "),N={__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({}),c=t.ref(0),l=t.ref([]);return n.onReadSafe(()=>{s.value=n.interface.events[e.event],a.value=n.filters[s.value.name],n.on(a.value,d=>{c.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",Ct,[t.createElementVNode("p",null,t.toDisplayString(s.value.name),1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Count : "+t.toDisplayString(c.value),1),t.createElementVNode("li",null,[Ot,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.value,at=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(at),1))),256))])])])])]),_:1},8,["contract"])}}},bt={class:"TransactButton"},Nt={key:1,disabled:""},It={key:2,disabled:""},Rt={key:3,disabled:""},Bt={key:4},I={__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(l){e("update:modelValue",l)}});function c(){const l=n.args?n.args:[],d=n.txArgs?n.txArgs:{};a.value.send(l,d)}return n.config&&n.configs.notx&&s.onReadSafe(()=>{a=new x(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",bt,[t.unref(a).status.is("READY")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:c},t.toDisplayString(n.configs&&n.configs.content?n.configs.content:"Transact"),1)):t.unref(a).status.is("SENT")?(t.openBlock(),t.createElementBlock("button",Nt,"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",Rt,"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"])}}},oe="",A=(o,e)=>{const n=o.__vccOpts||o;for(const[s,a]of e)n[s]=a;return n},Dt={key:1,disabled:""},Vt={key:2,disabled:""},Pt={key:3,disabled:""},Wt={key:4,disabled:""},M=A({__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]=c=>t.unref(r).signer.connectWallet(t.unref(r).wallets.metamask))},"Connect Wallet")):t.unref(r).signer.status.is("REQUESTED")?(t.openBlock(),t.createElementBlock("button",Dt,"Connection requested...")):t.unref(r).signer.status.is("REFUSED")?(t.openBlock(),t.createElementBlock("button",Vt,"Connection refused!")):t.unref(r).signer.status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",Pt,"Connection error!")):t.unref(r).provider.status.is("WRONG")?(t.openBlock(),t.createElementBlock("button",Wt,"Wrong network! ("+t.toDisplayString(t.unref(n)?t.unref(n).value.displayName:"unknown")+")",1)):t.unref(r).signer.status.is("CONNECTED")?(t.openBlock(),t.createElementBlock("button",{key:5,onClick:a[1]||(a[1]=(...c)=>t.unref(r).signer.disconnectWallet&&t.unref(r).signer.disconnectWallet(...c))},"Disconnect")):t.createCommentVNode("",!0)],2)]),_:1}))}},[["__scopeId","data-v-2b282558"]]),$t=t.createElementVNode("p",null,"Available wallets :",-1),U={__name:"AvailableWallets",setup(o){return(e,n)=>{const s=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(s,null,{default:t.withCtx(()=>[$t,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(r).wallets,a=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(a.name),1))),256))])]),_:1})}}},xt={class:"SelectNetworkDropdown"},Tt={key:0,selected:""},jt=["src","alt"],At=["onClick"],Mt=["src","alt"],L={__name:"SelectNetworkDropdown",setup(o){let e=t.ref({}),n=t.ref([]);r.onSafe(async function(){e.value=await r.config.networks.getCurrent(),n.value=r.config.networks.getAvailable(),n.value=n.value.filter(l=>l!=e.value)});async function s(l){const d=n.value.find(h=>h.chainId===parseInt(l));if(d){l=f.ethers.utils.hexlify(parseInt(l)).toString(),l=f.ethers.utils.hexValue(l);try{await window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch(h){h.code===4902&&await window.ethereum.request({method:"wallet_addEthereumChain",params:[{chainId:l,rpcUrls:[d.defaultRPC],chainName:d.name,nativeCurrency:{name:d.currency.symbol,symbol:d.currency.symbol,decimals:d.currency.decimals},blockExplorerUrls:d.explorer&&d.explorer.url!==""?[d.explorer.url]:null}]})}}}function a(){c.value=!c.value}let c=t.ref(!1);return(l,d)=>{const h=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(h,null,{default:t.withCtx(()=>[t.createElementVNode("div",xt,[t.createElementVNode("ul",{onClick:a},[e.value?(t.openBlock(),t.createElementBlock("li",Tt,[t.createElementVNode("img",{width:"40",src:e.value.icon?e.value.icon:t.unref(r).config.defaults.networks.icon,alt:e.value.name+" logo"},null,8,jt),t.createElementVNode("p",null,t.toDisplayString(e.value.displayName),1)])):t.createCommentVNode("",!0),c.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(n.value,u=>(t.openBlock(),t.createElementBlock("li",{key:u.chainId,onClick:at=>s(u.chainId)},[t.createElementVNode("img",{width:"40",src:u.icon?u.icon:t.unref(r).config.defaults.networks.icon,alt:u.name+" logo"},null,8,Mt),t.createElementVNode("p",null,t.toDisplayString(u.displayName),1)],8,At))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},R={__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})}},P={__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})}},ie="",q=o=>(t.pushScopeId("data-v-d83f3980"),o=o(),t.popScopeId(),o),Ut=q(()=>t.createElementVNode("h3",null,"Safe Runners",-1)),Lt=q(()=>t.createElementVNode("h3",null,"Status",-1)),H=A({__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,[Ut,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"DApp safe : "+t.toDisplayString(t.unref(r).isSafe),1),t.createElementVNode("li",null,"Network safe : "+t.toDisplayString(t.unref(r).provider.isSafe),1),t.createElementVNode("li",null,"Wallet 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,c)=>(t.openBlock(),t.createElementBlock("li",null,[t.createTextVNode(" contract "+t.toDisplayString(c)+" : ",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,[Lt,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,c)=>(t.openBlock(),t.createElementBlock("li",null," contract "+t.toDisplayString(c)+" : "+t.toDisplayString(a.status.get()),1))),256))])])])]),_:1})}}},[["__scopeId","data-v-d83f3980"]]),Ft={class:"InputUnits"},Gt=["placeholder"],qt=["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 c=t.ref("wei");function l(){if(s.value){const d=f.ethers.utils.parseUnits(s.value,c.value);e("update:modelValue",d)}}return(d,h)=>(t.openBlock(),t.createElementBlock("div",Ft,[t.withDirectives(t.createElementVNode("input",{onInput:l,"onUpdate:modelValue":h[0]||(h[0]=u=>s.value=u),type:"text",placeholder:t.unref(n).placeholder},null,40,Gt),[[t.vModelText,s.value]]),t.withDirectives(t.createElementVNode("select",{onChange:l,"onUpdate:modelValue":h[1]||(h[1]=u=>c.value=u)},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(a,u=>t.createElementVNode("option",{value:u},t.toDisplayString(u),9,qt)),64))],544),[[t.vModelSelect,c.value]])]))}},Ht=Object.freeze(Object.defineProperty({__proto__:null,InputUnits:W,styleLevelProp:k,ContractInteractor:j,MethodsInteractor:C,MethodInteractor:O,EventsInteractor:b,EventInteractor:N,Transact:I,ConnectWalletButton:M,AvailableWallets:U,SelectNetworkDropdown:L,OnDappSafe:R,OnProviderSafe:B,OnSignerSafe:D,OnContractsReadSafe:F,OnContractsWriteSafe:G,OnContractReadSafe:V,OnContractWriteSafe:P,DebugBar:H},Symbol.toStringTag,{value:"Module"}));class y{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 E(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}`;m(this._state,e),console.log(`Status '${this._name}' set to '${E(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)}}const p={style:{level:"minimal"},networks:[{name:"Ethereum Mainnet",displayName:"Ethereum",chainId: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)",chainId: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)",chainId: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)",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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:[{name:"metamask",displayName:"Metamask",icon:null},{name:"binanceChain",displayName:"Binance Chain",icon:null},{name:"coinbase",displayName:"Coinbase",icon:null}],defaults:{networks:{icon:"https://static.tuli.pe/icons/networks/unknown.svg"},wallets:{icon:"TODO"}}};class Zt{constructor(e=null){let n={};return e?n=_({...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 Yt{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.chainId){const s=p.networks.find(c=>c.chainId===n.chainId),a=_({...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.chainId===n.chainId)||(n.available=!1,this._list.push(n))}async getCurrent(){if(r.provider.proxy.getEthersObject()){const e=await r.provider.getNetwork().then(n=>n.chainId);return this._list.find(n=>n.chainId===e)}return null}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class zt{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.name){const s=p.wallets.find(c=>c.name===n.name),a=_({...s},{...n});a.available!==!1&&(a.available=!0),a.displayName||(a.displayName=a.name),this._list.push(a)}}for(const n of p.wallets)this._list.find(a=>a.name===n.name)||(n.available=!1,this._list.push(n))}async getCurrent(){if(r.signer.getEthersObject()){const e=r.signer.name;return this._list.find(n=>n.name===e)}return null}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class Kt{constructor(e=null){let n={};return e?n=_({...p.defaults},{...e}):n=p.defaults,n}}class Z{constructor(e=null){this.style=new Zt(e?e.style:null),this.networks=new Yt(e?e.networks:null),this.wallets=new zt(e?e.wallets:null),this.defaults=new Kt(e?e.defaults:null)}}class Y{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 K(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 Q(e))}removeContractWatcher(e){Object.keys(this.wallets).includes(e)&&delete this.wallets[e]}}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(!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 K 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 a=this._buildSourceName(e,n);let c=!1;Object.keys(this.sources).includes(a)||(this.sources[a]={name:e,args:n,state:t.ref(null),dependents:{}},c=!0);let l=null;s&&(l=t.watch(this.sources[a].state,s));const d=this._generateDependentUUID();return this.sources[a].dependents[d]=l,c&&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 c=this.sources[a].dependents[s];c&&c(),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 Q extends z{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 c=null;s&&(c=watch(this.sources[a].state,s));const l=this._generateDependentUUID();return this.sources[a].dependents[l]=c,newSource&&this._updateState(this.sources[a]),l}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 c=this.sources[a].dependents[s];c&&c(),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}}function Qt(o){for(var e=[];o&&o!==Object.prototype;)e.push.apply(e,Object.getOwnPropertyNames(o)),o=Object.getPrototypeOf(o);return e}class Jt{constructor(e){this._parent=e}setEthersObject(e){this._parent._ethersObject=e&&t.markRaw(e),this.extendsEthersObject()}getEthersObject(){return this._parent._ethersObject}extendsEthersObject(){if(this._parent._ethersObject&&this._parent._extensionObject){const e=Qt(this._parent._extensionObject);for(const n of e)if(n!=="constructor")try{this._parent._ethersObject[n]=this._parent._extensionObject[n].bind(this._parent._ethersObject)}catch(s){if(s instanceof TypeError)this._parent._ethersObject[n]=this._parent._extensionObject[n];else throw s}}}}class g{constructor(e=null,n=null){return this._ethersObject=null,this._extensionObject=n,this.proxy=new Jt(this),this.proxy.setEthersObject(e),new Proxy(this,{get:function(s,a,c){if(s._ethersObject&&s._ethersObject[a])try{return s._ethersObject[a].bind(s._ethersObject)}catch(l){if(l.message.includes(".bind is not a function"))return s._ethersObject[a];throw l}else if(s[a])return s[a]},set:function(s,a,c){return s._ethersObject&&s._ethersObject[a]?(s._ethersObject[a]=c,!0):(s[a]=c,!0)}})}}class Xt{}class J extends g{constructor(e=null){const n=new Xt;super(e,n),this.status=new y("provider",["DISCONNECTED","WRONG","ERROR","CONNECTED"]),this.isSafe=t.computed(()=>r.isSafe.value&&!this.status.isIn(["DISCONNECTED","ERROR"])),this.OnSafe=B,this._asyncInit()}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.setEthersObject(new f.ethers.providers.Web3Provider(e,"any"));else{const n=r.config.networks.getDefault();n&&n.defaultRPC&&this.proxy.setEthersObject(new f.ethers.providers.JsonRpcProvider(n.defaultRPC))}}async _asyncInit(){if(await this._initProviderConnection(),!this._ethersObject)this.status.set("DISCONNECTED");else{const e=await this.getNetwork();let n=await r.config.networks.getAvailable().find(s=>s.chainId===e.chainId);if(n)this.status.set("CONNECTED");else if(this.status.set("WRONG"),n=r.config.networks.getAll().find(s=>s.chainId===e.chainId),!n){const s={name:e.name,displayName:T(e.name),chainId:e.chainId};r.config.network.append(s)}this.on("network",(s,a)=>{a&&a!==s&&window.location.reload()}),this.on("error",()=>{this.status.set("ERROR")}),n&&n.pollingInterval&&(this.pollingInterval=n.pollingInterval)}}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 vt{}class X extends g{constructor(e=null){const n=new vt;super(e,n),this.status=new y("signer",["DISCONNECTED","REQUESTED","REFUSED","ERROR","NO_PROVIDER","WRONG_PROVIDER","CONNECTED"]),r.provider.status.watchAny(s=>{s==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(s)&&this.status.set("NO_PROVIDER")}),this.status.watch(["REFUSED","ERROR"],()=>{setTimeout(()=>{this.status.set("DISCONNECTED")},5e3)}),this.isSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("CONNECTED")),this.OnSafe=D,this.address=t.ref(null),this._asyncInit()}async _asyncInit(){const e=this;r.provider.onSafe(async function(){for(const n of Object.values(r.wallets))await e.connectWallet(n,!0)})}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.setEthersObject(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.setEthersObject(null),this.address.value=null,r.signer.status.set("DISCONNECTED")}}class v{constructor(){this.provider=null,this.name=""}getProvider(){return null}async connect(){throw`connect() method of ${this.name} wallet is not implemented.`}}class w extends Error{constructor(e,...n){super(e,...n),this.message=`${e} wallet has rejected the connection request.`}}class tt extends v{constructor(){super(),this.name="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.name):e}}}class te extends v{constructor(e,n={}){super(),this.name="Coinbase";const s=n.appName||"",a=n.appLogoUrl,c=n.darkMode||!1;this.coinbaseWalletSdk=new e({appName:s,appLogoUrl:a,darkMode:c}),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.name)}}}class ee extends tt{constructor(){super(),this.name="BinanceChain"}getProvider(){return window.BinanceChain}}class et{constructor(){const e=r.config.wallets.getAvailable();for(const n of e){const s=nt[n.name];s&&(this[n.name]=new s)}}}const nt={metamask:tt,coinbase:te,binanceChain:ee};class ne{_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 c=this._watch(e,n,s);return a?t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,c)},a):t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,c)}),r.chainWatchers.contracts[this.address].remove.bind(r.chainWatchers.contracts[this.address],e,n,c)}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 $ extends g{constructor(e,n){const s=new ne;super(n,s),this.name=e,this.status=new y(`contract:${e}`,["NO_PROVIDER","WRONG_PROVIDER","ERROR","INITIALIZED"]),r.provider.status.watchAny(a=>{a==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(a)&&this.status.set("NO_PROVIDER")}),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(P,{contract:this.name}),this._asyncInit()}_watchSignerChanges(e,n){t.watch([r.signer.isSafe],(s,a)=>{console.log("Refresh contract "+this.name),s!==a&&(this.proxy.setEthersObject(null),this._updateContract(e,n))})}_updateContract(e,n){if(r.signer.isSafe.value)this.proxy.setEthersObject(new f.ethers.Contract(e,n,r.signer.proxy.getEthersObject()));else if(r.provider.isSafe.value)this.proxy.setEthersObject(new f.ethers.Contract(e,n,r.provider.proxy.getEthersObject()));else throw`_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`}async _asyncInit(){const e=this;r.provider.onSafe(async function(){try{const n=await r.config.networks.getCurrent();if(n.contracts&&Object.keys(n.contracts).includes(e.name)){const s=n.contracts[e.name];e._updateContract(s.address,s.abi),e._watchSignerChanges(s.address,s.abi),e.status.set("INITIALIZED")}else e.status.set("WRONG_PROVIDER")}catch(n){throw e.status.set("ERROR"),n}})}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())})}}}class st{constructor(){this.status=new y("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())})}}}class se{}class x extends g{constructor(e,n,s=[],a={value:0}){super(null,new se),this.contractName=e,this.methodName=n,this.methodInfos={},this.args=t.ref(s),this.txArgs=t.ref(a),this.status=new y(`tx:${e}:${n}`,["NOT_READY","READY","SENT","ERROR","SUCCESS"]),this.status.watch(["ERROR","SUCCESS"],()=>{setTimeout(()=>{this.status.set("READY")},3e3)}),this.data=t.ref([]),this.error=t.ref(null),this.call=null,this._init()}_init(){r.contracts[this.contractName].isReadSafe.value&&this._initEthersObject(),r.contracts[this.contractName].onReadSafe(()=>{this._initEthersObject()})}_initEthersObject(){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.setEthersObject(r.contracts[this.contractName][this.methodName]),this.status.set("READY")}send(e=null,n=null){e=e||E(this.args),n=n||E(this.txArgs),e?Array.isArray(e)?this.call=this.proxy.getEthersObject()(...e,n):this.call=this.proxy.getEthersObject()(e,n):this.call=this.proxy.getEthersObject()(n),this.status.set("SENT"),this.methodInfos.constant?this.call.then(s=>{Array.isArray(s)||(s=[s]),m(this.data,s),m(this.error,null),this.status.set("SUCCESS")}).catch(s=>{m(this.error,s),this.status.set("ERROR")}):this.call.then(s=>s.wait()).then(s=>{Array.isArray(s)||(s=[s]),m(this.data,s),m(this.error,null),this.status.set("SUCCESS")}).catch(s=>{m(this.error,s),this.status.set("ERROR")})}}async function ae(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=E,o.config.globalProperties.rSet=m,window.dapp=r;const s=await Promise.resolve().then(()=>Ht);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 i.AvailableWallets=U,i.ChainWatchersList=Y,i.ConnectWalletButton=M,i.ContractInteractor=j,i.ContractWatcher=K,i.ContractsList=st,i.DebugBar=H,i.EthersContractProxy=$,i.EthersProviderProxy=J,i.EthersSignerProxy=X,i.EthersTransactionProxy=x,i.EventInteractor=N,i.EventsInteractor=b,i.InputUnits=W,i.MethodInteractor=O,i.MethodsInteractor=C,i.OnContractReadSafe=V,i.OnContractWriteSafe=P,i.OnContractsReadSafe=F,i.OnContractsWriteSafe=G,i.OnDappSafe=R,i.OnProviderSafe=B,i.OnSignerSafe=D,i.SelectNetworkDropdown=L,i.Status=y,i.Transact=I,i.TulipeConfig=Z,i.WalletConnectionRejected=w,i.WalletWatcher=Q,i.WalletsList=et,i.capitalizeWords=T,i.dapp=r,i.deepMerge=_,i.initTulipe=ae,i.isObject=S,i.rGet=E,i.rSet=m,i.styleLevelProp=k,i.wallets=nt,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),i}({},vue,ethers);
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);

@@ -1,1 +0,1 @@

(function(i,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("ethers")):typeof define=="function"&&define.amd?define(["exports","vue","ethers"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.Tulipe={},i.vue,i.ethers))})(this,function(i,t,f){"use strict";class rt{constructor(){}init(e=null){this.config=new Z(e),this.status=new y("dapp",["UNSAFE","ERROR","INITIALIZED"]),this.isSafe=t.computed(()=>this.status.is("INITIALIZED")),this.OnSafe=R,this.chainWatchers=new Y,this.wallets=new et,this.provider=new J,this.pro=this.provider,this.signer=new X,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 r=new rt;function S(o){return o&&typeof o=="object"&&!Array.isArray(o)}function _(o,...e){if(!e.length)return o;const n=e.shift();if(S(o)&&S(n))for(const s in n)S(n[s])?(o[s]||Object.assign(o,{[s]:{}}),_(o[s],n[s])):Object.assign(o,{[s]:n[s]});return _(o,...e)}function T(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 E(o){return t.isRef(o)?o.value:o}function m(o,e){t.isRef(o)?o.value=e:o=e}const re="",k={required:!1,type:String,default:"minimal",validator(o){return["unstylized","minimal","opinionated"].includes(o)}},ot={class:"ContractInteractor"},ct=t.createTextVNode(" Methods : "),it=t.createElementVNode("br",null,null,-1),lt=t.createTextVNode(" Events : "),dt=t.createElementVNode("br",null,null,-1),j={__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,c)=>{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(s.value),1),t.createElementVNode("li",null,[ct,it,t.createVNode(t.unref(C),{contract:e.contract},null,8,["contract"])]),t.createElementVNode("li",null,[lt,dt,t.createVNode(t.unref(N),{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=r.contracts[e.contract];return(s,a)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{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(O),{contract:e.contract,method:d},null,8,["contract","method"])]))),256))])])]),_:1},8,["contract"])}}},ut={class:"MethodInteractor"},mt={key:0},pt=t.createElementVNode("p",null,"Inputs :",-1),ft=["onUpdate:modelValue","placeholder"],_t={key:0},yt={key:1},Et=t.createElementVNode("p",null,"Outputs :",-1),St=["onUpdate:modelValue","placeholder"],gt=["placeholder"],wt={key:2},O={__name:"MethodInteractor",props:{contract:{type:String,required:!0},method:{type:String,required:!0}},setup(o){const e=o,n=t.shallowRef(new x(e.contract,e.method));function s(a){return`${a.name&&a.name!=="null"?a.name:""} (${a.type})`}return(a,c)=>{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(I),{contract:e.contract,method:e.method,modelValue:n.value,"onUpdate:modelValue":c[0]||(c[0]=d=>n.value=d),configs:{content:e.method,notx:!0,noerror:!0}},null,8,["contract","method","modelValue","configs"]),t.createElementVNode("small",null,t.toDisplayString(n.value.methodInfos.stateMutability),1),Object.keys(n.value.methodInfos.inputs).length>0||n.value.methodInfos.payable?(t.openBlock(),t.createElementBlock("div",mt,[pt,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.value.methodInfos.inputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":u=>n.value.args[h]=u,type:"text",placeholder:s(d)},null,8,ft),[[t.vModelText,n.value.args[h]]])]))),256)),n.value.methodInfos.payable?(t.openBlock(),t.createElementBlock("li",_t,[t.createVNode(t.unref(W),{modelValue:n.value.txArgs.value.value,"onUpdate:modelValue":c[1]||(c[1]=d=>n.value.txArgs.value.value=d)},null,8,["modelValue"])])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),Object.keys(n.value.methodInfos.outputs).length>0?(t.openBlock(),t.createElementBlock("div",yt,[Et,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.value.methodInfos.outputs,(d,h)=>(t.openBlock(),t.createElementBlock("li",null,[n.value.data.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:0,"onUpdate:modelValue":u=>n.value.data.value[h]=u,type:"text",placeholder:s(d),disabled:""},null,8,St)),[[t.vModelText,n.value.data.value[h]]]):(t.openBlock(),t.createElementBlock("input",{key:1,type:"text",placeholder:s(d),disabled:""},null,8,gt))]))),256))])])):t.createCommentVNode("",!0),n.value.status.is("ERROR")?(t.openBlock(),t.createElementBlock("p",wt,t.toDisplayString(n.value.error.value.reason),1)):t.createCommentVNode("",!0)])]),_:1},8,["contract"])}}},kt={class:"EventsInteractor"},N={__name:"EventsInteractor",props:{contract:{type:String,required:!0}},setup(o){const e=o,n=r.contracts[e.contract];return(s,a)=>{const c=t.resolveComponent("OnContractReadSafe");return t.openBlock(),t.createBlock(c,{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(b),{contract:e.contract,event:d},null,8,["contract","event"])]))),256))])])]),_:1},8,["contract"])}}},Ct={class:"EventInteractor"},Ot=t.createTextVNode("Logs: "),b={__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({}),c=t.ref(0),l=t.ref([]);return n.onReadSafe(()=>{s.value=n.interface.events[e.event],a.value=n.filters[s.value.name],n.on(a.value,d=>{c.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",Ct,[t.createElementVNode("p",null,t.toDisplayString(s.value.name),1),t.createElementVNode("ul",null,[t.createElementVNode("li",null,"Count : "+t.toDisplayString(c.value),1),t.createElementVNode("li",null,[Ot,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.value,at=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(at),1))),256))])])])])]),_:1},8,["contract"])}}},Nt={class:"TransactButton"},bt={key:1,disabled:""},It={key:2,disabled:""},Rt={key:3,disabled:""},Bt={key:4},I={__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(l){e("update:modelValue",l)}});function c(){const l=n.args?n.args:[],d=n.txArgs?n.txArgs:{};a.value.send(l,d)}return n.config&&n.configs.notx&&s.onReadSafe(()=>{a=new x(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",Nt,[t.unref(a).status.is("READY")?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:c},t.toDisplayString(n.configs&&n.configs.content?n.configs.content:"Transact"),1)):t.unref(a).status.is("SENT")?(t.openBlock(),t.createElementBlock("button",bt,"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",Rt,"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"])}}},oe="",A=(o,e)=>{const n=o.__vccOpts||o;for(const[s,a]of e)n[s]=a;return n},Dt={key:1,disabled:""},Vt={key:2,disabled:""},Pt={key:3,disabled:""},Wt={key:4,disabled:""},M=A({__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]=c=>t.unref(r).signer.connectWallet(t.unref(r).wallets.metamask))},"Connect Wallet")):t.unref(r).signer.status.is("REQUESTED")?(t.openBlock(),t.createElementBlock("button",Dt,"Connection requested...")):t.unref(r).signer.status.is("REFUSED")?(t.openBlock(),t.createElementBlock("button",Vt,"Connection refused!")):t.unref(r).signer.status.is("ERROR")?(t.openBlock(),t.createElementBlock("button",Pt,"Connection error!")):t.unref(r).provider.status.is("WRONG")?(t.openBlock(),t.createElementBlock("button",Wt,"Wrong network! ("+t.toDisplayString(t.unref(n)?t.unref(n).value.displayName:"unknown")+")",1)):t.unref(r).signer.status.is("CONNECTED")?(t.openBlock(),t.createElementBlock("button",{key:5,onClick:a[1]||(a[1]=(...c)=>t.unref(r).signer.disconnectWallet&&t.unref(r).signer.disconnectWallet(...c))},"Disconnect")):t.createCommentVNode("",!0)],2)]),_:1}))}},[["__scopeId","data-v-2b282558"]]),$t=t.createElementVNode("p",null,"Available wallets :",-1),U={__name:"AvailableWallets",setup(o){return(e,n)=>{const s=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(s,null,{default:t.withCtx(()=>[$t,t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(r).wallets,a=>(t.openBlock(),t.createElementBlock("li",null,t.toDisplayString(a.name),1))),256))])]),_:1})}}},xt={class:"SelectNetworkDropdown"},Tt={key:0,selected:""},jt=["src","alt"],At=["onClick"],Mt=["src","alt"],L={__name:"SelectNetworkDropdown",setup(o){let e=t.ref({}),n=t.ref([]);r.onSafe(async function(){e.value=await r.config.networks.getCurrent(),n.value=r.config.networks.getAvailable(),n.value=n.value.filter(l=>l!=e.value)});async function s(l){const d=n.value.find(h=>h.chainId===parseInt(l));if(d){l=f.ethers.utils.hexlify(parseInt(l)).toString(),l=f.ethers.utils.hexValue(l);try{await window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch(h){h.code===4902&&await window.ethereum.request({method:"wallet_addEthereumChain",params:[{chainId:l,rpcUrls:[d.defaultRPC],chainName:d.name,nativeCurrency:{name:d.currency.symbol,symbol:d.currency.symbol,decimals:d.currency.decimals},blockExplorerUrls:d.explorer&&d.explorer.url!==""?[d.explorer.url]:null}]})}}}function a(){c.value=!c.value}let c=t.ref(!1);return(l,d)=>{const h=t.resolveComponent("OnDappSafe");return t.openBlock(),t.createBlock(h,null,{default:t.withCtx(()=>[t.createElementVNode("div",xt,[t.createElementVNode("ul",{onClick:a},[e.value?(t.openBlock(),t.createElementBlock("li",Tt,[t.createElementVNode("img",{width:"40",src:e.value.icon?e.value.icon:t.unref(r).config.defaults.networks.icon,alt:e.value.name+" logo"},null,8,jt),t.createElementVNode("p",null,t.toDisplayString(e.value.displayName),1)])):t.createCommentVNode("",!0),c.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(n.value,u=>(t.openBlock(),t.createElementBlock("li",{key:u.chainId,onClick:at=>s(u.chainId)},[t.createElementVNode("img",{width:"40",src:u.icon?u.icon:t.unref(r).config.defaults.networks.icon,alt:u.name+" logo"},null,8,Mt),t.createElementVNode("p",null,t.toDisplayString(u.displayName),1)],8,At))),128)):t.createCommentVNode("",!0)])])]),_:1})}}},R={__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})}},P={__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})}},ie="",q=o=>(t.pushScopeId("data-v-d83f3980"),o=o(),t.popScopeId(),o),Ut=q(()=>t.createElementVNode("h3",null,"Safe Runners",-1)),Lt=q(()=>t.createElementVNode("h3",null,"Status",-1)),H=A({__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,[Ut,t.createElementVNode("ul",null,[t.createElementVNode("li",null,"DApp safe : "+t.toDisplayString(t.unref(r).isSafe),1),t.createElementVNode("li",null,"Network safe : "+t.toDisplayString(t.unref(r).provider.isSafe),1),t.createElementVNode("li",null,"Wallet 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,c)=>(t.openBlock(),t.createElementBlock("li",null,[t.createTextVNode(" contract "+t.toDisplayString(c)+" : ",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,[Lt,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,c)=>(t.openBlock(),t.createElementBlock("li",null," contract "+t.toDisplayString(c)+" : "+t.toDisplayString(a.status.get()),1))),256))])])])]),_:1})}}},[["__scopeId","data-v-d83f3980"]]),Ft={class:"InputUnits"},Gt=["placeholder"],qt=["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 c=t.ref("wei");function l(){if(s.value){const d=f.ethers.utils.parseUnits(s.value,c.value);e("update:modelValue",d)}}return(d,h)=>(t.openBlock(),t.createElementBlock("div",Ft,[t.withDirectives(t.createElementVNode("input",{onInput:l,"onUpdate:modelValue":h[0]||(h[0]=u=>s.value=u),type:"text",placeholder:t.unref(n).placeholder},null,40,Gt),[[t.vModelText,s.value]]),t.withDirectives(t.createElementVNode("select",{onChange:l,"onUpdate:modelValue":h[1]||(h[1]=u=>c.value=u)},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(a,u=>t.createElementVNode("option",{value:u},t.toDisplayString(u),9,qt)),64))],544),[[t.vModelSelect,c.value]])]))}},Ht=Object.freeze(Object.defineProperty({__proto__:null,InputUnits:W,styleLevelProp:k,ContractInteractor:j,MethodsInteractor:C,MethodInteractor:O,EventsInteractor:N,EventInteractor:b,Transact:I,ConnectWalletButton:M,AvailableWallets:U,SelectNetworkDropdown:L,OnDappSafe:R,OnProviderSafe:B,OnSignerSafe:D,OnContractsReadSafe:F,OnContractsWriteSafe:G,OnContractReadSafe:V,OnContractWriteSafe:P,DebugBar:H},Symbol.toStringTag,{value:"Module"}));class y{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 E(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}`;m(this._state,e),console.log(`Status '${this._name}' set to '${E(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)}}const p={style:{level:"minimal"},networks:[{name:"Ethereum Mainnet",displayName:"Ethereum",chainId: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)",chainId: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)",chainId: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)",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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",chainId: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:[{name:"metamask",displayName:"Metamask",icon:null},{name:"binanceChain",displayName:"Binance Chain",icon:null},{name:"coinbase",displayName:"Coinbase",icon:null}],defaults:{networks:{icon:"https://static.tuli.pe/icons/networks/unknown.svg"},wallets:{icon:"TODO"}}};class Zt{constructor(e=null){let n={};return e?n=_({...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 Yt{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.chainId){const s=p.networks.find(c=>c.chainId===n.chainId),a=_({...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.chainId===n.chainId)||(n.available=!1,this._list.push(n))}async getCurrent(){if(r.provider.proxy.getEthersObject()){const e=await r.provider.getNetwork().then(n=>n.chainId);return this._list.find(n=>n.chainId===e)}return null}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class zt{constructor(e=null){if(this._list=[],e){for(const n of e)if(n.name){const s=p.wallets.find(c=>c.name===n.name),a=_({...s},{...n});a.available!==!1&&(a.available=!0),a.displayName||(a.displayName=a.name),this._list.push(a)}}for(const n of p.wallets)this._list.find(a=>a.name===n.name)||(n.available=!1,this._list.push(n))}async getCurrent(){if(r.signer.getEthersObject()){const e=r.signer.name;return this._list.find(n=>n.name===e)}return null}getDefault(){return this._list.find(e=>e.default===!0)}getAvailable(){return this._list.filter(e=>e.available)}getAll(){return this._list}}class Kt{constructor(e=null){let n={};return e?n=_({...p.defaults},{...e}):n=p.defaults,n}}class Z{constructor(e=null){this.style=new Zt(e?e.style:null),this.networks=new Yt(e?e.networks:null),this.wallets=new zt(e?e.wallets:null),this.defaults=new Kt(e?e.defaults:null)}}class Y{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 K(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 Q(e))}removeContractWatcher(e){Object.keys(this.wallets).includes(e)&&delete this.wallets[e]}}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(!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 K 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 a=this._buildSourceName(e,n);let c=!1;Object.keys(this.sources).includes(a)||(this.sources[a]={name:e,args:n,state:t.ref(null),dependents:{}},c=!0);let l=null;s&&(l=t.watch(this.sources[a].state,s));const d=this._generateDependentUUID();return this.sources[a].dependents[d]=l,c&&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 c=this.sources[a].dependents[s];c&&c(),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 Q extends z{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 c=null;s&&(c=watch(this.sources[a].state,s));const l=this._generateDependentUUID();return this.sources[a].dependents[l]=c,newSource&&this._updateState(this.sources[a]),l}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 c=this.sources[a].dependents[s];c&&c(),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}}function Qt(o){for(var e=[];o&&o!==Object.prototype;)e.push.apply(e,Object.getOwnPropertyNames(o)),o=Object.getPrototypeOf(o);return e}class Jt{constructor(e){this._parent=e}setEthersObject(e){this._parent._ethersObject=e&&t.markRaw(e),this.extendsEthersObject()}getEthersObject(){return this._parent._ethersObject}extendsEthersObject(){if(this._parent._ethersObject&&this._parent._extensionObject){const e=Qt(this._parent._extensionObject);for(const n of e)if(n!=="constructor")try{this._parent._ethersObject[n]=this._parent._extensionObject[n].bind(this._parent._ethersObject)}catch(s){if(s instanceof TypeError)this._parent._ethersObject[n]=this._parent._extensionObject[n];else throw s}}}}class g{constructor(e=null,n=null){return this._ethersObject=null,this._extensionObject=n,this.proxy=new Jt(this),this.proxy.setEthersObject(e),new Proxy(this,{get:function(s,a,c){if(s._ethersObject&&s._ethersObject[a])try{return s._ethersObject[a].bind(s._ethersObject)}catch(l){if(l.message.includes(".bind is not a function"))return s._ethersObject[a];throw l}else if(s[a])return s[a]},set:function(s,a,c){return s._ethersObject&&s._ethersObject[a]?(s._ethersObject[a]=c,!0):(s[a]=c,!0)}})}}class Xt{}class J extends g{constructor(e=null){const n=new Xt;super(e,n),this.status=new y("provider",["DISCONNECTED","WRONG","ERROR","CONNECTED"]),this.isSafe=t.computed(()=>r.isSafe.value&&!this.status.isIn(["DISCONNECTED","ERROR"])),this.OnSafe=B,this._asyncInit()}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.setEthersObject(new f.ethers.providers.Web3Provider(e,"any"));else{const n=r.config.networks.getDefault();n&&n.defaultRPC&&this.proxy.setEthersObject(new f.ethers.providers.JsonRpcProvider(n.defaultRPC))}}async _asyncInit(){if(await this._initProviderConnection(),!this._ethersObject)this.status.set("DISCONNECTED");else{const e=await this.getNetwork();let n=await r.config.networks.getAvailable().find(s=>s.chainId===e.chainId);if(n)this.status.set("CONNECTED");else if(this.status.set("WRONG"),n=r.config.networks.getAll().find(s=>s.chainId===e.chainId),!n){const s={name:e.name,displayName:T(e.name),chainId:e.chainId};r.config.network.append(s)}this.on("network",(s,a)=>{a&&a!==s&&window.location.reload()}),this.on("error",()=>{this.status.set("ERROR")}),n&&n.pollingInterval&&(this.pollingInterval=n.pollingInterval)}}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 vt{}class X extends g{constructor(e=null){const n=new vt;super(e,n),this.status=new y("signer",["DISCONNECTED","REQUESTED","REFUSED","ERROR","NO_PROVIDER","WRONG_PROVIDER","CONNECTED"]),r.provider.status.watchAny(s=>{s==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(s)&&this.status.set("NO_PROVIDER")}),this.status.watch(["REFUSED","ERROR"],()=>{setTimeout(()=>{this.status.set("DISCONNECTED")},5e3)}),this.isSafe=t.computed(()=>r.provider.isSafe.value&&this.status.is("CONNECTED")),this.OnSafe=D,this.address=t.ref(null),this._asyncInit()}async _asyncInit(){const e=this;r.provider.onSafe(async function(){for(const n of Object.values(r.wallets))await e.connectWallet(n,!0)})}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.setEthersObject(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.setEthersObject(null),this.address.value=null,r.signer.status.set("DISCONNECTED")}}class v{constructor(){this.provider=null,this.name=""}getProvider(){return null}async connect(){throw`connect() method of ${this.name} wallet is not implemented.`}}class w extends Error{constructor(e,...n){super(e,...n),this.message=`${e} wallet has rejected the connection request.`}}class tt extends v{constructor(){super(),this.name="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.name):e}}}class te extends v{constructor(e,n={}){super(),this.name="Coinbase";const s=n.appName||"",a=n.appLogoUrl,c=n.darkMode||!1;this.coinbaseWalletSdk=new e({appName:s,appLogoUrl:a,darkMode:c}),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.name)}}}class ee extends tt{constructor(){super(),this.name="BinanceChain"}getProvider(){return window.BinanceChain}}class et{constructor(){const e=r.config.wallets.getAvailable();for(const n of e){const s=nt[n.name];s&&(this[n.name]=new s)}}}const nt={metamask:tt,coinbase:te,binanceChain:ee};class ne{_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 c=this._watch(e,n,s);return a?t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,c)},a):t.onUnmounted(()=>{r.chainWatchers.contracts[this.address].remove(e,n,c)}),r.chainWatchers.contracts[this.address].remove.bind(r.chainWatchers.contracts[this.address],e,n,c)}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 $ extends g{constructor(e,n){const s=new ne;super(n,s),this.name=e,this.status=new y(`contract:${e}`,["NO_PROVIDER","WRONG_PROVIDER","ERROR","INITIALIZED"]),r.provider.status.watchAny(a=>{a==="WRONG"?this.status.set("WRONG_PROVIDER"):["DISCONNECTED","ERROR"].includes(a)&&this.status.set("NO_PROVIDER")}),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(P,{contract:this.name}),this._asyncInit()}_watchSignerChanges(e,n){t.watch([r.signer.isSafe],(s,a)=>{console.log("Refresh contract "+this.name),s!==a&&(this.proxy.setEthersObject(null),this._updateContract(e,n))})}_updateContract(e,n){if(r.signer.isSafe.value)this.proxy.setEthersObject(new f.ethers.Contract(e,n,r.signer.proxy.getEthersObject()));else if(r.provider.isSafe.value)this.proxy.setEthersObject(new f.ethers.Contract(e,n,r.provider.proxy.getEthersObject()));else throw`_updateContract() is called for contract ${this.name} but neither provider nor signer are available.`}async _asyncInit(){const e=this;r.provider.onSafe(async function(){try{const n=await r.config.networks.getCurrent();if(n.contracts&&Object.keys(n.contracts).includes(e.name)){const s=n.contracts[e.name];e._updateContract(s.address,s.abi),e._watchSignerChanges(s.address,s.abi),e.status.set("INITIALIZED")}else e.status.set("WRONG_PROVIDER")}catch(n){throw e.status.set("ERROR"),n}})}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())})}}}class st{constructor(){this.status=new y("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())})}}}class se{}class x extends g{constructor(e,n,s=[],a={value:0}){super(null,new se),this.contractName=e,this.methodName=n,this.methodInfos={},this.args=t.ref(s),this.txArgs=t.ref(a),this.status=new y(`tx:${e}:${n}`,["NOT_READY","READY","SENT","ERROR","SUCCESS"]),this.status.watch(["ERROR","SUCCESS"],()=>{setTimeout(()=>{this.status.set("READY")},3e3)}),this.data=t.ref([]),this.error=t.ref(null),this.call=null,this._init()}_init(){r.contracts[this.contractName].isReadSafe.value&&this._initEthersObject(),r.contracts[this.contractName].onReadSafe(()=>{this._initEthersObject()})}_initEthersObject(){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.setEthersObject(r.contracts[this.contractName][this.methodName]),this.status.set("READY")}send(e=null,n=null){e=e||E(this.args),n=n||E(this.txArgs),e?Array.isArray(e)?this.call=this.proxy.getEthersObject()(...e,n):this.call=this.proxy.getEthersObject()(e,n):this.call=this.proxy.getEthersObject()(n),this.status.set("SENT"),this.methodInfos.constant?this.call.then(s=>{Array.isArray(s)||(s=[s]),m(this.data,s),m(this.error,null),this.status.set("SUCCESS")}).catch(s=>{m(this.error,s),this.status.set("ERROR")}):this.call.then(s=>s.wait()).then(s=>{Array.isArray(s)||(s=[s]),m(this.data,s),m(this.error,null),this.status.set("SUCCESS")}).catch(s=>{m(this.error,s),this.status.set("ERROR")})}}async function ae(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=E,o.config.globalProperties.rSet=m,window.dapp=r;const s=await Promise.resolve().then(()=>Ht);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")}i.AvailableWallets=U,i.ChainWatchersList=Y,i.ConnectWalletButton=M,i.ContractInteractor=j,i.ContractWatcher=K,i.ContractsList=st,i.DebugBar=H,i.EthersContractProxy=$,i.EthersProviderProxy=J,i.EthersSignerProxy=X,i.EthersTransactionProxy=x,i.EventInteractor=b,i.EventsInteractor=N,i.InputUnits=W,i.MethodInteractor=O,i.MethodsInteractor=C,i.OnContractReadSafe=V,i.OnContractWriteSafe=P,i.OnContractsReadSafe=F,i.OnContractsWriteSafe=G,i.OnDappSafe=R,i.OnProviderSafe=B,i.OnSignerSafe=D,i.SelectNetworkDropdown=L,i.Status=y,i.Transact=I,i.TulipeConfig=Z,i.WalletConnectionRejected=w,i.WalletWatcher=Q,i.WalletsList=et,i.capitalizeWords=T,i.dapp=r,i.deepMerge=_,i.initTulipe=ae,i.isObject=S,i.rGet=E,i.rSet=m,i.styleLevelProp=k,i.wallets=nt,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(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"}})});
{
"name": "tulipe",
"version": "1.4.1",
"version": "1.5.0",
"private": false,

@@ -16,3 +16,2 @@ "description": "A DApp frontend framework for Vue3 built with Ethers.js",

"bugs": "https://github.com/0Lilian/tulipe/issues",
"type": "module",
"files": [

@@ -55,3 +54,3 @@ "dist"

"ethers": "^5.7.0",
"vue": "^3.2.37"
"vue": "^3.2.38"
},

@@ -69,3 +68,3 @@ "peerDependencies": {

"cz-conventional-changelog": "^3.3.0",
"hardhat": "^2.10.1",
"hardhat": "^2.10.2",
"hardhat-deploy": "^0.11.12",

@@ -72,0 +71,0 @@ "semantic-release": "^19.0.5",

**<h1 align="center">Tulipe</h1>**
<div align="center">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/0Lilian/tulipe/Build,%20Commit%20&%20Publish%20Tulipe%20Packages?label=Build">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/0Lilian/tulipe/CI-CD?label=Build">
<img alt="npm" src="https://img.shields.io/npm/v/tulipe?label=Version">
<img alt="npm" src="https://img.shields.io/npm/dw/tulipe?color=%23bcf&label=Downloads">
<img alt="Libraries.io dependency status for latest release" src="https://img.shields.io/librariesio/release/npm/tulipe?color=%23faf&label=Dependencies">
<img alt="NPM" src="https://img.shields.io/npm/l/tulipe?color=def&label=License">
<img alt="GitHub" src="https://img.shields.io/github/license/0Lilian/tulipe?color=def">
<img alt="GitHub file size in bytes" src="https://img.shields.io/github/size/0Lilian/tulipe/dist/tulipe.min.js?label=Raw size">

@@ -83,3 +83,3 @@ </div>

### Auto-instanciations
When your DApp loads, Tulipe will read your `tulipe.config.js` file and populates, if possible, the `dapp` object with all the `Ethers.js` instances your DApp requires.
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.
```js

@@ -99,3 +99,3 @@ import { dapp } from "tulipe";

## ARS (Automated Relations Safety)
### ARS (Automated Relations Safety)
While a DApp has a very unstable context (eg. a user can connect/deconnect a wallet, chain connection can be lost, etc.) it may be difficult to always write safe code.

@@ -107,3 +107,5 @@

## Safers
With the ARS you don't have anymore to think about "Have I updated my contract with the new signer ?" or "What should I do if the network changes ?" all those problems are internally and transparently managed by Tulipe.
### Safers
Also, in such an unstable context, writing safe code may became quickly complex.

@@ -110,0 +112,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc