-
Notifications
You must be signed in to change notification settings - Fork 316
/
interface.cairo
142 lines (111 loc) · 4.13 KB
/
interface.cairo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts for Cairo v0.11.0 (account/interface.cairo)
use openzeppelin::account::utils::secp256k1::Secp256k1PointSerde;
use starknet::ContractAddress;
use starknet::account::Call;
type EthPublicKey = starknet::secp256k1::Secp256k1Point;
const ISRC6_ID: felt252 = 0x2ceccef7f994940b3962a6c67e0ba4fcd37df7d131417c604f91e03caecc1cd;
//
// Account
//
#[starknet::interface]
trait ISRC6<TState> {
fn __execute__(self: @TState, calls: Array<Call>) -> Array<Span<felt252>>;
fn __validate__(self: @TState, calls: Array<Call>) -> felt252;
fn is_valid_signature(self: @TState, hash: felt252, signature: Array<felt252>) -> felt252;
}
#[starknet::interface]
trait IDeclarer<TState> {
fn __validate_declare__(self: @TState, class_hash: felt252) -> felt252;
}
#[starknet::interface]
trait IDeployable<TState> {
fn __validate_deploy__(
self: @TState, class_hash: felt252, contract_address_salt: felt252, public_key: felt252
) -> felt252;
}
#[starknet::interface]
trait IPublicKey<TState> {
fn get_public_key(self: @TState) -> felt252;
fn set_public_key(ref self: TState, new_public_key: felt252);
}
#[starknet::interface]
trait ISRC6CamelOnly<TState> {
fn isValidSignature(self: @TState, hash: felt252, signature: Array<felt252>) -> felt252;
}
#[starknet::interface]
trait IPublicKeyCamel<TState> {
fn getPublicKey(self: @TState) -> felt252;
fn setPublicKey(ref self: TState, newPublicKey: felt252);
}
//
// Account ABI
//
#[starknet::interface]
trait AccountABI<TState> {
// ISRC6
fn __execute__(self: @TState, calls: Array<Call>) -> Array<Span<felt252>>;
fn __validate__(self: @TState, calls: Array<Call>) -> felt252;
fn is_valid_signature(self: @TState, hash: felt252, signature: Array<felt252>) -> felt252;
// ISRC5
fn supports_interface(self: @TState, interface_id: felt252) -> bool;
// IDeclarer
fn __validate_declare__(self: @TState, class_hash: felt252) -> felt252;
// IDeployable
fn __validate_deploy__(
self: @TState, class_hash: felt252, contract_address_salt: felt252, public_key: felt252
) -> felt252;
// IPublicKey
fn get_public_key(self: @TState) -> felt252;
fn set_public_key(ref self: TState, new_public_key: felt252);
// ISRC6CamelOnly
fn isValidSignature(self: @TState, hash: felt252, signature: Array<felt252>) -> felt252;
// IPublicKeyCamel
fn getPublicKey(self: @TState) -> felt252;
fn setPublicKey(ref self: TState, newPublicKey: felt252);
}
//
// EthAccount
//
#[starknet::interface]
trait IEthDeployable<TState> {
fn __validate_deploy__(
self: @TState, class_hash: felt252, contract_address_salt: felt252, public_key: EthPublicKey
) -> felt252;
}
#[starknet::interface]
trait IEthPublicKey<TState> {
fn get_public_key(self: @TState) -> EthPublicKey;
fn set_public_key(ref self: TState, new_public_key: EthPublicKey);
}
#[starknet::interface]
trait IEthPublicKeyCamel<TState> {
fn getPublicKey(self: @TState) -> EthPublicKey;
fn setPublicKey(ref self: TState, newPublicKey: EthPublicKey);
}
//
// EthAccount ABI
//
#[starknet::interface]
trait EthAccountABI<TState> {
// ISRC6
fn __execute__(self: @TState, calls: Array<Call>) -> Array<Span<felt252>>;
fn __validate__(self: @TState, calls: Array<Call>) -> felt252;
fn is_valid_signature(self: @TState, hash: felt252, signature: Array<felt252>) -> felt252;
// ISRC5
fn supports_interface(self: @TState, interface_id: felt252) -> bool;
// IDeclarer
fn __validate_declare__(self: @TState, class_hash: felt252) -> felt252;
// IEthDeployable
fn __validate_deploy__(
self: @TState, class_hash: felt252, contract_address_salt: felt252, public_key: EthPublicKey
) -> felt252;
// IEthPublicKey
fn get_public_key(self: @TState) -> EthPublicKey;
fn set_public_key(ref self: TState, new_public_key: EthPublicKey);
// ISRC6CamelOnly
fn isValidSignature(self: @TState, hash: felt252, signature: Array<felt252>) -> felt252;
// IEthPublicKeyCamel
fn getPublicKey(self: @TState) -> EthPublicKey;
fn setPublicKey(ref self: TState, newPublicKey: EthPublicKey);
}