UNPKG

@argent/x-sessions

Version:

Manage sessions for Argent X wallets

135 lines (133 loc) 6.05 kB
import { ArraySignatureType, BigNumberish, Call } from 'starknet'; import { BuildOutsideExecutionTypedDataParams, CreateOutsideExecutionCallParams, CreateOutsideExecutionTypedData, OutsideCall, OutsideExecution, SignOutsideExecutionParams } from './outsideExecution.types'; export declare const typesRev1: { StarknetDomain: { name: string; type: string; }[]; OutsideExecution: { name: string; type: string; }[]; Call: { name: string; type: string; }[]; }; export declare function getOutsideCall(call: Call): OutsideCall; export declare function getTypedDataHash(outsideExecution: OutsideExecution, accountAddress: BigNumberish, chainId: string, version?: string): string; export declare const buildOutsideExecution: (calls: Call[], caller?: string, execute_after?: BigNumberish, execute_before?: BigNumberish, nonce?: BigNumberish) => OutsideExecution; /** * Creates the outside call. * * @param {Object} params - The parameters for creating the outside execution typed data. * @param {Session} params.session - The session object containing session details. * @param {string} params.sessionKey - The session key used for authentication. * @param {boolean} params.cacheAuthorisation - Flag indicating whether to cache the authorisation. * @param {Array<Call>} params.calls - The array of calls to be executed. * @param {OutsideExecutionParams} params.outsideExecutionParams - The parameters for the outside execution. * @param {string} [params.argentSessionServiceUrl=ARGENT_SESSION_SERVICE_BASE_URL] - The URL of the Argent session service. * * @returns {Promise<{ outsideExecutionTypedData: OutsideExecutionTypedData, signature: string }>} The typed data for the outside execution and the signature. */ export declare const createOutsideExecutionCall: ({ session, sessionKey, cacheAuthorisation, calls, outsideExecutionParams, argentSessionServiceUrl, network, }: CreateOutsideExecutionCallParams) => Promise<Call>; /** * Creates the typed data for an outside execution and signs it. * * @param {Object} params - The parameters for creating the outside execution typed data. * @param {Session} params.session - The session object containing session details. * @param {string} params.sessionKey - The session key used for authentication. * @param {boolean} params.cacheAuthorisation - Flag indicating whether to cache the authorisation. * @param {Array<Call>} params.calls - The array of calls to be executed. * @param {OutsideExecutionParams} params.outsideExecutionParams - The parameters for the outside execution. * @param {string} [params.argentSessionServiceUrl=ARGENT_SESSION_SERVICE_BASE_URL] - The URL of the Argent session service. * @param {string} params.network - The network on which the execution is taking place. * * @returns {Promise<{ outsideExecutionTypedData: OutsideExecutionTypedData, signature: string }>} The typed data for the outside execution and the signature. */ export declare const createOutsideExecutionTypedData: ({ session, sessionKey, cacheAuthorisation, calls, outsideExecutionParams, argentSessionServiceUrl, network, }: CreateOutsideExecutionTypedData) => Promise<{ outsideExecutionTypedData: { types: { StarknetDomain: { name: string; type: string; }[]; OutsideExecution: { name: string; type: string; }[]; Call: { name: string; type: string; }[]; }; primaryType: string; domain: { name: string; version: string; chainId: string; revision: string; }; message: { Caller: string; Nonce: BigNumberish; "Execute After": BigNumberish; "Execute Before": BigNumberish; Calls: { To: string; Selector: BigNumberish; Calldata: import('starknet').RawArgs; }[]; }; }; signature: ArraySignatureType; }>; export declare const buildOutsideExecutionTypedData: ({ outsideExecution, chainId, version, }: BuildOutsideExecutionTypedDataParams) => { types: { StarknetDomain: { name: string; type: string; }[]; OutsideExecution: { name: string; type: string; }[]; Call: { name: string; type: string; }[]; }; primaryType: string; domain: { name: string; version: string; chainId: string; revision: string; }; message: { Caller: string; Nonce: BigNumberish; "Execute After": BigNumberish; "Execute Before": BigNumberish; Calls: { To: string; Selector: BigNumberish; Calldata: import('starknet').RawArgs; }[]; }; }; /** * Signs the outside execution. * * @param {Object} params - The parameters for signing the outside execution. * @param {Session} params.session - The session object containing session details. * @param {string} params.sessionKey - The session key used for authentication. * @param {TypedData} params.outsideExecutionTypedData - The typed data for the outside execution. * @param {string} [params.argentSessionServiceUrl=ARGENT_SESSION_SERVICE_BASE_URL] - The URL of the Argent session service. * @param {boolean} [params.cacheAuthorisation=false] - Flag indicating whether to cache the authorisation. * @param {Array<Call>} params.calls - The array of calls to be executed. * @param {string} params.network - The network on which the execution is taking place. * * @returns {Promise<ArraySignatureType>} The signature. */ export declare const signOutsideExecution: ({ session, sessionKey, outsideExecutionTypedData, argentSessionServiceUrl, cacheAuthorisation, calls, network, }: SignOutsideExecutionParams) => Promise<ArraySignatureType>;