Skip to content

Commit

Permalink
Merge pull request #352 from arconnectio/development
Browse files Browse the repository at this point in the history
ArConnect BETA 1.12.1
  • Loading branch information
nicholaswma committed May 29, 2024
2 parents b6bfea4 + 261ff96 commit e699209
Show file tree
Hide file tree
Showing 29 changed files with 888 additions and 231 deletions.
12 changes: 12 additions & 0 deletions assets/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1762,10 +1762,18 @@
"message": "Token Already Added",
"description": "token already imported"
},
"token_already_removed": {
"message": "Token Already Removed",
"description": "token already removed"
},
"token_imported": {
"message": "Token Succesfully Added",
"description": "token added"
},
"token_removed": {
"message": "Token Succesfully Removed",
"description": "token removed"
},
"subscription_allowance": {
"message": "Subscription Allowance",
"description": "subscription settings title"
Expand Down Expand Up @@ -1797,5 +1805,9 @@
"subscription_delete_error": {
"message": "Subscription Deletion Error",
"description": "There was an error deleting the subscription. Please try again."
},
"subscription_add_failure": {
"message": "Failed to add subscription",
"description": "Failed to add subscription error message"
}
}
3 changes: 3 additions & 0 deletions src/api/modules/dispatch/allowance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import type { JWKInterface } from "warp-contracts";
import { allowanceAuth } from "../sign/allowance";
import { signAuth } from "../sign/sign_auth";
import Arweave from "arweave";
import type { DataItem } from "arbundles";
import type Transaction from "arweave/web/lib/transaction";

/**
* Ensure allowance for dispatch
*/
export async function ensureAllowanceDispatch(
dataEntry: DataItem | Transaction,
appData: ModuleAppData,
allowance: Allowance,
keyfile: JWKInterface,
Expand Down
2 changes: 2 additions & 0 deletions src/api/modules/dispatch/dispatch.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const background: ModuleFunction<ReturnType> = async (
const price = await getPrice(dataEntry, await app.getBundler());

await ensureAllowanceDispatch(
dataEntry,
appData,
allowance,
decryptedWallet.keyfile,
Expand Down Expand Up @@ -127,6 +128,7 @@ const background: ModuleFunction<ReturnType> = async (

// ensure allowance
await ensureAllowanceDispatch(
transaction,
appData,
allowance,
decryptedWallet.keyfile,
Expand Down
24 changes: 21 additions & 3 deletions src/api/modules/sign/transaction_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ export function deconstructTransaction(transaction: Transaction) {
};
}

/**
* Get Data size from transaction chunks
*
* @param chunks Chunks to reconstruct the transaction with
*
* @returns Data size
*/
export function getDataSize(chunks: Chunk[]): number {
let dataSize = 0;

for (const chunk of chunks) {
if (chunk.type === "data") {
dataSize += chunk.value?.length || 0;
}
}

return dataSize;
}

/**
* Construct a transaction from a split transaction
* and it's chunks
Expand All @@ -93,9 +112,8 @@ export function constructTransaction(
chunks.sort((a, b) => a.index - b.index);

// create a Uint8Array to reconstruct the data to
const reconstructedData = new Uint8Array(
parseFloat(splitTransaction.data_size ?? "0")
);
const dataSize = getDataSize(chunks);
const reconstructedData = new Uint8Array(dataSize);

// previous buffer length in bytes (gets updated
// in the loop below)
Expand Down
6 changes: 5 additions & 1 deletion src/api/modules/subscription/subscription.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type SubscriptionData
} from "~subscriptions/subscription";

const background: ModuleFunction<void> = async (
const background: ModuleFunction<SubscriptionData> = async (
appData,
subscriptionData: SubscriptionData
) => {
Expand All @@ -22,6 +22,10 @@ const background: ModuleFunction<void> = async (
isSubscriptionType(subscriptionData);
const address = await getActiveAddress();

if (address === subscriptionData.arweaveAccountAddress) {
throw new Error("Wallet cannot subscribe to its own address");
}

// if is hardware wallet
const decryptedWallet = await getActiveKeyfile();
isLocalWallet(decryptedWallet);
Expand Down
9 changes: 8 additions & 1 deletion src/components/dashboard/Tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ export default function Tokens() {
setLocation("/tokens/new");
};

const handleTokenClick = (token) => {
const handleTokenClick = (token: {
id: any;
defaultLogo?: string;
balance?: number;
ticker?: string;
type?: TokenType;
name?: string;
}) => {
setLocation(`/tokens/${token.id}`);
};

Expand Down
9 changes: 7 additions & 2 deletions src/components/dashboard/list/TokenListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import styled from "styled-components";
import { useGateway } from "~gateways/wayfinder";
import { concatGatewayURL } from "~gateways/utils";
import aoLogo from "url:/assets/ecosystem/ao-logo.svg";
import arLogoDark from "url:/assets/ar/logo_dark.png";
import { getUserAvatar } from "~lib/avatar";

export default function TokenListItem({ token, active, ao, onClick }: Props) {
Expand Down Expand Up @@ -43,8 +44,12 @@ export default function TokenListItem({ token, active, ao, onClick }: Props) {
);
}
if (ao) {
const logo = await getUserAvatar(token.defaultLogo);
return setImage(logo);
if (token.defaultLogo) {
const logo = await getUserAvatar(token.defaultLogo);
return setImage(logo);
} else {
return setImage(arLogoDark);
}
}

// query community logo using Warp DRE
Expand Down
11 changes: 7 additions & 4 deletions src/components/hardware/AnimatedQRScanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Loading, Spacer, Text, useToasts } from "@arconnect/components";
import { AnimatedQRScanner as Scanner } from "@arconnect/keystone-sdk";
import { type ComponentProps, useEffect, useState } from "react";
import { type ComponentProps, useEffect, useMemo, useState } from "react";
import { CameraOffIcon } from "@iconicicons/react";
import browser from "webextension-polyfill";
import styled from "styled-components";
Expand All @@ -12,6 +12,11 @@ export default function AnimatedQRScanner({ className, ...props }: Props) {
// camera allowed
const [cameraAllowed, setCameraAllowed] = useState(true);

const isWebWorkerAvailable = useMemo(
() => typeof Worker !== "undefined",
[Worker]
);

useEffect(() => {
(async () => {
// get if camera permission is granted
Expand Down Expand Up @@ -63,9 +68,7 @@ export default function AnimatedQRScanner({ className, ...props }: Props) {
</>
)}
</LoadingSection>
<Wrapper>
<Scanner {...props} />
</Wrapper>
<Wrapper>{isWebWorkerAvailable && <Scanner {...props} />}</Wrapper>
</Outline>
);
}
Expand Down
4 changes: 0 additions & 4 deletions src/components/hardware/KeystoneButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
type KeystoneAccount
} from "~wallets/hardware/keystone";
import { addHardwareWallet } from "~wallets/hardware";
import { usePatchWorker } from "~wallets/hardware/hooks";
import { useScanner } from "@arconnect/keystone-sdk";
import {
Alert,
Expand Down Expand Up @@ -83,9 +82,6 @@ export default function KeystoneButton({ onSuccess }: Props) {
cancel();
});

// Patch Worker
usePatchWorker();

return (
<>
<ButtonV2
Expand Down
Loading

0 comments on commit e699209

Please sign in to comment.