-
Notifications
You must be signed in to change notification settings - Fork 54
feat: Added programmable_transaction.move and related test #8146
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
miker83z
merged 8 commits into
vm-lang/aa-auth/8116-feature-branch
from
vm-lang/aa-auth/8122-ptb-type-in-move
Sep 2, 2025
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
92cdfd4
feat: added auth_context.move module
theiari b1844da
fix: poolished auth_context.move
theiari 1dcdfb4
refactor: remove auth_context module and related tests, migrate to pr…
theiari f21cdcc
fix: minor changes to programmable_transaction_tests.move
theiari 99d00ea
feat: added auth_context.move
theiari c277896
refactor: changed enum CommandArg to Command
theiari 4a2328c
fix: updated published_api with new move modules
theiari 96411b6
remove comments and fix spelling
miker83z 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
290 changes: 290 additions & 0 deletions
290
crates/iota-framework/packages/iota-framework/sources/auth_context.move
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,290 @@ | ||
| // Copyright (c) Mysten Labs, Inc. | ||
| // Modifications Copyright (c) 2024 IOTA Stiftung | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| module iota::auth_context; | ||
miker83z marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| use std::ascii::String; | ||
|
|
||
| // === Constants === | ||
| const EBadTxHashLength: u64 = 0; | ||
|
|
||
| // === Enums === | ||
|
|
||
| public enum CallArgType has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| PureData(vector<u8>), | ||
| ObjectData(ObjectArgType), | ||
| } | ||
|
|
||
| public enum CommandArgType has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| MoveCall(ProgrammableMoveCall), | ||
| TransferObjects(TransferObjectsData), | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| SplitCoins(SplitCoinsData), | ||
| MergeCoins(MergeCoinsData), | ||
| Publish(PublishData), | ||
| MakeMoveVec(MakeMoveVecData), | ||
| Upgrade(UpgradeData), | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public enum TypeInput has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| BoolType(bool), | ||
| U8Type(bool), | ||
| U16Type(bool), | ||
| U32Type(bool), | ||
| U64Type(bool), | ||
| U128Type(bool), | ||
| U256Type(bool), | ||
| AddressType(bool), | ||
| SignerType(bool), | ||
| // TODO: VectorType(Box<TypeInput>) | ||
| // TODO: StructType(StructInput) | ||
| } | ||
|
|
||
| public enum ArgumentType has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| GasCoin, | ||
| Input(u16), | ||
| Result(u16), | ||
| NestedResult(u16, u16), | ||
| } | ||
|
|
||
| public enum ObjectArgType has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ImmOrOwnedObject(ObjectRef), | ||
| SharedObject(SharedObjectData), | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ReceivingObject(ObjectRef), | ||
| } | ||
|
|
||
| // === Structs === | ||
|
|
||
| public struct CallArg has copy, drop { | ||
| call_type: CallArgType, | ||
| } | ||
|
|
||
| public struct Command has copy, drop { | ||
| command_type: CommandArgType, | ||
| } | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public struct ProgrammableMoveCall has copy, drop { | ||
| package: ID, | ||
| module_name: String, | ||
| function: String, | ||
| type_arguments: vector<std::type_name::TypeName>, | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| arguments: vector<Argument>, | ||
| } | ||
|
|
||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // --- Command Data --- | ||
|
|
||
| public struct TransferObjectsData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| objects: vector<Argument>, | ||
| recipient: Argument, | ||
| } | ||
|
|
||
| public struct SplitCoinsData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| coin: Argument, | ||
| amounts: vector<Argument>, | ||
| } | ||
|
|
||
| public struct MergeCoinsData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| target_coin: Argument, | ||
| coins_to_merge: vector<Argument>, | ||
| } | ||
|
|
||
| public struct PublishData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| package_bytes: vector<vector<u8>>, | ||
| dependencies: vector<ID>, | ||
| } | ||
|
|
||
| public struct MakeMoveVecData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type_input: Option<TypeInput>, | ||
| arguments: vector<Argument>, | ||
| } | ||
|
|
||
| public struct UpgradeData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| modules: vector<vector<u8>>, | ||
| dependencies: vector<ID>, | ||
| package_id: ID, | ||
| upgrade_ticket: Argument, | ||
| } | ||
|
|
||
| public struct Argument has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| argument_type: ArgumentType, | ||
| } | ||
|
|
||
| // --- Helper Structs --- | ||
|
|
||
| public struct NestedResultData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| command_index: u16, | ||
| result_index: u16, | ||
| } | ||
|
|
||
| public struct SharedObjectData has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| id: ID, | ||
| initial_shared_version: SequenceNumber, | ||
| mutable: bool, | ||
| } | ||
|
|
||
| public struct ObjectRef has copy, drop { | ||
| object_id: ID, | ||
| sequence_number: SequenceNumber, | ||
| object_digest: ObjectDigest, | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public struct ObjectDigest has copy, drop { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| digest: Digest, | ||
| } | ||
|
|
||
| public struct SequenceNumber has copy, drop, store { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| value: u64, | ||
| } | ||
|
|
||
| public struct Digest has copy, drop, store { | ||
miker83z marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| bytes: vector<u8>, // Should always be 32 bytes | ||
| } | ||
|
|
||
| // === CallArg Helpers === | ||
|
|
||
| #[test_only] | ||
| public fun new_pure(data: vector<u8>): CallArg { | ||
| CallArg { | ||
| call_type: CallArgType::PureData(data), | ||
| } | ||
| } | ||
|
|
||
| #[test_only] | ||
| public fun new_object(obj: ObjectArgType): CallArg { | ||
| CallArg { | ||
| call_type: CallArgType::ObjectData(obj), | ||
| } | ||
| } | ||
|
|
||
| public fun is_pure_data(arg: &CallArg): bool { | ||
| match (&arg.call_type) { | ||
| CallArgType::PureData(_) => true, | ||
| _ => false, | ||
| } | ||
| } | ||
|
|
||
| public fun is_object_data(arg: &CallArg): bool { | ||
| match (&arg.call_type) { | ||
| CallArgType::ObjectData(_) => true, | ||
| _ => false, | ||
| } | ||
| } | ||
|
|
||
| public fun get_pure_data(arg: &CallArg): &vector<u8> { | ||
| match (&arg.call_type) { | ||
| CallArgType::PureData(data) => data, | ||
| _ => abort EBadTxHashLength, | ||
| } | ||
| } | ||
|
|
||
| public fun get_object_data(arg: &CallArg): &ObjectArgType { | ||
| match (&arg.call_type) { | ||
| CallArgType::ObjectData(obj) => obj, | ||
| _ => abort EBadTxHashLength, | ||
| } | ||
| } | ||
|
|
||
| // === Command Helpers === | ||
|
|
||
| #[test_only] | ||
| public fun new_move_call(call: ProgrammableMoveCall): Command { | ||
| Command { | ||
| command_type: CommandArgType::MoveCall(call), | ||
| } | ||
| } | ||
|
|
||
| #[test_only] | ||
| public fun new_transfer_objects(data: TransferObjectsData): Command { | ||
| Command { | ||
| command_type: CommandArgType::TransferObjects(data), | ||
| } | ||
| } | ||
|
|
||
| #[test_only] | ||
| public fun new_split_coins(data: SplitCoinsData): Command { | ||
| Command { | ||
| command_type: CommandArgType::SplitCoins(data), | ||
| } | ||
| } | ||
|
|
||
| #[test_only] | ||
| public fun new_merge_coins(data: MergeCoinsData): Command { | ||
| Command { | ||
| command_type: CommandArgType::MergeCoins(data), | ||
| } | ||
| } | ||
|
|
||
| #[test_only] | ||
| public fun new_publish_data(data: PublishData): Command { | ||
| Command { | ||
| command_type: CommandArgType::PublishData(data), | ||
| } | ||
| } | ||
|
|
||
| #[test_only] | ||
| public fun new_upgrade_data(data: UpgradeData): Command { | ||
| Command { | ||
| command_type: CommandArgType::UpgradeData(data), | ||
| } | ||
| } | ||
|
|
||
| // === Command Getters === | ||
|
|
||
| public fun get_command_type(command: &Command): CommandArgType { | ||
| command.command_type | ||
| } | ||
|
|
||
| // === ProgrammableMoveCall Getters === | ||
|
|
||
| #[test_only] | ||
| public fun new_programmable_move_call( | ||
| package: ID, | ||
| module_name: String, | ||
| function: String, | ||
| type_arguments: vector<std::type_name::TypeName>, | ||
| arguments: vector<Argument>, | ||
| ): ProgrammableMoveCall { | ||
| ProgrammableMoveCall { | ||
| package, | ||
| module_name, | ||
| function, | ||
| type_arguments, | ||
| arguments, | ||
| } | ||
| } | ||
|
|
||
| public fun get_package_id(call: &ProgrammableMoveCall): ID { | ||
| call.package | ||
| } | ||
|
|
||
| public fun get_module_name(call: &ProgrammableMoveCall): String { | ||
| call.module_name | ||
| } | ||
|
|
||
| public fun get_function_name(call: &ProgrammableMoveCall): String { | ||
| call.function | ||
| } | ||
|
|
||
| public fun get_type_arguments(call: &ProgrammableMoveCall): vector<std::type_name::TypeName> { | ||
| call.type_arguments | ||
| } | ||
|
|
||
| public fun get_arguments(call: &ProgrammableMoveCall): vector<Argument> { | ||
| call.arguments | ||
| } | ||
|
|
||
| // === Argument Helpers === | ||
|
|
||
| #[test_only] | ||
| public fun new_argument(arg_type: ArgumentType): Argument { | ||
| Argument { | ||
| argument_type: arg_type, | ||
| } | ||
| } | ||
|
|
||
| public fun get_argument_type(arg: &Argument): ArgumentType { | ||
| arg.argument_type | ||
| } | ||
|
|
||
| // ==== test-only functions ==== | ||
| // TODO | ||
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.