Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Support asset field in BaseTransaction #3697

Closed
MaciejBaj opened this issue May 22, 2019 · 0 comments
Closed

Support asset field in BaseTransaction #3697

MaciejBaj opened this issue May 22, 2019 · 0 comments

Comments

@MaciejBaj
Copy link
Contributor

Expected behavior

BasicTransaction should store the asset property and implement the default behaviour for assetToJSON function, so the transactions don't necessarily need to implement the following constructor:

public constructor(rawTransaction: unknown) {
		super(rawTransaction);
		const tx = (typeof rawTransaction === 'object' && rawTransaction !== null
			? rawTransaction
			: {}) as Partial<TransactionJSON>;
		// Initializes to empty object if it doesn't exist
		this.asset = (tx.asset || {}) as TransferAsset;
}

All of the transaction types implement the assetToJSON function in the same way, which also can be moved to the BasicTransaction:

	public assetToJSON(): TransferAsset {
		return this.asset;
	}

Which version(s) does this affect? (Environment, OS, etc...)

2.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants