Skip to content

Commit

Permalink
Merge pull request #457 from arconnectio/development
Browse files Browse the repository at this point in the history
ArConnect BETA 1.18.1
  • Loading branch information
nicholaswma authored Aug 5, 2024
2 parents 76169f9 + f76d6e2 commit ed52db2
Show file tree
Hide file tree
Showing 25 changed files with 674 additions and 161 deletions.
20 changes: 20 additions & 0 deletions assets/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
"message": "Save",
"description": "Save button text"
},
"generate": {
"message": "Generate",
"description": "Generate button text"
},
"add_wallet": {
"message": "Add wallet",
"description": "Add a wallet text"
Expand Down Expand Up @@ -299,6 +303,10 @@
"message": "Allows using dispatch transactions.",
"description": "Description for the \"DISPATCH\" permission"
},
"permissionAccessTokens": {
"message": "Allows access to view tokens and their balances that you've added to your wallet",
"description": "Description for the permission to access user-added token and token balances"
},
"copyId": {
"message": "Copy ID",
"description": "Copy ID button text"
Expand Down Expand Up @@ -1373,6 +1381,14 @@
"message": "Generate QR code",
"description": "Generate QR code button"
},
"generate_qr_code_title": {
"message": "Enter your password to generate QR Code",
"description": "Generate QR code title"
},
"cannot_generate_qr_code": {
"message": "Cannot generate QR code for your hardware wallet.",
"description": "Cannot generate QR text"
},
"viewblock": {
"message": "Viewblock",
"description": "view block"
Expand Down Expand Up @@ -2179,5 +2195,9 @@
"mismatch_warning": {
"message": "Your wallet has a mismatched bit length. You can proceed, but may encounter errors. Transactions could fail or behave unexpectedly.",
"description": "warning for mismatch wallet"
},
"transak_unavailable": {
"message": "Transak is unavailable at the moment. Please try again later.",
"description": "Transak unavailable error message"
}
}
20 changes: 20 additions & 0 deletions assets/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
"message": "节省",
"description": "Save button text"
},
"generate": {
"message": "产生",
"description": "Generate button text"
},
"add_wallet": {
"message": "添加钱包",
"description": "Add a wallet text"
Expand Down Expand Up @@ -295,6 +299,10 @@
"message": "允许使用调度交易。",
"description": "Description for the \"DISPATCH\" permission"
},
"permissionAccessTokens": {
"message": "允许查看您已添加到钱包中的代币及其余额",
"description": "Description for the permission to access user-added token and token balances"
},
"copyId": {
"message": "复制 ID",
"description": "Copy ID button text"
Expand Down Expand Up @@ -1361,6 +1369,14 @@
"message": "生成二维码",
"description": "Generate QR code button"
},
"generate_qr_code_title": {
"message": "输入密码生成二维码",
"description": "Generate QR code title"
},
"cannot_generate_qr_code": {
"message": "无法为您的硬件钱包生成二维码。",
"description": "Cannot generate QR text"
},
"viewblock": {
"message": "Viewblock",
"description": "view block"
Expand Down Expand Up @@ -2165,5 +2181,9 @@
"mismatch_warning": {
"message": "您的钱包存在不匹配的位长度。您可以继续操作,但可能会遇到错误。交易可能会失败或表现异常。",
"description": "warning for mismatch wallet"
},
"transak_unavailable": {
"message": "Transak 目前不可用。请稍后再试。",
"description": "Transak unavailable error message"
}
}
1 change: 1 addition & 0 deletions assets/ecosystem/aolink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ecosystem/arswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ecosystem/autonomous-dca-agent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ecosystem/betteridea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/ecosystem/dexi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions assets/ecosystem/liquidops.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ecosystem/llama.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"plimit-lit": "^3.0.1",
"pretty-bytes": "^6.0.0",
"qrcode.react": "^3.1.0",
"qrloop": "^1.4.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-fast-marquee": "^1.3.5",
Expand Down
5 changes: 4 additions & 1 deletion src/api/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import signDataItemModule from "./modules/sign_data_item";
import signDataItem from "./modules/sign_data_item/sign_data_item.background";
import subscriptionModule from "./modules/subscription";
import subscription from "./modules/subscription/subscription.background";
import userTokensModule from "./modules/user_tokens";
import userTokens from "./modules/user_tokens/user_tokens.background";

