Skip to content

Commit

Permalink
revert mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Feb 1, 2024
1 parent eded3df commit cdaeeb8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/KukaiCoreSwift/Factories/OperationFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public class OperationFactory {
- Approve operation
- update_operator operation
*/
public static func tokenIdAndAmountFromMichelson(michelson: Any, operation: Operation) -> (rpcAmount: String, tokenId: Decimal?, destination: String?)? {
public static func tokenIdAndAmountFromMichelson(michelson: Any) -> (rpcAmount: String, tokenId: Decimal?, destination: String?)? {
if let michelsonDict = michelson as? [String: Any], let entrypoint = michelsonDict["entrypoint"] as? String {
switch entrypoint {
case OperationTransaction.StandardEntrypoint.approve.rawValue:
Expand All @@ -558,7 +558,7 @@ public class OperationFactory {

case OperationTransaction.StandardEntrypoint.execute.rawValue:
if let executeResponse = tokenAmountFromExecuteMichelson(michelson: michelsonDict["value"] ?? [:]) {
return (rpcAmount: executeResponse.description, tokenId: nil, destination: (operation as? OperationTransaction)?.destination) // We can extract the token address, but not the tokenId ... cause life
return (rpcAmount: executeResponse.description, tokenId: nil, destination: nil) // Can extract amount, but nothing else

} else {
return nil
Expand All @@ -580,14 +580,14 @@ public class OperationFactory {
public static func firstNonZeroTokenTransferAmount(operations: [Operation]) -> (tokenContract: String, rpcAmount: String, tokenId: Decimal?, destination: String)? {

for (index, op) in operations.enumerated() {
if let opTrans = op as? OperationTransaction, let details = tokenIdAndAmountFromMichelson(michelson: opTrans.parameters ?? [:], operation: op) {
if let opTrans = op as? OperationTransaction, let details = tokenIdAndAmountFromMichelson(michelson: opTrans.parameters ?? [:]) {

if details.rpcAmount == "0" && (opTrans.parameters?["entrypoint"] as? String) != OperationTransaction.StandardEntrypoint.updateOperators.rawValue {

// If we have a rpcAmount of zero, and its not an `update_operators`, move on to next value
continue

} else if details.rpcAmount == "0", operations.count > (index + 1), let executeDetails = tokenIdAndAmountFromMichelson(michelson: (operations[index+1] as? OperationTransaction)?.parameters ?? [:], operation: op) {
} else if details.rpcAmount == "0", operations.count > (index + 1), let executeDetails = tokenIdAndAmountFromMichelson(michelson: (operations[index+1] as? OperationTransaction)?.parameters ?? [:]) {

// If its zero, and was update_operators, check to see if parsing the next operation as a 3route execute, returns the missing piece
// If so return a mixture of the 2 values, as update tells us the token, execute tells us how much
Expand Down

0 comments on commit cdaeeb8

Please sign in to comment.