diff --git a/src/connectors/webwallet/constants.ts b/src/connectors/webwallet/constants.ts index ba6d561..7b8c7c6 100644 --- a/src/connectors/webwallet/constants.ts +++ b/src/connectors/webwallet/constants.ts @@ -26,5 +26,3 @@ export const RPC_NODE_URL_TESTNET = export const RPC_NODE_URL_MAINNET = "https://cloud.argent-api.com/v1/starknet/mainnet/rpc/v0.6" - -export const OFFCHAIN_SESSION_ENTRYPOINT = "use_offchain_session" diff --git a/src/connectors/webwallet/helpers/popupSizes.ts b/src/connectors/webwallet/helpers/popupSizes.ts index 6bc46cb..7ac5cb7 100644 --- a/src/connectors/webwallet/helpers/popupSizes.ts +++ b/src/connectors/webwallet/helpers/popupSizes.ts @@ -1,6 +1,3 @@ -export const OFFCHAIN_SESSION_KEYS_EXECUTE_POPUP_WIDTH = 1 -export const OFFCHAIN_SESSION_KEYS_EXECUTE_POPUP_HEIGHT = 1 - /* all these sizes are optimistic */ export const EXECUTE_POPUP_WIDTH = 385 export const EXECUTE_POPUP_HEIGHT = 775 diff --git a/src/connectors/webwallet/starknetWindowObject/argentStarknetWindowObject.ts b/src/connectors/webwallet/starknetWindowObject/argentStarknetWindowObject.ts index 41e6f99..416ce1e 100644 --- a/src/connectors/webwallet/starknetWindowObject/argentStarknetWindowObject.ts +++ b/src/connectors/webwallet/starknetWindowObject/argentStarknetWindowObject.ts @@ -3,10 +3,10 @@ import type { constants } from "starknet" import type { AccountChangeEventHandler, NetworkChangeEventHandler, + RpcTypeToMessageMap, StarknetWindowObject, WalletEvents, } from "starknet-types" -import { OFFCHAIN_SESSION_ENTRYPOINT } from "../constants" import { EXECUTE_POPUP_HEIGHT, EXECUTE_POPUP_WIDTH, @@ -52,10 +52,17 @@ export const getArgentStarknetWindowObject = ( } case "wallet_signTypedData": { + const params = + call.params as RpcTypeToMessageMap["wallet_signTypedData"]["params"] + + const isSession = + params?.primaryType === "Session" && + params?.domain.name === "SessionAccount.session" + setPopupOptions({ width: SIGN_MESSAGE_POPUP_WIDTH, height: SIGN_MESSAGE_POPUP_HEIGHT, - location: "/signMessage", + location: isSession ? "/signSessionKeys" : "/signMessage", }) const data = Array.isArray(call.params) ? call.params : [call.params] return proxyLink.signTypedData.mutate(data as any) @@ -73,18 +80,7 @@ export const getArgentStarknetWindowObject = ( height: EXECUTE_POPUP_HEIGHT, location: "/review", }) - if ( - Array.isArray(calls) && - calls[0] && - calls[0].entrypoint === OFFCHAIN_SESSION_ENTRYPOINT - ) { - setPopupOptions({ - width: 1, - height: 1, - location: "/executeSessionTx", - atLeftBottom: true, - }) - } + const hash = await proxyLink.addInvokeTransaction.mutate(calls) return { transaction_hash: hash } diff --git a/src/window/window.ts b/src/window/window.ts index 1edd879..e26bb54 100644 --- a/src/window/window.ts +++ b/src/window/window.ts @@ -227,40 +227,17 @@ export type IframeMethods = { connect: () => void } -export const OffchainSessionDetailsSchema = z.object({ - nonce: BigNumberishSchema, - maxFee: BigNumberishSchema.optional(), - version: z.string(), -}) - -export type OffchainSessionDetails = z.infer< - typeof OffchainSessionDetailsSchema -> - -const OFFCHAIN_SESSION_ENTRYPOINT = "use_offchain_session" - export const RpcCallSchema = z .object({ contract_address: z.string(), entry_point: z.string(), calldata: z.array(BigNumberishSchema).optional(), - offchainSessionDetails: OffchainSessionDetailsSchema.optional(), }) - .transform( - ({ contract_address, entry_point, calldata, offchainSessionDetails }) => - entry_point === OFFCHAIN_SESSION_ENTRYPOINT - ? { - contractAddress: contract_address, - entrypoint: entry_point, - calldata: calldata || [], - offchainSessionDetails: offchainSessionDetails || undefined, - } - : { - contractAddress: contract_address, - entrypoint: entry_point, - calldata: calldata || [], - }, - ) + .transform(({ contract_address, entry_point, calldata }) => ({ + contractAddress: contract_address, + entrypoint: entry_point, + calldata: calldata || [], + })) export const RpcCallsArraySchema = z.array(RpcCallSchema).nonempty()