Skip to content

Commit

Permalink
Updated type registry
Browse files Browse the repository at this point in the history
Throw exception if no more scale-bytes available
  • Loading branch information
Arjan Zijderveld committed Mar 20, 2020
1 parent c1c474c commit a5ef5b5
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 5 deletions.
4 changes: 4 additions & 0 deletions scalecodec/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ def decode(self, check_remaining=True):
if check_remaining and self.data.offset != self.data.length:
raise RemainingScaleBytesNotEmptyException('Current offset: {} / length: {}'.format(self.data.offset, self.data.length))

if self.data.offset > self.data.length:
raise RemainingScaleBytesNotEmptyException(
'No more bytes available (offset: {} / length: {})'.format(self.data.offset, self.data.length))

return self.value

def __str__(self):
Expand Down
22 changes: 19 additions & 3 deletions scalecodec/type_registry/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
["balance", "Balance"]
]
},
"(BalanceOf<T, I>, BidKind<AccountId, BalanceOf<T, I>>)": {
"type": "struct",
"type_mapping": [
["balance", "Balance"],
["bidkind", "BidKind"]
]
},
"RefCount": "u8",
"Moment": "u64",
"AccountData": {
Expand Down Expand Up @@ -67,8 +74,7 @@
"type_mapping": [
["id", "LockIdentifier"],
["amount", "Balance"],
["until", "BlockNumber"],
["reasons", "WithdrawReasons"]
["reasons", "Reasons"]
]
},
"FullIdentification": {
Expand Down Expand Up @@ -401,7 +407,8 @@
["stash", "AccountId"],
["total", "Compact<Balance>"],
["active", "Compact<Balance>"],
["unlocking", "Vec<UnlockChunk<Balance>>"]
["unlocking", "Vec<UnlockChunk<Balance>>"],
["lastReward", "Option<EraIndex>"]
]
},
"SubId": "u32",
Expand Down Expand Up @@ -522,6 +529,7 @@
"type_mapping": [
["spanIndex", "SpanIndex"],
["lastStart", "EraIndex"],
["lastNonzeroSlash", "EraIndex"],
["prior", "Vec<EraIndex>"]
]
},
Expand Down Expand Up @@ -617,6 +625,7 @@
]
},
"BidKind<AccountId,Balance>": "Bidkind",
"BidKind<AccountId, BalanceOf<T, I>>": "Bidkind",
"Bid": {
"type": "struct",
"type_mapping": [
Expand Down Expand Up @@ -677,6 +686,13 @@
["Deploy", "IncomingParachainDeploy"]
]
},
"LastRuntimeUpgradeInfo": {
"type": "struct",
"type_mapping": [
["specVersion", "Compact<u32>"],
["specName", "Bytes"]
]
},
"ProxyState": {
"type": "struct",
"type_mapping": [
Expand Down
67 changes: 65 additions & 2 deletions scalecodec/type_registry/kusama.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,79 @@
}
}
},
{
"runtime_range": [1019, 1042],
"types": {
"SlashingSpans": {
"type": "struct",
"type_mapping": [
["spanIndex", "SpanIndex"],
["lastStart", "EraIndex"],
["prior", "Vec<EraIndex>"]
]
}
}
},
{
"runtime_range": [1043, null],
"types": {
"SlashingSpans": {
"type": "struct",
"type_mapping": [
["spanIndex", "SpanIndex"],
["lastStart", "EraIndex"],
["lastNonzeroSlash", "EraIndex"],
["prior", "Vec<EraIndex>"]
]
}
}
},
{
"runtime_range": [1019, 1045],
"types": {
"Address": "RawAddress"
"Address": "RawAddress",
"StakingLedger<AccountId, BalanceOf>": {
"type": "struct",
"type_mapping": [
["stash", "AccountId"],
["total", "Compact<Balance>"],
["active", "Compact<Balance>"],
["unlocking", "Vec<UnlockChunk<Balance>>"]
]
},
"BalanceLock": {
"type": "struct",
"type_mapping": [
["id", "LockIdentifier"],
["amount", "Balance"],
["until", "BlockNumber"],
["reasons", "WithdrawReasons"]
]
}
}
},
{
"runtime_range": [1050, null],
"types": {
"Address": "AccountIdAddress"
"Address": "AccountIdAddress",
"StakingLedger<AccountId, BalanceOf>": {
"type": "struct",
"type_mapping": [
["stash", "AccountId"],
["total", "Compact<Balance>"],
["active", "Compact<Balance>"],
["unlocking", "Vec<UnlockChunk<Balance>>"],
["lastReward", "Option<EraIndex>"]
]
},
"BalanceLock": {
"type": "struct",
"type_mapping": [
["id", "LockIdentifier"],
["amount", "Balance"],
["reasons", "Reasons"]
]
}
}
}

Expand Down

0 comments on commit a5ef5b5

Please sign in to comment.