-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sprint-1.18' into fix/refactor-zboxcore
# Conflicts: # mobilesdk/zcn/smartcontract.go # zboxcore/sdk/transaction_mobile.go # zcncore/transaction.go # zcncore/transaction_base.go # zcncore/transaction_mobile.go # zcncore/transactionauth.go # zcncore/transactionauth_base.go # zcncore/transactionauth_mobile.go # zcncore/zauth.go
- Loading branch information
Showing
5 changed files
with
114 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build !mobile | ||
// +build !mobile | ||
|
||
package transaction | ||
|
||
// Transaction entity that encapsulates the transaction related data and meta data | ||
type Transaction struct { | ||
Hash string `json:"hash,omitempty"` | ||
Version string `json:"version,omitempty"` | ||
ClientID string `json:"client_id,omitempty"` | ||
PublicKey string `json:"public_key,omitempty"` | ||
ToClientID string `json:"to_client_id,omitempty"` | ||
ChainID string `json:"chain_id,omitempty"` | ||
TransactionData string `json:"transaction_data"` | ||
Value uint64 `json:"transaction_value"` | ||
Signature string `json:"signature,omitempty"` | ||
CreationDate int64 `json:"creation_date,omitempty"` | ||
TransactionType int `json:"transaction_type"` | ||
TransactionOutput string `json:"transaction_output,omitempty"` | ||
TransactionFee uint64 `json:"transaction_fee"` | ||
TransactionNonce int64 `json:"transaction_nonce"` | ||
OutputHash string `json:"txn_output_hash"` | ||
Status int `json:"transaction_status"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//go:build mobile | ||
// +build mobile | ||
|
||
package transaction | ||
|
||
import ( | ||
"encoding/json" | ||
"strconv" | ||
) | ||
|
||
// Transaction represents entity that encapsulates the transaction related data and metadata. | ||
type Transaction struct { | ||
Hash string `json:"hash,omitempty"` | ||
Version string `json:"version,omitempty"` | ||
ClientID string `json:"client_id,omitempty"` | ||
PublicKey string `json:"public_key,omitempty"` | ||
ToClientID string `json:"to_client_id,omitempty"` | ||
ChainID string `json:"chain_id,omitempty"` | ||
TransactionData string `json:"transaction_data"` | ||
Value string `json:"transaction_value"` | ||
Signature string `json:"signature,omitempty"` | ||
CreationDate int64 `json:"creation_date,omitempty"` | ||
TransactionType int `json:"transaction_type"` | ||
TransactionOutput string `json:"transaction_output,omitempty"` | ||
TransactionFee string `json:"transaction_fee"` | ||
TransactionNonce int64 `json:"transaction_nonce"` | ||
OutputHash string `json:"txn_output_hash"` | ||
Status int `json:"transaction_status"` | ||
} | ||
|
||
// TransactionWrapper represents wrapper for mobile transaction entity. | ||
type TransactionWrapper struct { | ||
Hash string `json:"hash,omitempty"` | ||
Version string `json:"version,omitempty"` | ||
ClientID string `json:"client_id,omitempty"` | ||
PublicKey string `json:"public_key,omitempty"` | ||
ToClientID string `json:"to_client_id,omitempty"` | ||
ChainID string `json:"chain_id,omitempty"` | ||
TransactionData string `json:"transaction_data"` | ||
Value uint64 `json:"transaction_value"` | ||
Signature string `json:"signature,omitempty"` | ||
CreationDate int64 `json:"creation_date,omitempty"` | ||
TransactionType int `json:"transaction_type"` | ||
TransactionOutput string `json:"transaction_output,omitempty"` | ||
TransactionFee uint64 `json:"transaction_fee"` | ||
TransactionNonce int64 `json:"transaction_nonce"` | ||
OutputHash string `json:"txn_output_hash"` | ||
Status int `json:"transaction_status"` | ||
} | ||
|
||
func (t *Transaction) MarshalJSON() ([]byte, error) { | ||
valueRaw, err := strconv.ParseUint(t.Value, 0, 64) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
transactionFeeRaw, err := strconv.ParseUint(t.TransactionFee, 0, 64) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
wrapper := TransactionWrapper{ | ||
Hash: t.Hash, | ||
Version: t.Version, | ||
ClientID: t.ClientID, | ||
PublicKey: t.PublicKey, | ||
ToClientID: t.ToClientID, | ||
ChainID: t.ChainID, | ||
TransactionData: t.TransactionData, | ||
Value: valueRaw, | ||
Signature: t.Signature, | ||
CreationDate: t.CreationDate, | ||
TransactionType: t.TransactionType, | ||
TransactionOutput: t.TransactionOutput, | ||
TransactionFee: transactionFeeRaw, | ||
TransactionNonce: t.TransactionNonce, | ||
OutputHash: t.OutputHash, | ||
Status: t.Status, | ||
} | ||
|
||
return json.Marshal(wrapper) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters