Skip to content

Commit

Permalink
devop: merge prep release
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Oct 22, 2024
2 parents c062889 + cf08a21 commit ded605f
Show file tree
Hide file tree
Showing 29 changed files with 751 additions and 519 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/lib/cjs/constants.js b/lib/cjs/constants.js
index 5772226ef895bff7a6f7fa291fc1138b10049dab..c65a57bf3535e6c6d4d894657da9b571d7f40d8a 100644
--- a/lib/cjs/constants.js
+++ b/lib/cjs/constants.js
@@ -29,7 +29,7 @@ exports.AMPLITUDE_ORIGINS_MAP = {
EU: exports.AMPLITUDE_ORIGIN_EU,
STAGING: exports.AMPLITUDE_ORIGIN_STAGING,
};
-exports.AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz';
+exports.AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = '';
// This is the class name used by the visual tagging selector to highlight the selected element.
// Should not use this class in the selector.
exports.AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight';
diff --git a/lib/esm/constants.js b/lib/esm/constants.js
index 17e665c05e62e488032673d312a69432297cb6fd..7d75951a29fad79ba49c83c076785294166dd0bf 100644
--- a/lib/esm/constants.js
+++ b/lib/esm/constants.js
@@ -27,7 +27,7 @@ export var AMPLITUDE_ORIGINS_MAP = {
EU: AMPLITUDE_ORIGIN_EU,
STAGING: AMPLITUDE_ORIGIN_STAGING,
};
-export var AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz';
+export var AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = '';
// This is the class name used by the visual tagging selector to highlight the selected element.
// Should not use this class in the selector.
export var AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight';
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"resolutions": {
"@ledgerhq/compressjs": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.2.1.tgz",
"@noble/hashes": "^1.4.0",
"fork-ts-checker-webpack-plugin": "^6.5.3"
"fork-ts-checker-webpack-plugin": "^6.5.3",
"@amplitude/plugin-autocapture-browser@^1.0.2": "patch:@amplitude/plugin-autocapture-browser@npm%3A1.0.3#./.yarn/patches/@amplitude-plugin-autocapture-browser-npm-1.0.3-edb25bef55.patch"
}
}
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@enkryptcom/extension-vite",
"name": "@enkryptcom/extension",
"version": "2.0.0",
"private": true,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/libs/market-data/ethvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const getMarketInfoByIDs = (
return ethvmPost(
'{"operationName":null,"variables":{},"query":"{\\n getCoinGeckoTokenMarketDataByIds(coinGeckoTokenIds: [' +
params +
']) {\\n id\\n symbol\\n name\\n image\\n market_cap\\n market_cap_rank\\n high_24h\\n low_24h\\n price_change_24h\\n price_change_percentage_24h\\n sparkline_in_7d {\\n price\\n }\\n price_change_percentage_7d_in_currency\\n current_price\\n }\\n}\\n"}'
']) {\\n id\\n symbol\\n name\\n image\\n market_cap\\n market_cap_rank\\n high_24h\\n low_24h\\n price_change_24h\\n price_change_percentage_24h\\n sparkline_in_24h {\\n price\\n }\\n price_change_percentage_24h_in_currency\\n current_price\\n }\\n}\\n"}'
).then((json) => {
return json.data.getCoinGeckoTokenMarketDataByIds as CoinGeckoTokenMarket[];
});
Expand Down
60 changes: 30 additions & 30 deletions packages/extension/src/libs/market-data/types.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
export enum StorageKeys {
lastTimestamp = "last-time-stamp",
allTokens = "all-tokens",
fiatInfo = "fiat-info",
lastTimestamp = 'last-time-stamp',
allTokens = 'all-tokens',
fiatInfo = 'fiat-info',
}

export interface CoingeckPlatforms {
[key: string]: any;
ethereum?: string;
"ethereum-classic"?: string;
"binance-smart-chain"?: string;
gochain?: string;
"polygon-pos"?: string;
moonbeam?: string;
rootstock?: string;
[key: string]: any
ethereum?: string
'ethereum-classic'?: string
'binance-smart-chain'?: string
gochain?: string
'polygon-pos'?: string
moonbeam?: string
rootstock?: string
}
export interface CoinGeckoToken {
id: string;
symbol: string;
name: string;
platforms: CoingeckPlatforms;
id: string
symbol: string
name: string
platforms: CoingeckPlatforms
}
export interface CoinGeckoTokenMarket {
id: string;
symbol: string;
name: string;
image: string;
current_price: null | number;
market_cap: number;
market_cap_rank: number;
high_24h: number;
low_24h: number;
price_change_24h: number;
price_change_percentage_24h: number;
sparkline_in_7d: { price: number[] };
price_change_percentage_7d_in_currency: number;
id: string
symbol: string
name: string
image: string
current_price: null | number
market_cap: number
market_cap_rank: number
high_24h: number
low_24h: number
price_change_24h: number
price_change_percentage_24h: number
sparkline_in_24h: { price: number[] }
price_change_percentage_24h_in_currency: number
}
export interface FiatMarket {
fiat_currency: string;
exchange_rate: string;
fiat_currency: string
exchange_rate: string
}
141 changes: 79 additions & 62 deletions packages/extension/src/libs/window-promise/promise.ts
Original file line number Diff line number Diff line change
@@ -1,122 +1,139 @@
import {
sendToBackgroundFromBackground,
sendToNewWindowFromBackground,
} from "@/libs/messenger/extension";
import { ProviderName } from "@/types/provider";
import Browser from "webextension-polyfill";
import { InternalMethods, InternalOnMessageResponse } from "@/types/messenger";
import { getCustomError, getError } from "../error";
import getUiPath from "../utils/get-ui-path";
import UIRoutes from "@/ui/provider-pages/enkrypt/routes/names";
import { ErrorCodes } from "@/providers/ethereum/types";
} from '@/libs/messenger/extension'
import { ProviderName } from '@/types/provider'
import Browser from 'webextension-polyfill'
import { InternalMethods, InternalOnMessageResponse } from '@/types/messenger'
import { getCustomError, getError } from '../error'
import getUiPath from '../utils/get-ui-path'
import UIRoutes from '@/ui/provider-pages/enkrypt/routes/names'
import { ErrorCodes } from '@/providers/ethereum/types'

