Skip to content

Commit 8c8e3e0

Browse files
authored
Merge pull request #46 from argentlabs/fix/tests
fix: failing tests
2 parents f2c4cf3 + 5feae93 commit 8c8e3e0

File tree

2 files changed

+81
-12
lines changed

2 files changed

+81
-12
lines changed

src/__tests__/sessionBackendService.test.ts

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,48 +48,97 @@ describe("ArgentSessionService", () => {
4848
it("should sign the transactions and session and return a argent service signature response", async () => {
4949
const cacheAuthorisation = false
5050

51+
const contractAddress = stark.randomAddress()
52+
5153
const sessionRequest = {
5254
expires_at: 1234567890,
5355
allowed_methods: [
5456
{
55-
"Contract Address": stark.randomAddress(),
57+
"Contract Address": contractAddress,
5658
selector: "set_number_double",
5759
},
5860
],
5961
metadata: JSON.stringify({
6062
projectID: "test",
6163
txFees: [
62-
{ tokenAddress: stark.randomAddress(), maxAmount: "1000000000000" },
64+
{ tokenAddress: contractAddress, maxAmount: "1000000000000" },
6365
],
6466
}),
6567
session_key_guid:
6668
"0x116dcea0b31d06f721c156324cd8de3652bf8953cd5ba055f74db21b1134ec9",
69+
sessionTypedData: undefined as any,
70+
offchainSession: {
71+
expires_at: 1234567890,
72+
allowed_methods: [
73+
{
74+
"Contract Address": contractAddress,
75+
selector: "set_number_double",
76+
},
77+
],
78+
metadata: JSON.stringify({
79+
projectID: "test",
80+
txFees: [
81+
{
82+
tokenAddress: stark.randomAddress(),
83+
maxAmount: "1000000000000",
84+
},
85+
],
86+
}),
87+
session_key_guid:
88+
"0x116dcea0b31d06f721c156324cd8de3652bf8953cd5ba055f74db21b1134ec9",
89+
},
90+
sessionKey: {
91+
publicKey: "",
92+
privateKey: "",
93+
},
6794
}
6895

6996
const sessionTypedData = getSessionTypedData(
7097
sessionRequest,
7198
constants.StarknetChainId.SN_SEPOLIA,
7299
)
73100

101+
sessionRequest.sessionTypedData = sessionTypedData
102+
74103
const sessionPrivateKey = ec.starkCurve.utils.randomPrivateKey()
75104
const sessionPublicKey = ec.starkCurve.getStarkKey(sessionPrivateKey)
76105
const sessionKey: SessionKey = {
77-
privateKey: sessionPrivateKey,
106+
privateKey: sessionPrivateKey.toString(),
78107
publicKey: sessionPublicKey,
79108
}
80109

110+
sessionRequest.sessionKey = sessionKey
111+
81112
const response: ArgentServiceSignatureResponse =
82113
await argentSignTxAndSession({
83114
argentSessionServiceBaseUrl: "http://localhost:3000",
84115
authorisationSignature: ["123", "456"],
85116
sessionKey,
86117
calls: [],
87118
transactionsDetail: {
119+
tip: 1000n,
120+
paymasterData: [],
121+
accountDeploymentData: [],
122+
nonceDataAvailabilityMode: "L2",
123+
feeDataAvailabilityMode: "L2",
124+
resourceBounds: {
125+
l1_data_gas: {
126+
max_amount: 300000n,
127+
max_price_per_unit: 10n,
128+
},
129+
l1_gas: {
130+
max_amount: 300000n,
131+
max_price_per_unit: 10n,
132+
},
133+
l2_gas: {
134+
max_amount: 300000n,
135+
max_price_per_unit: 10n,
136+
},
137+
},
88138
cairoVersion: "1",
89139
chainId: constants.StarknetChainId.SN_SEPOLIA,
90-
maxFee: 1000n,
91140
nonce: 1,
92-
version: "0x2",
141+
version: "0x3",
93142
walletAddress: stark.randomAddress(),
94143
},
95144
sessionTypedData,
@@ -162,7 +211,7 @@ describe("ArgentSessionService", () => {
162211
const sessionPrivateKey = ec.starkCurve.utils.randomPrivateKey()
163212
const sessionPublicKey = ec.starkCurve.getStarkKey(sessionPrivateKey)
164213
const sessionKey: SessionKey = {
165-
privateKey: sessionPrivateKey,
214+
privateKey: sessionPrivateKey.toString(),
166215
publicKey: sessionPublicKey,
167216
}
168217

src/__tests__/sessionDappService.test.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
Account,
33
Call,
44
RpcProvider,
5-
V2InvocationsSignerDetails,
5+
V3InvocationsSignerDetails,
66
constants,
77
ec,
88
stark,
@@ -47,7 +47,7 @@ const accountSessionAddress = "0x123456"
4747
const privateKey = ec.starkCurve.utils.randomPrivateKey()
4848

4949
const sessionKey: SessionKey = {
50-
privateKey,
50+
privateKey: privateKey.toString(),
5151
publicKey: ec.starkCurve.getStarkKey(privateKey),
5252
}
5353

@@ -99,13 +99,33 @@ describe("SessionDappService", () => {
9999
})
100100

101101
it("should signTransaction calling argent session service", async () => {
102-
const invokationDetails: V2InvocationsSignerDetails = {
102+
const walletAddress = stark.randomAddress()
103+
104+
const invokationDetails: V3InvocationsSignerDetails = {
105+
walletAddress,
106+
resourceBounds: {
107+
l1_data_gas: {
108+
max_amount: 300000n,
109+
max_price_per_unit: 10n,
110+
},
111+
l1_gas: {
112+
max_amount: 300000n,
113+
max_price_per_unit: 10n,
114+
},
115+
l2_gas: {
116+
max_amount: 300000n,
117+
max_price_per_unit: 10n,
118+
},
119+
},
103120
cairoVersion: "1",
104121
chainId: constants.StarknetChainId.SN_SEPOLIA,
105-
maxFee: 1000n,
106122
nonce: 1,
107-
version: "0x2",
108-
walletAddress: stark.randomAddress(),
123+
version: "0x3",
124+
tip: 10000n,
125+
paymasterData: [],
126+
accountDeploymentData: [],
127+
nonceDataAvailabilityMode: "L2",
128+
feeDataAvailabilityMode: "L2",
109129
}
110130

111131
const account = new SessionAccount(session, sessionKey)

0 commit comments

Comments
 (0)