Skip to content

Commit

Permalink
Merge pull request #541 from enkryptcom/develop
Browse files Browse the repository at this point in the history
Release: v1.45.0
  • Loading branch information
kvhnuke authored Oct 23, 2024
2 parents 8d6c8e0 + aa8058a commit 0bf8040
Show file tree
Hide file tree
Showing 32 changed files with 1,138 additions and 528 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,6 +1,6 @@
{
"name": "@enkryptcom/extension",
"version": "1.44.0",
"version": "1.45.0",
"private": true,
"scripts": {
"zip": "cd dist; zip -r release.zip *;",
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
4 changes: 2 additions & 2 deletions packages/extension/src/libs/market-data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export interface CoinGeckoTokenMarket {
low_24h: number;
price_change_24h: number;
price_change_percentage_24h: number;
sparkline_in_7d: { price: number[] };
price_change_percentage_7d_in_currency: number;
sparkline_in_24h: { price: number[] };
price_change_percentage_24h_in_currency: number;
}
export interface FiatMarket {
fiat_currency: string;
Expand Down
55 changes: 36 additions & 19 deletions packages/extension/src/libs/window-promise/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ class WindowPromise {
private async getRawResponse(
url: string,
msg: string,
tabId: number
tabInfo: { tabId: number }
): Promise<InternalOnMessageResponse> {
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
tabInfo.tabId
)
);
Browser.tabs.onUpdated.removeListener(listener);
}
});
Browser.tabs.update(tabId, { url });
Browser.tabs.update(tabInfo.tabId, { url });
});
}

Expand All @@ -47,36 +51,49 @@ class WindowPromise {
msg: string,
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",
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"),
});
}
const waitForWindow = async (): Promise<void> => {
// eslint-disable-next-line no-empty
while ((await Browser.tabs.get(tabId)).status !== "complete") {}
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) {
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> => {
Expand All @@ -91,28 +108,28 @@ class WindowPromise {
const unlockKeyring = await this.getRawResponse(
Browser.runtime.getURL(UNLOCK_PATH),
msg,
tabId
tabInfo
);
if (unlockKeyring.error) {
this.removeTab(tabId);
this.removeTab(tabInfo.tabId);
return unlockKeyring;
} else {
return await this.getRawResponse(
Browser.runtime.getURL(url),
msg,
tabId
tabInfo
).then((res) => {
this.removeTab(tabId);
this.removeTab(tabInfo.tabId);
return res;
});
}
}
return await this.getRawResponse(
Browser.runtime.getURL(url),
msg,
tabId
tabInfo
).then((res) => {
this.removeTab(tabId);
this.removeTab(tabInfo.tabId);
return res;
});
};
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/manifest/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"run_at": "document_start"
}
],
"description": "Everything in the blockchain made easy",
"description": "The best multichain crypto wallet",
"icons": {
"16": "assets/img/icons/icon16.png",
"32": "assets/img/icons/icon32.png",
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 @@ -160,11 +160,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
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ export class EvmNetwork extends BaseNetwork {
).value,
decimals: this.decimals,
sparkline: nativeMarketData
? new Sparkline(nativeMarketData.sparkline_in_7d.price, 25).dataValues
? new Sparkline(nativeMarketData.sparkline_in_24h.price, 25)
.dataValues
: "",
priceChangePercentage:
nativeMarketData?.price_change_percentage_7d_in_currency ?? 0,
nativeMarketData?.price_change_percentage_24h_in_currency ?? 0,
contract: NATIVE_TOKEN_ADDRESS,
};

Expand Down Expand Up @@ -273,11 +274,11 @@ export class EvmNetwork extends BaseNetwork {
marketInfo.current_price?.toString() ?? "0"
).value;
asset.sparkline = new Sparkline(
marketInfo.sparkline_in_7d.price,
marketInfo.sparkline_in_24h.price,
25
).dataValues;
asset.priceChangePercentage =
marketInfo.price_change_percentage_7d_in_currency || 0;
marketInfo.price_change_percentage_24h_in_currency || 0;
}

return asset;
Expand Down
11 changes: 5 additions & 6 deletions packages/extension/src/providers/kadena/libs/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class API implements ProviderAPIInterface {
this.displayAddress(address),
chainId
);

if (balance.result.status === "failure") {
const error = balance.result.error as { message: string | undefined };
const message = error.message ?? "Unknown error retrieving balances";
Expand All @@ -78,11 +77,11 @@ class API implements ProviderAPIInterface {
}
throw new Error(message);
}

const balanceValue = parseFloat(balance.result.data.toString()).toFixed(
this.decimals
);

const balanceValue = parseFloat(
balance.result.data.decimal
? balance.result.data.decimal
: balance.result.data.toString()
).toString();
return toBase(balanceValue, this.decimals);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ export class KadenaNetwork 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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ export class SubstrateNetwork extends BaseNetwork {
name: st.name,
symbol: st.symbol,
priceChangePercentage:
market[idx]?.price_change_percentage_7d_in_currency || 0,
market[idx]?.price_change_percentage_24h_in_currency || 0,
sparkline: market[idx]
? new Sparkline(market[idx]?.sparkline_in_7d.price, 25).dataValues
? new Sparkline(market[idx]?.sparkline_in_24h.price, 25).dataValues
: "",
value: market[idx]?.current_price?.toString() || "0",
valuef: formatFloatingPointValue(
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/providers/solana/types/sol-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export class SolanaNetwork 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
Loading

2 comments on commit 0bf8040

@github-actions
Copy link

Choose a reason for hiding this comment

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

@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.