-
Notifications
You must be signed in to change notification settings - Fork 0
Feature: Expose the build_fee_block
#37
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d5dd0f2
feat(wasi): expose the build_fee_block
sephynox 8414766
fix(wasi): better reference alignment
sephynox b4468db
chore: cleanup
sephynox 9d21c9e
fix: require fee block if fees are required
sephynox 11c9a4e
fix(ci): use cargo lock
sephynox f115bce
fix(wasi): java transmit
sephynox a29fdf8
feat(wasm): support wasm as well
sephynox 6e64761
fix(wasm): error handling
sephynox 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 hidden or 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 hidden or 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 hidden or 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
16 changes: 16 additions & 0 deletions
16
...anetwork-client-wasi/bindings/java/src/main/java/network/keeta/wasi/GenerateFeeBlock.java
This file contains hidden or 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,16 @@ | ||
| package network.keeta.wasi; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Factory invoked mid-transmit when {@link TransmitOptions} carries one: build | ||
| * and sign the block paying the fee the temporary-round {@code staple} | ||
| * demands, honoring the {@code feeTokenPriority} preference. Return | ||
| * {@code null} to pay nothing. See | ||
| * {@link UserClient#buildFeeBlock(VoteStaple, Account, Account, List)} for the | ||
| * common implementation. | ||
| */ | ||
| @FunctionalInterface | ||
| public interface GenerateFeeBlock { | ||
| Block.SignedBlock generate(UserClient client, VoteStaple staple, List<Account> feeTokenPriority); | ||
| } |
62 changes: 62 additions & 0 deletions
62
keetanetwork-client-wasi/bindings/java/src/main/java/network/keeta/wasi/TransmitOptions.java
This file contains hidden or 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,62 @@ | ||
| package network.keeta.wasi; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Publish-time options for {@link UserClient#transmit(List, TransmitOptions)}. | ||
| * Fee payment is a {@link GenerateFeeBlock} factory. | ||
| * {@link #withFeeSigner(Account)} and | ||
| * {@link #withFeeBlockFrom(Account, Account)} cover the common shapes. | ||
| */ | ||
| public final class TransmitOptions { | ||
| private final List<Account> feeTokenPriority = new ArrayList<>(); | ||
| private GenerateFeeBlock generateFeeBlock; | ||
|
|
||
| private TransmitOptions() { | ||
| } | ||
|
|
||
| /** Options paying no fee: a vote requiring one fails with {@code FEE_REQUIRED}. */ | ||
| public static TransmitOptions defaults() { | ||
| return new TransmitOptions(); | ||
| } | ||
|
|
||
| /** | ||
| * Append a token to the fee-token preference order, highest priority | ||
| * first, used when a fee is payable in several tokens. | ||
| */ | ||
| public TransmitOptions addFeeTokenPriority(Account token) { | ||
| this.feeTokenPriority.add(token); | ||
| return this; | ||
| } | ||
|
|
||
| /** Pay any required fee from {@code signer}, signing for itself. */ | ||
| public TransmitOptions withFeeSigner(Account signer) { | ||
| return withFeeBlockFrom(signer, signer); | ||
| } | ||
|
|
||
| /** | ||
| * Pay any required fee from {@code account}, signed by {@code signer} | ||
| * (delegated signing, e.g. a storage account whose owner signs). For a | ||
| * payer that signs for itself, prefer {@link #withFeeSigner(Account)}. | ||
| */ | ||
| public TransmitOptions withFeeBlockFrom(Account account, Account signer) { | ||
| this.generateFeeBlock = (client, staple, priority) -> client.buildFeeBlock(staple, account, signer, priority); | ||
| return this; | ||
| } | ||
|
|
||
| /** Install a hand-written fee-block factory for exotic payment flows. */ | ||
| public TransmitOptions withGenerateFeeBlock(GenerateFeeBlock factory) { | ||
| this.generateFeeBlock = factory; | ||
| return this; | ||
| } | ||
|
|
||
| List<Account> feeTokenPriority() { | ||
| return Collections.unmodifiableList(feeTokenPriority); | ||
| } | ||
|
|
||
| GenerateFeeBlock generateFeeBlock() { | ||
| return generateFeeBlock; | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.