Launch extension with Metamask - Web3 - google-chrome-extension

I am trying to build a project to understand the Web3 much deeper , I wanted to know if there is a solution to launch an extension with the call of a smart contract ( in the same time MetaMask open I can open my extension next to it)
I tried several options like to call the same functions as MetaMask or play with their developer version of MetaMask but I saw some extensions that succeed to do it without it
EDIT : When a request is made from a dapp like uniswap to metamask I would like get this request in my extension at the same time metamask get it
Thanks for your help 🙂

Related

Reinstall Shopify App Error: "The Page is not Avalaible

I am developing the shopify app according to the tutorial presented on the page (QR create code), however when I am doing tests, when I uninstall it and try to reinstall it I get the following message:
There is no page at this address
Please check the URL and try again, or use the search bar to find what you need. (Attached in the photo)
Photo 404
If you can help me, thank you very much, I feel that it is as if the authentication failed or I had already used the token, the truth is that I do not know about the subject
My project is in node, react
"#shopify/app": "3.3.3",
"#shopify/cli": "3.3.3"
Thanks
This is a shopify_app bug
You need to delete the previous installation Shop from the database then try the install again and it will work.
If you have only one shop in the database quick solution will be the rails console
rails c
Shop.first.destroy
To resolve it permanently you have to register and handle the app_uninstalled webhook however it will not work 100% of the time due to delay. When the user removes the app the Shopify server trigger webhook with delay (2 seconds to 10 minutes)

Google's dialogflow integration "dialogflow messenger" (beta)

I am trying to use dialogflow's integration called "Dialogflow messenger" (This isn't the interface to microsoft messenger). The integration is at beta stage, but I would have expected it to work at this bsaic level. When I configure it, if I click "try it here" ini the dialogflow console all is well.
I copied and pasted the dialogflow messenger integration into an html page on my laptop but when I open the page I get a CORS error.
Here is what I pasted - copied from the integration item
I copied and pasted the dialogflow messenger integration into an html page on my laptop but when I open the page I get a CORS error.
Here is what I pasted - copied from the integration item
<script src="https://www.gstatic.com/dialogflow-console/fast/messenger/bootstrap.js?v=1"></script>
<df-messenger
chat-icon="417a4c06-c7a0-4fb4-8b42-8d4ba853f941_x.png"
intent="WELCOME"
chat-title="SupaMoov"
agent-id="xxx"
language-code="en"
></df-messenger>
here is the error:
SupaChat%20-%20google-1.html:1 Access to XMLHttpRequest at 'https://dialogflow.cloud.google.com/v1/integrations/messenger/webhook/xxx/sessions/dfMessenger-20080482' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
How do I resolve this?
The problem is that you can't insert the html and open it directly from your file system. You need to open from a web server that could be with NodeJs, Java, php or whatever you want. Then put this script at the end of the body.
If it can be useful for you, I am intesively expimenting with this and I have prepared three videos in Youtube that can help to
Create the chatbot for dialoflow messenger,
Launch a web server with NodeJs and personalize the imagen of the chatbot
How to capture the javascript event in your web that generate the interactions with the chatbot.
I have prepare a Youtube list with those videos (in spanish but code can be understood easily) https://www.youtube.com/playlist?list=PLnNbmcjjevxs_Uj-hAeekSbb4Yb7FZERe
I hope that this could help.
I got in touch with Google support. Their answer is:
"to work you have to run it within a web server, you can try xampp"
Not great! I was looking to convert from IBM watson to dialogflow, but the watson integration is much more sophisticated, so I'll be staying with IBM.
I also had this problem.
I decided to publish it on an S3 (Static Site) on Amazon.
Just put the html and another files in Bucket.
Complete information here:
https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html
You can paste the embedding code into an embed code block in a Google Site and then you will not need a web server.
Here is the embed button Once you click embed, then click Embed code and paste in the code from Dialogflow.
You can also work on it on your local host using a simple Flask script.
from flask import Flask, request, send_from_directory,render_template
app = Flask(__name__, static_url_path='/static',template_folder='./')
#app.route("/")
def shadow():
return render_template("shadow.html")#assuming this is the name of your html file
if __name__ == "__main__":
app.run(host='localhost' , port=5000 , debug=True)
Then just open it at http://localhost:5000/ in your browser.
There is a dependency as this is assuming you have installed Python3 and Flask in your system.
To install Flask using Python 3.x
pip install flask
Or if you have Python2 by default, you would need to do
pip3 install Flask
This is of course, if you are working locally that is.
CORS is a mechanism that restricts requests coming from a different origin (domain). This is usually common when testing locally so when you deploy, the error will go away.
Usually, A request coming from a different origin is known as a cross-origin request. Cross-origin requests are vital for when your site needs to load data from other services. Essentially, CORS allows servers to specify who can access their resources and how.
-- The easiest and most reliable way to CORS in Safari is to disable CORS in the develop menu.
Enable the develop menu by going to Preferences > Advanced.
Then select “Disable Cross-Origin Restrictions” from the develop menu.
MAKE SURE YOU SWITCH IT BACK WHEN YOU FINISH TESTING.
-- I believe Firefox has a plugin you can install as well.
-- There are other more technical ways of fixing this via middleware, but this is a simple workaround.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
The way I solve having a webchat with Dialogflow is by using the WebChat by Voximplant Kit.
Is very simple to use and allows you to connect your DF ES or CX Agent through a JS function.
You can test the platform and then having human agents connected than can answer the questions that the DF Agent can't. Don't forget about that.
Web Chat creation with Voximplant Kit in action demo video
Web Chat Documentation
JS Script to create a Function to Connect the Dialogflow Agent with a Queue created in Voximplant Kit.
I hope this simplifies your life! You can reach me out in Discord.
You can just create an html index just like overhere on my github page. Here is 5 minute guide to github pages, Will take less than 15 minutes for the whole process.

