From dcaa6bb777cc89d12ebf5ff96e7371c2da2c5bf3 Mon Sep 17 00:00:00 2001 From: Gerald Date: Thu, 14 Dec 2023 09:53:36 +0100 Subject: [PATCH] Release @argent-x/extension@6.11.0 --- .github/workflows/pull-request.yml | 14 +- .github/workflows/release.yml | 9 +- .nvmrc | 2 +- package.json | 4 +- packages/dapp/.env.example | 2 + packages/dapp/next.config.js | 5 + packages/dapp/package.json | 14 +- packages/dapp/src/components/AddNetwork.tsx | 39 + packages/dapp/src/components/AddToken.tsx | 72 + packages/dapp/src/components/Declare.tsx | 146 ++ packages/dapp/src/components/Deploy.tsx | 71 + packages/dapp/src/components/Header.tsx | 38 + packages/dapp/src/components/InfoRow.tsx | 45 + packages/dapp/src/components/Mint.tsx | 64 + .../src/components/MintWithStarknetReact.tsx | 89 + .../src/components/OffchainSessionKeys.tsx | 54 + .../components/OffchainSessionKeysExecute.tsx | 97 + .../components/OffchainSessionKeysSign.tsx | 85 + packages/dapp/src/components/SignMessage.tsx | 92 + .../SignMessageWithStarknetReact.tsx | 132 ++ packages/dapp/src/components/TokenDapp.tsx | 599 ++---- packages/dapp/src/components/Transfer.tsx | 85 + .../components/TransferWithStarknetReact.tsx | 104 + packages/dapp/src/pages/_app.tsx | 33 +- packages/dapp/src/pages/_document.tsx | 34 + packages/dapp/src/pages/index.tsx | 152 +- packages/dapp/src/pages/starknetReactDapp.tsx | 154 ++ packages/dapp/src/services/wallet.service.ts | 66 +- packages/dapp/src/styles/Home.module.css | 102 - packages/dapp/src/styles/globals.css | 488 ----- packages/dapp/src/types/Status.ts | 1 + packages/e2e/extension/src/config.ts | 12 +- .../e2e/extension/src/languages/ILanguage.ts | 4 + .../e2e/extension/src/languages/en/index.ts | 5 + .../e2e/extension/src/page-objects/Account.ts | 71 +- .../e2e/extension/src/page-objects/Dapps.ts | 5 +- .../src/page-objects/DeveloperSettings.ts | 4 + .../src/page-objects/ExtensionPage.ts | 85 +- .../extension/src/page-objects/Navigation.ts | 14 +- .../extension/src/page-objects/Settings.ts | 16 +- packages/e2e/extension/src/specs/2FA.spec.ts | 90 + .../e2e/extension/src/specs/network.spec.ts | 16 +- .../src/specs/sendPartialFunds.spec.ts | 4 +- packages/e2e/extension/src/utils/account.ts | 53 +- packages/e2e/extension/src/utils/common.ts | 18 + packages/e2e/package.json | 4 +- packages/extension/.env.example | 1 + packages/extension/CHANGELOG.md | 26 + packages/extension/manifest/v2.json | 4 +- packages/extension/manifest/v3.json | 4 +- packages/extension/package.json | 15 +- .../__new/procedures/account/deploy.ts | 7 +- .../accountMessaging/cancelEscape.ts | 1 + .../accountMessaging/changeGuardian.ts | 19 +- .../escapeAndChangeGuardian.ts | 13 +- .../getAccountDeploymentPayload.ts | 56 + .../procedures/accountMessaging/index.ts | 2 + .../accountMessaging/triggerEscapeGuardian.ts | 1 + .../address/getAddressFromDomainName.ts | 30 + .../__new/procedures/address/index.ts | 8 + .../address/parseAddressOrDomain.ts | 30 + .../__new/procedures/tokens/index.ts | 2 + .../__new/procedures/tokens/swap.ts | 36 + .../procedures/transactionReview/getLabels.ts | 9 + .../procedures/transactionReview/index.ts | 8 + .../transactionReview/simulateAndReview.ts | 17 + .../__new/procedures/transfer/send.ts | 21 +- .../udc/declareContractProcedure.ts | 42 + .../procedures/udc/deployContractProcedure.ts | 51 + .../procedures/udc/getConstructorParams.ts | 22 +- .../background/__new/procedures/udc/index.ts | 5 +- .../extension/src/background/__new/router.ts | 16 +- .../services/activity/implementation.test.ts | 329 ++++ .../__new/services/activity/implementation.ts | 145 ++ .../__new/services/activity/index.ts | 15 + .../__new/services/activity/interface.ts | 22 + .../__new/services/activity/model.ts | 68 + .../__new/services/address/index.ts | 12 + .../__new/services/analytics/worker.ts | 16 +- .../__new/services/http/singleton.ts | 7 +- .../__new/services/multisig/implementation.ts | 169 +- .../__new/services/network/status.ts | 18 +- .../__new/services/network/worker.ts | 18 +- .../services/nft/worker/implementation.ts | 124 +- .../__new/services/nft/worker/index.ts | 13 +- .../services/transactionReview/background.ts | 333 ++++ .../__new/services/transactionReview/index.ts | 13 + .../worker/implementation.test.ts | 85 + .../worker/implementation.ts | 65 + .../transactionReview/worker/index.ts | 10 + .../transactionReview/worker/interface.ts | 3 + .../worker/schedule/decorators.test.ts | 53 +- .../services/worker/schedule/decorators.ts | 37 +- .../__new/services/worker/schedule/pipe.ts | 2 +- .../extension/src/background/__new/trpc.ts | 16 +- .../extension/src/background/accountDeploy.ts | 49 +- .../src/background/accountDeployAction.ts | 11 +- .../src/background/accountUpgrade.ts | 27 +- .../src/background/actionHandlers.ts | 146 +- .../src/background/actionMessaging.ts | 1 + .../src/background/devnet/declareAccounts.ts | 5 +- .../background/messageHandling/messages.ts | 1 - .../src/background/migrations/index.ts | 16 +- ....ts => restoreDefaultNetworksMigration.ts} | 2 +- .../migrations/wallet/testnet2Accounts.ts | 6 +- .../background/migrations/wallet/v5.8.1.ts | 2 +- .../multisig/multisigDeployAction.ts | 19 +- .../multisig/worker/implementation.ts | 8 +- packages/extension/src/background/nonce.ts | 4 +- .../transactions/service/starknet.service.ts | 1 + .../transactions/sources/onchain.ts | 43 +- .../transactions/transactionExecution.ts | 9 +- .../transactions/transactionMessaging.ts | 53 +- .../extension/src/background/udcAction.ts | 26 +- .../extension/src/background/udcMessaging.ts | 39 +- .../src/background/utils/argentMaxFee.ts | 12 - .../wallet/account/shared.service.test.ts | 7 +- .../wallet/account/shared.service.ts | 7 +- .../wallet/account/starknet.service.ts | 59 +- .../wallet/crypto/starknet.service.ts | 2 +- .../background/wallet/deployment/interface.ts | 6 + .../wallet/deployment/starknet.service.ts | 42 +- .../extension/src/background/wallet/index.ts | 13 +- .../wallet/recovery/shared.service.test.ts | 3 +- .../wallet/recovery/shared.service.ts | 2 +- .../src/background/wallet/test.utils.ts | 2 +- packages/extension/src/background/workers.ts | 2 + .../extension/src/inpage/ArgentXAccount.ts | 16 +- .../extension/src/inpage/ArgentXAccount4.ts | 16 +- .../extension/src/inpage/ArgentXProvider.ts | 21 +- .../extension/src/inpage/ArgentXProvider4.ts | 15 +- .../src/inpage/requestMessageHandlers.ts | 3 +- .../account/service/implementation.test.ts | 42 +- .../shared/account/service/implementation.ts | 101 +- .../src/shared/account/service/index.ts | 6 - .../src/shared/account/service/interface.ts | 23 +- .../account/worker/implementation.test.ts | 4 - .../shared/actionQueue/queue/queue.test.ts | 1 + .../src/shared/actionQueue/queue/queue.ts | 9 +- .../src/shared/actionQueue/schema.test.ts | 36 + .../src/shared/actionQueue/schema.ts | 10 +- .../extension/src/shared/actionQueue/types.ts | 33 +- .../extension/src/shared/activity/storage.ts | 11 + .../extension/src/shared/activity/types.ts | 9 + .../src/shared/addressBook/schema.ts | 4 +- .../extension/src/shared/api/constants.ts | 2 +- packages/extension/src/shared/api/fetcher.ts | 15 +- .../shared/chain/service/implementation.ts | 41 +- .../src/shared/debounce/chrome.test.ts | 53 + .../extension/src/shared/debounce/chrome.ts | 10 +- .../src/shared/debounce/interface.ts | 2 +- .../extension/src/shared/debounce/mock.ts | 18 +- .../src/shared/devnet/mintFeeToken.ts | 4 +- .../extension/src/shared/errors/account.ts | 1 + .../extension/src/shared/errors/activity.ts | 16 + .../extension/src/shared/errors/review.ts | 16 + .../extension/src/shared/errors/schema.ts | 17 + packages/extension/src/shared/knownDapps.ts | 2 + .../extension/src/shared/knownDapps/index.ts | 6 + .../knownDapps/worker/implementation.ts | 18 +- .../src/shared/knownDapps/worker/index.ts | 4 + .../src/shared/messages/ActionMessage.ts | 2 +- .../src/shared/messages/UdcMessage.ts | 4 +- .../src/shared/multicall/getMulticall.ts | 2 +- .../extension/src/shared/multisig/account.ts | 11 +- .../multisig/multisig.model.test.ts} | 2 +- .../src/shared/multisig/multisig.model.ts | 5 +- .../network/FallbackRpcProvider.test.ts | 200 ++ .../src/shared/network/FallbackRpcProvider.ts | 121 ++ .../extension/src/shared/network/constants.ts | 6 +- .../extension/src/shared/network/defaults.ts | 12 +- .../src/shared/network/exponentialBackoff.ts | 10 + .../extension/src/shared/network/provider.ts | 87 +- .../extension/src/shared/network/schema.ts | 149 +- .../extension/src/shared/network/store.ts | 8 +- .../extension/src/shared/network/utils.ts | 60 +- .../src/shared/nft/implementation.ts | 201 ++ packages/extension/src/shared/nft/index.ts | 27 + .../extension/src/shared/nft/interface.ts | 8 - .../src/shared/nft/test/index.test.ts | 157 ++ .../nfts => shared/nft}/test/nft.mock.ts | 0 .../extension/src/shared/nft/worker/store.ts | 9 - .../extension/src/shared/schedule/mock.ts | 94 +- .../src/shared/shield/backend/time.ts | 2 +- .../extension/src/shared/shield/jwtFetcher.ts | 2 +- .../__new/__test__/inmemoryImplementations.ts | 116 +- .../storage/__new/__test__/keyvalue.test.ts | 140 +- .../src/shared/storage/__new/keyvalue.ts | 16 +- .../src/shared/storage/__new/prune.test.ts | 126 ++ .../src/shared/storage/__new/prune.ts | 174 +- .../shared/storage/__test__/keyvalue.test.ts | 218 ++- .../extension/src/shared/storage/keyvalue.ts | 108 +- .../shared/token/__new/types/token.model.ts | 6 +- .../token/__new/worker/implementation.test.ts | 159 +- .../token/__new/worker/implementation.ts | 333 ++-- .../src/shared/token/__new/worker/index.ts | 12 +- .../__fixtures__/simulation-error.json | 147 ++ .../__fixtures__/simulation.json | 139 ++ .../src/shared/transactionReview/interface.ts | 38 + .../shared/transactionReview/schema.test.ts | 136 ++ .../src/shared/transactionReview/schema.ts | 309 +++ .../src/shared/transactionReview/store.ts | 10 + .../transactionSimulation/fees/fees.model.ts | 24 +- .../src/shared/udc/service/interface.ts | 16 +- packages/extension/src/shared/udc/type.ts | 18 + .../src/shared/utils/accountsEqual.ts | 2 +- .../extension/src/shared/utils/accountv4.ts | 14 - .../src/shared/utils/argentMaxFee.test.ts | 49 + .../src/shared/utils/argentMaxFee.ts | 41 + .../src/shared/utils/encodeChainId.test.ts | 34 + .../src/shared/utils/encodeChainId.ts | 16 + packages/extension/src/shared/utils/number.ts | 89 +- .../src/shared/utils/starknetNetwork.ts | 2 - packages/extension/src/ui/App.tsx | 15 - packages/extension/src/ui/AppRoutes.tsx | 3 +- .../src/ui/components/AddressCopyButton.tsx | 2 +- .../src/ui/components/ScreenSkeleton.tsx | 6 +- .../extension/src/ui/components/Spinner.tsx | 1 + .../accountActivity/TransactionDetail.tsx | 24 +- .../accountActivity/TransactionListItem.tsx | 4 - .../__test__/transformTransaction.test.ts | 2 +- .../accountEdit/AccountEditButtons.tsx | 5 +- .../ChangeAccountImplementationScreen.tsx | 6 +- .../AccountCollectionsContainer.tsx | 25 +- .../features/accountNfts/EmptyCollections.tsx | 6 +- .../ui/features/accountNfts/ViewOnMenu.tsx | 4 +- .../ui/features/accountNfts/useRemoteNft.ts | 2 +- .../accountPlugins.tsx/PluginAccount.ts | 17 +- .../accountTokens/AccountTokensContainer.tsx | 4 +- .../accountTokens/StarknetIdCopyButton.tsx | 2 +- .../ui/features/accountTokens/tokens.state.ts | 25 +- .../accountTokens/useMaxFeeForTransfer.ts | 19 +- .../src/ui/features/accounts/Account.ts | 4 +- .../accounts/AccountAddressListItem.tsx | 65 +- .../ui/features/accounts/AccountListItem.tsx | 4 +- .../accounts/AccountListItemShieldBadge.tsx | 1 + .../accounts/AccountListScreenContainer.tsx | 4 - .../AccountListScreenItemContainer.tsx | 4 +- .../accounts/AccountNavigationBar.tsx | 2 +- .../ui/features/accounts/AccountScreen.tsx | 14 +- .../accounts/AddNewAccountScreenContainer.tsx | 4 +- .../accounts/DeployAccountScreenContainer.tsx | 11 +- .../accounts/accountUpgradeCheck.test.ts | 5 +- .../src/ui/features/accounts/switchAccount.ts | 5 +- .../features/accounts/useAccountOrContact.ts | 16 +- .../src/ui/features/actions/ActionScreen.tsx | 17 +- .../AddNetworkScreen.test.tsx | 5 - .../AddNetworkScreen/AddNetworkScreen.tsx | 10 +- .../features/actions/ApproveDeployAccount.tsx | 90 +- .../ApproveSignatureScreenContainer.tsx | 11 +- .../DeclareContractActionScreenContainer.tsx | 2 +- .../DeployAccountActionScreenContainer.tsx | 5 +- .../DeployContractActionScreenContainer.tsx | 2 +- .../DeployMultisigActionScreenContainer.tsx | 11 +- .../src/ui/features/actions/LoadingScreen.tsx | 2 +- .../features/actions/__fixtures__/jediswap.ts | 23 - .../ui/features/actions/__fixtures__/types.ts | 1 - .../connectDapp/ConnectDappScreen.test.tsx | 6 - .../actions/connectDapp/ConnectDappScreen.tsx | 28 +- .../ConnectDappScreenContainer.tsx | 12 +- .../connectDapp/KnownDappButtonWrapper.tsx | 7 + .../connectDapp/useDappDisplayAttributes.ts | 8 +- .../feeEstimation/FeeEstimation.test.tsx | 6 +- .../actions/feeEstimation/FeeEstimation.tsx | 33 +- .../feeEstimation/FeeEstimationContainer.tsx | 2 + .../feeEstimation/feeEstimation.model.ts | 1 + .../features/actions/feeEstimation/types.ts | 1 + .../feeEstimation/ui/FeeEstimationBox.tsx | 32 +- .../feeEstimation/ui/FeeEstimationText.tsx | 2 +- .../transaction/ApproveDeployMultisig.tsx | 77 - .../ApproveTransactionScreen.test.tsx | 1 - .../ApproveTransactionScreen.tsx | 2 - .../ApproveTransactionScreenContainer.tsx | 8 - .../DappHeader/DappHeaderArgentX.tsx | 20 +- .../MultisigBanner.tsx | 4 +- .../VerifiedDappModalArgentX.tsx | 90 - .../VerifiedDappBanner/index.tsx | 38 - .../transaction/executeFromOutside/model.ts | 42 + .../executeFromOutside/utils.test.ts | 73 + .../transaction/executeFromOutside/utils.ts | 57 + .../executeFromOutside/whitelist.ts | 11 + .../useTransactionSimulatedData.ts | 3 +- .../transaction/useTransactionSimulation.ts | 9 +- .../transactionV2/AmountEditModalForm.tsx | 78 + .../FeeEstimationContainerV2.tsx | 108 ++ .../actions/transactionV2/ReviewFallback.tsx | 36 + .../SignActionScreenContainerV2.tsx | 102 + .../transactionV2/SignActionScreenV2.tsx | 56 + .../TransactionActionScreenContainerV2.tsx | 344 ++++ .../TransactionHeader/AccountDetails.tsx | 24 + .../TransactionIcon/DappIcon.tsx | 8 + .../TransactionIcon/IconWrapper.tsx | 14 + .../TransactionIcon/KnownIcon.tsx | 16 + .../TransactionIcon/UnknownDappIcon.tsx | 15 + .../TransactionIcon/index.tsx | 28 + .../TransactionHeader/TransactionTitle.tsx | 25 + .../transactionV2/TransactionHeader/index.tsx | 61 + .../transactionV2/TransactionReviewLabel.tsx | 11 + .../action/TransactionReviewAction.tsx | 68 + .../action/TransactionReviewActions.tsx | 25 + .../action/TransactionReviewSignAction.tsx | 112 ++ .../TransactionReviewProperties.tsx | 24 + .../properties/TransactionReviewProperty.tsx | 240 +++ .../TransactionReviewSimulation.tsx | 54 + .../summary/TransactionReviewSummary.tsx | 92 + .../summary/TransactionReviewSummaryStack.tsx | 15 + .../transactionV2/useMultisigActionScreen.tsx | 55 + .../transactionV2/useTransactionReviewV2.ts | 52 + .../warning/AlertFillIconWithHalo.tsx | 55 + .../transactionV2/warning/WarningBanner.tsx | 31 + .../transactionV2/warning/warningMap.ts | 118 ++ .../extension/src/ui/features/dev/DevUI.tsx | 80 +- .../src/ui/features/dev/useDevStorageUI.tsx | 83 + .../features/funding/FundingBridgeScreen.tsx | 10 +- .../features/funding/FundingOnRampOption.tsx | 4 +- .../funding/FundingProviderScreen.tsx | 6 +- .../src/ui/features/funding/FundingScreen.tsx | 8 +- .../MultisigSecondStep.tsx | 4 +- .../features/multisig/JoinMultisigScreen.tsx | 4 - .../src/ui/features/multisig/Multisig.ts | 9 +- .../ui/features/multisig/MultisigBanner.tsx | 4 +- .../features/multisig/NewMultisigScreen.tsx | 4 - .../src/ui/features/multisig/constants.ts | 9 + .../multisig/hooks/useCreateMultisigForm.ts | 5 +- .../multisig/hooks/useReplaceOwnerForm.ts | 2 +- .../src/ui/features/multisig/multisig.mock.ts | 2 +- .../NetworkSwitcher/NetworkSwitcher.test.tsx | 17 +- .../NetworkSwitcher/NetworkSwitcherButton.tsx | 11 +- .../NetworkSwitcherContainer.tsx | 37 +- .../NetworkSwitcher/NetworkSwitcherList.tsx | 17 +- .../ui/features/networks/hooks/useNetworks.ts | 19 +- .../onboarding/OnboardingFinishScreen.tsx | 6 +- .../OnboardingPasswordScreenContainer.tsx | 7 +- .../ui/features/recovery/recovery.service.ts | 6 +- .../SendAmountAndAssetNftScreenContainer.tsx | 10 +- ...SendAmountAndAssetTokenScreenContainer.tsx | 45 +- .../send/SendRecipientScreenContainer.tsx | 32 +- .../src/ui/features/send/TokenAmountInput.tsx | 2 +- .../extension/src/ui/features/send/schema.ts | 4 +- .../send/sendRecipientScreen.model.ts | 4 +- .../ui/features/send/useFilteredAccounts.ts | 4 +- .../ui/features/send/useFilteredContacts.ts | 6 +- .../send/useGetAddressFromDomainName.ts | 79 + .../send/useGetAddressFromStarknetId.ts | 73 - .../settings/AddressBookAddOrEditScreen.tsx | 14 +- .../features/settings/BetaFeatureSettings.tsx | 27 +- .../DeclareOrDeployContractSuccessScreen.tsx | 2 +- .../DeclareSmartContractForm.tsx | 13 +- .../DeploySmartContractForm.tsx | 187 +- .../DeploySmartContractParameters.tsx | 156 +- ...DeploySmartContractParametersContainer.tsx | 46 + .../deploySmartContractForm.model.ts | 3 + .../useConstructorParams.tsx | 21 + .../NetworkSettingsFormScreenContainer.tsx | 8 +- .../ui/features/settings/SettingsScreen.tsx | 4 +- .../ui/features/settings/SupportFooter.tsx | 8 +- .../shield/escape/useAccountEscape.ts | 4 +- .../extension/src/ui/features/swap/Swap.tsx | 15 +- .../src/ui/features/swap/ui/SlippageForm.tsx | 94 - .../ui/features/swap/ui/SwapPricesInfo.tsx | 35 +- .../transactionReview/signature/fixtures.ts | 204 ++ .../src/ui/services/account/clientTrpc.ts | 17 - .../src/ui/services/account/implementation.ts | 128 ++ .../src/ui/services/account/index.ts | 9 +- .../src/ui/services/account/interface.ts | 28 +- .../src/ui/services/address/client.ts | 29 + .../src/ui/services/address/index.ts | 6 + .../src/ui/services/address/interface.ts | 12 + .../src/ui/services/messaging/trpc.ts | 27 +- .../src/ui/services/nfts/implementation.ts | 253 +-- .../extension/src/ui/services/nfts/index.ts | 26 +- .../src/ui/services/nfts/interface.ts | 11 + .../src/ui/services/nfts/test/index.test.ts | 285 --- .../src/ui/services/resetAndReload.tsx | 3 + .../extension/src/ui/services/swr.service.ts | 30 +- .../src/ui/services/tokens/implementation.ts | 32 + .../src/ui/services/tokens/interface.ts | 16 +- .../ui/services/transactionReview/client.ts | 25 + .../ui/services/transactionReview/index.ts | 5 + .../extension/src/ui/services/transactions.ts | 21 +- .../extension/src/ui/services/udc.service.ts | 58 - .../src/ui/services/udc/implementation.ts | 19 +- .../src/ui/services/useStarknetId.ts | 96 +- .../__tests__/AtomFromKeyValueStore.test.tsx | 66 + .../__tests__/atomWithSubscription.test.tsx | 50 + .../implementation/atomFromKeyValueStore.ts | 15 + .../implementation/atomWithSubscription.ts | 78 +- .../src/ui/views/transactionReviews.ts | 35 + packages/extension/test/account.mock.ts | 2 +- packages/extension/test/setupTestAccount.ts | 8 +- packages/extension/test/tokenPrice.test.ts | 7 + packages/extension/test/utils/number.test.ts | 3 + packages/extension/test/wallet.test.ts | 2 +- packages/extension/test/walletAccount.mock.ts | 2 +- packages/get-starknet/package.json | 2 +- packages/guardian/package.json | 4 +- .../guardian/src/services/GuardianSigner.ts | 40 + packages/sessions/CHANGELOG.md | 7 + packages/sessions/README.md | 126 ++ packages/sessions/package.json | 5 +- packages/sessions/src/main.ts | 4 +- .../sessions/src/offchainSessionAccount.ts | 153 ++ packages/sessions/src/offchainSessionUtils.ts | 108 ++ packages/sessions/vite.config.ts | 2 +- packages/shared/package.json | 9 +- packages/shared/src/argent/index.ts | 1 + packages/shared/src/argent/interface.ts | 28 + .../src/bigdecimal/createUnitsSchema.test.ts | 47 + .../src/bigdecimal/createUnitsSchema.ts | 14 + packages/shared/src/bigdecimal/index.ts | 1 + packages/shared/src/bigdecimal/utils.ts | 2 +- packages/shared/src/chains/index.ts | 7 +- .../src/chains/starknet/address.test.ts | 27 +- .../shared/src/chains/starknet/address.ts | 15 +- .../src/chains/starknet/addressDomain.test.ts | 112 ++ .../src/chains/starknet/addressDomain.ts | 68 + .../src/chains/starknet/addressInput.test.ts | 49 +- .../src/chains/starknet/addressInput.ts | 10 - .../chains/starknet/addressStarknetId.test.ts | 52 - .../src/chains/starknet/addressStarknetId.ts | 11 - .../src/chains/starknet/argentName.test.ts | 93 + .../shared/src/chains/starknet/argentName.ts | 28 + .../starknet/getAddressFromArgentName.ts | 85 + ...eAddress.ts => getAddressFromStarkName.ts} | 100 +- packages/shared/src/chains/starknet/index.ts | 9 + .../address/IStarknetAddressService.ts | 15 + .../address/StarknetAddressService.test.ts | 165 ++ .../address/StarknetAddressService.ts | 65 + .../chains/starknet/services/address/index.ts | 2 + .../src/chains/starknet/services/index.ts | 1 + .../shared/src/chains/starknet/starknetId.ts | 11 - packages/shared/src/errors/address.ts | 7 +- packages/shared/src/hooks/index.ts | 1 + .../src/hooks/useDebouncedValue.ts} | 2 +- packages/shared/src/http/HttpService.ts | 37 +- packages/shared/src/http/IHttpService.ts | 8 +- packages/shared/src/index.ts | 2 + packages/shared/src/knownDapps/model.ts | 1 + packages/shared/src/nfts/argent.ts | 8 +- packages/shared/src/tokens/price.ts | 12 +- .../transactionSimulationTypes.ts | 4 +- packages/shared/src/utils/index.ts | 2 + packages/shared/src/utils/starknet.ts | 56 - .../shared/src/utils/starknet/starknet.ts | 97 + .../src/utils/starknet/starknetLibTypes.ts | 109 ++ .../src/utils/starknet/starknetSchemas.ts | 130 ++ packages/stack-router/src/StackScreen.tsx | 4 +- .../package.json | 4 +- packages/storybook/.storybook/polyfill.ts | 8 +- packages/storybook/package.json | 2 +- .../transaction/KnownDappButton.stories.tsx | 9 + .../VerifiedDappBanner.stories.tsx | 35 - .../SignActionScreenV2.stories.tsx | 28 + .../TransactionReviewActions.stories.tsx | 117 ++ .../TransactionReviewSignAction.stories.tsx | 25 + .../TransactionReviewSimulation.stories.tsx | 63 + .../transactionV2/__fixtures__/fixtures.sh | 156 ++ .../transactionV2/__fixtures__/mint-nft.json | 86 + .../__fixtures__/multisig-add.json | 55 + .../__fixtures__/multisig-change.json | 40 + .../__fixtures__/non-native-jediswap.json | 265 +++ .../__fixtures__/send-nft-self.json | 157 ++ .../transactionV2/__fixtures__/send-nft.json | 133 ++ .../transactionV2/__fixtures__/send.json | 142 ++ .../__fixtures__/shield-add.json | 55 + .../__fixtures__/shield-keep.json | 34 + .../__fixtures__/shield-remove.json | 52 + .../transactionV2/__fixtures__/swap.json | 245 +++ .../transactionV2/__fixtures__/upgrade.json | 37 + .../src/ui/components/Accordion.stories.tsx | 99 +- .../ui/components/NestedAccordion.stories.tsx | 43 + packages/swap/package.json | 6 +- .../src/lib/hooks/useCurrentBlockTimestamp.ts | 15 +- packages/swap/src/lib/providers/swap.tsx | 20 +- packages/swap/src/lib/providers/types.ts | 6 +- packages/swap/src/lib/services/multicall.ts | 14 +- packages/swap/src/lib/services/provider.ts | 30 +- packages/ui/package.json | 5 +- packages/ui/scripts/generate-icons.ts | 26 +- packages/ui/src/components/Accordion.tsx | 70 +- packages/ui/src/components/CopyTooltip.tsx | 11 +- .../ui/src/components/DetailAccordion.tsx | 4 +- packages/ui/src/components/FloatingForm.tsx | 106 + packages/ui/src/components/LabelValue.tsx | 91 + packages/ui/src/components/ModalDialog.tsx | 7 +- .../ui/src/components/ModalDialogData.tsx | 15 +- .../ui/src/components/NestedAccordion.tsx | 76 + .../src/components/icons/DisconnectIcon.tsx | 18 + .../Ethereum.tsx => icons/FlagIcon.tsx} | 6 +- .../Ledger.tsx => icons/MobileIcon.tsx} | 2 +- .../ui/src/components/icons/PopupIcon.tsx | 18 + .../src/components/icons/PreferencesIcon.tsx | 18 + packages/ui/src/components/icons/index.ts | 146 +- packages/ui/src/components/index.ts | 3 + .../ui/src/components/logos/ArgentXLogo.tsx | 12 +- .../src/components/logos/ArgentXLogoFull.tsx | 47 +- packages/ui/src/components/logos/Aspect.tsx | 20 - .../ui/src/components/logos/AspectLogo.tsx | 20 + .../ui/src/components/logos/BanxaLogo.tsx | 18 + packages/ui/src/components/logos/Briq.tsx | 18 - packages/ui/src/components/logos/BriqLogo.tsx | 18 + packages/ui/src/components/logos/Coinbase.tsx | 25 - .../ui/src/components/logos/CoinbaseLogo.tsx | 25 + packages/ui/src/components/logos/Discord.tsx | 18 - .../ui/src/components/logos/DiscordLogo.tsx | 18 + .../ui/src/components/logos/ElementLogo.tsx | 159 ++ packages/ui/src/components/logos/EmptyNft.tsx | 25 - .../ui/src/components/logos/EmptyNftLogo.tsx | 25 + .../logos/{Jediswap.tsx => EthereumLogo.tsx} | 12 +- .../logos/{Flex.tsx => FlexLogo.tsx} | 218 ++- .../{Frenslands.tsx => FrenslandsLogo.tsx} | 18 +- packages/ui/src/components/logos/Github.tsx | 18 - .../ui/src/components/logos/GithubLogo.tsx | 18 + packages/ui/src/components/logos/Image.tsx | 24 - .../ui/src/components/logos/ImageLogo.tsx | 24 + .../ui/src/components/logos/Influence.tsx | 40 - .../ui/src/components/logos/InfluenceLogo.tsx | 40 + .../ui/src/components/logos/JediswapLogo.tsx | 26 + .../ui/src/components/logos/Layerswap.tsx | 29 - .../ui/src/components/logos/LayerswapLogo.tsx | 29 + .../logos/{Banxa.tsx => LedgerLogo.tsx} | 8 +- .../ui/src/components/logos/Mintsquare.tsx | 37 - .../src/components/logos/MintsquareLogo.tsx | 43 + packages/ui/src/components/logos/Orbiter.tsx | 26 - .../ui/src/components/logos/OrbiterLogo.tsx | 49 + .../ui/src/components/logos/PyramidLogo.tsx | 71 + packages/ui/src/components/logos/Ramp.tsx | 22 - packages/ui/src/components/logos/RampLogo.tsx | 26 + packages/ui/src/components/logos/Spok.tsx | 32 - packages/ui/src/components/logos/SpokLogo.tsx | 32 + packages/ui/src/components/logos/Starknet.tsx | 24 - .../ui/src/components/logos/StarknetLogo.tsx | 28 + packages/ui/src/components/logos/Twitter.tsx | 18 - .../ui/src/components/logos/TwitterLogo.tsx | 18 + packages/ui/src/components/logos/Unframed.tsx | 22 - .../ui/src/components/logos/UnframedLogo.tsx | 74 + .../ui/src/components/logos/VoyagerLogo.tsx | 44 + packages/ui/src/components/logos/Zklend.tsx | 80 - .../ui/src/components/logos/ZklendLogo.tsx | 80 + packages/ui/src/components/logos/index.ts | 52 +- .../KnownDapp/KnownDappButton.tsx | 36 + .../KnownDapp}/KnownDappModal.tsx | 6 +- .../transactions/KnownDapp/index.ts | 2 + .../components/transactions/NftDetails.tsx | 2 +- .../transactions/TransactionActions.tsx | 16 +- .../transactions/VerifiedDappBanner.tsx | 46 - .../transactions/VerifiedDappModal.tsx | 84 - .../ui/src/components/transactions/index.ts | 2 +- packages/ui/src/theme/index.tsx | 2 +- packages/ui/src/theme/semanticTokens.ts | 25 +- packages/web-sdk/package.json | 2 +- packages/window/package.json | 2 +- pnpm-lock.yaml | 1697 ++++++++++------- 553 files changed, 17492 insertions(+), 6702 deletions(-) create mode 100644 packages/dapp/.env.example create mode 100644 packages/dapp/src/components/AddNetwork.tsx create mode 100644 packages/dapp/src/components/AddToken.tsx create mode 100644 packages/dapp/src/components/Declare.tsx create mode 100644 packages/dapp/src/components/Deploy.tsx create mode 100644 packages/dapp/src/components/Header.tsx create mode 100644 packages/dapp/src/components/InfoRow.tsx create mode 100644 packages/dapp/src/components/Mint.tsx create mode 100644 packages/dapp/src/components/MintWithStarknetReact.tsx create mode 100644 packages/dapp/src/components/OffchainSessionKeys.tsx create mode 100644 packages/dapp/src/components/OffchainSessionKeysExecute.tsx create mode 100644 packages/dapp/src/components/OffchainSessionKeysSign.tsx create mode 100644 packages/dapp/src/components/SignMessage.tsx create mode 100644 packages/dapp/src/components/SignMessageWithStarknetReact.tsx create mode 100644 packages/dapp/src/components/Transfer.tsx create mode 100644 packages/dapp/src/components/TransferWithStarknetReact.tsx create mode 100644 packages/dapp/src/pages/_document.tsx create mode 100644 packages/dapp/src/pages/starknetReactDapp.tsx delete mode 100644 packages/dapp/src/styles/Home.module.css delete mode 100644 packages/dapp/src/styles/globals.css create mode 100644 packages/dapp/src/types/Status.ts create mode 100644 packages/e2e/extension/src/specs/2FA.spec.ts create mode 100644 packages/e2e/extension/src/utils/common.ts create mode 100644 packages/extension/src/background/__new/procedures/accountMessaging/getAccountDeploymentPayload.ts create mode 100644 packages/extension/src/background/__new/procedures/address/getAddressFromDomainName.ts create mode 100644 packages/extension/src/background/__new/procedures/address/index.ts create mode 100644 packages/extension/src/background/__new/procedures/address/parseAddressOrDomain.ts create mode 100644 packages/extension/src/background/__new/procedures/tokens/swap.ts create mode 100644 packages/extension/src/background/__new/procedures/transactionReview/getLabels.ts create mode 100644 packages/extension/src/background/__new/procedures/transactionReview/index.ts create mode 100644 packages/extension/src/background/__new/procedures/transactionReview/simulateAndReview.ts create mode 100644 packages/extension/src/background/__new/procedures/udc/declareContractProcedure.ts create mode 100644 packages/extension/src/background/__new/procedures/udc/deployContractProcedure.ts create mode 100644 packages/extension/src/background/__new/services/activity/implementation.test.ts create mode 100644 packages/extension/src/background/__new/services/activity/implementation.ts create mode 100644 packages/extension/src/background/__new/services/activity/index.ts create mode 100644 packages/extension/src/background/__new/services/activity/interface.ts create mode 100644 packages/extension/src/background/__new/services/activity/model.ts create mode 100644 packages/extension/src/background/__new/services/address/index.ts create mode 100644 packages/extension/src/background/__new/services/transactionReview/background.ts create mode 100644 packages/extension/src/background/__new/services/transactionReview/index.ts create mode 100644 packages/extension/src/background/__new/services/transactionReview/worker/implementation.test.ts create mode 100644 packages/extension/src/background/__new/services/transactionReview/worker/implementation.ts create mode 100644 packages/extension/src/background/__new/services/transactionReview/worker/index.ts create mode 100644 packages/extension/src/background/__new/services/transactionReview/worker/interface.ts rename packages/extension/src/background/migrations/network/{removeTestnet2.ts => restoreDefaultNetworksMigration.ts} (67%) create mode 100644 packages/extension/src/shared/actionQueue/schema.test.ts create mode 100644 packages/extension/src/shared/activity/storage.ts create mode 100644 packages/extension/src/shared/activity/types.ts create mode 100644 packages/extension/src/shared/debounce/chrome.test.ts create mode 100644 packages/extension/src/shared/errors/activity.ts create mode 100644 packages/extension/src/shared/errors/review.ts create mode 100644 packages/extension/src/shared/errors/schema.ts rename packages/extension/src/{ui/features/multisig/hooks/pubkeySchema.test.ts => shared/multisig/multisig.model.test.ts} (96%) create mode 100644 packages/extension/src/shared/network/FallbackRpcProvider.test.ts create mode 100644 packages/extension/src/shared/network/FallbackRpcProvider.ts create mode 100644 packages/extension/src/shared/network/exponentialBackoff.ts create mode 100644 packages/extension/src/shared/nft/implementation.ts create mode 100644 packages/extension/src/shared/nft/index.ts create mode 100644 packages/extension/src/shared/nft/test/index.test.ts rename packages/extension/src/{ui/services/nfts => shared/nft}/test/nft.mock.ts (100%) delete mode 100644 packages/extension/src/shared/nft/worker/store.ts create mode 100644 packages/extension/src/shared/storage/__new/prune.test.ts create mode 100644 packages/extension/src/shared/transactionReview/__fixtures__/simulation-error.json create mode 100644 packages/extension/src/shared/transactionReview/__fixtures__/simulation.json create mode 100644 packages/extension/src/shared/transactionReview/interface.ts create mode 100644 packages/extension/src/shared/transactionReview/schema.test.ts create mode 100644 packages/extension/src/shared/transactionReview/schema.ts create mode 100644 packages/extension/src/shared/transactionReview/store.ts delete mode 100644 packages/extension/src/shared/utils/accountv4.ts create mode 100644 packages/extension/src/shared/utils/argentMaxFee.test.ts create mode 100644 packages/extension/src/shared/utils/argentMaxFee.ts create mode 100644 packages/extension/src/shared/utils/encodeChainId.test.ts create mode 100644 packages/extension/src/shared/utils/encodeChainId.ts create mode 100644 packages/extension/src/ui/features/actions/connectDapp/KnownDappButtonWrapper.tsx delete mode 100644 packages/extension/src/ui/features/actions/transaction/ApproveDeployMultisig.tsx delete mode 100644 packages/extension/src/ui/features/actions/transaction/ApproveTransactionScreen/VerifiedDappBanner/VerifiedDappModalArgentX.tsx delete mode 100644 packages/extension/src/ui/features/actions/transaction/ApproveTransactionScreen/VerifiedDappBanner/index.tsx create mode 100644 packages/extension/src/ui/features/actions/transaction/executeFromOutside/model.ts create mode 100644 packages/extension/src/ui/features/actions/transaction/executeFromOutside/utils.test.ts create mode 100644 packages/extension/src/ui/features/actions/transaction/executeFromOutside/utils.ts create mode 100644 packages/extension/src/ui/features/actions/transaction/executeFromOutside/whitelist.ts create mode 100644 packages/extension/src/ui/features/actions/transactionV2/AmountEditModalForm.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/FeeEstimationContainerV2.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/ReviewFallback.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/SignActionScreenContainerV2.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/SignActionScreenV2.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionActionScreenContainerV2.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/AccountDetails.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/TransactionIcon/DappIcon.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/TransactionIcon/IconWrapper.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/TransactionIcon/KnownIcon.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/TransactionIcon/UnknownDappIcon.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/TransactionIcon/index.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/TransactionTitle.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionHeader/index.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/TransactionReviewLabel.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/action/TransactionReviewAction.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/action/TransactionReviewActions.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/action/TransactionReviewSignAction.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/action/properties/TransactionReviewProperties.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/action/properties/TransactionReviewProperty.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/simulation/TransactionReviewSimulation.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/simulation/summary/TransactionReviewSummary.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/simulation/summary/TransactionReviewSummaryStack.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/useMultisigActionScreen.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/useTransactionReviewV2.ts create mode 100644 packages/extension/src/ui/features/actions/transactionV2/warning/AlertFillIconWithHalo.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/warning/WarningBanner.tsx create mode 100644 packages/extension/src/ui/features/actions/transactionV2/warning/warningMap.ts create mode 100644 packages/extension/src/ui/features/dev/useDevStorageUI.tsx create mode 100644 packages/extension/src/ui/features/multisig/constants.ts create mode 100644 packages/extension/src/ui/features/send/useGetAddressFromDomainName.ts delete mode 100644 packages/extension/src/ui/features/send/useGetAddressFromStarknetId.ts create mode 100644 packages/extension/src/ui/features/settings/DeveloperSettings/DeploySmartContractParametersContainer.tsx create mode 100644 packages/extension/src/ui/features/settings/DeveloperSettings/useConstructorParams.tsx delete mode 100644 packages/extension/src/ui/features/swap/ui/SlippageForm.tsx create mode 100644 packages/extension/src/ui/features/transactionReview/signature/fixtures.ts delete mode 100644 packages/extension/src/ui/services/account/clientTrpc.ts create mode 100644 packages/extension/src/ui/services/account/implementation.ts create mode 100644 packages/extension/src/ui/services/address/client.ts create mode 100644 packages/extension/src/ui/services/address/index.ts create mode 100644 packages/extension/src/ui/services/address/interface.ts create mode 100644 packages/extension/src/ui/services/nfts/interface.ts delete mode 100644 packages/extension/src/ui/services/nfts/test/index.test.ts create mode 100644 packages/extension/src/ui/services/transactionReview/client.ts create mode 100644 packages/extension/src/ui/services/transactionReview/index.ts delete mode 100644 packages/extension/src/ui/services/udc.service.ts create mode 100644 packages/extension/src/ui/views/implementation/__tests__/AtomFromKeyValueStore.test.tsx create mode 100644 packages/extension/src/ui/views/implementation/atomFromKeyValueStore.ts create mode 100644 packages/extension/src/ui/views/transactionReviews.ts create mode 100644 packages/sessions/CHANGELOG.md create mode 100644 packages/sessions/src/offchainSessionAccount.ts create mode 100644 packages/sessions/src/offchainSessionUtils.ts create mode 100644 packages/shared/src/argent/index.ts create mode 100644 packages/shared/src/bigdecimal/createUnitsSchema.test.ts create mode 100644 packages/shared/src/bigdecimal/createUnitsSchema.ts create mode 100644 packages/shared/src/chains/starknet/addressDomain.test.ts create mode 100644 packages/shared/src/chains/starknet/addressDomain.ts delete mode 100644 packages/shared/src/chains/starknet/addressStarknetId.test.ts delete mode 100644 packages/shared/src/chains/starknet/addressStarknetId.ts create mode 100644 packages/shared/src/chains/starknet/argentName.test.ts create mode 100644 packages/shared/src/chains/starknet/argentName.ts create mode 100644 packages/shared/src/chains/starknet/getAddressFromArgentName.ts rename packages/shared/src/chains/starknet/{parseAddress.ts => getAddressFromStarkName.ts} (53%) create mode 100644 packages/shared/src/chains/starknet/index.ts create mode 100644 packages/shared/src/chains/starknet/services/address/IStarknetAddressService.ts create mode 100644 packages/shared/src/chains/starknet/services/address/StarknetAddressService.test.ts create mode 100644 packages/shared/src/chains/starknet/services/address/StarknetAddressService.ts create mode 100644 packages/shared/src/chains/starknet/services/address/index.ts create mode 100644 packages/shared/src/chains/starknet/services/index.ts rename packages/{extension/src/ui/services/useDebounce.ts => shared/src/hooks/useDebouncedValue.ts} (90%) delete mode 100644 packages/shared/src/utils/starknet.ts create mode 100644 packages/shared/src/utils/starknet/starknet.ts create mode 100644 packages/shared/src/utils/starknet/starknetLibTypes.ts create mode 100644 packages/shared/src/utils/starknet/starknetSchemas.ts create mode 100644 packages/storybook/src/features/actions/transaction/KnownDappButton.stories.tsx delete mode 100644 packages/storybook/src/features/actions/transaction/VerifiedDappBanner.stories.tsx create mode 100644 packages/storybook/src/features/actions/transactionV2/SignActionScreenV2.stories.tsx create mode 100644 packages/storybook/src/features/actions/transactionV2/TransactionReviewActions.stories.tsx create mode 100644 packages/storybook/src/features/actions/transactionV2/TransactionReviewSignAction.stories.tsx create mode 100644 packages/storybook/src/features/actions/transactionV2/TransactionReviewSimulation.stories.tsx create mode 100755 packages/storybook/src/features/actions/transactionV2/__fixtures__/fixtures.sh create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/mint-nft.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/multisig-add.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/multisig-change.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/non-native-jediswap.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/send-nft-self.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/send-nft.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/send.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/shield-add.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/shield-keep.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/shield-remove.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/swap.json create mode 100644 packages/storybook/src/features/actions/transactionV2/__fixtures__/upgrade.json create mode 100644 packages/storybook/src/ui/components/NestedAccordion.stories.tsx create mode 100644 packages/ui/src/components/FloatingForm.tsx create mode 100644 packages/ui/src/components/LabelValue.tsx create mode 100644 packages/ui/src/components/NestedAccordion.tsx create mode 100644 packages/ui/src/components/icons/DisconnectIcon.tsx rename packages/ui/src/components/{logos/Ethereum.tsx => icons/FlagIcon.tsx} (67%) rename packages/ui/src/components/{logos/Ledger.tsx => icons/MobileIcon.tsx} (51%) create mode 100644 packages/ui/src/components/icons/PopupIcon.tsx create mode 100644 packages/ui/src/components/icons/PreferencesIcon.tsx delete mode 100644 packages/ui/src/components/logos/Aspect.tsx create mode 100644 packages/ui/src/components/logos/AspectLogo.tsx create mode 100644 packages/ui/src/components/logos/BanxaLogo.tsx delete mode 100644 packages/ui/src/components/logos/Briq.tsx create mode 100644 packages/ui/src/components/logos/BriqLogo.tsx delete mode 100644 packages/ui/src/components/logos/Coinbase.tsx create mode 100644 packages/ui/src/components/logos/CoinbaseLogo.tsx delete mode 100644 packages/ui/src/components/logos/Discord.tsx create mode 100644 packages/ui/src/components/logos/DiscordLogo.tsx create mode 100644 packages/ui/src/components/logos/ElementLogo.tsx delete mode 100644 packages/ui/src/components/logos/EmptyNft.tsx create mode 100644 packages/ui/src/components/logos/EmptyNftLogo.tsx rename packages/ui/src/components/logos/{Jediswap.tsx => EthereumLogo.tsx} (58%) rename packages/ui/src/components/logos/{Flex.tsx => FlexLogo.tsx} (94%) rename packages/ui/src/components/logos/{Frenslands.tsx => FrenslandsLogo.tsx} (98%) delete mode 100644 packages/ui/src/components/logos/Github.tsx create mode 100644 packages/ui/src/components/logos/GithubLogo.tsx delete mode 100644 packages/ui/src/components/logos/Image.tsx create mode 100644 packages/ui/src/components/logos/ImageLogo.tsx delete mode 100644 packages/ui/src/components/logos/Influence.tsx create mode 100644 packages/ui/src/components/logos/InfluenceLogo.tsx create mode 100644 packages/ui/src/components/logos/JediswapLogo.tsx delete mode 100644 packages/ui/src/components/logos/Layerswap.tsx create mode 100644 packages/ui/src/components/logos/LayerswapLogo.tsx rename packages/ui/src/components/logos/{Banxa.tsx => LedgerLogo.tsx} (51%) delete mode 100644 packages/ui/src/components/logos/Mintsquare.tsx create mode 100644 packages/ui/src/components/logos/MintsquareLogo.tsx delete mode 100644 packages/ui/src/components/logos/Orbiter.tsx create mode 100644 packages/ui/src/components/logos/OrbiterLogo.tsx create mode 100644 packages/ui/src/components/logos/PyramidLogo.tsx delete mode 100644 packages/ui/src/components/logos/Ramp.tsx create mode 100644 packages/ui/src/components/logos/RampLogo.tsx delete mode 100644 packages/ui/src/components/logos/Spok.tsx create mode 100644 packages/ui/src/components/logos/SpokLogo.tsx delete mode 100644 packages/ui/src/components/logos/Starknet.tsx create mode 100644 packages/ui/src/components/logos/StarknetLogo.tsx delete mode 100644 packages/ui/src/components/logos/Twitter.tsx create mode 100644 packages/ui/src/components/logos/TwitterLogo.tsx delete mode 100644 packages/ui/src/components/logos/Unframed.tsx create mode 100644 packages/ui/src/components/logos/UnframedLogo.tsx create mode 100644 packages/ui/src/components/logos/VoyagerLogo.tsx delete mode 100644 packages/ui/src/components/logos/Zklend.tsx create mode 100644 packages/ui/src/components/logos/ZklendLogo.tsx create mode 100644 packages/ui/src/components/transactions/KnownDapp/KnownDappButton.tsx rename packages/{extension/src/ui/features/actions/connectDapp => ui/src/components/transactions/KnownDapp}/KnownDappModal.tsx (92%) create mode 100644 packages/ui/src/components/transactions/KnownDapp/index.ts delete mode 100644 packages/ui/src/components/transactions/VerifiedDappBanner.tsx delete mode 100644 packages/ui/src/components/transactions/VerifiedDappModal.tsx diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d01ef95e8..1d7c5760d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -19,7 +19,7 @@ jobs: # FEATURE flags FEATURE_PRIVACY_SETTINGS: "true" FEATURE_EXPERIMENTAL_SETTINGS: "false" - FEATURE_BETA_FEATURES: "true" + FEATURE_BETA_FEATURES: "false" FEATURE_BANXA: "true" FEATURE_LAYERSWAP: "true" FEATURE_ORBITER: "true" @@ -29,6 +29,7 @@ jobs: # API URLs ARGENT_API_BASE_URL: ${{ vars.ARGENT_API_BASE_URL }} ARGENT_X_STATUS_URL: ${{ vars.ARGENT_X_STATUS_URL }} + ARGENT_TESTNET_RPC_URL: ${{ vars.ARGENT_TESTNET_RPC_URL }} # API ENVIRONMENT ARGENT_X_ENVIRONMENT: ${{ matrix.env }} @@ -50,6 +51,9 @@ jobs: SLOW: 60 * 5 # 5m VERY_SLOW: 24 * 60 * 60 # 1d + #For testing only + FEE_OVERHEAD: 2 + steps: # Setup Project - uses: actions/checkout@v4 @@ -120,12 +124,13 @@ jobs: env: ARGENT_API_BASE_URL: ${{ vars.ARGENT_API_BASE_URL }} + ARGENT_TESTNET_RPC_URL: ${{ vars.ARGENT_TESTNET_RPC_URL }} ARGENT_X_STATUS_URL: ${{ vars.ARGENT_X_STATUS_URL }} ARGENT_X_ENVIRONMENT: "hydrogen" services: devnet: - image: shardlabs/starknet-devnet:latest-seed0 + image: shardlabs/starknet-devnet-rs:latest-seed0 ports: - 5050:5050 @@ -184,6 +189,7 @@ jobs: shardTotal: [8] env: ARGENT_X_ENVIRONMENT: "hydrogen" + ARGENT_API_BASE_URL: ${{ secrets.ARGENT_API_BASE_URL }} E2E_TESTNET_SEED1: ${{ secrets.E2E_TESTNET_SEED1 }} E2E_TESTNET_SEED2: ${{ secrets.E2E_TESTNET_SEED2 }} E2E_TESTNET_SEED3: ${{ secrets.E2E_TESTNET_SEED3 }} @@ -195,6 +201,7 @@ jobs: E2E_SENDER_SEED: ${{ secrets.E2E_SENDER_SEED }} STARKNET_TESTNET_URL: ${{ secrets.STARKNET_TESTNET_URL }} STARKSCAN_TESTNET_URL: ${{ secrets.STARKSCAN_TESTNET_URL }} + ARGENT_TESTNET_RPC_URL: ${{ secrets.ARGENT_TESTNET_RPC_URL }} steps: - uses: actions/checkout@v4 @@ -397,6 +404,7 @@ jobs: NEXT_PUBLIC_RAMP_API_KEY: ${{ secrets.RAMP_API_KEY }} NEXT_PUBLIC_FEATURE_COSIGNER: "true" NEXT_PUBLIC_ARGENT_API_BASE_URL: ${{ vars.ARGENT_API_BASE_URL }} + NEXT_PUBLIC_ARGENT_TESTNET_RPC_URL: ${{ vars.ARGENT_TESTNET_RPC_URL }} steps: - uses: actions/checkout@v4 @@ -445,7 +453,7 @@ jobs: if: always() uses: actions/upload-artifact@v3 with: - name: all-blob-reports + name: all-blob-reports-webwallet path: packages/e2e/blob-report/ retention-days: 5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4c3f0e75d..a5c23719f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ on: env: FEATURE_PRIVACY_SETTINGS: "true" FEATURE_EXPERIMENTAL_SETTINGS: "false" - FEATURE_BETA_FEATURES: "true" + FEATURE_BETA_FEATURES: "false" FEATURE_BANXA: "true" FEATURE_LAYERSWAP: "true" FEATURE_ORBITER: "true" @@ -26,9 +26,8 @@ env: FILENAME: argent-extension SAFE_ENV_VARS: true ARGENT_API_BASE_URL: ${{ vars.ARGENT_API_BASE_URL }} - ARGENT_TRANSACTION_REVIEW_API_BASE_URL: ${{ vars.ARGENT_TRANSACTION_REVIEW_API_BASE_URL }} + ARGENT_TESTNET_RPC_URL: ${{ vars.ARGENT_TESTNET_RPC_URL }} ARGENT_X_STATUS_URL: ${{ vars.ARGENT_X_STATUS_URL }} - ARGENT_EXPLORER_BASE_URL: ${{ vars.ARGENT_EXPLORER_BASE_URL }} ARGENT_X_ENVIRONMENT: "prod" MULTICALL_MAX_BATCH_SIZE: 20 FAST: 20 # 20s @@ -136,7 +135,7 @@ jobs: pnpm --filter @argent/get-starknet publish --no-git-checks --access public || exit 0 pnpm --filter @argent/web-sdk publish --no-git-checks --access public || exit 0 pnpm --filter @argent/starknet-react-webwallet-connector publish --no-git-checks --access public || exit 0 - pnpm --filter @argent-x/sessions publish --no-git-checks --access public || exit 0 + pnpm --filter @argent/x-sessions publish --no-git-checks --access public || exit 0 - name: Get product version id: product-version @@ -149,7 +148,7 @@ jobs: uses: softprops/action-gh-release@v1 with: generate_release_notes: true - title: extension@${{ steps.product-version.outputs.current-version }} + name: extension@${{ steps.product-version.outputs.current-version }} files: | ${{ env.FILENAME }}-chrome.zip ${{ env.FILENAME }}-firefox.zip diff --git a/.nvmrc b/.nvmrc index f6610cade..87ec8842b 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18.18.1 +18.18.2 diff --git a/package.json b/package.json index f17db27d4..e014f3d15 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,13 @@ "homepage": "https://github.com/argentlabs/argent-x/#readme", "devDependencies": { "@changesets/cli": "^2.26.1", - "@lavamoat/preinstall-always-fail": "^2.0.0", "@lavamoat/allow-scripts": "^3.0.0", + "@lavamoat/preinstall-always-fail": "^2.0.0", "bundlewatch": "^0.3.3", "husky": "^8.0.3", "import-sort-style-module": "^6.0.0", "lint-staged": "^15.0.0", - "nx": "^16.2.2", + "nx": "^17.0.0", "patch-package": "^8.0.0", "prettier": ">=2.8.8", "prettier-plugin-import-sort": "^0.0.7", diff --git a/packages/dapp/.env.example b/packages/dapp/.env.example new file mode 100644 index 000000000..ce579f865 --- /dev/null +++ b/packages/dapp/.env.example @@ -0,0 +1,2 @@ +NEXT_PUBLIC_WEBWALLET_URL="http://localhost:3005" +NEXT_PUBLIC_ARGENT_CHAIN_ID=SN_GOERLI \ No newline at end of file diff --git a/packages/dapp/next.config.js b/packages/dapp/next.config.js index 4b1bd3055..5456af0c3 100644 --- a/packages/dapp/next.config.js +++ b/packages/dapp/next.config.js @@ -2,4 +2,9 @@ module.exports = { reactStrictMode: true, swcMinify: false, // we need to use terser, as swc doesn't support svelte and `@argent/get-starknet` + publicRuntimeConfig: { + webWalletUrl: + process.env.NEXT_PUBLIC_WEBWALLET_URL ?? "http://localhost:3005", + argentMobileChainId: process.env.NEXT_PUBLIC_ARGENT_CHAIN_ID ?? "SN_GOERLI", + }, } diff --git a/packages/dapp/package.json b/packages/dapp/package.json index bc6180154..49d7e60d9 100644 --- a/packages/dapp/package.json +++ b/packages/dapp/package.json @@ -11,20 +11,24 @@ }, "dependencies": { "@argent/shared": "^6.3.1", - "@argent/get-starknet": "^6.3.1", + "@argent/ui": "^6.3.1", "@argent/x-sessions": "^6.3.1", + "@chakra-ui/react": "^2.6.1", + "@starknet-react/chains": "0.1.0-next.1", + "@starknet-react/core": "2.0.0-next.6", + "micro-starknet": "^0.2.3", "next": "^13.4.6", "react": "^18.0.0", "react-dom": "^18.0.0", - "starknet": "5.19.5", - "micro-starknet": "^0.2.3" + "starknet": "5.24.3", + "starknetkit": "^1.0.21" }, "devDependencies": { - "@types/node": "20.8.4", + "@types/node": "20.8.10", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "eslint": "8", - "eslint-config-next": "13.5.4", + "eslint-config-next": "13.5.6", "typescript": "^5.0.4" } } diff --git a/packages/dapp/src/components/AddNetwork.tsx b/packages/dapp/src/components/AddNetwork.tsx new file mode 100644 index 000000000..397ef6573 --- /dev/null +++ b/packages/dapp/src/components/AddNetwork.tsx @@ -0,0 +1,39 @@ +import { H2 } from "@argent/ui" +import { Flex } from "@chakra-ui/react" +import { addNetwork } from "../services/wallet.service" +import { useState } from "react" + +const AddNetwork = () => { + const [addNetworkError, setAddNetworkError] = useState("") + + const handleAddNetwork = async () => { + try { + await addNetwork({ + id: "dapp-test", + chainId: "SN_DAPP_TEST", + chainName: "Test chain name", + baseUrl: "http://localhost:5050", + }) + setAddNetworkError("") + } catch (error) { + setAddNetworkError((error as any).message) + } + } + + return ( + +