const UNLOCK_PATH = getUiPath(UIRoutes.unlock.path, ProviderName.enkrypt);
const UNLOCK_PATH = getUiPath(UIRoutes.unlock.path, ProviderName.enkrypt)
class WindowPromise {
private async getRawResponse(
url: string,
msg: string,
tabId: number
tabInfo: { tabId: number },
): Promise<InternalOnMessageResponse> {
return new Promise((resolve) => {
return new Promise(resolve => {
Browser.tabs.onUpdated.addListener(function listener(_tabId, info, tab) {
if (info.status === "complete" && _tabId === tabId && tab.url === url) {
if (
info.status === 'complete' &&
_tabId === tabInfo.tabId &&
tab.url === url
) {
resolve(
sendToNewWindowFromBackground(
{
provider: ProviderName.enkrypt,
message: msg,
},
tabId
)
);
Browser.tabs.onUpdated.removeListener(listener);
tabInfo.tabId,
),
)
Browser.tabs.onUpdated.removeListener(listener)
}
});
Browser.tabs.update(tabId, { url });
});
})
Browser.tabs.update(tabInfo.tabId, { url })
})
}

private removeTab(tabId: number) {
Browser.tabs.get(tabId).then((info) => {
Browser.windows.remove(info.windowId!);
});
Browser.tabs.get(tabId).then(info => {
Browser.windows.remove(info.windowId!)
})
}

async getResponse(
url: string,
msg: string,
unlockKeyring = false
unlockKeyring = false,
): Promise<InternalOnMessageResponse> {
const loadingURL = '/index.html#/enkrypt/loading'
const tabInfo = {
tabId: -1,
}
const windowInfo = await Browser.windows.create({
url: "/index.html#/enkrypt/loading",
type: "popup",
url: loadingURL,
type: 'popup',
focused: true,
height: 600,
width: 460,
});
const tabId: number | undefined = windowInfo.tabs?.length
? windowInfo.tabs[0].id
: 0;
if (typeof tabId === "undefined") {
})
const validTabs = await Browser.tabs.query({
windowId: windowInfo.id,
})
tabInfo.tabId = validTabs.length && validTabs[0].id ? validTabs[0].id : -1
if (typeof tabInfo.tabId === 'undefined' || tabInfo.tabId === -1) {
return Promise.resolve({
error: getCustomError("unknown error, no tabId"),
});
error: getCustomError('unknown error, no tabId'),
})
}
const waitForWindow = async (): Promise<void> => {
while ((await Browser.tabs.get(tabId)).status !== "complete") {}
};
await waitForWindow();
// eslint-disable-next-line no-empty
while ((await Browser.tabs.get(tabInfo.tabId)).status !== 'complete') {}
}
await waitForWindow()
const monitorTabs = (): Promise<InternalOnMessageResponse> => {
return new Promise((resolve) => {
Browser.tabs.onRemoved.addListener(function tabListener(_tabId) {
if (_tabId === tabId) {
Browser.tabs.onRemoved.removeListener(tabListener);
return new Promise(resolve => {
const tabReplacedListener = (addedId: number, replacedId: number) => {
if (replacedId === tabInfo.tabId) {
tabInfo.tabId = addedId
}
}
const tabListener = (_tabId: number) => {
if (_tabId === tabInfo.tabId) {
Browser.tabs.onRemoved.removeListener(tabListener)
Browser.tabs.onReplaced.removeListener(tabReplacedListener)
resolve({
error: getError(ErrorCodes.userRejected),
});
})
}
});
});
};
}
Browser.tabs.onRemoved.addListener(tabListener)
Browser.tabs.onReplaced.addListener(tabReplacedListener)
})
}
const executePromise = async (): Promise<InternalOnMessageResponse> => {
const isKeyRingLocked = await sendToBackgroundFromBackground({
provider: ProviderName.enkrypt,
message: JSON.stringify({
method: InternalMethods.isLocked,
params: [],
}),
}).then((res) => JSON.parse(res.result as string));
}).then(res => JSON.parse(res.result as string))
if (unlockKeyring && isKeyRingLocked) {
const unlockKeyring = await this.getRawResponse(
Browser.runtime.getURL(UNLOCK_PATH),
msg,
tabId
);
tabInfo,
)
if (unlockKeyring.error) {
this.removeTab(tabId);
return unlockKeyring;
this.removeTab(tabInfo.tabId)
return unlockKeyring
} else {
return await this.getRawResponse(
Browser.runtime.getURL(url),
msg,
tabId
).then((res) => {
this.removeTab(tabId);
return res;
});
tabInfo,
).then(res => {
this.removeTab(tabInfo.tabId)
return res
})
}
}
return await this.getRawResponse(
Browser.runtime.getURL(url),
msg,
tabId
).then((res) => {
this.removeTab(tabId);
return res;
});
};
return Promise.race([monitorTabs(), executePromise()]);
tabInfo,
).then(res => {
this.removeTab(tabInfo.tabId)
return res
})
}
return Promise.race([monitorTabs(), executePromise()])
}
}
export default WindowPromise;
export default WindowPromise
2 changes: 1 addition & 1 deletion packages/extension/src/manifest/manifest.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
version,
name: 'Enkrypt: ETH, BTC and Solana Wallet',
short_name: 'Enkrypt',
description: 'Everything in the blockchain made easy',
description: 'The best multichain crypto wallet',
permissions: [
'storage',
'unlimitedStorage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ export class BitcoinNetwork extends BaseNetwork {
contract: "",
decimals: this.decimals,
sparkline: marketData.length
? new Sparkline(marketData[0]!.sparkline_in_7d.price, 25).dataValues
? new Sparkline(marketData[0]!.sparkline_in_24h.price, 25).dataValues
: "",
priceChangePercentage: marketData.length
? marketData[0]!.price_change_percentage_7d_in_currency
? marketData[0]!.price_change_percentage_24h_in_currency
: 0,
};
return [nativeAsset];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ export default (
low_24h: 0,
price_change_24h: 0,
price_change_percentage_24h: 0,
sparkline_in_7d: { price: [] },
price_change_percentage_7d_in_currency: 0,
sparkline_in_24h: { price: [] },
price_change_percentage_24h_in_currency: 0,
};
}

Expand Down Expand Up @@ -303,9 +303,10 @@ export default (
valuef: formatFiatValue(currentPrice.toString()).value,
contract: address,
decimals: tokenInfo[address].decimals,
sparkline: new Sparkline(market.sparkline_in_7d.price, 25).dataValues,
sparkline: new Sparkline(market.sparkline_in_24h.price, 25)
.dataValues,
priceChangePercentage:
market.price_change_percentage_7d_in_currency || 0,
market.price_change_percentage_24h_in_currency || 0,
};
if (address !== NATIVE_TOKEN_ADDRESS) assets.push(asset);
else nativeAsset = asset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ async function getPreconfiguredTokens(
).value,
decimals: assetDecimals,
sparkline: nativeAssetMarketData[index]
? new Sparkline(nativeAssetMarketData[index]?.sparkline_in_7d.price, 25)
.dataValues
? new Sparkline(
nativeAssetMarketData[index]?.sparkline_in_24h.price,
25,
).dataValues
: '',
priceChangePercentage:
nativeAssetMarketData[index]?.price_change_percentage_7d_in_currency ??
nativeAssetMarketData[index]?.price_change_percentage_24h_in_currency ??
0,
contract: asset.address,
}
Expand Down
Loading

1 comment on commit ded605f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.