How can I communicate in a secure way with my firefox extension

I am working on a webpage that depends on browser extensions to perform certain tasks.
From the webpage I can communicate with the chrome browser using 'externally_connectable' and:
chrome.runtime.sendMessage(string extensionId, any message, object options, function responseCallback)
The good thing here is that from the point of view of my website I am sure I am communicating with my extension and not with a 'reverse engineered' version of my extension.
In firefox extensions however there is no support for externally_connectable and I have to use events or window.postmessage:
const event = new CustomEvent('msg-for-content-script');
document.querySelector('body').dispatchEvent(event);
This works ok, but the problem is that when somebody manages to reverse engineer my extension I am not able to check whether the extension I am communicating with is really my extension.
Is there anybody who can give advice on how to make sure that I am communicating with the right extension?

Getting chromecast sample code to run

I have found no joy in getting any of the sample programs for Chrome to connect to my Chromecasts.
The Chromecasts have been registered and I am able to browse to their IP address port 9222 successfully.
Both the Chrome browser and Beta extension are up to date.
I have tried the CastHelloVideo-Chrome, CastMedia-Chrome and Cast-Tictactoe-Chrome and all fail to connect. The developer console shows a pair of errors:
GET chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js net::ERR_FAILED
and
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').
When testing our own code we get an error when calling requestSession but the message returned by Chrome.cast.Error is useless since the function and variable names have been obscured.
I also have a difficult time testing the examples for Chrome. I decided to use Chrome to test because debugging JavaScript is so much quicker than going directly to Android. I spent hours trying to figure out why I keep getting the error message GET chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js net::ERR_FAILED and Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null') if I run it from my PC but not when I run it from an example website at http://www.videws.com/eureka/helloVideos/ provided by one of the Cast developers at Google. I keep reading/trying different combinations from his readme note in the example until it dawned on me what he meant by "Put all files on your own server" instead of "computer".
I created a public weblink on my Google Drive, make the folder public and copied all the files there. When go to Google drive on the web, preview the example (index.html), the example runs beautifully. I tried tic-tac-toe. It also runs.
So the answer is you need to run it off a website -- not from a local file in your computer (ctrl-O in Chrome)
I hope this will help you going with Cast.
Danh
I was finally able to get connected, but from Android. Many steps will be the same though.
I tested this: https://github.com/googlecast/CastHelloText-android It let's you speak into the phone, and what you say appears on the TV/Chromecast. I didn't install the formal sender app, but I was able to load the TicTac Toe from the receiver as well. So i have seen them both on my CC.
I couldn't connect until I properly setup the RECEIVER APPLICATION. You didn't mention it.
What I did from where I think you are at.. I just double checked my receiver app settings.
File copy the receiver.hml file provided in the sample sender app. Place it in a public dropbox folder. copy that public link to my clipboard.
Go back to where you registered your Chromecast device(s). https://cast.google.com/publish -Add An Application. I called mine : ReceiverSimple
Edit the app you just created, and for the URL field: paste in that public link. For you, set the platform to Chrome. It did not seem to matter whether or not i included the package name, so try leaving it blank.
Save It. Now COPY to clipboard the ApplicationID for the receiver you just created.
Open the provided sender app source code, and find where it's using APP_ID (hopefully R.Strings or equivalent in chrome ) Paste that App ID in. That will tell your client to use your receiver app, (and therefore, load that receiver.html file into the chrome cast screen).
also try a chrome cast reboot as another means of sanity checking.
I think you're close.

Implementing Google+ one-time code flow authentication from chrome extension

I am trying to implement a Google+ sign in option as part of a chrome extension using the one-time code flow as described here.
While making a request using the javascript Google API package a popup opens with an "origin_mismatch" error. This is obviously since I need to add my origin to the relevant Client Id on the Google API console.
My origin is : chrome-extension://<my extension id> however when trying to add that on the API console I get an error saying "Invalid URI: chrome-extension://..." which probably means this scheme is not supported.
Any idea what I can do instead?
I've faced the same problem. I think Google has changed the validation for javascript origins and doesn't allow origins from chrome-extension any more. Google gives you the Chrome Identity API instead (https://developer.chrome.com/apps/app_identity)
But there is a workaround. If you already have at least one chrome-extension://[ext_id] origin in your client ID and you have for example the older version of your extension with this extension ID, you can:
install this extension
go to C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\Extensions (for windows)
find your extension there and open the manifest.json
copy the line "key":"[your_key]" and paste it into your developed manifest
and after next build you should get the extension with the same id as it was in the working one. Also it won't change any more.

Resources