-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
contract_cost_type.ex
79 lines (65 loc) · 1.82 KB
/
contract_cost_type.ex
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
defmodule StellarBase.XDR.ContractCostType do
@moduledoc """
Automatically generated by xdrgen
DO NOT EDIT or your changes may be overwritten
Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr
Representation of Stellar `ContractCostType` type.
"""
@behaviour XDR.Declaration
@declarations [
WasmInsnExec: 0,
MemAlloc: 1,
MemCpy: 2,
MemCmp: 3,
DispatchHostFunction: 4,
VisitObject: 5,
ValSer: 6,
ValDeser: 7,
ComputeSha256Hash: 8,
ComputeEd25519PubKey: 9,
VerifyEd25519Sig: 10,
VmInstantiation: 11,
VmCachedInstantiation: 12,
InvokeVmFunction: 13,
ComputeKeccak256Hash: 14,
ComputeEcdsaSecp256k1Sig: 15,
RecoverEcdsaSecp256k1Key: 16,
Int256AddSub: 17,
Int256Mul: 18,
Int256Div: 19,
Int256Pow: 20,
Int256Shift: 21,
ChaCha20DrawBytes: 22
]
@enum_spec %XDR.Enum{declarations: @declarations, identifier: nil}
@type t :: %__MODULE__{identifier: atom()}
defstruct [:identifier]
@spec new(type :: atom()) :: t()
def new(type \\ :WasmInsnExec), do: %__MODULE__{identifier: type}
@impl true
def encode_xdr(%__MODULE__{identifier: type}) do
@declarations
|> XDR.Enum.new(type)
|> XDR.Enum.encode_xdr()
end
@impl true
def encode_xdr!(%__MODULE__{identifier: type}) do
@declarations
|> XDR.Enum.new(type)
|> XDR.Enum.encode_xdr!()
end
@impl true
def decode_xdr(bytes, spec \\ @enum_spec)
def decode_xdr(bytes, spec) do
case XDR.Enum.decode_xdr(bytes, spec) do
{:ok, {%XDR.Enum{identifier: type}, rest}} -> {:ok, {new(type), rest}}
error -> error
end
end
@impl true
def decode_xdr!(bytes, spec \\ @enum_spec)
def decode_xdr!(bytes, spec) do
{%XDR.Enum{identifier: type}, rest} = XDR.Enum.decode_xdr!(bytes, spec)
{new(type), rest}
end
end