Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev into main #30

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions xsuite-simulnet/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions xsuite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xsuite",
"version": "0.0.31",
"version": "0.0.32",
"license": "MIT",
"bin": {
"xsuite": "cli.js"
Expand Down Expand Up @@ -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"
},
Expand All @@ -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"
Expand Down
27 changes: 11 additions & 16 deletions xsuite/src/cli/cmd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) => {
Expand All @@ -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."),
"",
]);
});
Expand Down
23 changes: 9 additions & 14 deletions xsuite/src/cli/requestXegldCmd.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -67,6 +61,7 @@ const action = async ({
await new Promise((r) => setTimeout(r, 1000));
}

log();
logSuccess("Wallet well received 30 xEGLD.");
};

Expand Down