Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
clarus committed Oct 6, 2023
1 parent 31a9c63 commit f2d3e96
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions CoqOfRust/ink/ink_env.v
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ Module types.
End CodecAsType.

Module Environment.
Print parity_scale_codec.codec.Codec.Trait.

Class Boxed_Codec (Self : Set) : Type := {
Encode :: parity_scale_codec.codec.Encode.Trait Self;
Decode :: parity_scale_codec.codec.Decode.Trait Self;
Main :: parity_scale_codec.codec.Codec.Trait Self;
}.

Global Instance Boxed_Codec_from_Codec (Self : Set)
`{parity_scale_codec.codec.Codec.Trait Self} :
Boxed_Codec Self := {
Encode := _;
Decode := _;
Main := _;
}.

Class Trait (Self : Set) : Type := {
MAX_EVENT_TOPICS `{H' : State.Trait} : usize;
AccountId : Set;
Expand All @@ -156,6 +172,7 @@ Module types.
`(core.convert.AsRef.Trait AccountId (T := Slice u8))
`(core.convert.AsMut.Trait AccountId (T := Slice u8)),
unit;
AccountId_is_Codec :: Boxed_Codec AccountId;
Balance : Set;
_
:
Expand Down Expand Up @@ -216,15 +233,27 @@ Module types.
unit;
ChainExtension : Set;
}.

Definition fn_requiring_encode (T : Set)
`{parity_scale_codec.codec.Encode.Trait T} :
unit :=
tt.

Global Instance Method_AccountId `(Trait)
: Notation.DoubleColonType Self "AccountId" := {
Notation.double_colon_type := AccountId;
}.

Definition calling_fn (Env : Set) `{Trait Env} : unit :=
fn_requiring_encode (Env::type["AccountId"]).

Set Printing All.
Print calling_fn.

Global Instance Method_MAX_EVENT_TOPICS `{H' : State.Trait} `(Trait)
: Notation.Dot "MAX_EVENT_TOPICS" := {
Notation.dot := MAX_EVENT_TOPICS;
}.
Global Instance Method_AccountId `(Trait)
: Notation.DoubleColonType Self "AccountId" := {
Notation.double_colon_type := AccountId;
}.
Global Instance Method_Balance `(Trait)
: Notation.DoubleColonType Self "Balance" := {
Notation.double_colon_type := Balance;
Expand Down Expand Up @@ -449,7 +478,21 @@ Module contract.
Notation.double_colon_type := Env;
}.
End ContractEnv.


Print ContractEnv.Trait.

Module ContractEnvBis.
Class Trait (Self : Set) : Type := {
Env : Set;
Environment_for_Env :: ink_env.types.Environment.Trait Env;
}.

Global Instance Method_Env `(Trait)
: Notation.DoubleColonType Self "Env" := {
Notation.double_colon_type := Env;
}.
End ContractEnvBis.

Module ContractReference.
Class Trait (Self : Set) : Type := {
Type_ : Set;
Expand Down

0 comments on commit f2d3e96

Please sign in to comment.