/** Background modules */
const modules: BackgroundModule<any>[] = [
Expand All @@ -63,7 +65,8 @@ const modules: BackgroundModule<any>[] = [
{ ...privateHashModule, function: privateHash },
{ ...verifyMessageModule, function: verifyMessage },
{ ...signDataItemModule, function: signDataItem },
{ ...subscriptionModule, function: subscription }
{ ...subscriptionModule, function: subscription },
{ ...userTokensModule, function: userTokens }
];

export default modules;
Expand Down
5 changes: 4 additions & 1 deletion src/api/foreground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import signDataItemModule from "./modules/sign_data_item";
import signDataItem, {
finalizer as signDataItemFinalizer
} from "./modules/sign_data_item/sign_data_item.foreground";
import userTokensModule from "./modules/user_tokens";
import userTokens from "./modules/user_tokens/user_tokens.foreground";

/** Foreground modules */
const modules: ForegroundModule[] = [
Expand Down Expand Up @@ -93,7 +95,8 @@ const modules: ForegroundModule[] = [
function: signDataItem,
finalizer: signDataItemFinalizer
},
{ ...subscriptionModule, function: subscription }
{ ...subscriptionModule, function: subscription },
{ ...userTokensModule, function: userTokens }
];

export default modules;
Expand Down
11 changes: 11 additions & 0 deletions src/api/modules/user_tokens/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { PermissionType } from "~applications/permissions";
import type { ModuleProperties } from "~api/module";

const permissions: PermissionType[] = ["ACCESS_TOKENS"];

const userTokensModule: ModuleProperties = {
functionName: "userTokens",
permissions
};

export default userTokensModule;
50 changes: 50 additions & 0 deletions src/api/modules/user_tokens/user_tokens.background.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { ModuleFunction } from "~api/background";
import { ExtensionStorage } from "~utils/storage";
import {
getAoTokenBalance,
getNativeTokenBalance,
type TokenInfo,
type TokenInfoWithBalance
} from "~tokens/aoTokens/ao";
import { AO_NATIVE_TOKEN } from "~utils/ao_import";

const background: ModuleFunction<TokenInfoWithBalance[] | TokenInfo[]> = async (
_,
options?: { fetchBalance?: boolean }
) => {
const address = await ExtensionStorage.get("active_address");
const tokens = (await ExtensionStorage.get<TokenInfo[]>("ao_tokens")) || [];

if (!options?.fetchBalance) {
return tokens;
}

const enrichedTokens: TokenInfoWithBalance[] = await Promise.all(
tokens.map(async (token) => {
let balance: string | null = null;

try {
if (token.processId === AO_NATIVE_TOKEN) {
balance = await getNativeTokenBalance(address);
} else {
const balanceResult = await getAoTokenBalance(
address,
token.processId
);
balance = balanceResult.toString();
}
} catch (error) {
console.error(
`Error fetching balance for token ${token.Name} (${token.processId}):`,
error
);
}

return { ...token, balance };
})
);

return enrichedTokens;
};

export default background;
6 changes: 6 additions & 0 deletions src/api/modules/user_tokens/user_tokens.foreground.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { ModuleFunction } from "~api/module";

// no need to transform anything in the foreground
const foreground: ModuleFunction<void> = () => {};

export default foreground;
6 changes: 4 additions & 2 deletions src/applications/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type PermissionType =
| "DECRYPT"
| "SIGNATURE"
| "ACCESS_ARWEAVE_CONFIG"
| "DISPATCH";
| "DISPATCH"
| "ACCESS_TOKENS";

/**
* All permissions with their descriptions
Expand All @@ -24,7 +25,8 @@ export const permissionData: Record<PermissionType, string> = {
DECRYPT: "permissionDescriptionDecrypt",
SIGNATURE: "permissionDescriptionSignature",
ACCESS_ARWEAVE_CONFIG: "permissionDescriptionArweaveConfig",
DISPATCH: "permissionDescriptionDispatch"
DISPATCH: "permissionDescriptionDispatch",
ACCESS_TOKENS: "permissionAccessTokens"
};

/**
Expand Down
50 changes: 29 additions & 21 deletions src/routes/popup/explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,29 @@ export default function Explore() {
<div>
{filteredApps.map((app, index) => (
<AppWrapper key={index}>
<LogoWrapper>
<AppShortcut
bgColor={
theme === "light"
? app.assets?.lightBackground
: app.assets?.darkBackground
}
onClick={() => {
browser.tabs.create({ url: app.links.website });
}}
>
<Logo src={app.assets.logo} />
</AppShortcut>
</LogoWrapper>
<Description>
<Title>
<AppTitle>{app.name}</AppTitle>
<Pill>{app.category}</Pill>
</Title>
<AppDescription>{app.description}</AppDescription>
</Description>
<LogoDescriptionWrapper>
<LogoWrapper>
<AppShortcut
bgColor={
theme === "light"
? app.assets?.lightBackground
: app.assets?.darkBackground
}
onClick={() => {
browser.tabs.create({ url: app.links.website });
}}
>
<Logo src={app.assets.logo} />
</AppShortcut>
</LogoWrapper>
<Description>
<Title>
<AppTitle>{app.name}</AppTitle>
<Pill>{app.category}</Pill>
</Title>
<AppDescription>{app.description}</AppDescription>
</Description>
</LogoDescriptionWrapper>
<IconWrapper>
<ShareIcon
style={{ cursor: "pointer" }}
Expand Down Expand Up @@ -152,6 +154,12 @@ const AppWrapper = styled.div`
padding: 10px;
gap: 12px;
display: flex;
justify-content: space-between;
`;

const LogoDescriptionWrapper = styled.div`
gap: 12px;
display: flex;
`;

const AppShortcut = styled(AppIcon)<{ bgColor?: string }>`
Expand Down
Loading

0 comments on commit ed52db2

Please sign in to comment.