From 7f081c2e10689d41b3e6bd529b7304a387035ee1 Mon Sep 17 00:00:00 2001 From: smartsir796 Date: Mon, 25 Apr 2022 16:55:18 +0200 Subject: [PATCH] use signedFetch --- .dclignore | 2 +- CHANGELOG.md | 7 ++- asset.json | 1 - package-lock.json | 130 ++++++++++++++++++++++++++++++++++------------ package.json | 2 +- src/game.ts | 54 +++++++++---------- src/item.ts | 40 ++++++++++---- 7 files changed, 163 insertions(+), 73 deletions(-) diff --git a/.dclignore b/.dclignore index 77c053e..226b743 100644 --- a/.dclignore +++ b/.dclignore @@ -15,4 +15,4 @@ README.md *.blend *.fbx *.zip -*.rar \ No newline at end of file +*.rar diff --git a/CHANGELOG.md b/CHANGELOG.md index 873e518..ebc1021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.4] - 2022-04-25 +### Changed +- Use signedFetch for logging events + ## [1.1.3] - 2022-04-04 ### Changed - Npm package setup @@ -23,7 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Video ads support -[Unreleased]: https://github.com/adshares/decentraland/compare/v1.0.3...HEAD +[Unreleased]: https://github.com/adshares/decentraland/compare/v1.1.4...HEAD +[1.1.4]: https://github.com/adshares/decentraland/compare/v1.1.3...v1.1.4 [1.1.3]: https://github.com/adshares/decentraland/compare/v1.1.2...v1.1.3 [1.1.2]: https://github.com/adshares/decentraland/compare/v1.1.1...v1.1.2 [1.1.1]: https://github.com/adshares/decentraland/compare/v1.1.0...v1.1.1 diff --git a/asset.json b/asset.json index 9fe41ab..3fee9fc 100644 --- a/asset.json +++ b/asset.json @@ -1,5 +1,4 @@ { - "name": "Adshares banner", "tags": ["income", "earnings", "ads", "banner", "advertisement", "advertising"], "category": "decorations", diff --git a/package-lock.json b/package-lock.json index bd6de91..57c51ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,27 +1,29 @@ { - "name": "adshares-banner", - "version": "1.0.0", + "name": "@adshares/decentraland", + "version": "1.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { "@dcl/amd": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/@dcl/amd/-/amd-6.8.0.tgz", - "integrity": "sha512-aBm9ePeQ2AIBdozAoQ67+JqJ499WicinkwscNeDZIwZ36PhB1cVnbO23MR5ivoSOtGynVyMt3NSHiFYway1EsQ==" + "integrity": "sha512-aBm9ePeQ2AIBdozAoQ67+JqJ499WicinkwscNeDZIwZ36PhB1cVnbO23MR5ivoSOtGynVyMt3NSHiFYway1EsQ==", + "dev": true }, "@dcl/build-ecs": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/@dcl/build-ecs/-/build-ecs-6.8.0.tgz", "integrity": "sha512-pPmBh5BGvWqcZF+pjWEbnaMiF3vHLpViTni8v5lJRPa5RwLk2ZEzmS+grYqh/mgdN9lgxBUNRgad2wKra0WCoQ==", + "dev": true, "requires": { "terser": "^5.7.2", "typescript": "^4.4.2" } }, "@dcl/kernel": { - "version": "1.0.0-1692945184.commit-4d9fcfd", - "resolved": "https://registry.npmjs.org/@dcl/kernel/-/kernel-1.0.0-1692945184.commit-4d9fcfd.tgz", - "integrity": "sha512-NsGC5MeE2yqS4LHS+HP5sX6iRzus4dLaDXZtfLf1JnsGFp4LHOn7ezmuGdp3uB2PSg/sVDKYrd0/k0pcEbcJrg==" + "version": "1.0.0-2189800740.commit-1ab8e83", + "resolved": "https://registry.npmjs.org/@dcl/kernel/-/kernel-1.0.0-2189800740.commit-1ab8e83.tgz", + "integrity": "sha512-w8BpPlT8rIM1nHLiYGRWCuyA/nhjNKXWWM6Xed+nuLwJQcRsO5Qhagebq3XkyDsEIlwK98rCriRKBdmZUVdvBQ==" }, "@dcl/posix": { "version": "1.0.4", @@ -29,9 +31,9 @@ "integrity": "sha512-Z0zpNr2HAxn2cLWUadWGlzaG48Z+N3hg2bI20UH+OT8NJtvCJnAwVBshAG83iAn4BTC+CsUsk4A394jrlv2ZIQ==" }, "@dcl/schemas": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-3.1.1.tgz", - "integrity": "sha512-LsNpyjf6T8OM8FkuHrzO2vPoSAggBj1iKY3myoH5K+YYM1s4xBD6wZK9JTcXa9dhBfPnlrr7aJWIsJ81oztlIQ==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-4.6.0.tgz", + "integrity": "sha512-2+HV4QsnfQqL1bU8OQyPF6WHRIxariZfIH+iWkSKc2hg1QLUkioPKsfWvhBtC18Uwl+loKQGuoslYB+cWQATVg==", "requires": { "ajv": "^7.1.0" } @@ -39,7 +41,8 @@ "@dcl/unity-renderer": { "version": "1.0.24915-20220118144533.commit-4bfe660", "resolved": "https://registry.npmjs.org/@dcl/unity-renderer/-/unity-renderer-1.0.24915-20220118144533.commit-4bfe660.tgz", - "integrity": "sha512-FBUOgndo22LXaBBRAgycQF2wy07OcHJtBE5qcfm3dI3k4F5BtRnKOX2/j8ozVUD+opjLdfnAs5puXj6KkTVrgw==" + "integrity": "sha512-FBUOgndo22LXaBBRAgycQF2wy07OcHJtBE5qcfm3dI3k4F5BtRnKOX2/j8ozVUD+opjLdfnAs5puXj6KkTVrgw==", + "dev": true }, "@types/http-proxy": { "version": "1.17.8", @@ -50,9 +53,14 @@ } }, "@types/node": { - "version": "17.0.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.12.tgz", - "integrity": "sha512-4YpbAsnJXWYK/fpTVFlMIcUIho2AYCi4wg5aNPrG1ng7fn/1/RZfCIpRCiBX+12RVa34RluilnvCqD+g3KiSiA==" + "version": "17.0.26", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.26.tgz", + "integrity": "sha512-z/FG/6DUO7pnze3AE3TBGIjGGKkvCcGcWINe1C7cADY8hKLJPDYpzsNE37uExQ4md5RFtTCvg+M8Mu1Enyeg2A==" + }, + "acorn": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==" }, "ajv": { "version": "7.2.4", @@ -108,12 +116,50 @@ "integrity": "sha512-gqCwQCLX1oez3rACmeqmVUyYmcwZmpk2VozfBF4LRMawgX1YoInraKbuOTs+2DbrDG8zmbDGDCj6wAeLsg7irA==", "requires": { "decentraland-ecs": "^6.1.4" + }, + "dependencies": { + "@dcl/amd": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@dcl/amd/-/amd-6.10.0.tgz", + "integrity": "sha512-erdqX+HKYACyzLdCbdsB6RsIXtdQ/SX22yLQfVWmexhDhuJfFxaCscYe3PfD1dp2IXF1tIdOpKdu4zJnj2bHBg==" + }, + "@dcl/build-ecs": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@dcl/build-ecs/-/build-ecs-6.10.0.tgz", + "integrity": "sha512-y9/+fCAIPxbUPpqvNLX3udrfbCVndyd+nzEpodp7ulhPzLR+jJF38XaWwjU0rNelNdlp+P0MmceYMCSGEeEMpw==", + "requires": { + "terser": "^5.7.2", + "typescript": "^4.4.2" + } + }, + "@dcl/unity-renderer": { + "version": "1.0.31824-20220330201254.commit-c617627", + "resolved": "https://registry.npmjs.org/@dcl/unity-renderer/-/unity-renderer-1.0.31824-20220330201254.commit-c617627.tgz", + "integrity": "sha512-/PgxAsBJ4vjK+kSEiNgLzmjAzYfz8zp59E2MT0LY9WXPTRWIMzji8HKGgS1DmncEREjo19bUnpqeutlPulvLTQ==" + }, + "decentraland-ecs": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/decentraland-ecs/-/decentraland-ecs-6.10.0.tgz", + "integrity": "sha512-WMjn/T+tE4Nh55xN6hyCdwCZ7k6fTB00bMpZw1UHLkxu0L7dbsitkNfUjbS9U1bY8hwaC0lTRr8Kjrr80m9X0Q==", + "requires": { + "@dcl/amd": "6.10.0", + "@dcl/build-ecs": "6.10.0", + "@dcl/kernel": "^1.0.0-1959721167.commit-e8e7260", + "@dcl/posix": "^1.0.4", + "@dcl/schemas": "^4.1.0", + "@dcl/unity-renderer": "^1.0.31824-20220330201254.commit-c617627", + "glob": "^7.1.7", + "http-proxy-middleware": "^2.0.3", + "ignore": "^5.1.8" + } + } } }, "decentraland-ecs": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/decentraland-ecs/-/decentraland-ecs-6.8.0.tgz", "integrity": "sha512-J23kqHrdZPXPfFqrkYeaei5HzOkSLO6DVB3SqhkBnFY+/2z0UvapiBNUFZrBiehrZTKvmzY6e6AhwWMU8xydzg==", + "dev": true, "requires": { "@dcl/amd": "6.8.0", "@dcl/build-ecs": "6.8.0", @@ -124,6 +170,23 @@ "glob": "^7.1.7", "http-proxy-middleware": "^2.0.1", "ignore": "^5.1.8" + }, + "dependencies": { + "@dcl/kernel": { + "version": "1.0.0-1692945184.commit-4d9fcfd", + "resolved": "https://registry.npmjs.org/@dcl/kernel/-/kernel-1.0.0-1692945184.commit-4d9fcfd.tgz", + "integrity": "sha512-NsGC5MeE2yqS4LHS+HP5sX6iRzus4dLaDXZtfLf1JnsGFp4LHOn7ezmuGdp3uB2PSg/sVDKYrd0/k0pcEbcJrg==", + "dev": true + }, + "@dcl/schemas": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-3.1.1.tgz", + "integrity": "sha512-LsNpyjf6T8OM8FkuHrzO2vPoSAggBj1iKY3myoH5K+YYM1s4xBD6wZK9JTcXa9dhBfPnlrr7aJWIsJ81oztlIQ==", + "dev": true, + "requires": { + "ajv": "^7.1.0" + } + } } }, "eventemitter3": { @@ -145,9 +208,9 @@ } }, "follow-redirects": { - "version": "1.14.7", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" }, "fs.realpath": { "version": "1.0.0", @@ -178,9 +241,9 @@ } }, "http-proxy-middleware": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.2.tgz", - "integrity": "sha512-XtmDN5w+vdFTBZaYhdJAbMqn0DP/EhkUaAeo963mojwpKMMbw6nivtFKw07D7DDOH745L5k0VL0P8KRYNEVF/g==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", + "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", "requires": { "@types/http-proxy": "^1.17.8", "http-proxy": "^1.18.1", @@ -237,18 +300,18 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.2", + "picomatch": "^2.3.1" } }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "requires": { "brace-expansion": "^1.1.7" } @@ -308,10 +371,11 @@ } }, "terser": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.10.0.tgz", - "integrity": "sha512-AMmF99DMfEDiRJfxfY5jj5wNH/bYO09cniSqhfoyxc8sFoYIgkJy86G04UoZU5VjlpnplVu0K6Tx6E9b5+DlHA==", + "version": "5.12.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.12.1.tgz", + "integrity": "sha512-NXbs+7nisos5E+yXwAD+y7zrcTkMqb0dEJxIGtSKPdCBzopf7ni4odPul2aechpV7EXNvOudYOX2bb5tln1jbQ==", "requires": { + "acorn": "^8.5.0", "commander": "^2.20.0", "source-map": "~0.7.2", "source-map-support": "~0.5.20" @@ -326,9 +390,9 @@ } }, "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==" + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", + "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==" }, "uri-js": { "version": "4.4.1", diff --git a/package.json b/package.json index c31aa95..65c84f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adshares/decentraland", - "version": "1.1.3", + "version": "1.1.4", "display-name": "Adshares DCL smart item", "description": "Adshares Decentraland smart item banner", "author": "Adshares ", diff --git a/src/game.ts b/src/game.ts index 3a8e72f..92920ed 100644 --- a/src/game.ts +++ b/src/game.ts @@ -1,37 +1,37 @@ import { Spawner } from '../node_modules/decentraland-builder-scripts/spawner' -import AdsharesBanner, { Props } from './item' +import AdsharesBanner, {Props} from './item' const banner = new AdsharesBanner() const spawner = new Spawner(banner) spawner.spawn( - 'banner', - new Transform({ - position: new Vector3(4, 0, 8), - scale: new Vector3(2, 2, 0.1), - }), - { - payout_network: 'ads', - payout_address: '0001-000000F1-6451', - keywords: 'decentraland,metaverse', - zone_name: 'default', - adserver: 'https://adserver.priv', - exclude: '{"quality": ["low"], "category": ["adult"]}', - }, + 'banner', + new Transform({ + position: new Vector3(4, 0, 8), + scale: new Vector3(2, 2, 0.1), + }), + { + payout_network: 'ads', + payout_address: '0001-000000F1-6451', + keywords: 'decentraland,metaverse', + zone_name: 'default', + adserver: 'https://adserver.priv', + exclude: '{"quality": ["low"], "category": ["adult"]}', + }, ) spawner.spawn( - 'banner', - new Transform({ - position: new Vector3(6, 0, 6), - scale: new Vector3(2, 2, 0.1), - }), - { - payout_network: 'ads', - payout_address: '0001-000000F1-6451', - keywords: 'decentraland,metaverse', - zone_name: 'default', - adserver: 'https://adserver.priv', - exclude: '{"quality": ["low"], "category": ["adult"]}', - }, + 'banner', + new Transform({ + position: new Vector3(6, 0, 6), + scale: new Vector3(2, 2, 0.1), + }), + { + payout_network: 'ads', + payout_address: '0001-000000F1-6451', + keywords: 'decentraland,metaverse', + zone_name: 'default', + adserver: 'https://adserver.priv', + exclude: '{"quality": ["low"], "category": ["adult"]}', + }, ) diff --git a/src/item.ts b/src/item.ts index a35fae5..e7e1384 100644 --- a/src/item.ts +++ b/src/item.ts @@ -1,6 +1,22 @@ import { getUserAccount } from '@decentraland/EthereumController' import { getParcel, ILand } from '@decentraland/ParcelIdentity' +let SignedFetch: Function +async function importFetch():Promise{ + if(SignedFetch) { + return SignedFetch + } + await import("@decentraland/SignedFetch").then((x: any) => { + if(typeof x === 'object') { + x = x[0] + } + SignedFetch = x.signedFetch + }, x => { + SignedFetch = fetch + }) + return SignedFetch +} + export type Props = { payout_network: string payout_address: string @@ -114,8 +130,10 @@ export default class AdsharesBanner implements IScript { const parcel = await getParcel() const transform = host.getComponent(Transform) + let signedFetch = await importFetch() + if (this.impressionId == '') { - fetch( + signedFetch( (props.adserver + '/supply/register?iid=' + this.getImpressionId()) + '&stid=' + userAccount).then() } @@ -142,7 +160,7 @@ export default class AdsharesBanner implements IScript { }, medium: 'metaverse', vendor: 'decentraland', - version: '1.1.3', + version: '1.1.4', } let response: any = {} @@ -196,13 +214,17 @@ export default class AdsharesBanner implements IScript { try { let loadedAdusers = this.loadedAdusers - fetch(banner.view_url).then(function (response) { - response.json().then(function (object) { - if (object.aduser_url && !loadedAdusers[object.aduser_url]) { - fetch(addUrlParam(object.aduser_url, 'stid', userAccount)) - loadedAdusers[object.aduser_url] = true - } - }) + signedFetch(banner.view_url).then(function (response: any) { + let object; + if (response.text ) { + object = JSON.parse(response.text); + } else { + object = response.json; + } + if (object.aduser_url && !loadedAdusers[object.aduser_url]) { + signedFetch(addUrlParam(object.aduser_url, 'stid', userAccount)) + loadedAdusers[object.aduser_url] = true + } }) } catch (e) {