Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/project Id implementation #80

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/app/components/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { NzNotificationService } from 'ng-zorro-antd/notification';
import { BehaviorSubject, firstValueFrom, skip, Subscription } from 'rxjs';
import { MemberApi, TokenDistributionWithAirdrops } from './../../../@api/member.api';
import { removeItem } from './../../../@core/utils/local-storage.utils';
import { environment } from '@env/environment';
const tanglePay = (window as any).iota;

export interface MetamaskSignature {
Expand Down Expand Up @@ -206,14 +207,15 @@ export class AuthService {
public async sign(params: any = {}, cb: SignCallback): Promise<WenRequest | undefined> {
this.showWalletPopup$.next(WalletStatus.ACTIVE);
// We support either resign with metamask or reuse token.
let sc: WenRequest | undefined | false = undefined;
let sc: any | undefined | false = undefined;
const customToken: any = getItem(StorageItem.CustomToken);
const wallet = customToken.wallet || Wallets.Metamask;
// check it's not expired.
if (this.isCustomTokenNotExpired(customToken)) {
sc = {
address: customToken.address,
customToken: customToken.value,
projectApiKey: environment.build5Token,
body: params,
};
} else if (customToken) {
Expand Down Expand Up @@ -271,7 +273,7 @@ export class AuthService {
return true;
}

private async signWithMetamask(params: any = {}): Promise<WenRequest | undefined | false> {
private async signWithMetamask(params: any = {}): Promise<any | undefined | false> {
const provider: any = await detectEthereumProvider();
if (provider) {
try {
Expand Down Expand Up @@ -319,6 +321,7 @@ export class AuthService {
return {
address: provider.selectedAddress,
signature: signature,
projectApiKey: environment.build5Token,
body: params,
};
} catch (e) {
Expand Down Expand Up @@ -389,9 +392,10 @@ export class AuthService {
},
});

const returnObj: WenRequest = {
const returnObj: any = {
address: currentAddress,
signature: signature,
projectApiKey: environment.build5Token,
body: params,
};

Expand Down
1 change: 1 addition & 0 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const environment = {
key: 'ed51a01fc204688339e89ac8e9d53028',
},
soonaversePlaceholder: 'https://soonaverse.com/favicon.ico',
build5Token: '',
};
2 changes: 2 additions & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export const environment = {
key: '5c053a0370395f0fe8cf7ce9e5a21a72',
},
soonaversePlaceholder: 'https://soonaverse.com/favicon.ico',
build5Token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIweDU1MWZkMmM3YzdiZjM1NmJhYzE5NDU4N2RhYjJmY2Q0NjQyMDA1NGIiLCJwcm9qZWN0IjoiMHg0NjIyM2VkZDQxNTc2MzVkZmM2Mzk5MTU1NjA5ZjMwMWRlY2JmZDg4IiwiaWF0IjoxNjk1ODUyNTk2fQ.WT9L4H9eDdFfJZMrfxTKhEq4PojNWSGNv_CbmlG9sJg',
};
Loading