Commit a601098
Allow applications to hold native tokens (#2978)
* Use `AccountOwner` as the key for `balances`
Allow applications to hold native tokens.
* Use `AccountOwner` in `ChainInfoRequest`
Allow requesting the balance of an application's account.
* Allow client to query application balances
Update `ChainClient` methods to be able to query an application's
balance.
* Use `AccountOwner` in `OwnerBalance` request
Allow the runtime to request the balance of application accounts.
* Update parameter in runtime's `read_owner_balance`
Prepare to update the WIT API to be able to query an application's
balance.
* Update `read_owner_balance` WIT interface
Use `AccountOwner` as the parameter instead of `Owner`, in order to
support application accounts.
* Derive `Hash` for `AccountOwner`
Prepare to use the type in `SystemMessage`, which has `Hash` derived for
it.
* Use `AccountOwner` inside `MockContractRuntime`
Prepare to change the runtime interface to use `AccountOwner`.
* Use `AccountOwner` inside `MockServiceRuntime`
Prepare to change the runtime interface to use `AccountOwner`.
* Use `AccountOwner` in runtime's `owner_balance`
Update the SDK's runtime API to support querying an application's
balance.
* Use `AccountOwner` in cached `owner_balances`
Prepare the `ServiceRuntime` to use an updated WIT interface that allows
querying the balance of application accounts.
* Use `AccountOwner` in `OwnerBalances` request
Allow the runtime to get a list the balances of application accounts.
* Update return type of `read_owner_balances`
Prepare to update the WIT API to be able to list application balances.
* Update `read_owner_balances` WIT interface
Return `AccountOwner` in order to include application accounts.
* Update runtime's `owner_balances` signature
Include application balances in the result.
* Use `AccountOwner` in cached `balance_owners`
Prepare the `ServiceRuntime` to use an updated WIT interface that allows
querying the balance of application accounts.
* Use `AccountOwner` in `BalanceOwners` request
Allow the runtime to get a list the accounts including application
accounts.
* Update return type of `read_balance_owners`
Prepare to update the WIT API to be able to list application accounts.
* Update `read_balance_owners` WIT interface
Return `AccountOwner` in order to include application accounts.
* Update runtime's `balance_owners` signature
Include application accounts in the result.
* Remove redundant authentication check
The authentication is checked before the message is sent, so it does not
need to be checked again when the message is received, because only the
system application can send its own messages.
Also prepares to allow applications to initiate transfers and claims,
which can't be authorized by the message receiving code.
* Use `AccountOwner` in `SystemMessage`
Prepare to allow applications to transfer native tokens.
* Change `transfer` parameter into `AccountOwner`
Prepare to allow applications to transfer native tokens.
* Verify application token transfers
Ensure that moving an application's account can only be performed by the
application that owns the account.
* Send application ID to execution state actor
Allow it to be used to authenticate transfers.
* Accept application transfers in execution actor
Update the request message to use `AccountOwner` so that the runtime can
request transfers from application accounts.
* Update the runtime trait to support app. transfers
Replace the `Owner` parameter with `AccountOwner`, so that applications
can request transfers from their account.
* Update `transfer` WIT interface
Use `AccountOwner` instead of `Owner` as the source parameter in order
to allow applications to request transfers from their own accounts.
* Update `ContractRuntime::transfer` SDK interface
Use `AccountOwner` to allow applications to transfer native tokens using
the SDK.
* Send authenticated application ID to `claim` func.
Prepare to allow claiming from application accounts.
* Verify application claims
Allow the source account to be an application account, and ensure only
the application that owns that account can access it.
* Send application ID in `ExecutionRequest::Claim`
Allow it to be used to authenticate claims from applications.
* Tweak `Account` constructors documentation
Add documentation links and rephrase a little to provide more details.
* Refactor `FromStr` implementation for `Account`
Prepare to handle more than one colon in the input string.
* Use `AccountOwner` in `Account` type
Update `Account` to also represent application accounts.
* Box some futures to reduce their size
Prevent excessive stack usage by nested futures.
* Support app. accounts in native token example
Remove normalization of owners, and use `AccountOwner` directly.
* Use `AccountOwner` in `SystemExecuteState` helper
Update the `balances` map to support applications.
* Refactor to move test helpers to `test_utils`
Prepare to allow the helpers to be used by a new integration test
module. Also, rename the test helpers for consistency.
* Test `transfer` contract runtime API
Ensure that applications can transfer from their accounts, from the
shared chain account, and from the signer's account.
* Test `claim` contract runtime API
Ensure that applications can claim from their accounts or from the
signer account in remote chains.
* Derive `Arbitrary` for `Amount`
Prepare to use it in property tests.
* Test `read_chain_balance` contract runtime API
Ensure applications can read the chain balance.
* Test `read_owner_balance` contract runtime API
Ensure applications can read the balances of individual accounts.
* Test `read_owner_balances` contract runtime API
Ensure applications can read a list of all account balances.
* Test `read_balance_owners` contract runtime API
Ensure applications can read a list of all accounts.
* Test reading the balance of a missing account
The system API should fallback and return zero in that case.
* Test unauthorized transfers from applications
Ensure that execution fails with the appropriate error.
* Test unauthorized claims from applications
Ensure that execution fails with the appropriate error.
* Add a `create_dummy_query_context` helper function
Allow tests to create a dummy context to test queries.
* Test `read_chain_balance` service runtime API
Ensure applications can read the chain balance.
* Move `test_accounts_strategy` to `test_utils`
Allow the helper function to be used in other tests.
* Test `read_owner_balance` service runtime API
Ensure applications can read the balances of individual accounts.
* Test `read_owner_balances` service runtime API
Ensure applications can read a list of all account balances.
* Test `read_balance_owners` service runtime API
Ensure applications can read a list of all accounts.
* Test reading the balance of a missing account
The system API should fallback and return zero in that case.
* Replace `ok_or_else` with `context`
Simplify the code to generate the error.
Co-authored-by: Andreas Fackler <[email protected]>
Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
* Expect returned accounts to be sorted
The runtime API should be deterministic, so the returned lists of
accounts must be sorted.
Co-authored-by: Andreas Fackler <[email protected]>
Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
---------
Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
Co-authored-by: Andreas Fackler <[email protected]>1 parent 30092c1 commit a601098
File tree
46 files changed
+1511
-330
lines changed- examples
- native-fungible/src
- linera-base/src
- linera-chain/src
- linera-core/src
- chain_worker/state
- client
- unit_tests
- linera-execution
- src
- test_utils
- unit_tests
- wasm
- tests
- linera-rpc
- proto
- src/grpc
- tests
- snapshots
- linera-sdk
- src
- contract
- service
- wit
- linera-service-graphql-client/gql
- linera-service
- src/linera
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
46 files changed
+1511
-330
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
52 | | - | |
53 | 50 | | |
54 | 51 | | |
55 | 52 | | |
| |||
62 | 59 | | |
63 | 60 | | |
64 | 61 | | |
65 | | - | |
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
| |||
130 | 126 | | |
131 | 127 | | |
132 | 128 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | 129 | | |
141 | | - | |
142 | 130 | | |
143 | 131 | | |
144 | | - | |
| 132 | + | |
145 | 133 | | |
146 | 134 | | |
147 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
59 | 55 | | |
60 | 56 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
65 | 60 | | |
66 | 61 | | |
67 | 62 | | |
| |||
73 | 68 | | |
74 | 69 | | |
75 | 70 | | |
76 | | - | |
| 71 | + | |
77 | 72 | | |
78 | 73 | | |
79 | 74 | | |
| |||
84 | 79 | | |
85 | 80 | | |
86 | 81 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 82 | + | |
92 | 83 | | |
93 | 84 | | |
94 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | | - | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
94 | 96 | | |
| 97 | + | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| |||
292 | 296 | | |
293 | 297 | | |
294 | 298 | | |
295 | | - | |
| 299 | + | |
296 | 300 | | |
297 | 301 | | |
298 | 302 | | |
| |||
304 | 308 | | |
305 | 309 | | |
306 | 310 | | |
307 | | - | |
| 311 | + | |
308 | 312 | | |
309 | 313 | | |
310 | 314 | | |
| |||
358 | 362 | | |
359 | 363 | | |
360 | 364 | | |
361 | | - | |
| 365 | + | |
362 | 366 | | |
363 | 367 | | |
364 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
767 | 767 | | |
768 | 768 | | |
769 | 769 | | |
770 | | - | |
| 770 | + | |
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
| |||
776 | 776 | | |
777 | 777 | | |
778 | 778 | | |
779 | | - | |
| 779 | + | |
780 | 780 | | |
781 | 781 | | |
782 | 782 | | |
| |||
793 | 793 | | |
794 | 794 | | |
795 | 795 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
806 | 805 | | |
807 | 806 | | |
808 | 807 | | |
| |||
942 | 941 | | |
943 | 942 | | |
944 | 943 | | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
956 | 954 | | |
957 | 955 | | |
958 | 956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
0 commit comments