Skip to content

Commit

Permalink
commission multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
klim0v committed Dec 23, 2020
1 parent d980007 commit 03465e1
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 39 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
### Added
- Autotests to Github Actions.
- More documentation and examples for API clients.
- Telegram [channel](https://t.me/MinterGoSDK) with notifications and discussions.
- Telegram channel with release notifications and discussions.
- Increase your commission multiplier to 10e16
- **WithDebug** method for *http_client*.
- **WithLogger** method for *http_client*.
- **WithHeaders** method for *http_client*.
Expand All @@ -20,4 +21,6 @@
- **CheckVersion** method for *http_client* and *grpc_client*

### Changed
- Remove `status` parameter from **Candidates** method for *http_client* and *grpc_client*

- Remove `status` parameter from **Candidates** method for *http_client* and *grpc_client*, flag `not_show_stakes` sets
as default.
6 changes: 4 additions & 2 deletions transaction/buy_coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ func TestDecode_buyCoin(t *testing.T) {
if err != nil {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000" {
if decode.GetTransaction().Type != TypeBuyCoin {
t.Error("buy coin transaction type is invalid", decode.GetTransaction().Type)
}
if decode.Fee().String() != "10000000000000000000" {
t.Error("buy coin transaction fee is invalid", decode.Fee().String())
}
}
6 changes: 4 additions & 2 deletions transaction/create_coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ func TestDecode_createCoin(t *testing.T) {
if err != nil {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000000" {
if decode.GetTransaction().Type != TypeCreateCoin {
t.Error("create coin transaction type is invalid", decode.GetTransaction().Type)
}
if decode.Fee().String() != "10000000000000000000000" {
t.Error("create coin transaction fee is invalid", decode.Fee().String())
}
}
Expand Down
7 changes: 5 additions & 2 deletions transaction/create_multisig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func TestDecode_createMultisig(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000" {
t.Error("send transaction fee is invalid", decode.Fee().String())
if decode.GetTransaction().Type != TypeCreateMultisig {
t.Error("create multisig transaction type is invalid", decode.GetTransaction().Type)
}
if decode.Fee().String() != "10000000000000000000" {
t.Error("create multisig transaction fee is invalid", decode.Fee().String())
}
}
8 changes: 5 additions & 3 deletions transaction/declare_candidacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ func TestDecode_declareCandidacy(t *testing.T) {
if err != nil {
t.Fatal(err)
}

if decode.Fee().String() != "10000000000000000000" {
t.Error("declare candidacy transaction fee is invalid", decode.Fee().String())
if decode.GetTransaction().Type != TypeDeclareCandidacy {
t.Error("declare candidate transaction type is invalid", decode.GetTransaction().Type)
}
if decode.Fee().String() != "1000000000000000000000" {
t.Error("declare candidate transaction fee is invalid", decode.Fee().String())
}
}
6 changes: 4 additions & 2 deletions transaction/delegate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ func TestDecode_delegate(t *testing.T) {
if err != nil {
t.Fatal(err)
}

if decode.Fee().String() != "200000000000000000" {
if decode.GetTransaction().Type != TypeDelegate {
t.Error("delegate transaction type is invalid", decode.GetTransaction().Type)
}
if decode.Fee().String() != "20000000000000000000" {
t.Error("delegate transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/edit_candidate_public_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestDecode_editCandidatePublicKey(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000000000" {
if decode.Fee().String() != "10000000000000000000000000" {
t.Error("edit candidate public key transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/edit_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestDecode_editCandidate(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000000" {
if decode.Fee().String() != "10000000000000000000000" {
t.Error("edit candidate transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/edit_coin_owner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestDecode_editCoinOwner(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "10000000000000000000000" {
if decode.Fee().String() != "1000000000000000000000000" {
t.Error("edit coin owner transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/edit_multisig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestDecode_editMultisig(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "1000000000000000000" {
if decode.Fee().String() != "100000000000000000000" {
t.Error("edit multisig transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/multisend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestDecode_multisend(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "15000000000000000" {
if decode.Fee().String() != "1500000000000000000" {
t.Error("multisend transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/price_vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestDecode_priceVote(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "10000000000000000" {
if decode.Fee().String() != "1000000000000000000" {
t.Error("price vote transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/recreate_coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestDecode_recreateCoin(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "10000000000000000000000" {
if decode.Fee().String() != "1000000000000000000000000" {
t.Error("recreate coin transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/redeem_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestDecode_redeemCheck(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "30000000000000000" {
if decode.Fee().String() != "3000000000000000000" {
t.Error("redeem check transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/sell_all_coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestDecode_sellAllCoin(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000" {
if decode.Fee().String() != "10000000000000000000" {
t.Error("sell all coin transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/sell_coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestDecode_sellCoin(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000" {
if decode.Fee().String() != "10000000000000000000" {
t.Error("sell coin transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestDecode_send(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "10000000000000000" {
if decode.Fee().String() != "1000000000000000000" {
t.Error("send transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/set_candidate_off_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestDecode_setCandidateOff(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000" {
if decode.Fee().String() != "10000000000000000000" {
t.Error("set candidate off transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/set_candidate_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestDecode_setCandidateOn(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "100000000000000000" {
if decode.Fee().String() != "10000000000000000000" {
t.Error("set candidate on transaction fee is invalid", decode.Fee().String())
}
}
2 changes: 1 addition & 1 deletion transaction/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ type object struct {

// Fee returns fee of transaction in PIP. Also sender should pay extra 2 units per byte in Payload and ServiceData fields.
func (o *object) Fee() *big.Int {
gasPrice := big.NewInt(0).Mul(big.NewInt(int64(o.data.Fee())), big.NewInt(1000000000000000))
gasPrice := big.NewInt(0).Mul(big.NewInt(int64(o.data.Fee())), big.NewInt(10e16))
commission := big.NewInt(0).Add(big.NewInt(0).Mul(big.NewInt(int64(len(o.Payload))*2), big.NewInt(1000000000000000)), big.NewInt(0).Mul(big.NewInt(int64(len(o.ServiceData))*2), big.NewInt(1000000000000000)))
return big.NewInt(0).Add(gasPrice, commission)
}
Expand Down
2 changes: 1 addition & 1 deletion transaction/transaction_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func ExampleBuilder_NewTransaction_signSingleSignature_simple() {

// Output:
// Mx622e1e0e788f4b1258f7e2a196f738c6a360c3de
// 10000000000000000
// 1000000000000000000
// Mtec2166cced36276426360a79934fbf49f29f9e48e9d1f06ef4afc4f557aa3767
// 0xf8700102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808001b845f8431ba0fffc3f503ace8a5d0c87efe50cf33ad41e3475459120d9c6fd75bd796b192313a0243d643a799e844ad82382d41cee98137a1d0c5888ff13951919e5e241ab89e0

Expand Down
20 changes: 10 additions & 10 deletions transaction/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func TestObject_Fee_Send(t *testing.T) {
t.Fatal(err)
}

if signedTransaction.Fee().String() != "10000000000000000" {
t.Errorf("Fee want %s, got %s", "10000000000000000", signedTransaction.Fee().String())
if signedTransaction.Fee().String() != "1000000000000000000" {
t.Errorf("Fee want %s, got %s", "1000000000000000000", signedTransaction.Fee().String())
}
}

Expand All @@ -121,8 +121,8 @@ func TestObject_Fee_Payload(t *testing.T) {
t.Fatal(err)
}

if signedTransaction.Fee().String() != "16000000000000000" {
t.Errorf("Fee want %s, got %s", "16000000000000000", signedTransaction.Fee().String())
if signedTransaction.Fee().String() != "1006000000000000000" {
t.Errorf("Fee want %s, got %s", "1006000000000000000", signedTransaction.Fee().String())
}
}

Expand All @@ -137,8 +137,8 @@ func TestObject_Fee_PayloadUTF8(t *testing.T) {
t.Fatal(err)
}

if signedTransaction.Fee().String() != "18000000000000000" {
t.Errorf("Fee want %s, got %s", "18000000000000000", signedTransaction.Fee().String())
if signedTransaction.Fee().String() != "1008000000000000000" {
t.Errorf("Fee want %s, got %s", "1008000000000000000", signedTransaction.Fee().String())
}
}

Expand All @@ -153,8 +153,8 @@ func TestCreateCoinData_Fee_3symbol(t *testing.T) {
t.Fatal(err)
}

if signedTransaction.Fee().String() != "1000000000000000000000000" {
t.Errorf("Fee want %s, got %s", "1000000000000000000000000", signedTransaction.Fee().String())
if signedTransaction.Fee().String() != "100000000000000000000000000" {
t.Errorf("Fee want %s, got %s", "100000000000000000000000000", signedTransaction.Fee().String())
}
}

Expand All @@ -177,9 +177,9 @@ func TestObject_Fee_Multisend(t *testing.T) {
}

fee := signedTransaction.Fee().String()
feeValid := big.NewInt(0).Mul(big.NewInt(30), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18-3), nil)).String()
feeValid := big.NewInt(0).Mul(big.NewInt(30), big.NewInt(1e17)).String()
if fee != feeValid {
t.Errorf("Fee want %s, got %s", fee, feeValid)
t.Errorf("Fee want %s, got %s", feeValid, fee)
}
}

Expand Down
2 changes: 1 addition & 1 deletion transaction/unbond_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestDecode_unbond(t *testing.T) {
t.Fatal(err)
}

if decode.Fee().String() != "200000000000000000" {
if decode.Fee().String() != "20000000000000000000" {
t.Error("unbond transaction fee is invalid", decode.Fee().String())
}
}

0 comments on commit 03465e1

Please sign in to comment.