Network

+ + Add network to wallet + + {addNetworkError} +
+ ) +} + +export { AddNetwork } diff --git a/packages/dapp/src/components/AddToken.tsx b/packages/dapp/src/components/AddToken.tsx new file mode 100644 index 000000000..75ab0d8db --- /dev/null +++ b/packages/dapp/src/components/AddToken.tsx @@ -0,0 +1,72 @@ +import { Button, H2 } from "@argent/ui" +import { truncateAddress } from "../services/address.service" +import { DAITokenAddress, ETHTokenAddress } from "../services/token.service" +import { addToken } from "../services/wallet.service" +import { useState } from "react" +import { Code, Flex } from "@chakra-ui/react" + +const AddToken = () => { + const [addTokenError, setAddTokenError] = useState("") + + const handleAddEth = async () => { + try { + await addToken(ETHTokenAddress) + setAddTokenError("") + } catch (error) { + setAddTokenError((error as any).message) + } + } + + const handleAddDai = async () => { + try { + await addToken(DAITokenAddress) + setAddTokenError("") + } catch (error) { + setAddTokenError((error as any).message) + } + } + + return ( + +

ERC20

+ ETH token address + + + {truncateAddress(ETHTokenAddress)} + + + + Add ETH token to wallet + + + Add DAI token to wallet + + {addTokenError} +
+ ) +} + +export { AddToken } diff --git a/packages/dapp/src/components/Declare.tsx b/packages/dapp/src/components/Declare.tsx new file mode 100644 index 000000000..5dcf1d68e --- /dev/null +++ b/packages/dapp/src/components/Declare.tsx @@ -0,0 +1,146 @@ +import { Button, H2, Input } from "@argent/ui" +import { + CompiledSierraCasm, + DeclareContractPayload, + hash, + isSierra, +} from "starknet" + +import { readFileAsString } from "@argent/shared" +import { Flex } from "@chakra-ui/react" +import { FC, useMemo, useState } from "react" +import { declare, declareAndDeploy } from "../services/wallet.service" +import { Status } from "../types/Status" + +interface DeclareProps { + setTransactionStatus: (status: Status) => void + setLastTransactionHash: (status: string) => void +} + +const Declare: FC = ({ + setTransactionStatus, + setLastTransactionHash, +}) => { + const [classHash, setClassHash] = useState("") + const [contract, setContract] = useState(null) + const [casm, setCasm] = useState(null) + const [shouldDeploy, setShouldDeploy] = useState(false) + + const contractIsSierra = useMemo(() => { + return contract && isSierra(contract) + }, [contract]) + + const handleDeclare = async (e: React.FormEvent) => { + try { + e.preventDefault() + if (!contract) { + throw new Error("No contract") + } + if (!classHash) { + throw new Error("No class hash") + } + const payload: DeclareContractPayload = { + contract, + classHash, + } + if (casm) { + payload.casm = casm + delete payload.classHash + } + if (shouldDeploy) { + const result = await declareAndDeploy(payload) + console.log(result) + setLastTransactionHash(result.deploy.transaction_hash) + } else { + const result = await declare(payload) + console.log(result) + setLastTransactionHash(result.transaction_hash) + } + setTransactionStatus("pending") + } catch (e) { + console.error(e) + setTransactionStatus("idle") + } + } + + return ( + +

Declare (and deploy)

+ + + { + if (!e.target.files) { + return + } + setCasm(null) + + const file = e.target.files[0] + const fileAsString = await readFileAsString(file) + setContract(fileAsString) + + const classHash = hash.computeContractClassHash(fileAsString) + setClassHash(classHash) + }} + /> + + + + + {contractIsSierra && ( + <> + + { + if (!e.target.files) { + return + } + const file = e.target.files[0] + const fileAsString = await readFileAsString(file) + const fileAsJson = JSON.parse(fileAsString) + setCasm(fileAsJson) + }} + /> + + )} + + setShouldDeploy(!shouldDeploy)} + /> + + + +
+ ) +} + +export { Declare } diff --git a/packages/dapp/src/components/Deploy.tsx b/packages/dapp/src/components/Deploy.tsx new file mode 100644 index 000000000..df17d4abd --- /dev/null +++ b/packages/dapp/src/components/Deploy.tsx @@ -0,0 +1,71 @@ +import { Button, H2, Input } from "@argent/ui" +import { UniversalDeployerContractPayload } from "starknet" + +import { Flex } from "@chakra-ui/react" +import { FC, useState } from "react" +import { deploy } from "../services/wallet.service" +import { Status } from "../types/Status" + +interface DeployProps { + setTransactionStatus: (status: Status) => void + setLastTransactionHash: (status: string) => void +} + +const Deploy: FC = ({ + setTransactionStatus, + setLastTransactionHash, +}) => { + const [deployClassHash, setDeployClassHash] = useState("") + + const handleDeploy = async (e: React.FormEvent) => { + try { + e.preventDefault() + if (!deployClassHash) { + throw new Error("No class hash") + } + const payload: UniversalDeployerContractPayload = { + classHash: deployClassHash, + } + const result = await deploy(payload) + setLastTransactionHash(result.transaction_hash) + setTransactionStatus("pending") + } catch (e) { + console.error(e) + setTransactionStatus("idle") + } + } + + return ( + +

Deploy

+ + + { + setDeployClassHash(e.target.value) + }} + value={deployClassHash} + /> + + +
+ ) +} + +export { Deploy } diff --git a/packages/dapp/src/components/Header.tsx b/packages/dapp/src/components/Header.tsx new file mode 100644 index 000000000..830d39fb9 --- /dev/null +++ b/packages/dapp/src/components/Header.tsx @@ -0,0 +1,38 @@ +import { Divider, Flex, Text } from "@chakra-ui/react" +import { Button } from "@argent/ui" +import { useRouter } from "next/router" +import Link from "next/link" +import { FC } from "react" + +export const Header: FC<{ + isConnected?: boolean + disconnectFn?: () => void +}> = ({ isConnected, disconnectFn }) => { + const { pathname } = useRouter() + + return ( + + + + StarknetKit app + + + Starknet React app + + + + {!isConnected && ( + + )} + {isConnected && disconnectFn && ( + + )} + + + + ) +} diff --git a/packages/dapp/src/components/InfoRow.tsx b/packages/dapp/src/components/InfoRow.tsx new file mode 100644 index 000000000..b7585a3fa --- /dev/null +++ b/packages/dapp/src/components/InfoRow.tsx @@ -0,0 +1,45 @@ +import { H4 } from "@argent/ui" +import { Code, Flex } from "@chakra-ui/react" +import { FC } from "react" + +const InfoRow: FC<{ + title: string + content?: string + copyContent?: string +}> = ({ title, content, copyContent }) => { + return ( + +

{title}

+ {!copyContent && ( +

+ + {content} + +

+ )} + {copyContent && content && ( + { + navigator.clipboard.writeText(copyContent) + }} + > +

+ + {content} + +

+
+ )} +
+ ) +} + +export { InfoRow } diff --git a/packages/dapp/src/components/Mint.tsx b/packages/dapp/src/components/Mint.tsx new file mode 100644 index 000000000..ed32a99b3 --- /dev/null +++ b/packages/dapp/src/components/Mint.tsx @@ -0,0 +1,64 @@ +import { H2, Input } from "@argent/ui" +import { Flex } from "@chakra-ui/react" +import { FC, useState } from "react" +import { AccountInterface } from "starknet" +import { mintToken } from "../services/token.service" +import { Status } from "../types/Status" + +interface MintProps { + account?: AccountInterface + setTransactionStatus: (status: Status) => void + setLastTransactionHash: (status: string) => void + transactionStatus: Status +} +const Mint: FC = ({ + setTransactionStatus, + setLastTransactionHash, + transactionStatus, +}) => { + const [mintAmount, setMintAmount] = useState("10") + const buttonsDisabled = ["approve", "pending"].includes(transactionStatus) + + const handleMintSubmit = async (e: React.FormEvent) => { + e.preventDefault() + try { + setTransactionStatus("approve") + const { transaction_hash } = await mintToken(mintAmount) + setLastTransactionHash(transaction_hash) + setTransactionStatus("pending") + } catch (e) { + console.error(e) + setTransactionStatus("idle") + } + } + + return ( + + +

Mint token

+ setMintAmount(e.target.value)} + /> + + +
+
+ ) +} + +export { Mint } diff --git a/packages/dapp/src/components/MintWithStarknetReact.tsx b/packages/dapp/src/components/MintWithStarknetReact.tsx new file mode 100644 index 000000000..9790c2275 --- /dev/null +++ b/packages/dapp/src/components/MintWithStarknetReact.tsx @@ -0,0 +1,89 @@ +import { bigDecimal } from "@argent/shared" +import { H2, Input } from "@argent/ui" +import { Flex } from "@chakra-ui/react" +import { useContractWrite } from "@starknet-react/core" +import { FC, useMemo, useState } from "react" +import { AccountInterface } from "starknet" +import { ETHTokenAddress } from "../services/token.service" +import { Status } from "../types/Status" + +interface MintProps { + account?: AccountInterface + setTransactionStatus: (status: Status) => void + setLastTransactionHash: (status: string) => void + transactionStatus: Status +} + +const MintWithStarknetReact: FC = ({ + account, + setTransactionStatus, + setLastTransactionHash, + transactionStatus, +}) => { + const [mintAmount, setMintAmount] = useState("10") + const buttonsDisabled = ["approve", "pending"].includes(transactionStatus) + + const mintCalls = useMemo(() => { + if (!account) { + return [] + } + return [ + { + contractAddress: ETHTokenAddress, + entrypoint: "transfer", + calldata: [ + account?.address, + Number(bigDecimal.parseEther(mintAmount).value), + 0, + ], + }, + ] + }, [account, mintAmount]) + + const { writeAsync: mintWithStarknetReact } = useContractWrite({ + calls: mintCalls, + }) + + const handleMintSubmit = async (e: React.FormEvent) => { + e.preventDefault() + try { + setTransactionStatus("approve") + const { transaction_hash } = await mintWithStarknetReact() + setLastTransactionHash(transaction_hash) + setTransactionStatus("pending") + } catch (e) { + console.error(e) + setTransactionStatus("idle") + } + } + + return ( + + +

Mint token

+ setMintAmount(e.target.value)} + /> + + +
+
+ ) +} + +export { MintWithStarknetReact } diff --git a/packages/dapp/src/components/OffchainSessionKeys.tsx b/packages/dapp/src/components/OffchainSessionKeys.tsx new file mode 100644 index 000000000..3811600f8 --- /dev/null +++ b/packages/dapp/src/components/OffchainSessionKeys.tsx @@ -0,0 +1,54 @@ +import { Button, H2, Input } from "@argent/ui" +import { OffchainSessionAccount } from "@argent/x-sessions" +import { FC, useState } from "react" +import { Abi, AccountInterface, Contract } from "starknet" + +import { Flex } from "@chakra-ui/react" +import Erc20Abi from "../../abi/ERC20.json" +import { + ETHTokenAddress, + parseInputAmountToUint256, +} from "../services/token.service" +import { Status } from "../types/Status" +import { OffchainSessionKeysSign } from "./OffchainSessionKeysSign" +import { OffchainSessionKeysExecute } from "./OffchainSessionKeysExecute" + +interface OffchainSessionKeysProps { + account: AccountInterface + setTransactionStatus: (status: Status) => void + setLastTransactionHash: (tx: string) => void + transactionStatus: Status +} + +/* no starknet react, need to use the account directly to sign + and the offchainSessionAccount to execute the transaction + */ +const OffchainSessionKeys: FC = ({ + account, + setTransactionStatus, + transactionStatus, + setLastTransactionHash, +}) => { + const [offchainSessionAccount, setOffchainSessionAccount] = useState< + OffchainSessionAccount | undefined + >() + + return ( + + + + + ) +} + +export { OffchainSessionKeys } diff --git a/packages/dapp/src/components/OffchainSessionKeysExecute.tsx b/packages/dapp/src/components/OffchainSessionKeysExecute.tsx new file mode 100644 index 000000000..7d0463678 --- /dev/null +++ b/packages/dapp/src/components/OffchainSessionKeysExecute.tsx @@ -0,0 +1,97 @@ +import { Button, H2, Input } from "@argent/ui" +import { OffchainSessionAccount } from "@argent/x-sessions" +import { FC, useState } from "react" +import { Abi, AccountInterface, Contract } from "starknet" + +import { Flex } from "@chakra-ui/react" +import Erc20Abi from "../../abi/ERC20.json" +import { + ETHTokenAddress, + parseInputAmountToUint256, +} from "../services/token.service" +import { Status } from "../types/Status" + +interface OffchainSessionKeysExecuteProps { + account: AccountInterface + setTransactionStatus: (status: Status) => void + setLastTransactionHash: (tx: string) => void + transactionStatus: Status + offchainSessionAccount: OffchainSessionAccount | undefined +} + +const OffchainSessionKeysExecute: FC = ({ + account, + setTransactionStatus, + transactionStatus, + setLastTransactionHash, + offchainSessionAccount, +}) => { + const [transferOffchainSessionAmount, setTransferOffchainSessionAmount] = + useState("") + + const buttonsDisabled = + ["approve", "pending"].includes(transactionStatus) || + !offchainSessionAccount + + const handleOffchainSessionTransaction = async (e: React.FormEvent) => { + try { + e.preventDefault() + setTransactionStatus("pending") + if (!offchainSessionAccount) { + throw new Error("No open session") + } + const erc20Contract = new Contract( + Erc20Abi as Abi, + ETHTokenAddress, + offchainSessionAccount, + ) + + const result = await erc20Contract.transfer( + account.address, + parseInputAmountToUint256(transferOffchainSessionAmount), + ) + + setLastTransactionHash(result.transaction_hash) + setTransactionStatus("success") + } catch (e) { + console.error(e) + setTransactionStatus("idle") + } + } + + return ( + +

Use session keys

+ + setTransferOffchainSessionAmount(e.target.value)} + /> + +
+ ) +} + +export { OffchainSessionKeysExecute } diff --git a/packages/dapp/src/components/OffchainSessionKeysSign.tsx b/packages/dapp/src/components/OffchainSessionKeysSign.tsx new file mode 100644 index 000000000..16eccf7ac --- /dev/null +++ b/packages/dapp/src/components/OffchainSessionKeysSign.tsx @@ -0,0 +1,85 @@ +import { Button, H2, Input } from "@argent/ui" +import { OffchainSessionAccount } from "@argent/x-sessions" +import { FC, useState } from "react" +import { AccountInterface, RpcProvider } from "starknet" + +import { Flex } from "@chakra-ui/react" +import { getStarkKey, utils } from "micro-starknet" +import { createSessionKeys } from "../services/wallet.service" +import { Status } from "../types/Status" + +interface OffchainSessionKeysSignProps { + account: AccountInterface + setTransactionStatus: (status: Status) => void + setOffchainSessionAccount: (account: OffchainSessionAccount) => void +} + +const OffchainSessionKeysSign: FC = ({ + account, + setTransactionStatus, + setOffchainSessionAccount, +}) => { + const [allowedFees, setAllowedFees] = useState("") + const [sessionSigner] = useState(utils.randomPrivateKey()) + + const handleCreateSessionSubmit = async (e: React.FormEvent) => { + try { + e.preventDefault() + + setTransactionStatus("approve") + const signedSession = await createSessionKeys( + getStarkKey(sessionSigner), + allowedFees, + account, + ) + + const provider = new RpcProvider({ + nodeUrl: "https://cloud.argent-api.com/v1/starknet/goerli/rpc/v0.5", + }) + + const sessionAccount = new OffchainSessionAccount( + provider, + account.address, + sessionSigner, + signedSession, + account, + ) + + setOffchainSessionAccount(sessionAccount) + + setTransactionStatus("success") + } catch (e) { + console.error(e) + setTransactionStatus("idle") + } + } + + return ( + +

Create session keys

+ setAllowedFees(e.target.value)} + /> + +
+ ) +} + +export { OffchainSessionKeysSign } diff --git a/packages/dapp/src/components/SignMessage.tsx b/packages/dapp/src/components/SignMessage.tsx new file mode 100644 index 000000000..828240322 --- /dev/null +++ b/packages/dapp/src/components/SignMessage.tsx @@ -0,0 +1,92 @@ +import { Button, H2, Input, Textarea } from "@argent/ui" +import { Flex } from "@chakra-ui/react" +import { FC, useState } from "react" +import { stark } from "starknet" +import { signMessage } from "../services/wallet.service" +import { Status } from "../types/Status" + +interface SignMessageProps { + setTransactionStatus: (status: Status) => void +} + +const SignMessage: FC = ({ setTransactionStatus }) => { + const [shortText, setShortText] = useState("") + const [lastSig, setLastSig] = useState([]) + + const handleSignSubmit = async (skipDeploy: boolean) => { + try { + setTransactionStatus("approve") + const result = await signMessage(shortText, skipDeploy) + setLastSig(stark.formatSignature(result)) + setTransactionStatus("success") + } catch (e) { + console.error(e) + setTransactionStatus("idle") + } + } + + return ( + + { + e.preventDefault() + handleSignSubmit(false) + }} + direction="column" + background="neutrals.700" + flex={1} + p="4" + gap="3" + borderTopLeftRadius="lg" + borderBottomLeftRadius="lg" + > +

Sign Message

+ + setShortText(e.target.value)} + /> + +
+ + +
+
+ +

Sign results

+ + {/* Label and textarea for value r */} +