Skip to content

Commit

Permalink
Merge pull request #37 from argentlabs/fix/EFO-network
Browse files Browse the repository at this point in the history
Fix/efo network
  • Loading branch information
bluecco authored Dec 23, 2024
2 parents f0a5dcf + b625daa commit 3aac958
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ const { contractAddress, entrypoint, calldata } =
sessionKey,
calls: [transferCallData],
argentSessionServiceUrl: ARGENT_SESSION_SERVICE_BASE_URL
network // values "mainnet" | "sepolia", default to "mainnet"
})

const { signature, outsideExecutionTypedData } =
Expand All @@ -235,5 +236,6 @@ const { signature, outsideExecutionTypedData } =
sessionKey,
calls: [transferCallData],
argentSessionServiceUrl: ARGENT_SESSION_SERVICE_BASE_URL
network // values "mainnet" | "sepolia", default to "mainnet"
})
```
2 changes: 2 additions & 0 deletions src/SessionAccount.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ProviderInterface,
} from "starknet"
import { Session } from "./session.types"
import { Network } from "./outsideExecution.types"

export interface GetAccountWithSessionSignerParams {
provider: ProviderInterface
Expand All @@ -20,4 +21,5 @@ export interface GetSessionSignatureForTransactionParams {
accountAddress: string
invocationSignerDetails: InvocationsSignerDetails
cacheAuthorisation: boolean
network?: Network
}
4 changes: 4 additions & 0 deletions src/argentBackendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SessionKey,
} from "./session.types"
import { getSessionTypedData } from "./utils"
import { Network } from "./outsideExecution.types"

interface ArgentSignTxAndSessionParams {
sessionKey: SessionKey
Expand Down Expand Up @@ -154,6 +155,7 @@ interface ArgentSignSessionEFOParams {
sessionSignature: bigint[]
cacheAuthorisation: boolean
chainId: constants.StarknetChainId
network?: Network
}

export const argentSignSessionEFO = async ({
Expand All @@ -166,6 +168,7 @@ export const argentSignSessionEFO = async ({
sessionSignature,
cacheAuthorisation,
chainId,
network = "mainnet",
}: ArgentSignSessionEFOParams): Promise<ArgentServiceSignatureResponse> => {
const sessionMessageHash = typedData.getMessageHash(
getSessionTypedData(sessionTokenToSign, chainId),
Expand Down Expand Up @@ -193,6 +196,7 @@ export const argentSignSessionEFO = async ({
accountAddress,
chain: "starknet",
message: currentTypedData,
network,
}

const body = {
Expand Down
8 changes: 8 additions & 0 deletions src/outsideExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const createOutsideExecutionCall = async ({
calls,
outsideExecutionParams,
argentSessionServiceUrl = ARGENT_SESSION_SERVICE_BASE_URL,
network = "mainnet",
}: CreateOutsideExecutionCallParams): Promise<Call> => {
const { caller, execute_after, execute_before, nonce, version } =
outsideExecutionParams || {}
Expand All @@ -154,6 +155,7 @@ export const createOutsideExecutionCall = async ({
outsideExecutionTypedData,
cacheAuthorisation,
calls,
network,
})

return {
Expand All @@ -173,6 +175,7 @@ export const createOutsideExecutionCall = async ({
* @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.
*/
Expand All @@ -183,6 +186,7 @@ export const createOutsideExecutionTypedData = async ({
calls,
outsideExecutionParams,
argentSessionServiceUrl = ARGENT_SESSION_SERVICE_BASE_URL,
network = "mainnet",
}: CreateOutsideExecutionTypedData) => {
const { caller, execute_after, execute_before, nonce, version } =
outsideExecutionParams || {}
Expand All @@ -208,6 +212,7 @@ export const createOutsideExecutionTypedData = async ({
outsideExecutionTypedData,
session,
sessionKey,
network,
})

return {
Expand Down Expand Up @@ -249,6 +254,7 @@ export const buildOutsideExecutionTypedData = ({
* @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.
*/
Expand All @@ -259,6 +265,7 @@ export const signOutsideExecution = async ({
argentSessionServiceUrl = ARGENT_SESSION_SERVICE_BASE_URL,
cacheAuthorisation = false,
calls,
network = "mainnet",
}: SignOutsideExecutionParams): Promise<ArraySignatureType> => {
const sessionRequest: OffChainSession = {
expires_at: session.expiresAt,
Expand Down Expand Up @@ -295,6 +302,7 @@ export const signOutsideExecution = async ({
sessionSignature,
cacheAuthorisation,
chainId: session.chainId,
network,
})

const sessionToken = await compileSessionTokenHelper(
Expand Down
7 changes: 6 additions & 1 deletion src/outsideExecution.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Session, SessionKey } from "dist/sessionTypes"
import { Session, SessionKey } from "./session.types"
import {
ArraySignatureType,
BigNumberish,
Expand All @@ -8,6 +8,8 @@ import {
TypedData,
} from "starknet"

export type Network = "mainnet" | "sepolia"

export interface OutsideExecution {
caller: string
nonce: num.BigNumberish
Expand Down Expand Up @@ -42,6 +44,7 @@ export interface CreateOutsideExecutionCallParams {
cacheAuthorisation?: boolean
calls: Call[]
outsideExecutionParams?: OutsideExecutionParams
network?: Network
}

export interface BuildOutsideExecutionTypedDataParams {
Expand All @@ -57,6 +60,7 @@ export interface CreateOutsideExecutionTypedData {
cacheAuthorisation?: boolean
calls: Call[]
outsideExecutionParams?: OutsideExecutionParams
network?: Network
}

export interface SignOutsideExecutionParams {
Expand All @@ -66,4 +70,5 @@ export interface SignOutsideExecutionParams {
outsideExecutionTypedData: TypedData
cacheAuthorisation?: boolean
calls: Call[]
network?: Network
}

0 comments on commit 3aac958

Please sign in to comment.