I began converting the angular demo code to run as an injectable service.
I have added all polyfills and dependencies.
I am seeing this error
import { Injectable } from '@angular/core';
import { Moralis } from 'moralis';
import { environment } from 'src/environments/environment';
import { User } from '../profile/profile.component';
@Injectable({
providedIn: 'root',
})
export class MoralisService {
user?: User;
constructor() {
Moralis.start({
appId: environment.moralis.appId,
serverUrl: environment.moralis.serverUrl,
})
.then(() => console.info('Moralis has been initialised.'))
.finally(() => this.setLoggedInUser(Moralis.User.current()));
}
login(provider: 'metamask' | 'walletconnect' = 'metamask') {
(provider === 'metamask'
? Moralis.Web3.authenticate()
: Moralis.Web3.authenticate({ provider })
)
.then((loggedInUser) => this.setLoggedInUser(loggedInUser))
.catch((e) => console.error(`Moralis '${provider}' login error:`, e));
}
logout() {
Moralis.User.logOut()
.then((loggedOutUser) => console.info('logout', loggedOutUser))
// Set user to undefined
.then(() => this.setLoggedInUser(undefined))
// Disconnect Web3 wallet
.then(() => Moralis.Web3.cleanup())
.catch((e) => console.error('Moralis logout error:', e));
}
private setLoggedInUser(loggedInUser?: User) {
this.user = loggedInUser;
console.info('Loggedin user:', loggedInUser);
/**
* Manual detect changes due to OnPush change detection.
* This can be eliminated if you use async pipe and Observables
* (out of scope of this demo)
*/
//this.cdr.detectChanges();
}
}
Error: node_modules/moralis/types/generated/web3Api.d.ts:1970:194 - error TS2339: Property '200' does not exist on type '{ 201: unknown; }'.
1970 syncNFTContract: (options: operations["syncNFTContract"]["parameters"]["query"] & operations["syncNFTContract"]["parameters"]["path"]) => Promise<operations["syncNFTContract"]["responses"]["200"]["content"]["application/json"]>;
Does anyone know what could cause this? I have double checked my environtment credentials and everything is correct.