25
25
# CONSTANTS
26
26
####################
27
27
28
- const VERSION = '0.2.0' # '0.2.0' = 30 2E 32 2E 30 = 0x302E322E30 = 206933470768
28
+ const VERSION = '0.2.1'
29
29
30
30
const CHANGE_SIGNER_SELECTOR = 1540130945889430637313403138889853410180247761946478946165786566748520529557
31
31
const CHANGE_GUARDIAN_SELECTOR = 1374386526556551464817815908276843861478960435557596145330240747921847320237
@@ -40,13 +40,11 @@ const ESCAPE_SECURITY_PERIOD = 7*24*60*60 # set to e.g. 7 days in prod
40
40
const ESCAPE_TYPE_GUARDIAN = 0
41
41
const ESCAPE_TYPE_SIGNER = 1
42
42
43
- const ERC156_ACCOUNT_INTERFACE = 0xf10dbd44
43
+ const ERC165_ACCOUNT_INTERFACE = 0xf10dbd44
44
44
45
45
const TRUE = 1
46
46
const FALSE = 0
47
47
48
- const PREFIX_TRANSACTION = 'StarkNet Transaction'
49
-
50
48
####################
51
49
# STRUCTS
52
50
####################
@@ -169,6 +167,7 @@ func initialize{
169
167
end
170
168
171
169
@external
170
+ @raw_output
172
171
func __execute__ {
173
172
syscall_ptr: felt *,
174
173
pedersen_ptr: HashBuiltin*,
@@ -181,8 +180,8 @@ func __execute__{
181
180
calldata: felt *,
182
181
nonce: felt
183
182
) -> (
184
- response_len : felt ,
185
- response : felt *
183
+ retdata_size : felt ,
184
+ retdata : felt *
186
185
):
187
186
alloc_locals
188
187
@@ -199,21 +198,18 @@ func __execute__{
199
198
# get the tx info
200
199
let (tx_info) = get_tx_info()
201
200
202
- # compute message hash
203
- let (hash) = hash_multicall(tx_info.account_contract_address, calls_len, calls, nonce, tx_info.max_fee, tx_info.version)
204
-
205
201
if calls_len == 1 :
206
202
if calls[0 ].to == tx_info.account_contract_address:
207
203
tempvar signer_condition = (calls[0 ].selector - ESCAPE_GUARDIAN_SELECTOR) * (calls[0 ].selector - TRIGGER_ESCAPE_GUARDIAN_SELECTOR)
208
204
tempvar guardian_condition = (calls[0 ].selector - ESCAPE_SIGNER_SELECTOR) * (calls[0 ].selector - TRIGGER_ESCAPE_SIGNER_SELECTOR)
209
205
if signer_condition == 0 :
210
206
# validate signer signature
211
- validate_signer_signature(hash , tx_info.signature, tx_info.signature_len)
207
+ validate_signer_signature(tx_info.transaction_hash , tx_info.signature, tx_info.signature_len)
212
208
jmp do_execute
213
209
end
214
210
if guardian_condition == 0 :
215
211
# validate guardian signature
216
- validate_guardian_signature(hash , tx_info.signature, tx_info.signature_len)
212
+ validate_guardian_signature(tx_info.transaction_hash , tx_info.signature, tx_info.signature_len)
217
213
jmp do_execute
218
214
end
219
215
end
@@ -222,8 +218,8 @@ func __execute__{
222
218
assert_no_self_call(tx_info.account_contract_address, calls_len, calls)
223
219
end
224
220
# validate signer and guardian signatures
225
- validate_signer_signature(hash , tx_info.signature, tx_info.signature_len)
226
- validate_guardian_signature(hash , tx_info.signature + 2 , tx_info.signature_len - 2 )
221
+ validate_signer_signature(tx_info.transaction_hash , tx_info.signature, tx_info.signature_len)
222
+ validate_guardian_signature(tx_info.transaction_hash , tx_info.signature + 2 , tx_info.signature_len - 2 )
227
223
228
224
# execute calls
229
225
do_execute:
@@ -234,8 +230,8 @@ func __execute__{
234
230
let (response : felt *) = alloc()
235
231
let (response_len) = execute_list(calls_len, calls, response)
236
232
# emit event
237
- transaction_executed.emit(hash=hash , response_len=response_len, response=response)
238
- return (response_len =response_len, response =response)
233
+ transaction_executed.emit(hash=tx_info.transaction_hash , response_len=response_len, response=response)
234
+ return (retdata_size =response_len, retdata =response)
239
235
end
240
236
241
237
@external
@@ -250,7 +246,7 @@ func upgrade{
250
246
assert_only_self()
251
247
# make sure the target is an account
252
248
with_attr error_message ("implementation invalid" ):
253
- let (success) = IAccount.supportsInterface(contract_address=implementation, interfaceId=ERC156_ACCOUNT_INTERFACE )
249
+ let (success) = IAccount.supportsInterface(contract_address=implementation, interfaceId=ERC165_ACCOUNT_INTERFACE )
254
250
assert success = TRUE
255
251
end
256
252
# change implementation
@@ -506,7 +502,7 @@ func supportsInterface{
506
502
return (TRUE)
507
503
end
508
504
# IAccount
509
- if interfaceId == ERC156_ACCOUNT_INTERFACE :
505
+ if interfaceId == ERC165_ACCOUNT_INTERFACE :
510
506
return (TRUE)
511
507
end
512
508
return (FALSE)
@@ -725,120 +721,6 @@ func execute_list{
725
721
return (response_len + res.retdata_size)
726
722
end
727
723
728
- # @notice Computes the hash of a multicall to the `execute` method.
729
- # @param calls_len The legnth of the array of `Call`
730
- # @param calls A pointer to the array of `Call`
731
- # @param nonce The nonce for the multicall transaction
732
- # @param max_fee The max fee the user is willing to pay for the multicall
733
- # @param version The version of transaction in the Cairo OS. Always set to 0 .
734
- # @return res The hash of the multicall
735
- func hash_multicall {
736
- syscall_ptr: felt *,
737
- pedersen_ptr: HashBuiltin*
738
- } (
739
- account: felt ,
740
- calls_len: felt ,
741
- calls: Call*,
742
- nonce: felt ,
743
- max_fee: felt ,
744
- version: felt
745
- ) -> (res: felt ):
746
- alloc_locals
747
- let (calls_hash) = hash_call_array(calls_len, calls)
748
- let hash_ptr = pedersen_ptr
749
- with hash_ptr:
750
- let (hash_state_ptr) = hash_init()
751
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, PREFIX_TRANSACTION)
752
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, account)
753
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, calls_hash)
754
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, nonce)
755
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, max_fee)
756
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, version)
757
- let (res) = hash_finalize(hash_state_ptr)
758
- let pedersen_ptr = hash_ptr
759
- return (res=res)
760
- end
761
- end
762
-
763
- # @notice Computes the hash of an array of `Call`
764
- # @param calls_len The legnth of the array of `Call`
765
- # @param calls A pointer to the array of `Call`
766
- # @return res The hash of the array of `Call`
767
- func hash_call_array {
768
- pedersen_ptr: HashBuiltin*
769
- } (
770
- calls_len: felt ,
771
- calls: Call*
772
- ) -> (
773
- res: felt
774
- ):
775
- alloc_locals
776
-
777
- let (hash_array : felt *) = alloc()
778
- hash_call_loop(calls_len, calls, hash_array)
779
-
780
- let hash_ptr = pedersen_ptr
781
- with hash_ptr:
782
- let (hash_state_ptr) = hash_init()
783
- let (hash_state_ptr) = hash_update(hash_state_ptr, hash_array, calls_len)
784
- let (res) = hash_finalize(hash_state_ptr)
785
- let pedersen_ptr = hash_ptr
786
- return (res=res)
787
- end
788
- end
789
-
790
- # @notice Turns an array of `Call` into an array of `hash(Call)`
791
- # @param calls_len The legnth of the array of `Call`
792
- # @param calls A pointer to the array of `Call`
793
- # @param hash_array A pointer to the array of `hash(Call)`
794
- func hash_call_loop {
795
- pedersen_ptr: HashBuiltin*
796
- } (
797
- calls_len: felt ,
798
- calls: Call*,
799
- hash_array: felt *
800
- ):
801
- if calls_len == 0 :
802
- return ()
803
- end
804
- let this_call = [calls]
805
- let (calldata_hash) = hash_calldata(this_call.calldata_len, this_call.calldata)
806
- let hash_ptr = pedersen_ptr
807
- with hash_ptr:
808
- let (hash_state_ptr) = hash_init()
809
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, this_call.to)
810
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, this_call.selector)
811
- let (hash_state_ptr) = hash_update_single(hash_state_ptr, calldata_hash)
812
- let (res) = hash_finalize(hash_state_ptr)
813
- let pedersen_ptr = hash_ptr
814
- assert [hash_array] = res
815
- end
816
- hash_call_loop(calls_len - 1 , calls + Call.SIZE , hash_array + 1 )
817
- return ()
818
- end
819
-
820
- # @notice Computes the hash of calldata as an array of felt
821
- # @param calldata_len The length of the calldata array
822
- # @param calldata A pointer to the calldata array
823
- # @return the hash of the calldata
824
- func hash_calldata {
825
- pedersen_ptr: HashBuiltin*
826
- } (
827
- calldata_len: felt ,
828
- calldata: felt *,
829
- ) -> (
830
- res: felt
831
- ):
832
- let hash_ptr = pedersen_ptr
833
- with hash_ptr:
834
- let (hash_state_ptr) = hash_init()
835
- let (hash_state_ptr) = hash_update(hash_state_ptr, calldata, calldata_len)
836
- let (res) = hash_finalize(hash_state_ptr)
837
- let pedersen_ptr = hash_ptr
838
- return (res=res)
839
- end
840
- end
841
-
842
724
func from_call_array_to_call {
843
725
syscall_ptr: felt *
844
726
} (
0 commit comments