diff --git a/packages/dapp/package.json b/packages/dapp/package.json
index 4366a6c01..55c11d6b2 100644
--- a/packages/dapp/package.json
+++ b/packages/dapp/package.json
@@ -12,7 +12,6 @@
"dependencies": {
"@alephium/web3": "v0.5.0-rc.13",
"@alephium/get-extension-wallet": "^0.5.0-rc.4",
- "@argent/x-sessions": "^5.2.0",
"ethers": "^5.5.1",
"next": "^13.0.0",
"react": "^18.0.0",
diff --git a/packages/extension/package.json b/packages/extension/package.json
index 13e5033cc..4ac4f10a5 100644
--- a/packages/extension/package.json
+++ b/packages/extension/package.json
@@ -81,7 +81,6 @@
"@argent/stack-router": "^5.2.0",
"@argent/ui": "^5.2.0",
"@argent/x-multicall": "^5.2.0",
- "@argent/x-sessions": "^5.2.0",
"@argent/x-swap": "^5.2.0",
"@extend-chrome/messages": "^1.2.2",
"@google/model-viewer": "^2.0.0",
diff --git a/packages/extension/src/ui/features/accountPlugins.tsx/Plugins.tsx b/packages/extension/src/ui/features/accountPlugins.tsx/Plugins.tsx
index 2a56563d7..e47b1d36e 100644
--- a/packages/extension/src/ui/features/accountPlugins.tsx/Plugins.tsx
+++ b/packages/extension/src/ui/features/accountPlugins.tsx/Plugins.tsx
@@ -1,7 +1,3 @@
-import { SESSION_PLUGIN_CLASS_HASH } from "@argent/x-sessions"
-
-import { SessionPluginIcon } from "../../components/Icons/SessionPluginIcon"
-
export interface IPlugin {
classHash: string
title: string
@@ -10,11 +6,4 @@ export interface IPlugin {
}
export const plugins: IPlugin[] = [
- {
- classHash: SESSION_PLUGIN_CLASS_HASH,
- title: "User sessions",
- description:
- "In supported dapps, you will be able to allow the dapp to perform certain transactions on your behalf without needing further confirmation",
- icon: ,
- },
]
diff --git a/packages/sessions/.eslintrc.json b/packages/sessions/.eslintrc.json
deleted file mode 100644
index 66709acb2..000000000
--- a/packages/sessions/.eslintrc.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "env": {
- "browser": true,
- "es2021": true,
- "node": true
- },
- "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
- "parser": "@typescript-eslint/parser",
- "parserOptions": {
- "ecmaVersion": "latest",
- "sourceType": "module"
- },
- "plugins": ["@typescript-eslint"],
- "rules": {
- "@typescript-eslint/no-explicit-any": "off",
- "@typescript-eslint/no-extra-semi": "off",
- "@typescript-eslint/no-unused-vars": [
- "warn",
- {
- "vars": "all",
- "ignoreRestSiblings": true,
- "argsIgnorePattern": "^_"
- }
- ],
- "@typescript-eslint/no-non-null-assertion": "error",
- "curly": "error"
- }
-}
diff --git a/packages/sessions/README.md b/packages/sessions/README.md
deleted file mode 100644
index c1889f777..000000000
--- a/packages/sessions/README.md
+++ /dev/null
@@ -1,147 +0,0 @@
-# Sessions
-
-Sessions can be used to send transactions from a dapp on behalf of a user without requiring their confirmation with a wallet.
-
-The user is guaranteed that the dapp can only execute transactions that comply to the policies of the session and until the session expires.
-
-## Installation
-
-```bash
-npm install @argent/x-sessions
-# or
-yarn add @argent/x-sessions
-# or
-pnpm add @argent/x-sessions
-```
-
-## Creating a session as a dapp
-
-First you need to have a deployed account with a valid Signer. This is the account that will authorise the session and interact with the contracts of your dapp.
-
-A session kind of looks like this:
-
-```typescript
-interface Policy {
- contractAddress: string
- selector: string
-}
-
-interface RequestSession {
- key: string
- expires: number
- policies: Policy[]
-}
-```
-
-You can either get that by using the Account and Signer classes provided by starknet.js, or use an injected instance by a wallet.
-
-```typescript
-const account = window.starknet.account
-```
-
-Next you need to come up with the permissions you would like for your session. You also need to generate the session keypair you want to grant these rights to.
-
-This example session will allow the dapp to execute an example endpoint on an example contract without asking the user to approve the transaction again. After signing the session the dapp can execute all transactions listed in `policies` whenever it wants and as many times as it wants.
-
-```typescript
-import { Signer, ec } from "starknet"
-
-// gets signer with random private key you need to store if you want to reuse the session
-const sessionSigner = new Signer()
-
-const requestSession: RequestSession = {
- key: await sessionSigner.getPublicKey(),
- expires: Math.floor((Date.now() + 1000 * 60 * 60 * 24) / 1000), // 1 day in seconds
- policies: [
- {
- contractAddress: "0x...",
- selector: "doAction"
- }
- ]
-}
-```
-
-Now you can sign the session with the account you have. Depending on how your account works, the user may get asked to sign a message
-
-```typescript
-import { createSession } from "@argent/x-sessions"
-
-// calls account.signMessage internally
-const signedSession = await createSession(requestSession, account)
-```
-
-### Using established sessions
-
-With your signed session you can now use it with your dapp to do transactions without the user having to approve again.
-
-```typescript
-import { SessionAccount } from "@argent/x-sessions"
-
-const sessionAccount = new SessionAccount(
- account,
- account.address,
- sessionSigner,
- signedSession
-)
-
-// this transaction should get executed without the user having to approve again
-const tx = sessionAccount.execute({
- // lets assume this is a erc20 contract
- contractAddress: "0x...",
- selector: "transfer",
- calldata: [
- "0x...",
- // ...
- ]
-})
-```
-
-You can also use the session when you dont have access to the main account (`window.starknet.account`). You only need access to the `signedSession` object and the `sessionSigner`.
-
-```typescript
-const sessionAccount = new SessionAccount(
- providerWithCorrectNetwork,
- "0xaccountAddress",
- sessionSigner,
- signedSession
-)
-```
-
-Congratulations, you can now use your dapp to execute transactions without the user having to approve!
-
-## Allowing a session as a user
-
-> Note: Sessions are an alpha feature and are not yet available on mainnet. You can use them on testnet, but expect bugs. That is also the reason why it is so inconvenient to activate them for use in Argent X right now.
-
-Sessions can just be used with a new type of account, pioneered by Argent X. This guide will set you up with a new account that can use sessions, by deploying a Plugin Account and registering your first plugin (Sessions Plugin!).
-
-### Activate Plugin account in Argent X
-
-You can activate session accounts in Argent X Settings, under the "Experimental features" tab.
-
-|  |  |  |
-| --- | --- | --- |
-
-### Deploy a Plugin Account
-
-We strongly recommend to use a new account for sessions. You can create a new account in Argent X by clicking the big `+` button in the account list.
-
-### Upgrade Account to use Plugin Account Implementation
-
-You can upgrade your account to use the Plugin Account implementation by opening the account context menu and selecting "Use Plugins". It will prompt you to confirm a upgrade transaction.
-
-|  |  |
-| --- | --- |
-
-### Register Sessions Plugin
-
-After the upgrade is done you can register the Sessions Plugin by clicking the new Plugins button in your Account. It will prompt you to confirm a register transaction.
-
-|  |  |
-| --- | --- |
-
-### Test if Sessions work
-
-To test if sessions work for your account you can head to the [Wallet Playground](https://argentlabs.github.io/argent-x/). It should show `supports sessions: true` at the top and you should be able to test sessions in the playground.
-
-Each "Use Session" click will send a transaction to mint 666 Test Tokens to the account.
diff --git a/packages/sessions/__tests__/utils.test.ts b/packages/sessions/__tests__/utils.test.ts
deleted file mode 100644
index 7f8d57894..000000000
--- a/packages/sessions/__tests__/utils.test.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { describe, expect, test } from "vitest"
-
-import { createMerkleTreeForPolicies } from "../src/main"
-
-describe("createMerkleTreeForPolicies()", () => {
- test("should complete with valid policies", async () => {
- const proof = createMerkleTreeForPolicies([
- {
- contractAddress: "0x1",
- selector: "selector",
- },
- ])
- expect(proof.root).toBe(
- "0x11b9c3da2d94398a5eaafca97b30a3a9517d0b7743b50308d312e3b6416b830",
- )
- })
-})
diff --git a/packages/sessions/assets/add-plugin.png b/packages/sessions/assets/add-plugin.png
deleted file mode 100644
index 660a1b631..000000000
Binary files a/packages/sessions/assets/add-plugin.png and /dev/null differ
diff --git a/packages/sessions/assets/approve.png b/packages/sessions/assets/approve.png
deleted file mode 100644
index afdbe2633..000000000
Binary files a/packages/sessions/assets/approve.png and /dev/null differ
diff --git a/packages/sessions/assets/experimental.png b/packages/sessions/assets/experimental.png
deleted file mode 100644
index 7740123ff..000000000
Binary files a/packages/sessions/assets/experimental.png and /dev/null differ
diff --git a/packages/sessions/assets/plugins.png b/packages/sessions/assets/plugins.png
deleted file mode 100644
index aaad815b4..000000000
Binary files a/packages/sessions/assets/plugins.png and /dev/null differ
diff --git a/packages/sessions/assets/settings.png b/packages/sessions/assets/settings.png
deleted file mode 100644
index 4eb77bf8a..000000000
Binary files a/packages/sessions/assets/settings.png and /dev/null differ
diff --git a/packages/sessions/assets/toggle-session.png b/packages/sessions/assets/toggle-session.png
deleted file mode 100644
index 49353b98f..000000000
Binary files a/packages/sessions/assets/toggle-session.png and /dev/null differ
diff --git a/packages/sessions/assets/use-plugin.png b/packages/sessions/assets/use-plugin.png
deleted file mode 100644
index 72733d994..000000000
Binary files a/packages/sessions/assets/use-plugin.png and /dev/null differ
diff --git a/packages/sessions/package.json b/packages/sessions/package.json
deleted file mode 100644
index b8408102c..000000000
--- a/packages/sessions/package.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "name": "@argent/x-sessions",
- "version": "5.2.0",
- "description": "Manage sessions for Argent X wallets",
- "keywords": [
- "starknet",
- "starkware",
- "sessions",
- "session",
- "argent",
- "argentx",
- "wallet",
- "dapp"
- ],
- "author": "Janek Rahrt ",
- "homepage": "https://github.com/argentlabs/argent-x/tree/main/packages/sessions#readme",
- "license": "MIT",
- "type": "module",
- "exports": {
- ".": {
- "import": "./dist/sessions.js",
- "require": "./dist/sessions.umd.cjs"
- }
- },
- "main": "./dist/sessions.umd.cjs",
- "module": "./dist/sessions.js",
- "types": "./dist/sessions.d.ts",
- "files": [
- "dist"
- ],
- "publishConfig": {
- "registry": "https://registry.npmjs.org"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/argentlabs/argent-x.git"
- },
- "scripts": {
- "test": "vitest run",
- "test:watch": "vitest",
- "dev": "vite build --watch",
- "prepare": "vite build",
- "build": "vite build"
- },
- "bugs": {
- "url": "https://github.com/argentlabs/argent-x/issues"
- },
- "devDependencies": {
- "@rollup/plugin-node-resolve": "^15.0.0",
- "@types/minimalistic-assert": "^1.0.1",
- "happy-dom": "^8.1.0",
- "vite": "^4.0.3",
- "vite-plugin-dts": "^1.4.1",
- "vitest": "^0.27.1"
- },
- "dependencies": {
- "minimalistic-assert": "^1.0.1",
- "starknet": "^4.19.3"
- }
-}
diff --git a/packages/sessions/src/account.ts b/packages/sessions/src/account.ts
deleted file mode 100644
index f93d9c4c6..000000000
--- a/packages/sessions/src/account.ts
+++ /dev/null
@@ -1,204 +0,0 @@
-import assert from "minimalistic-assert"
-import {
- Abi,
- Account,
- AccountInterface,
- Call,
- EstimateFee,
- EstimateFeeDetails,
- InvocationsDetails,
- InvocationsSignerDetails,
- InvokeFunctionResponse,
- KeyPair,
- ProviderInterface,
- ProviderOptions,
- SignerInterface,
- constants,
- hash,
- merkle,
- number,
- stark,
- transaction,
-} from "starknet"
-
-import {
- SESSION_PLUGIN_CLASS_HASH,
- SignedSession,
- createMerkleTreeForPolicies,
- preparePolicy,
-} from "./utils"
-
-export class SessionAccount extends Account implements AccountInterface {
- public merkleTree: merkle.MerkleTree
-
- constructor(
- providerOrOptions: ProviderOptions | ProviderInterface,
- address: string,
- keyPairOrSigner: KeyPair | SignerInterface,
- public signedSession: SignedSession,
- ) {
- super(providerOrOptions, address, keyPairOrSigner)
- this.merkleTree = createMerkleTreeForPolicies(signedSession.policies)
- assert(signedSession.root === this.merkleTree.root, "Invalid session")
- }
-
- private async sessionToCall(
- session: SignedSession,
- proofs: string[][],
- ): Promise {
- return {
- contractAddress: this.address,
- entrypoint: "use_plugin",
- calldata: stark.compileCalldata({
- classHash: SESSION_PLUGIN_CLASS_HASH,
- signer: await this.signer.getPubKey(),
- expires: session.expires.toString(),
- root: session.root,
- proofLength: proofs[0].length.toString(),
- ...proofs.reduce(
- (acc, proof, i) => ({
- ...acc,
- ...proof.reduce(
- (acc2, path, j) => ({ ...acc2, [`proof${i}:${j}`]: path }),
- {},
- ),
- }),
- {},
- ),
-
- token1: session.signature[0],
- token2: session.signature[1],
- }),
- }
- }
-
- private proofCalls(calls: Call[]): string[][] {
- return calls.map((call) => {
- const leaf = preparePolicy({
- contractAddress: call.contractAddress,
- selector: call.entrypoint,
- })
- return this.merkleTree.getProof(leaf)
- })
- }
-
- private async extendCallsBySession(
- calls: Call[],
- session: SignedSession,
- ): Promise {
- const proofs = this.proofCalls(calls)
- const pluginCall = await this.sessionToCall(session, proofs)
- return [pluginCall, ...calls]
- }
-
- public async estimateInvokeFee(
- calls: Call | Call[],
- { nonce: providedNonce, blockIdentifier }: EstimateFeeDetails = {},
- ): Promise {
- const transactions = await this.extendCallsBySession(
- Array.isArray(calls) ? calls : [calls],
- this.signedSession,
- )
- const nonce = number.toBN(providedNonce ?? (await this.getNonce()))
- const version = number.toBN(hash.feeTransactionVersion)
- const chainId = await this.getChainId()
-
- const signerDetails: InvocationsSignerDetails = {
- walletAddress: this.address,
- nonce: number.toBN(nonce),
- maxFee: constants.ZERO,
- version,
- chainId,
- }
-
- const signature = await this.signer.signTransaction(
- transactions,
- signerDetails,
- )
-
- const calldata = transaction.fromCallsToExecuteCalldata(transactions)
- const response = await super.getInvokeEstimateFee(
- {
- contractAddress: this.address,
- calldata,
- signature,
- },
- { version, nonce },
- blockIdentifier,
- )
-
- const suggestedMaxFee = stark.estimatedFeeToMaxFee(response.overall_fee)
-
- return {
- ...response,
- suggestedMaxFee,
- }
- }
-
- /**
- * Invoke execute function in account contract
- *
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
- *
- * @param calls - one or more calls to be executed
- * @param abis - one or more abis which can be used to display the calls
- * @param transactionsDetail - optional transaction details
- * @returns a confirmation of invoking a function on the starknet contract
- */
- public async execute(
- calls: Call | Call[],
- abis: Abi[] | undefined = undefined,
- transactionsDetail: InvocationsDetails = {},
- ): Promise {
- const transactions = await this.extendCallsBySession(
- Array.isArray(calls) ? calls : [calls],
- this.signedSession,
- )
- const nonce = number.toBN(
- transactionsDetail.nonce ?? (await this.getNonce()),
- )
- let maxFee: number.BigNumberish = "0"
- if (transactionsDetail.maxFee || transactionsDetail.maxFee === 0) {
- maxFee = transactionsDetail.maxFee
- } else {
- const { suggestedMaxFee } = await this.estimateInvokeFee(
- Array.isArray(calls) ? calls : [calls],
- {
- nonce,
- },
- )
- maxFee = suggestedMaxFee.toString()
- }
-
- const version = number.toBN(hash.transactionVersion)
-
- const signerDetails: InvocationsSignerDetails = {
- walletAddress: this.address,
- nonce,
- maxFee,
- version,
- chainId: this.chainId,
- }
-
- const signature = await this.signer.signTransaction(
- transactions,
- signerDetails,
- abis,
- )
-
- const calldata = transaction.fromCallsToExecuteCalldata(transactions)
-
- return this.invokeFunction(
- {
- contractAddress: this.address,
- calldata,
- signature,
- },
- {
- maxFee,
- version,
- nonce,
- },
- )
- }
-}
diff --git a/packages/sessions/src/main.ts b/packages/sessions/src/main.ts
deleted file mode 100644
index 0571dce3e..000000000
--- a/packages/sessions/src/main.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from "./utils"
-export { SessionAccount } from "./account"
-export { SessionAccount as default } from "./account"
diff --git a/packages/sessions/src/utils.ts b/packages/sessions/src/utils.ts
deleted file mode 100644
index ea12c3aa0..000000000
--- a/packages/sessions/src/utils.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-import {
- AccountInterface,
- ProviderInterface,
- Signature,
- hash,
- merkle,
- number,
- stark,
- typedData,
-} from "starknet"
-
-export interface Policy {
- contractAddress: string
- selector: string
-}
-
-export interface RequestSession {
- key: string
- expires: number
- policies: Policy[]
-}
-
-export interface PreparedSession extends RequestSession {
- root: string
-}
-
-export interface SignedSession extends PreparedSession {
- signature: Signature
-}
-
-export const SESSION_PLUGIN_CLASS_HASH =
- "0x31c70ed28f4b0faf39b2f97d8f0a61a36968319c13fe6f2051b8de5a15f3d9b"
-
-// H(Policy(contractAddress:felt,selector:selector))
-const POLICY_TYPE_HASH =
- "0x2f0026e78543f036f33e26a8f5891b88c58dc1e20cbbfaf0bb53274da6fa568"
-
-export async function supportsSessions(
- address: string,
- provider: ProviderInterface,
-): Promise {
- const { result } = await provider.callContract({
- contractAddress: address,
- entrypoint: "isPlugin",
- calldata: stark.compileCalldata({ classHash: SESSION_PLUGIN_CLASS_HASH }),
- })
- return !number.toBN(result[0]).isZero()
-}
-
-export function preparePolicy({ contractAddress, selector }: Policy): string {
- return hash.computeHashOnElements([
- POLICY_TYPE_HASH,
- contractAddress,
- typedData.prepareSelector(selector),
- ])
-}
-
-export function createMerkleTreeForPolicies(
- policies: Policy[],
-): merkle.MerkleTree {
- return new merkle.MerkleTree(policies.map(preparePolicy))
-}
-
-export function prepareSession(session: RequestSession): PreparedSession {
- const { root } = createMerkleTreeForPolicies(session.policies)
- return { ...session, root }
-}
-
-export async function createSession(
- session: RequestSession,
- account: AccountInterface,
-): Promise {
- const { expires, key, policies, root } = prepareSession(session)
- const signature = await account.signMessage({
- primaryType: "Session",
- types: {
- Policy: [
- { name: "contractAddress", type: "felt" },
- { name: "selector", type: "selector" },
- ],
- Session: [
- { name: "key", type: "felt" },
- { name: "expires", type: "felt" },
- { name: "root", type: "merkletree", contains: "Policy" },
- ],
- StarkNetDomain: [{ name: "chainId", type: "felt" }],
- },
- domain: {
- chainId: account.chainId,
- },
- message: {
- key,
- expires,
- root: policies, // we can pass the policy to the message, when argent x works with type merkletree (starknet.js update)
- },
- })
- return {
- key,
- policies,
- expires,
- root,
- signature,
- }
-}
diff --git a/packages/sessions/tsconfig.json b/packages/sessions/tsconfig.json
deleted file mode 100644
index ce50f5a64..000000000
--- a/packages/sessions/tsconfig.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "compilerOptions": {
- "target": "ES2020",
- "useDefineForClassFields": true,
- "module": "ESNext",
- "lib": ["ESNext", "DOM"],
- "moduleResolution": "Node",
- "strict": true,
- "sourceMap": true,
- "resolveJsonModule": true,
- "isolatedModules": true,
- "esModuleInterop": true,
- "declaration": true,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "noImplicitReturns": true,
- "skipLibCheck": true
- },
- "include": ["src"]
-}
diff --git a/packages/sessions/vite.config.ts b/packages/sessions/vite.config.ts
deleted file mode 100644
index 8736b42b4..000000000
--- a/packages/sessions/vite.config.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-// vite.config.js
-import { resolve as resolvePath } from "path"
-
-import dts from "vite-plugin-dts"
-import { defineConfig } from "vitest/config"
-
-export default defineConfig({
- build: {
- rollupOptions: {
- external: ["starknet"],
- output: {
- exports: "named",
- },
- },
- emptyOutDir: false,
- lib: {
- entry: resolvePath(__dirname, "src/main.ts"),
- name: "sessions",
- // the proper extensions will be added
- fileName: "sessions",
- },
- },
- optimizeDeps: {
- include: ["starknet"],
- },
- plugins: [
- dts({
- entryRoot: resolvePath(__dirname, "src"),
- insertTypesEntry: true,
- }),
- ],
- test: {
- environment: "happy-dom",
- exclude: ["**/node_modules/**", "**/*.mock.ts"],
- coverage: {
- exclude: ["**/node_modules/**", "**/*.mock.ts"],
- },
- },
-})
diff --git a/yarn.lock b/yarn.lock
index ecc1d7ca1..6debcac84 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7458,11 +7458,6 @@
resolved "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz"
integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==
-"@types/minimalistic-assert@^1.0.1":
- version "1.0.1"
- resolved "https://registry.npmjs.org/@types/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz"
- integrity sha512-LjFxDeQtgj+MYOOFuV+BILc/w9ryfxd2eNLF0oJdOBud+xCj80ZAEkAwt6y0qx81QMZ632yAaWdvIMjEK2HcmA==
-
"@types/minimatch@*":
version "5.1.2"
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz"