@@ -38,13 +38,25 @@ type executor struct {
3838}
3939
4040// NewExecutor creates a new Executor for TON chains
41- func NewExecutor (encoder sdk.Encoder , client * ton.APIClient , wallet * wallet.Wallet , amount tlb.Coins ) sdk.Executor {
41+ func NewExecutor (encoder sdk.Encoder , client ton.APIClientWrapped , wallet * wallet.Wallet , amount tlb.Coins ) (sdk.Executor , error ) {
42+ if encoder == nil {
43+ return nil , errors .New ("failed to create sdk.Executor - encoder (sdk.Encoder) is nil" )
44+ }
45+
46+ if client == nil {
47+ return nil , errors .New ("failed to create sdk.Executor - client (ton.APIClientWrapped) is nil" )
48+ }
49+
50+ if wallet == nil {
51+ return nil , errors .New ("failed to create sdk.Executor - wallet (*wallet.Wallet) is nil" )
52+ }
53+
4254 return & executor {
4355 Encoder : encoder ,
4456 Inspector : NewInspector (client , NewConfigTransformer ()),
4557 wallet : wallet ,
4658 amount : amount ,
47- }
59+ }, nil
4860}
4961
5062func (e * executor ) ExecuteOperation (
@@ -54,10 +66,6 @@ func (e *executor) ExecuteOperation(
5466 proof []common.Hash ,
5567 op types.Operation ,
5668) (types.TransactionResult , error ) {
57- if e .Encoder == nil {
58- return types.TransactionResult {}, errors .New ("executor was created without an encoder" )
59- }
60-
6169 oe , ok := e .Encoder .(OperationEncoder [mcms.Op ])
6270 if ! ok {
6371 return types.TransactionResult {}, fmt .Errorf ("failed to assert OperationEncoder" )
@@ -127,16 +135,6 @@ func (e *executor) SetRoot(
127135 validUntil uint32 ,
128136 sortedSignatures []types.Signature ,
129137) (types.TransactionResult , error ) {
130- if e .Encoder == nil {
131- return types.TransactionResult {}, errors .New ("Executor was created without an encoder" )
132- }
133-
134- // Map to Ton Address type
135- dstAddr , err := address .ParseAddr (metadata .MCMAddress )
136- if err != nil {
137- return types.TransactionResult {}, fmt .Errorf ("invalid timelock address: %w" , err )
138- }
139-
140138 rme , ok := e .Encoder .(RootMetadataEncoder [mcms.RootMetadata ])
141139 if ! ok {
142140 return types.TransactionResult {}, fmt .Errorf ("failed to assert RootMetadataEncoder" )
@@ -147,6 +145,12 @@ func (e *executor) SetRoot(
147145 return types.TransactionResult {}, fmt .Errorf ("failed to convert to root metadata: %w" , err )
148146 }
149147
148+ // Map to Ton Address type
149+ dstAddr , err := address .ParseAddr (metadata .MCMAddress )
150+ if err != nil {
151+ return types.TransactionResult {}, fmt .Errorf ("invalid timelock address: %w" , err )
152+ }
153+
150154 // Encode proofs
151155 pe , ok := e .Encoder .(ProofEncoder [mcms.Proof ])
152156 if ! ok {
0 commit comments