Skip to content

Commit

Permalink
Release v5.3.21
Browse files Browse the repository at this point in the history
  • Loading branch information
gergold committed May 4, 2023
1 parent e2f14bf commit 374ba0f
Show file tree
Hide file tree
Showing 32 changed files with 336 additions and 83 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
branches:
- develop
pull_request:
branches:
- main
- develop

jobs:
setup:
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "5.3.20",
"version": "5.3.21",
"npmClient": "yarn",
"useWorkspaces": true
}
6 changes: 3 additions & 3 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent-x/dapp",
"version": "5.3.20",
"version": "5.3.21",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -10,8 +10,8 @@
"lint": "next lint"
},
"dependencies": {
"@argent/get-starknet": "^5.3.20",
"@argent/x-sessions": "^5.3.20",
"@argent/get-starknet": "^5.3.21",
"@argent/x-sessions": "^5.3.21",
"ethers": "^5.5.1",
"next": "^13.0.0",
"react": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/manifest/v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/chrome-manifest.json",
"name": "Argent X",
"description": "The security of Ethereum with the scale of StarkNet",
"version": "5.3.20",
"version": "5.3.21",
"manifest_version": 2,
"browser_action": {
"default_icon": {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/manifest/v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/chrome-manifest.json",
"name": "Argent X",
"description": "The security of Ethereum with the scale of StarkNet",
"version": "5.3.20",
"version": "5.3.21",
"manifest_version": 3,
"action": {
"default_icon": {
Expand Down
18 changes: 9 additions & 9 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent-x/extension",
"version": "5.3.20",
"version": "5.3.21",
"main": "index.js",
"license": "MIT",
"devDependencies": {
Expand Down Expand Up @@ -74,13 +74,13 @@
"push-release-branch": "git push --set-upstream origin release/v$npm_package_version --follow-tags"
},
"dependencies": {
"@argent/guardian": "^5.3.20",
"@argent/stack-router": "^5.3.20",
"@argent/ui": "^5.3.20",
"@argent/x-multicall": "^5.3.20",
"@argent/x-sessions": "^5.3.20",
"@argent/x-swap": "^5.3.20",
"@argent/x-window": "^5.3.20",
"@argent/guardian": "^5.3.21",
"@argent/stack-router": "^5.3.21",
"@argent/ui": "^5.3.21",
"@argent/x-multicall": "^5.3.21",
"@argent/x-sessions": "^5.3.21",
"@argent/x-swap": "^5.3.21",
"@argent/x-window": "^5.3.21",
"@chakra-ui/icons": "^2.0.15",
"@chakra-ui/react": "2.5.1",
"@extend-chrome/messages": "^1.2.2",
Expand Down Expand Up @@ -118,7 +118,7 @@
"starknet": "^4.21.0",
"starknet3": "npm:[email protected]",
"starknet4": "npm:[email protected]",
"starknet5": "npm:starknet@5.0.0-beta.3",
"starknet5": "npm:starknet@5.7.0",
"styled-components": "^5.3.5",
"styled-normalize": "^8.0.7",
"swr": "^1.3.0",
Expand Down
36 changes: 27 additions & 9 deletions packages/extension/src/background/transactions/sources/voyager.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
import join from "url-join"
import { Status } from "starknet"

import { ARGENT_EXPLORER_BASE_URL } from "../../../shared/api/constants"
import { argentApiNetworkForNetwork } from "../../../shared/api/fetcher"
import { Network } from "../../../shared/network"
import { Transaction, compareTransactions } from "../../../shared/transactions"
import { urlWithQuery } from "../../../shared/utils/url"
import { WalletAccount } from "../../../shared/wallet.model"
import { stripAddressZeroPadding } from "../../../ui/features/accounts/accounts.service"
import { fetchWithTimeout } from "../../utils/fetchWithTimeout"
import { mapVoyagerTransactionToTransaction } from "../transformers"

export interface VoyagerTransaction {
blockId: string
entry_point_type: string | null
globalIndex?: number
blockNumber: number
hash: string
index: number
signature: string[] | null
timestamp: number
to: string
type: string
status: Status
}

export const fetchVoyagerTransactions = async (
address: string,
network: Network,
): Promise<VoyagerTransaction[]> => {
const { explorerUrl } = network
if (!explorerUrl) {
const explorerUrl = ARGENT_EXPLORER_BASE_URL
const apiNetwork = argentApiNetworkForNetwork(network.id)
if (!explorerUrl || !apiNetwork) {
return []
}
const response = await fetchWithTimeout(
join(explorerUrl, `api/txns?to=${address}`),

const url = urlWithQuery(
[
explorerUrl,
"accounts",
apiNetwork,
stripAddressZeroPadding(address),
"voyager",
],
{
page: 0,
size: 100,
direction: "DESC",
withTransfers: true,
},
)

const response = await fetchWithTimeout(url)
const { items } = await response.json()
return items
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export const mapVoyagerTransactionToTransaction = (
hash: transaction.hash,
account,
meta,
status: "ACCEPTED_ON_L2",
status: transaction.status,
timestamp: transaction.timestamp,
})
20 changes: 20 additions & 0 deletions packages/extension/src/shared/network/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { constants } from "starknet5"

import { isEqualAddress } from "../../ui/services/addresses"
import { ArgentAccountType } from "../wallet.model"
import { Network } from "./type"
Expand Down Expand Up @@ -38,3 +40,21 @@ export function mapImplementationToArgentAccountType(
}
return "argent"
}

export function getChainIdFromNetworkId(
networkId: string,
): constants.StarknetChainId {
switch (networkId) {
case "mainnet-alpha":
return constants.StarknetChainId.SN_MAIN

case "goerli-alpha":
return constants.StarknetChainId.SN_GOERLI

case "goerli-alpha-2":
return constants.StarknetChainId.SN_GOERLI2

default:
throw new Error(`Unknown networkId: ${networkId}`)
}
}
50 changes: 44 additions & 6 deletions packages/extension/src/ui/features/accountNfts/SendNftScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { CloseIconAlt } from "../../components/Icons/CloseIconAlt"
import { AddIcon } from "../../components/Icons/MuiIcons"
import { StyledControlledTextArea } from "../../components/InputText"
import Row, { RowBetween, RowCentered } from "../../components/Row"
import { Spinner } from "../../components/Spinner"
import { routes } from "../../routes"
import { makeClickable } from "../../services/a11y"
import { useAddressBook } from "../../services/addressBook"
import {
addressSchema,
formatTruncatedAddress,
isEqualAddress,
isStarknetId,
isValidAddress,
normalizeAddress,
} from "../../services/addresses"
Expand All @@ -30,6 +32,7 @@ import {
sendTransaction,
} from "../../services/transactions"
import { useOnClickOutside } from "../../services/useOnClickOutside"
import { getAddressFromStarkName } from "../../services/useStarknetId"
import { H3, H5 } from "../../theme/Typography"
import { Account } from "../accounts/Account"
import {
Expand Down Expand Up @@ -103,11 +106,13 @@ export const SendNftScreen: FC = () => {
const resolver = useYupValidationResolver(SendNftSchema)

const { id: currentNetworkId } = useCurrentNetwork()
const [addressBookRecipient, setAddressBookRecipient] =
useState<Account | AddressBookContact>()
const [addressBookRecipient, setAddressBookRecipient] = useState<
Account | AddressBookContact
>()

const { accountNames } = useAccountMetadata()
const [bottomSheetOpen, setBottomSheetOpen] = useState(false)
const [starknetIdLoading, setStarknetIdLoading] = useState(false)

const accountName = useMemo(
() =>
Expand All @@ -126,6 +131,8 @@ export const SendNftScreen: FC = () => {
control,
setValue,
watch,
clearErrors,
trigger,
} = useForm<SendNftInput>({
defaultValues: {
recipient: "",
Expand All @@ -141,6 +148,8 @@ export const SendNftScreen: FC = () => {
[],
)

const validateStarknetId = useCallback((id: string) => isStarknetId(id), [])

const validRecipientAddress =
inputRecipient && !getFieldState("recipient").error

Expand All @@ -166,7 +175,8 @@ export const SendNftScreen: FC = () => {
return <Navigate to={routes.accounts()} />
}

const disableSubmit = isSubmitting || (submitCount > 0 && !isDirty)
const disableSubmit =
isSubmitting || (submitCount > 0 && !isDirty) || starknetIdLoading

const onSubmit = async ({ recipient }: SendNftInput) => {
if (nft.contract.schema === "ERC721") {
Expand Down Expand Up @@ -209,6 +219,7 @@ export const SendNftScreen: FC = () => {
const resetAddressBookRecipient = () => {
setAddressBookRecipient(undefined)
setValue("recipient", "")
clearErrors("recipient")
}

const handleSaveAddress = (savedContact: AddressBookContact) => {
Expand All @@ -217,6 +228,28 @@ export const SendNftScreen: FC = () => {
setBottomSheetOpen(false)
}

const handleStarknetIdNameInput = async (starkName: string) => {
setStarknetIdLoading(true)

const starkNameAddress = await getAddressFromStarkName(
starkName,
currentNetworkId,
)

setStarknetIdLoading(false)

if (starkNameAddress && isValidAddress(starkNameAddress)) {
handleAddressSelect({
id: `${starkName}-${starkNameAddress}`,
name: starkName,
address: starkNameAddress,
networkId: currentNetworkId,
})
}

await trigger("recipient")
}

return (
<>
<AddContactBottomSheet
Expand Down Expand Up @@ -291,8 +324,11 @@ export const SendNftScreen: FC = () => {
paddingRight: "50px",
borderRadius: addressBookOpen ? "8px 8px 0 0" : "8px",
}}
onlyAddressHex
onChange={(e: any) => {
onChange={async (e: any) => {
if (validateStarknetId(e.target.value)) {
return await handleStarknetIdNameInput(e.target.value)
}

if (validateStarknetAddress(e.target.value)) {
const account = addressBook.contacts.find((c) =>
isEqualAddress(c.address, e.target.value),
Expand All @@ -303,7 +339,9 @@ export const SendNftScreen: FC = () => {
>
<>
<InputGroupAfter>
{validRecipientAddress ? (
{starknetIdLoading ? (
<Spinner size={18} />
) : validRecipientAddress ? (
<CloseIconAlt
{...makeClickable(resetAddressBookRecipient)}
style={{ cursor: "pointer" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const AspectNftSchema = z.object({
.transform((s) => s ?? undefined),
animation_uri: z.string().nullable().optional(),
external_uri: z.string().nullable().optional(),
owner: AspectNftOwnerSchema.optional(),
owner: AspectNftOwnerSchema.nullable().optional(),
contract: AspectNftContractSchema,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { FC } from "react"
import { prettifyCurrencyValue } from "../../../shared/token/price"
import { BaseWalletAccount } from "../../../shared/wallet.model"
import { AddressCopyButton } from "../../components/AddressCopyButton"
import { useStarknetId } from "../../services/useStarknetId"
import { AccountStatus } from "../accounts/accounts.service"
import { StarknetIdCopyButton } from "./StarknetIdCopyButton"
import { useSumTokenBalancesToCurrencyValue } from "./tokenPriceHooks"
import { useTokensWithBalance } from "./tokens.state"

Expand All @@ -28,14 +30,23 @@ export const AccountTokensHeader: FC<AccountSubheaderProps> = ({
const sumCurrencyValue = useSumTokenBalancesToCurrencyValue(tokenDetails)
const accountAddress = account.address

const { data: starknetId } = useStarknetId(account)

return (
<VStack spacing={0.5}>
{sumCurrencyValue !== undefined ? (
<H2>{prettifyCurrencyValue(sumCurrencyValue)}</H2>
) : (
<H2>{accountName}</H2>
)}
<AddressCopyButton address={accountAddress} />
{starknetId ? (
<StarknetIdCopyButton
starknetId={starknetId}
address={accountAddress}
/>
) : (
<AddressCopyButton address={accountAddress} />
)}
{status.code === "ERROR" && (
<VStack spacing={2} pt={2}>
<FieldError>{status.text}</FieldError>
Expand Down
Loading

0 comments on commit 374ba0f

Please sign in to comment.