Comparing version 1.0.4 to 1.0.5
@@ -45,3 +45,3 @@ /** | ||
*/ | ||
var tt=function(t,i,s,e){for(var n,o=arguments.length,r=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,h=t.length-1;h>=0;h--)(n=t[h])&&(r=(o<3?n(r):o>3?n(i,s,r):n(i,s))||r);return o>3&&r&&Object.defineProperty(i,s,r),r};window.Moralis.start({serverUrl:"https://mqia9hg0fj9k.usemoralis.com:2053/server",appId:"yXCZJLM8gX3PgM8xc2TnxHoQfg86qukH8NRgjKPv"});let it=class extends J{constructor(){super(...arguments),this.tokenId="0x9ec4a3eff8ccaf295321aa4c2a03552f11c760af",this.balance=0,this.isAuthenticated=!1}formatUnits({balance:t,decimals:i}){return t/Math.pow(10,i)}async moralisAuthentication(){const t=window.Moralis.User.current();if(!t)return await window.Moralis.authenticate({signingMessage:"Log in using Moralis"});const[i]=await window.ethereum.request({method:"eth_requestAccounts"});return t.get("ethAddress")!==i?await window.Moralis.authenticate({signingMessage:"Log in using Moralis"}):t}async login(){try{const t=await this.moralisAuthentication();return this.isAuthenticated=!!t,t}catch(t){return console.error(t),null}}async updateGameBalance(t){const i=(await window.Moralis.Web3API.account.getTokenBalances({chain:"polygon",address:t.get("ethAddress")})).find((({token_address:t})=>t===this.tokenId));i&&(this.balance=this.formatUnits(i),this.dispatchEvent(new CustomEvent("balance-changed",{detail:this.balance,bubbles:!0,composed:!0})))}reset(){this.isAuthenticated=!1,this.balance=0}async connectedCallback(){if(super.connectedCallback(),!this.tokenId||""===this.tokenId)throw"Please define attribute `tokenId` first!";const t=window.Moralis.User.current(),[i]=await window.ethereum.request({method:"eth_requestAccounts"});t.get("ethAddress")!==i?await window.Moralis.User.logOut():(this.isAuthenticated=!0,this.updateGameBalance(t)),window.ethereum.on("accountsChanged",(async()=>{await window.Moralis.User.logOut(),this.reset();const t=await this.login();t&&await this.updateGameBalance(t)}))}async handleConnect(){const t=await this.login();t&&await this.updateGameBalance(t)}render(){return T` | ||
var tt=function(t,i,s,e){for(var n,o=arguments.length,r=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,h=t.length-1;h>=0;h--)(n=t[h])&&(r=(o<3?n(r):o>3?n(i,s,r):n(i,s))||r);return o>3&&r&&Object.defineProperty(i,s,r),r};window.Moralis.start({serverUrl:"https://mqia9hg0fj9k.usemoralis.com:2053/server",appId:"yXCZJLM8gX3PgM8xc2TnxHoQfg86qukH8NRgjKPv"});let it=class extends J{constructor(){super(...arguments),this.tokenId="",this.balance=0,this.isAuthenticated=!1}formatUnits({balance:t,decimals:i}){return t/Math.pow(10,i)}async moralisAuthentication(){const t=window.Moralis.User.current();if(!t)return await window.Moralis.authenticate({signingMessage:"Log in using Moralis"});const[i]=await window.ethereum.request({method:"eth_requestAccounts"});return t.get("ethAddress")!==i?await window.Moralis.authenticate({signingMessage:"Log in using Moralis"}):t}async login(){try{const t=await this.moralisAuthentication();return this.isAuthenticated=!!t,t}catch(t){return console.error(t),null}}async updateGameBalance(t){const i=(await window.Moralis.Web3API.account.getTokenBalances({chain:"polygon",address:t.get("ethAddress")})).find((({token_address:t})=>t.toLowerCase()===this.tokenId.toLowerCase()));i&&(this.balance=this.formatUnits(i),this.dispatchEvent(new CustomEvent("balance-changed",{detail:this.balance,bubbles:!0,composed:!0})))}reset(){this.isAuthenticated=!1,this.balance=0}async connectedCallback(){if(super.connectedCallback(),!this.tokenId||""===this.tokenId)throw"Please define attribute `tokenId` first!";const t=window.Moralis.User.current(),[i]=await window.ethereum.request({method:"eth_requestAccounts"});t.get("ethAddress")!==i?await window.Moralis.User.logOut():(this.isAuthenticated=!0,this.updateGameBalance(t)),window.ethereum.on("accountsChanged",(async()=>{await window.Moralis.User.logOut(),this.reset();const t=await this.login();t&&await this.updateGameBalance(t)}))}async handleConnect(){const t=await this.login();t&&await this.updateGameBalance(t)}render(){return T` | ||
${this.isAuthenticated?this.mainTmpl():this.connectionTmpl()} | ||
@@ -48,0 +48,0 @@ ${this.balance<1?this.notAllowedTmpl():""} |
@@ -27,3 +27,3 @@ /** | ||
super(...arguments); | ||
this.tokenId = '0x9ec4a3eff8ccaf295321aa4c2a03552f11c760af'; | ||
this.tokenId = ''; | ||
this.balance = 0; | ||
@@ -59,3 +59,3 @@ this.isAuthenticated = false; | ||
const userTokens = await window.Moralis.Web3API.account.getTokenBalances({ chain: 'polygon', address: user.get('ethAddress') }); | ||
const userGameToken = userTokens.find(({ token_address }) => token_address === this.tokenId); | ||
const userGameToken = userTokens.find(({ token_address }) => token_address.toLowerCase() === this.tokenId.toLowerCase()); | ||
if (userGameToken) { | ||
@@ -62,0 +62,0 @@ this.balance = this.formatUnits(userGameToken); |
{ | ||
"name": "hashup-drm", | ||
"private": false, | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Hashup drm", | ||
@@ -10,4 +10,5 @@ "main": "hashup-drm.bundled.js", | ||
"scripts": { | ||
"start": "npm run build", | ||
"watch": "tsc --watch", | ||
"build": "tsc && npm run rollup", | ||
"build:watch": "tsc --watch", | ||
"clean": "rimraf hashup-drm.{d.ts,d.ts.map,js,js.map} test/hashup-drm.{d.ts,d.ts.map,js,js.map} test/hashup-drm_test.{d.ts,d.ts.map,js,js.map}", | ||
@@ -14,0 +15,0 @@ "lint": "npm run lint:lit-analyzer && npm run lint:eslint", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73092