kaiesh / connect-web3-wallets

Helpful JS libs to connect various self-custody web3 wallets
GNU General Public License v3.0
8 stars 5 forks source link

How do I self-host all the js files? #9

Open php4fan opened 2 years ago

php4fan commented 2 years ago

When using your CDN, I sometimes randomly get errors like this:

image

(sorry for posting a picture rather than a screenshot, it's what I have handy right now)

So, for my projects, I downloaded your files KV.latest.min.js and KV.WalletUIHandler.latest.min.js and I load them from my own server.

My html code:

<script 
  src="js/3p/kv/KV.latest.min.js" 
  onload='shield("js/my_script.js, null, "head", "script", 0);'></script>

And my js code in my_script.js starts with:

KV.init(["js/3p/kv/KV.WalletUIHandler.latest.min.js"]).then(function(res){
  //.......
});

I also downloaded the files web3_3.0.0-rc.5.min.js and walletconnect_1.7.1.min.js from your CDN and put them into the same folder on my server where your KV.*.js files are.

I have checked that the files KV.latest.min.js and KV.WalletUIHandler.latest.min.js are loaded from where I host them on my server. But the dependencies web3_3.0.0-rc.5.min.js and walletconnect_1.7.1.min.js (which are loaded from your scripts) are still loaded from your CDN, and therefore, they sometimes randomly fail to load with the errors mentioned above.

How do I get all the dependencies to load from an arbitrary path, or at least from a given path relative to where yours are loaded from or relative to my root?

kaiesh commented 2 years ago

This is a good point - at present these support files are specified with the CDN link.

I will add a flag to the init method to signify overwrite of this array as opposed to append, leaving it backward compatible with existing deployments.

kaiesh commented 2 years ago

In the src directory, not yet minified or published on CDN. Will look to consolidate a few other fixes and then publish.

Pls feel free to use the files direct from src to address your current requirement.

kaiesh commented 2 years ago

Also, separate to the code change, will investigate the CDN loading issue.