Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArConnect 1.10.0 #312

Merged
merged 33 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
02872b6
fix: abbreviate large numbers
elehma4 Apr 10, 2024
b5e0928
ci: add tooltip to token balances
elehma4 Apr 12, 2024
1e54206
Merge branch 'development' into arc-295-shorten-large-numbers
elehma4 Apr 12, 2024
e22ac56
ci: is million
elehma4 Apr 15, 2024
9933765
fix: tooltip position
elehma4 Apr 16, 2024
098eb51
Merge pull request #295 from arconnectio/arc-295-shorten-large-numbers
elehma4 Apr 16, 2024
7449ae8
fix: sign allowance if 0
elehma4 Apr 16, 2024
815a932
refactor: integrated ao-tokens
nicholaswma Apr 16, 2024
63cdd18
feat: support sending to ANS users
elehma4 Apr 17, 2024
c673a29
ci: ans support
elehma4 Apr 18, 2024
02e422a
Merge pull request #303 from arconnectio/arc-312/333/ao-tokens-integr…
nicholaswma Apr 18, 2024
d6c8d7f
feat: started popup for sign data item involving transfers
nicholaswma Apr 18, 2024
f2053ce
fix: added password for sign data item
nicholaswma Apr 18, 2024
add6fb5
Merge branch 'development' into arc-335-support-sending-to-ans-addresses
elehma4 Apr 18, 2024
611b8a6
Merge pull request #304 from arconnectio/arc-335-support-sending-to-a…
elehma4 Apr 18, 2024
69eb2d5
fix: added ticker, denom, and logo
nicholaswma Apr 18, 2024
4bf03b4
fix: reverted type change
nicholaswma Apr 18, 2024
f04eccd
Merge pull request #305 from arconnectio/arc-336/popup-signdataitem
nicholaswma Apr 18, 2024
e4b1a6f
fix: use effect
elehma4 Apr 18, 2024
434eb21
fix: sign allowance 0
elehma4 Apr 18, 2024
775efd9
Merge branch 'development' into arc-334-send-allowance-not-triggering…
elehma4 Apr 18, 2024
9b3e5d7
Merge pull request #302 from arconnectio/arc-334-send-allowance-not-t…
elehma4 Apr 19, 2024
7db3718
Merge pull request #306 from arconnectio/development
elehma4 Apr 19, 2024
a6b74b1
chore: update version
elehma4 Apr 19, 2024
6c85438
Merge pull request #307 from arconnectio/beta/1.10.0-1
elehma4 Apr 19, 2024
9475a81
fix: updated process to direct to target in signdataitem
nicholaswma Apr 23, 2024
23a16a3
Merge pull request #308 from arconnectio/fix/sign-data-item
nicholaswma Apr 23, 2024
6c947e9
Merge pull request #309 from arconnectio/development
nicholaswma Apr 23, 2024
6f6eecd
chore: version bump for beta
nicholaswma Apr 23, 2024
694f6aa
fix: removed to locale string
nicholaswma Apr 24, 2024
068d08f
Merge pull request #310 from arconnectio/fix/ao-balance-type
nicholaswma Apr 24, 2024
fdb1970
Merge pull request #311 from arconnectio/development
nicholaswma Apr 24, 2024
533548f
chore: update version for beta
nicholaswma Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions assets/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1177,10 +1177,24 @@
"message": "Click to view your last signed transaction",
"description": "View last tx prompt content"
},
"sign_item": {
"message": "Sign Item",
"description": "Sign message popup title"
},
"titles_signature": {
"message": "Sign message",
"description": "Sign message popup title"
},
"sign_data_description": {
"message": "$APPNAME$ wants to sign a transaction. Review the details below.",
"description": "Desription for signing an item containing a transfer",
"placeholders": {
"appname": {
"content": "$1",
"example": "permafacts.arweave.dev"
}
}
},
"signature_description": {
"message": "$APPNAME$ wants to sign a message. Review the message below.",
"description": "App signature request for data that cannot be decoded to string",
Expand Down Expand Up @@ -1312,7 +1326,7 @@
"description": "Label for the address input"
},
"transaction_send_address_input_placeholder": {
"message": "Address or ArNS name...",
"message": "Address, ANS or ArNS...",
"description": "Placeholder for the address input"
},
"transaction_send_scan_address": {
Expand Down Expand Up @@ -1656,10 +1670,14 @@
"message": "Your Contacts",
"desription": "Your Contacts title in Send Modal"
},
"check_address" : {
"check_address": {
"message": "Please check the recipient address",
"description": "Error message for invalid address/ArNS"
},
"incorrect_address": {
"message": "Incorrect recipient address",
"description": "Error message for invalid ANS"
},
"arns_added": {
"message": " ar://$ADDRESS$ added",
"description": "ArNS recipient added",
Expand All @@ -1670,6 +1688,16 @@
}
}
},
"ans_added": {
"message": "$ADDRESS$ added",
"description": "ANS recipient added",
"placeholders": {
"address": {
"content": "$1",
"example": "Address"
}
}
},
"setting_ao_support": {
"message": "ao support",
"description": "ao support settings title"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arconnect",
"displayName": "ArConnect",
"version": "1.9.0",
"version": "1.10.2",
"description": "__MSG_extensionDescription__",
"author": "th8ta",
"packageManager": "yarn@1.22.18",
Expand Down Expand Up @@ -59,6 +59,7 @@
"@plasmohq/storage": "^1.7.2",
"@segment/analytics-next": "^1.53.2",
"@untitled-ui/icons-react": "^0.1.1",
"ao-tokens": "^0.0.3",
"ar-gql": "^0.0.6",
"arbundles": "^0.9.5",
"arweave": "^1.13.0",
Expand Down
3 changes: 2 additions & 1 deletion src/api/modules/connect/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export type AuthType =
| "token"
| "sign"
| "signMessage"
| "signature";
| "signature"
| "signDataItem";

export interface AuthData {
// type of auth to request from the user
Expand Down
20 changes: 20 additions & 0 deletions src/api/modules/sign_data_item/sign_data_item.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getActiveKeyfile } from "~wallets";
import browser from "webextension-polyfill";
import { signAuth } from "../sign/sign_auth";
import Arweave from "arweave";
import authenticate from "../connect/auth";

const background: ModuleFunction<number[]> = async (
appData,
Expand All @@ -25,6 +26,25 @@ const background: ModuleFunction<number[]> = async (
throw new Error(err);
}

if (
dataItem.tags.some(
(tag) => tag.name === "Action" && tag.value === "Transfer"
) &&
dataItem.tags.some(
(tag) => tag.name === "Data-Protocol" && tag.value === "ao"
)
) {
try {
await authenticate({
type: "signDataItem",
data: dataItem,
appData
});
} catch {
throw new Error("User rejected the sign data item request");
}
}

// grab the user's keyfile
const decryptedWallet = await getActiveKeyfile().catch((e) => {
isNotCancelError(e);
Expand Down
22 changes: 21 additions & 1 deletion src/components/Recipient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { searchArNSName } from "~lib/arns";
import { useToasts } from "@arconnect/components";
import { formatAddress, isAddressFormat } from "~utils/format";
import { ExtensionStorage } from "~utils/storage";
import { getAnsProfileByLabel, isANS } from "~lib/ans";

export type Contact = {
name: string;
Expand Down Expand Up @@ -80,6 +81,25 @@ export default function Recipient({ onClick, onClose }: RecipientProps) {
return;
} else {
let search = targetInput.state;
const ANS = isANS(search);
if (ANS) {
const result = await getAnsProfileByLabel(search.slice(0, -3));
if (!result) {
setToast({
type: "error",
content: browser.i18n.getMessage("incorrect_address"),
duration: 2400
});
}
onClick({ address: result.user });
onClose();
setToast({
type: "success",
content: browser.i18n.getMessage("ans_added", [search]),
duration: 2400
});
return;
}
if (targetInput.state.startsWith("ar://"))
search = targetInput.state.substring(5);
const result = await searchArNSName(search);
Expand Down Expand Up @@ -146,7 +166,7 @@ export default function Recipient({ onClick, onClose }: RecipientProps) {
}}
/>
<ButtonV2
style={{ borderRadius: "10px", width: "56px", padding: 0 }}
style={{ borderRadius: "10px", width: "30px", padding: 0 }}
onClick={() => {
submit();
}}
Expand Down
6 changes: 4 additions & 2 deletions src/components/dashboard/subsettings/AddToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import browser from "webextension-polyfill";
import { useEffect, useState } from "react";
import { useAo, type TokenInfo, useAoTokens } from "~tokens/aoTokens/ao";
import { getTokenInfo } from "~tokens/aoTokens/router";
import { Token } from "ao-tokens";
import styled from "styled-components";
import { isAddress } from "~utils/assertions";
import { addToken, getAoTokens, getDreForToken, useTokens } from "~tokens";
Expand Down Expand Up @@ -83,7 +83,9 @@ export default function AddToken() {
//TODO double check
isAddress(targetInput.state);
if (type === "ao") {
const tokenInfo = await getTokenInfo(targetInput.state, ao);
const token = (await Token(targetInput.state)).info;
const denomination = Number(token.Denomination.toString());
const tokenInfo: TokenInfo = { ...token, Denomination: denomination };
setToken(tokenInfo);
setLoading(false);
} else {
Expand Down
37 changes: 28 additions & 9 deletions src/components/popup/Token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { hoverEffect, useTheme } from "~utils/theme";
import { loadTokenLogo, type Token } from "~tokens/token";
import { useStorage } from "@plasmohq/storage/hook";
import { ExtensionStorage } from "~utils/storage";
import { Text } from "@arconnect/components";
import { Text, TooltipV2 } from "@arconnect/components";
import { getArPrice } from "~lib/coingecko";
import { usePrice } from "~lib/redstone";
import arLogoLight from "url:/assets/ar/logo_light.png";
Expand All @@ -22,8 +22,11 @@ import { defaultGateway } from "~gateways/gateway";
import { useGateway } from "~gateways/wayfinder";
import aoLogo from "url:/assets/ecosystem/ao-logo.svg";
import { getUserAvatar } from "~lib/avatar";
import { abbreviateNumber } from "~utils/format";

export default function Token({ onClick, ...props }: Props) {
const [totalBalance, setTotalBalance] = useState("");
const [isMillion, setIsMillion] = useState(false);
// display theme
const theme = useTheme();

Expand All @@ -38,17 +41,20 @@ export default function Token({ onClick, ...props }: Props) {
[props]
);

const balance = useMemo(
() => formatTokenBalance(fractBalance),
[fractBalance]
);
const balance = useMemo(() => {
const formattedBalance = formatTokenBalance(fractBalance);
setTotalBalance(formattedBalance);
const numBalance = parseFloat(formattedBalance.replace(/,/g, ""));
setIsMillion(numBalance >= 1_000_000);
return abbreviateNumber(numBalance);
}, [fractBalance]);

// token price
const { price, currency } = usePrice(props.ticker);

// fiat balance
const fiatBalance = useMemo(() => {
if (!price) return "--";
if (!price) return <div />;

const estimate = fractBalance * price;

Expand Down Expand Up @@ -81,9 +87,18 @@ export default function Token({ onClick, ...props }: Props) {
{props?.ao && <Image src={aoLogo} alt="ao logo" />}
</LogoAndDetails>
<BalanceSection>
<NativeBalance>
{balance} {props.ticker}
</NativeBalance>
{isMillion ? (
<BalanceTooltip content={totalBalance} position="topEnd">
<NativeBalance style={{}}>
{props.ao ? props.balance : balance} {props.ticker}
</NativeBalance>
</BalanceTooltip>
) : (
<NativeBalance>
{props.ao ? props.balance : balance} {props.ticker}
</NativeBalance>
)}

<FiatBalance>{fiatBalance}</FiatBalance>
</BalanceSection>
</Wrapper>
Expand Down Expand Up @@ -111,6 +126,10 @@ const Wrapper = styled.div`
}
`;

const BalanceTooltip = styled(TooltipV2)`
margin-right: 1rem;
`;

const Image = styled.img`
width: 16px;
padding: 0 8px;
Expand Down
11 changes: 11 additions & 0 deletions src/lib/ans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ export async function getAnsProfileByLabel(label: string): Promise<AnsUser> {
}
}

/**
* Checks if search has .ar appended to the end
* If so, it is an ANS address and can call getAnsProfileByLabel()
* @param label string to fetch profile for
*/

export const isANS = (label: string): boolean => {
const lastThreeLetters = label.slice(-3);
return lastThreeLetters === ".ar";
};

/**
* React hook for a simple ANS profile
*
Expand Down
Loading
Loading