From 282dc1cf0e52627c2e854912d6b15acc5716ccaa Mon Sep 17 00:00:00 2001 From: Monalisha Mishra <42746736+mishramonalisha76@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:13:09 +0530 Subject: [PATCH 1/3] fix: fixed font awesome (#799) --- packages/uiweb/package.json | 2 +- .../ChatAndNotificationWidget.tsx | 2 +- packages/uiweb/yarn.lock | 143 ++++++++---------- 3 files changed, 69 insertions(+), 78 deletions(-) diff --git a/packages/uiweb/package.json b/packages/uiweb/package.json index 6645e2d69..0bfdce8e0 100644 --- a/packages/uiweb/package.json +++ b/packages/uiweb/package.json @@ -19,7 +19,7 @@ "date-fns": "^2.28.0", "emoji-picker-react": "^4.4.9", "ethers": "^5.6.8", - "font-awesome": "^4.7.0", + "gif-picker-react": "^1.1.0", "html-react-parser": "^1.4.13", "livekit-client": "^1.13.3", diff --git a/packages/uiweb/src/lib/components/chatAndNotification/ChatAndNotificationWidget.tsx b/packages/uiweb/src/lib/components/chatAndNotification/ChatAndNotificationWidget.tsx index 4d7ace1be..aecce02a6 100644 --- a/packages/uiweb/src/lib/components/chatAndNotification/ChatAndNotificationWidget.tsx +++ b/packages/uiweb/src/lib/components/chatAndNotification/ChatAndNotificationWidget.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { ChatAndNotificationMainContextProvider, ChatAndNotificationPropsContext, NotificationMainStateContextProvider } from '../../context'; -import 'font-awesome/css/font-awesome.min.css'; +// import 'font-awesome/css/font-awesome.min.css'; import { Constants } from '../../config'; import { ChatMainStateContextProvider } from '../../context'; diff --git a/packages/uiweb/yarn.lock b/packages/uiweb/yarn.lock index fe58dcd8b..d714d5fff 100644 --- a/packages/uiweb/yarn.lock +++ b/packages/uiweb/yarn.lock @@ -9,11 +9,6 @@ dependencies: regenerator-runtime "^0.13.11" -"@bufbuild/protobuf@^1.3.0": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@bufbuild/protobuf/-/protobuf-1.3.1.tgz#c4de66bacbe7ac97fe054e68314aeba6f45177f9" - integrity sha512-BUyJWutgP2S8K/1NphOJokuwDckXS4qI2T1pGZAlkFdZchWae3jm6fCdkcGbLlM1QLOcNFFePd+7Feo4BYGrJQ== - "@babel/runtime@^7.17.2", "@babel/runtime@^7.22.6": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.15.tgz#38f46494ccf6cf020bd4eed7124b425e83e523b8" @@ -21,6 +16,11 @@ dependencies: regenerator-runtime "^0.14.0" +"@bufbuild/protobuf@^1.3.0": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@bufbuild/protobuf/-/protobuf-1.3.1.tgz#c4de66bacbe7ac97fe054e68314aeba6f45177f9" + integrity sha512-BUyJWutgP2S8K/1NphOJokuwDckXS4qI2T1pGZAlkFdZchWae3jm6fCdkcGbLlM1QLOcNFFePd+7Feo4BYGrJQ== + "@coinbase/wallet-sdk@^3.7.1": version "3.7.2" resolved "https://registry.yarnpkg.com/@coinbase/wallet-sdk/-/wallet-sdk-3.7.2.tgz#7a89bd9e3a06a1f26d4480d8642af33fb0c7e3aa" @@ -933,32 +933,6 @@ resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.1.4.tgz#19654d1026cc410975d46445180e70a5089b3e7d" integrity sha512-qprfWkn82Iw821mcKofJ5Pk9wgioHicxcQMxx+5zt5GSKoqdWvgG5AxVmpmUUjzTLPVSH5auBrhI93Deayn/DA== -"@livekit/components-core@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@livekit/components-core/-/components-core-0.7.0.tgz#1283a34753c8f1bb805b987684a3e29d1bc2eb39" - integrity sha512-KwzqnW8V9G+4fXc4gOxpXqQFLpL/kFBn82sYO10zHjHfNKSw4pRj1sDLTWc5UF22W2Z461/bqMtB+3WGB/3Dtg== - dependencies: - "@floating-ui/dom" "^1.1.0" - email-regex "^5.0.0" - global-tld-list "^0.0.1139" - loglevel "^1.8.1" - rxjs "^7.8.0" - -"@livekit/components-react@^1.2.2": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@livekit/components-react/-/components-react-1.2.2.tgz#202083f70d5fb5512077fd145e81232116601e0a" - integrity sha512-0ds0A/XUUG9zarAZdlUdOEJsKKVp7kwFS+wFBXgJ2KcQwNJVCZh+NY780QP4r9E8R+knRJy/kkmEGYcCxvrgWA== - dependencies: - "@livekit/components-core" "0.7.0" - "@react-hook/latest" "^1.0.3" - clsx "^2.0.0" - usehooks-ts "^2.9.1" - -"@livekit/components-styles@^1.0.6": - version "1.0.6" - resolved "https://registry.yarnpkg.com/@livekit/components-styles/-/components-styles-1.0.6.tgz#2649c61a631efff37eb2326e100e34a84e597d71" - integrity sha512-/toY2NFJCU0NdeP9AB+CWW9kPf8gdpndIoR0hYTKjDb8pHPdXDu5NE7XyO8qKIeV4biRFGsQ9+C3giPNgYm9TA== - "@formatjs/ecma402-abstract@1.11.4": version "1.11.4" resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz#b962dfc4ae84361f9f08fbce411b4e4340930eda" @@ -1022,6 +996,32 @@ dependencies: "@lit-labs/ssr-dom-shim" "^1.0.0" +"@livekit/components-core@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@livekit/components-core/-/components-core-0.7.0.tgz#1283a34753c8f1bb805b987684a3e29d1bc2eb39" + integrity sha512-KwzqnW8V9G+4fXc4gOxpXqQFLpL/kFBn82sYO10zHjHfNKSw4pRj1sDLTWc5UF22W2Z461/bqMtB+3WGB/3Dtg== + dependencies: + "@floating-ui/dom" "^1.1.0" + email-regex "^5.0.0" + global-tld-list "^0.0.1139" + loglevel "^1.8.1" + rxjs "^7.8.0" + +"@livekit/components-react@^1.2.2": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@livekit/components-react/-/components-react-1.2.2.tgz#202083f70d5fb5512077fd145e81232116601e0a" + integrity sha512-0ds0A/XUUG9zarAZdlUdOEJsKKVp7kwFS+wFBXgJ2KcQwNJVCZh+NY780QP4r9E8R+knRJy/kkmEGYcCxvrgWA== + dependencies: + "@livekit/components-core" "0.7.0" + "@react-hook/latest" "^1.0.3" + clsx "^2.0.0" + usehooks-ts "^2.9.1" + +"@livekit/components-styles@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@livekit/components-styles/-/components-styles-1.0.6.tgz#2649c61a631efff37eb2326e100e34a84e597d71" + integrity sha512-/toY2NFJCU0NdeP9AB+CWW9kPf8gdpndIoR0hYTKjDb8pHPdXDu5NE7XyO8qKIeV4biRFGsQ9+C3giPNgYm9TA== + "@livepeer/core-react@^1.8.0": version "1.8.0" resolved "https://registry.npmjs.org/@livepeer/core-react/-/core-react-1.8.0.tgz" @@ -2471,6 +2471,7 @@ clsx@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.0.0.tgz#12658f3fd98fafe62075595a5c30e43d18f3d00b" integrity sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q== + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -3026,16 +3027,6 @@ find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" -events@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -font-awesome@^4.7.0: - version "4.7.0" - resolved "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz" - integrity sha512-U6kGnykA/6bFmg1M/oT9EkFeIYv7JlX3bozwQJWiiLz6L0w3F5vBVPxHlwyX/vtNq1ckcpRKOB9f2Qal/VtFpg== - for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -3324,19 +3315,6 @@ js-sha3@0.8.0: resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -livekit-client@^1.13.3: - version "1.13.4" - resolved "https://registry.yarnpkg.com/livekit-client/-/livekit-client-1.13.4.tgz#af20a338334d6c9e3c81e7c9641222d95a532b75" - integrity sha512-7Ef80q7aWkgkFWfWBd+gv2AcUrubpt+oXYk+tXSWVkTXoPpm6xqrMPu3TNYKIzXQWt8IEbyPQLLVsCZpR7RBTg== - dependencies: - "@bufbuild/protobuf" "^1.3.0" - events "^3.3.0" - loglevel "^1.8.0" - sdp-transform "^2.14.1" - ts-debounce "^4.0.0" - typed-emitter "^2.1.0" - webrtc-adapter "^8.1.1" - json-rpc-engine@6.1.0, json-rpc-engine@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/json-rpc-engine/-/json-rpc-engine-6.1.0.tgz#bf5ff7d029e1c1bf20cb6c0e9f348dcd8be5a393" @@ -3399,6 +3377,19 @@ lit@2.7.6: lit-element "^3.3.0" lit-html "^2.7.0" +livekit-client@^1.13.3: + version "1.13.4" + resolved "https://registry.yarnpkg.com/livekit-client/-/livekit-client-1.13.4.tgz#af20a338334d6c9e3c81e7c9641222d95a532b75" + integrity sha512-7Ef80q7aWkgkFWfWBd+gv2AcUrubpt+oXYk+tXSWVkTXoPpm6xqrMPu3TNYKIzXQWt8IEbyPQLLVsCZpR7RBTg== + dependencies: + "@bufbuild/protobuf" "^1.3.0" + events "^3.3.0" + loglevel "^1.8.0" + sdp-transform "^2.14.1" + ts-debounce "^4.0.0" + typed-emitter "^2.1.0" + webrtc-adapter "^8.1.1" + livepeer@2.8.0: version "2.8.0" resolved "https://registry.npmjs.org/livepeer/-/livepeer-2.8.0.tgz" @@ -3498,16 +3489,16 @@ lodash.uniqby@4.5.0: lodash._baseiteratee "~4.7.0" lodash._baseuniq "~4.6.0" -loglevel@^1.8.0, loglevel@^1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.8.1.tgz#5c621f83d5b48c54ae93b6156353f555963377b4" - integrity sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg== - lodash.uniqby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz#d99c07a669e9e6d24e1362dfe266c67616af1302" integrity sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww== +loglevel@^1.8.0, loglevel@^1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.8.1.tgz#5c621f83d5b48c54ae93b6156353f555963377b4" + integrity sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg== + loose-envify@^1.0.0: version "1.4.0" resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz" @@ -3975,6 +3966,11 @@ scriptjs@^2.5.9: resolved "https://registry.npmjs.org/scriptjs/-/scriptjs-2.5.9.tgz" integrity sha512-qGVDoreyYiP1pkQnbnFAUIS5AjenNwwQBdl7zeos9etl+hYKWahjRTfzAZZYBv5xNHx7vNKCmaLDQZ6Fr2AEXg== +scrypt-js@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" + integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== + sdp-transform@^2.14.1: version "2.14.1" resolved "https://registry.yarnpkg.com/sdp-transform/-/sdp-transform-2.14.1.tgz#2bb443583d478dee217df4caa284c46b870d5827" @@ -3985,11 +3981,6 @@ sdp@^3.2.0: resolved "https://registry.yarnpkg.com/sdp/-/sdp-3.2.0.tgz#8961420552b36663b4d13ddba6f478d1461896a5" integrity sha512-d7wDPgDV3DDiqulJjKiV2865wKsJ34YI+NDREbm+FySq6WuKOikwyNQcm+doLAZ1O6ltdO0SeKle2xMpN3Brgw== -scrypt-js@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" - integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== - semver@^7.3.8: version "7.5.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" @@ -4246,13 +4237,6 @@ tus-js-client@^3.1.0: proper-lockfile "^4.1.2" url-parse "^1.5.7" -typed-emitter@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/typed-emitter/-/typed-emitter-2.1.0.tgz#ca78e3d8ef1476f228f548d62e04e3d4d3fd77fb" - integrity sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA== - optionalDependencies: - rxjs "^7.5.2" - type@^1.0.1: version "1.2.0" resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" @@ -4263,6 +4247,13 @@ type@^2.7.2: resolved "https://registry.yarnpkg.com/type/-/type-2.7.2.tgz#2376a15a3a28b1efa0f5350dcf72d24df6ef98d0" integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw== +typed-emitter@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/typed-emitter/-/typed-emitter-2.1.0.tgz#ca78e3d8ef1476f228f548d62e04e3d4d3fd77fb" + integrity sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA== + optionalDependencies: + rxjs "^7.5.2" + typedarray-to-buffer@3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -4315,11 +4306,6 @@ usehooks-ts@^2.9.1: resolved "https://registry.yarnpkg.com/usehooks-ts/-/usehooks-ts-2.9.1.tgz#953d3284851ffd097432379e271ce046a8180b37" integrity sha512-2FAuSIGHlY+apM9FVlj8/oNhd+1y+Uwv5QNkMQz1oSfdHk4PXo1qoCw9I5M7j0vpH8CSWFJwXbVPeYDjLCx9PA== -uuid@^9.0.1: - version "9.0.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" - integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== - utf-8-validate@^5.0.2: version "5.0.10" resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" @@ -4348,6 +4334,11 @@ uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== +uuid@^9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" + integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== + valtio@1.11.0: version "1.11.0" resolved "https://registry.yarnpkg.com/valtio/-/valtio-1.11.0.tgz#c029dcd17a0f99d2fbec933721fe64cfd32a31ed" From 072dc88e5c9dc98626ae69f8f061e859cf99104c Mon Sep 17 00:00:00 2001 From: diposs Date: Mon, 23 Oct 2023 12:53:37 +0100 Subject: [PATCH 2/3] Update getFeedsPerChannel.ts (#800) --- packages/restapi/src/lib/user/getFeedsPerChannel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/restapi/src/lib/user/getFeedsPerChannel.ts b/packages/restapi/src/lib/user/getFeedsPerChannel.ts index fb6d902d4..0ff7db014 100644 --- a/packages/restapi/src/lib/user/getFeedsPerChannel.ts +++ b/packages/restapi/src/lib/user/getFeedsPerChannel.ts @@ -35,7 +35,7 @@ export const getFeedsPerChannel = async (options: FeedsPerChannelOptionsType) => throw new Error('channels cannot be empty'); } const _channel = await getCAIPAddress(env, channels[0], 'Channel'); - const apiEndpoint = `${API_BASE_URL}/v1/users/${_channel}/channels/${_user}/feeds`; + const apiEndpoint = `${API_BASE_URL}/v1/users/${_user}/channels/${_channel}/feeds`; const queryObj = { page, limit: getLimit(limit), From 325ad80c29d57706e14a36b74cd43a8545fa266b Mon Sep 17 00:00:00 2001 From: Harsh | Push Date: Mon, 23 Oct 2023 17:41:30 +0400 Subject: [PATCH 3/3] =?UTF-8?q?docs(/packages/examples/token-gated-chat):?= =?UTF-8?q?=20added=20token=20gated=20chat=20exa=E2=80=A6=20(#791)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(/packages/examples/token-gated-chat): added token gated chat example * docs(/packages/examples/token-gated-chat/readme.md): added relevant readme file --- packages/examples/token-gated-chat/README.md | 13 ++++ packages/examples/token-gated-chat/index.js | 59 +++++++++++++++++++ .../package-lock.json | 0 .../package.json | 12 ++-- packages/examples/use-cases/.DONNOTREMOVE | 0 .../use-cases/automated-chat/src/index.js | 42 ------------- 6 files changed, 78 insertions(+), 48 deletions(-) create mode 100644 packages/examples/token-gated-chat/README.md create mode 100644 packages/examples/token-gated-chat/index.js rename packages/examples/{use-cases/automated-chat => token-gated-chat}/package-lock.json (100%) rename packages/examples/{use-cases/automated-chat => token-gated-chat}/package.json (54%) delete mode 100644 packages/examples/use-cases/.DONNOTREMOVE delete mode 100644 packages/examples/use-cases/automated-chat/src/index.js diff --git a/packages/examples/token-gated-chat/README.md b/packages/examples/token-gated-chat/README.md new file mode 100644 index 000000000..e0316899d --- /dev/null +++ b/packages/examples/token-gated-chat/README.md @@ -0,0 +1,13 @@ +# About Token Gated Chat +Token gated chat shows you how to create group chats using Push Chat that can gated in various ways including token or NFT gating on entry of the group or when a participant of that group wants to send a message + +## What's the use case +You can use this example to see the functionality of token gating. Some use cases are: + +- Creating your token gated community and hosting that particular chat on your frontend +- Enabling more token use cases and ensuring that conversations that happen in your group are coming from token holders or from participants that have certain on-chain traits (for example: POAPs, ENS domain names, UD domain names, tec) + +## Install instructions +1. Navigate to this directory from the terminal +2. do `npm install` or `yarn install` +3. do `yarn start` \ No newline at end of file diff --git a/packages/examples/token-gated-chat/index.js b/packages/examples/token-gated-chat/index.js new file mode 100644 index 000000000..4deab4fb0 --- /dev/null +++ b/packages/examples/token-gated-chat/index.js @@ -0,0 +1,59 @@ +import { PushAPI } from '@pushprotocol/restapi'; +import { ethers } from 'ethers'; + +// Creating a random signer from a wallet, ideally this is the wallet you will connect +const signer = ethers.Wallet.createRandom(); + +console.log(`Signer address: ${signer.address} | Signer private key: ${signer.privateKey}`); + +// Initialize wallet user, pass 'prod' instead of 'staging' for mainnet apps +const userAlice = await PushAPI.initialize(signer, { env: 'staging' }); + +// Creating your token gated community +const createTokenGatedGroup = await userAlice.chat.group.create('Push Community', { + description: 'Token gated web3 native chat example', // provide short description of group + image: 'data:image/png;base64,iVBORw0K...', // provide base64 encoded image + members: [], // not needed, rules define this, can omit + admins: [], // not needed as per problem statement, can omit + private: true, + rules: { + "entry": { // entry is based on conditions + "conditions": { + "any": [ // any of the decider should allow entry + { // decider 1 - If admin or owner invites someone + "any": [ + { // criteria 1 + "type": "PUSH", + "category": "INVITE", + "subcategory": "DEFAULT", + "data": { + "inviterRoles": [ + "ADMIN", + "OWNER" + ] + } + } + ] + }, + { // decicder 2 - If wallet holds 1 NFT on polygon testnet + "any": [ + { // criteria 1 + type: "PUSH", // define type that rules engine should go for + category: "ERC721", // define it's ERC20 token that you want to check, supports ERC721 as well + subcategory: "holder", // define if you are checking 'holder' + data: { + "contract": "eip155:80001:0x9105D95577575116948F5afcF479254f49F27939", + "comparison": ">=", // what comparison needs to pass + "amount": 1, // amount that needs to passed + "decimals": 18, + } + } + ] + } + ] + } + } + } +}); + +console.log("Chat created successfully!", createTokenGatedGroup); diff --git a/packages/examples/use-cases/automated-chat/package-lock.json b/packages/examples/token-gated-chat/package-lock.json similarity index 100% rename from packages/examples/use-cases/automated-chat/package-lock.json rename to packages/examples/token-gated-chat/package-lock.json diff --git a/packages/examples/use-cases/automated-chat/package.json b/packages/examples/token-gated-chat/package.json similarity index 54% rename from packages/examples/use-cases/automated-chat/package.json rename to packages/examples/token-gated-chat/package.json index dbd298c44..1333c7602 100644 --- a/packages/examples/use-cases/automated-chat/package.json +++ b/packages/examples/token-gated-chat/package.json @@ -1,20 +1,20 @@ { - "name": "automated-chat", + "name": "token-gated-chat", "version": "1.0.0", - "description": "Example of Push Chat from backend, auto-responding to messages sent", - "main": "src/index.js", + "description": "Example of Push Chat token gated group in action", + "main": "index.js", "type": "module", "scripts": { "build": "rimraf ./build && tsc", "start": "nodemon", - "inspect": "nodemon --inspect src/index.js", - "dev": "node-dev --respawn --transpile-only src/index.js", + "inspect": "nodemon --inspect index.js", + "dev": "node-dev --respawn --transpile-only index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { - "@pushprotocol/restapi": "1.4.19", + "@pushprotocol/restapi": "latest", "@pushprotocol/socket": "0.5.2", "ethers": "5.7.2" }, diff --git a/packages/examples/use-cases/.DONNOTREMOVE b/packages/examples/use-cases/.DONNOTREMOVE deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/examples/use-cases/automated-chat/src/index.js b/packages/examples/use-cases/automated-chat/src/index.js deleted file mode 100644 index 5725040e8..000000000 --- a/packages/examples/use-cases/automated-chat/src/index.js +++ /dev/null @@ -1,42 +0,0 @@ -console.log('Hello World'); - -import { PushAPI } from '@pushprotocol/restapi'; -import { createSocketConnection, EVENTS } from '@pushprotocol/socket'; -import { ethers } from 'ethers'; - -// Creating a random signer from a wallet, ideally this is the wallet you will connect -const signer = ethers.Wallet.createRandom(); - -// Initialize wallet user, pass 'prod' instead of 'staging' for mainnet apps -const userAlice = await PushAPI.initialize(signer, { env: 'prod' }); - -// This will be the wallet address of the recipient -const pushAIWalletAddress = '0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666'; - -// Send a message to Bob -console.log('sending message to PushAI Bot'); -const aliceMessagesPushAI = await userAlice.chat.send(pushAIWalletAddress, { - content: "Gm gm! It's a me... Mario", -}); - -// Create Socket to Listen to incoming messages -const pushSDKSocket = await createSocketConnection({ - user: signer.address, - socketType: 'chat', - socketOptions: { autoConnect: true, reconnectionAttempts: 3 }, - env: 'prod', -}); - -pushSDKSocket.on(EVENTS.CONNECT, (message) => { - console.log('Socket Connected'); -}); - -// React to message payload getting recieved -pushSDKSocket.on(EVENTS.CHAT_RECEIVED_MESSAGE, (message) => { - console.log(message); - pushSDKSocket.disconnect(); -}); - -pushSDKSocket.on(EVENTS.DISCONNECT, (message) => { - console.log('Socket Disconnected'); -});