Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 96 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"aptos-move/aptos-gas-profiling",
"aptos-move/aptos-gas-schedule",
"aptos-move/aptos-gas-schedule-updator",
"aptos-move/aptos-intent",
"aptos-move/aptos-memory-usage-tracker",
"aptos-move/aptos-native-interface",
"aptos-move/aptos-release-builder",
Expand Down Expand Up @@ -363,6 +364,7 @@ aptos-github-client = { path = "crates/aptos-github-client" }
aptos-global-constants = { path = "config/global-constants" }
aptos-id-generator = { path = "crates/aptos-id-generator" }
aptos-indexer = { path = "crates/indexer" }
aptos-intent = { path = "aptos-move/aptos-intent" }
aptos-indexer-grpc-cache-worker = { path = "ecosystem/indexer-grpc/indexer-grpc-cache-worker" }
aptos-indexer-grpc-data-service = { path = "ecosystem/indexer-grpc/indexer-grpc-data-service" }
aptos-indexer-grpc-data-service-v2 = { path = "ecosystem/indexer-grpc/indexer-grpc-data-service-v2" }
Expand Down
1 change: 1 addition & 0 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ aptos-cached-packages = { workspace = true }
aptos-framework = { workspace = true }
aptos-gas-meter = { workspace = true }
aptos-gas-schedule = { workspace = true, features = ["testing"] }
aptos-intent = { workspace = true }
aptos-move-stdlib = { workspace = true }
aptos-proptest-helpers = { workspace = true }
aptos-transaction-filters = { workspace = true, features = ["fuzzing"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"hash": "",
"sender": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf",
"sequence_number": "0",
"max_gas_amount": "100000000",
"gas_unit_price": "0",
"expiration_timestamp_secs": "18446744073709551615",
"payload": {
"intent_calls": [
{
"function": "0x1::coin::withdraw",
"type_arguments": [
"0x1::aptos_coin::AptosCoin"
],
"arguments": [
"10"
]
},
{
"function": "0x1::coin::coin_to_fungible_asset",
"type_arguments": [
"0x1::aptos_coin::AptosCoin"
],
"arguments": [
{
"call_idx": 0,
"return_idx": 0,
"operation_type": "Move"
}
]
},
{
"function": "0x1::primary_fungible_store::deposit",
"type_arguments": [],
"arguments": [
"0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf",
{
"call_idx": 1,
"return_idx": 0,
"operation_type": "Move"
}
]
}
],
"type": "intent_payload"
},
"signature": {
"public_key": "0xd5a781494d2bf1a174ddffde1e02cb8881cff6dab70e61cbdef393deac0ce639",
"signature": "0xaa3e6ddb3762601932363df9bada2f70b2e00881f3b78a1af66a36f03be7f17ebddff68825800afee07bc7bfdb8231777a20b1bb6ce0056fe7093b4dfe06e20b",
"type": "ed25519_signature"
},
"replay_protection_nonce": null
}
68 changes: 68 additions & 0 deletions api/src/tests/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2579,3 +2579,71 @@ fn gen_string(len: u64) -> String {
fn build_path(path: &str) -> String {
format!("/v1/transactions{}", path)
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_intent_execution_and_simulation() {
use aptos_intent::{BatchArgumentWASM, BatchedFunctionCallBuilder};
use move_core_types::value::MoveValue;

let mut context = new_test_context(current_function_name!());
let account = context.gen_account();
let user_account_tx = context.create_user_account(&account).await;
context.commit_block(&vec![user_account_tx]).await;

let mut builder = BatchedFunctionCallBuilder::single_signer();
let url = context.poem_url();
builder.load_module(url.clone(), "0x1::coin".to_string()).await.unwrap();
builder.load_module(url, "0x1::primary_fungible_store".to_string()).await.unwrap();

let mut returns_1 = builder
.add_batched_call(
"0x1::coin".to_string(),
"withdraw".to_string(),
vec!["0x1::aptos_coin::AptosCoin".to_string()],
vec![
BatchArgumentWASM::new_signer(0),
BatchArgumentWASM::new_bytes(MoveValue::U64(10).simple_serialize().unwrap()),
],
)
.unwrap();
let mut returns_2 = builder
.add_batched_call(
"0x1::coin".to_string(),
"coin_to_fungible_asset".to_string(),
vec!["0x1::aptos_coin::AptosCoin".to_string()],
vec![returns_1.pop().unwrap()],
)
.unwrap();
builder
.add_batched_call(
"0x1::primary_fungible_store".to_string(),
"deposit".to_string(),
vec![],
vec![
BatchArgumentWASM::new_bytes(
MoveValue::Address(account.address())
.simple_serialize()
.unwrap(),
),
returns_2.pop().unwrap(),
],
)
.unwrap();

let script = builder.generate_batched_calls().unwrap();

let txn = account.sign_with_transaction_builder(
context
.transaction_factory()
.payload(aptos_types::transaction::TransactionPayload::Script(bcs::from_bytes::<Script>(&script).unwrap()))
.expiration_timestamp_secs(u64::MAX),
);

let body = bcs::to_bytes(&txn).unwrap();

let resp = context
.expect_status_code(202)
.post_bcs_txn("/transactions", body)
.await;
context.check_golden_output(resp);
}
6 changes: 6 additions & 0 deletions api/test-context/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,12 @@ impl TestContext {
}
}

pub fn poem_url(&self) -> String {
match self.api_specific_config {
ApiSpecificConfig::V1(address) => format!("http://{}/v1", address),
}
}

// Currently we still run our tests with warp.
// https://github.com/aptos-labs/aptos-core/issues/2966
pub fn get_routes_with_poem(
Expand Down
1 change: 1 addition & 0 deletions api/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rust-version = { workspace = true }
anyhow = { workspace = true }
aptos-config = { workspace = true }
aptos-crypto = { workspace = true }
aptos-intent = { workspace = true }
aptos-logger = { workspace = true }
aptos-openapi = { workspace = true }
aptos-resource-viewer = { workspace = true }
Expand Down
Loading