-
Notifications
You must be signed in to change notification settings - Fork 458
Update block schema - Closes #6739 #6765
Update block schema - Closes #6739 #6765
Conversation
10d1076
to
89589fc
Compare
if (typeof header !== 'object') { | ||
throw new Error('Invalid block format. header must be an object.'); | ||
} | ||
if (!Array.isArray(payload)) { | ||
throw new Error('Invalid block format. payload must be an array.'); | ||
} | ||
if (!Array.isArray(assets)) { | ||
throw new Error('Invalid block format. assets must be an array.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error('Invalid block format. assets must be an array.'); | |
throw new Error('Invalid block format. assets must be an array.'); |
throw new Error('Invalid block format. assets must be an array.'); | |
throw new Error('Invalid block format. "assets" must be an array.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is following the style of other error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw further below the property name was in double quotes but I'm ok with either way.
…update_block_schema
}, | ||
}; | ||
|
||
export const blockAssetSchema = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be more appropriate if we follow the naming conventions in the LIP.
The LIP defines new block property assets
, and since we have blockHeaderSchema
for the property header
, hence blockAssetsSchema
would be inline.
export const blockAssetSchema = { | |
export const blockAssetsSchema = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asset is not part of the block header, and we need to decode asset one by one. Notice block schema has byte array for assets
public constructor( | ||
public readonly header: BlockHeader, | ||
public readonly payload: Transaction[], | ||
public readonly assets: BlockAssets, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit unsure here if it can be redefined to be something like BlockAsset[]
. In the LIP it says assets
is an array of objects and also since payload is an array of objects too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other properties are also class instance, and we could create BlockAsset
class, but we want to have blockAssets.get
and blockAssets.set
. Therefore it's better to be BlockAssets
class
What was the problem?
This PR resolves #6739
How was it solved?
How was it tested?