-
Notifications
You must be signed in to change notification settings - Fork 418
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
966 grants spike #978
Closed
Closed
966 grants spike #978
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3614be6
Add contract authz proto
giansalex 46050f1
Implement contract autorization
giansalex baa5c23
Register contract authz
giansalex ef22770
Add contract-authz tests
giansalex 21110ff
Consume gas for contract authz
giansalex 219a9c7
Add contract authz cli
giansalex 4c485d8
Update cli usage
giansalex 0672c8d
Model spike
alpe 62fcae9
Add max funds limit
alpe 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.wasm.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/wasm/types"; | ||
|
||
// ContractExecutionAuthorization defines authorization for wasm execute. | ||
message ContractExecutionAuthorization { | ||
option (cosmos_proto.implements_interface) = "Authorization"; | ||
|
||
repeated ContractExecutionGrant grants = 1 [ (gogoproto.nullable) = false ]; | ||
|
||
// ContractExecutionGrant a granted execute permission for a single contract | ||
message ContractExecutionGrant { | ||
// Contract is the address of the smart contract | ||
string contract = 1; | ||
|
||
// ExecutionLimit specifies number of executions or spendable amounts | ||
oneof execution_limit { | ||
InfiniteCalls infinite_calls = 2; | ||
MaxCalls max_calls = 3; | ||
MaxFunds max_funds = 4; | ||
} | ||
|
||
// Filter rules to apply | ||
oneof filter { | ||
AcceptedMessageKeysFilter accepted_message_keys = 5; | ||
AllowAllWildcard allow_all_wildcard = 6; | ||
} | ||
} | ||
} | ||
|
||
// ContractMigrationAuthorization defines authorization for wasm contract | ||
// migration. | ||
message ContractMigrationAuthorization { | ||
option (cosmos_proto.implements_interface) = "Authorization"; | ||
|
||
repeated ContractMigrationGrant grants = 1 [ (gogoproto.nullable) = false ]; | ||
|
||
// ContractExecutionGrant a granted migrate permission for a single contract | ||
message ContractMigrationGrant { | ||
// Contract is the address of the smart contract | ||
string contract = 1; | ||
|
||
// MaxExecutions specifies the number of authorized migrations remaining | ||
oneof max_executions { | ||
InfiniteCalls infinite_calls = 2; | ||
MaxCalls max_calls = 3; | ||
} | ||
} | ||
} | ||
|
||
// InfiniteCalls unlimited number of calls | ||
message InfiniteCalls {} | ||
|
||
// MaxCalls limited number of calls | ||
message MaxCalls { | ||
// Remaining number that is decremented on each execution | ||
uint64 remaining = 1; | ||
} | ||
|
||
// MaxFunds defines the max amounts that can be sent to a contract | ||
message MaxFunds { | ||
repeated cosmos.base.v1beta1.Coin amounts = 1 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" | ||
]; | ||
} | ||
|
||
// AllowAllWildcard is a wildcard to allow any type of contract execution | ||
// message | ||
message AllowAllWildcard {} | ||
|
||
// AcceptedMessageKeysFilter accept specific contract message keys in the json | ||
// object that can be executed | ||
message AcceptedMessageKeysFilter { | ||
// Messages is the list of unique keys | ||
repeated string messages = 1; | ||
} |
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
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.
Do we really need this? I would prefer to not provide Infinite(s) but have high MaxCalls instead. Less options for the CLI or other places that display state.