-
Notifications
You must be signed in to change notification settings - Fork 2
Update go version and libraries #141
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
Changes from 2 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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -414,3 +414,68 @@ func (service *constructionService) ConstructionSubmit( | |||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| }, nil | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| func (service *constructionService) ConstructionPreprocessOperations( | ||||||||||||||||||||||||
|
Comment on lines
+417
to
+422
Contributor
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. add comment?
Contributor
Author
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 |
||||||||||||||||||||||||
| _ context.Context, | ||||||||||||||||||||||||
| request *types.ConstructionPreprocessOperationsRequest, | ||||||||||||||||||||||||
| ) (*types.ConstructionPreprocessOperationsResponse, *types.Error) { | ||||||||||||||||||||||||
| log.Debug("constructionService.ConstructionPreprocessOperations()", "construct_op", request.ConstructOp, "from_address", request.FromAddress) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| requestOptions, err := newConstructionOptions(request.Options) | ||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||
| return nil, service.errFactory.newErrWithOriginal(ErrConstruction, err) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| if request.FromAddress != nil && len(*request.FromAddress) > 0 && len(requestOptions.Sender) == 0 { | ||||||||||||||||||||||||
| requestOptions.Sender = *request.FromAddress | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| nativeCurrencySymbol := service.extension.getNativeCurrencySymbol() | ||||||||||||||||||||||||
| isNative := service.extension.isNativeCurrencySymbol(requestOptions.CurrencySymbol) | ||||||||||||||||||||||||
| if !isNative && !service.provider.HasCustomCurrency(requestOptions.CurrencySymbol) { | ||||||||||||||||||||||||
| return nil, service.errFactory.newErrWithOriginal(ErrConstruction, fmt.Errorf("unsupported currency: %s", requestOptions.CurrencySymbol)) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Contributor
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.
Suggested change
is this call intensive? it is used only after
Contributor
Author
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. refactored |
||||||||||||||||||||||||
| if request.ConstructOp == "transfer" { | ||||||||||||||||||||||||
| err = requestOptions.validate(nativeCurrencySymbol) | ||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||
| return nil, service.errFactory.newErrWithOriginal(ErrConstruction, err) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||
| return nil, service.errFactory.newErrWithOriginal(ErrNotImplemented, fmt.Errorf("unsupported construct_op: %s", request.ConstructOp)) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| tx := &data.Transaction{ | ||||||||||||||||||||||||
| Sender: requestOptions.Sender, | ||||||||||||||||||||||||
| Receiver: requestOptions.Receiver, | ||||||||||||||||||||||||
| Value: requestOptions.Amount, | ||||||||||||||||||||||||
| Data: requestOptions.Data, | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if !isNative { | ||||||||||||||||||||||||
| tx.Value = amountZero | ||||||||||||||||||||||||
| tx.Data = service.computeDataForCustomCurrencyTransfer(requestOptions.CurrencySymbol, requestOptions.Amount) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| operations, err := service.createOperationsFromPreparedTx(tx) | ||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||
| return nil, service.errFactory.newErrWithOriginal(ErrConstruction, err) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| fee, gasLimit, gasPrice, errTyped := service.computeFeeComponents(requestOptions, tx.Data) | ||||||||||||||||||||||||
| if errTyped != nil { | ||||||||||||||||||||||||
| return nil, errTyped | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| requestOptions.GasLimit = gasLimit | ||||||||||||||||||||||||
| requestOptions.GasPrice = gasPrice | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| metadataBytes, err := json.Marshal(requestOptions) | ||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||
| return nil, service.errFactory.newErrWithOriginal(ErrConstruction, err) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| return &types.ConstructionPreprocessOperationsResponse{ | ||||||||||||||||||||||||
| Operations: operations, | ||||||||||||||||||||||||
| MaxFee: service.extension.valueToNativeAmount(fee.String()), | ||||||||||||||||||||||||
| Metadata: new(string(metadataBytes)), | ||||||||||||||||||||||||
| }, nil | ||||||||||||||||||||||||
|
miiu96 marked this conversation as resolved.
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.