Skip to content

Commit 8619164

Browse files
committed
2 parents 5845590 + d0a6100 commit 8619164

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

src/localServer/define.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,14 @@ interface profile extends keyPair {
424424
historicBalance?: historicBalance[]
425425
airdrop?: airdrop
426426
silentPassPassports?: passportInfo[]
427+
activePassport?: freePassport
428+
}
429+
430+
interface freePassport {
431+
nftID: string;
432+
expires: string;
433+
expiresDays: string;
434+
premium: boolean;
427435
}
428436

429437
interface publicProfile {

src/localServer/workers/utilities/web3Util.ts

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ const getProfileAssets_allOthers_Balance = async (profile: profile) => {
316316
current.conet_eth = {
317317
balance: conet_eth === false ? "" : ethers.formatEther(conet_eth),
318318
history: [],
319-
network: "conetMainnet",
319+
network: "CONET DePIN",
320320
decimal: 18,
321321
contract: "",
322322
name: "conet_eth",
@@ -400,7 +400,7 @@ const getProfileAssets_CONET_Balance = async (profile: profile) => {
400400
const current = profile.tokens
401401

402402
const [
403-
CNTPV1, cCNTP, conet, conetDepin,
403+
CNTPV1, cCNTP, conet, conetDepin, conet_eth,
404404
cBNBUSDT, cUSDT, cBNB, cETH, cArbETH, cArbUSDT,
405405
_GuardianPlan, _CONETianPlan
406406
] = await Promise.all([
@@ -410,6 +410,7 @@ const getProfileAssets_CONET_Balance = async (profile: profile) => {
410410
scanCONETHolesky(key, provideCONET),
411411
scanCONETDepin(key),
412412

413+
scanConetETH(key),
413414
scanCONET_Claimable_BNBUSDT(key),
414415
scanCONET_Claimable_ETHUSDT(key),
415416
scanCONET_Claimable_BNB(key),
@@ -472,6 +473,20 @@ const getProfileAssets_CONET_Balance = async (profile: profile) => {
472473
name: 'conetDepin'
473474
}
474475
}
476+
477+
if (current.conet_eth) {
478+
current.conet_eth.balance =
479+
conet_eth === false ? "" : ethers.formatEther(conet_eth);
480+
} else {
481+
current.conet_eth = {
482+
balance: conet_eth === false ? "" : ethers.formatEther(conet_eth),
483+
history: [],
484+
network: "CONET DePIN",
485+
decimal: 18,
486+
contract: "",
487+
name: "conet_eth",
488+
};
489+
}
475490

476491
// Claimable Assets
477492

@@ -3549,11 +3564,53 @@ const getPassportsInfoForAllProfiles = async () => {
35493564
}
35503565

35513566
for (const profile of profiles) {
3552-
const result = await getPassportsInfoForProfile(profile);
3553-
profile.silentPassPassports = result
3567+
const passports = await getPassportsInfoForProfile(profile);
3568+
const currentPassport = await getCurrentPassportInfo(profile);
3569+
3570+
profile.silentPassPassports = passports;
3571+
profile.activePassport = {
3572+
nftID: currentPassport?.nftIDs?.toString(),
3573+
expires: currentPassport?.expires?.toString(),
3574+
expiresDays: currentPassport?.expiresDays?.toString(),
3575+
premium: currentPassport?.premium,
3576+
}
35543577
}
35553578
};
35563579

3580+
const getCurrentPassportInfoInMainnet = async (profile: profile) => {
3581+
if (!profile) {
3582+
return;
3583+
}
3584+
3585+
const wallet = new ethers.Wallet(
3586+
profile.privateKeyArmor,
3587+
conetDepinProvider
3588+
);
3589+
3590+
const passportContract = new ethers.Contract(
3591+
passportContractAddress_mainnet,
3592+
passportAbi_mainnet,
3593+
wallet
3594+
);
3595+
3596+
try {
3597+
const result = await passportContract.getCurrentPassport(wallet.address);
3598+
return result;
3599+
} catch (ex) {
3600+
console.log(ex);
3601+
}
3602+
};
3603+
3604+
const getCurrentPassportInfo = async (profile: profile) => {
3605+
if (!CoNET_Data) {
3606+
return;
3607+
}
3608+
3609+
const resultMainnet = await getCurrentPassportInfoInMainnet(profile);
3610+
3611+
return resultMainnet;
3612+
};
3613+
35573614
const getPassportsInfoForProfile = async (profile: profile): Promise<passportInfo[]> => {
35583615
const tmpCancunPassports = await getPassportsInfo(profile, 'cancun');
35593616
const tmpMainnetPassports = await getPassportsInfo(profile, 'mainnet');

0 commit comments

Comments
 (0)