Skip to content
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

Separate mock_library into both mock_wallet and mock_faucet #878

Open
phklive opened this issue Sep 17, 2024 · 1 comment
Open

Separate mock_library into both mock_wallet and mock_faucet #878

phklive opened this issue Sep 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@phklive
Copy link
Contributor

phklive commented Sep 17, 2024

Feature description

We have built 1 account interface that exports many procedures related to faucets, wallets, dummy, and more.

We should create 2 different interfaces that would be similar to how accounts would be created by a user.

Goal: Split mock_library into both mock_wallet and mock_faucet for testing

pub fn mock_library(assembler: Assembler) -> Library {
let code = "
use.miden::account
use.miden::faucet
use.miden::tx
export.::miden::contracts::wallets::basic::receive_asset
export.::miden::contracts::wallets::basic::send_asset
export.::miden::contracts::wallets::basic::create_note
export.::miden::contracts::wallets::basic::move_asset_to_note
export.incr_nonce
push.0 swap
# => [value, 0]
exec.account::incr_nonce
# => [0]
end
export.set_item
exec.account::set_item
# => [R', V, 0, 0, 0]
movup.8 drop movup.8 drop movup.8 drop
# => [R', V]
end
export.get_item
exec.account::get_item
movup.8 drop movup.8 drop movup.8 drop
end
export.set_map_item
exec.account::set_map_item
# => [R', V, 0, 0, 0]
movup.8 drop movup.8 drop movup.8 drop
# => [R', V]
end
export.get_map_item
exec.account::get_map_item
end
export.set_code
padw swapw
# => [CODE_COMMITMENT, 0, 0, 0, 0]
exec.account::set_code
# => [0, 0, 0, 0]
end
export.add_asset_to_note
exec.tx::add_asset_to_note
# => [ASSET, note_idx]
end
export.add_asset
exec.account::add_asset
end
export.remove_asset
exec.account::remove_asset
# => [ASSET]
end
export.account_procedure_1
push.1.2
add
end
export.account_procedure_2
push.2.1
sub
end
export.mint
exec.faucet::mint
end
export.burn
exec.faucet::burn
end
";
let source_manager = Arc::new(assembly::DefaultSourceManager::default());
let module = Module::parser(assembly::ast::ModuleKind::Library)
.parse_str(LibraryPath::new("test::account").unwrap(), code, &source_manager)
.unwrap();
assembler.assemble_library(&[*module]).unwrap()
}

Why is this feature needed?

Splitting a monolithic account into 2 account interfaces with sensible procedures

@phklive phklive added the enhancement New feature or request label Sep 17, 2024
@phklive
Copy link
Contributor Author

phklive commented Sep 17, 2024

Related to @bobbinth comment here: #875 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant