User info
+
- Edit
- components/HelloWorld.vue
to test HMR
-
- Check out - create-vue, the official Vue + Vite starter -
-- Learn more about IDE Support for Vue in the - Vue Docs Scaling up Guide. -
-Click on the Vite and Vue logos to learn more
- - - diff --git a/demo/vue-app-new/src/config.ts b/demo/vue-app-new/src/config.ts index 486552beb..101d9fb5c 100644 --- a/demo/vue-app-new/src/config.ts +++ b/demo/vue-app-new/src/config.ts @@ -1,6 +1,5 @@ import { CHAIN_NAMESPACES, ChainNamespaceType, CustomChainConfig, WEB3AUTH_NETWORK, WEB3AUTH_NETWORK_TYPE } from "@web3auth/base"; -import { WhiteLabelData, LOGIN_PROVIDER } from "@toruslabs/openlogin-utils"; - +import { WhiteLabelData, LOGIN_PROVIDER, LANGUAGES, LANGUAGE_TYPE } from "@toruslabs/openlogin-utils"; export const networkOptions = Object.values(WEB3AUTH_NETWORK).map((x) => ({ name: x, value: x })); export const chainNamespaceOptions = Object.values(CHAIN_NAMESPACES).map((x) => ({ name: x, value: x })); @@ -79,3 +78,16 @@ export const initWhiteLabel: WhiteLabelData = { export const loginProviderOptions = Object.values(LOGIN_PROVIDER) .filter((x) => x !== "jwt" && x !== "webauthn") .map((x) => ({ name: x.replaceAll("_", " "), value: x })); + +export const languageOptions: { name: string; value: LANGUAGE_TYPE }[] = [ + { name: "English", value: LANGUAGES.en }, + { name: "German", value: LANGUAGES.de }, + { name: "Japanese", value: LANGUAGES.ja }, + { name: "Korean", value: LANGUAGES.ko }, + { name: "Mandarin", value: LANGUAGES.zh }, + { name: "Spanish", value: LANGUAGES.es }, + { name: "French", value: LANGUAGES.fr }, + { name: "Portuguese", value: LANGUAGES.pt }, + { name: "Dutch", value: LANGUAGES.nl }, + { name: "Turkish", value: LANGUAGES.tr }, +]; diff --git a/demo/vue-app-new/src/lib/eth.ts b/demo/vue-app-new/src/lib/eth.ts new file mode 100644 index 000000000..fcff285b1 --- /dev/null +++ b/demo/vue-app-new/src/lib/eth.ts @@ -0,0 +1,169 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { IProvider, log } from "@web3auth/base"; +import Web3 from "web3"; + +export const sendEth = async (provider: IProvider, uiConsole: any) => { + try { + const web3 = new Web3(provider); + const accounts = await web3.eth.getAccounts(); + log.info("pubKey", accounts); + const txRes = await web3.eth.sendTransaction({ + from: accounts[0], + to: accounts[0], + value: web3.utils.toWei("0.01", "ether"), + }); + uiConsole("txRes", txRes); + } catch (error) { + log.info("error", error); + uiConsole("error", error); + } +}; + +export const signEthMessage = async (provider: IProvider, uiConsole: any) => { + try { + const web3 = new Web3(); + web3.setProvider(provider); + // hex message + // const message = "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"; + const fromAddress = (await web3.eth.getAccounts())[0]; + log.info("fromAddress", fromAddress); + // const signedMessage = await provider.request({ + // method: "eth_sign", + // params: [fromAddress, message], + // }); + + const message = "Some string"; + const hash = web3.utils.sha3(message) as string; + const sig = await web3.eth.personal.sign(hash, fromAddress, ""); + uiConsole("personal sign", sig); + // const originalMessage = { + // types: { + // EIP712Domain: [ + // { + // name: "name", + // type: "string", + // }, + // { + // name: "version", + // type: "string", + // }, + // { + // name: "chainId", + // type: "uint256", + // }, + // { + // name: "verifyingContract", + // type: "address", + // }, + // ], + // Person: [ + // { + // name: "name", + // type: "string", + // }, + // { + // name: "wallet", + // type: "address", + // }, + // ], + // Mail: [ + // { + // name: "from", + // type: "Person", + // }, + // { + // name: "to", + // type: "Person", + // }, + // { + // name: "contents", + // type: "string", + // }, + // ], + // }, + // primaryType: "Mail", + // domain: { + // name: "Ether Mail", + // version: "1", + // chainId: 1, + // verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC", + // }, + // message: { + // from: { + // name: "Cow", + // wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", + // }, + // to: { + // name: "Bob", + // wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB", + // }, + // contents: "Hello, Bob!", + // }, + // }; + // const params = [originalMessage, fromAddress]; + // const method = "eth_signTypedData"; + + // const signedMessage = await provider.request({ + // method, + // params, + // }); + // uiConsole("signedMessage orog", signedMessage); + } catch (error) { + log.error("error", error); + uiConsole("error", error); + } +}; + +export const getAccounts = async (provider: IProvider, uiConsole: any): Promise