RSS3-Network / Protocol-Go

The Go Implementation of RSS3 Protocol.
MIT License
0 stars 0 forks source link

Provide an activity and action builders for fields validation #44

Open kallydev opened 2 months ago

kallydev commented 2 months ago

What feature is it?

actionBuilder := activity.NewActionBuilder(type.TransactionTransfer, from, to)
actionBuilder.SetPlatform(decentralized.Platform1Inch)

action, err := actionBuilder.Build() // Build and check all fields.

What problem does this feature solve?

Using Activity and Action structures directly can easily lead to invalid or missing values in some fields, which can be avoided using builder pattern.

Additional description

No response

This is not a duplicated feature request or new worker proposal

kallydev commented 2 months ago

This can ensure that the necessary fields are assigned at compile time, but the checks for the values of the fields are still at runtime.