Skip to content

Commit

Permalink
fix: basic allowance
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Lee committed Feb 13, 2022
1 parent 69a9673 commit 55d308b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions terra_sdk/core/feegrant/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def to_amino(self) -> dict:
return {
"type": self.type_amino,
"value": {
"spend_limit": self.spend_limit.to_amino(),
"expiration": to_isoformat(self.expiration)
"spend_limit": self.spend_limit.to_amino() if self.spend_limit else None,
"expiration": to_isoformat(self.expiration) if self.expiration else None
}
}

def to_data(self) -> dict:
return {
"spend_limit": self.spend_limit.to_data(),
"expiration": to_isoformat(self.expiration)
"spend_limit": self.spend_limit.to_data() if self.spend_limit else None,
"expiration": to_isoformat(self.expiration) if self.expiration else None
}

@classmethod
Expand All @@ -56,12 +56,13 @@ def from_data(cls, data: dict) -> BasicAllowance:
exp = data.get("expiration")
return cls(
spend_limit=Coins.from_data(sl) if sl else None,
expiration=exp
expiration=exp if exp else None
)

def to_proto(self) -> BasicAllowance_pb:
return BasicAllowance_pb(
spend_limit=self.spend_limit.to_proto(), expiration=self.expiration
spend_limit=self.spend_limit.to_proto() if self.spend_limit else [],
expiration=self.expiration
)


Expand Down

0 comments on commit 55d308b

Please sign in to comment.