Skip to content

Commit 3aac958

Browse files
authored
Merge pull request #37 from argentlabs/fix/EFO-network
Fix/efo network
2 parents f0a5dcf + b625daa commit 3aac958

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ const { contractAddress, entrypoint, calldata } =
227227
sessionKey,
228228
calls: [transferCallData],
229229
argentSessionServiceUrl: ARGENT_SESSION_SERVICE_BASE_URL
230+
network // values "mainnet" | "sepolia", default to "mainnet"
230231
})
231232

232233
const { signature, outsideExecutionTypedData } =
@@ -235,5 +236,6 @@ const { signature, outsideExecutionTypedData } =
235236
sessionKey,
236237
calls: [transferCallData],
237238
argentSessionServiceUrl: ARGENT_SESSION_SERVICE_BASE_URL
239+
network // values "mainnet" | "sepolia", default to "mainnet"
238240
})
239241
```

src/SessionAccount.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ProviderInterface,
66
} from "starknet"
77
import { Session } from "./session.types"
8+
import { Network } from "./outsideExecution.types"
89

910
export interface GetAccountWithSessionSignerParams {
1011
provider: ProviderInterface
@@ -20,4 +21,5 @@ export interface GetSessionSignatureForTransactionParams {
2021
accountAddress: string
2122
invocationSignerDetails: InvocationsSignerDetails
2223
cacheAuthorisation: boolean
24+
network?: Network
2325
}

src/argentBackendUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
SessionKey,
2323
} from "./session.types"
2424
import { getSessionTypedData } from "./utils"
25+
import { Network } from "./outsideExecution.types"
2526

2627
interface ArgentSignTxAndSessionParams {
2728
sessionKey: SessionKey
@@ -154,6 +155,7 @@ interface ArgentSignSessionEFOParams {
154155
sessionSignature: bigint[]
155156
cacheAuthorisation: boolean
156157
chainId: constants.StarknetChainId
158+
network?: Network
157159
}
158160

159161
export const argentSignSessionEFO = async ({
@@ -166,6 +168,7 @@ export const argentSignSessionEFO = async ({
166168
sessionSignature,
167169
cacheAuthorisation,
168170
chainId,
171+
network = "mainnet",
169172
}: ArgentSignSessionEFOParams): Promise<ArgentServiceSignatureResponse> => {
170173
const sessionMessageHash = typedData.getMessageHash(
171174
getSessionTypedData(sessionTokenToSign, chainId),
@@ -193,6 +196,7 @@ export const argentSignSessionEFO = async ({
193196
accountAddress,
194197
chain: "starknet",
195198
message: currentTypedData,
199+
network,
196200
}
197201

198202
const body = {

src/outsideExecution.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export const createOutsideExecutionCall = async ({
129129
calls,
130130
outsideExecutionParams,
131131
argentSessionServiceUrl = ARGENT_SESSION_SERVICE_BASE_URL,
132+
network = "mainnet",
132133
}: CreateOutsideExecutionCallParams): Promise<Call> => {
133134
const { caller, execute_after, execute_before, nonce, version } =
134135
outsideExecutionParams || {}
@@ -154,6 +155,7 @@ export const createOutsideExecutionCall = async ({
154155
outsideExecutionTypedData,
155156
cacheAuthorisation,
156157
calls,
158+
network,
157159
})
158160

159161
return {
@@ -173,6 +175,7 @@ export const createOutsideExecutionCall = async ({
173175
* @param {Array<Call>} params.calls - The array of calls to be executed.
174176
* @param {OutsideExecutionParams} params.outsideExecutionParams - The parameters for the outside execution.
175177
* @param {string} [params.argentSessionServiceUrl=ARGENT_SESSION_SERVICE_BASE_URL] - The URL of the Argent session service.
178+
* @param {string} params.network - The network on which the execution is taking place.
176179
*
177180
* @returns {Promise<{ outsideExecutionTypedData: OutsideExecutionTypedData, signature: string }>} The typed data for the outside execution and the signature.
178181
*/
@@ -183,6 +186,7 @@ export const createOutsideExecutionTypedData = async ({
183186
calls,
184187
outsideExecutionParams,
185188
argentSessionServiceUrl = ARGENT_SESSION_SERVICE_BASE_URL,
189+
network = "mainnet",
186190
}: CreateOutsideExecutionTypedData) => {
187191
const { caller, execute_after, execute_before, nonce, version } =
188192
outsideExecutionParams || {}
@@ -208,6 +212,7 @@ export const createOutsideExecutionTypedData = async ({
208212
outsideExecutionTypedData,
209213
session,
210214
sessionKey,
215+
network,
211216
})
212217

213218
return {
@@ -249,6 +254,7 @@ export const buildOutsideExecutionTypedData = ({
249254
* @param {string} [params.argentSessionServiceUrl=ARGENT_SESSION_SERVICE_BASE_URL] - The URL of the Argent session service.
250255
* @param {boolean} [params.cacheAuthorisation=false] - Flag indicating whether to cache the authorisation.
251256
* @param {Array<Call>} params.calls - The array of calls to be executed.
257+
* @param {string} params.network - The network on which the execution is taking place.
252258
*
253259
* @returns {Promise<ArraySignatureType>} The signature.
254260
*/
@@ -259,6 +265,7 @@ export const signOutsideExecution = async ({
259265
argentSessionServiceUrl = ARGENT_SESSION_SERVICE_BASE_URL,
260266
cacheAuthorisation = false,
261267
calls,
268+
network = "mainnet",
262269
}: SignOutsideExecutionParams): Promise<ArraySignatureType> => {
263270
const sessionRequest: OffChainSession = {
264271
expires_at: session.expiresAt,
@@ -295,6 +302,7 @@ export const signOutsideExecution = async ({
295302
sessionSignature,
296303
cacheAuthorisation,
297304
chainId: session.chainId,
305+
network,
298306
})
299307

300308
const sessionToken = await compileSessionTokenHelper(

src/outsideExecution.types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Session, SessionKey } from "dist/sessionTypes"
1+
import { Session, SessionKey } from "./session.types"
22
import {
33
ArraySignatureType,
44
BigNumberish,
@@ -8,6 +8,8 @@ import {
88
TypedData,
99
} from "starknet"
1010

11+
export type Network = "mainnet" | "sepolia"
12+
1113
export interface OutsideExecution {
1214
caller: string
1315
nonce: num.BigNumberish
@@ -42,6 +44,7 @@ export interface CreateOutsideExecutionCallParams {
4244
cacheAuthorisation?: boolean
4345
calls: Call[]
4446
outsideExecutionParams?: OutsideExecutionParams
47+
network?: Network
4548
}
4649

4750
export interface BuildOutsideExecutionTypedDataParams {
@@ -57,6 +60,7 @@ export interface CreateOutsideExecutionTypedData {
5760
cacheAuthorisation?: boolean
5861
calls: Call[]
5962
outsideExecutionParams?: OutsideExecutionParams
63+
network?: Network
6064
}
6165

6266
export interface SignOutsideExecutionParams {
@@ -66,4 +70,5 @@ export interface SignOutsideExecutionParams {
6670
outsideExecutionTypedData: TypedData
6771
cacheAuthorisation?: boolean
6872
calls: Call[]
73+
network?: Network
6974
}

0 commit comments

Comments
 (0)