Skip to content

Commit

Permalink
resolved reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakeally committed May 9, 2023
1 parent 019894c commit c3fe5de
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 74 deletions.
6 changes: 3 additions & 3 deletions android/src/main/kotlin/africa/ejara/trustdart/coins/NEAR.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class NEAR : Coin("NEAR", CoinType.NEAR) {
signerId = txData["signerID"] as String
nonce = txData["nonce"]!!.toLong()
receiverId = txData["receiverID"] as String
addActionsBuilder().apply {
transfer = transferAction
}
// addActionsBuilder().apply {
// transfer = transferAction
// }
blockHash = ByteString.copyFrom(Base58.decodeNoCheck(txData["blockHash"] as String))
privateKey = ByteString.copyFrom(secretKey.data())
}.build()
Expand Down
45 changes: 23 additions & 22 deletions android/src/main/kotlin/africa/ejara/trustdart/coins/XTZ.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import africa.ejara.trustdart.Numeric
import africa.ejara.trustdart.utils.base64String
import africa.ejara.trustdart.utils.toHex
import africa.ejara.trustdart.utils.toHexBytes
import africa.ejara.trustdart.utils.toLong
import android.util.Log
import wallet.core.jni.CoinType
import wallet.core.jni.HDWallet
Expand Down Expand Up @@ -77,27 +78,27 @@ class XTZ : Coin("XTZ", CoinType.TEZOS) {
.setPublicKey(ByteString.copyFrom(publicKey))

val transactionData = TransactionOperationData.newBuilder()
.setAmount(txData["transactionAmount"] as Long)
.setAmount(txData["transactionAmount"]!!.toLong())
.setDestination(txData["destination"] as String)
.setParameters(parameters)
.build()

val reveal = Operation.newBuilder()
.setSource(txData["source"] as String)
.setFee(txData["fee"] as Long)
.setCounter(txData["counter"] as Long)
.setGasLimit(txData["gasLimit"] as Long)
.setStorageLimit(txData["storageLimit"] as Long)
.setKind(Operation.OperationKind.REVEAL)
.setRevealOperationData(revealOperationData)
.build()
.setSource(txData["source"] as String)
.setFee(txData["fee"]!!.toLong())
.setCounter(txData["counter"]!!.toLong())
.setGasLimit(txData["gasLimit"]!!.toLong())
.setStorageLimit(txData["storageLimit"]!!.toLong())
.setKind(Operation.OperationKind.REVEAL)
.setRevealOperationData(revealOperationData)
.build()

val transaction = Operation.newBuilder()
.setSource(txData["source"] as String)
.setFee(txData["fee"] as Long)
.setCounter(txData["counter"] as Long)
.setGasLimit(txData["gasLimit"] as Long)
.setStorageLimit(txData["storageLimit"] as Long)
.setFee(txData["fee"]!!.toLong())
.setCounter(txData["counter"]!!.toLong())
.setGasLimit(txData["gasLimit"]!!.toLong())
.setStorageLimit(txData["storageLimit"]!!.toLong())
.setKind(Operation.OperationKind.TRANSACTION)
.setTransactionOperationData(transactionData)
.build()
Expand Down Expand Up @@ -132,27 +133,27 @@ class XTZ : Coin("XTZ", CoinType.TEZOS) {
.setPublicKey(ByteString.copyFrom(publicKey))

val transactionData = TransactionOperationData.newBuilder()
.setAmount(txData["amount"] as Long)
.setAmount(txData["transactionAmount"]!!.toLong())
.setDestination(txData["destination"] as String)
.setParameters(parameters)
.build()

val reveal = Operation.newBuilder()
.setSource(txData["source"] as String)
.setFee(txData["fee"] as Long)
.setCounter(txData["counter"] as Long)
.setGasLimit(txData["gasLimit"] as Long)
.setStorageLimit(txData["storageLimit"] as Long)
.setFee(txData["fee"]!!.toLong())
.setCounter(txData["counter"]!!.toLong())
.setGasLimit(txData["gasLimit"]!!.toLong())
.setStorageLimit(txData["storageLimit"]!!.toLong())
.setKind(Operation.OperationKind.REVEAL)
.setRevealOperationData(revealOperationData)
.build()

val transaction = Operation.newBuilder()
.setSource(txData["source"] as String)
.setFee((txData["fee"] as String).toLong())
.setCounter(txData["counter"] as Long)
.setGasLimit(txData["gasLimit"] as Long)
.setStorageLimit(txData["storageLimit"] as Long)
.setFee(txData["fee"]!!.toLong())
.setCounter(txData["counter"]!!.toLong())
.setGasLimit(txData["gasLimit"]!!.toLong())
.setStorageLimit(txData["storageLimit"]!!.toLong())
.setKind(Operation.OperationKind.TRANSACTION)
.setTransactionOperationData(transactionData)
.build()
Expand Down
90 changes: 45 additions & 45 deletions example/lib/operations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,52 @@ import 'package:trustdart/trustdart.dart';
import 'package:trustdart_example/coins.dart';

Map<String, dynamic> operations = {
// 'XTZ': {
// "operationList": {
// "branch": "BL8euoCWqNCny9AR3AKjnpi38haYMxjei1ZqNHuXMn19JSQnoWp",
// "operations": [
// {
// "source": "tz1XVJ8bZUXs7r5NV8dHvuiBhzECvLRLR3jW",
// "fee": 1272,
// "counter": 30738,
// "gasLimit": 10100,
// "storageLimit": 257,
// "kind": 107,
// "revealOperationData": {
// "publicKey": "8z6GkG6TaQVnpYr2gc6r8Q/mS7m0Qf6Ef9VinW8mKXM="
// }
// },
// {
// "source": "tz1XVJ8bZUXs7r5NV8dHvuiBhzECvLRLR3jW",
// "fee": 1272,
// "counter": 30739,
// "gasLimit": 10100,
// "storageLimit": 257,
// "kind": 108,
// "transactionOperationData": {
// "destination": "tz1XVJ8bZUXs7r5NV8dHvuiBhzECvLRLR3jW",
// "amount": 1
// }
// }
// ]
// }
// },

'XTZ': {
"cmd": "FA2",
"amount": "10",
"tokenId": "1",
"toAddress": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
"senderAddress": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
"destination": "KT1DYk1XDzHredJq1EyNkDindiWDqZyekXGj",
"transactionAmount": 0,
"source": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
"fee": 100000,
"counter": 2993173,
"gasLimit": 100000,
"storageLimit": 0,
"branch": "BKvEAX9HXfJZWYfTQbR1C7B3ADoKY6a1aKVRF7qQqvc9hS8Rr3m",
"operationList": {
"branch": "BL8euoCWqNCny9AR3AKjnpi38haYMxjei1ZqNHuXMn19JSQnoWp",
"operations": [
{
"source": "tz1XVJ8bZUXs7r5NV8dHvuiBhzECvLRLR3jW",
"fee": 1272,
"counter": 30738,
"gasLimit": 10100,
"storageLimit": 257,
"kind": 107,
"revealOperationData": {
"publicKey": "8z6GkG6TaQVnpYr2gc6r8Q/mS7m0Qf6Ef9VinW8mKXM="
}
},
{
"source": "tz1XVJ8bZUXs7r5NV8dHvuiBhzECvLRLR3jW",
"fee": 1272,
"counter": 30739,
"gasLimit": 10100,
"storageLimit": 257,
"kind": 108,
"transactionOperationData": {
"destination": "tz1XVJ8bZUXs7r5NV8dHvuiBhzECvLRLR3jW",
"amount": 1
}
}
]
}
},

// 'XTZ': {
// "cmd": "FA2",
// "amount": "10",
// "tokenId": "1",
// "toAddress": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
// "senderAddress": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
// "destination": "KT1DYk1XDzHredJq1EyNkDindiWDqZyekXGj",
// "transactionAmount": 0,
// "source": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
// "fee": 100000,
// "counter": 2993173,
// "gasLimit": 100000,
// "storageLimit": 0,
// "branch": "BKvEAX9HXfJZWYfTQbR1C7B3ADoKY6a1aKVRF7qQqvc9hS8Rr3m",
// },
// 'XTZ': {
// "cmd": "FA12",
// "branch": "BL8euoCWqNCny9AR3AKjnpi38haYMxjei1ZqNHuXMn19JSQnoWp",
Expand All @@ -60,7 +60,7 @@ Map<String, dynamic> operations = {
// "senderAddress": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
// "toAddress": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
// "value": "123",
// "amount": "0"
// "amount": "0",
// "source": "tz1ioz62kDw6Gm5HApeQtc1PGmN2wPBtJKUP",
// "fee": 100000,
// "counter": 2993173,
Expand Down
9 changes: 5 additions & 4 deletions ios/Classes/coins/XTZ.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class XTZ: Coin {
}

override func signTransaction(path: String, txData: [String : Any], mnemonic: String, passphrase: String) -> String? {
var txHash: String?
let cmd = txData["cmd"] as! String
var txHash: String? = nil
let cmd: String? = txData["cmd"] as String
let branch = txData["branch"] as! String
let privateKey = HDWallet(mnemonic: mnemonic, passphrase: passphrase)!.getKey(coin: self.coinType, derivationPath: path)
let publicKey = privateKey.getPublicKeyEd25519().data
Expand Down Expand Up @@ -135,9 +135,10 @@ class XTZ: Coin {
txHash = output.encoded.hexString

default:
txHash = nil
let opJson = Utils.objToJson(from: txData)
let output = AnySigner.signJSON(opJson!, key: privateKey.data, coin: self.coinType)
txHash = output
}

return txHash

}
Expand Down

0 comments on commit c3fe5de

Please sign in to comment.