diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fbf12a82..e8aa2c36 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -144,6 +144,9 @@ importers: commander: specifier: 11.0.0 version: 11.0.0 + open: + specifier: ^8.4.2 + version: 8.4.2 protobufjs: specifier: 7.2.4 version: 7.2.4 @@ -172,9 +175,6 @@ importers: msw: specifier: ^1.3.1 version: 1.3.1(typescript@5.1.6) - open: - specifier: ^9.1.0 - version: 9.1.0 rimraf: specifier: 5.0.0 version: 5.0.0 @@ -4681,6 +4681,11 @@ packages: clone: 1.0.4 dev: true + /define-lazy-prop@2.0.0: + resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} + engines: {node: '>=8'} + dev: false + /define-lazy-prop@3.0.0: resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} engines: {node: '>=12'} @@ -6114,7 +6119,6 @@ packages: resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} engines: {node: '>=8'} hasBin: true - dev: true /is-docker@3.0.0: resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} @@ -6296,7 +6300,6 @@ packages: engines: {node: '>=8'} dependencies: is-docker: 2.2.1 - dev: true /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -8110,6 +8113,15 @@ packages: mimic-fn: 4.0.0 dev: true + /open@8.4.2: + resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} + engines: {node: '>=12'} + dependencies: + define-lazy-prop: 2.0.0 + is-docker: 2.2.1 + is-wsl: 2.2.0 + dev: false + /open@9.1.0: resolution: {integrity: sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==} engines: {node: '>=14.16'} diff --git a/xsuite-simulnet/package.json b/xsuite-simulnet/package.json index d3df9ac1..a8f9fd1e 100644 --- a/xsuite-simulnet/package.json +++ b/xsuite-simulnet/package.json @@ -1,12 +1,12 @@ { "name": "@xsuite/simulnet", - "version": "0.0.5", + "version": "0.0.6", "license": "MIT", "scripts": { "build": "run-script-os", "build:linux": "cd src && GOOS=linux GOARCH=amd64 go build -o ../bin/sproxy-linux-amd64 -ldflags \"-extldflags '-Wl,-rpath,\\$ORIGIN'\"", "build:darwin": "cd src && GOOS=darwin GOARCH=amd64 go build -o ../bin/sproxy-darwin-amd64", - "postinstall": "chmod -f +x ./bin/proxy-* || true" + "postinstall": "chmod -f +x ./bin/sproxy-* || true" }, "files": [ "bin", diff --git a/xsuite/package.json b/xsuite/package.json index ce9de666..61a70392 100644 --- a/xsuite/package.json +++ b/xsuite/package.json @@ -1,6 +1,6 @@ { "name": "xsuite", - "version": "0.0.31", + "version": "0.0.32", "license": "MIT", "bin": { "xsuite": "cli.js" @@ -39,6 +39,7 @@ "bech32": "2.0.0", "chalk": "4.1.2", "commander": "11.0.0", + "open": "^8.4.2", "protobufjs": "7.2.4", "tar": "6.1.15" }, @@ -50,7 +51,6 @@ "@types/tar": "6.1.5", "jest": "29.5.0", "msw": "^1.3.1", - "open": "^9.1.0", "rimraf": "5.0.0", "tsx": "3.12.7", "typescript": "5.1.6" diff --git a/xsuite/src/cli/cmd.test.ts b/xsuite/src/cli/cmd.test.ts index fb4d85bd..cf17d76a 100644 --- a/xsuite/src/cli/cmd.test.ts +++ b/xsuite/src/cli/cmd.test.ts @@ -102,7 +102,6 @@ test("request-xegld --wallet wallet.json", async () => { const walletPath = path.resolve("wallet.json"); const signer = Keystore.createFile_unsafe(walletPath, "1234").newSigner(); const address = signer.toString(); - let numFaucetReqs = 0; let numBalanceReqs = 0; const server = setupServer( rest.get( @@ -124,19 +123,6 @@ test("request-xegld --wallet wallet.json", async () => { ]), ); }), - rest.post( - "https://devnet-extras-api.multiversx.com/faucet", - (_req, res, ctx) => { - numFaucetReqs += 1; - if (numFaucetReqs === 1) { - return res(ctx.json({ status: "success" })); - } else { - return res( - ctx.json({ status: "error", message: "Already claimed today." }), - ); - } - }, - ), rest.get( `https://devnet-gateway.multiversx.com/address/${address}/balance`, (_req, res, ctx) => { @@ -153,14 +139,23 @@ test("request-xegld --wallet wallet.json", async () => { await run(`request-xegld --wallet ${walletPath} --password 1234`); stdoutInt.stop(); server.close(); - expect(stdoutInt.data.split("\n")).toEqual([ + const splittedStdoutData = stdoutInt.data.split("\n"); + expect(splittedStdoutData).toEqual([ `Loading keystore wallet at "${walletPath}"...`, "Enter password: ", "", `Claiming 30 xEGLD for address "${address}"...`, + "", + "Open this URL:", + splittedStdoutData.at(6), + "", chalk.green("Wallet well received 30 xEGLD."), `Claiming 30 xEGLD for address "${address}"...`, - chalk.red("Error: Already claimed today."), + "", + "Open this URL:", + splittedStdoutData.at(12), + "", + chalk.green("Wallet well received 30 xEGLD."), "", ]); }); diff --git a/xsuite/src/cli/requestXegldCmd.ts b/xsuite/src/cli/requestXegldCmd.ts index 41d17acd..11fc7466 100644 --- a/xsuite/src/cli/requestXegldCmd.ts +++ b/xsuite/src/cli/requestXegldCmd.ts @@ -1,10 +1,11 @@ import { SignableMessage } from "@multiversx/sdk-core"; import { NativeAuthClient } from "@multiversx/sdk-native-auth-client"; import { Command } from "commander"; +import open from "open"; import { log } from "../_stdio"; import { Proxy } from "../proxy"; import { KeystoreSigner } from "../world/signer"; -import { logError, logSuccess } from "./helpers"; +import { logSuccess } from "./helpers"; export const registerRequestXegldCmd = (cmd: Command) => { cmd @@ -45,19 +46,12 @@ const action = async ({ .then((b) => b.toString("hex")); const accessToken = client.getToken(address, initToken, signature); - const faucetRes = await fetch( - "https://devnet-extras-api.multiversx.com/faucet", - { - headers: { - authorization: `Bearer ${accessToken}`, - }, - method: "POST", - }, - ).then((r) => r.json()); - - if (faucetRes["status"] !== "success") { - logError(`Error: ${faucetRes["message"]}`); - return; + const faucetUrl = `https://devnet-wallet.multiversx.com/faucet?accessToken=${accessToken}`; + log(); + log("Open this URL:"); + log(faucetUrl); + if (!process.env.JEST_WORKER_ID) { + open(faucetUrl); } const initialBalance = await devnetProxy.getAccountBalance(address); @@ -67,6 +61,7 @@ const action = async ({ await new Promise((r) => setTimeout(r, 1000)); } + log(); logSuccess("Wallet well received 30 xEGLD."); };