Skip to content

Commit

Permalink
Merge branch 'main' into feat/safari-support
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Oct 24, 2023
2 parents 5676d73 + 3f5cfa7 commit fa07d7a
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
id: node-version
run: |
docker build -t enkrypt-build-container .
echo ::set-output name=NODE_VERSION::$(docker run --rm -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "node --version")
echo "NODE_VERSION=$(docker run --rm -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "node --version")" >> $GITHUB_OUTPUT
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- name: Cache yarn modules
uses: actions/cache@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
id: node-version
run: |
docker build -t enkrypt-build-container .
echo ::set-output name=NODE_VERSION::$(docker run --rm -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "node --version")
echo "NODE_VERSION=$(docker run --rm -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "node --version")" >> $GITHUB_OUTPUT
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- name: Cache yarn modules
uses: actions/cache@v3
Expand All @@ -35,7 +35,7 @@ jobs:

- name: Get release tag
id: get_release_tag
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT

- name: build
env:
Expand Down
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.28.0",
"version": "1.29.0",
"private": true,
"scripts": {
"zip": "cd dist; zip -r release.zip *;",
Expand Down
11 changes: 10 additions & 1 deletion packages/extension/src/libs/utils/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const getAccountsByNetworkName = async (

const accounts = await keyring.getAccounts(network.signer);

return accounts.filter((account) => {
const filtered = accounts.filter((account) => {
if (account.isHardware && account.HWOptions !== undefined) {
// Polkadot and Kusama ledger apps only work for those networks
if (
Expand All @@ -34,6 +34,15 @@ export const getAccountsByNetworkName = async (

return true;
});
return filtered.map((f) => {
if (
network.signer.includes(SignerType.secp256k1btc) &&
f.name === "Bitcoin Account 1"
) {
f.name = f.name.replace("Bitcoin", network.name_long);
}
return f;
});
};

export { getOtherSigners };
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const NetworkEndpoints: Record<string, string> = {
[NetworkNames.MaticZK]: "https://api-zkevm.polygonscan.com/",
[NetworkNames.Base]: "https://api.basescan.org/",
[NetworkNames.Celo]: "https://explorer.celo.org/mainnet/",
[NetworkNames.Arthera]: "https://explorer-test.arthera.net/",
};

export { NetworkEndpoints };
24 changes: 24 additions & 0 deletions packages/extension/src/providers/ethereum/networks/aa.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NetworkNames } from "@enkryptcom/types";
import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network";
import { EtherscanActivity } from "../libs/activity-handlers";
import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler";
import assetsInfoHandler from "@/providers/ethereum/libs/assets-handlers/assetinfo-mew";

const artheraOptions: EvmNetworkOptions = {
name: NetworkNames.Arthera,
name_long: "Arthera",
homePage: "https://arthera.net/",
blockExplorerTX: "https://explorer-test.arthera.net/tx/[[txHash]]",
blockExplorerAddr: "https://explorer-test.arthera.net/address/[[address]]",
chainID: "0x2803",
isTestNetwork: true,
currencyName: "AA",
currencyNameLong: "Arthera",
node: "wss://ws-test.arthera.net",
icon: require("./icons/aa.svg"),
activityHandler: wrapActivityHandler(EtherscanActivity),
};

const arthera = new EvmNetwork(artheraOptions);

export default arthera;
42 changes: 42 additions & 0 deletions packages/extension/src/providers/ethereum/networks/icons/aa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/extension/src/providers/ethereum/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import sepoliaNode from "./sepolia";
import baseNode from "./base";
import celoNode from "./celo";
import shibNode from "./shib";
import artheraNode from "./aa";

export default {
goerli: goerliNode,
Expand Down Expand Up @@ -73,4 +74,5 @@ export default {
base: baseNode,
celo: celoNode,
shib: shibNode,
arthera: artheraNode,
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
class="rename-account-form__input"
:class="{ focus: isFocus && isValidName, error: !isValidName }"
>
<img :src="network.identicon(account.address || '')" />
<img
:src="network.identicon(network.displayAddress(account.address))"
/>
<input
ref="renameAccountInput"
v-model="accountName"
Expand Down
12 changes: 12 additions & 0 deletions packages/swap/tests/fixtures/mainnet/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ const fromToken: TokenType = {
type: NetworkType.EVM,
};

const fromTokenWBTC: TokenType = {
address: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
decimals: 8,
logoURI: "https://api.rango.exchange/tokens/ETH/WBTC.png",
name: "WBTC",
symbol: "WBTC",
rank: 18,
cgId: "bitcoin",
type: NetworkType.EVM,
};

const toTokenWETH: TokenTypeTo = {
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
decimals: 18,
Expand Down Expand Up @@ -68,6 +79,7 @@ export {
fromToken,
toToken,
toTokenWETH,
fromTokenWBTC,
amount,
fromAddress,
toAddress,
Expand Down
20 changes: 11 additions & 9 deletions packages/swap/tests/rango.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from "chai";
import { toBN } from "web3-utils";
import Web3Eth from "web3-eth";
import Rango from "../src/providers/rango";
import {
Expand All @@ -7,28 +8,29 @@ import {
WalletIdentifier,
} from "../src/types";
import {
fromToken,
fromTokenWBTC,
toToken,
amount,
fromAddress,
toAddress,
nodeURL,
nodeURLMatic,
fromTokenNative,
amount,
} from "./fixtures/mainnet/configs";

describe("Rango Provider", () => {
// @ts-ignore
it("it should return a quote", async () => {
const localAmount = toBN("100000000");
const web3eth = new Web3Eth(nodeURL);
const rango = new Rango(web3eth, SupportedNetworkName.Ethereum);
const init = rango.init();
await init;
const quote = await rango.getQuote(
{
amount,
fromAddress,
fromToken,
amount: localAmount,
fromAddress: "0x9ff58f4ffb29fa2266ab25e75e2a8b3503311656", // aave
fromToken: fromTokenWBTC,
toToken,
toAddress,
},
Expand All @@ -39,13 +41,13 @@ describe("Rango Provider", () => {
expect(quote?.quote.meta.walletIdentifier).to.be.eq(
WalletIdentifier.enkrypt
);
expect(quote?.fromTokenAmount.toString()).to.be.eq(amount.toString());
expect(quote?.fromTokenAmount.toString()).to.be.eq(localAmount.toString());
expect(quote?.toTokenAmount.gtn(0)).to.be.eq(true);

const swap = await rango.getSwap(quote!.quote);
expect(swap?.transactions.length).to.be.eq(2);
expect(swap?.transactions[0].to).to.be.eq(fromToken.address);
}).timeout(20000);
expect(swap?.transactions[0].to).to.be.eq(fromTokenWBTC.address);
}).timeout(25000);

it("it should return cross chain swap", async () => {
const web3eth = new Web3Eth(nodeURLMatic);
Expand All @@ -72,5 +74,5 @@ describe("Rango Provider", () => {
expect(quote?.additionalNativeFees.gtn(0)).to.be.eq(true);
const swap = await rango.getSwap(quote!.quote);
expect(swap?.transactions.length).to.be.eq(1);
}).timeout(20000);
}).timeout(25000);
});
10 changes: 5 additions & 5 deletions packages/swap/tests/swap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("Swap", () => {
toToken,
toAddress,
});
expect(quotes?.length).to.be.eq(4);
expect(quotes?.length).to.be.eq(3);
const oneInceQuote = quotes.find(
(q) => q.provider === ProviderName.oneInch
);
Expand All @@ -72,12 +72,12 @@ describe("Swap", () => {
(q) => q.provider === ProviderName.changelly
);
const zeroxQuote = quotes.find((q) => q.provider === ProviderName.zerox);
const rangoQuote = quotes.find((q) => q.provider === ProviderName.rango);
// const rangoQuote = quotes.find((q) => q.provider === ProviderName.rango);
expect(zeroxQuote).to.be.eq(undefined);
expect(changellyQuote!.provider).to.be.eq(ProviderName.changelly);
expect(oneInceQuote!.provider).to.be.eq(ProviderName.oneInch);
expect(paraswapQuote!.provider).to.be.eq(ProviderName.paraswap);
expect(rangoQuote!.provider).to.be.eq(ProviderName.rango);
// expect(rangoQuote!.provider).to.be.eq(ProviderName.rango);
const swapOneInch = await enkryptSwap.getSwap(oneInceQuote!.quote);
expect(swapOneInch?.fromTokenAmount.toString()).to.be.eq(amount.toString());
expect(swapOneInch?.transactions.length).to.be.eq(2);
Expand Down Expand Up @@ -105,11 +105,11 @@ describe("Swap", () => {
(q) => q.provider === ProviderName.changelly
);
const zeroxQuote = quotes.find((q) => q.provider === ProviderName.zerox);
const rangoQuote = quotes.find((q) => q.provider === ProviderName.rango);
// const rangoQuote = quotes.find((q) => q.provider === ProviderName.rango);
expect(zeroxQuote!.provider).to.be.eq(ProviderName.zerox);
expect(changellyQuote!.provider).to.be.eq(ProviderName.changelly);
expect(oneInceQuote!.provider).to.be.eq(ProviderName.oneInch);
expect(paraswapQuote!.provider).to.be.eq(ProviderName.paraswap);
expect(rangoQuote!.provider).to.be.eq(ProviderName.rango);
// expect(rangoQuote!.provider).to.be.eq(ProviderName.rango);
}).timeout(10000);
});
1 change: 1 addition & 0 deletions packages/types/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export enum NetworkNames {
Celo = "CELO",
Litecoin = "LTC",
Dogecoin = "DOGE",
Arthera = "AA",
}

export enum CoingeckoPlatform {
Expand Down

1 comment on commit fa07d7a

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