-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export relayed txs builder #184
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,57 +6,59 @@ import ( | |
"math/big" | ||
|
||
"github.com/multiversx/mx-chain-core-go/data/transaction" | ||
|
||
"github.com/multiversx/mx-sdk-go/core" | ||
"github.com/multiversx/mx-sdk-go/data" | ||
) | ||
|
||
type relayedTxV2Builder struct { | ||
// RelayedTxV2Builder is a builder for relayed transaction v2 | ||
type RelayedTxV2Builder struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
innerTransaction *transaction.FrontendTransaction | ||
gasLimitNeededForInnerTransaction uint64 | ||
relayerAccount *data.Account | ||
networkConfig *data.NetworkConfig | ||
} | ||
|
||
// NewRelayedTxV2Builder creates a new relayed transaction v2 builder | ||
func NewRelayedTxV2Builder() *relayedTxV2Builder { | ||
return &relayedTxV2Builder{ | ||
func NewRelayedTxV2Builder() *RelayedTxV2Builder { | ||
return &RelayedTxV2Builder{ | ||
innerTransaction: nil, | ||
relayerAccount: nil, | ||
networkConfig: nil, | ||
} | ||
} | ||
|
||
// SetInnerTransaction sets the inner transaction to be relayed | ||
func (rtb *relayedTxV2Builder) SetInnerTransaction(tx *transaction.FrontendTransaction) *relayedTxV2Builder { | ||
func (rtb *RelayedTxV2Builder) SetInnerTransaction(tx *transaction.FrontendTransaction) *RelayedTxV2Builder { | ||
rtb.innerTransaction = tx | ||
|
||
return rtb | ||
} | ||
|
||
// SetRelayerAccount sets the relayer account (that will send the wrapped transaction) | ||
func (rtb *relayedTxV2Builder) SetRelayerAccount(account *data.Account) *relayedTxV2Builder { | ||
func (rtb *RelayedTxV2Builder) SetRelayerAccount(account *data.Account) *RelayedTxV2Builder { | ||
rtb.relayerAccount = account | ||
|
||
return rtb | ||
} | ||
|
||
// SetGasLimitNeededForInnerTransaction sets the gas limit needed for the inner transaction | ||
func (rtb *relayedTxV2Builder) SetGasLimitNeededForInnerTransaction(gasLimit uint64) *relayedTxV2Builder { | ||
func (rtb *RelayedTxV2Builder) SetGasLimitNeededForInnerTransaction(gasLimit uint64) *RelayedTxV2Builder { | ||
rtb.gasLimitNeededForInnerTransaction = gasLimit | ||
|
||
return rtb | ||
} | ||
|
||
// SetNetworkConfig sets the network config | ||
func (rtb *relayedTxV2Builder) SetNetworkConfig(config *data.NetworkConfig) *relayedTxV2Builder { | ||
func (rtb *RelayedTxV2Builder) SetNetworkConfig(config *data.NetworkConfig) *RelayedTxV2Builder { | ||
rtb.networkConfig = config | ||
|
||
return rtb | ||
} | ||
|
||
// Build builds the relayed transaction v1 | ||
// The returned transaction will not be signed | ||
func (rtb *relayedTxV2Builder) Build() (*transaction.FrontendTransaction, error) { | ||
func (rtb *RelayedTxV2Builder) Build() (*transaction.FrontendTransaction, error) { | ||
if rtb.innerTransaction == nil { | ||
return nil, ErrNilInnerTransaction | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,48 +2,50 @@ package builders | |
|
||
import ( | ||
"github.com/multiversx/mx-chain-core-go/data/transaction" | ||
|
||
"github.com/multiversx/mx-sdk-go/data" | ||
) | ||
|
||
type relayedTxV3Builder struct { | ||
// RelayedTxV3Builder is a builder for relayed transactions v3 | ||
type RelayedTxV3Builder struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
innerTransactions []*transaction.FrontendTransaction | ||
relayerAccount *data.Account | ||
networkConfig *data.NetworkConfig | ||
} | ||
|
||
// NewRelayedTxV3Builder creates a new relayed transaction v2 builder | ||
func NewRelayedTxV3Builder() *relayedTxV3Builder { | ||
return &relayedTxV3Builder{ | ||
func NewRelayedTxV3Builder() *RelayedTxV3Builder { | ||
return &RelayedTxV3Builder{ | ||
innerTransactions: nil, | ||
relayerAccount: nil, | ||
networkConfig: nil, | ||
} | ||
} | ||
|
||
// SetInnerTransactions sets the inner transactions to be relayed | ||
func (rtb *relayedTxV3Builder) SetInnerTransactions(innerTxs []*transaction.FrontendTransaction) *relayedTxV3Builder { | ||
func (rtb *RelayedTxV3Builder) SetInnerTransactions(innerTxs []*transaction.FrontendTransaction) *RelayedTxV3Builder { | ||
rtb.innerTransactions = innerTxs | ||
|
||
return rtb | ||
} | ||
|
||
// SetRelayerAccount sets the relayer account (that will send the wrapped transaction) | ||
func (rtb *relayedTxV3Builder) SetRelayerAccount(account *data.Account) *relayedTxV3Builder { | ||
func (rtb *RelayedTxV3Builder) SetRelayerAccount(account *data.Account) *RelayedTxV3Builder { | ||
rtb.relayerAccount = account | ||
|
||
return rtb | ||
} | ||
|
||
// SetNetworkConfig sets the network config | ||
func (rtb *relayedTxV3Builder) SetNetworkConfig(config *data.NetworkConfig) *relayedTxV3Builder { | ||
func (rtb *RelayedTxV3Builder) SetNetworkConfig(config *data.NetworkConfig) *RelayedTxV3Builder { | ||
rtb.networkConfig = config | ||
|
||
return rtb | ||
} | ||
|
||
// Build builds the relayed transaction v3 | ||
// The returned transaction will not be signed | ||
func (rtb *relayedTxV3Builder) Build() (*transaction.FrontendTransaction, error) { | ||
func (rtb *RelayedTxV3Builder) Build() (*transaction.FrontendTransaction, error) { | ||
if len(rtb.innerTransactions) == 0 { | ||
return nil, ErrEmptyInnerTransactions | ||
} | ||
|
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.
missing comment
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.
done