Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Jan 7, 2025
1 parent 07434d7 commit 329e9c6
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 20 deletions.
2 changes: 1 addition & 1 deletion assets/browser-ce83a5c4.js → assets/browser-143b793d.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { g as getDefaultExportFromCjs } from "./index-960fde5b.js";
import { g as getDefaultExportFromCjs } from "./index-f92d2db5.js";
var browser = { exports: {} };
var ms;
var hasRequiredMs;
Expand Down
4 changes: 2 additions & 2 deletions assets/index-dde0a00d.js → assets/index-00eed6f6.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { a3 as __vitePreload } from "./index-960fde5b.js";
import { a3 as __vitePreload } from "./index-f92d2db5.js";
const t = Symbol();
const s = Object.getPrototypeOf, c = /* @__PURE__ */ new WeakMap(), l = (e) => e && (c.has(e) ? c.get(e) : s(e) === Object.prototype || s(e) === Array.prototype), y = (e) => l(e) && e[t] || null, h = (e, t2 = true) => {
c.set(e, t2);
Expand Down Expand Up @@ -791,7 +791,7 @@ class WalletConnectModal {
}
async initUi() {
if (typeof window !== "undefined") {
await __vitePreload(() => import("./index-d1406a8a.js"), true ? ["./index-d1406a8a.js","./index-960fde5b.js","./index-6434e334.css"] : void 0, import.meta.url);
await __vitePreload(() => import("./index-682f4657.js"), true ? ["./index-682f4657.js","./index-f92d2db5.js","./index-6434e334.css"] : void 0, import.meta.url);
const modal = document.createElement("wcm-modal");
document.body.insertAdjacentElement("beforeend", modal);
OptionsCtrl.setIsUiLoaded(true);
Expand Down
4 changes: 2 additions & 2 deletions assets/index-d1406a8a.js → assets/index-682f4657.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { T as ThemeCtrl, M as ModalCtrl, R as RouterCtrl, E as ExplorerCtrl, C as CoreUtil, a as ToastCtrl, b as EventsCtrl, O as OptionsCtrl, c as ConfigCtrl } from "./index-dde0a00d.js";
import { a8 as dijkstraExports } from "./index-960fde5b.js";
import { T as ThemeCtrl, M as ModalCtrl, R as RouterCtrl, E as ExplorerCtrl, C as CoreUtil, a as ToastCtrl, b as EventsCtrl, O as OptionsCtrl, c as ConfigCtrl } from "./index-00eed6f6.js";
import { a8 as dijkstraExports } from "./index-f92d2db5.js";
/**
* @license
* Copyright 2019 Google LLC
Expand Down
4 changes: 2 additions & 2 deletions assets/index-7116aa01.js → assets/index-d8840027.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { c as commonjsGlobal, V as bnExports, X as safeBufferExports, Y as inherits_browserExports, S as getAugmentedNamespace, Z as eventsExports, _ as buffer, $ as require$$3, a0 as eventemitter3Exports, g as getDefaultExportFromCjs } from "./index-960fde5b.js";
import { c as commonjsGlobal, V as bnExports, X as safeBufferExports, Y as inherits_browserExports, S as getAugmentedNamespace, Z as eventsExports, _ as buffer, $ as require$$3, a0 as eventemitter3Exports, g as getDefaultExportFromCjs } from "./index-f92d2db5.js";
import { p as preact_module, a as clsx_m, b as hooks_module } from "./hooks.module-1f3364a3.js";
import { b as browserExports } from "./browser-ce83a5c4.js";
import { b as browserExports } from "./browser-143b793d.js";
function _mergeNamespaces(n, m) {
for (var i = 0; i < m.length; i++) {
const e = m[i];
Expand Down
2 changes: 1 addition & 1 deletion assets/index-73f396b6.js → assets/index-e42e4945.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { c as commonjsGlobal, g as getDefaultExportFromCjs, B as BN$1, O, e as ea$2, Q as Q$2, z as z$1, a as ep, r as rm, b as ed$1, m, W as W$1, d as reactExports, f as eh$1, h as createRoot, i as rP, j as rT, k as rj, l as rC, n as rh, o as rl, p as rd, q as eD, s as ej, t as q$1, u as rp, v as r_, w as rA, x as rS, y as rs, A as W$2, C as rN, D as rc, E as rf, G as G$1, F as eM, H as ef$1, I as rx, J as decode, K as et$1, L as rD, M as ey, N as ev, P as ee$1, R as eC } from "./index-960fde5b.js";
import { c as commonjsGlobal, g as getDefaultExportFromCjs, B as BN$1, O, e as ea$2, Q as Q$2, z as z$1, a as ep, r as rm, b as ed$1, m, W as W$1, d as reactExports, f as eh$1, h as createRoot, i as rP, j as rT, k as rj, l as rC, n as rh, o as rl, p as rd, q as eD, s as ej, t as q$1, u as rp, v as r_, w as rA, x as rS, y as rs, A as W$2, C as rN, D as rc, E as rf, G as G$1, F as eM, H as ef$1, I as rx, J as decode, K as et$1, L as rD, M as ey, N as ev, P as ee$1, R as eC } from "./index-f92d2db5.js";
var sha3$1 = { exports: {} };
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
Expand Down
215 changes: 209 additions & 6 deletions assets/index-960fde5b.js → assets/index-f92d2db5.js
Original file line number Diff line number Diff line change
Expand Up @@ -8381,6 +8381,18 @@ function parseAccount(account) {
return { address: account, type: "json-rpc" };
return account;
}
class AccountNotFoundError extends BaseError$2 {
constructor({ docsPath } = {}) {
super([
"Could not find an Account to execute with this Action.",
"Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."
].join("\n"), {
docsPath,
docsSlug: "account",
name: "AccountNotFoundError"
});
}
}
const stringify$3 = (value, replacer, space) => JSON.stringify(value, (key2, value_) => {
const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
return typeof replacer === "function" ? replacer(key2, value2) : value2;
Expand Down Expand Up @@ -9339,6 +9351,26 @@ function getHttpRpcClient(url, options = {}) {
}
};
}
async function signMessage$2(client2, { account: account_ = client2.account, message: message2 }) {
if (!account_)
throw new AccountNotFoundError({
docsPath: "/docs/actions/wallet/signMessage"
});
const account = parseAccount(account_);
if (account.signMessage)
return account.signMessage({ message: message2 });
const message_ = (() => {
if (typeof message2 === "string")
return stringToHex(message2);
if (message2.raw instanceof Uint8Array)
return toHex$3(message2.raw);
return message2.raw;
})();
return client2.request({
method: "personal_sign",
params: [message_, account.address]
}, { retryCount: 0 });
}
function anumber(n4) {
if (!Number.isSafeInteger(n4) || n4 < 0)
throw new Error("positive integer expected, got " + n4);
Expand Down Expand Up @@ -11451,6 +11483,15 @@ const secp256k1$3 = createCurve$2({
}, sha256$4);
BigInt(0);
secp256k1$3.ProjectivePoint;
function getAction(client2, actionFn, name2) {
const action_implicit = client2[actionFn.name];
if (typeof action_implicit === "function")
return action_implicit;
const action_explicit = client2[name2];
if (typeof action_explicit === "function")
return action_explicit;
return (params) => actionFn(client2, params);
}
const version$6 = "2.16.0";
const getVersion$1 = () => `@wagmi/core@${version$6}`;
var __classPrivateFieldGet$5 = globalThis && globalThis.__classPrivateFieldGet || function(receiver, state, kind, f4) {
Expand Down Expand Up @@ -11554,6 +11595,61 @@ class ConnectorAlreadyConnectedError extends BaseError$1 {
});
}
}
class ConnectorNotConnectedError extends BaseError$1 {
constructor() {
super("Connector not connected.");
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "ConnectorNotConnectedError"
});
}
}
class ConnectorAccountNotFoundError extends BaseError$1 {
constructor({ address: address2, connector }) {
super(`Account "${address2}" not found for connector "${connector.name}".`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "ConnectorAccountNotFoundError"
});
}
}
class ConnectorChainMismatchError extends BaseError$1 {
constructor({ connectionChainId, connectorChainId }) {
super(`The current chain of the connector (id: ${connectorChainId}) does not match the connection's chain (id: ${connectionChainId}).`, {
metaMessages: [
`Current Chain ID: ${connectorChainId}`,
`Expected Chain ID: ${connectionChainId}`
]
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "ConnectorChainMismatchError"
});
}
}
class ConnectorUnavailableReconnectingError extends BaseError$1 {
constructor({ connector }) {
super(`Connector "${connector.name}" unavailable while reconnecting.`, {
details: [
"During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.",
"All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
"This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
].join(" ")
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "ConnectorUnavailableReconnectingError"
});
}
}
async function connect(config2, parameters) {
var _a3;
let connector;
Expand Down Expand Up @@ -11656,6 +11752,17 @@ function createTransport({ key: key2, name: name2, request, retryCount = 3, retr
value
};
}
function custom(provider, config2 = {}) {
const { key: key2 = "custom", name: name2 = "Custom Provider", retryDelay } = config2;
return ({ retryCount: defaultRetryCount }) => createTransport({
key: key2,
name: name2,
request: provider.request.bind(provider),
retryCount: config2.retryCount ?? defaultRetryCount,
retryDelay,
type: "custom"
});
}
class UrlRequiredError extends BaseError$2 {
constructor() {
super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
Expand Down Expand Up @@ -11719,6 +11826,51 @@ function http(url, config2 = {}) {
});
};
}
async function getConnectorClient(config2, parameters = {}) {
let connection;
if (parameters.connector) {
const { connector: connector2 } = parameters;
if (config2.state.status === "reconnecting" && !connector2.getAccounts && !connector2.getChainId)
throw new ConnectorUnavailableReconnectingError({ connector: connector2 });
const [accounts2, chainId2] = await Promise.all([
connector2.getAccounts(),
connector2.getChainId()
]);
connection = {
accounts: accounts2,
chainId: chainId2,
connector: connector2
};
} else
connection = config2.state.connections.get(config2.state.current);
if (!connection)
throw new ConnectorNotConnectedError();
const chainId = parameters.chainId ?? connection.chainId;
const connectorChainId = await connection.connector.getChainId();
if (connectorChainId !== connection.chainId)
throw new ConnectorChainMismatchError({
connectionChainId: connection.chainId,
connectorChainId
});
const connector = connection.connector;
if (connector.getClient)
return connector.getClient({ chainId });
const account = parseAccount(parameters.account ?? connection.accounts[0]);
account.address = getAddress$2(account.address);
if (parameters.account && !connection.accounts.some((x3) => x3.toLowerCase() === account.address.toLowerCase()))
throw new ConnectorAccountNotFoundError({
address: account.address,
connector
});
const chain = config2.chains.find((chain2) => chain2.id === chainId);
const provider = await connection.connector.getProvider({ chainId });
return createClient({
account,
chain,
name: "Connector Client",
transport: (opts) => custom(provider)({ ...opts, retryCount: 0 })
});
}
async function disconnect(config2, parameters = {}) {
var _a3, _b2;
let connector;
Expand Down Expand Up @@ -11972,6 +12124,19 @@ async function reconnect(config2, parameters = {}) {
isReconnecting = false;
return connections;
}
async function signMessage$1(config2, parameters) {
const { account, connector, ...rest } = parameters;
let client2;
if (typeof account === "object" && account.type === "local")
client2 = config2.getClient();
else
client2 = await getConnectorClient(config2, { account, connector });
const action = getAction(client2, signMessage$2, "signMessage");
return action({
...rest,
...account ? { account } : {}
});
}
class ProviderNotFoundError extends BaseError$1 {
constructor() {
super("Provider not found.");
Expand Down Expand Up @@ -13558,7 +13723,7 @@ function version4(parameters) {
options: ((_a3 = parameters.preference) == null ? void 0 : _a3.options) ?? "all"
};
})();
const { createCoinbaseWalletSDK } = await __vitePreload(() => import("./index-0a46961e.js"), true ? ["./index-0a46961e.js","./hooks.module-1f3364a3.js"] : void 0, import.meta.url);
const { createCoinbaseWalletSDK } = await __vitePreload(() => import("./index-fc8144f7.js"), true ? ["./index-fc8144f7.js","./hooks.module-1f3364a3.js"] : void 0, import.meta.url);
const sdk = createCoinbaseWalletSDK({
...parameters,
appChainIds: config2.chains.map((x3) => x3.id),
Expand Down Expand Up @@ -13730,7 +13895,7 @@ function version3(parameters) {
var _a3;
if (!walletProvider) {
const CoinbaseWalletSDK = await (async () => {
const { default: SDK } = await __vitePreload(() => import("./index-7116aa01.js").then((n4) => n4.i), true ? ["./index-7116aa01.js","./hooks.module-1f3364a3.js","./browser-ce83a5c4.js"] : void 0, import.meta.url);
const { default: SDK } = await __vitePreload(() => import("./index-d8840027.js").then((n4) => n4.i), true ? ["./index-d8840027.js","./hooks.module-1f3364a3.js","./browser-143b793d.js"] : void 0, import.meta.url);
if (typeof SDK !== "function" && typeof SDK.default === "function")
return SDK.default;
return SDK;
Expand Down Expand Up @@ -13967,7 +14132,7 @@ function metaMask$1(parameters = {}) {
async function initProvider() {
var _a3, _b2, _c2, _d2, _e3;
const MetaMaskSDK = await (async () => {
const { default: SDK } = await __vitePreload(() => import("./metamask-sdk-fbb4e0d0.js"), true ? ["./metamask-sdk-fbb4e0d0.js","./browser-ce83a5c4.js"] : void 0, import.meta.url);
const { default: SDK } = await __vitePreload(() => import("./metamask-sdk-86a011ea.js"), true ? ["./metamask-sdk-86a011ea.js","./browser-143b793d.js"] : void 0, import.meta.url);
if (typeof SDK !== "function" && typeof SDK.default === "function")
return SDK.default;
return SDK;
Expand Down Expand Up @@ -14327,7 +14492,7 @@ function walletConnect$1(parameters) {
const optionalChains = config2.chains.map((x3) => x3.id);
if (!optionalChains.length)
return;
const { EthereumProvider: EthereumProvider2 } = await __vitePreload(() => import("./index.es-561cdb20.js"), true ? [] : void 0, import.meta.url);
const { EthereumProvider: EthereumProvider2 } = await __vitePreload(() => import("./index.es-abd50b8b.js"), true ? [] : void 0, import.meta.url);
return await EthereumProvider2.init({
...parameters,
disableProviderPing: true,
Expand Down Expand Up @@ -19162,6 +19327,14 @@ function disconnectMutationOptions(config2) {
mutationKey: ["disconnect"]
};
}
function signMessageMutationOptions(config2) {
return {
mutationFn(variables) {
return signMessage$1(config2, variables);
},
mutationKey: ["signMessage"]
};
}
var QueryClientContext = reactExports.createContext(
void 0
);
Expand Down Expand Up @@ -19273,6 +19446,20 @@ function useDisconnect(parameters = {}) {
disconnectAsync: mutateAsync
};
}
function useSignMessage(parameters = {}) {
const { mutation } = parameters;
const config2 = useConfig(parameters);
const mutationOptions = signMessageMutationOptions(config2);
const { mutate, mutateAsync, ...result } = useMutation({
...mutation,
...mutationOptions
});
return {
...result,
signMessage: mutate,
signMessageAsync: mutateAsync
};
}
function n$5(n4, e12, t2, r2, i2, c2, o2) {
try {
var s2 = n4[c2](o2);
Expand Down Expand Up @@ -19536,7 +19723,7 @@ function m$3() {
case 0:
if ((typeof window === "undefined" ? "undefined" : o$1(window)) > "u")
return [2];
return [4, __vitePreload(() => import("./index-73f396b6.js"), true ? [] : void 0, import.meta.url)];
return [4, __vitePreload(() => import("./index-e42e4945.js"), true ? [] : void 0, import.meta.url)];
case 1:
l2 = s2.sent().default, f4 = h4 || ((e12 = a3.chains[0]) === null || e12 === void 0 ? void 0 : e12.id), d4 = n4.infuraId ? {} : a3.chains.reduce(function(n5, e13) {
return c$4(r$3({}, n5), t$1({}, e13.id, e13.rpcUrls.default.http[0]));
Expand Down Expand Up @@ -121631,15 +121818,31 @@ function App() {
}
function ConnectButton() {
const { onOpen } = useConnectModal();
const [sign6, setSign] = reactExports.useState("");
const { address: address2 } = useAccount();
const { disconnect: disconnect2 } = useDisconnect();
const { signMessageAsync } = useSignMessage();
if (address2) {
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
"address:",
address2
] }),
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => disconnect2(), children: "disconnect" })
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => disconnect2(), children: "disconnect" }),
/* @__PURE__ */ jsxRuntimeExports.jsx(
"button",
{
onClick: async () => {
const res = await signMessageAsync({ message: "hello" });
setSign(res);
},
children: "sign"
}
),
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
"sign:",
sign6
] })
] });
}
return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => onOpen(), children: "connect" });
Expand Down
2 changes: 1 addition & 1 deletion assets/index-0a46961e.js → assets/index-fc8144f7.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { S as getAugmentedNamespace, g as getDefaultExportFromCjs, T as bytesToHex, U as sha256, O } from "./index-960fde5b.js";
import { S as getAugmentedNamespace, g as getDefaultExportFromCjs, T as bytesToHex, U as sha256, O } from "./index-f92d2db5.js";
import { D, g, c as clsx, h, y } from "./hooks.module-1f3364a3.js";
const crypto$1 = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
const crypto$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
Expand Down
4 changes: 2 additions & 2 deletions assets/index.es-561cdb20.js → assets/index.es-abd50b8b.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Z as eventsExports, a4 as Wo, a5 as er, a6 as Ev, a3 as __vitePreload, a7 as Nr } from "./index-960fde5b.js";
import { Z as eventsExports, a4 as Wo, a5 as er, a6 as Ev, a3 as __vitePreload, a7 as Nr } from "./index-f92d2db5.js";
const R = "wc", T = "ethereum_provider", $ = `${R}@2:${T}:`, j = "https://rpc.walletconnect.org/v1/", u = ["eth_sendTransaction", "personal_sign"], y = ["eth_accounts", "eth_requestAccounts", "eth_sendRawTransaction", "eth_sign", "eth_signTransaction", "eth_signTypedData", "eth_signTypedData_v3", "eth_signTypedData_v4", "eth_sendTransaction", "personal_sign", "wallet_switchEthereumChain", "wallet_addEthereumChain", "wallet_getPermissions", "wallet_requestPermissions", "wallet_registerOnboarding", "wallet_watchAsset", "wallet_scanQRCode", "wallet_sendCalls", "wallet_getCapabilities", "wallet_getCallsStatus", "wallet_showCallsStatus"], g = ["chainChanged", "accountsChanged"], b = ["chainChanged", "accountsChanged", "message", "disconnect", "connect"];
var q = Object.defineProperty, N = Object.defineProperties, D = Object.getOwnPropertyDescriptors, M = Object.getOwnPropertySymbols, U = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable, O = (r, t, s) => t in r ? q(r, t, { enumerable: true, configurable: true, writable: true, value: s }) : r[t] = s, p = (r, t) => {
for (var s in t || (t = {}))
Expand Down Expand Up @@ -171,7 +171,7 @@ class C {
if (this.rpc = this.getRpcConfig(t), this.chainId = this.rpc.chains.length ? m(this.rpc.chains) : m(this.rpc.optionalChains), this.signer = await Ev.init({ projectId: this.rpc.projectId, metadata: this.rpc.metadata, disableProviderPing: t.disableProviderPing, relayUrl: t.relayUrl, storageOptions: t.storageOptions, customStoragePrefix: t.customStoragePrefix, telemetryEnabled: t.telemetryEnabled }), this.registerEventListeners(), await this.loadPersistedSession(), this.rpc.showQrModal) {
let s;
try {
const { WalletConnectModal: i } = await __vitePreload(() => import("./index-dde0a00d.js").then((n) => n.i), true ? ["./index-dde0a00d.js","./index-960fde5b.js","./index-6434e334.css"] : void 0, import.meta.url);
const { WalletConnectModal: i } = await __vitePreload(() => import("./index-00eed6f6.js").then((n) => n.i), true ? ["./index-00eed6f6.js","./index-f92d2db5.js","./index-6434e334.css"] : void 0, import.meta.url);
s = i;
} catch {
throw new Error("To use QR modal, please install @walletconnect/modal package");
Expand Down
Loading

0 comments on commit 329e9c6

Please sign in to comment.