-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Events support #27
Merged
Merged
Events support #27
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 27 additions & 0 deletions
27
api/src/main/java/com/strategyobject/substrateclient/api/pallet/balances/AccountData.java
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,27 @@ | ||
package com.strategyobject.substrateclient.api.pallet.balances; | ||
|
||
import com.strategyobject.substrateclient.api.pallet.system.System; | ||
import com.strategyobject.substrateclient.scale.ScaleType; | ||
import com.strategyobject.substrateclient.scale.annotation.Scale; | ||
import com.strategyobject.substrateclient.scale.annotation.ScaleReader; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.math.BigInteger; | ||
|
||
@ScaleReader | ||
@Getter | ||
@Setter | ||
public class AccountData implements System.AccountData { | ||
@Scale(ScaleType.U128.class) | ||
private BigInteger free; | ||
|
||
@Scale(ScaleType.U128.class) | ||
private BigInteger reserved; | ||
|
||
@Scale(ScaleType.U128.class) | ||
private BigInteger miscFrozen; | ||
|
||
@Scale(ScaleType.U128.class) | ||
private BigInteger feeFrozen; | ||
} |
118 changes: 118 additions & 0 deletions
118
api/src/main/java/com/strategyobject/substrateclient/api/pallet/balances/Balances.java
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,118 @@ | ||
package com.strategyobject.substrateclient.api.pallet.balances; | ||
|
||
import com.strategyobject.substrateclient.pallet.annotation.Event; | ||
import com.strategyobject.substrateclient.pallet.annotation.Pallet; | ||
import com.strategyobject.substrateclient.rpc.api.AccountId; | ||
import com.strategyobject.substrateclient.rpc.api.BalanceStatus; | ||
import com.strategyobject.substrateclient.rpc.api.primitives.Balance; | ||
import com.strategyobject.substrateclient.scale.annotation.ScaleReader; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Pallet("Balances") | ||
public interface Balances { | ||
|
||
/** | ||
* An account was created with some free balance. \[account, free_balance\] | ||
*/ | ||
@Event(index = 0) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class Endowed { | ||
private AccountId account; | ||
private Balance freeBalance; | ||
} | ||
|
||
/** | ||
* An account was removed whose balance was non-zero but below ExistentialDeposit, | ||
* resulting in an outright loss. \[account, balance\] | ||
*/ | ||
@Event(index = 1) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class DustLost { | ||
private AccountId account; | ||
private Balance balance; | ||
} | ||
|
||
/** | ||
* Transfer succeeded. \[from, to, value\] | ||
*/ | ||
@Event(index = 2) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class Transfer { | ||
private AccountId from; | ||
private AccountId to; | ||
private Balance value; | ||
} | ||
|
||
/** | ||
* A balance was set by root. \[who, free, reserved\] | ||
*/ | ||
@Event(index = 3) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class BalanceSet { | ||
private AccountId account; | ||
private Balance free; | ||
private Balance reserved; | ||
} | ||
|
||
/** | ||
* Some amount was deposited (e.g. for transaction fees). \[who, deposit\] | ||
*/ | ||
@Event(index = 4) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class Deposit { | ||
private AccountId account; | ||
private Balance value; | ||
} | ||
|
||
/** | ||
* Some balance was reserved (moved from free to reserved). \[who, value\] | ||
*/ | ||
@Event(index = 5) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class Reserved { | ||
private AccountId account; | ||
private Balance value; | ||
} | ||
|
||
/** | ||
* Some balance was unreserved (moved from reserved to free). \[who, value\] | ||
*/ | ||
@Event(index = 6) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class Unreserved { | ||
private AccountId account; | ||
private Balance value; | ||
} | ||
|
||
/** | ||
* Some balance was moved from the reserve of the first account to the second account. | ||
* Final argument indicates the destination balance type. | ||
* \[from, to, balance, destination_status\] | ||
*/ | ||
@Event(index = 7) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class ReserveRepatriated { | ||
private AccountId from; | ||
private AccountId to; | ||
private Balance value; | ||
private BalanceStatus destinationStatus; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
api/src/main/java/com/strategyobject/substrateclient/api/pallet/grandpa/Authority.java
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,20 @@ | ||
package com.strategyobject.substrateclient.api.pallet.grandpa; | ||
|
||
import com.strategyobject.substrateclient.crypto.PublicKey; | ||
import com.strategyobject.substrateclient.scale.ScaleType; | ||
import com.strategyobject.substrateclient.scale.annotation.Scale; | ||
import com.strategyobject.substrateclient.scale.annotation.ScaleReader; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.math.BigInteger; | ||
|
||
@ScaleReader | ||
@Getter | ||
@Setter | ||
public class Authority { | ||
private PublicKey authorityId; | ||
|
||
@Scale(ScaleType.U64.class) | ||
private BigInteger authorityWeight; | ||
} |
41 changes: 41 additions & 0 deletions
41
api/src/main/java/com/strategyobject/substrateclient/api/pallet/grandpa/Grandpa.java
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,41 @@ | ||
package com.strategyobject.substrateclient.api.pallet.grandpa; | ||
|
||
import com.strategyobject.substrateclient.pallet.annotation.Event; | ||
import com.strategyobject.substrateclient.pallet.annotation.Pallet; | ||
import com.strategyobject.substrateclient.scale.annotation.ScaleReader; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
|
||
@Pallet("Grandpa") | ||
public interface Grandpa { | ||
|
||
/** | ||
* New authority set has been applied. \[authority_set\] | ||
*/ | ||
@Event(index = 0) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class NewAuthorities { | ||
private List<Authority> authorityList; | ||
} | ||
|
||
/** | ||
* Current authority set has been paused. | ||
*/ | ||
@Event(index = 1) | ||
@ScaleReader | ||
class Paused { | ||
} | ||
|
||
/** | ||
* Current authority set has been resumed. | ||
*/ | ||
@Event(index = 2) | ||
@ScaleReader | ||
class Resumed { | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
api/src/main/java/com/strategyobject/substrateclient/api/pallet/indices/Indices.java
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,48 @@ | ||
package com.strategyobject.substrateclient.api.pallet.indices; | ||
|
||
import com.strategyobject.substrateclient.pallet.annotation.Event; | ||
import com.strategyobject.substrateclient.pallet.annotation.Pallet; | ||
import com.strategyobject.substrateclient.rpc.api.AccountId; | ||
import com.strategyobject.substrateclient.rpc.api.primitives.AccountIndex; | ||
import com.strategyobject.substrateclient.scale.annotation.ScaleReader; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Pallet("Indices") | ||
public interface Indices { | ||
|
||
/** | ||
* An account index was assigned. \[index, who\] | ||
*/ | ||
@Event(index = 0) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class IndexAssigned { | ||
private AccountId account; | ||
private AccountIndex index; | ||
} | ||
|
||
/** | ||
* An account index has been freed up (unassigned). \[index\] | ||
*/ | ||
@Event(index = 1) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class IndexFreed { | ||
private AccountIndex accountIndex; | ||
} | ||
|
||
/** | ||
* An account index has been frozen to its current account ID. \[index, who\] | ||
*/ | ||
@Event(index = 2) | ||
@Getter | ||
@Setter | ||
@ScaleReader | ||
class IndexFrozen { | ||
private AccountIndex index; | ||
private AccountId account; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could it be registered automatically?
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.
no, unless write a custom scale reader.