Skip to content

Commit

Permalink
fix: session
Browse files Browse the repository at this point in the history
  • Loading branch information
janek26 committed Aug 23, 2022
1 parent 0b56833 commit 00269bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
10 changes: 6 additions & 4 deletions src/account/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ import {
import { feeTransactionVersion, transactionVersion } from '../utils/hash';
import { MerkleTree } from '../utils/merkle';
import { BigNumberish, toBN } from '../utils/number';
import { SignedSession, createMerkleTreeForPolicies, preparePolicy } from '../utils/session';
import {
SESSION_PLUGIN_CLASS_HASH,
SignedSession,
createMerkleTreeForPolicies,
preparePolicy,
} from '../utils/session';
import { compileCalldata, estimatedFeeToMaxFee } from '../utils/stark';
import { fromCallsToExecuteCalldataWithNonce } from '../utils/transaction';
import { Account } from './default';
import { AccountInterface } from './interface';

const SESSION_PLUGIN_CLASS_HASH =
'0x6a184757e350de1fe3a544037efbef6434724980a572f294c90555dadc20052';

export class SessionAccount extends Account implements AccountInterface {
public merkleTree: MerkleTree;

Expand Down
14 changes: 4 additions & 10 deletions src/utils/session.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { AccountInterface } from '../account';
import { StarknetChainId } from '../constants';
import { ProviderInterface } from '../provider';
import { Signature } from '../types';
import { computeHashOnElements } from './hash';
Expand Down Expand Up @@ -28,7 +27,8 @@ export interface SignedSession extends PreparedSession {
}

export const SESSION_PLUGIN_CLASS_HASH =
'0x1031d8540af9d984d8d8aa5dff598467008c58b6f6147b7f90fda4b6d8db463';
'0x31c70ed28f4b0faf39b2f97d8f0a61a36968319c13fe6f2051b8de5a15f3d9b';

// H(Policy(contractAddress:felt,selector:selector))
const POLICY_TYPE_HASH = '0x2f0026e78543f036f33e26a8f5891b88c58dc1e20cbbfaf0bb53274da6fa568';

Expand Down Expand Up @@ -74,16 +74,10 @@ export async function createSession(
{ name: 'expires', type: 'felt' },
{ name: 'root', type: 'merkletree', contains: 'Policy' },
],
StarkNetDomain: [
{ name: 'name', type: 'felt' },
{ name: 'version', type: 'felt' },
{ name: 'chainId', type: 'felt' },
],
StarkNetDomain: [{ name: 'chainId', type: 'felt' }],
},
domain: {
name: '0x0',
version: '0x0',
chainId: StarknetChainId.TESTNET,
chainId: account.chainId,
},
message: {
key,
Expand Down

0 comments on commit 00269bf

Please sign in to comment.