-
Notifications
You must be signed in to change notification settings - Fork 67
Conversation
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.
Can you add tests?
Sources/Tron/TransferContract.swift
Outdated
private let toAddress: Data | ||
private let amount: Int64 | ||
|
||
init(ownerAddress: Data, toAddress: Data, amount: Int64) { |
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.
can you pass TronAddress
?
Sources/Tron/TronTransaction.swift
Outdated
let rawData = TronTransactionRawDataBuilder() | ||
.contract(contract) | ||
.timestamp(Date().currentTimeMilliseconds) | ||
.expiration(blockHeader.rawData.timestamp + 10 * 60 * 60 * 1000) |
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.
can you make this customizable from the app side? so you pass this value
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.
I'm not sure if builder pattern is suitable here, most of the properties are primitive types...
struct TransferAssetContract: TronTransactionContract { | ||
|
||
private let assetName: Data | ||
private let ownerAddress: Data |
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.
use TronAddress
|
||
struct TransferAssetContract: TronTransactionContract { | ||
|
||
private let assetName: Data |
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.
assets name as String
?
|
||
extension Protocol_Transaction { | ||
private func hash() -> Data { | ||
return Crypto.sha256(rawData.data) |
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.
make a property.
Sources/Tron/Extension/Date.swift
Outdated
extension Date { | ||
var currentTimeMilliseconds: Int64 { | ||
let now = timeIntervalSince1970 | ||
return Int64(now * 1000) |
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.
just Int64(timeIntervalSince1970 * 1000)
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.
personal opinion, currentTimeMilliseconds
is a bit long, like good old objc variable naming
@@ -53,6 +53,9 @@ | |||
/// Computes the SHA256 hash of the SHA256 hash of the data. | |||
+ (nonnull NSData *)sha256sha256:(nonnull NSData *)data; | |||
|
|||
/// Computes the SHA256 hash of the data. | |||
+ (nonnull NSData *)sha256:(nonnull NSData *)data; |
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.
there is also hash()
which is the same thing
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.
@vikmeup not exactly the same, hash()
is too general, how about rename to keccak256
or something similar
@@ -0,0 +1,4581 @@ | |||
// DO NOT EDIT. |
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.
Can you exclude files from the commit? we should run script to generate them instead from original protobuf
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.
a few comments, how large is the new introduced SwiftProtobuf.framework
?
@@ -53,6 +53,9 @@ | |||
/// Computes the SHA256 hash of the SHA256 hash of the data. | |||
+ (nonnull NSData *)sha256sha256:(nonnull NSData *)data; | |||
|
|||
/// Computes the SHA256 hash of the data. | |||
+ (nonnull NSData *)sha256:(nonnull NSData *)data; |
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.
@vikmeup not exactly the same, hash()
is too general, how about rename to keccak256
or something similar
Sources/Tron/Extension/Date.swift
Outdated
extension Date { | ||
var currentTimeMilliseconds: Int64 { | ||
let now = timeIntervalSince1970 | ||
return Int64(now * 1000) |
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.
personal opinion, currentTimeMilliseconds
is a bit long, like good old objc variable naming
|
||
import UIKit | ||
|
||
extension Protocol_Transaction { |
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.
Protocol_Transaction
is generated?
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.
@hewigovens yes it is generated by protobuf.
Sources/Tron/TronTransaction.swift
Outdated
|
||
enum TronTransactionError: Error { | ||
case blockHeaderHeight | ||
case blockHeaderRawData |
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.
maybe LocalizedError
? block height/raw data seems not like a error
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.
yeah it makes sense
Sources/Tron/TronTransaction.swift
Outdated
let rawData = TronTransactionRawDataBuilder() | ||
.contract(contract) | ||
.timestamp(Date().currentTimeMilliseconds) | ||
.expiration(blockHeader.rawData.timestamp + 10 * 60 * 60 * 1000) |
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.
I'm not sure if builder pattern is suitable here, most of the properties are primitive types...
Hello it is my first implementation of the network.
Could you take a look at implementation before I add unit tests ?
Document that I was using during implementation.
https://github.com/tronprotocol/Documentation/blob/master/TRX/Tron-overview.md#103-signature