From 0dda005f96a3c6152915330d360232ab274996c4 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 21 Dec 2024 09:20:08 -0500 Subject: [PATCH 1/5] test havenod 1.0.17 --- src/HavenoClient.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HavenoClient.test.ts b/src/HavenoClient.test.ts index 2f301095..5a0e29e5 100644 --- a/src/HavenoClient.test.ts +++ b/src/HavenoClient.test.ts @@ -366,7 +366,7 @@ const TestConfig = { deferralMs: 25000, haveno: { path: "../haveno", - version: "1.0.16" + version: "1.0.17" }, monerod: { url: "http://localhost:" + getNetworkStartPort() + "8081", // 18081, 28081, 38081 for mainnet, testnet, and stagenet, respectively From 1d50b0027e0f4a313033603fe97896acba0db9e7 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 21 Dec 2024 10:32:33 -0500 Subject: [PATCH 2/5] update test to make or take offer with insufficient funds --- src/HavenoClient.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HavenoClient.test.ts b/src/HavenoClient.test.ts index 5a0e29e5..5e7a2da9 100644 --- a/src/HavenoClient.test.ts +++ b/src/HavenoClient.test.ts @@ -1995,7 +1995,7 @@ test("Can go offline while resolving a dispute (CI)", async () => { if (err) throw err; }); -test("Cannot make or take offer with insufficient unlocked funds (CI, sanity check)", async () => { +test("Cannot make or take offer with insufficient funds (CI, sanity check)", async () => { let user3: HavenoClient|undefined; let err: any; try { @@ -2011,7 +2011,7 @@ test("Cannot make or take offer with insufficient unlocked funds (CI, sanity che await makeOffer({maker: {havenod: user3}, makerPaymentAccountId: paymentAccount.getId(), awaitFundsToMakeOffer: false}); throw new Error("Should have failed making offer with insufficient funds") } catch (err: any) { - if (!err.message.includes("not enough money")) throw err; + if (!err.message.includes("not enough funds")) throw err; const errTyped = err as HavenoError; assert.equal(errTyped.code, 2); } From 73e14fe5b3a60886286d241f8689b60fe77185ed Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Thu, 26 Dec 2024 16:33:11 +0100 Subject: [PATCH 3/5] pack all dist files and add decimal.js --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d12af0b2..efa63665 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ + "dist", "dist/**/*" ], "scripts": { @@ -28,6 +29,7 @@ "dependencies": { "@types/node": "^18.14.2", "console": "^0.7.2", + "decimal.js": "^10.4.3", "google-protobuf": "^3.20.3", "grpc-web": "^1.4.2" }, @@ -39,7 +41,6 @@ "@typescript-eslint/eslint-plugin": "5.53.0", "@typescript-eslint/parser": "^5.53.0", "babel-jest": "^29.4.3", - "decimal.js": "^10.4.3", "eslint": "^8.35.0", "eslint-config-prettier": "^8.6.0", "eslint-import-resolver-typescript": "^3.5.3", From 987672fe3b52f81de22ec3f08069a39505a6daf7 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Fri, 27 Dec 2024 17:21:59 +0100 Subject: [PATCH 4/5] Fix missing XMLHttpRequest on node environments --- package-lock.json | 24 ++++++++++-------------- package.json | 4 ++-- src/index.ts | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 51c27282..99424b7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,8 +11,10 @@ "dependencies": { "@types/node": "^18.14.2", "console": "^0.7.2", + "decimal.js": "^10.4.3", "google-protobuf": "^3.20.3", - "grpc-web": "^1.4.2" + "grpc-web": "^1.4.2", + "node-xmlhttprequest": "^1.0.6" }, "devDependencies": { "@babel/core": "^7.21.0", @@ -22,7 +24,6 @@ "@typescript-eslint/eslint-plugin": "5.53.0", "@typescript-eslint/parser": "^5.53.0", "babel-jest": "^29.4.3", - "decimal.js": "^10.4.3", "eslint": "^8.35.0", "eslint-config-prettier": "^8.6.0", "eslint-import-resolver-typescript": "^3.5.3", @@ -30,7 +31,6 @@ "eslint-plugin-jsx-a11y": "^6.7.1", "jest": "^29.7.0", "monero-ts": "^0.11.1", - "node-xmlhttprequest": "^1.0.6", "ts-jest": "^29.2.5", "ts-jest-resolver": "^2.0.1", "typedoc": "^0.23.26", @@ -1890,7 +1890,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", - "dev": true, "engines": { "node": ">=14" } @@ -3591,9 +3590,9 @@ } }, "node_modules/axios": { - "version": "1.7.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz", - "integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==", + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", "dev": true, "dependencies": { "follow-redirects": "^1.15.6", @@ -4171,9 +4170,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -4216,8 +4215,7 @@ "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", - "dev": true + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" }, "node_modules/dedent": { "version": "1.5.3", @@ -8234,7 +8232,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/node-xmlhttprequest/-/node-xmlhttprequest-1.0.6.tgz", "integrity": "sha512-wBcHLcDg0oIyRQNKwPzyF+W5/eqwbvPM6Tbaz9E8lTBN/7OVMGaLTWYkL69Tt8eo6JyjoPtoAaVtZYcNIfRKvw==", - "dev": true, "dependencies": { "undici": "6.6.2" } @@ -9604,7 +9601,6 @@ "version": "6.6.2", "resolved": "https://registry.npmjs.org/undici/-/undici-6.6.2.tgz", "integrity": "sha512-vSqvUE5skSxQJ5sztTZ/CdeJb1Wq0Hf44hlYMciqHghvz+K88U0l7D6u1VsndoFgskDcnU+nG3gYmMzJVzd9Qg==", - "dev": true, "dependencies": { "@fastify/busboy": "^2.0.0" }, diff --git a/package.json b/package.json index efa63665..54db03ae 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "console": "^0.7.2", "decimal.js": "^10.4.3", "google-protobuf": "^3.20.3", - "grpc-web": "^1.4.2" + "grpc-web": "^1.4.2", + "node-xmlhttprequest": "^1.0.6" }, "devDependencies": { "@babel/core": "^7.21.0", @@ -48,7 +49,6 @@ "eslint-plugin-jsx-a11y": "^6.7.1", "jest": "^29.7.0", "monero-ts": "^0.11.1", - "node-xmlhttprequest": "^1.0.6", "ts-jest": "^29.2.5", "ts-jest-resolver": "^2.0.1", "typedoc": "^0.23.26", diff --git a/src/index.ts b/src/index.ts index 0b68fe9a..49e79ffb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,19 @@ +try { + new XMLHttpRequest(); +} +catch { + const xhr = require('node-xmlhttprequest'); + + //@ts-ignore + global.ProgressEvent = xhr.ProgressEvent; + //@ts-ignore + global.XMLHttpRequestEventTarget = xhr.XMLHttpRequestEventTarget; + //@ts-ignore + global.XMLHttpRequestUpload = xhr.XMLHttpRequestUpload; + //@ts-ignore + global.XMLHttpRequest = xhr.XMLHttpRequest; +} + import HavenoClient from "./HavenoClient"; import HavenoError from "./types/HavenoError"; import HavenoUtils from "./utils/HavenoUtils"; From 0991fe67d957639a2cff577cfa1d1ea166c930f0 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 29 Dec 2024 08:10:32 -0500 Subject: [PATCH 5/5] bump version to v0.0.32 and update dist --- dist/index.js | 14 ++++++++++++++ dist/index.js.map | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index a3d32bd7..d7ab8b79 100644 --- a/dist/index.js +++ b/dist/index.js @@ -18,6 +18,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.HavenoUtils = exports.HavenoError = exports.HavenoClient = void 0; +try { + new XMLHttpRequest(); +} +catch { + const xhr = require('node-xmlhttprequest'); + //@ts-ignore + global.ProgressEvent = xhr.ProgressEvent; + //@ts-ignore + global.XMLHttpRequestEventTarget = xhr.XMLHttpRequestEventTarget; + //@ts-ignore + global.XMLHttpRequestUpload = xhr.XMLHttpRequestUpload; + //@ts-ignore + global.XMLHttpRequest = xhr.XMLHttpRequest; +} const HavenoClient_1 = __importDefault(require("./HavenoClient")); exports.HavenoClient = HavenoClient_1.default; const HavenoError_1 = __importDefault(require("./types/HavenoError")); diff --git a/dist/index.js.map b/dist/index.js.map index 3c8edc64..7f7b195f 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAIjC,uBAJF,sBAAY,CAIE;AAHrB,sEAA8C;AAIrC,sBAJF,qBAAW,CAIE;AAHpB,sEAA8C;AAIrC,sBAJF,qBAAW,CAIE;AACpB,qDAAmC;AACnC,mDAAiC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAI;IACA,IAAI,cAAc,EAAE,CAAC;CACxB;AACD,MAAM;IACF,MAAM,GAAG,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAE3C,YAAY;IACZ,MAAM,CAAC,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;IACzC,YAAY;IACZ,MAAM,CAAC,yBAAyB,GAAG,GAAG,CAAC,yBAAyB,CAAC;IACjE,YAAY;IACZ,MAAM,CAAC,oBAAoB,GAAG,GAAG,CAAC,oBAAoB,CAAC;IACvD,YAAY;IACZ,MAAM,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC;CAC9C;AAED,kEAA0C;AAIjC,uBAJF,sBAAY,CAIE;AAHrB,sEAA8C;AAIrC,sBAJF,qBAAW,CAIE;AAHpB,sEAA8C;AAIrC,sBAJF,qBAAW,CAIE;AACpB,qDAAmC;AACnC,mDAAiC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 99424b7e..23aba59c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "haveno-ts", - "version": "0.0.31", + "version": "0.0.32", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "haveno-ts", - "version": "0.0.31", + "version": "0.0.32", "license": "Apache-2.0", "dependencies": { "@types/node": "^18.14.2", diff --git a/package.json b/package.json index 54db03ae..d03f35b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haveno-ts", - "version": "0.0.31", + "version": "0.0.32", "description": "Haveno TypeScript client", "main": "dist/index.js", "types": "dist/index.d.ts",