Skip to content

Commit f2d3e96

Browse files
committed
wip
1 parent 31a9c63 commit f2d3e96

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

CoqOfRust/ink/ink_env.v

+48-5
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ Module types.
140140
End CodecAsType.
141141

142142
Module Environment.
143+
Print parity_scale_codec.codec.Codec.Trait.
144+
145+
Class Boxed_Codec (Self : Set) : Type := {
146+
Encode :: parity_scale_codec.codec.Encode.Trait Self;
147+
Decode :: parity_scale_codec.codec.Decode.Trait Self;
148+
Main :: parity_scale_codec.codec.Codec.Trait Self;
149+
}.
150+
151+
Global Instance Boxed_Codec_from_Codec (Self : Set)
152+
`{parity_scale_codec.codec.Codec.Trait Self} :
153+
Boxed_Codec Self := {
154+
Encode := _;
155+
Decode := _;
156+
Main := _;
157+
}.
158+
143159
Class Trait (Self : Set) : Type := {
144160
MAX_EVENT_TOPICS `{H' : State.Trait} : usize;
145161
AccountId : Set;
@@ -156,6 +172,7 @@ Module types.
156172
`(core.convert.AsRef.Trait AccountId (T := Slice u8))
157173
`(core.convert.AsMut.Trait AccountId (T := Slice u8)),
158174
unit;
175+
AccountId_is_Codec :: Boxed_Codec AccountId;
159176
Balance : Set;
160177
_
161178
:
@@ -216,15 +233,27 @@ Module types.
216233
unit;
217234
ChainExtension : Set;
218235
}.
236+
237+
Definition fn_requiring_encode (T : Set)
238+
`{parity_scale_codec.codec.Encode.Trait T} :
239+
unit :=
240+
tt.
241+
242+
Global Instance Method_AccountId `(Trait)
243+
: Notation.DoubleColonType Self "AccountId" := {
244+
Notation.double_colon_type := AccountId;
245+
}.
246+
247+
Definition calling_fn (Env : Set) `{Trait Env} : unit :=
248+
fn_requiring_encode (Env::type["AccountId"]).
219249

250+
Set Printing All.
251+
Print calling_fn.
252+
220253
Global Instance Method_MAX_EVENT_TOPICS `{H' : State.Trait} `(Trait)
221254
: Notation.Dot "MAX_EVENT_TOPICS" := {
222255
Notation.dot := MAX_EVENT_TOPICS;
223256
}.
224-
Global Instance Method_AccountId `(Trait)
225-
: Notation.DoubleColonType Self "AccountId" := {
226-
Notation.double_colon_type := AccountId;
227-
}.
228257
Global Instance Method_Balance `(Trait)
229258
: Notation.DoubleColonType Self "Balance" := {
230259
Notation.double_colon_type := Balance;
@@ -449,7 +478,21 @@ Module contract.
449478
Notation.double_colon_type := Env;
450479
}.
451480
End ContractEnv.
452-
481+
482+
Print ContractEnv.Trait.
483+
484+
Module ContractEnvBis.
485+
Class Trait (Self : Set) : Type := {
486+
Env : Set;
487+
Environment_for_Env :: ink_env.types.Environment.Trait Env;
488+
}.
489+
490+
Global Instance Method_Env `(Trait)
491+
: Notation.DoubleColonType Self "Env" := {
492+
Notation.double_colon_type := Env;
493+
}.
494+
End ContractEnvBis.
495+
453496
Module ContractReference.
454497
Class Trait (Self : Set) : Type := {
455498
Type_ : Set;

0 commit comments

Comments
 (0)