From db59d56e96ea4b2c075013809b8c2e965c14b3a6 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Tue, 19 Dec 2023 15:37:50 +0100 Subject: [PATCH 01/20] feat: Skip files in .gitignore when uploading --- packages/sdk/src/util/file-utils.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/util/file-utils.ts b/packages/sdk/src/util/file-utils.ts index 1bbcf50..9f1293b 100644 --- a/packages/sdk/src/util/file-utils.ts +++ b/packages/sdk/src/util/file-utils.ts @@ -17,11 +17,27 @@ function listFilesRecursive( fileList = [], relativePath = '', ) { + const gitignorePath = path.join(folderPath, '.gitignore'); + const gitignorePatterns = fs.existsSync(gitignorePath) + ? fs.readFileSync(gitignorePath, 'utf-8').split('\n') + : []; + const files = fs.readdirSync(folderPath); for (const file of files) { const fullPath = path.join(folderPath, file); + const relativeFilePath = path.join(relativePath, file); + + // Skip file if it matches .gitignore patterns + if ( + gitignorePatterns.some((pattern) => + new RegExp(pattern).test(relativeFilePath), + ) + ) { + continue; + } + if (fs.statSync(fullPath).isDirectory()) { - listFilesRecursive(fullPath, fileList, `${relativePath + file}/`); + listFilesRecursive(fullPath, fileList, `${relativeFilePath}/`); } else { fileList.push({ fileName: file, path: relativePath, index: fullPath }); } From c4baac007347a133a0708e5486a6ba990ea88291 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Tue, 19 Dec 2023 15:41:16 +0100 Subject: [PATCH 02/20] Package version upgrade --- package-lock.json | 1012 +++++++++++-------------------------- package.json | 4 +- packages/cli/package.json | 10 +- packages/sdk/package.json | 14 +- 4 files changed, 309 insertions(+), 731 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ece87e..5c817a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,11 +12,11 @@ "packages/*" ], "devDependencies": { - "@types/jest": "^29.5.5", + "@types/jest": "^29.5.11", "eslint-config-common": "*", "jest": "29.7.0", "prettier": "latest", - "rimraf": "^4.4.0", + "rimraf": "^5.0.5", "ts-jest": "29.1.1", "turbo": "latest" }, @@ -1414,6 +1414,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "dev": true, "dependencies": { "@noble/hashes": "1.3.2" }, @@ -1425,6 +1426,7 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "dev": true, "engines": { "node": ">= 16" }, @@ -1475,21 +1477,21 @@ } }, "node_modules/@polkadot/keyring": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-12.6.1.tgz", - "integrity": "sha512-cicTctZr5Jy5vgNT2FsNiKoTZnz6zQkgDoIYv79NI+p1Fhwc9C+DN/iMCnk3Cm9vR2gSAd2fSV+Y5iKVDhAmUw==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-12.6.2.tgz", + "integrity": "sha512-O3Q7GVmRYm8q7HuB3S0+Yf/q/EB2egKRRU3fv9b3B7V+A52tKzA+vIwEmNVaD1g5FKW9oB97rmpggs0zaKFqHw==", "dev": true, "dependencies": { - "@polkadot/util": "12.6.1", - "@polkadot/util-crypto": "12.6.1", + "@polkadot/util": "12.6.2", + "@polkadot/util-crypto": "12.6.2", "tslib": "^2.6.2" }, "engines": { "node": ">=18" }, "peerDependencies": { - "@polkadot/util": "12.6.1", - "@polkadot/util-crypto": "12.6.1" + "@polkadot/util": "12.6.2", + "@polkadot/util-crypto": "12.6.2" } }, "node_modules/@polkadot/keyring/node_modules/tslib": { @@ -1499,11 +1501,11 @@ "dev": true }, "node_modules/@polkadot/networks": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/networks/-/networks-12.6.1.tgz", - "integrity": "sha512-pzyirxTYAnsx+6kyLYcUk26e4TLz3cX6p2KhTgAVW77YnpGX5VTKTbYykyXC8fXFd/migeQsLaa2raFN47mwoA==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/networks/-/networks-12.6.2.tgz", + "integrity": "sha512-1oWtZm1IvPWqvMrldVH6NI2gBoCndl5GEwx7lAuQWGr7eNL+6Bdc5K3Z9T0MzFvDGoi2/CBqjX9dRKo39pDC/w==", "dependencies": { - "@polkadot/util": "12.6.1", + "@polkadot/util": "12.6.2", "@substrate/ss58-registry": "^1.44.0", "tslib": "^2.6.2" }, @@ -1517,14 +1519,14 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@polkadot/util": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-12.6.1.tgz", - "integrity": "sha512-10ra3VfXtK8ZSnWI7zjhvRrhupg3rd4iFC3zCaXmRpOU+AmfIoCFVEmuUuC66gyXiz2/g6k5E6j0lWQCOProSQ==", - "dependencies": { - "@polkadot/x-bigint": "12.6.1", - "@polkadot/x-global": "12.6.1", - "@polkadot/x-textdecoder": "12.6.1", - "@polkadot/x-textencoder": "12.6.1", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-12.6.2.tgz", + "integrity": "sha512-l8TubR7CLEY47240uki0TQzFvtnxFIO7uI/0GoWzpYD/O62EIAMRsuY01N4DuwgKq2ZWD59WhzsLYmA5K6ksdw==", + "dependencies": { + "@polkadot/x-bigint": "12.6.2", + "@polkadot/x-global": "12.6.2", + "@polkadot/x-textdecoder": "12.6.2", + "@polkadot/x-textencoder": "12.6.2", "@types/bn.js": "^5.1.5", "bn.js": "^5.2.1", "tslib": "^2.6.2" @@ -1534,26 +1536,48 @@ } }, "node_modules/@polkadot/util-crypto": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-12.6.1.tgz", - "integrity": "sha512-2ezWFLmdgeDXqB9NAUdgpp3s2rQztNrZLY+y0SJYNOG4ch+PyodTW/qSksnOrVGVdRhZ5OESRE9xvo9LYV5UAw==", - "dependencies": { - "@noble/curves": "^1.2.0", - "@noble/hashes": "^1.3.2", - "@polkadot/networks": "12.6.1", - "@polkadot/util": "12.6.1", - "@polkadot/wasm-crypto": "^7.3.1", - "@polkadot/wasm-util": "^7.3.1", - "@polkadot/x-bigint": "12.6.1", - "@polkadot/x-randomvalues": "12.6.1", - "@scure/base": "^1.1.3", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-12.6.2.tgz", + "integrity": "sha512-FEWI/dJ7wDMNN1WOzZAjQoIcCP/3vz3wvAp5QQm+lOrzOLj0iDmaIGIcBkz8HVm3ErfSe/uKP0KS4jgV/ib+Mg==", + "dependencies": { + "@noble/curves": "^1.3.0", + "@noble/hashes": "^1.3.3", + "@polkadot/networks": "12.6.2", + "@polkadot/util": "12.6.2", + "@polkadot/wasm-crypto": "^7.3.2", + "@polkadot/wasm-util": "^7.3.2", + "@polkadot/x-bigint": "12.6.2", + "@polkadot/x-randomvalues": "12.6.2", + "@scure/base": "^1.1.5", "tslib": "^2.6.2" }, "engines": { "node": ">=18" }, "peerDependencies": { - "@polkadot/util": "12.6.1" + "@polkadot/util": "12.6.2" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@noble/curves": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.3.0.tgz", + "integrity": "sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA==", + "dependencies": { + "@noble/hashes": "1.3.3" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@noble/hashes": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", + "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" } }, "node_modules/@polkadot/util-crypto/node_modules/tslib": { @@ -1695,11 +1719,11 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@polkadot/x-bigint": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-bigint/-/x-bigint-12.6.1.tgz", - "integrity": "sha512-YlABeVIlgYQZJ4ZpW/+akFGGxw5jMGt4g5vaP7EumlORGneJHzzWJYDmI5v2y7j1zvC9ofOle7z4tRmtN/QDew==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-bigint/-/x-bigint-12.6.2.tgz", + "integrity": "sha512-HSIk60uFPX4GOFZSnIF7VYJz7WZA7tpFJsne7SzxOooRwMTWEtw3fUpFy5cYYOeLh17/kHH1Y7SVcuxzVLc74Q==", "dependencies": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "engines": { @@ -1712,9 +1736,9 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@polkadot/x-global": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-12.6.1.tgz", - "integrity": "sha512-w5t19HIdBPuyu7X/AiCyH2DsKqxBF0KpF4Ymolnx8PfcSIgnq9ZOmgs74McPR6FgEmeEkr9uNKujZrsfURi1ug==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-12.6.2.tgz", + "integrity": "sha512-a8d6m+PW98jmsYDtAWp88qS4dl8DyqUBsd0S+WgyfSMtpEXu6v9nXDgPZgwF5xdDvXhm+P0ZfVkVTnIGrScb5g==", "dependencies": { "tslib": "^2.6.2" }, @@ -1728,18 +1752,18 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@polkadot/x-randomvalues": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-randomvalues/-/x-randomvalues-12.6.1.tgz", - "integrity": "sha512-1uVKlfYYbgIgGV5v1Dgn960cGovenWm5pmg+aTMeUGXVYiJwRD2zOpLyC1i/tP454iA74j74pmWb8Nkn0tJZUQ==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-randomvalues/-/x-randomvalues-12.6.2.tgz", + "integrity": "sha512-Vr8uG7rH2IcNJwtyf5ebdODMcr0XjoCpUbI91Zv6AlKVYOGKZlKLYJHIwpTaKKB+7KPWyQrk4Mlym/rS7v9feg==", "dependencies": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "engines": { "node": ">=18" }, "peerDependencies": { - "@polkadot/util": "12.6.1", + "@polkadot/util": "12.6.2", "@polkadot/wasm-util": "*" } }, @@ -1749,11 +1773,11 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@polkadot/x-textdecoder": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-12.6.1.tgz", - "integrity": "sha512-IasodJeV1f2Nr/VtA207+LXCQEqYcG8y9qB/EQcRsrEP58NbwwxM5Z2obV0lSjJOxRTJ4/OlhUwnLHwcbIp6+g==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-12.6.2.tgz", + "integrity": "sha512-M1Bir7tYvNappfpFWXOJcnxUhBUFWkUFIdJSyH0zs5LmFtFdbKAeiDXxSp2Swp5ddOZdZgPac294/o2TnQKN1w==", "dependencies": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "engines": { @@ -1766,11 +1790,11 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@polkadot/x-textencoder": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-12.6.1.tgz", - "integrity": "sha512-sTq/+tXqBhGe01a1rjieSHFh3y935vuRgtahVgVJZnfqh5SmLPgSN5tTPxZWzyx7gHIfotle8laTJbJarv7V1A==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-12.6.2.tgz", + "integrity": "sha512-4N+3UVCpI489tUJ6cv3uf0PjOHvgGp9Dl+SZRLgFGt9mvxnvpW/7+XBADRMtlG4xi5gaRK7bgl5bmY6OMDsNdw==", "dependencies": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "engines": { @@ -1783,9 +1807,9 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@scure/base": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", - "integrity": "sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", + "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==", "funding": { "url": "https://paulmillr.com/funding/" } @@ -2315,9 +2339,9 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -2817,11 +2841,11 @@ } }, "node_modules/commander": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz", - "integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/concat-map": { @@ -3002,12 +3026,15 @@ } }, "node_modules/dotenv": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", - "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", "dev": true, "engines": { "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" } }, "node_modules/eastasianwidth": { @@ -3769,15 +3796,19 @@ } }, "node_modules/glob": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.0.tgz", - "integrity": "sha512-EAZejC7JvnQINayvB/7BJbpZpNOJ8Lrw2OZNEvQxe0vaLn1SuwMcfV7/MNaX8L/T0wmptBFI4YMtDvSBxYDc7w==", + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dev": true, "dependencies": { - "fs.realpath": "^1.0.0", - "minimatch": "^7.4.1", - "minipass": "^4.2.4", - "path-scurry": "^1.6.1" + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" }, "engines": { "node": ">=16 || 14 >=14.17" @@ -4103,33 +4134,6 @@ "node": ">=10" } }, - "node_modules/istanbul-lib-instrument/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/istanbul-lib-report": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", @@ -4733,33 +4737,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-snapshot/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jest-snapshot/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/jest-util": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", @@ -5003,9 +4980,9 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, "node_modules/lru-cache": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz", - "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", + "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", "dev": true, "engines": { "node": "14 || >=16.14" @@ -5032,33 +5009,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-dir/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/make-dir/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -5161,27 +5111,27 @@ "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" }, "node_modules/minimatch": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.2.tgz", - "integrity": "sha512-xy4q7wou3vUoC9k1xGTXc+awNdGaGVHtFUaey8tiX4H1QRc04DZ/rmDFwNm2EBsuYEhAZ6SgMmYf3InGY6OauA==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=10" + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", "dev": true, "engines": { - "node": ">=8" + "node": ">=16 || 14 >=14.17" } }, "node_modules/ms": { @@ -5227,18 +5177,18 @@ "dev": true }, "node_modules/nodemon": { - "version": "2.0.21", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.21.tgz", - "integrity": "sha512-djN/n2549DUtY33S7o1djRCd7dEm0kBnj9c7S9XVXqRUbuggN1MZH/Nqa+5RFQr63Fbefq37nFXAE9VU86yL1A==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.2.tgz", + "integrity": "sha512-9qIN2LNTrEzpOPBaWHTm4Asy1LxXLSickZStAQ4IZe7zsoIpD/A7LWxhZV3t4Zu352uBcqVnRsDXSMR2Sc3lTA==", "dev": true, "dependencies": { "chokidar": "^3.5.2", - "debug": "^3.2.7", + "debug": "^4", "ignore-by-default": "^1.0.1", "minimatch": "^3.1.2", "pstree.remy": "^1.1.8", - "semver": "^5.7.1", - "simple-update-notifier": "^1.0.7", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", "supports-color": "^5.5.0", "touch": "^3.1.0", "undefsafe": "^2.0.5" @@ -5247,7 +5197,7 @@ "nodemon": "bin/nodemon.js" }, "engines": { - "node": ">=8.10.0" + "node": ">=10" }, "funding": { "type": "opencollective", @@ -5264,15 +5214,6 @@ "concat-map": "0.0.1" } }, - "node_modules/nodemon/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, "node_modules/nodemon/node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -5294,15 +5235,6 @@ "node": "*" } }, - "node_modules/nodemon/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, "node_modules/nodemon/node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -5502,15 +5434,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/path-scurry/node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -5871,15 +5794,15 @@ } }, "node_modules/rimraf": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-4.4.0.tgz", - "integrity": "sha512-X36S+qpCUR0HjXlkDe4NAOhS//aHH0Z+h8Ckf2auGJk3PTnx5rLmrHkwNdbVQuCSUhOyFrlRvFEllZOYE+yZGQ==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", + "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", "dev": true, "dependencies": { - "glob": "^9.2.0" + "glob": "^10.3.7" }, "bin": { - "rimraf": "dist/cjs/src/bin.js" + "rimraf": "dist/esm/bin.mjs" }, "engines": { "node": ">=14" @@ -5977,9 +5900,9 @@ } }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -6062,24 +5985,15 @@ } }, "node_modules/simple-update-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", - "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", "dev": true, "dependencies": { - "semver": "~7.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/simple-update-notifier/node_modules/semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" + "node": ">=10" } }, "node_modules/sisteransi": { @@ -6446,37 +6360,10 @@ } } }, - "node_modules/ts-jest/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ts-jest/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", @@ -6667,9 +6554,9 @@ } }, "node_modules/typedoc": { - "version": "0.25.2", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.2.tgz", - "integrity": "sha512-286F7BeATBiWe/qC4PCOCKlSTwfnsLbC/4cZ68oGBbvAqb9vV33quEOXx7q176OXotD+JdEerdQ1OZGJ818lnA==", + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.4.tgz", + "integrity": "sha512-Du9ImmpBCw54bX275yJrxPVnjdIyJO/84co0/L9mwe0R3G4FSR6rQ09AlXVRvZEGMUg09+z/usc8mgygQ1aidA==", "dev": true, "dependencies": { "lunr": "^2.3.9", @@ -6684,22 +6571,7 @@ "node": ">= 16" }, "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x" - } - }, - "node_modules/typedoc/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x" } }, "node_modules/typescript": { @@ -7068,9 +6940,9 @@ "license": "MIT", "dependencies": { "@apillon/sdk": "*", - "axios": "^1.3.4", - "chalk": "^4.1.2", - "commander": "^10.0.0" + "axios": "^1.6.2", + "chalk": "^5.3.0", + "commander": "^11.1.0" }, "bin": { "apillon": "dist/index.js", @@ -7078,74 +6950,21 @@ }, "devDependencies": { "eslint-config-common": "*", - "nodemon": "^2.0.20", + "nodemon": "^3.0.2", "rimraf": "^5.0.5", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "tsconfig": "*" } }, - "packages/cli/node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dev": true, - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/cli/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/cli/node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "packages/cli/node_modules/rimraf": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", - "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", - "dev": true, - "dependencies": { - "glob": "^10.3.7" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, + "packages/cli/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", "engines": { - "node": ">=14" + "node": "^12.17.0 || ^14.13 || >=16.0.0" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "url": "https://github.com/chalk/chalk?sponsor=1" } }, "packages/eslint-config-common": { @@ -7170,85 +6989,21 @@ "version": "1.2.0", "license": "MIT", "dependencies": { - "@polkadot/util-crypto": "^12.6.1", - "axios": "^1.3.4", + "@polkadot/util-crypto": "^12.6.2", + "axios": "^1.6.2", "ethereumjs-util": "^7.1.5" }, "devDependencies": { - "@polkadot/keyring": "^12.6.1", + "@polkadot/keyring": "^12.6.2", "@types/jest": "^29.5.11", - "dotenv": "^16.0.3", + "dotenv": "^16.3.1", "eslint-config-common": "*", "ethers": "^6.9.0", - "nodemon": "^2.0.20", + "nodemon": "^3.0.2", "rimraf": "^5.0.5", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "tsconfig": "*", - "typedoc": "^0.25.1" - } - }, - "packages/sdk/node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dev": true, - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/sdk/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/sdk/node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "packages/sdk/node_modules/rimraf": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", - "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", - "dev": true, - "dependencies": { - "glob": "^10.3.7" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "typedoc": "^0.25.4" } }, "packages/tsconfig": { @@ -7276,110 +7031,39 @@ "version": "file:packages/cli", "requires": { "@apillon/sdk": "*", - "axios": "^1.3.4", - "chalk": "^4.1.2", - "commander": "^10.0.0", + "axios": "^1.6.2", + "chalk": "^5.3.0", + "commander": "^11.1.0", "eslint-config-common": "*", - "nodemon": "^2.0.20", + "nodemon": "^3.0.2", "rimraf": "^5.0.5", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "tsconfig": "*" }, "dependencies": { - "glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dev": true, - "requires": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - } - }, - "minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - }, - "minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true - }, - "rimraf": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", - "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", - "dev": true, - "requires": { - "glob": "^10.3.7" - } + "chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==" } } }, "@apillon/sdk": { "version": "file:packages/sdk", "requires": { - "@polkadot/keyring": "^12.6.1", - "@polkadot/util-crypto": "^12.6.1", + "@polkadot/keyring": "^12.6.2", + "@polkadot/util-crypto": "^12.6.2", "@types/jest": "^29.5.11", - "axios": "^1.3.4", - "dotenv": "^16.0.3", + "axios": "^1.6.2", + "dotenv": "^16.3.1", "eslint-config-common": "*", "ethereumjs-util": "^7.1.5", "ethers": "^6.9.0", - "nodemon": "^2.0.20", + "nodemon": "^3.0.2", "rimraf": "^5.0.5", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "tsconfig": "*", - "typedoc": "^0.25.1" - }, - "dependencies": { - "glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dev": true, - "requires": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - } - }, - "minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - }, - "minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true - }, - "rimraf": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", - "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", - "dev": true, - "requires": { - "glob": "^10.3.7" - } - } + "typedoc": "^0.25.4" } }, "@babel/code-frame": { @@ -8449,6 +8133,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "dev": true, "requires": { "@noble/hashes": "1.3.2" } @@ -8456,7 +8141,8 @@ "@noble/hashes": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==" + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "dev": true }, "@nodelib/fs.scandir": { "version": "2.1.5", @@ -8489,13 +8175,13 @@ "optional": true }, "@polkadot/keyring": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-12.6.1.tgz", - "integrity": "sha512-cicTctZr5Jy5vgNT2FsNiKoTZnz6zQkgDoIYv79NI+p1Fhwc9C+DN/iMCnk3Cm9vR2gSAd2fSV+Y5iKVDhAmUw==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-12.6.2.tgz", + "integrity": "sha512-O3Q7GVmRYm8q7HuB3S0+Yf/q/EB2egKRRU3fv9b3B7V+A52tKzA+vIwEmNVaD1g5FKW9oB97rmpggs0zaKFqHw==", "dev": true, "requires": { - "@polkadot/util": "12.6.1", - "@polkadot/util-crypto": "12.6.1", + "@polkadot/util": "12.6.2", + "@polkadot/util-crypto": "12.6.2", "tslib": "^2.6.2" }, "dependencies": { @@ -8508,11 +8194,11 @@ } }, "@polkadot/networks": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/networks/-/networks-12.6.1.tgz", - "integrity": "sha512-pzyirxTYAnsx+6kyLYcUk26e4TLz3cX6p2KhTgAVW77YnpGX5VTKTbYykyXC8fXFd/migeQsLaa2raFN47mwoA==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/networks/-/networks-12.6.2.tgz", + "integrity": "sha512-1oWtZm1IvPWqvMrldVH6NI2gBoCndl5GEwx7lAuQWGr7eNL+6Bdc5K3Z9T0MzFvDGoi2/CBqjX9dRKo39pDC/w==", "requires": { - "@polkadot/util": "12.6.1", + "@polkadot/util": "12.6.2", "@substrate/ss58-registry": "^1.44.0", "tslib": "^2.6.2" }, @@ -8525,14 +8211,14 @@ } }, "@polkadot/util": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-12.6.1.tgz", - "integrity": "sha512-10ra3VfXtK8ZSnWI7zjhvRrhupg3rd4iFC3zCaXmRpOU+AmfIoCFVEmuUuC66gyXiz2/g6k5E6j0lWQCOProSQ==", - "requires": { - "@polkadot/x-bigint": "12.6.1", - "@polkadot/x-global": "12.6.1", - "@polkadot/x-textdecoder": "12.6.1", - "@polkadot/x-textencoder": "12.6.1", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-12.6.2.tgz", + "integrity": "sha512-l8TubR7CLEY47240uki0TQzFvtnxFIO7uI/0GoWzpYD/O62EIAMRsuY01N4DuwgKq2ZWD59WhzsLYmA5K6ksdw==", + "requires": { + "@polkadot/x-bigint": "12.6.2", + "@polkadot/x-global": "12.6.2", + "@polkadot/x-textdecoder": "12.6.2", + "@polkadot/x-textencoder": "12.6.2", "@types/bn.js": "^5.1.5", "bn.js": "^5.2.1", "tslib": "^2.6.2" @@ -8546,22 +8232,35 @@ } }, "@polkadot/util-crypto": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-12.6.1.tgz", - "integrity": "sha512-2ezWFLmdgeDXqB9NAUdgpp3s2rQztNrZLY+y0SJYNOG4ch+PyodTW/qSksnOrVGVdRhZ5OESRE9xvo9LYV5UAw==", - "requires": { - "@noble/curves": "^1.2.0", - "@noble/hashes": "^1.3.2", - "@polkadot/networks": "12.6.1", - "@polkadot/util": "12.6.1", - "@polkadot/wasm-crypto": "^7.3.1", - "@polkadot/wasm-util": "^7.3.1", - "@polkadot/x-bigint": "12.6.1", - "@polkadot/x-randomvalues": "12.6.1", - "@scure/base": "^1.1.3", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-12.6.2.tgz", + "integrity": "sha512-FEWI/dJ7wDMNN1WOzZAjQoIcCP/3vz3wvAp5QQm+lOrzOLj0iDmaIGIcBkz8HVm3ErfSe/uKP0KS4jgV/ib+Mg==", + "requires": { + "@noble/curves": "^1.3.0", + "@noble/hashes": "^1.3.3", + "@polkadot/networks": "12.6.2", + "@polkadot/util": "12.6.2", + "@polkadot/wasm-crypto": "^7.3.2", + "@polkadot/wasm-util": "^7.3.2", + "@polkadot/x-bigint": "12.6.2", + "@polkadot/x-randomvalues": "12.6.2", + "@scure/base": "^1.1.5", "tslib": "^2.6.2" }, "dependencies": { + "@noble/curves": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.3.0.tgz", + "integrity": "sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA==", + "requires": { + "@noble/hashes": "1.3.3" + } + }, + "@noble/hashes": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", + "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==" + }, "tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", @@ -8671,11 +8370,11 @@ } }, "@polkadot/x-bigint": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-bigint/-/x-bigint-12.6.1.tgz", - "integrity": "sha512-YlABeVIlgYQZJ4ZpW/+akFGGxw5jMGt4g5vaP7EumlORGneJHzzWJYDmI5v2y7j1zvC9ofOle7z4tRmtN/QDew==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-bigint/-/x-bigint-12.6.2.tgz", + "integrity": "sha512-HSIk60uFPX4GOFZSnIF7VYJz7WZA7tpFJsne7SzxOooRwMTWEtw3fUpFy5cYYOeLh17/kHH1Y7SVcuxzVLc74Q==", "requires": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "dependencies": { @@ -8687,9 +8386,9 @@ } }, "@polkadot/x-global": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-12.6.1.tgz", - "integrity": "sha512-w5t19HIdBPuyu7X/AiCyH2DsKqxBF0KpF4Ymolnx8PfcSIgnq9ZOmgs74McPR6FgEmeEkr9uNKujZrsfURi1ug==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-12.6.2.tgz", + "integrity": "sha512-a8d6m+PW98jmsYDtAWp88qS4dl8DyqUBsd0S+WgyfSMtpEXu6v9nXDgPZgwF5xdDvXhm+P0ZfVkVTnIGrScb5g==", "requires": { "tslib": "^2.6.2" }, @@ -8702,11 +8401,11 @@ } }, "@polkadot/x-randomvalues": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-randomvalues/-/x-randomvalues-12.6.1.tgz", - "integrity": "sha512-1uVKlfYYbgIgGV5v1Dgn960cGovenWm5pmg+aTMeUGXVYiJwRD2zOpLyC1i/tP454iA74j74pmWb8Nkn0tJZUQ==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-randomvalues/-/x-randomvalues-12.6.2.tgz", + "integrity": "sha512-Vr8uG7rH2IcNJwtyf5ebdODMcr0XjoCpUbI91Zv6AlKVYOGKZlKLYJHIwpTaKKB+7KPWyQrk4Mlym/rS7v9feg==", "requires": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "dependencies": { @@ -8718,11 +8417,11 @@ } }, "@polkadot/x-textdecoder": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-12.6.1.tgz", - "integrity": "sha512-IasodJeV1f2Nr/VtA207+LXCQEqYcG8y9qB/EQcRsrEP58NbwwxM5Z2obV0lSjJOxRTJ4/OlhUwnLHwcbIp6+g==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-12.6.2.tgz", + "integrity": "sha512-M1Bir7tYvNappfpFWXOJcnxUhBUFWkUFIdJSyH0zs5LmFtFdbKAeiDXxSp2Swp5ddOZdZgPac294/o2TnQKN1w==", "requires": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "dependencies": { @@ -8734,11 +8433,11 @@ } }, "@polkadot/x-textencoder": { - "version": "12.6.1", - "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-12.6.1.tgz", - "integrity": "sha512-sTq/+tXqBhGe01a1rjieSHFh3y935vuRgtahVgVJZnfqh5SmLPgSN5tTPxZWzyx7gHIfotle8laTJbJarv7V1A==", + "version": "12.6.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-12.6.2.tgz", + "integrity": "sha512-4N+3UVCpI489tUJ6cv3uf0PjOHvgGp9Dl+SZRLgFGt9mvxnvpW/7+XBADRMtlG4xi5gaRK7bgl5bmY6OMDsNdw==", "requires": { - "@polkadot/x-global": "12.6.1", + "@polkadot/x-global": "12.6.2", "tslib": "^2.6.2" }, "dependencies": { @@ -8750,9 +8449,9 @@ } }, "@scure/base": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", - "integrity": "sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==" + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", + "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==" }, "@sinclair/typebox": { "version": "0.27.8", @@ -9150,9 +8849,9 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "axios": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "requires": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -9528,9 +9227,9 @@ } }, "commander": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz", - "integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==" + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==" }, "concat-map": { "version": "0.0.1", @@ -9665,9 +9364,9 @@ } }, "dotenv": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", - "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", "dev": true }, "eastasianwidth": { @@ -10250,15 +9949,16 @@ "dev": true }, "glob": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.0.tgz", - "integrity": "sha512-EAZejC7JvnQINayvB/7BJbpZpNOJ8Lrw2OZNEvQxe0vaLn1SuwMcfV7/MNaX8L/T0wmptBFI4YMtDvSBxYDc7w==", + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "minimatch": "^7.4.1", - "minipass": "^4.2.4", - "path-scurry": "^1.6.1" + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" } }, "glob-parent": { @@ -10492,26 +10192,6 @@ "@istanbuljs/schema": "^0.1.2", "istanbul-lib-coverage": "^3.2.0", "semver": "^7.5.4" - }, - "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } } }, "istanbul-lib-report": { @@ -10975,26 +10655,6 @@ "natural-compare": "^1.4.0", "pretty-format": "^29.7.0", "semver": "^7.5.3" - }, - "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } } }, "jest-util": { @@ -11182,9 +10842,9 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, "lru-cache": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz", - "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", + "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", "dev": true }, "lunr": { @@ -11200,26 +10860,6 @@ "dev": true, "requires": { "semver": "^7.5.3" - }, - "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } } }, "make-error": { @@ -11303,18 +10943,18 @@ "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" }, "minimatch": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.2.tgz", - "integrity": "sha512-xy4q7wou3vUoC9k1xGTXc+awNdGaGVHtFUaey8tiX4H1QRc04DZ/rmDFwNm2EBsuYEhAZ6SgMmYf3InGY6OauA==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "dev": true, "requires": { "brace-expansion": "^2.0.1" } }, "minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", "dev": true }, "ms": { @@ -11355,18 +10995,18 @@ "dev": true }, "nodemon": { - "version": "2.0.21", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.21.tgz", - "integrity": "sha512-djN/n2549DUtY33S7o1djRCd7dEm0kBnj9c7S9XVXqRUbuggN1MZH/Nqa+5RFQr63Fbefq37nFXAE9VU86yL1A==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.2.tgz", + "integrity": "sha512-9qIN2LNTrEzpOPBaWHTm4Asy1LxXLSickZStAQ4IZe7zsoIpD/A7LWxhZV3t4Zu352uBcqVnRsDXSMR2Sc3lTA==", "dev": true, "requires": { "chokidar": "^3.5.2", - "debug": "^3.2.7", + "debug": "^4", "ignore-by-default": "^1.0.1", "minimatch": "^3.1.2", "pstree.remy": "^1.1.8", - "semver": "^5.7.1", - "simple-update-notifier": "^1.0.7", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", "supports-color": "^5.5.0", "touch": "^3.1.0", "undefsafe": "^2.0.5" @@ -11382,15 +11022,6 @@ "concat-map": "0.0.1" } }, - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -11406,12 +11037,6 @@ "brace-expansion": "^1.1.7" } }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -11548,14 +11173,6 @@ "requires": { "lru-cache": "^9.1.1 || ^10.0.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "dependencies": { - "minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true - } } }, "path-type": { @@ -11803,12 +11420,12 @@ "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" }, "rimraf": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-4.4.0.tgz", - "integrity": "sha512-X36S+qpCUR0HjXlkDe4NAOhS//aHH0Z+h8Ckf2auGJk3PTnx5rLmrHkwNdbVQuCSUhOyFrlRvFEllZOYE+yZGQ==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", + "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", "dev": true, "requires": { - "glob": "^9.2.0" + "glob": "^10.3.7" } }, "ripemd160": { @@ -11865,9 +11482,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "requires": { "lru-cache": "^6.0.0" }, @@ -11928,20 +11545,12 @@ "dev": true }, "simple-update-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", - "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", "dev": true, "requires": { - "semver": "~7.0.0" - }, - "dependencies": { - "semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true - } + "semver": "^7.5.3" } }, "sisteransi": { @@ -12201,32 +11810,12 @@ "make-error": "1.x", "semver": "^7.5.3", "yargs-parser": "^21.0.1" - }, - "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } } }, "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "requires": { "@cspotcode/source-map-support": "^0.8.0", @@ -12336,26 +11925,15 @@ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==" }, "typedoc": { - "version": "0.25.2", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.2.tgz", - "integrity": "sha512-286F7BeATBiWe/qC4PCOCKlSTwfnsLbC/4cZ68oGBbvAqb9vV33quEOXx7q176OXotD+JdEerdQ1OZGJ818lnA==", + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.4.tgz", + "integrity": "sha512-Du9ImmpBCw54bX275yJrxPVnjdIyJO/84co0/L9mwe0R3G4FSR6rQ09AlXVRvZEGMUg09+z/usc8mgygQ1aidA==", "dev": true, "requires": { "lunr": "^2.3.9", "marked": "^4.3.0", "minimatch": "^9.0.3", "shiki": "^0.14.1" - }, - "dependencies": { - "minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - } } }, "typescript": { diff --git a/package.json b/package.json index 7bfaf6f..65c84f6 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,11 @@ "devDependencies": { "eslint-config-common": "*", "prettier": "latest", - "rimraf": "^4.4.0", + "rimraf": "^5.0.5", "turbo": "latest", "jest": "29.7.0", "ts-jest": "29.1.1", - "@types/jest": "^29.5.5" + "@types/jest": "^29.5.11" }, "jest": { "testTimeout": 1800000, diff --git a/packages/cli/package.json b/packages/cli/package.json index f08b0d8..fe9e4b2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -46,16 +46,16 @@ "decentralized" ], "devDependencies": { - "nodemon": "^2.0.20", - "ts-node": "^10.9.1", + "nodemon": "^3.0.2", + "ts-node": "^10.9.2", "eslint-config-common": "*", "tsconfig": "*", "rimraf": "^5.0.5" }, "dependencies": { - "axios": "^1.3.4", - "chalk": "^4.1.2", - "commander": "^10.0.0", + "axios": "^1.6.2", + "chalk": "^5.3.0", + "commander": "^11.1.0", "@apillon/sdk": "*" } } \ No newline at end of file diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 8ef48c4..a1e440e 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -44,21 +44,21 @@ "decentralized" ], "dependencies": { - "@polkadot/util-crypto": "^12.6.1", - "axios": "^1.3.4", + "@polkadot/util-crypto": "^12.6.2", + "axios": "^1.6.2", "ethereumjs-util": "^7.1.5" }, "devDependencies": { - "@polkadot/keyring": "^12.6.1", + "@polkadot/keyring": "^12.6.2", "@types/jest": "^29.5.11", - "dotenv": "^16.0.3", + "dotenv": "^16.3.1", "eslint-config-common": "*", "ethers": "^6.9.0", - "nodemon": "^2.0.20", + "nodemon": "^3.0.2", "rimraf": "^5.0.5", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "tsconfig": "*", - "typedoc": "^0.25.1" + "typedoc": "^0.25.4" }, "jest": { "testTimeout": 1800000, From 00d2efa08038f07c4aafa28b0cb395c8d57e9130 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Tue, 19 Dec 2023 15:59:04 +0100 Subject: [PATCH 03/20] General code cleanup --- packages/sdk/src/lib/apillon-api.ts | 24 ++++++++++++++----- .../sdk/src/modules/hosting/deployment.ts | 6 ++--- .../src/modules/hosting/hosting-website.ts | 21 +++++++--------- packages/sdk/src/modules/hosting/hosting.ts | 6 ++--- packages/sdk/src/modules/identity/identity.ts | 6 ++--- .../sdk/src/modules/nft/nft-collection.ts | 22 +++++++---------- packages/sdk/src/modules/nft/nft.ts | 14 +++-------- packages/sdk/src/modules/storage/directory.ts | 6 ++--- packages/sdk/src/modules/storage/file.ts | 8 +++---- packages/sdk/src/modules/storage/ipns.ts | 16 ++++--------- .../sdk/src/modules/storage/storage-bucket.ts | 22 ++++++----------- packages/sdk/src/modules/storage/storage.ts | 10 +++----- packages/sdk/src/types/apillon.ts | 10 -------- packages/sdk/src/util/file-utils.ts | 15 ++++++------ 14 files changed, 73 insertions(+), 113 deletions(-) diff --git a/packages/sdk/src/lib/apillon-api.ts b/packages/sdk/src/lib/apillon-api.ts index f93ad9d..56001b2 100644 --- a/packages/sdk/src/lib/apillon-api.ts +++ b/packages/sdk/src/lib/apillon-api.ts @@ -8,6 +8,11 @@ import { ApillonRequestError, } from './common'; +type IApillonResponse = { + id: string; + status: number; + data: T; +}; export class ApillonApi { private static instance: AxiosInstance; @@ -59,8 +64,8 @@ export class ApillonApi { } public static async get(url: string, config?: any): Promise { - const { data } = await this.instance.get(url, config); - return data; + const { data } = await this.instance.get>(url, config); + return data.data; } public static async post( @@ -68,12 +73,19 @@ export class ApillonApi { body?: any, config?: any, ): Promise { - const { data } = await this.instance.post(url, body, config); - return data; + const { data } = await this.instance.post>( + url, + body, + config, + ); + return data.data; } public static async delete(url: string, config?: any): Promise { - const { data } = await this.instance.delete(url, config); - return data; + const { data } = await this.instance.delete>( + url, + config, + ); + return data.data; } } diff --git a/packages/sdk/src/modules/hosting/deployment.ts b/packages/sdk/src/modules/hosting/deployment.ts index b207247..cc98a95 100644 --- a/packages/sdk/src/modules/hosting/deployment.ts +++ b/packages/sdk/src/modules/hosting/deployment.ts @@ -1,5 +1,5 @@ import { ApillonModel } from '../../lib/apillon'; -import { IApillonResponse } from '../../types/apillon'; + import { ApillonApi } from '../../lib/apillon-api'; import { DeployToEnvironment, DeploymentStatus } from '../../types/hosting'; @@ -60,9 +60,7 @@ export class Deployment extends ApillonModel { * Gets deployment details. */ async get(): Promise { - const { data } = await ApillonApi.get>( - this.API_PREFIX, - ); + const data = await ApillonApi.get(this.API_PREFIX); return this.populate(data); } diff --git a/packages/sdk/src/modules/hosting/hosting-website.ts b/packages/sdk/src/modules/hosting/hosting-website.ts index eeeabca..22421d8 100644 --- a/packages/sdk/src/modules/hosting/hosting-website.ts +++ b/packages/sdk/src/modules/hosting/hosting-website.ts @@ -1,10 +1,6 @@ import { constructUrlWithQueryParams } from '../../lib/common'; import { DeployToEnvironment, IDeploymentFilters } from '../../types/hosting'; -import { - IApillonList, - IApillonListResponse, - IApillonResponse, -} from '../../types/apillon'; +import { IApillonList } from '../../types/apillon'; import { Deployment } from './deployment'; import { ApillonApi } from '../../lib/apillon-api'; import { ApillonLogger } from '../../lib/apillon-logger'; @@ -59,9 +55,7 @@ export class HostingWebsite extends ApillonModel { * @returns An instance of HostingWebsite class with filled properties. */ public async get(): Promise { - const { data } = await ApillonApi.get>( - this.API_PREFIX, - ); + const data = await ApillonApi.get(this.API_PREFIX); return this.populate(data); } @@ -104,9 +98,10 @@ export class HostingWebsite extends ApillonModel { ); ApillonLogger.logWithTime('Initiating deployment'); - const { data } = await ApillonApi.post< - IApillonResponse - >(`${this.API_PREFIX}/deploy`, { environment: toEnvironment }); + const data = await ApillonApi.post( + `${this.API_PREFIX}/deploy`, + { environment: toEnvironment }, + ); ApillonLogger.logWithTime('Deployment in progress'); @@ -125,8 +120,8 @@ export class HostingWebsite extends ApillonModel { params, ); - const { data } = await ApillonApi.get< - IApillonListResponse + const data = await ApillonApi.get< + IApillonList >(url); return { diff --git a/packages/sdk/src/modules/hosting/hosting.ts b/packages/sdk/src/modules/hosting/hosting.ts index 85af53c..4ca3afc 100644 --- a/packages/sdk/src/modules/hosting/hosting.ts +++ b/packages/sdk/src/modules/hosting/hosting.ts @@ -1,7 +1,7 @@ import { ApillonModule } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { constructUrlWithQueryParams } from '../../lib/common'; -import { IApillonList, IApillonListResponse } from '../../types/apillon'; +import { IApillonList } from '../../types/apillon'; import { IWebsiteFilters } from '../../types/hosting'; import { HostingWebsite } from './hosting-website'; @@ -20,9 +20,7 @@ export class Hosting extends ApillonModule { ): Promise> { const url = constructUrlWithQueryParams(this.API_PREFIX, params); - const { data } = await ApillonApi.get>( - url, - ); + const data = await ApillonApi.get>(url); return { ...data, diff --git a/packages/sdk/src/modules/identity/identity.ts b/packages/sdk/src/modules/identity/identity.ts index 1cd55d7..fb5dcd1 100644 --- a/packages/sdk/src/modules/identity/identity.ts +++ b/packages/sdk/src/modules/identity/identity.ts @@ -1,6 +1,6 @@ import { ApillonModule } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; -import { IApillonResponse } from '../../types/apillon'; + import { IValidateEvmWalletSignature, IValidatePolkadotWalletSignature, @@ -30,11 +30,9 @@ export class Identity extends ApillonModule { public async getWalletIdentity( walletAddress: string, ): Promise { - const { data } = await ApillonApi.get>( + return await ApillonApi.get( `${this.API_PREFIX}?address=${walletAddress}`, ); - - return data; } /** diff --git a/packages/sdk/src/modules/nft/nft-collection.ts b/packages/sdk/src/modules/nft/nft-collection.ts index b8de054..b6c4732 100644 --- a/packages/sdk/src/modules/nft/nft-collection.ts +++ b/packages/sdk/src/modules/nft/nft-collection.ts @@ -3,7 +3,6 @@ import { ApillonApi } from '../../lib/apillon-api'; import { ApillonLogger } from '../../lib/apillon-logger'; import { constructUrlWithQueryParams } from '../../lib/common'; import { - IApillonResponse, IApillonList, IApillonStatus, IApillonBoolResponse, @@ -138,9 +137,7 @@ export class NftCollection extends ApillonModel { * @returns Collection instance. */ public async get(): Promise { - const { data } = await ApillonApi.get>( - this.API_PREFIX, - ); + const data = await ApillonApi.get(this.API_PREFIX); return this.populate(data); } @@ -151,9 +148,10 @@ export class NftCollection extends ApillonModel { * @returns Call status. */ public async mint(receiver: string, quantity: number) { - const { data } = await ApillonApi.post< - IApillonResponse - >(`${this.API_PREFIX}/mint`, { receivingAddress: receiver, quantity }); + const data = await ApillonApi.post( + `${this.API_PREFIX}/mint`, + { receivingAddress: receiver, quantity }, + ); ApillonLogger.log(`NFT minted successfully to ${receiver}`); @@ -179,7 +177,7 @@ export class NftCollection extends ApillonModel { ) { throw new Error('Collection is not nestable.'); } - const { data } = await ApillonApi.post>( + const data = await ApillonApi.post( `${this.API_PREFIX}/nest-mint`, { parentCollectionUuid, parentNftId, quantity }, ); @@ -198,7 +196,7 @@ export class NftCollection extends ApillonModel { if (this.isRevokable != null && !this.isRevokable) { throw new Error('Collection is not revokable.'); } - const { data } = await ApillonApi.post>( + const data = await ApillonApi.post( `${this.API_PREFIX}/burn`, { tokenId }, ); @@ -215,7 +213,7 @@ export class NftCollection extends ApillonModel { * @returns Collection data. */ public async transferOwnership(address: string): Promise { - const { data } = await ApillonApi.post>( + const data = await ApillonApi.post( `${this.API_PREFIX}/transfer`, { address }, ); @@ -239,9 +237,7 @@ export class NftCollection extends ApillonModel { params, ); - const { data } = await ApillonApi.get< - IApillonResponse> - >(url); + const data = await ApillonApi.get>(url); return { ...data, diff --git a/packages/sdk/src/modules/nft/nft.ts b/packages/sdk/src/modules/nft/nft.ts index 5b01e3b..ef98425 100644 --- a/packages/sdk/src/modules/nft/nft.ts +++ b/packages/sdk/src/modules/nft/nft.ts @@ -1,11 +1,7 @@ import { ApillonModule } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { constructUrlWithQueryParams } from '../../lib/common'; -import { - IApillonResponse, - IApillonListResponse, - IApillonList, -} from '../../types/apillon'; +import { IApillonList } from '../../types/apillon'; import { ICollectionFilters, ICollection, @@ -37,9 +33,7 @@ export class Nft extends ApillonModule { ): Promise> { const url = constructUrlWithQueryParams(this.API_PREFIX, params); - const { data } = await ApillonApi.get>( - url, - ); + const data = await ApillonApi.get>(url); return { ...data, @@ -59,9 +53,7 @@ export class Nft extends ApillonModule { if (!data.drop) { data.dropStart = data.dropPrice = data.dropReserve = 0; } - const { data: response } = await ApillonApi.post< - IApillonResponse - >(this.API_PREFIX, data); + const response = await ApillonApi.post(this.API_PREFIX, data); return new NftCollection(response.collectionUuid, response); } diff --git a/packages/sdk/src/modules/storage/directory.ts b/packages/sdk/src/modules/storage/directory.ts index fbcb6b2..5e8e3f1 100644 --- a/packages/sdk/src/modules/storage/directory.ts +++ b/packages/sdk/src/modules/storage/directory.ts @@ -5,7 +5,7 @@ import { import { File } from './file'; import { constructUrlWithQueryParams } from '../../lib/common'; import { ApillonApi } from '../../lib/apillon-api'; -import { IApillonListResponse } from '../../types/apillon'; +import { IApillonList } from '../../types/apillon'; import { ApillonModel } from '../../lib/apillon'; import { ApillonLogger } from '../../lib/apillon-logger'; @@ -71,9 +71,7 @@ export class Directory extends ApillonModel { `${this.API_PREFIX}/content`, params, ); - const { data } = await ApillonApi.get< - IApillonListResponse - >(url); + const data = await ApillonApi.get>(url); for (const item of data.items) { if (item.type == StorageContentType.FILE) { diff --git a/packages/sdk/src/modules/storage/file.ts b/packages/sdk/src/modules/storage/file.ts index c25731d..92c3488 100644 --- a/packages/sdk/src/modules/storage/file.ts +++ b/packages/sdk/src/modules/storage/file.ts @@ -1,7 +1,7 @@ import { ApillonModel } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { ApillonLogger } from '../../lib/apillon-logger'; -import { IApillonResponse } from '../../types/apillon'; + import { FileStatus, StorageContentType } from '../../types/storage'; export class File extends ApillonModel { @@ -75,9 +75,9 @@ export class File extends ApillonModel { * Gets file details. */ async get(): Promise { - const { data } = await ApillonApi.get< - IApillonResponse - >(this.API_PREFIX); + const data = await ApillonApi.get( + this.API_PREFIX, + ); this.status = data.fileStatus; return this.populate(data); } diff --git a/packages/sdk/src/modules/storage/ipns.ts b/packages/sdk/src/modules/storage/ipns.ts index 08dc86c..def1956 100644 --- a/packages/sdk/src/modules/storage/ipns.ts +++ b/packages/sdk/src/modules/storage/ipns.ts @@ -1,7 +1,6 @@ import { ApillonModel } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { ApillonLogger } from '../../lib/apillon-logger'; -import { IApillonResponse } from '../../types/apillon'; export class Ipns extends ApillonModel { /** @@ -51,9 +50,7 @@ export class Ipns extends ApillonModel { * Gets IPNS details. */ async get(): Promise { - const { data } = await ApillonApi.get>( - this.API_PREFIX, - ); + const data = await ApillonApi.get(this.API_PREFIX); return this.populate(data); } @@ -63,10 +60,9 @@ export class Ipns extends ApillonModel { * @returns {Promise} */ async publish(cid: string): Promise { - const { data } = await ApillonApi.post>( - `${this.API_PREFIX}/publish`, - { cid }, - ); + const data = await ApillonApi.post(`${this.API_PREFIX}/publish`, { + cid, + }); ApillonLogger.log('IPNS record published successfully'); return this.populate(data); } @@ -76,9 +72,7 @@ export class Ipns extends ApillonModel { * @returns {Promise} */ async delete(): Promise { - const { data } = await ApillonApi.delete>( - this.API_PREFIX, - ); + const data = await ApillonApi.delete(this.API_PREFIX); ApillonLogger.log('IPNS record deleted successfully'); return this.populate(data); } diff --git a/packages/sdk/src/modules/storage/storage-bucket.ts b/packages/sdk/src/modules/storage/storage-bucket.ts index de1ead9..2282a75 100644 --- a/packages/sdk/src/modules/storage/storage-bucket.ts +++ b/packages/sdk/src/modules/storage/storage-bucket.ts @@ -10,11 +10,7 @@ import { } from '../../types/storage'; import { File } from './file'; import { constructUrlWithQueryParams } from '../../lib/common'; -import { - IApillonList, - IApillonListResponse, - IApillonResponse, -} from '../../types/apillon'; +import { IApillonList } from '../../types/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { uploadFiles } from '../../util/file-utils'; import { ApillonModel } from '../../lib/apillon'; @@ -64,9 +60,7 @@ export class StorageBucket extends ApillonModel { `${this.API_PREFIX}/content`, params, ); - const { data } = await ApillonApi.get< - IApillonListResponse - >(url); + const data = await ApillonApi.get>(url); for (const item of data.items) { if (item.type == StorageContentType.FILE) { const file = item as File; @@ -92,8 +86,8 @@ export class StorageBucket extends ApillonModel { `/storage/buckets/${this.uuid}/files`, params, ); - const { data } = await ApillonApi.get< - IApillonListResponse + const data = await ApillonApi.get< + IApillonList >(url); return { @@ -166,8 +160,8 @@ export class StorageBucket extends ApillonModel { `/storage/buckets/${this.uuid}/ipns`, params, ); - const { data } = await ApillonApi.get< - IApillonListResponse + const data = await ApillonApi.get< + IApillonList >(url); return { @@ -183,9 +177,7 @@ export class StorageBucket extends ApillonModel { */ async createIpns(body: ICreateIpns): Promise { const url = `/storage/buckets/${this.uuid}/ipns`; - const { data } = await ApillonApi.post< - IApillonResponse - >(url, body); + const data = await ApillonApi.post(url, body); return new Ipns(this.uuid, data.ipnsUuid, data); } //#endregion diff --git a/packages/sdk/src/modules/storage/storage.ts b/packages/sdk/src/modules/storage/storage.ts index 49d1b25..5d7b7c3 100644 --- a/packages/sdk/src/modules/storage/storage.ts +++ b/packages/sdk/src/modules/storage/storage.ts @@ -1,11 +1,7 @@ import { ApillonModule } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { constructUrlWithQueryParams } from '../../lib/common'; -import { - IApillonList, - IApillonListResponse, - IApillonPagination, -} from '../../types/apillon'; +import { IApillonList, IApillonPagination } from '../../types/apillon'; import { StorageBucket } from './storage-bucket'; export class Storage extends ApillonModule { @@ -24,8 +20,8 @@ export class Storage extends ApillonModule { ): Promise> { const url = constructUrlWithQueryParams(this.API_PREFIX, params); - const { data } = await ApillonApi.get< - IApillonListResponse + const data = await ApillonApi.get< + IApillonList >(url); return { diff --git a/packages/sdk/src/types/apillon.ts b/packages/sdk/src/types/apillon.ts index fa0c3aa..50c26cc 100644 --- a/packages/sdk/src/types/apillon.ts +++ b/packages/sdk/src/types/apillon.ts @@ -3,12 +3,6 @@ export interface IApillonList { total: number; } -export interface IApillonResponse { - id: string; - status: number; - data: D; -} - export interface IApillonStatus { status: number; success: boolean; @@ -22,10 +16,6 @@ export interface IApillonPagination { desc?: boolean; } -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface IApillonListResponse - extends IApillonResponse> {} - export interface IApillonBoolResponse { success: boolean; } diff --git a/packages/sdk/src/util/file-utils.ts b/packages/sdk/src/util/file-utils.ts index 9f1293b..6cf7b39 100644 --- a/packages/sdk/src/util/file-utils.ts +++ b/packages/sdk/src/util/file-utils.ts @@ -9,7 +9,7 @@ import { IFileUploadRequest, IFileUploadResponse, } from '../types/storage'; -import { IApillonResponse, LogLevel } from '../types/apillon'; +import { LogLevel } from '../types/apillon'; import { randomBytes } from 'crypto'; function listFilesRecursive( @@ -118,12 +118,13 @@ export async function uploadFiles( await Promise.all( chunkify(files, fileChunkSize).map(async (fileGroup) => { - const { data } = await ApillonApi.post< - IApillonResponse - >(`${apiPrefix}/upload`, { - files: fileGroup, - sessionUuid, - }); + const data = await ApillonApi.post( + `${apiPrefix}/upload`, + { + files: fileGroup, + sessionUuid, + }, + ); await uploadFilesToS3(data.files, fileGroup); }), From 068b4a21516da2fb45bd3b719a76117962ad6a43 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Wed, 20 Dec 2023 13:03:24 +0100 Subject: [PATCH 04/20] JSdoc updates --- packages/sdk/src/modules/hosting/hosting-website.ts | 2 +- packages/sdk/src/modules/identity/identity.ts | 2 +- packages/sdk/src/modules/storage/directory.ts | 1 + packages/sdk/src/modules/storage/file.ts | 1 + packages/sdk/src/modules/storage/ipns.ts | 5 +++-- packages/sdk/src/modules/storage/storage-bucket.ts | 5 ++++- packages/sdk/src/types/identity.ts | 4 ++-- packages/sdk/src/types/storage.ts | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/sdk/src/modules/hosting/hosting-website.ts b/packages/sdk/src/modules/hosting/hosting-website.ts index 22421d8..f9a691f 100644 --- a/packages/sdk/src/modules/hosting/hosting-website.ts +++ b/packages/sdk/src/modules/hosting/hosting-website.ts @@ -86,7 +86,7 @@ export class HostingWebsite extends ApillonModel { /** * Deploy a website to a new environment. * @param {DeployToEnvironment} toEnvironment The environment to deploy to - * @returns {Deployment} + * @returns Newly created deployment */ public async deploy(toEnvironment: DeployToEnvironment) { ApillonLogger.log( diff --git a/packages/sdk/src/modules/identity/identity.ts b/packages/sdk/src/modules/identity/identity.ts index fb5dcd1..75563d9 100644 --- a/packages/sdk/src/modules/identity/identity.ts +++ b/packages/sdk/src/modules/identity/identity.ts @@ -38,7 +38,7 @@ export class Identity extends ApillonModule { /** * Generate a message presented to the user when requested to sign using their wallet * @param {string} [customText='Please sign this message'] - * @returns {{message: string, timestamp: number}} + * @returns Generated message and timestamp */ public generateSigningMessage(customText = 'Please sign this message'): { message: string; diff --git a/packages/sdk/src/modules/storage/directory.ts b/packages/sdk/src/modules/storage/directory.ts index 5e8e3f1..ea30755 100644 --- a/packages/sdk/src/modules/storage/directory.ts +++ b/packages/sdk/src/modules/storage/directory.ts @@ -61,6 +61,7 @@ export class Directory extends ApillonModel { /** * Gets contents of a directory. + * @returns Directory data and content (files and subfolders) */ async get( params: IStorageBucketContentRequest = {}, diff --git a/packages/sdk/src/modules/storage/file.ts b/packages/sdk/src/modules/storage/file.ts index 92c3488..117e19d 100644 --- a/packages/sdk/src/modules/storage/file.ts +++ b/packages/sdk/src/modules/storage/file.ts @@ -73,6 +73,7 @@ export class File extends ApillonModel { /** * Gets file details. + * @returns File instance */ async get(): Promise { const data = await ApillonApi.get( diff --git a/packages/sdk/src/modules/storage/ipns.ts b/packages/sdk/src/modules/storage/ipns.ts index def1956..1933570 100644 --- a/packages/sdk/src/modules/storage/ipns.ts +++ b/packages/sdk/src/modules/storage/ipns.ts @@ -48,6 +48,7 @@ export class Ipns extends ApillonModel { /** * Gets IPNS details. + * @returns IPNS record */ async get(): Promise { const data = await ApillonApi.get(this.API_PREFIX); @@ -57,7 +58,7 @@ export class Ipns extends ApillonModel { /** * Publish an IPNS record to IPFS and link it to a CID. * @param {string} cid - CID to which this ipns name will point. - * @returns {Promise} + * @returns IPNS record with updated data after publish */ async publish(cid: string): Promise { const data = await ApillonApi.post(`${this.API_PREFIX}/publish`, { @@ -69,7 +70,7 @@ export class Ipns extends ApillonModel { /** * Delete an IPNS record from the bucket. - * @returns {Promise} + * @returns Deleted IPNS record */ async delete(): Promise { const data = await ApillonApi.delete(this.API_PREFIX); diff --git a/packages/sdk/src/modules/storage/storage-bucket.ts b/packages/sdk/src/modules/storage/storage-bucket.ts index 2282a75..ead8ea5 100644 --- a/packages/sdk/src/modules/storage/storage-bucket.ts +++ b/packages/sdk/src/modules/storage/storage-bucket.ts @@ -80,6 +80,8 @@ export class StorageBucket extends ApillonModel { /** * Gets all files in a bucket. + * @param {?IBucketFilesRequest} [params] - query filter parameters + * @returns List of files in the bucket */ async listFiles(params?: IBucketFilesRequest): Promise> { const url = constructUrlWithQueryParams( @@ -154,6 +156,7 @@ export class StorageBucket extends ApillonModel { /** * List all IPNS records for this bucket * @param {IPNSListRequest?} [params] - Listing query filters + * @returns List of IPNS names in the bucket */ async listIpnsNames(params?: IPNSListRequest) { const url = constructUrlWithQueryParams( @@ -173,7 +176,7 @@ export class StorageBucket extends ApillonModel { /** * Create a new IPNS record for this bucket * @param {ICreateIpns} body - * @returns {Promise} + * @returns New IPNS instance */ async createIpns(body: ICreateIpns): Promise { const url = `/storage/buckets/${this.uuid}/ipns`; diff --git a/packages/sdk/src/types/identity.ts b/packages/sdk/src/types/identity.ts index 88bd146..661278a 100644 --- a/packages/sdk/src/types/identity.ts +++ b/packages/sdk/src/types/identity.ts @@ -1,10 +1,10 @@ export interface WalletIdentityData { /** - * [Polkadot Identity Info DTO](https://github.com/polkadot-js/api/blob/c73c26d13324a6211a7cf4e401aa032c87f7aa10/packages/types-augment/src/lookup/types-substrate.ts#L3331) + * @docs [Polkadot Identity Info DTO](https://github.com/polkadot-js/api/blob/c73c26d13324a6211a7cf4e401aa032c87f7aa10/packages/types-augment/src/lookup/types-substrate.ts#L3331) */ polkadot: any; /** - * [Subsocial SpaceData DTO](https://docs.subsocial.network/js-docs/js-sdk/modules/dto.html#spacedata) + * @docs [Subsocial SpaceData DTO](https://docs.subsocial.network/js-docs/js-sdk/modules/dto.html#spacedata) */ subsocial: any; } diff --git a/packages/sdk/src/types/storage.ts b/packages/sdk/src/types/storage.ts index e47ddae..e4e4196 100644 --- a/packages/sdk/src/types/storage.ts +++ b/packages/sdk/src/types/storage.ts @@ -44,7 +44,7 @@ export interface IFileUploadRequest { * * Files in session can be wrapped to CID on IPFS via wrapWithDirectory parameter. This means that the directory gets its own CID and its content cannot be modified afterwards. * - * Read more on the [IPFS docs](https://dweb-primer.ipfs.io/files-on-ipfs/wrap-directories-around-content#explanation) + * @docs [IPFS docs](https://dweb-primer.ipfs.io/files-on-ipfs/wrap-directories-around-content#explanation) */ wrapWithDirectory: boolean; /** From de7760d4b38baedbb8a80f35f946459f04bda15c Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Wed, 20 Dec 2023 13:24:58 +0100 Subject: [PATCH 05/20] Unit tests updates and cleanup --- packages/sdk/src/tests/hosting.test.ts | 33 +++++++--------- packages/sdk/src/tests/identity.test.ts | 17 +------- packages/sdk/src/tests/ipns.test.ts | 24 +++++------- packages/sdk/src/tests/nft.test.ts | 40 ++++++++----------- packages/sdk/src/tests/storage.test.ts | 52 +++++++++---------------- 5 files changed, 57 insertions(+), 109 deletions(-) diff --git a/packages/sdk/src/tests/hosting.test.ts b/packages/sdk/src/tests/hosting.test.ts index 5fe5e7e..80a374c 100644 --- a/packages/sdk/src/tests/hosting.test.ts +++ b/packages/sdk/src/tests/hosting.test.ts @@ -1,5 +1,4 @@ import { resolve } from 'path'; -import { ApillonConfig } from '../lib/apillon'; import { Hosting } from '../modules/hosting/hosting'; import { DeployToEnvironment } from '../types/hosting'; import { getConfig, getWebsiteUUID } from './helpers/helper'; @@ -7,16 +6,16 @@ import { HostingWebsite } from '../modules/hosting/hosting-website'; import * as fs from 'fs'; describe('Hosting tests', () => { - let config: ApillonConfig; - let websiteUUID: string; + let hosting: Hosting; + let websiteUuid: string; + let deploymentUuid: string; beforeAll(async () => { - config = getConfig(); - websiteUUID = getWebsiteUUID(); + hosting = new Hosting(getConfig()); + websiteUuid = getWebsiteUUID(); }); test('get all websites', async () => { - const hosting = new Hosting(config); const { items } = await hosting.listWebsites(); expect(items.length).toBeGreaterThan(0); expect(items[0]).toBeInstanceOf(HostingWebsite); @@ -24,25 +23,23 @@ describe('Hosting tests', () => { }); test('get website info', async () => { - const hosting = new Hosting(config); - const website = await hosting.website(websiteUUID).get(); + const website = await hosting.website(websiteUuid).get(); expect(website).toBeInstanceOf(HostingWebsite); expect(website.name).toBeTruthy(); expect(website.uuid).toBeTruthy(); }); - test.skip('upload website from folder', async () => { - const hosting = new Hosting(config); - const website = hosting.website(websiteUUID); + test('upload website from folder', async () => { + const website = hosting.website(websiteUuid); const uploadDir = resolve(__dirname, './helpers/website/'); await website.uploadFromFolder(uploadDir); const deployment = await website.deploy(DeployToEnvironment.TO_STAGING); expect(deployment.environment).toEqual(DeployToEnvironment.TO_STAGING); + deploymentUuid = deployment.uuid; }); test.skip('upload files from buffer', async () => { - const hosting = new Hosting(config); const html = fs.readFileSync( resolve(__dirname, './helpers/website/index.html'), ); @@ -51,7 +48,7 @@ describe('Hosting tests', () => { ); try { console.time('File upload complete'); - await hosting.website(websiteUUID).uploadFiles( + await hosting.website(websiteUuid).uploadFiles( [ { fileName: 'index.html', @@ -74,8 +71,7 @@ describe('Hosting tests', () => { }); test('list all deployments', async () => { - const hosting = new Hosting(config); - const website = hosting.website(websiteUUID); + const website = hosting.website(websiteUuid); const { items } = await website.listDeployments({ environment: DeployToEnvironment.TO_STAGING, @@ -86,12 +82,9 @@ describe('Hosting tests', () => { }); test('get deployment status', async () => { - const hosting = new Hosting(config); - const website = hosting.website(websiteUUID); + const website = hosting.website(websiteUuid); - const deployment = await website - .deployment('e21a8e4e-bfce-4e63-b65b-59404d4fc6b4') - .get(); + const deployment = await website.deployment(deploymentUuid).get(); expect(deployment.environment).toEqual(DeployToEnvironment.TO_STAGING); }); }); diff --git a/packages/sdk/src/tests/identity.test.ts b/packages/sdk/src/tests/identity.test.ts index 003d304..3d2add3 100644 --- a/packages/sdk/src/tests/identity.test.ts +++ b/packages/sdk/src/tests/identity.test.ts @@ -5,19 +5,16 @@ import { ed25519PairFromSeed, encodeAddress, } from '@polkadot/util-crypto'; -import { ApillonConfig } from '../lib/apillon'; import { Identity } from '../modules/identity/identity'; import { getConfig } from './helpers/helper'; import { Wallet } from 'ethers'; import { Keyring } from '@polkadot/keyring'; describe('Identity Module tests', () => { - let config: ApillonConfig; let identity: Identity; beforeAll(async () => { - config = getConfig(); - identity = new Identity(config); + identity = new Identity(getConfig()); await cryptoWaitReady(); }); @@ -45,8 +42,6 @@ describe('Identity Module tests', () => { }); test('Validate EVM wallet signature with timestamp', async () => { - const identity = new Identity(config); - const customMessage = 'Identity EVM SDK test'; const { timestamp, message } = identity.generateSigningMessage(customMessage); @@ -68,8 +63,6 @@ describe('Identity Module tests', () => { }); test('Validate EVM wallet signature with invalid timestamp', async () => { - const identity = new Identity(config); - const customMessage = 'Identity EVM SDK test'; const { message } = identity.generateSigningMessage(customMessage); @@ -94,8 +87,6 @@ describe('Identity Module tests', () => { describe('Polkadot wallet signature tests', () => { test('Validate Polkadot wallet signature', async () => { - const identity = new Identity(config); - const customMessage = 'Identity Polkadot SDK test'; const { message } = identity.generateSigningMessage(customMessage); const [firstPart, secondPart] = message.split('\n'); @@ -119,8 +110,6 @@ describe('Identity Module tests', () => { }); test('Validate Polkadot wallet signature with timestamp', async () => { - const identity = new Identity(config); - const customMessage = 'Identity Polkadot SDK test'; const { timestamp, message } = identity.generateSigningMessage(customMessage); @@ -144,8 +133,6 @@ describe('Identity Module tests', () => { }); test('Validate Polkadot wallet signature with invalid timestamp', async () => { - const identity = new Identity(config); - const customMessage = 'Identity Polkadot SDK test'; const { message } = identity.generateSigningMessage(customMessage); @@ -167,8 +154,6 @@ describe('Identity Module tests', () => { }); test('Get wallet identity profile', async () => { - const identity = new Identity(config); - const { subsocial } = await identity.getWalletIdentity( '3rJriA6MiYj7oFXv5hgxvSuacenm8fk76Kb5TEEHcWWQVvii', ); diff --git a/packages/sdk/src/tests/ipns.test.ts b/packages/sdk/src/tests/ipns.test.ts index e468b78..314ce09 100644 --- a/packages/sdk/src/tests/ipns.test.ts +++ b/packages/sdk/src/tests/ipns.test.ts @@ -1,31 +1,28 @@ -import { ApillonConfig } from '../lib/apillon'; import { Ipns } from '../modules/storage/ipns'; import { Storage } from '../modules/storage/storage'; import { getBucketUUID, getConfig } from './helpers/helper'; describe('IPNS tests for StorageBucket', () => { - let config: ApillonConfig; - let bucketUUID: string; + let storage: Storage; + let bucketUuid: string; let newIpnsUuid: string; beforeAll(async () => { - config = getConfig(); - bucketUUID = getBucketUUID(); + storage = new Storage(getConfig()); + bucketUuid = getBucketUUID(); }); test('List IPNS records in a bucket', async () => { - const storage = new Storage(config); - const response = await storage.bucket(bucketUUID).listIpnsNames(); + const response = await storage.bucket(bucketUuid).listIpnsNames(); expect(response.items).toBeInstanceOf(Array); expect(response.items.length).toBeGreaterThanOrEqual(0); }); test('Create a new IPNS record', async () => { - const storage = new Storage(config); const name = 'Test IPNS'; const description = 'This is a test description'; const cid = 'QmUxtfFfWFguxSWUUy2FiBsGuH6Px4KYFxJqNYJRiDpemj'; - const ipns = await storage.bucket(bucketUUID).createIpns({ + const ipns = await storage.bucket(bucketUuid).createIpns({ name, description, cid, @@ -38,18 +35,16 @@ describe('IPNS tests for StorageBucket', () => { }); test('Get a specific IPNS record', async () => { - const storage = new Storage(config); - const ipns = await storage.bucket(bucketUUID).ipns(newIpnsUuid).get(); + const ipns = await storage.bucket(bucketUuid).ipns(newIpnsUuid).get(); expect(ipns).toBeDefined(); expect(ipns.name).toEqual('Test IPNS'); expect(ipns.uuid).toEqual(newIpnsUuid); }); test('Publish an IPNS record', async () => { - const storage = new Storage(config); const cid = 'Qmakf2aN7wzt5u9H3RadGjfotu62JsDfBq8hHzGsV2LZFx'; const ipns = await storage - .bucket(bucketUUID) + .bucket(bucketUuid) .ipns(newIpnsUuid) .publish(cid); expect(ipns).toBeDefined(); @@ -58,8 +53,7 @@ describe('IPNS tests for StorageBucket', () => { }); test('Delete an IPNS record', async () => { - const storage = new Storage(config); - const ipns = await storage.bucket(bucketUUID).ipns(newIpnsUuid).delete(); + const ipns = await storage.bucket(bucketUuid).ipns(newIpnsUuid).delete(); expect(ipns).toBeDefined(); expect(ipns.name).toEqual('Test IPNS'); expect(ipns.uuid).toEqual(newIpnsUuid); diff --git a/packages/sdk/src/tests/nft.test.ts b/packages/sdk/src/tests/nft.test.ts index 5c13bb4..8657ed2 100644 --- a/packages/sdk/src/tests/nft.test.ts +++ b/packages/sdk/src/tests/nft.test.ts @@ -1,29 +1,26 @@ -import { ApillonConfig } from '../lib/apillon'; import { Nft } from '../modules/nft/nft'; import { NftCollection } from '../modules/nft/nft-collection'; import { CollectionType, EvmChain } from '../types/nfts'; import { getCollectionUUID, getConfig, getMintAddress } from './helpers/helper'; describe('Nft tests', () => { - let config: ApillonConfig; - let collectionUUID: string; + let nft: Nft; + let collectionUuid: string; let receiverAddress: string; beforeAll(async () => { - config = getConfig(); - collectionUUID = getCollectionUUID(); + nft = new Nft(getConfig()); + collectionUuid = getCollectionUUID(); receiverAddress = getMintAddress(); }); test('list nft collections', async () => { - const nft = new Nft(config); const { items: collections } = await nft.listCollections(); expect(collections.length).toBeGreaterThan(0); expect(collections[0]).toBeInstanceOf(NftCollection); }); - test.skip('creates a new collection', async () => { - const nft = new Nft(config); + test('creates a new collection', async () => { const collection = await nft.create({ chain: EvmChain.MOONBASE, collectionType: CollectionType.GENERIC, @@ -34,39 +31,36 @@ describe('Nft tests', () => { baseUri: 'https://test.com/metadata/', baseExtension: '.json', maxSupply: 5, - isRevokable: true, + isRevokable: false, isSoulbound: false, drop: false, }); expect(collection.uuid).toBeDefined(); + collectionUuid = collection.uuid; }); - test.skip('mints a new nft', async () => { - const nft = new Nft(config); - const collection = nft.collection(collectionUUID); + test('mints a new nft', async () => { + const collection = nft.collection(collectionUuid); const res = await collection.mint(receiverAddress, 1); expect(res.success).toBe(true); }); test('get nft collection transactions', async () => { - const nft = new Nft(config); const { items: transactions } = await nft - .collection(collectionUUID) + .collection(collectionUuid) .listTransactions(); expect(transactions.length).toBeGreaterThan(0); expect(transactions[0].transactionHash).toBeDefined(); }); test('get nft collection details', async () => { - const nft = new Nft(config); - const collection = await nft.collection(collectionUUID).get(); + const collection = await nft.collection(collectionUuid).get(); console.log(collection); - expect(collection.name).toBe('sdk test manual'); + expect(collection.name).toBe('created from sdk tests'); }); test('should fail nest minting for collection that is not nestable if collection populated', async () => { - const nft = new Nft(config); - const collection = await nft.collection(collectionUUID).get(); + const collection = await nft.collection(collectionUuid).get(); await expect(collection.nestMint('', 1, 1)).rejects.toThrow( 'Collection is not nestable.', ); @@ -74,14 +68,12 @@ describe('Nft tests', () => { // TODO: unhandled error in api test('should fail nest minting', async () => { - const nft = new Nft(config); - const collection = nft.collection(collectionUUID); - await collection.nestMint('2ad03895-fd5d-40e7-af17-1d6daecf3b5a', 1, 1); + const collection = nft.collection(collectionUuid); + await expect(collection.nestMint(collectionUuid, 1, 1)).rejects.toThrow(); }); test('should fail revoking for collection that is not revokable if collection populated', async () => { - const nft = new Nft(config); - const collection = await nft.collection(collectionUUID).get(); + const collection = await nft.collection(collectionUuid).get(); await expect(collection.burn('1')).rejects.toThrow( 'Collection is not revokable.', diff --git a/packages/sdk/src/tests/storage.test.ts b/packages/sdk/src/tests/storage.test.ts index 5404079..0fc630a 100644 --- a/packages/sdk/src/tests/storage.test.ts +++ b/packages/sdk/src/tests/storage.test.ts @@ -1,28 +1,29 @@ import { resolve } from 'path'; -import { ApillonConfig } from '../lib/apillon'; import { Storage } from '../modules/storage/storage'; import { StorageContentType } from '../types/storage'; import { getBucketUUID, getConfig } from './helpers/helper'; import * as fs from 'fs'; describe('Storage tests', () => { - let config: ApillonConfig; - let bucketUUID: string; + let storage: Storage; + let bucketUuid: string; + // For get and delete tests + const directoryUuid = '6c9c6ab1-801d-4915-a63e-120eed21fee0'; + const fileUuid = 'cf6a0d3d-2abd-4a0d-85c1-10b8f04cd4fc'; beforeAll(async () => { - config = getConfig(); - bucketUUID = getBucketUUID(); + storage = new Storage(getConfig()); + bucketUuid = getBucketUUID(); }); test('List buckets', async () => { - const { items } = await new Storage(config).listBuckets(); + const { items } = await storage.listBuckets(); expect(items.length).toBeGreaterThanOrEqual(0); items.forEach((item) => expect(item.name).toBeTruthy()); }); test('get bucket content', async () => { - const storage = new Storage(config); - const { items } = await storage.bucket(bucketUUID).listObjects(); + const { items } = await storage.bucket(bucketUuid).listObjects(); for (const item of items) { if (item.type == StorageContentType.DIRECTORY) { await item.get(); @@ -34,8 +35,7 @@ describe('Storage tests', () => { }); test('get bucket files', async () => { - const storage = new Storage(config); - const { items } = await storage.bucket(bucketUUID).listFiles(); + const { items } = await storage.bucket(bucketUuid).listFiles(); for (const item of items) { console.log(`${item.type}: ${item.name}`); } @@ -44,18 +44,16 @@ describe('Storage tests', () => { }); test('get bucket files markedForDeletion=true', async () => { - const storage = new Storage(config); const { items } = await storage - .bucket(bucketUUID) + .bucket(bucketUuid) .listObjects({ markedForDeletion: true }); expect(items.some((file) => file['status'] == 8)); }); test('get bucket directory content', async () => { - const storage = new Storage(config); const { items } = await storage - .bucket(bucketUUID) - .listObjects({ directoryUuid: '6c9c6ab1-801d-4915-a63e-120eed21fee0' }); + .bucket(bucketUuid) + .listObjects({ directoryUuid }); for (const item of items) { if (item.type == StorageContentType.DIRECTORY) { @@ -67,20 +65,15 @@ describe('Storage tests', () => { }); test('get file details', async () => { - const storage = new Storage(config); - const file = await storage - .bucket(bucketUUID) - .file('cf6a0d3d-2abd-4a0d-85c1-10b8f04cd4fc') - .get(); + const file = await storage.bucket(bucketUuid).file(fileUuid).get(); expect(file.name).toBeTruthy(); }); test.skip('upload files from folder', async () => { - const storage = new Storage(config); try { const uploadDir = resolve(__dirname, './helpers/website/'); console.time('File upload complete'); - await storage.bucket(bucketUUID).uploadFromFolder(uploadDir); + await storage.bucket(bucketUuid).uploadFromFolder(uploadDir); console.timeEnd('File upload complete'); // console.log(content); @@ -90,7 +83,6 @@ describe('Storage tests', () => { }); test.skip('upload files from buffer', async () => { - const storage = new Storage(config); const html = fs.readFileSync( resolve(__dirname, './helpers/website/index.html'), ); @@ -99,7 +91,7 @@ describe('Storage tests', () => { ); try { console.time('File upload complete'); - await storage.bucket(bucketUUID).uploadFiles( + await storage.bucket(bucketUuid).uploadFiles( [ { fileName: 'index.html', @@ -125,18 +117,10 @@ describe('Storage tests', () => { }); test.skip('delete a file', async () => { - const storage = new Storage(config); - await storage - .bucket(bucketUUID) - .file('cf6a0d3d-2abd-4a0d-85c1-10b8f04cd4fc') - .delete(); + await storage.bucket(bucketUuid).file(fileUuid).delete(); }); test.skip('delete a directory', async () => { - const storage = new Storage(config); - await storage - .bucket(bucketUUID) - .directory('eddc52cf-92d2-436e-b6de-52d7cad621c2') - .delete(); + await storage.bucket(bucketUuid).directory(directoryUuid).delete(); }); }); From 315beabb057d7db1c4c555400cfd0a0021fa45f1 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Wed, 20 Dec 2023 14:13:07 +0100 Subject: [PATCH 06/20] Update CLI error handling --- package-lock.json | 22 +--- packages/cli/package.json | 14 +-- .../src/modules/hosting/hosting.service.ts | 67 +++++------ packages/cli/src/modules/nfts/nft.service.ts | 112 +++++++----------- .../cli/src/modules/storage/ipns.service.ts | 41 +++---- .../src/modules/storage/storage.service.ts | 55 ++++----- 6 files changed, 124 insertions(+), 187 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5c817a5..6cbc12a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6941,7 +6941,7 @@ "dependencies": { "@apillon/sdk": "*", "axios": "^1.6.2", - "chalk": "^5.3.0", + "chalk": "^4.1.2", "commander": "^11.1.0" }, "bin": { @@ -6956,17 +6956,6 @@ "tsconfig": "*" } }, - "packages/cli/node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "packages/eslint-config-common": { "version": "0.0.0", "dependencies": { @@ -7032,20 +7021,13 @@ "requires": { "@apillon/sdk": "*", "axios": "^1.6.2", - "chalk": "^5.3.0", + "chalk": "^4.1.2", "commander": "^11.1.0", "eslint-config-common": "*", "nodemon": "^3.0.2", "rimraf": "^5.0.5", "ts-node": "^10.9.2", "tsconfig": "*" - }, - "dependencies": { - "chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==" - } } }, "@apillon/sdk": { diff --git a/packages/cli/package.json b/packages/cli/package.json index fe9e4b2..504ce45 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -46,16 +46,16 @@ "decentralized" ], "devDependencies": { + "eslint-config-common": "*", "nodemon": "^3.0.2", + "rimraf": "^5.0.5", "ts-node": "^10.9.2", - "eslint-config-common": "*", - "tsconfig": "*", - "rimraf": "^5.0.5" + "tsconfig": "*" }, "dependencies": { + "@apillon/sdk": "*", "axios": "^1.6.2", - "chalk": "^5.3.0", - "commander": "^11.1.0", - "@apillon/sdk": "*" + "chalk": "^4.1.2", + "commander": "^11.1.0" } -} \ No newline at end of file +} diff --git a/packages/cli/src/modules/hosting/hosting.service.ts b/packages/cli/src/modules/hosting/hosting.service.ts index 4498ad0..ec94d83 100644 --- a/packages/cli/src/modules/hosting/hosting.service.ts +++ b/packages/cli/src/modules/hosting/hosting.service.ts @@ -8,34 +8,26 @@ import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; export async function listWebsites(optsWithGlobals: GlobalOptions) { - const hosting = new Hosting(optsWithGlobals); - try { + await withErrorHandler(async (hosting) => { const data = await hosting.listWebsites(paginate(optsWithGlobals)); data.items = data.items.map((w) => w.serialize()); console.log(data); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function getWebsite(optsWithGlobals: GlobalOptions) { - const hosting = new Hosting(optsWithGlobals); - try { + await withErrorHandler(async (hosting) => { const website = await hosting.website(optsWithGlobals.uuid).get(); console.log(website.serialize()); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function deployWebsite( path: string, optsWithGlobals: GlobalOptions, ) { - const hosting = new Hosting(optsWithGlobals); - try { + await withErrorHandler(async (hosting) => { const website = hosting.website(optsWithGlobals.uuid); - console.log(`Uploading files from folder: ${path}`); await website.uploadFromFolder(path); const deployment = await website.deploy( @@ -43,65 +35,62 @@ export async function deployWebsite( ? DeployToEnvironment.TO_STAGING : DeployToEnvironment.DIRECTLY_TO_PRODUCTION, ); - console.log(`Deployment started!`); const deploymentData = await website.deployment(deployment.uuid).get(); console.log(deploymentData.serialize()); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function uploadWebsiteFiles( path: string, optsWithGlobals: GlobalOptions, ) { - const hosting = new Hosting(optsWithGlobals); - try { + await withErrorHandler(async (hosting) => { await hosting.website(optsWithGlobals.uuid).uploadFromFolder(path); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function deployToEnvironment(optsWithGlobals: GlobalOptions) { - const hosting = new Hosting(optsWithGlobals); - try { + await withErrorHandler(async (hosting) => { await hosting .website(optsWithGlobals.uuid) .deploy(toInteger(optsWithGlobals.env)); console.log('Deploy successful'); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function listDeployments(optsWithGlobals: GlobalOptions) { - const hosting = new Hosting(optsWithGlobals); - const params = { - ...paginate(optsWithGlobals), - environment: toInteger(optsWithGlobals.env), - deploymentStatus: toInteger(optsWithGlobals.status), - }; - try { + await withErrorHandler(async (hosting) => { + const params = { + ...paginate(optsWithGlobals), + environment: toInteger(optsWithGlobals.env), + deploymentStatus: toInteger(optsWithGlobals.status), + }; const data = await hosting .website(optsWithGlobals.uuid) .listDeployments(params); data.items = data.items.map((w) => w.serialize()); console.log(data); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function getDeployment(optsWithGlobals: GlobalOptions) { - const hosting = new Hosting(optsWithGlobals); - try { + await withErrorHandler(async (hosting) => { const deployment = await hosting .website(optsWithGlobals.websiteUuid) .deployment(optsWithGlobals.deploymentUuid) .get(); console.log(deployment.serialize()); + }, optsWithGlobals); +} + +async function withErrorHandler( + handler: (module: Hosting) => Promise, + optsWithGlobals: GlobalOptions, +) { + try { + const module = new Hosting(optsWithGlobals); + await handler(module); } catch (err) { exceptionHandler(err); } diff --git a/packages/cli/src/modules/nfts/nft.service.ts b/packages/cli/src/modules/nfts/nft.service.ts index 77aac2e..84157b6 100644 --- a/packages/cli/src/modules/nfts/nft.service.ts +++ b/packages/cli/src/modules/nfts/nft.service.ts @@ -8,85 +8,66 @@ import { readAndParseJson } from '../../lib/files'; import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; -// COLLECTIONS export async function listCollections(optsWithGlobals: GlobalOptions) { - const nftService = new Nft(optsWithGlobals); - - try { + await withErrorHandler(async (nftService: Nft) => { const data = await nftService.listCollections({ ...paginate(optsWithGlobals), collectionStatus: toInteger(optsWithGlobals.status), }); console.log(data.items.map((d) => d.serialize())); - } catch (e: any) { - exceptionHandler(e); - } + }, optsWithGlobals); } export async function getCollection(optsWithGlobals: GlobalOptions) { - const nftService = new Nft(optsWithGlobals); - - try { + await withErrorHandler(async (nftService: Nft) => { const data = await nftService.collection(optsWithGlobals.uuid).get(); console.log(data.serialize()); - } catch (e: any) { - exceptionHandler(e); - } + }, optsWithGlobals); } export async function createCollection( filePath: string, optsWithGlobals: GlobalOptions, ) { - let createCollectionData; - try { - createCollectionData = readAndParseJson(filePath) as ICreateCollection; - } catch (e) { - if (e.code === 'ENOENT') { - return console.error(`Error: File not found (${filePath}).`); - } else if ( - e.name === 'SyntaxError' && - e.message.includes('Unexpected end of JSON input') - ) { - return console.error(`Error: Failed to parse JSON file (${filePath}).`); - } else { - return console.error(e); + await withErrorHandler(async (nftService: Nft) => { + let createCollectionData; + try { + createCollectionData = readAndParseJson(filePath) as ICreateCollection; + } catch (e) { + if (e.code === 'ENOENT') { + return console.error(`Error: File not found (${filePath}).`); + } else if ( + e.name === 'SyntaxError' && + e.message.includes('Unexpected end of JSON input') + ) { + return console.error(`Error: Failed to parse JSON file (${filePath}).`); + } else { + return console.error(e); + } + } + if (!createCollectionData) { + return; } - } - if (!createCollectionData) { - return; - } - - const nftService = new Nft(optsWithGlobals); - try { const data = await nftService.create(createCollectionData); console.log(data.serialize()); console.log('NFT collection created successfully!'); - } catch (e: any) { - exceptionHandler(e); - } + }, optsWithGlobals); } export async function mintCollectionNft(optsWithGlobals: GlobalOptions) { - const nftService = new Nft(optsWithGlobals); - - try { + await withErrorHandler(async (nftService: Nft) => { const data = await nftService .collection(optsWithGlobals.uuid) .mint(optsWithGlobals.address, toInteger(optsWithGlobals.quantity)); if (data.success) { console.log('NFT minted successfully'); } - } catch (e: any) { - exceptionHandler(e); - } + }, optsWithGlobals); } export async function nestMintCollectionNft(optsWithGlobals: GlobalOptions) { - const nftService = new Nft(optsWithGlobals); - - try { + await withErrorHandler(async (nftService: Nft) => { const data = await nftService .collection(optsWithGlobals.uuid) .nestMint( @@ -97,48 +78,35 @@ export async function nestMintCollectionNft(optsWithGlobals: GlobalOptions) { if (data.success) { console.log('NFT nest minted successfully'); } - } catch (e: any) { - exceptionHandler(e); - } + }, optsWithGlobals); } export async function burnCollectionNft(optsWithGlobals: GlobalOptions) { - const nftService = new Nft(optsWithGlobals); - - try { + await withErrorHandler(async (nftService: Nft) => { const data = await nftService .collection(optsWithGlobals.uuid) .burn(optsWithGlobals.tokenId); if (data.success) { console.log('NFT burned successfully'); } - } catch (e: any) { - exceptionHandler(e); - } + }, optsWithGlobals); } export async function transferCollectionOwnership( optsWithGlobals: GlobalOptions, ) { - const nftService = new Nft(optsWithGlobals); - - try { + await withErrorHandler(async (nftService: Nft) => { await nftService .collection(optsWithGlobals.uuid) .transferOwnership(optsWithGlobals.address); - console.log('NFT ownership transfered successfully'); - } catch (e: any) { - exceptionHandler(e); - } + console.log('NFT ownership transferred successfully'); + }, optsWithGlobals); } -// TRANSACTIONS export async function listCollectionTransactions( optsWithGlobals: GlobalOptions, ) { - const nftService = new Nft(optsWithGlobals); - - try { + await withErrorHandler(async (nftService: Nft) => { const data = await nftService .collection(optsWithGlobals.uuid) .listTransactions({ @@ -147,7 +115,17 @@ export async function listCollectionTransactions( transactionType: toInteger(optsWithGlobals.type), }); console.log(data); - } catch (e: any) { - exceptionHandler(e); + }, optsWithGlobals); +} + +async function withErrorHandler( + handler: (module: Nft) => Promise, + optsWithGlobals: GlobalOptions, +) { + try { + const module = new Nft(optsWithGlobals); + await handler(module); + } catch (err) { + exceptionHandler(err); } } diff --git a/packages/cli/src/modules/storage/ipns.service.ts b/packages/cli/src/modules/storage/ipns.service.ts index 09eb83e..a81ad73 100644 --- a/packages/cli/src/modules/storage/ipns.service.ts +++ b/packages/cli/src/modules/storage/ipns.service.ts @@ -3,21 +3,17 @@ import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; export async function listIpnsNames(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const data = await storage .bucket(optsWithGlobals.bucketUuid) .listIpnsNames(paginate(optsWithGlobals)); data.items = data.items.map((w) => w.serialize()); console.log(data); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function createIpns(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const ipns = await storage.bucket(optsWithGlobals.bucketUuid).createIpns({ name: optsWithGlobals.name, description: optsWithGlobals.description, @@ -25,46 +21,47 @@ export async function createIpns(optsWithGlobals: GlobalOptions) { }); console.log('IPNS record created successfully'); console.log(ipns.serialize()); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function getIpns(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const ipns = await storage .bucket(optsWithGlobals.bucketUuid) .ipns(optsWithGlobals.ipnsUuid) .get(); console.log(ipns.serialize()); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function publishIpns(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const ipns = await storage .bucket(optsWithGlobals.bucketUuid) .ipns(optsWithGlobals.ipnsUuid) .publish(optsWithGlobals.cid); console.log('IPNS published successfully'); console.log(ipns.serialize()); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function deleteIpns(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { await storage .bucket(optsWithGlobals.bucketUuid) .ipns(optsWithGlobals.ipnsUuid) .delete(); console.log('IPNS record deleted successfully'); + }, optsWithGlobals); +} + +async function withErrorHandler( + handler: (module: Storage) => Promise, + optsWithGlobals: GlobalOptions, +) { + try { + const module = new Storage(optsWithGlobals); + await handler(module); } catch (err) { exceptionHandler(err); } diff --git a/packages/cli/src/modules/storage/storage.service.ts b/packages/cli/src/modules/storage/storage.service.ts index ce9f274..9fbd90b 100644 --- a/packages/cli/src/modules/storage/storage.service.ts +++ b/packages/cli/src/modules/storage/storage.service.ts @@ -3,19 +3,15 @@ import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; export async function listBuckets(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const data = await storage.listBuckets(paginate(optsWithGlobals)); data.items = data.items.map((w) => w.serialize()); console.log(data); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function listObjects(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const data = await storage.bucket(optsWithGlobals.bucketUuid).listObjects({ ...paginate(optsWithGlobals), directoryUuid: optsWithGlobals.directoryUuid, @@ -23,72 +19,67 @@ export async function listObjects(optsWithGlobals: GlobalOptions) { }); data.items = data.items.map((w) => w.serialize()); console.log(data); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function listFiles(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const data = await storage.bucket(optsWithGlobals.bucketUuid).listFiles({ ...paginate(optsWithGlobals), fileStatus: toInteger(optsWithGlobals.fileStatus), }); data.items = data.items.map((w) => w.serialize()); console.log(data); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function uploadFromFolder( path: string, optsWithGlobals: GlobalOptions, ) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { console.log(`Uploading files from folder: ${path}`); await storage.bucket(optsWithGlobals.bucketUuid).uploadFromFolder(path); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function getFile(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { const file = await storage .bucket(optsWithGlobals.bucketUuid) .file(optsWithGlobals.fileUuid) .get(); console.log(file.serialize()); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function deleteFile(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { await storage .bucket(optsWithGlobals.bucketUuid) .file(optsWithGlobals.fileUuid) .delete(); console.log('File deleted successfully'); - } catch (err) { - exceptionHandler(err); - } + }, optsWithGlobals); } export async function deleteDirectory(optsWithGlobals: GlobalOptions) { - const storage = new Storage(optsWithGlobals); - try { + await withErrorHandler(async (storage: Storage) => { await storage .bucket(optsWithGlobals.bucketUuid) .directory(optsWithGlobals.directoryUuid) .delete(); console.log('Directory deleted successfully'); + }, optsWithGlobals); +} + +async function withErrorHandler( + handler: (module: Storage) => Promise, + optsWithGlobals: GlobalOptions, +) { + try { + const module = new Storage(optsWithGlobals); + await handler(module); } catch (err) { exceptionHandler(err); } From 2387f3117598752357ff8d868a19cbb2bb31a0b9 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Thu, 21 Dec 2023 14:27:11 +0100 Subject: [PATCH 07/20] Add get bucket endpoint --- packages/sdk/src/modules/storage/storage-bucket.ts | 11 +++++++++++ packages/sdk/src/tests/storage.test.ts | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/packages/sdk/src/modules/storage/storage-bucket.ts b/packages/sdk/src/modules/storage/storage-bucket.ts index ead8ea5..388b371 100644 --- a/packages/sdk/src/modules/storage/storage-bucket.ts +++ b/packages/sdk/src/modules/storage/storage-bucket.ts @@ -48,6 +48,17 @@ export class StorageBucket extends ApillonModel { this.populate(data); } + /** + * Gets bucket details. + * @returns Bucket instance + */ + async get(): Promise { + const data = await ApillonApi.get( + this.API_PREFIX, + ); + return new StorageBucket(data.bucketUuid, data); + } + /** * Gets contents of a bucket. * @returns A a list of File and Directory objects. diff --git a/packages/sdk/src/tests/storage.test.ts b/packages/sdk/src/tests/storage.test.ts index 0fc630a..819aa23 100644 --- a/packages/sdk/src/tests/storage.test.ts +++ b/packages/sdk/src/tests/storage.test.ts @@ -22,6 +22,13 @@ describe('Storage tests', () => { items.forEach((item) => expect(item.name).toBeTruthy()); }); + test('Get bucket', async () => { + const bucket = await storage.bucket(bucketUuid).get(); + expect(bucket.uuid).toEqual(bucketUuid); + expect(bucket.name).toBeTruthy(); + expect(bucket.size).toBeGreaterThan(0); + }); + test('get bucket content', async () => { const { items } = await storage.bucket(bucketUuid).listObjects(); for (const item of items) { From 7c8d3f60c9b2815cb14f8f9c0e44a51c6cb829d4 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Fri, 22 Dec 2023 13:58:47 +0100 Subject: [PATCH 08/20] feat: Resolve file CIDs after uploading --- .../sdk/src/modules/storage/storage-bucket.ts | 39 ++++++++++++++++--- packages/sdk/src/tests/storage.test.ts | 27 ++++++++++++- packages/sdk/src/types/storage.ts | 21 ++++++++-- packages/sdk/src/util/file-utils.ts | 9 +++-- 4 files changed, 82 insertions(+), 14 deletions(-) diff --git a/packages/sdk/src/modules/storage/storage-bucket.ts b/packages/sdk/src/modules/storage/storage-bucket.ts index 388b371..2b98c6a 100644 --- a/packages/sdk/src/modules/storage/storage-bucket.ts +++ b/packages/sdk/src/modules/storage/storage-bucket.ts @@ -10,11 +10,12 @@ import { } from '../../types/storage'; import { File } from './file'; import { constructUrlWithQueryParams } from '../../lib/common'; -import { IApillonList } from '../../types/apillon'; +import { IApillonList, LogLevel } from '../../types/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { uploadFiles } from '../../util/file-utils'; import { ApillonModel } from '../../lib/apillon'; import { Ipns } from './ipns'; +import { ApillonLogger } from '../../lib/apillon-logger'; export class StorageBucket extends ApillonModel { /** @@ -119,8 +120,36 @@ export class StorageBucket extends ApillonModel { public async uploadFromFolder( folderPath: string, params?: IFileUploadRequest, - ): Promise { - await uploadFiles(folderPath, this.API_PREFIX, params); + ): Promise { + const uploadedFiles = await uploadFiles( + folderPath, + this.API_PREFIX, + params, + ); + + if (!params?.awaitCid) { + return uploadedFiles; + } + + // Resolve CIDs for each file + let retryTimes = 0; + ApillonLogger.log('Resolving file CIDs...'); + while (!uploadedFiles.every((f) => !!f.CID)) { + for (const uploadedFile of uploadedFiles) { + const file = await new File( + this.uuid, + null, + uploadedFile.fileUuid, + ).get(); + uploadedFile.CID = file.CID; + } + + await new Promise((resolve) => setTimeout(resolve, 1000)); + if (++retryTimes >= 10) { + ApillonLogger.log('Unable to resolve file CIDs', LogLevel.ERROR); + return uploadedFiles; + } + } } /** @@ -131,8 +160,8 @@ export class StorageBucket extends ApillonModel { public async uploadFiles( files: FileMetadata[], params?: IFileUploadRequest, - ): Promise { - await uploadFiles(null, this.API_PREFIX, params, files); + ): Promise { + return await uploadFiles(null, this.API_PREFIX, params, files); } /** diff --git a/packages/sdk/src/tests/storage.test.ts b/packages/sdk/src/tests/storage.test.ts index 819aa23..d08c279 100644 --- a/packages/sdk/src/tests/storage.test.ts +++ b/packages/sdk/src/tests/storage.test.ts @@ -76,13 +76,36 @@ describe('Storage tests', () => { expect(file.name).toBeTruthy(); }); - test.skip('upload files from folder', async () => { + test('upload files from folder', async () => { try { const uploadDir = resolve(__dirname, './helpers/website/'); + console.time('File upload complete'); - await storage.bucket(bucketUuid).uploadFromFolder(uploadDir); + const files = await storage + .bucket(bucketUuid) + .uploadFromFolder(uploadDir); console.timeEnd('File upload complete'); + expect(files.every((f) => !!f.fileUuid)).toBeTruthy(); + + // console.log(content); + } catch (e) { + console.log(e); + } + }); + + test('upload files from folder with awaitCid', async () => { + try { + const uploadDir = resolve(__dirname, './helpers/website/'); + + console.time('File upload complete'); + const files = await storage + .bucket(bucketUuid) + .uploadFromFolder(uploadDir, { awaitCid: true }); + console.timeEnd('File upload complete'); + + expect(files.every((f) => !!f.CID)).toBeTruthy(); + // console.log(content); } catch (e) { console.log(e); diff --git a/packages/sdk/src/types/storage.ts b/packages/sdk/src/types/storage.ts index e4e4196..eb26c87 100644 --- a/packages/sdk/src/types/storage.ts +++ b/packages/sdk/src/types/storage.ts @@ -36,6 +36,14 @@ export interface FileMetadata { * For example, an images/icons path creates images directory in a bucket and icons directory inside it. File will then be created in the icons directory. */ path?: string; + /** + * The file's UUID, obtained after uploadig + */ + fileUuid?: string; + /** + * The file's CID on IPFS + */ + CID?: string; } export interface IFileUploadRequest { @@ -46,17 +54,22 @@ export interface IFileUploadRequest { * * @docs [IPFS docs](https://dweb-primer.ipfs.io/files-on-ipfs/wrap-directories-around-content#explanation) */ - wrapWithDirectory: boolean; + wrapWithDirectory?: boolean; /** * Path to wrapped directory inside bucket. * * Mandatory when `wrapWithDirectory` is true. * - * **Example**: `main-dir` --> Files get uploaded to a folder named `main-dir` in the bucket. + * @example `main-dir` --> Files get uploaded to a folder named `main-dir` in the bucket. * - * **Example 2**: `main-dir/sub-dir` --> Files get uploaded to a subfolder in the location `/main-dir/sub-dir`. + * @example `main-dir/sub-dir` --> Files get uploaded to a subfolder in the location `/main-dir/sub-dir`. + */ + directoryPath?: string; + + /** + * If set to true, the upload action will wait until files receive a CID from IPFS before returning a result */ - directoryPath: string; + awaitCid?: boolean; } export interface IFileUploadResponse { diff --git a/packages/sdk/src/util/file-utils.ts b/packages/sdk/src/util/file-utils.ts index 6cf7b39..108fa01 100644 --- a/packages/sdk/src/util/file-utils.ts +++ b/packages/sdk/src/util/file-utils.ts @@ -92,7 +92,7 @@ export async function uploadFiles( apiPrefix: string, params?: IFileUploadRequest, files?: FileMetadata[], -): Promise { +): Promise { if (folderPath) { ApillonLogger.log(`Preparing to upload files from ${folderPath}...`); } else if (files?.length) { @@ -116,7 +116,7 @@ export async function uploadFiles( const fileChunkSize = 50; const sessionUuid = uuidv4(); - await Promise.all( + const uploadedFiles = await Promise.all( chunkify(files, fileChunkSize).map(async (fileGroup) => { const data = await ApillonApi.post( `${apiPrefix}/upload`, @@ -127,6 +127,7 @@ export async function uploadFiles( ); await uploadFilesToS3(data.files, fileGroup); + return data.files; }), ); @@ -134,7 +135,9 @@ export async function uploadFiles( ApillonLogger.log('Closing upload session...'); await ApillonApi.post(`${apiPrefix}/upload/${sessionUuid}/end`, params); - ApillonLogger.logWithTime('Session ended.'); + ApillonLogger.logWithTime('Upload session ended.'); + + return uploadedFiles.flatMap((f) => f); } function chunkify(files: FileMetadata[], chunkSize = 10): FileMetadata[][] { From 87c257c9b1f5c4e08126b255dd86e64a6f17a629 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Fri, 22 Dec 2023 14:16:20 +0100 Subject: [PATCH 09/20] Update package versions --- package.json | 2 +- packages/cli/package.json | 2 +- packages/sdk/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 65c84f6..50b2a1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apillon-web3-tools", - "version": "1.2.0", + "version": "1.2.1", "description": "Monorepo for Apillon tools", "author": "Apillon", "license": "MIT", diff --git a/packages/cli/package.json b/packages/cli/package.json index 504ce45..62a84e7 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@apillon/cli", "description": "▶◀ Apillon CLI tools ▶◀", - "version": "1.2.0", + "version": "1.1.0", "author": "Apillon", "license": "MIT", "main": "./dist/index.js", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index a1e440e..4a54338 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,7 +1,7 @@ { "name": "@apillon/sdk", "description": "▶◀ Apillon SDK for NodeJS ▶◀", - "version": "1.2.0", + "version": "1.2.1", "author": "Apillon", "license": "MIT", "main": "./dist/index.js", From f65164281c5000d75439f73f3882a03c81ebe120 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Thu, 18 Jan 2024 11:46:11 +0100 Subject: [PATCH 10/20] Hosting website updates --- package.json | 2 +- .../src/modules/hosting/hosting.commands.ts | 4 ++- packages/sdk/package.json | 2 +- .../src/modules/hosting/hosting-website.ts | 34 ++++++++++++++++++- packages/sdk/src/types/hosting.ts | 5 ++- packages/sdk/src/util/file-utils.ts | 6 ++-- 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 50b2a1a..eea1440 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apillon-web3-tools", - "version": "1.2.1", + "version": "1.3.0", "description": "Monorepo for Apillon tools", "author": "Apillon", "license": "MIT", diff --git a/packages/cli/src/modules/hosting/hosting.commands.ts b/packages/cli/src/modules/hosting/hosting.commands.ts index cc83f7c..1f4e450 100644 --- a/packages/cli/src/modules/hosting/hosting.commands.ts +++ b/packages/cli/src/modules/hosting/hosting.commands.ts @@ -101,7 +101,9 @@ export function createHostingCommands(cli: Command) { '--status ', 'Status of the deployment (optional) Choose from:\n' + ` ${DeploymentStatus.INITIATED}: Initiated\n` + - ` ${DeploymentStatus.IN_PROCESS}: In process\n` + + ` ${DeploymentStatus.IN_PROGRESS}: In process\n` + + ` ${DeploymentStatus.IN_REVIEW}: In review\n` + + ` ${DeploymentStatus.APPROVED}: Approved\n` + ` ${DeploymentStatus.SUCCESSFUL}: Successful\n` + ` ${DeploymentStatus.FAILED}: Failed\n`, ).choices(enumValues(DeploymentStatus)), diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 4a54338..a11b213 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,7 +1,7 @@ { "name": "@apillon/sdk", "description": "▶◀ Apillon SDK for NodeJS ▶◀", - "version": "1.2.1", + "version": "1.3.0", "author": "Apillon", "license": "MIT", "main": "./dist/index.js", diff --git a/packages/sdk/src/modules/hosting/hosting-website.ts b/packages/sdk/src/modules/hosting/hosting-website.ts index f9a691f..34b8839 100644 --- a/packages/sdk/src/modules/hosting/hosting-website.ts +++ b/packages/sdk/src/modules/hosting/hosting-website.ts @@ -1,5 +1,9 @@ import { constructUrlWithQueryParams } from '../../lib/common'; -import { DeployToEnvironment, IDeploymentFilters } from '../../types/hosting'; +import { + DeployToEnvironment, + DeploymentStatus, + IDeploymentFilters, +} from '../../types/hosting'; import { IApillonList } from '../../types/apillon'; import { Deployment } from './deployment'; import { ApillonApi } from '../../lib/apillon-api'; @@ -39,6 +43,26 @@ export class HostingWebsite extends ApillonModel { */ public ipnsProduction: string = null; + /** + * Link to staging version of the website + */ + public w3StagingLink: string = null; + + /** + * Link to production version of the website + */ + public w3ProductionLink: string = null; + + /** + * Website last deployment (to any environment) unique identifier + */ + public lastDeploymentUuid: string = null; + + /** + * Status of last deployment + */ + public lastDeploymentStatus: DeploymentStatus = null; + /** * Constructor which should only be called via Hosting class. * @param uuid Unique identifier of the website. @@ -140,4 +164,12 @@ export class HostingWebsite extends ApillonModel { deployment(deploymentUuid: string): Deployment { return new Deployment(this.uuid, deploymentUuid, {}); } + + protected override serializeFilter(key: string, value: any) { + const serialized = super.serializeFilter(key, value); + const enums = { + lastDeploymentStatus: DeploymentStatus[value], + }; + return Object.keys(enums).includes(key) ? enums[key] : serialized; + } } diff --git a/packages/sdk/src/types/hosting.ts b/packages/sdk/src/types/hosting.ts index 7540918..23eb831 100644 --- a/packages/sdk/src/types/hosting.ts +++ b/packages/sdk/src/types/hosting.ts @@ -8,9 +8,12 @@ export enum DeployToEnvironment { export enum DeploymentStatus { INITIATED = 0, - IN_PROCESS = 1, + IN_PROGRESS = 1, + IN_REVIEW = 2, + APPROVED = 3, SUCCESSFUL = 10, FAILED = 100, + REJECTED = 101, } export interface IWebsiteFilters extends IApillonPagination { diff --git a/packages/sdk/src/util/file-utils.ts b/packages/sdk/src/util/file-utils.ts index 108fa01..bb8643b 100644 --- a/packages/sdk/src/util/file-utils.ts +++ b/packages/sdk/src/util/file-utils.ts @@ -160,8 +160,8 @@ function uuidv4() { // Convert bytes to hexadecimal and format the UUID const uuid = bytes.toString('hex'); - return `${uuid.substr(0, 8)}-${uuid.substr(8, 4)}-${uuid.substr( + return `${uuid.substring(0, 8)}-${uuid.substring(8, 12)}-${uuid.substring( 12, - 4, - )}-${uuid.substr(16, 4)}-${uuid.substr(20)}`; + 16, + )}-${uuid.substring(16, 20)}-${uuid.substring(20)}`; } From e0c10b8888f952db9761c66d73cba55a4b5091d5 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Thu, 18 Jan 2024 13:01:22 +0100 Subject: [PATCH 11/20] Storage bucket awaitCid improvements --- .../sdk/src/modules/storage/storage-bucket.ts | 64 ++++++++++++------ packages/sdk/src/tests/storage.test.ts | 67 ++++++++----------- packages/sdk/src/types/storage.ts | 4 ++ packages/sdk/src/util/file-utils.ts | 4 +- 4 files changed, 77 insertions(+), 62 deletions(-) diff --git a/packages/sdk/src/modules/storage/storage-bucket.ts b/packages/sdk/src/modules/storage/storage-bucket.ts index 2b98c6a..a3d5228 100644 --- a/packages/sdk/src/modules/storage/storage-bucket.ts +++ b/packages/sdk/src/modules/storage/storage-bucket.ts @@ -116,12 +116,13 @@ export class StorageBucket extends ApillonModel { * Uploads files inside a local folder via path. * @param folderPath Path to the folder to upload. * @param {IFileUploadRequest} params - Optional parameters to be used for uploading files + * @returns List of uploaded files with their properties */ public async uploadFromFolder( folderPath: string, params?: IFileUploadRequest, ): Promise { - const uploadedFiles = await uploadFiles( + const { files: uploadedFiles, sessionUuid } = await uploadFiles( folderPath, this.API_PREFIX, params, @@ -131,25 +132,7 @@ export class StorageBucket extends ApillonModel { return uploadedFiles; } - // Resolve CIDs for each file - let retryTimes = 0; - ApillonLogger.log('Resolving file CIDs...'); - while (!uploadedFiles.every((f) => !!f.CID)) { - for (const uploadedFile of uploadedFiles) { - const file = await new File( - this.uuid, - null, - uploadedFile.fileUuid, - ).get(); - uploadedFile.CID = file.CID; - } - - await new Promise((resolve) => setTimeout(resolve, 1000)); - if (++retryTimes >= 10) { - ApillonLogger.log('Unable to resolve file CIDs', LogLevel.ERROR); - return uploadedFiles; - } - } + return await this.resolveFileCIDs(sessionUuid, uploadedFiles.length); } /** @@ -161,7 +144,18 @@ export class StorageBucket extends ApillonModel { files: FileMetadata[], params?: IFileUploadRequest, ): Promise { - return await uploadFiles(null, this.API_PREFIX, params, files); + const { files: uploadedFiles, sessionUuid } = await uploadFiles( + null, + this.API_PREFIX, + params, + files, + ); + + if (!params?.awaitCid) { + return uploadedFiles; + } + + return await this.resolveFileCIDs(sessionUuid, uploadedFiles.length); } /** @@ -182,6 +176,34 @@ export class StorageBucket extends ApillonModel { return new Directory(this.uuid, directoryUuid); } + private async resolveFileCIDs( + sessionUuid: string, + limit: number, + ): Promise { + let resolvedFiles: FileMetadata[] = []; + + // Resolve CIDs for each file + let retryTimes = 0; + ApillonLogger.log('Resolving file CIDs...'); + while (resolvedFiles.length === 0 || !resolvedFiles.every((f) => !!f.CID)) { + resolvedFiles = (await this.listFiles({ sessionUuid, limit })).items.map( + (file) => ({ + fileName: file.name, + fileUuid: file.uuid, + CID: file.CID, + content: null, + }), + ); + + await new Promise((resolve) => setTimeout(resolve, 1000)); + if (++retryTimes >= 15) { + ApillonLogger.log('Unable to resolve file CIDs', LogLevel.ERROR); + return resolvedFiles; + } + } + return resolvedFiles; + } + //#region IPNS methods /** diff --git a/packages/sdk/src/tests/storage.test.ts b/packages/sdk/src/tests/storage.test.ts index d08c279..34afc3a 100644 --- a/packages/sdk/src/tests/storage.test.ts +++ b/packages/sdk/src/tests/storage.test.ts @@ -95,55 +95,44 @@ describe('Storage tests', () => { }); test('upload files from folder with awaitCid', async () => { - try { - const uploadDir = resolve(__dirname, './helpers/website/'); + const uploadDir = resolve(__dirname, './helpers/website/'); - console.time('File upload complete'); - const files = await storage - .bucket(bucketUuid) - .uploadFromFolder(uploadDir, { awaitCid: true }); - console.timeEnd('File upload complete'); - - expect(files.every((f) => !!f.CID)).toBeTruthy(); + console.time('File upload complete'); + const files = await storage + .bucket(bucketUuid) + .uploadFromFolder(uploadDir, { awaitCid: true }); + console.timeEnd('File upload complete'); - // console.log(content); - } catch (e) { - console.log(e); - } + expect(files.length).toBeGreaterThan(0); + expect(files.every((f) => !!f.CID)).toBeTruthy(); }); - test.skip('upload files from buffer', async () => { + test('upload files from buffer', async () => { const html = fs.readFileSync( resolve(__dirname, './helpers/website/index.html'), ); const css = fs.readFileSync( resolve(__dirname, './helpers/website/style.css'), ); - try { - console.time('File upload complete'); - await storage.bucket(bucketUuid).uploadFiles( - [ - { - fileName: 'index.html', - contentType: 'text/html', - path: null, - content: html, - }, - { - fileName: 'style.css', - contentType: 'text/css', - path: null, - content: css, - }, - ], - { wrapWithDirectory: true, directoryPath: 'main/subdir' }, - ); - console.timeEnd('File upload complete'); - - // console.log(content); - } catch (e) { - console.log(e); - } + console.time('File upload complete'); + await storage.bucket(bucketUuid).uploadFiles( + [ + { + fileName: 'index.html', + contentType: 'text/html', + path: null, + content: html, + }, + { + fileName: 'style.css', + contentType: 'text/css', + path: null, + content: css, + }, + ], + { wrapWithDirectory: true, directoryPath: 'main/subdir' }, + ); + console.timeEnd('File upload complete'); }); test.skip('delete a file', async () => { diff --git a/packages/sdk/src/types/storage.ts b/packages/sdk/src/types/storage.ts index eb26c87..931df62 100644 --- a/packages/sdk/src/types/storage.ts +++ b/packages/sdk/src/types/storage.ts @@ -19,6 +19,10 @@ export interface IStorageBucketContentRequest extends IApillonPagination { export interface IBucketFilesRequest extends IApillonPagination { fileStatus?: FileStatus; + /** + * Search files by upload session UUID + */ + sessionUuid: string; } export interface FileMetadata { diff --git a/packages/sdk/src/util/file-utils.ts b/packages/sdk/src/util/file-utils.ts index bb8643b..263e4fa 100644 --- a/packages/sdk/src/util/file-utils.ts +++ b/packages/sdk/src/util/file-utils.ts @@ -92,7 +92,7 @@ export async function uploadFiles( apiPrefix: string, params?: IFileUploadRequest, files?: FileMetadata[], -): Promise { +): Promise<{ sessionUuid: string; files: FileMetadata[] }> { if (folderPath) { ApillonLogger.log(`Preparing to upload files from ${folderPath}...`); } else if (files?.length) { @@ -137,7 +137,7 @@ export async function uploadFiles( await ApillonApi.post(`${apiPrefix}/upload/${sessionUuid}/end`, params); ApillonLogger.logWithTime('Upload session ended.'); - return uploadedFiles.flatMap((f) => f); + return { sessionUuid, files: uploadedFiles.flatMap((f) => f) }; } function chunkify(files: FileMetadata[], chunkSize = 10): FileMetadata[][] { From 9d4019618d0a1b2b033d5633c558561d6a61fa8c Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Fri, 19 Jan 2024 11:16:38 +0100 Subject: [PATCH 12/20] Update unit tests --- packages/sdk/src/tests/hosting.test.ts | 5 ++++- packages/sdk/src/tests/identity.test.ts | 3 ++- packages/sdk/src/tests/nft.test.ts | 12 +++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/sdk/src/tests/hosting.test.ts b/packages/sdk/src/tests/hosting.test.ts index 80a374c..4787af7 100644 --- a/packages/sdk/src/tests/hosting.test.ts +++ b/packages/sdk/src/tests/hosting.test.ts @@ -1,6 +1,6 @@ import { resolve } from 'path'; import { Hosting } from '../modules/hosting/hosting'; -import { DeployToEnvironment } from '../types/hosting'; +import { DeployToEnvironment, DeploymentStatus } from '../types/hosting'; import { getConfig, getWebsiteUUID } from './helpers/helper'; import { HostingWebsite } from '../modules/hosting/hosting-website'; import * as fs from 'fs'; @@ -37,6 +37,9 @@ describe('Hosting tests', () => { const deployment = await website.deploy(DeployToEnvironment.TO_STAGING); expect(deployment.environment).toEqual(DeployToEnvironment.TO_STAGING); deploymentUuid = deployment.uuid; + + await website.get(); + expect(website.lastDeploymentStatus).toEqual(DeploymentStatus.INITIATED); }); test.skip('upload files from buffer', async () => { diff --git a/packages/sdk/src/tests/identity.test.ts b/packages/sdk/src/tests/identity.test.ts index 3d2add3..a25618a 100644 --- a/packages/sdk/src/tests/identity.test.ts +++ b/packages/sdk/src/tests/identity.test.ts @@ -158,7 +158,8 @@ describe('Identity Module tests', () => { '3rJriA6MiYj7oFXv5hgxvSuacenm8fk76Kb5TEEHcWWQVvii', ); expect(subsocial.content.name).toBe('dev only'); - expect(subsocial.content.interests).toContain('crypto'); + expect(subsocial.content.summary).toBeDefined(); + expect(subsocial.content.about).toBeDefined(); const { polkadot } = await identity.getWalletIdentity( '5HqHQDGcHqSQELAyr5PbJNAcQJew4vsoNCf5kkSpXcUGMtCK', diff --git a/packages/sdk/src/tests/nft.test.ts b/packages/sdk/src/tests/nft.test.ts index 8657ed2..16f300b 100644 --- a/packages/sdk/src/tests/nft.test.ts +++ b/packages/sdk/src/tests/nft.test.ts @@ -24,8 +24,9 @@ describe('Nft tests', () => { const collection = await nft.create({ chain: EvmChain.MOONBASE, collectionType: CollectionType.GENERIC, - name: 'created from sdk tests', - symbol: 'cfst', + name: 'sdk test', + description: 'created from sdk tests', + symbol: 'sdkt', royaltiesFees: 0, royaltiesAddress: '0x0000000000000000000000000000000000000000', baseUri: 'https://test.com/metadata/', @@ -36,6 +37,11 @@ describe('Nft tests', () => { drop: false, }); expect(collection.uuid).toBeDefined(); + expect(collection.contractAddress).toBeDefined(); + expect(collection.symbol).toEqual('sdkt'); + expect(collection.name).toEqual('sdk test'); + expect(collection.description).toEqual('created from sdk tests'); + collectionUuid = collection.uuid; }); @@ -56,7 +62,7 @@ describe('Nft tests', () => { test('get nft collection details', async () => { const collection = await nft.collection(collectionUuid).get(); console.log(collection); - expect(collection.name).toBe('created from sdk tests'); + expect(collection.name).toBe('sdk test'); }); test('should fail nest minting for collection that is not nestable if collection populated', async () => { From 415b519b8515ba343c981da919152c8639ef6ba4 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Fri, 19 Jan 2024 13:06:47 +0100 Subject: [PATCH 13/20] Add .git folder to ignored upload folders --- packages/sdk/src/util/file-utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sdk/src/util/file-utils.ts b/packages/sdk/src/util/file-utils.ts index 263e4fa..9f05eff 100644 --- a/packages/sdk/src/util/file-utils.ts +++ b/packages/sdk/src/util/file-utils.ts @@ -21,6 +21,7 @@ function listFilesRecursive( const gitignorePatterns = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, 'utf-8').split('\n') : []; + gitignorePatterns.push('.git'); // Always ignore .git folder. const files = fs.readdirSync(folderPath); for (const file of files) { From f475b9055951f0334b79c02bfe7b7cdfe7cbcdf0 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Fri, 19 Jan 2024 15:16:04 +0100 Subject: [PATCH 14/20] Add transactionHash response on nft actions --- packages/sdk/src/modules/nft/nft-collection.ts | 18 +++++++----------- packages/sdk/src/tests/nft.test.ts | 1 + packages/sdk/src/types/apillon.ts | 9 --------- packages/sdk/src/types/nfts.ts | 5 +++++ 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/packages/sdk/src/modules/nft/nft-collection.ts b/packages/sdk/src/modules/nft/nft-collection.ts index b6c4732..8b0b3ce 100644 --- a/packages/sdk/src/modules/nft/nft-collection.ts +++ b/packages/sdk/src/modules/nft/nft-collection.ts @@ -1,12 +1,8 @@ -import { TransactionStatus } from './../../types/nfts'; +import { INftActionResponse, TransactionStatus } from './../../types/nfts'; import { ApillonApi } from '../../lib/apillon-api'; import { ApillonLogger } from '../../lib/apillon-logger'; import { constructUrlWithQueryParams } from '../../lib/common'; -import { - IApillonList, - IApillonStatus, - IApillonBoolResponse, -} from '../../types/apillon'; +import { IApillonList } from '../../types/apillon'; import { ICollection, ITransactionFilters, @@ -148,7 +144,7 @@ export class NftCollection extends ApillonModel { * @returns Call status. */ public async mint(receiver: string, quantity: number) { - const data = await ApillonApi.post( + const data = await ApillonApi.post( `${this.API_PREFIX}/mint`, { receivingAddress: receiver, quantity }, ); @@ -170,14 +166,14 @@ export class NftCollection extends ApillonModel { parentCollectionUuid: string, parentNftId: number, quantity: number, - ): Promise { + ): Promise { if ( this.collectionType != null && this.collectionType != CollectionType.NESTABLE ) { throw new Error('Collection is not nestable.'); } - const data = await ApillonApi.post( + const data = await ApillonApi.post( `${this.API_PREFIX}/nest-mint`, { parentCollectionUuid, parentNftId, quantity }, ); @@ -192,11 +188,11 @@ export class NftCollection extends ApillonModel { * @param tokenId Token ID of the NFT we want to burn. * @returns Status. */ - public async burn(tokenId: string): Promise { + public async burn(tokenId: string): Promise { if (this.isRevokable != null && !this.isRevokable) { throw new Error('Collection is not revokable.'); } - const data = await ApillonApi.post( + const data = await ApillonApi.post( `${this.API_PREFIX}/burn`, { tokenId }, ); diff --git a/packages/sdk/src/tests/nft.test.ts b/packages/sdk/src/tests/nft.test.ts index 16f300b..d7dce87 100644 --- a/packages/sdk/src/tests/nft.test.ts +++ b/packages/sdk/src/tests/nft.test.ts @@ -49,6 +49,7 @@ describe('Nft tests', () => { const collection = nft.collection(collectionUuid); const res = await collection.mint(receiverAddress, 1); expect(res.success).toBe(true); + expect(res.transactionHash).toBeDefined(); }); test('get nft collection transactions', async () => { diff --git a/packages/sdk/src/types/apillon.ts b/packages/sdk/src/types/apillon.ts index 50c26cc..d9c3c8d 100644 --- a/packages/sdk/src/types/apillon.ts +++ b/packages/sdk/src/types/apillon.ts @@ -3,11 +3,6 @@ export interface IApillonList { total: number; } -export interface IApillonStatus { - status: number; - success: boolean; -} - export interface IApillonPagination { search?: string; page?: number; @@ -16,10 +11,6 @@ export interface IApillonPagination { desc?: boolean; } -export interface IApillonBoolResponse { - success: boolean; -} - export enum LogLevel { NONE = 1, ERROR = 2, diff --git a/packages/sdk/src/types/nfts.ts b/packages/sdk/src/types/nfts.ts index 9b1ee2a..db32ff9 100644 --- a/packages/sdk/src/types/nfts.ts +++ b/packages/sdk/src/types/nfts.ts @@ -86,6 +86,11 @@ export interface ICollectionFilters extends IApillonPagination { collectionStatus?: CollectionStatus; } +export interface INftActionResponse { + success: boolean; + transactionHash: string; +} + export interface ITransactionFilters extends IApillonPagination { transactionStatus?: TransactionStatus; transactionType?: TransactionType; From 55edb5b2a47756223db2c55e3f7f4747f725c425 Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Tue, 23 Jan 2024 11:19:10 +0100 Subject: [PATCH 15/20] Add isAutoIncrement NFT coll. parameter --- packages/sdk/src/modules/nft/nft-collection.ts | 5 +++-- packages/sdk/src/types/nfts.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/sdk/src/modules/nft/nft-collection.ts b/packages/sdk/src/modules/nft/nft-collection.ts index 8b0b3ce..b64fdb7 100644 --- a/packages/sdk/src/modules/nft/nft-collection.ts +++ b/packages/sdk/src/modules/nft/nft-collection.ts @@ -141,12 +141,13 @@ export class NftCollection extends ApillonModel { * Mints new nfts to a receiver. * @param receiver Address of the receiver. * @param quantity Amount of nfts to mint. + * @param idsToMint Custom token IDs for minted NFTs. Only when collection.isAutoIncrement=false. * @returns Call status. */ - public async mint(receiver: string, quantity: number) { + public async mint(receiver: string, quantity: number, idsToMint?: number[]) { const data = await ApillonApi.post( `${this.API_PREFIX}/mint`, - { receivingAddress: receiver, quantity }, + { receivingAddress: receiver, quantity, idsToMint }, ); ApillonLogger.log(`NFT minted successfully to ${receiver}`); diff --git a/packages/sdk/src/types/nfts.ts b/packages/sdk/src/types/nfts.ts index db32ff9..c2ea8d4 100644 --- a/packages/sdk/src/types/nfts.ts +++ b/packages/sdk/src/types/nfts.ts @@ -3,7 +3,6 @@ import { IApillonPagination } from './apillon'; export enum EvmChain { MOONBEAM = 1284, MOONBASE = 1287, - ASTAR_SHIBUYA = 81, ASTAR = 592, } @@ -54,6 +53,7 @@ export interface ICreateCollection { dropStart?: number; dropPrice?: number; dropReserve?: number; + isAutoIncrement?: boolean; } //OUTPUTS From 7c8c0dcea4a7a144dd4db96e25d7fb66eacf9e7b Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Tue, 23 Jan 2024 11:41:25 +0100 Subject: [PATCH 16/20] Add NFT mint data parameters --- .../sdk/src/modules/nft/nft-collection.ts | 25 ++++++++++++------- packages/sdk/src/tests/nft.test.ts | 9 ++++--- packages/sdk/src/types/nfts.ts | 16 ++++++++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/packages/sdk/src/modules/nft/nft-collection.ts b/packages/sdk/src/modules/nft/nft-collection.ts index b64fdb7..88e43c1 100644 --- a/packages/sdk/src/modules/nft/nft-collection.ts +++ b/packages/sdk/src/modules/nft/nft-collection.ts @@ -1,4 +1,8 @@ -import { INftActionResponse, TransactionStatus } from './../../types/nfts'; +import { + IMintNftData, + INftActionResponse, + TransactionStatus, +} from './../../types/nfts'; import { ApillonApi } from '../../lib/apillon-api'; import { ApillonLogger } from '../../lib/apillon-logger'; import { constructUrlWithQueryParams } from '../../lib/common'; @@ -138,19 +142,22 @@ export class NftCollection extends ApillonModel { } /** - * Mints new nfts to a receiver. - * @param receiver Address of the receiver. - * @param quantity Amount of nfts to mint. - * @param idsToMint Custom token IDs for minted NFTs. Only when collection.isAutoIncrement=false. - * @returns Call status. + * @param {IMintNftData} params - NFT mint parameters + * @returns {INftActionResponse} - success status and transaction hash of the mint */ - public async mint(receiver: string, quantity: number, idsToMint?: number[]) { + public async mint(params: IMintNftData) { + if (params.idsToMint?.length) { + params.quantity = params.idsToMint.length; + } + const data = await ApillonApi.post( `${this.API_PREFIX}/mint`, - { receivingAddress: receiver, quantity, idsToMint }, + params, ); - ApillonLogger.log(`NFT minted successfully to ${receiver}`); + ApillonLogger.log( + `${params.quantity} NFTs minted successfully to ${params.receivingAddress}`, + ); return data; } diff --git a/packages/sdk/src/tests/nft.test.ts b/packages/sdk/src/tests/nft.test.ts index d7dce87..ee17871 100644 --- a/packages/sdk/src/tests/nft.test.ts +++ b/packages/sdk/src/tests/nft.test.ts @@ -6,12 +6,12 @@ import { getCollectionUUID, getConfig, getMintAddress } from './helpers/helper'; describe('Nft tests', () => { let nft: Nft; let collectionUuid: string; - let receiverAddress: string; + let receivingAddress: string; beforeAll(async () => { nft = new Nft(getConfig()); collectionUuid = getCollectionUUID(); - receiverAddress = getMintAddress(); + receivingAddress = getMintAddress(); }); test('list nft collections', async () => { @@ -47,7 +47,10 @@ describe('Nft tests', () => { test('mints a new nft', async () => { const collection = nft.collection(collectionUuid); - const res = await collection.mint(receiverAddress, 1); + const res = await collection.mint({ + receivingAddress, + quantity: 1, + }); expect(res.success).toBe(true); expect(res.transactionHash).toBeDefined(); }); diff --git a/packages/sdk/src/types/nfts.ts b/packages/sdk/src/types/nfts.ts index c2ea8d4..f728f1d 100644 --- a/packages/sdk/src/types/nfts.ts +++ b/packages/sdk/src/types/nfts.ts @@ -95,3 +95,19 @@ export interface ITransactionFilters extends IApillonPagination { transactionStatus?: TransactionStatus; transactionType?: TransactionType; } + +export interface IMintNftData { + /** + * Address to receive the minted NFT + */ + receivingAddress: string; + /** + * How many NFTs to mint to the receiver + */ + quantity?: number; + /** + * If collection is set as isAutoIncrement=false, + * use this parameter to define the custom minted NFT token IDS + */ + idsToMint?: number[]; +} From 8a6eb5981429a729f0f15bd1a26d1b0d1406415b Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Thu, 25 Jan 2024 10:58:57 +0100 Subject: [PATCH 17/20] Add isAutoIncrement field and unit tests --- .../sdk/src/modules/nft/nft-collection.ts | 8 ++- packages/sdk/src/tests/nft.test.ts | 70 ++++++++++++++----- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/packages/sdk/src/modules/nft/nft-collection.ts b/packages/sdk/src/modules/nft/nft-collection.ts index 88e43c1..d6633f6 100644 --- a/packages/sdk/src/modules/nft/nft-collection.ts +++ b/packages/sdk/src/modules/nft/nft-collection.ts @@ -61,6 +61,12 @@ export class NftCollection extends ApillonModel { */ public isSoulbound: boolean = null; + /** + * If true, NFT token IDs are always sequential. + * If false, custom token IDs can be provided when minting. + */ + public isAutoIncrement: boolean = null; + /** * If collection owner can burn / destroy a NFT. */ @@ -145,7 +151,7 @@ export class NftCollection extends ApillonModel { * @param {IMintNftData} params - NFT mint parameters * @returns {INftActionResponse} - success status and transaction hash of the mint */ - public async mint(params: IMintNftData) { + public async mint(params: IMintNftData): Promise { if (params.idsToMint?.length) { params.quantity = params.idsToMint.length; } diff --git a/packages/sdk/src/tests/nft.test.ts b/packages/sdk/src/tests/nft.test.ts index ee17871..c6936ad 100644 --- a/packages/sdk/src/tests/nft.test.ts +++ b/packages/sdk/src/tests/nft.test.ts @@ -3,6 +3,22 @@ import { NftCollection } from '../modules/nft/nft-collection'; import { CollectionType, EvmChain } from '../types/nfts'; import { getCollectionUUID, getConfig, getMintAddress } from './helpers/helper'; +const nftData = { + chain: EvmChain.MOONBASE, + collectionType: CollectionType.GENERIC, + name: 'SDK Test', + description: 'Created from SDK tests', + symbol: 'SDKT', + royaltiesFees: 0, + royaltiesAddress: '0x0000000000000000000000000000000000000000', + baseUri: 'https://test.com/metadata/', + baseExtension: '.json', + maxSupply: 5, + isRevokable: false, + isSoulbound: false, + drop: false, +}; + describe('Nft tests', () => { let nft: Nft; let collectionUuid: string; @@ -21,26 +37,13 @@ describe('Nft tests', () => { }); test('creates a new collection', async () => { - const collection = await nft.create({ - chain: EvmChain.MOONBASE, - collectionType: CollectionType.GENERIC, - name: 'sdk test', - description: 'created from sdk tests', - symbol: 'sdkt', - royaltiesFees: 0, - royaltiesAddress: '0x0000000000000000000000000000000000000000', - baseUri: 'https://test.com/metadata/', - baseExtension: '.json', - maxSupply: 5, - isRevokable: false, - isSoulbound: false, - drop: false, - }); + const collection = await nft.create(nftData); expect(collection.uuid).toBeDefined(); expect(collection.contractAddress).toBeDefined(); - expect(collection.symbol).toEqual('sdkt'); - expect(collection.name).toEqual('sdk test'); - expect(collection.description).toEqual('created from sdk tests'); + expect(collection.symbol).toEqual('SDKT'); + expect(collection.name).toEqual('SDK Test'); + expect(collection.description).toEqual('Created from SDK tests'); + expect(collection.isAutoIncrement).toEqual(true); collectionUuid = collection.uuid; }); @@ -66,7 +69,7 @@ describe('Nft tests', () => { test('get nft collection details', async () => { const collection = await nft.collection(collectionUuid).get(); console.log(collection); - expect(collection.name).toBe('sdk test'); + expect(collection.name).toBe('SDK Test'); }); test('should fail nest minting for collection that is not nestable if collection populated', async () => { @@ -89,4 +92,33 @@ describe('Nft tests', () => { 'Collection is not revokable.', ); }); + + describe('NFT with custom IDs mint', () => { + test('creates a new collection', async () => { + const collection = await nft.create({ + ...nftData, + name: 'SDK Test isAutoIncrement=false', + isAutoIncrement: false, + }); + expect(collection.uuid).toBeDefined(); + expect(collection.contractAddress).toBeDefined(); + expect(collection.symbol).toEqual('SDKT'); + expect(collection.name).toEqual('SDK Test isAutoIncrement=false'); + expect(collection.description).toEqual('Created from SDK tests'); + expect(collection.isAutoIncrement).toEqual(false); + + collectionUuid = collection.uuid; + }); + + test('mints new nfts with custom IDs', async () => { + const collection = nft.collection(collectionUuid); + const res = await collection.mint({ + receivingAddress, + quantity: 2, + idsToMint: [10, 20], + }); + expect(res.success).toBe(true); + expect(res.transactionHash).toBeDefined(); + }); + }); }); From 5f1a5e2cb6ef2abb4aefb232c7e22c14a9da163b Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Wed, 31 Jan 2024 16:05:04 +0100 Subject: [PATCH 18/20] Make maxSupply nullable --- packages/sdk/README.md | 1 + packages/sdk/src/types/nfts.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sdk/README.md b/packages/sdk/README.md index 6f848aa..1d68c05 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -247,6 +247,7 @@ const collection1 = await nft.create({ description: 'A collection of unique space exploration NFTs.', baseUri: 'https://moonbeamnfts.com/collections/spaceexplorers/', baseExtension: 'json', + // If you omit the maxSupply parameter, the max supply will be unlimited maxSupply: 1000, isRevokable: false, isSoulbound: false, diff --git a/packages/sdk/src/types/nfts.ts b/packages/sdk/src/types/nfts.ts index f728f1d..3920a88 100644 --- a/packages/sdk/src/types/nfts.ts +++ b/packages/sdk/src/types/nfts.ts @@ -44,7 +44,7 @@ export interface ICreateCollection { description?: string; baseUri: string; baseExtension: string; - maxSupply: number; + maxSupply?: number; isRevokable: boolean; isSoulbound: boolean; royaltiesAddress: string; From 44f8b1d30913c8a1849f24b25aa24112389a59fc Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Thu, 1 Feb 2024 14:33:50 +0100 Subject: [PATCH 19/20] SDK version 2.0.0 --- package.json | 2 +- packages/cli/package.json | 2 +- packages/sdk/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index eea1440..33b220b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apillon-web3-tools", - "version": "1.3.0", + "version": "2.0.0", "description": "Monorepo for Apillon tools", "author": "Apillon", "license": "MIT", diff --git a/packages/cli/package.json b/packages/cli/package.json index 62a84e7..504ce45 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@apillon/cli", "description": "▶◀ Apillon CLI tools ▶◀", - "version": "1.1.0", + "version": "1.2.0", "author": "Apillon", "license": "MIT", "main": "./dist/index.js", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index a11b213..73a6940 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,7 +1,7 @@ { "name": "@apillon/sdk", "description": "▶◀ Apillon SDK for NodeJS ▶◀", - "version": "1.3.0", + "version": "2.0.0", "author": "Apillon", "license": "MIT", "main": "./dist/index.js", From a87db59d1b64dd9383a9f622f3d5572d1853c96a Mon Sep 17 00:00:00 2001 From: Damjan Dimitrov Date: Thu, 1 Feb 2024 15:24:50 +0100 Subject: [PATCH 20/20] PR review fixes --- packages/cli/src/lib/utils.ts | 10 +++ .../src/modules/hosting/hosting.commands.ts | 2 +- .../src/modules/hosting/hosting.service.ts | 68 +++++++--------- packages/cli/src/modules/nfts/nft.service.ts | 75 ++++++++---------- .../cli/src/modules/storage/ipns.service.ts | 55 ++++++------- .../src/modules/storage/storage.service.ts | 79 +++++++++---------- .../sdk/src/modules/storage/storage-bucket.ts | 1 + packages/sdk/src/types/storage.ts | 2 +- 8 files changed, 135 insertions(+), 157 deletions(-) diff --git a/packages/cli/src/lib/utils.ts b/packages/cli/src/lib/utils.ts index 17cb132..55af2ee 100644 --- a/packages/cli/src/lib/utils.ts +++ b/packages/cli/src/lib/utils.ts @@ -1,5 +1,15 @@ +import { exceptionHandler } from '@apillon/sdk'; + export function enumValues(enumType: any): string[] { return Object.values(enumType) .filter((value) => typeof value === 'number') .map((value) => value.toString()); } + +export async function withErrorHandler(handler: () => Promise) { + try { + await handler(); + } catch (err) { + exceptionHandler(err); + } +} diff --git a/packages/cli/src/modules/hosting/hosting.commands.ts b/packages/cli/src/modules/hosting/hosting.commands.ts index 1f4e450..a9009cf 100644 --- a/packages/cli/src/modules/hosting/hosting.commands.ts +++ b/packages/cli/src/modules/hosting/hosting.commands.ts @@ -101,7 +101,7 @@ export function createHostingCommands(cli: Command) { '--status ', 'Status of the deployment (optional) Choose from:\n' + ` ${DeploymentStatus.INITIATED}: Initiated\n` + - ` ${DeploymentStatus.IN_PROGRESS}: In process\n` + + ` ${DeploymentStatus.IN_PROGRESS}: In progress\n` + ` ${DeploymentStatus.IN_REVIEW}: In review\n` + ` ${DeploymentStatus.APPROVED}: Approved\n` + ` ${DeploymentStatus.SUCCESSFUL}: Successful\n` + diff --git a/packages/cli/src/modules/hosting/hosting.service.ts b/packages/cli/src/modules/hosting/hosting.service.ts index ec94d83..36dd84d 100644 --- a/packages/cli/src/modules/hosting/hosting.service.ts +++ b/packages/cli/src/modules/hosting/hosting.service.ts @@ -1,33 +1,33 @@ -import { - Hosting, - exceptionHandler, - DeployToEnvironment, - toInteger, -} from '@apillon/sdk'; +import { Hosting, DeployToEnvironment, toInteger } from '@apillon/sdk'; import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; +import { withErrorHandler } from '../../lib/utils'; export async function listWebsites(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (hosting) => { - const data = await hosting.listWebsites(paginate(optsWithGlobals)); + await withErrorHandler(async () => { + const data = await new Hosting(optsWithGlobals).listWebsites( + paginate(optsWithGlobals), + ); data.items = data.items.map((w) => w.serialize()); console.log(data); - }, optsWithGlobals); + }); } export async function getWebsite(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (hosting) => { - const website = await hosting.website(optsWithGlobals.uuid).get(); + await withErrorHandler(async () => { + const website = await new Hosting(optsWithGlobals) + .website(optsWithGlobals.uuid) + .get(); console.log(website.serialize()); - }, optsWithGlobals); + }); } export async function deployWebsite( path: string, optsWithGlobals: GlobalOptions, ) { - await withErrorHandler(async (hosting) => { - const website = hosting.website(optsWithGlobals.uuid); + await withErrorHandler(async () => { + const website = new Hosting(optsWithGlobals).website(optsWithGlobals.uuid); console.log(`Uploading files from folder: ${path}`); await website.uploadFromFolder(path); const deployment = await website.deploy( @@ -38,60 +38,50 @@ export async function deployWebsite( console.log(`Deployment started!`); const deploymentData = await website.deployment(deployment.uuid).get(); console.log(deploymentData.serialize()); - }, optsWithGlobals); + }); } export async function uploadWebsiteFiles( path: string, optsWithGlobals: GlobalOptions, ) { - await withErrorHandler(async (hosting) => { - await hosting.website(optsWithGlobals.uuid).uploadFromFolder(path); - }, optsWithGlobals); + await withErrorHandler(async () => { + await new Hosting(optsWithGlobals) + .website(optsWithGlobals.uuid) + .uploadFromFolder(path); + }); } export async function deployToEnvironment(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (hosting) => { - await hosting + await withErrorHandler(async () => { + await new Hosting(optsWithGlobals) .website(optsWithGlobals.uuid) .deploy(toInteger(optsWithGlobals.env)); console.log('Deploy successful'); - }, optsWithGlobals); + }); } export async function listDeployments(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (hosting) => { + await withErrorHandler(async () => { const params = { ...paginate(optsWithGlobals), environment: toInteger(optsWithGlobals.env), deploymentStatus: toInteger(optsWithGlobals.status), }; - const data = await hosting + const data = await new Hosting(optsWithGlobals) .website(optsWithGlobals.uuid) .listDeployments(params); data.items = data.items.map((w) => w.serialize()); console.log(data); - }, optsWithGlobals); + }); } export async function getDeployment(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (hosting) => { - const deployment = await hosting + await withErrorHandler(async () => { + const deployment = await new Hosting(optsWithGlobals) .website(optsWithGlobals.websiteUuid) .deployment(optsWithGlobals.deploymentUuid) .get(); console.log(deployment.serialize()); - }, optsWithGlobals); -} - -async function withErrorHandler( - handler: (module: Hosting) => Promise, - optsWithGlobals: GlobalOptions, -) { - try { - const module = new Hosting(optsWithGlobals); - await handler(module); - } catch (err) { - exceptionHandler(err); - } + }); } diff --git a/packages/cli/src/modules/nfts/nft.service.ts b/packages/cli/src/modules/nfts/nft.service.ts index 84157b6..0f68b46 100644 --- a/packages/cli/src/modules/nfts/nft.service.ts +++ b/packages/cli/src/modules/nfts/nft.service.ts @@ -1,35 +1,33 @@ -import { - exceptionHandler, - ICreateCollection, - Nft, - toInteger, -} from '@apillon/sdk'; +import { ICreateCollection, Nft, toInteger } from '@apillon/sdk'; import { readAndParseJson } from '../../lib/files'; import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; +import { withErrorHandler } from '../../lib/utils'; export async function listCollections(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (nftService: Nft) => { - const data = await nftService.listCollections({ + await withErrorHandler(async () => { + const data = await new Nft(optsWithGlobals).listCollections({ ...paginate(optsWithGlobals), collectionStatus: toInteger(optsWithGlobals.status), }); console.log(data.items.map((d) => d.serialize())); - }, optsWithGlobals); + }); } export async function getCollection(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (nftService: Nft) => { - const data = await nftService.collection(optsWithGlobals.uuid).get(); + await withErrorHandler(async () => { + const data = await new Nft(optsWithGlobals) + .collection(optsWithGlobals.uuid) + .get(); console.log(data.serialize()); - }, optsWithGlobals); + }); } export async function createCollection( filePath: string, optsWithGlobals: GlobalOptions, ) { - await withErrorHandler(async (nftService: Nft) => { + await withErrorHandler(async () => { let createCollectionData; try { createCollectionData = readAndParseJson(filePath) as ICreateCollection; @@ -49,26 +47,29 @@ export async function createCollection( return; } - const data = await nftService.create(createCollectionData); + const data = await new Nft(optsWithGlobals).create(createCollectionData); console.log(data.serialize()); console.log('NFT collection created successfully!'); - }, optsWithGlobals); + }); } export async function mintCollectionNft(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (nftService: Nft) => { - const data = await nftService + await withErrorHandler(async () => { + const data = await new Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) - .mint(optsWithGlobals.address, toInteger(optsWithGlobals.quantity)); + .mint({ + receivingAddress: optsWithGlobals.address, + quantity: toInteger(optsWithGlobals.quantity), + }); if (data.success) { console.log('NFT minted successfully'); } - }, optsWithGlobals); + }); } export async function nestMintCollectionNft(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (nftService: Nft) => { - const data = await nftService + await withErrorHandler(async () => { + const data = await new Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .nestMint( optsWithGlobals.parentCollection, @@ -78,36 +79,36 @@ export async function nestMintCollectionNft(optsWithGlobals: GlobalOptions) { if (data.success) { console.log('NFT nest minted successfully'); } - }, optsWithGlobals); + }); } export async function burnCollectionNft(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (nftService: Nft) => { - const data = await nftService + await withErrorHandler(async () => { + const data = await new Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .burn(optsWithGlobals.tokenId); if (data.success) { console.log('NFT burned successfully'); } - }, optsWithGlobals); + }); } export async function transferCollectionOwnership( optsWithGlobals: GlobalOptions, ) { - await withErrorHandler(async (nftService: Nft) => { - await nftService + await withErrorHandler(async () => { + await new Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .transferOwnership(optsWithGlobals.address); console.log('NFT ownership transferred successfully'); - }, optsWithGlobals); + }); } export async function listCollectionTransactions( optsWithGlobals: GlobalOptions, ) { - await withErrorHandler(async (nftService: Nft) => { - const data = await nftService + await withErrorHandler(async () => { + const data = await new Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .listTransactions({ ...paginate(optsWithGlobals), @@ -115,17 +116,5 @@ export async function listCollectionTransactions( transactionType: toInteger(optsWithGlobals.type), }); console.log(data); - }, optsWithGlobals); -} - -async function withErrorHandler( - handler: (module: Nft) => Promise, - optsWithGlobals: GlobalOptions, -) { - try { - const module = new Nft(optsWithGlobals); - await handler(module); - } catch (err) { - exceptionHandler(err); - } + }); } diff --git a/packages/cli/src/modules/storage/ipns.service.ts b/packages/cli/src/modules/storage/ipns.service.ts index a81ad73..6090130 100644 --- a/packages/cli/src/modules/storage/ipns.service.ts +++ b/packages/cli/src/modules/storage/ipns.service.ts @@ -1,68 +1,59 @@ -import { Storage, exceptionHandler } from '@apillon/sdk'; +import { Storage } from '@apillon/sdk'; import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; +import { withErrorHandler } from '../../lib/utils'; export async function listIpnsNames(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const data = await storage + await withErrorHandler(async () => { + const data = await new Storage(optsWithGlobals) .bucket(optsWithGlobals.bucketUuid) .listIpnsNames(paginate(optsWithGlobals)); data.items = data.items.map((w) => w.serialize()); console.log(data); - }, optsWithGlobals); + }); } export async function createIpns(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const ipns = await storage.bucket(optsWithGlobals.bucketUuid).createIpns({ - name: optsWithGlobals.name, - description: optsWithGlobals.description, - cid: optsWithGlobals.cid, - }); + await withErrorHandler(async () => { + const ipns = await new Storage(optsWithGlobals) + .bucket(optsWithGlobals.bucketUuid) + .createIpns({ + name: optsWithGlobals.name, + description: optsWithGlobals.description, + cid: optsWithGlobals.cid, + }); console.log('IPNS record created successfully'); console.log(ipns.serialize()); - }, optsWithGlobals); + }); } export async function getIpns(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const ipns = await storage + await withErrorHandler(async () => { + const ipns = await new Storage(optsWithGlobals) .bucket(optsWithGlobals.bucketUuid) .ipns(optsWithGlobals.ipnsUuid) .get(); console.log(ipns.serialize()); - }, optsWithGlobals); + }); } export async function publishIpns(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const ipns = await storage + await withErrorHandler(async () => { + const ipns = await new Storage(optsWithGlobals) .bucket(optsWithGlobals.bucketUuid) .ipns(optsWithGlobals.ipnsUuid) .publish(optsWithGlobals.cid); console.log('IPNS published successfully'); console.log(ipns.serialize()); - }, optsWithGlobals); + }); } export async function deleteIpns(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - await storage + await withErrorHandler(async () => { + await new Storage(optsWithGlobals) .bucket(optsWithGlobals.bucketUuid) .ipns(optsWithGlobals.ipnsUuid) .delete(); console.log('IPNS record deleted successfully'); - }, optsWithGlobals); -} - -async function withErrorHandler( - handler: (module: Storage) => Promise, - optsWithGlobals: GlobalOptions, -) { - try { - const module = new Storage(optsWithGlobals); - await handler(module); - } catch (err) { - exceptionHandler(err); - } + }); } diff --git a/packages/cli/src/modules/storage/storage.service.ts b/packages/cli/src/modules/storage/storage.service.ts index 9fbd90b..9c0f78b 100644 --- a/packages/cli/src/modules/storage/storage.service.ts +++ b/packages/cli/src/modules/storage/storage.service.ts @@ -1,86 +1,83 @@ -import { Storage, exceptionHandler, toInteger } from '@apillon/sdk'; +import { Storage, toInteger } from '@apillon/sdk'; import { GlobalOptions } from '../../lib/types'; import { paginate } from '../../lib/options'; +import { withErrorHandler } from '../../lib/utils'; export async function listBuckets(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const data = await storage.listBuckets(paginate(optsWithGlobals)); + await withErrorHandler(async () => { + const data = await new Storage(optsWithGlobals).listBuckets( + paginate(optsWithGlobals), + ); data.items = data.items.map((w) => w.serialize()); console.log(data); - }, optsWithGlobals); + }); } export async function listObjects(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const data = await storage.bucket(optsWithGlobals.bucketUuid).listObjects({ - ...paginate(optsWithGlobals), - directoryUuid: optsWithGlobals.directoryUuid, - markedForDeletion: !!optsWithGlobals.deleted, - }); + await withErrorHandler(async () => { + const data = await new Storage(optsWithGlobals) + .bucket(optsWithGlobals.bucketUuid) + .listObjects({ + ...paginate(optsWithGlobals), + directoryUuid: optsWithGlobals.directoryUuid, + markedForDeletion: !!optsWithGlobals.deleted, + }); data.items = data.items.map((w) => w.serialize()); console.log(data); - }, optsWithGlobals); + }); } export async function listFiles(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const data = await storage.bucket(optsWithGlobals.bucketUuid).listFiles({ - ...paginate(optsWithGlobals), - fileStatus: toInteger(optsWithGlobals.fileStatus), - }); + await withErrorHandler(async () => { + const data = await new Storage(optsWithGlobals) + .bucket(optsWithGlobals.bucketUuid) + .listFiles({ + ...paginate(optsWithGlobals), + fileStatus: toInteger(optsWithGlobals.fileStatus), + }); data.items = data.items.map((w) => w.serialize()); console.log(data); - }, optsWithGlobals); + }); } export async function uploadFromFolder( path: string, optsWithGlobals: GlobalOptions, ) { - await withErrorHandler(async (storage: Storage) => { + await withErrorHandler(async () => { console.log(`Uploading files from folder: ${path}`); - await storage.bucket(optsWithGlobals.bucketUuid).uploadFromFolder(path); - }, optsWithGlobals); + await new Storage(optsWithGlobals) + .bucket(optsWithGlobals.bucketUuid) + .uploadFromFolder(path); + }); } export async function getFile(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - const file = await storage + await withErrorHandler(async () => { + const file = await new Storage(optsWithGlobals) .bucket(optsWithGlobals.bucketUuid) .file(optsWithGlobals.fileUuid) .get(); console.log(file.serialize()); - }, optsWithGlobals); + }); } export async function deleteFile(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - await storage + await withErrorHandler(async () => { + await new Storage(optsWithGlobals) .bucket(optsWithGlobals.bucketUuid) .file(optsWithGlobals.fileUuid) .delete(); console.log('File deleted successfully'); - }, optsWithGlobals); + }); } export async function deleteDirectory(optsWithGlobals: GlobalOptions) { - await withErrorHandler(async (storage: Storage) => { - await storage + await withErrorHandler(async () => { + await new Storage(optsWithGlobals) .bucket(optsWithGlobals.bucketUuid) .directory(optsWithGlobals.directoryUuid) .delete(); console.log('Directory deleted successfully'); - }, optsWithGlobals); -} - -async function withErrorHandler( - handler: (module: Storage) => Promise, - optsWithGlobals: GlobalOptions, -) { - try { - const module = new Storage(optsWithGlobals); - await handler(module); - } catch (err) { - exceptionHandler(err); - } + }); } diff --git a/packages/sdk/src/modules/storage/storage-bucket.ts b/packages/sdk/src/modules/storage/storage-bucket.ts index a3d5228..7e8ad1a 100644 --- a/packages/sdk/src/modules/storage/storage-bucket.ts +++ b/packages/sdk/src/modules/storage/storage-bucket.ts @@ -191,6 +191,7 @@ export class StorageBucket extends ApillonModel { fileName: file.name, fileUuid: file.uuid, CID: file.CID, + CIDv1: file.CIDv1, content: null, }), ); diff --git a/packages/sdk/src/types/storage.ts b/packages/sdk/src/types/storage.ts index 931df62..2135834 100644 --- a/packages/sdk/src/types/storage.ts +++ b/packages/sdk/src/types/storage.ts @@ -22,7 +22,7 @@ export interface IBucketFilesRequest extends IApillonPagination { /** * Search files by upload session UUID */ - sessionUuid: string; + sessionUuid?: string; } export interface FileMetadata {